//
-// Open Service Platform
// Copyright (c) 2013 Samsung Electronics Co., Ltd.
//
// Licensed under the Apache License, Version 2.0 (the License);
// See the License for the specific language governing permissions and
// limitations under the License.
//
+
#include <errno.h>
+#include <new>
+#include <unique_ptr.h>
#include <libxml/parser.h>
#include <libxml/tree.h>
#include <account.h>
#include <account-types.h>
#include <FBaseDataType.h>
+#include <FBaseString.h>
#include <FBaseSysLog.h>
+#include <FBaseUtilStringTokenizer.h>
+#include <FBaseUtilStringUtil.h>
#define _SysTryReturn(NID, condition, returnValue, ...) \
if (!(condition)) { \
} \
else {;}
+using namespace Tizen::Base;
+using namespace Tizen::Base::Utility;
static const xmlChar _NODE_ACCOUNT_PROVIDER[] = "account-provider";
static const xmlChar _NODE_ICON[] = "icon";
static const xmlChar _VALUE_ACCOUNT_SMALL[] = "account-small";
static const xmlChar _VALUE_XHIGH[] = "Xhigh";
+static const char _DEFAULT_LOCALE[] = "default";
extern "C"
__attribute__ ((visibility("default")))
ret = account_type_create(&accountTypeHandle);
if (ret != ACCOUNT_ERROR_NONE || accountTypeHandle == null)
{
- SysLog(NID_SCL, "Memory allocation failed.");
- account_disconnect();
+ ret = account_disconnect();
+ _SysTryReturn(NID_SCL, ret == ACCOUNT_ERROR_NONE, -1, "A system error has occurred.");
+ SysLog(NID_SCL, "Memory allocation failed.");
return -ENOMEM;
}
xmlNodePtr curPtr = xmlFirstElementChild(xmlDocGetRootElement(docPtr));
_SysTryCatch(NID_SCL, curPtr != null, ret = -EINVAL, "Failed to get the element.");
- SysLog(NID_SCL, "Node: %s", curPtr->name);
+ SysSecureLog(NID_SCL, "Node: %s", curPtr->name);
// Get the children nodes
curPtr = curPtr->xmlChildrenNode;
while(curPtr != null)
{
- SysLog(NID_SCL, "Node: %s", curPtr->name);
+ SysSecureLog(NID_SCL, "Node: %s", curPtr->name);
// Node: <account-provider>
if ((!xmlStrcmp(curPtr->name, _NODE_ACCOUNT_PROVIDER)))
xmlChar* pAppIdId = xmlGetProp(curPtr, _ATTRIBUTE_APP_ID);
_SysTryCatch(NID_SCL, pAppIdId != null, ret = -EINVAL, "Failed to get the attribute.");
- SysLog(NID_SCL, "Attribute: appid - %s", pAppIdId);
+ SysSecureLog(NID_SCL, "Attribute: appid - %s", pAppIdId);
ret = account_type_set_app_id(accountTypeHandle, reinterpret_cast<char*> (pAppIdId));
_SysTryCatch(NID_SCL, ret == ACCOUNT_ERROR_NONE, ret = -1, "Failed to set the app ID.");
xmlChar* pMultipleAccountsSupport = xmlGetProp(curPtr, _ATTRIBUTE_MULTIPLE_ACCOUNTS_SUPPORT);
_SysTryCatch(NID_SCL, pMultipleAccountsSupport != null, ret = -EINVAL, "Failed to get the attribute.");
- SysLog(NID_SCL, "Attribute: multiple-accounts-support - %s", pMultipleAccountsSupport);
+ SysSecureLog(NID_SCL, "Attribute: multiple-accounts-support - %s", pMultipleAccountsSupport);
if ((!xmlStrcmp(pMultipleAccountsSupport, _VALUE_TRUE)))
{
ret = account_type_set_multiple_account_support(accountTypeHandle, true);
while (curPtr != NULL)
{
- SysLog(NID_SCL, "Node: %s", curPtr->name);
+ SysSecureLog(NID_SCL, "Node: %s", curPtr->name);
// Node: <icon>
if ((!xmlStrcmp(curPtr->name, _NODE_ICON)))
xmlChar* pSection = xmlGetProp(curPtr, _ATTRIBUTE_SECTION);
_SysTryCatch(NID_SCL, pSection != null, ret = -EINVAL, "Failed to get the attribute.");
- SysLog(NID_SCL, "Attribute: section - %s", pSection);
+ SysSecureLog(NID_SCL, "Attribute: section - %s", pSection);
if ((!xmlStrcmp(pSection, _VALUE_ACCOUNT)))
{
xmlChar* pAccountIcon = xmlNodeListGetString(docPtr, curPtr->xmlChildrenNode, 1);
_SysTryCatch(NID_SCL, pAccountIcon != null, ret = -EINVAL, "Failed to get the value.");
- SysLog(NID_SCL, "Node: icon - %s", pAccountIcon);
+ SysSecureLog(NID_SCL, "Node: icon - %s", pAccountIcon);
ret = account_type_set_icon_path(accountTypeHandle, reinterpret_cast<char*> (pAccountIcon));
_SysTryCatch(NID_SCL, ret == ACCOUNT_ERROR_NONE, ret = -1, "Failed to set the icon path.");
}
xmlChar* pAccountSmallIcon = xmlNodeListGetString(docPtr, curPtr->xmlChildrenNode, 1);
_SysTryCatch(NID_SCL, pAccountSmallIcon != null, ret = -EINVAL, "Failed to get the value.");
- SysLog(NID_SCL, "Node: icon (small) - %s", pAccountSmallIcon);
+ SysSecureLog(NID_SCL, "Node: icon (small) - %s", pAccountSmallIcon);
ret = account_type_set_small_icon_path(accountTypeHandle, reinterpret_cast<char*> (pAccountSmallIcon));
_SysTryCatch(NID_SCL, ret == ACCOUNT_ERROR_NONE, ret = -1, "Failed to set the small icon path.");
}
// Node: <label>
else if ((!xmlStrcmp(curPtr->name, _NODE_LABEL)))
{
- SysLog(NID_SCL, "Node: %s", curPtr->name);
+ SysSecureLog(NID_SCL, "Node: %s", curPtr->name);
// Attribute: xml:lang
xmlChar* pLang = xmlNodeGetLang(curPtr);
if (pLang != null)
{
- SysLog(NID_SCL, "Attribute: xml:lang - %s", pLang);
+ SysSecureLog(NID_SCL, "Attribute: xml:lang - %s", pLang);
+
+ String lang(reinterpret_cast<char*> (pLang));
+
+ StringTokenizer strTok(lang, L"-");
+ String token;
+ String convertedLang;
+
+ strTok.GetNextToken(convertedLang);
+ convertedLang.Append(L"_");
+
+ strTok.GetNextToken(token);
+ token.ToUpper();
+ convertedLang.Append(token);
+
+ std::unique_ptr<ByteBuffer> pConvertedLangBuf(StringUtil::StringToUtf8N(convertedLang));
+ _SysTryCatch(NID_SCL, pConvertedLangBuf != null, ret = -1, "Failed to convert String to Utf8N.");
+ SysSecureLog(NID_SCL, "Attribute: converted lang - %s", pConvertedLangBuf->GetPointer());
+
+ xmlChar* pLabel = xmlNodeListGetString(docPtr, curPtr->xmlChildrenNode, 1);
+ _SysTryCatch(NID_SCL, pLabel != null, ret = -EINVAL, "Failed to get the value.");
+
+ SysSecureLog(NID_SCL, "Node: label - %s", pLabel);
+ ret = account_type_set_label(accountTypeHandle, reinterpret_cast<char*> (pLabel), reinterpret_cast<char*> (pConvertedLangBuf->GetPointer()));
+ _SysTryCatch(NID_SCL, ret == ACCOUNT_ERROR_NONE, ret = -1, "Failed to set the display name.");
+ }
+ else
+ {
xmlChar* pLabel = xmlNodeListGetString(docPtr, curPtr->xmlChildrenNode, 1);
_SysTryCatch(NID_SCL, pLabel != null, ret = -EINVAL, "Failed to get the value.");
- SysLog(NID_SCL, "Node: label - %s", pLabel);
- ret = account_type_set_label(accountTypeHandle, reinterpret_cast<char*> (pLabel), reinterpret_cast<char*> (pLang));
+ SysSecureLog(NID_SCL, "Node: label - %s", pLabel);
+ ret = account_type_set_label(accountTypeHandle, reinterpret_cast<char*> (pLabel), _DEFAULT_LOCALE);
_SysTryCatch(NID_SCL, ret == ACCOUNT_ERROR_NONE, ret = -1, "Failed to set the display name.");
}
}
// Node: <capability>
else if ((!xmlStrcmp(curPtr->name, _NODE_CAPABILITY)))
{
- SysLog(NID_SCL, "Node: %s", curPtr->name);
+ SysSecureLog(NID_SCL, "Node: %s", curPtr->name);
xmlChar* pCapability = xmlNodeListGetString(docPtr, curPtr->xmlChildrenNode, 1);
_SysTryCatch(NID_SCL, pCapability != null, ret = -EINVAL, "Failed to get the value.");
- SysLog(NID_SCL, "Node: capability - %s", pCapability);
+ SysSecureLog(NID_SCL, "Node: capability - %s", pCapability);
ret = account_type_set_provider_feature(accountTypeHandle, reinterpret_cast<char*> (pCapability));
_SysTryCatch(NID_SCL, ret == ACCOUNT_ERROR_NONE, ret = -1, "Failed to set the capability.");
}
xmlNodePtr curPtr = xmlFirstElementChild(xmlDocGetRootElement(docPtr));
_SysTryCatch(NID_SCL, curPtr != null, ret = -EINVAL, "Failed to get the element.");
- SysLog(NID_SCL, "Node: %s", curPtr->name);
+ SysSecureLog(NID_SCL, "Node: %s", curPtr->name);
// Get the children nodes
curPtr = curPtr->xmlChildrenNode;
while(curPtr != null)
{
- SysLog(NID_SCL, "Node: %s", curPtr->name);
+ SysSecureLog(NID_SCL, "Node: %s", curPtr->name);
// Node: <account-provider>
if ((!xmlStrcmp(curPtr->name, _NODE_ACCOUNT_PROVIDER)))
xmlChar* pAppIdId = xmlGetProp(curPtr, _ATTRIBUTE_APP_ID);
_SysTryCatch(NID_SCL, pAppIdId != null, ret = -EINVAL, "Failed to get the attribute.");
- SysLog(NID_SCL, "Attribute: appid - %s", pAppIdId);
+ SysSecureLog(NID_SCL, "Attribute: appid - %s", pAppIdId);
ret = account_delete_from_db_by_package_name(reinterpret_cast<char*> (pAppIdId));
_SysTryCatch(NID_SCL, ret == ACCOUNT_ERROR_NONE, ret = -1, "A system error has occurred.");