Convert the locale information according to the standard format
authorYoonchan Choi <yc81.choi@samsung.com>
Tue, 16 Apr 2013 02:56:14 +0000 (11:56 +0900)
committerYoonchan Choi <yc81.choi@samsung.com>
Tue, 16 Apr 2013 02:56:14 +0000 (11:56 +0900)
Change-Id: I3e97867ddfc5f5d30804d4dd5243143874cbd745
Signed-off-by: Yoonchan Choi <yc81.choi@samsung.com>
pkgmgr_account/src/account.cpp
src/FScl_AccountManagerUtil.cpp

index 3e439a3..e919d2a 100644 (file)
 // 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)) { \
@@ -37,6 +43,8 @@
        } \
        else {;}
 
+using namespace Tizen::Base;
+using namespace Tizen::Base::Utility;
 
 static const xmlChar _NODE_ACCOUNT_PROVIDER[]                          = "account-provider";
 static const xmlChar _NODE_ICON[]                                                      = "icon";
@@ -163,11 +171,29 @@ int PKGMGR_PARSER_PLUGIN_INSTALL(xmlDocPtr docPtr, const char* packageId)
                                        {
                                                SysLog(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.");
+
+                                               SysLog(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.");
 
                                                SysLog(NID_SCL, "Node: label - %s", pLabel);
-                                               ret = account_type_set_label(accountTypeHandle, reinterpret_cast<char*> (pLabel), reinterpret_cast<char*> (pLang));
+                                               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.");
                                        }
                                }
index 5555a47..19b6027 100644 (file)
@@ -48,6 +48,8 @@ using namespace Tizen::Locales;
 namespace Tizen { namespace Social
 {
 
+static const wchar_t* _DEFAULT_LOCALE = L"en_GB";
+
 bool
 OnAccountTypeLabelReceived(char* pAppId, char* pLabel, char* pLocale, void* pUserData)
 {
@@ -61,17 +63,15 @@ OnAccountTypeLabelReceived(char* pAppId, char* pLabel, char* pLocale, void* pUse
                String localeStr(Locale::LanguageCodeToTwoLetterLanguageCodeString(languageCode));
 
                String countryCodeStr(systemLocale.GetCountryCodeString());
-               countryCodeStr.ToLowerCase();
-               localeStr.Append(L"-");
+               localeStr.Append(L"_");
                localeStr.Append(countryCodeStr);
 
-               String engGbCode(L"en-gb");
                String* pDisplayName = static_cast<String*> (pUserData);
                if (localeStr.Equals(String(pLocale)))
                {
                        *pDisplayName = String(pLabel);
                }
-               else if(engGbCode.Equals(String(pLocale)) && pDisplayName->IsEmpty())
+               else if((String(_DEFAULT_LOCALE)).Equals(String(pLocale)) && pDisplayName->IsEmpty())
                {
                        *pDisplayName = String(pLabel);
                }