Apply fallback apis for langlist.xml and tzlist.ini
authorHokwon Song <hokwon.song@samsung.com>
Wed, 5 Jun 2013 04:50:48 +0000 (13:50 +0900)
committerHokwon Song <hokwon.song@samsung.com>
Wed, 5 Jun 2013 05:24:00 +0000 (14:24 +0900)
Change-Id: Ia16b8b9e6944b79d087d4a8cb066ffb2d45880ed
Signed-off-by: Hokwon Song <hokwon.song@samsung.com>
inc/FLclCalendar.h
src/locales/FLcl_LocaleManagerImpl.cpp

index 0b7fd3e..2d6e30f 100644 (file)
@@ -88,7 +88,7 @@ enum TimeField
        TIME_FIELD_YEAR,                                                /**< Year : 1-based */
        TIME_FIELD_MONTH,                                               /**< Month : 1-based (1~13)*/
        TIME_FIELD_WEEK_OF_YEAR,                                /**< Week of Year : 1-based (1~53) */
-       TIME_FIELD_WEEK_OF_MONTH,                               /**< Week of Month : 1-based (1~5, may be specified as 0) */
+       TIME_FIELD_WEEK_OF_MONTH,                               /**< Week of Month : 1-based (1~6, may be specified as 0) */
        TIME_FIELD_DAY_OF_MONTH,                                /**< Date : 1-based (1~31) */
        TIME_FIELD_DAY_OF_YEAR,                                 /**< Day of Year : 1-based (1~366) */
        TIME_FIELD_DAY_OF_WEEK,                                 /**< Day of Week : 1-based (1~7) */
index 3dab222..f958fdf 100644 (file)
@@ -70,6 +70,7 @@ 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";
 
+#define _FALLBACK_ // It should be removed after checking SLP changes.
 
 Locale
 _LocaleManagerImpl::GetSystemLocale(void)
@@ -128,7 +129,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();
@@ -170,7 +171,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();
                        }
@@ -195,6 +196,49 @@ _LocaleManagerImpl::GetSelectedLanguage(void)
        return language;
 }
 
+// FALLBACk should be removed after checking the SLP change.
+#ifdef _FALLBACK_
+IList*
+_LocaleManagerImpl::GetAvailableLanguagesN(void)
+{
+       std::unique_ptr<IList> pLocaleList (GetAvailableLocalesN());
+       std::unique_ptr<HashMap> pLanguageMap(new (std::nothrow) HashMap(SingleObjectDeleter));
+       SysTryReturn(NID_LCL, pLanguageMap, null, E_OUT_OF_MEMORY,"[%s] Memory allocation failed", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       pLanguageMap->Construct();
+
+       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));
+       pAvailableLanguageList->Construct();
+
+       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));
+
+               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));
+
+                       result r = pLanguageMap->Add(pLanguageCode.get(), pDummyValue.get());
+                       SysTryReturn(NID_LCL, !IsFailed(r), null, E_SYSTEM, "It is failed to make a language map.");
+
+                       std::unique_ptr<String> pLangCode(new (std::nothrow) String(*(pLanguageCode.get())));
+                       r = pAvailableLanguageList->Add(pLangCode.get());
+                       SysTryReturn(NID_LCL, !IsFailed(r), null, E_SYSTEM, "It is failed to make a language list.");
+
+                       pLanguageCode.release();
+                       pDummyValue.release();
+                       pLangCode.release();
+               }
+       }
+
+       SetLastResult(E_SUCCESS);
+       return pAvailableLanguageList.release(); 
+}
+#else
 IList*
 _LocaleManagerImpl::GetAvailableLanguagesN(void)
 {
@@ -235,7 +279,7 @@ _LocaleManagerImpl::GetAvailableLanguagesN(void)
        SetLastResult(E_SUCCESS);
        return pAvailableLanguageList.release();
 }
-
+#endif
 
 IList*
 _LocaleManagerImpl::GetAvailableLanguageLocalesN(void)
@@ -269,7 +313,7 @@ _LocaleManagerImpl::GetAvailableLanguageLocalesN(void)
 
                                if (!pAvailableLanguageList->Contains(*(pLocale.get())))
                                {
-                                       result r = pAvailableLanguageList->Add(*(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();
@@ -311,7 +355,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();
@@ -323,7 +367,272 @@ _LocaleManagerImpl::GetAvailableTimeZonesN(U_ICU_NAMESPACE::StringEnumeration* p
        return pTimeZoneMap.release();
 }
 
+#ifdef _FALLBACK_
+static const int TIMEZONE_MAX = 224;
+static const char* TimeZoneList[TIMEZONE_MAX] =
+{
+       "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"
+}; 
+
+
+IMap*
+_LocaleManagerImpl::GetAvailableTimeZonesN(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();
+}
+#else
 IMap*
 _LocaleManagerImpl::GetAvailableTimeZonesN(void)
 {
@@ -358,7 +667,7 @@ _LocaleManagerImpl::GetAvailableTimeZonesN(void)
                        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, r == E_SUCCESS, null, r,"[%s] It is failed to make the tz list.", GetErrorMessage(r));
                        pTimeZone.release();
                        pDummyValue.release();
@@ -368,7 +677,7 @@ _LocaleManagerImpl::GetAvailableTimeZonesN(void)
        SetLastResult(E_SUCCESS);
        return pTimeZoneMap.release();
 }
-
+#endif
 
 IMap*
 _LocaleManagerImpl::GetAvailableTimeZonesN(int rawOffset)