Merge "Change API for locale" into tizen_2.2
authorDuyoung Jang <duyoung.jang@samsung.com>
Wed, 2 Oct 2013 06:48:18 +0000 (06:48 +0000)
committerGerrit Code Review <gerrit@gerrit.vlan144.tizendev.org>
Wed, 2 Oct 2013 06:48:18 +0000 (06:48 +0000)
src/app/inc/FAppPkg_PackageParser.h
src/app/package/FAppPkg_PackageParser.cpp

index c445f57..09ab5b9 100755 (executable)
@@ -145,6 +145,7 @@ private:
 
        bool ParseAppAttribute(_PackageXmlAttribute* pAttr, bool isUiApp);
        bool FindElement(const char* pName);
+       result GetLocale(Tizen::Base::String& value);
 
 private:
        _PackageInfoImpl* __pPackageInfoImpl;
index 043ba99..1083428 100755 (executable)
@@ -20,6 +20,8 @@
 
 #include <libxml/parserInternals.h>
 #include <system_info.h>
+#include <runtime_info.h>
+#include <unicode/locid.h>
 
 #include <FAppPkgPackageAppInfo.h>
 #include <FBaseSysLog.h>
@@ -29,7 +31,6 @@
 #include <FAppPkg_PackageInfoImpl.h>
 #include <FAppPkg_PackageParser.h>
 #include <FBase_StringConverter.h>
-#include <FSys_SettingInfoImpl.h>
 
 using namespace Tizen::App;
 using namespace Tizen::Base;
@@ -41,6 +42,18 @@ using namespace Tizen::System;
 namespace Tizen { namespace App { namespace Package
 {
 
+struct charDeleter
+{
+       void operator()(char* pValue)
+       {
+               if(pValue != null)
+               {
+                       free(pValue);
+                       pValue = null;
+               }
+       }
+};
+
 _PackageXmlAttribute::_PackageXmlAttribute(void)
 :__pName(null)
 ,__pValue(null)
@@ -753,7 +766,7 @@ _PackageParser::OnDisplayNamesEndElement(void)
        SysTryReturn(NID_APP, pNameList, false, E_SYSTEM, "pNameList is null.");
 
        String locale;
-       result r = _SettingInfoImpl::GetValue(L"http://tizen.org/setting/locale.language", locale);
+       result r = GetLocale(locale);
        SysTryReturn(NID_APP, !IsFailed(r), false, E_SYSTEM, "GetValue(http://tizen.org/setting/locale.language) failed.");
 
        locale.Replace(L"_", L"-");
@@ -1160,4 +1173,35 @@ _PackageParser::FindElement(const char* pName)
        return res;
 }
 
+result
+_PackageParser::GetLocale(String& value)
+{
+       int errorCode = 0;
+       result r = E_SUCCESS;
+       char* pTemp = null;
+       std::unique_ptr<char, charDeleter> pLocale(null);
+
+       errorCode = runtime_info_get_value_string(RUNTIME_INFO_KEY_LANGUAGE, &pTemp);
+       SysTryReturnResult(NID_APP, (errorCode == RUNTIME_INFO_ERROR_NONE) && (pTemp != null), E_SYSTEM, "runtime_info_get_value_string() failed.");
+
+       pLocale.reset(pTemp);
+       icu::Locale icuLocale(pLocale.get());
+       String localeString(icuLocale.getISO3Language());
+       String languageScriptTmp(icuLocale.getScript());
+
+       if (!languageScriptTmp.IsEmpty())
+       {
+               String languageScript;
+               languageScriptTmp.ToLowerCase(languageScript);
+               localeString.Append(L"-");
+               localeString.Append(languageScript);
+       }
+       localeString.Append("_");
+       localeString.Append(icuLocale.getCountry());
+
+       value = localeString;
+
+       return r;
+}
+
 } } } // Tizen::App::Package