Merge "Update deprecated libprivilege-control API functions." into tizen
[platform/framework/native/appfw.git] / src / locales / FLcl_LocaleManagerImpl.cpp
index 52c4aa6..427213f 100644 (file)
 #include <runtime_info.h>
 #include <unicode/calendar.h>
 #include <unicode/timezone.h>
+#include <unicode/locid.h>
 #include <libxml/parser.h>
 #include <libxml/tree.h>
+#include <vconf.h>
 
 #include <FIo.h>
 #include <FBaseSysLog.h>
@@ -41,241 +43,35 @@ using namespace Tizen::Base::Utility;
 using namespace Tizen::Base::Collection;
 using namespace Tizen::Io;
 
-namespace Tizen { namespace Locales
+struct FreeXmlDoc
 {
-static const char* LANGUAGE_LIST_FILE_PATH ="/opt/data/setting/langlist.xml";
-static const char* TIMEZONE_LIST_FILE_PATH = "/opt/data/setting/tzlist.ini";
-static const char* CLOCALE_LIST_FILE_PATH = "/opt/usr/etc/clocale.list";
+       void operator ()(xmlDoc* p)
+       {
+               if (p != null)
+               {
+                       xmlFreeDoc(p);
+               }
+       }
+};
 
-static const int TIMEZONE_MAX = 224;
-static const char* TimeZoneList[TIMEZONE_MAX] =
+struct FreeCharPtr
 {
-       "Africa/Abidjan",
-       "Africa/Accra",
-       "Africa/Addis_Ababa",
-       "Africa/Algiers",
-       "Africa/Asmara",
-       "Africa/Bamako",
-       "Africa/Bangui",
-       "Africa/Bissau",
-       "Africa/Cairo",
-       "Africa/Casablanca",
-       "Africa/Conakry",
-       "Africa/Dakar",
-       "Africa/Dar_es_Salaam",
-       "Africa/Djibouti",
-       "Africa/Douala",
-       "Africa/Freetown",
-       "Africa/Gaborone",
-       "Africa/Harare",
-       "Africa/Johannesburg",
-       "Africa/Kampala",
-       "Africa/Khartoum",
-       "Africa/Kinshasa",
-       "Africa/Lagos",
-       "Africa/Luanda",
-       "Africa/Lubumbashi",
-       "Africa/Lusaka",
-       "Africa/Malabo",
-       "Africa/Maputo",
-       "Africa/Mogadishu",
-       "Africa/Monrovia",
-       "Africa/Nairobi",
-       "Africa/Ndjamena",
-       "Africa/Niamey",
-       "Africa/Nouakchott",
-       "Africa/Ouagadougou",
-       "Africa/Tripoli",
-       "Africa/Tunis",
-       "America/Anchorage",
-       "America/Antigua",
-       "America/Argentina/Buenos_Aires",
-       "America/Asuncion",
-       "America/Barbados",
-       "America/Belize",
-       "America/Bogota",
-       "America/Caracas",
-       "America/Cayenne",
-       "America/Chicago",
-       "America/Costa_Rica",
-       "America/Denver",
-       "America/Detroit",
-       "America/El_Salvador",
-       "America/Godthab",
-       "America/Guadeloupe",
-       "America/Guatemala",
-       "America/Guayaquil",
-       "America/Guyana",
-       "America/Halifax",
-       "America/Havana",
-       "America/Indiana/Indianapolis",
-       "America/Jamaica",
-       "America/Kentucky/Louisville",
-       "America/La_Paz",
-       "America/Lima",
-       "America/Los_Angeles",
-       "America/Managua",
-       "America/Marigot",
-       "America/Martinique",
-       "America/Mazatlan",
-       "America/Mexico_City",
-       "America/Montevideo",
-       "America/Montreal",
-       "America/New_York",
-       "America/Nome",
-       "America/Panama",
-       "America/Paramaribo",
-       "America/Phoenix",
-       "America/Port-au-Prince",
-       "America/Puerto_Rico",
-       "America/Recife",
-       "America/Regina",
-       "America/Santiago",
-       "America/Santo_Domingo",
-       "America/Sao_Paulo",
-       "America/St_Johns",
-       "America/St_Thomas",
-       "America/Tegucigalpa",
-       "America/Tijuana",
-       "America/Toronto",
-       "America/Tortola",
-       "America/Vancouver",
-       "America/Winnipeg",
-       "Asia/Aden",
-       "Asia/Almaty",
-       "Asia/Amman",
-       "Asia/Anadyr",
-       "Asia/Ashgabat",
-       "Asia/Baghdad",
-       "Asia/Bahrain",
-       "Asia/Baku",
-       "Asia/Bangkok",
-       "Asia/Beirut",
-       "Asia/Bishkek",
-       "Asia/Colombo",
-       "Asia/Damascus",
-       "Asia/Dhaka",
-       "Asia/Dubai",
-       "Asia/Dushanbe",
-       "Asia/Ho_Chi_Minh",
-       "Asia/Hong_Kong",
-       "Asia/Hovd",
-       "Asia/Irkutsk",
-       "Asia/Istanbul",
-       "Asia/Jakarta",
-       "Asia/Jayapura",
-       "Asia/Jerusalem",
-       "Asia/Kabul",
-       "Asia/Kamchatka",
-       "Asia/Karachi",
-       "Asia/Kathmandu",
-       "Asia/Kolkata",
-       "Asia/Krasnoyarsk",
-       "Asia/Kuala_Lumpur",
-       "Asia/Kuwait",
-       "Asia/Macau",
-       "Asia/Magadan",
-       "Asia/Makassar",
-       "Asia/Manila",
-       "Asia/Muscat",
-       "Asia/Novokuznetsk",
-       "Asia/Novosibirsk",
-       "Asia/Omsk",
-       "Asia/Phnom_Penh",
-       "Asia/Pyongyang",
-       "Asia/Qatar",
-       "Asia/Rangoon",
-       "Asia/Riyadh",
-       "Asia/Sakhalin",
-       "Asia/Seoul",
-       "Asia/Shanghai",
-       "Asia/Singapore",
-       "Asia/Taipei",
-       "Asia/Tashkent",
-       "Asia/Tbilisi",
-       "Asia/Tehran",
-       "Asia/Tokyo",
-       "Asia/Ulan_Bator",
-       "Asia/Vladivostok",
-       "Asia/Yakutsk",
-       "Asia/Yekaterinburg",
-       "Asia/Yerevan",
-       "Atlantic/Azores",
-       "Atlantic/Canary",
-       "Atlantic/Reykjavik",
-       "Atlantic/South_Georgia",
-       "Australia/Adelaide",
-       "Australia/Brisbane",
-       "Australia/Canberra",
-       "Australia/Darwin",
-       "Australia/Hobart",
-       "Australia/Melbourne",
-       "Australia/Perth",
-       "Australia/Sydney",
-       "CST6CDT",
-       "EST5EDT",
-       "Europe/Amsterdam",
-       "Europe/Athens",
-       "Europe/Belgrade",
-       "Europe/Berlin",
-       "Europe/Bratislava",
-       "Europe/Brussels",
-       "Europe/Bucharest",
-       "Europe/Budapest",
-       "Europe/Chisinau",
-       "Europe/Copenhagen",
-       "Europe/Dublin",
-       "Europe/Helsinki",
-       "Europe/Istanbul",
-       "Europe/Kaliningrad",
-       "Europe/Kiev",
-       "Europe/Lisbon",
-       "Europe/Ljubljana",
-       "Europe/London",
-       "Europe/Luxembourg",
-       "Europe/Madrid",
-       "Europe/Malta",
-       "Europe/Minsk",
-       "Europe/Moscow",
-       "Europe/Paris",
-       "Europe/Podgorica",
-       "Europe/Prague",
-       "Europe/Riga",
-       "Europe/Rome",
-       "Europe/Samara",
-       "Europe/San_Marino",
-       "Europe/Skopje",
-       "Europe/Sofia",
-       "Europe/Stockholm",
-       "Europe/Tallinn",
-       "Europe/Vaduz",
-       "Europe/Vienna",
-       "Europe/Vilnius",
-       "Europe/Volgograd",
-       "Europe/Warsaw",
-       "Europe/Zagreb",
-       "Europe/Zurich",
-       "Indian/Antananarivo",
-       "Indian/Chagos",
-       "Indian/Maldives",
-       "Indian/Mauritius",
-       "Indian/Reunion",
-       "MST7MDT",
-       "Pacific/Auckland",
-       "Pacific/Easter",
-       "Pacific/Fiji",
-       "Pacific/Galapagos",
-       "Pacific/Guam",
-       "Pacific/Honolulu",
-       "Pacific/Midway",
-       "Pacific/Noumea",
-       "Pacific/Pago_Pago",
-       "Pacific/Tahiti",
-       "Pacific/Tarawa",
-       "Pacific/Tongatapu",
-       "PST8PDT"
+       void operator ()(char* p)
+       {
+               if (p != null)
+               {
+                       free(p);
+               }
+       }
 };
 
+namespace Tizen { namespace Locales
+{
+static const char* LANGUAGE_LIST_FILE_PATH ="/opt/usr/data/setting/langlist.xml";
+static const char* TIMEZONE_LIST_FILE_PATH = "/opt/usr/data/clock/tzlist.ini";
+static const char* CLOCALE_LIST_FILE_PATH = "/opt/usr/etc/clocale.list";
+
+
 Locale
 _LocaleManagerImpl::GetSystemLocale(void)
 {
@@ -293,6 +89,21 @@ _LocaleManagerImpl::GetSystemLocale(void)
        return Locale(LANGUAGE_INVALID, COUNTRY_INVALID, null);
 }
 
+U_ICU_NAMESPACE::Locale
+_LocaleManagerImpl::GetSystemIcuLocale(void)
+{
+       char* pRegionPtr;
+       if (runtime_info_get_value_string(RUNTIME_INFO_KEY_REGION, &pRegionPtr) == RUNTIME_INFO_ERROR_NONE)
+       {
+               SetLastResult(E_SUCCESS);
+               U_ICU_NAMESPACE::Locale locale(pRegionPtr);
+
+               free(pRegionPtr);
+               return locale;
+       }
+       return U_ICU_NAMESPACE::Locale();
+}
+
 
 IMap*
 _LocaleManagerImpl::GetAvailableEglibcLocaesN(void)
@@ -333,7 +144,7 @@ _LocaleManagerImpl::GetAvailableEglibcLocaesN(void)
                        SysTryReturn(NID_LCL, pDummyValue, null, E_OUT_OF_MEMORY,
                                "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
 
-                       r = pClocaleMap->Add(*(pClocaleId.get()), *(pDummyValue.get()));
+                       r = pClocaleMap->Add(pClocaleId.get(), pDummyValue.get());
                        SysTryReturn(NID_LCL, r == E_SUCCESS, null, r,
                                "[%s] It is failed to add the clocale id into the clocale map.", GetErrorMessage(r));
                        pClocaleId.release();
@@ -375,7 +186,7 @@ _LocaleManagerImpl::GetAvailableLocalesN(void)
 
                        if (!pAvailableLocaleList->Contains(*(pLocale.get())) && pClocaleMap->ContainsKey(localeId))
                        {
-                               r = pAvailableLocaleList->Add(*(pLocale.get()));
+                               r = pAvailableLocaleList->Add(pLocale.get());
                                SysTryReturn(NID_LCL, !IsFailed(r), null, E_SYSTEM, "It is failed to make the locale list");
                                pLocale.release();
                        }
@@ -403,18 +214,17 @@ _LocaleManagerImpl::GetSelectedLanguage(void)
 IList*
 _LocaleManagerImpl::GetAvailableLanguagesN(void)
 {
-       xmlDocPtr doc = null;
-       xmlNodePtr cur = null;
+       std::unique_ptr<ArrayList> pAvailableLanguageList(new (std::nothrow) ArrayList(SingleObjectDeleter));
+       SysTryReturn(NID_LCL, pAvailableLanguageList, null, E_OUT_OF_MEMORY,"[%s] Memory allocation failed", GetErrorMessage(E_OUT_OF_MEMORY));
 
-       std::unique_ptr<ArrayList, AllElementsDeleter> pAvailableLanguageList(new (std::nothrow) ArrayList());
-       SysTryCatch(NID_LCL, pAvailableLanguageList, null, E_OUT_OF_MEMORY,"[%s] Memory allocation failed", GetErrorMessage(E_OUT_OF_MEMORY));
+       xmlNodePtr cur = null;
+       std::unique_ptr< xmlDoc, FreeXmlDoc > pDoc(xmlParseFile(LANGUAGE_LIST_FILE_PATH));
 
-       doc = xmlParseFile(LANGUAGE_LIST_FILE_PATH);
-       SysTryCatch(NID_LCL, doc != null, , E_FILE_NOT_FOUND, "[E_FILE_NOT_FOUND] It is failed to get the langlist from the resource.");
+       SysTryReturn(NID_LCL, pDoc, null, E_FILE_NOT_FOUND, "[E_FILE_NOT_FOUND] It is failed to get the langlist from the resource.");
 
-       cur = xmlDocGetRootElement(doc);
-       SysTryCatch(NID_LCL, cur != null, , E_EMPTY_BODY, "[E_EMPTY_BODY] It is empty document.");
-       SysTryCatch(NID_LCL, xmlStrcmp(cur->name, (const xmlChar *) "langlist") == 0, , E_INVALID_CONTENT, "[E_INVALID_CONTENT] The document is wrong type");
+       cur = xmlDocGetRootElement(pDoc.get());
+       SysTryReturn(NID_LCL, cur != null, null, E_EMPTY_BODY, "[E_EMPTY_BODY] It is empty document.");
+       SysTryReturn(NID_LCL, xmlStrcmp(cur->name, (const xmlChar *) "langlist") == 0, null, E_INVALID_CONTENT, "[E_INVALID_CONTENT] The document is wrong type");
 
        cur = cur->xmlChildrenNode;
 
@@ -424,70 +234,68 @@ _LocaleManagerImpl::GetAvailableLanguagesN(void)
        {
                if (cur_node->type == XML_ELEMENT_NODE)
                {
-                       char* pLocId = (char*)xmlGetProp(cur_node, (const xmlChar *)"id");
-                       Locale loc = _LocaleImpl(pLocId).GetOspLocale();
+                       std::unique_ptr < char, FreeCharPtr > pLocId((char*)xmlGetProp(cur_node, (const xmlChar *)"id"));
+                       Locale loc = _LocaleImpl(pLocId.get()).GetOspLocale();
                        std::unique_ptr<String> pLanguageLocaleID(new (std::nothrow) String(loc.GetLanguageCodeString()));
-                       SysTryCatch(NID_LCL, pLanguageLocaleID, null, E_OUT_OF_MEMORY,"[%s] Memory allocation failed",GetErrorMessage(E_OUT_OF_MEMORY));
+                       SysTryReturn(NID_LCL, pLanguageLocaleID, null, E_OUT_OF_MEMORY,"[%s] Memory allocation failed",GetErrorMessage(E_OUT_OF_MEMORY));
 
-                       result r = pAvailableLanguageList->Add(pLanguageLocaleID.get());
-                       SysTryCatch(NID_LCL, r == E_SUCCESS, null, E_SYSTEM,
+                       if (!pAvailableLanguageList->Contains(*(pLanguageLocaleID.get())))
+                       {
+                               result r = pAvailableLanguageList->Add(pLanguageLocaleID.get());
+                               SysTryReturn(NID_LCL, r == E_SUCCESS, null, E_SYSTEM,
                                        "[%s] It is failed to add a locale string [%ls].", GetErrorMessage(E_SYSTEM), pLanguageLocaleID->GetPointer());
-                       pLanguageLocaleID.release();
+                               pLanguageLocaleID.release();
+                       }
                }
        }
 
        SetLastResult(E_SUCCESS);
-
-       if (doc)
-       {
-               xmlFreeDoc(doc);
-       }
-
        return pAvailableLanguageList.release();
-
-CATCH:
-       if (doc)
-       {
-               xmlFreeDoc(doc);
-       }
-       SysLog(NID_LCL, "It is calling fallback api.");
-       return GetAvailableLanguagesFallbackN();
 }
 
-
 IList*
-_LocaleManagerImpl::GetAvailableLanguagesFallbackN(void)
+_LocaleManagerImpl::GetAvailableLanguageLocalesN(void)
 {
-       std::unique_ptr<IList, AllElementsDeleter> pLocaleList (GetAvailableLocalesN());
-       std::unique_ptr<HashMap> pLanguageMap(new (std::nothrow) HashMap());
+       std::unique_ptr<ArrayList> pAvailableLanguageList(new (std::nothrow) ArrayList(SingleObjectDeleter));
+       SysTryReturn(NID_LCL, pAvailableLanguageList, null, E_OUT_OF_MEMORY,"[%s] Memory allocation failed", GetErrorMessage(E_OUT_OF_MEMORY));
 
-       SysTryReturn(NID_LCL, pLanguageMap, null, E_OUT_OF_MEMORY,"[%s] Memory allocation failed", GetErrorMessage(E_OUT_OF_MEMORY));
+       xmlNodePtr cur = null;
+       std::unique_ptr< xmlDoc, FreeXmlDoc > pDoc(xmlParseFile(LANGUAGE_LIST_FILE_PATH));
+       SysTryReturn(NID_LCL, pDoc != null, null, E_FILE_NOT_FOUND, "[E_FILE_NOT_FOUND] It is failed to get the langlist from the resource.");
 
-       pLanguageMap->Construct();
+       cur = xmlDocGetRootElement(pDoc.get());
+       SysTryReturn(NID_LCL, cur != null, null, E_EMPTY_BODY, "[E_EMPTY_BODY] It is empty document.");
+       SysTryReturn(NID_LCL, xmlStrcmp(cur->name, (const xmlChar *) "langlist") == 0, null, E_INVALID_CONTENT, "[E_INVALID_CONTENT] The document is wrong type");
 
-       for (int i = 0; i < pLocaleList->GetCount() ; i++)
-       {
-               Locale* pLocale = (Locale*)pLocaleList->GetAt(i);
-               std::unique_ptr<String> pLanguageCode(new (std::nothrow) String(pLocale->GetLanguageCodeString()));
-               SysTryReturn(NID_LCL, pLanguageCode, null, E_OUT_OF_MEMORY,"[%s] Memory allocation failed", GetErrorMessage(E_OUT_OF_MEMORY));
+       cur = cur->xmlChildrenNode;
 
-               if (!pLanguageMap->ContainsKey(*pLanguageCode))
-               {
-                       std::unique_ptr<String> pDummyValue(new (std::nothrow) String());
-                       SysTryReturn(NID_LCL, pDummyValue, null, E_OUT_OF_MEMORY,"[%s] Memory allocation failed", GetErrorMessage(E_OUT_OF_MEMORY));
+       pAvailableLanguageList->Construct();
 
-                       result r = pLanguageMap->Add(*(pLanguageCode.get()), *(pDummyValue.get()));
-                       SysTryReturn(NID_LCL, !IsFailed(r), null, E_SYSTEM, "It is failed to make a language list.");
-                       pLanguageCode.release();
-                       pDummyValue.release();
+       for (xmlNodePtr cur_node = cur; cur_node; cur_node = cur_node->next)
+       {
+               if (cur_node->type == XML_ELEMENT_NODE)
+               {
+                       std::unique_ptr< char, FreeCharPtr> pLocId((char*)xmlGetProp(cur_node, (const xmlChar *)"id"));
+                       Locale loc = _LocaleImpl(pLocId.get()).GetOspLocale();
+                       if (_LocaleImpl::IsSupported(loc))
+                       {
+                               std::unique_ptr< Locale > pLocale(new (std::nothrow) Locale(loc));
+                               SysTryReturn(NID_LCL, pLocale, null, E_OUT_OF_MEMORY,
+                                       "[%s] Memory allocation failed",GetErrorMessage(E_OUT_OF_MEMORY));
+
+                               if (!pAvailableLanguageList->Contains(*(pLocale.get())))
+                               {
+                                       result r = pAvailableLanguageList->Add(pLocale.get());
+                                       SysTryReturn(NID_LCL, r == E_SUCCESS, null, E_SYSTEM,
+                                               "[%s] It is failed to add a locale string [%s].", GetErrorMessage(E_SYSTEM), pLocId.get());
+                                       pLocale.release();
+                               }
+                       }
                }
        }
 
-       IList* pAvailableLanguageList;
-       pAvailableLanguageList = pLanguageMap->GetKeysN();
        SetLastResult(E_SUCCESS);
-       pLanguageMap->RemoveAll();
-       return pAvailableLanguageList;
+       return pAvailableLanguageList.release();
 }
 
 
@@ -519,7 +327,7 @@ _LocaleManagerImpl::GetAvailableTimeZonesN(U_ICU_NAMESPACE::StringEnumeration* p
                {
                        std::unique_ptr< String > pDummyValue(new  (std::nothrow) String());
                        SysTryReturn(NID_LCL, pDummyValue, null, E_OUT_OF_MEMORY,"[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
-                        r = pTimeZoneMap->Add(*(pTimeZone.get()), *(pDummyValue.get()));
+                        r = pTimeZoneMap->Add(pTimeZone.get(), pDummyValue.get());
                        SysTryReturn(NID_LCL, !IsFailed(r), null, E_SYSTEM, "[E_SYSTEM] It is failed to add a TZ into Map.");
                        pTimeZone.release();
                        pDummyValue.release();
@@ -540,34 +348,34 @@ _LocaleManagerImpl::GetAvailableTimeZonesN(void)
        result r = E_SUCCESS;
 
        std::unique_ptr<HashMap> pTimeZoneMap(new (std::nothrow) HashMap(SingleObjectDeleter));
-       SysTryCatch(NID_LCL, pTimeZoneMap, null, E_OUT_OF_MEMORY,
+       SysTryReturn(NID_LCL, pTimeZoneMap, null, E_OUT_OF_MEMORY,
                        "[%s] Memory allocation failed", GetErrorMessage(E_OUT_OF_MEMORY));
        r = file.Construct(tzFilePath, "r");
-       SysTryCatch(NID_LCL, r == E_SUCCESS, ,E_FILE_NOT_FOUND, "[E_FILE_NOT_FOUND] It is failed to get the tzlist from the ini file.");
+       SysTryReturn(NID_LCL, r == E_SUCCESS, null, E_FILE_NOT_FOUND, "[E_FILE_NOT_FOUND] It is failed to get the tzlist from the ini file.");
 
        pTimeZoneMap->Construct();
 
        do
        {
                std::unique_ptr<String> pTimeZone(new (std::nothrow) String());
-               SysTryCatch(NID_LCL, pTimeZone, null, E_OUT_OF_MEMORY,
+               SysTryReturn(NID_LCL, pTimeZone, null, E_OUT_OF_MEMORY,
                                "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
                r = file.Read(*(pTimeZone.get()));
                if ( r == E_END_OF_FILE)
                {
                        break;
                }
-               SysTryCatch(NID_LCL, r == E_SUCCESS, , r, "[%s] It is failed to read the tzlist.", GetErrorMessage(r));
+               SysTryReturn(NID_LCL, r == E_SUCCESS, null, r, "[%s] It is failed to read the tzlist.", GetErrorMessage(r));
                pTimeZone->Replace(L"\n", L"\0");
 
                if (!pTimeZoneMap->ContainsKey(*(pTimeZone.get())))
                {
                        std::unique_ptr<String> pDummyValue(new (std::nothrow) String());
-                       SysTryCatch(NID_LCL, pDummyValue, null, E_OUT_OF_MEMORY,
+                       SysTryReturn(NID_LCL, pDummyValue, null, E_OUT_OF_MEMORY,
                                        "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
 
-                       r = pTimeZoneMap->Add(*(pTimeZone.get()), *(pDummyValue.get()));
-                       SysTryCatch(NID_LCL, r == E_SUCCESS, , r,"[%s] It is failed to make the tz list.", GetErrorMessage(r));
+                       r = pTimeZoneMap->Add(pTimeZone.get(), pDummyValue.get());
+                       SysTryReturn(NID_LCL, r == E_SUCCESS, null, r,"[%s] It is failed to make the tz list.", GetErrorMessage(r));
                        pTimeZone.release();
                        pDummyValue.release();
                }
@@ -575,45 +383,6 @@ _LocaleManagerImpl::GetAvailableTimeZonesN(void)
 
        SetLastResult(E_SUCCESS);
        return pTimeZoneMap.release();
-
-CATCH:
-       return GetAvailableTimeZonesFallbackN();
-}
-
-
-IMap*
-_LocaleManagerImpl::GetAvailableTimeZonesFallbackN(void)
-{
-       std::unique_ptr<HashMap> pTimeZoneMap(new (std::nothrow) HashMap(SingleObjectDeleter));
-       SysTryReturn(NID_LCL, pTimeZoneMap, null, E_OUT_OF_MEMORY,
-                       "[%s] Memory allocation failed", GetErrorMessage(E_OUT_OF_MEMORY));
-
-       result r = E_SUCCESS;
-       int index = 0;
-               
-       pTimeZoneMap->Construct();
-       
-       do
-       {
-               std::unique_ptr< String > pTimeZone(new (std::nothrow) String(TimeZoneList[index++]));
-               SysTryReturn(NID_LCL, pTimeZone, null, E_OUT_OF_MEMORY,
-                       "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
-
-               if (!pTimeZoneMap->ContainsKey(*(pTimeZone.get())))
-               {
-                       std::unique_ptr< String > pDummyValue (new  (std::nothrow) String());
-                       SysTryReturn(NID_LCL, pDummyValue, null, E_OUT_OF_MEMORY,"[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
-
-                       r = pTimeZoneMap->Add(*(pTimeZone.get()), *(pDummyValue.get()));
-                       SysTryReturn(NID_LCL, !IsFailed(r), null, E_SYSTEM, "It is failed to make Timezone list.");
-                       
-                       pTimeZone.release();
-                       pDummyValue.release();
-               }
-       }while (index < TIMEZONE_MAX);
-
-       SetLastResult(E_SUCCESS);
-       return pTimeZoneMap.release();
 }
 
 
@@ -630,27 +399,50 @@ _LocaleManagerImpl::GetAvailableTimeZonesN(int rawOffset)
 TimeZone
 _LocaleManagerImpl::GetSystemTimeZone(void)
 {
-       char tz[PATH_MAX + 1];
-       int len = readlink("/opt/etc/localtime", tz, PATH_MAX);
+       char* pTZPath = null;
+       char* pTZID = null;
+       TimeZone timeZone;
+        DateTime utcTime;
+        struct tm gmTime;
+        struct tm*  pGmTime = null;
+        time_t currTime = time(null);
+       result r = E_SUCCESS;
+       ssize_t nLen = -1;
 
-       SysTryReturn(NID_LCL, len > 0, TimeZone(-1, ""), E_SYSTEM, "It is failed to get System Time Zone");
-       tz[len] = '\0';
-       SysTryReturn(NID_LCL, len > 20, TimeZone(-1, ""), E_SYSTEM, "It is failed to get System Time Zone");
+       pTZPath = (char*)malloc(sizeof(char) * 256);
+       SysTryCatch(NID_LCL, pTZPath, , E_OUT_OF_MEMORY, "It is not enough memory.");
 
-       String tzId(tz + 20);
-       SysLog(NID_LCL, "System TimeZone id [%ls]", tzId.GetPointer());
+       nLen = readlink("/opt/etc/localtime", pTZPath, 255);
 
-       TimeZone timeZone;
-       DateTime utcTime;
-       struct tm* pGmTime = null;
-       time_t currTime = 0;
-       time(&currTime);
-       pGmTime = gmtime(&currTime);
-       utcTime.SetValue(pGmTime->tm_year + 1900, pGmTime->tm_mon + 1, pGmTime->tm_mday, pGmTime->tm_hour, pGmTime->tm_min, pGmTime->tm_sec);
-
-       result r = Tizen::Locales::TimeZone::GetTimeZone(tzId, utcTime, timeZone);
-       SysTryReturn(NID_LCL, r == E_SUCCESS, TimeZone(-1, ""), r, "[%s] error occurs.", GetErrorMessage(r));
+       if (nLen > 20)
+       {
+               pTZPath[nLen] = '\0';
+               pTZID = pTZPath + 20;
+       }
+       else
+       {
+               pTZID = vconf_get_str(VCONFKEY_SETAPPL_TIMEZONE_ID);
+               SysTryCatch(NID_LCL, pTZID, , E_SYSTEM, "It is failed to get System Time Zone.");
+               free(pTZPath);
+               pTZPath = pTZID;
+       }
+
+       pGmTime = gmtime_r(&currTime, &gmTime);
+       SysTryCatch(NID_LCL, pGmTime, , E_SYSTEM, "It is failed to convert the time value to UTC time.");
+
+       utcTime.SetValue(gmTime.tm_year + 1900, gmTime.tm_mon + 1, gmTime.tm_mday, gmTime.tm_hour, gmTime.tm_min, gmTime.tm_sec);
+
+       r = Tizen::Locales::TimeZone::GetTimeZone(String(pTZID), utcTime, timeZone);
+       SysTryCatch(NID_LCL, r == E_SUCCESS, , r, "[%s] error occurs.", GetErrorMessage(r));
+       free(pTZPath);
        return timeZone;
+
+CATCH:
+       if (pTZPath)
+       {
+               free(pTZPath);
+       }
+       return TimeZone(-1, "");
 }
 
 result