Fix memory leaks in Locales
[platform/framework/native/appfw.git] / src / locales / FLcl_LocaleManagerImpl.cpp
1 //
2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 // http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17
18 /**
19 * @file         FLcl_LocaleManagerImpl.cpp
20 * @brief        This is the implementation file for _LocaleManagerImpl class.
21 */
22 #include <unique_ptr.h>
23 #include <limits.h>
24 #include <runtime_info.h>
25 #include <unicode/calendar.h>
26 #include <unicode/timezone.h>
27 #include <libxml/parser.h>
28 #include <libxml/tree.h>
29
30 #include <FIo.h>
31 #include <FBaseSysLog.h>
32 #include <FBase_StringConverter.h>
33
34 #include "FLcl_LocaleImpl.h"
35 #include "FLcl_TimeZoneImpl.h"
36 #include "FLcl_LocaleManagerImpl.h"
37
38
39 using namespace Tizen::Base;
40 using namespace Tizen::Base::Utility;
41 using namespace Tizen::Base::Collection;
42 using namespace Tizen::Io;
43
44 namespace Tizen { namespace Locales
45 {
46 static const char* LANGUAGE_LIST_FILE_PATH ="/opt/data/setting/langlist.xml";
47 static const char* TIMEZONE_LIST_FILE_PATH = "/opt/data/setting/tzlist.ini";
48 static const int TIMEZONE_MAX = 224;
49 static const char* TimeZoneList[TIMEZONE_MAX] =
50 {
51         "Africa/Abidjan",
52         "Africa/Accra",
53         "Africa/Addis_Ababa",
54         "Africa/Algiers",
55         "Africa/Asmara",
56         "Africa/Bamako",
57         "Africa/Bangui",
58         "Africa/Bissau",
59         "Africa/Cairo",
60         "Africa/Casablanca",
61         "Africa/Conakry",
62         "Africa/Dakar",
63         "Africa/Dar_es_Salaam",
64         "Africa/Djibouti",
65         "Africa/Douala",
66         "Africa/Freetown",
67         "Africa/Gaborone",
68         "Africa/Harare",
69         "Africa/Johannesburg",
70         "Africa/Kampala",
71         "Africa/Khartoum",
72         "Africa/Kinshasa",
73         "Africa/Lagos",
74         "Africa/Luanda",
75         "Africa/Lubumbashi",
76         "Africa/Lusaka",
77         "Africa/Malabo",
78         "Africa/Maputo",
79         "Africa/Mogadishu",
80         "Africa/Monrovia",
81         "Africa/Nairobi",
82         "Africa/Ndjamena",
83         "Africa/Niamey",
84         "Africa/Nouakchott",
85         "Africa/Ouagadougou",
86         "Africa/Tripoli",
87         "Africa/Tunis",
88         "America/Anchorage",
89         "America/Antigua",
90         "America/Argentina/Buenos_Aires",
91         "America/Asuncion",
92         "America/Barbados",
93         "America/Belize",
94         "America/Bogota",
95         "America/Caracas",
96         "America/Cayenne",
97         "America/Chicago",
98         "America/Costa_Rica",
99         "America/Denver",
100         "America/Detroit",
101         "America/El_Salvador",
102         "America/Godthab",
103         "America/Guadeloupe",
104         "America/Guatemala",
105         "America/Guayaquil",
106         "America/Guyana",
107         "America/Halifax",
108         "America/Havana",
109         "America/Indiana/Indianapolis",
110         "America/Jamaica",
111         "America/Kentucky/Louisville",
112         "America/La_Paz",
113         "America/Lima",
114         "America/Los_Angeles",
115         "America/Managua",
116         "America/Marigot",
117         "America/Martinique",
118         "America/Mazatlan",
119         "America/Mexico_City",
120         "America/Montevideo",
121         "America/Montreal",
122         "America/New_York",
123         "America/Nome",
124         "America/Panama",
125         "America/Paramaribo",
126         "America/Phoenix",
127         "America/Port-au-Prince",
128         "America/Puerto_Rico",
129         "America/Recife",
130         "America/Regina",
131         "America/Santiago",
132         "America/Santo_Domingo",
133         "America/Sao_Paulo",
134         "America/St_Johns",
135         "America/St_Thomas",
136         "America/Tegucigalpa",
137         "America/Tijuana",
138         "America/Toronto",
139         "America/Tortola",
140         "America/Vancouver",
141         "America/Winnipeg",
142         "Asia/Aden",
143         "Asia/Almaty",
144         "Asia/Amman",
145         "Asia/Anadyr",
146         "Asia/Ashgabat",
147         "Asia/Baghdad",
148         "Asia/Bahrain",
149         "Asia/Baku",
150         "Asia/Bangkok",
151         "Asia/Beirut",
152         "Asia/Bishkek",
153         "Asia/Colombo",
154         "Asia/Damascus",
155         "Asia/Dhaka",
156         "Asia/Dubai",
157         "Asia/Dushanbe",
158         "Asia/Ho_Chi_Minh",
159         "Asia/Hong_Kong",
160         "Asia/Hovd",
161         "Asia/Irkutsk",
162         "Asia/Istanbul",
163         "Asia/Jakarta",
164         "Asia/Jayapura",
165         "Asia/Jerusalem",
166         "Asia/Kabul",
167         "Asia/Kamchatka",
168         "Asia/Karachi",
169         "Asia/Kathmandu",
170         "Asia/Kolkata",
171         "Asia/Krasnoyarsk",
172         "Asia/Kuala_Lumpur",
173         "Asia/Kuwait",
174         "Asia/Macau",
175         "Asia/Magadan",
176         "Asia/Makassar",
177         "Asia/Manila",
178         "Asia/Muscat",
179         "Asia/Novokuznetsk",
180         "Asia/Novosibirsk",
181         "Asia/Omsk",
182         "Asia/Phnom_Penh",
183         "Asia/Pyongyang",
184         "Asia/Qatar",
185         "Asia/Rangoon",
186         "Asia/Riyadh",
187         "Asia/Sakhalin",
188         "Asia/Seoul",
189         "Asia/Shanghai",
190         "Asia/Singapore",
191         "Asia/Taipei",
192         "Asia/Tashkent",
193         "Asia/Tbilisi",
194         "Asia/Tehran",
195         "Asia/Tokyo",
196         "Asia/Ulan_Bator",
197         "Asia/Vladivostok",
198         "Asia/Yakutsk",
199         "Asia/Yekaterinburg",
200         "Asia/Yerevan",
201         "Atlantic/Azores",
202         "Atlantic/Canary",
203         "Atlantic/Reykjavik",
204         "Atlantic/South_Georgia",
205         "Australia/Adelaide",
206         "Australia/Brisbane",
207         "Australia/Canberra",
208         "Australia/Darwin",
209         "Australia/Hobart",
210         "Australia/Melbourne",
211         "Australia/Perth",
212         "Australia/Sydney",
213         "CST6CDT",
214         "EST5EDT",
215         "Europe/Amsterdam",
216         "Europe/Athens",
217         "Europe/Belgrade",
218         "Europe/Berlin",
219         "Europe/Bratislava",
220         "Europe/Brussels",
221         "Europe/Bucharest",
222         "Europe/Budapest",
223         "Europe/Chisinau",
224         "Europe/Copenhagen",
225         "Europe/Dublin",
226         "Europe/Helsinki",
227         "Europe/Istanbul",
228         "Europe/Kaliningrad",
229         "Europe/Kiev",
230         "Europe/Lisbon",
231         "Europe/Ljubljana",
232         "Europe/London",
233         "Europe/Luxembourg",
234         "Europe/Madrid",
235         "Europe/Malta",
236         "Europe/Minsk",
237         "Europe/Moscow",
238         "Europe/Paris",
239         "Europe/Podgorica",
240         "Europe/Prague",
241         "Europe/Riga",
242         "Europe/Rome",
243         "Europe/Samara",
244         "Europe/San_Marino",
245         "Europe/Skopje",
246         "Europe/Sofia",
247         "Europe/Stockholm",
248         "Europe/Tallinn",
249         "Europe/Vaduz",
250         "Europe/Vienna",
251         "Europe/Vilnius",
252         "Europe/Volgograd",
253         "Europe/Warsaw",
254         "Europe/Zagreb",
255         "Europe/Zurich",
256         "Indian/Antananarivo",
257         "Indian/Chagos",
258         "Indian/Maldives",
259         "Indian/Mauritius",
260         "Indian/Reunion",
261         "MST7MDT",
262         "Pacific/Auckland",
263         "Pacific/Easter",
264         "Pacific/Fiji",
265         "Pacific/Galapagos",
266         "Pacific/Guam",
267         "Pacific/Honolulu",
268         "Pacific/Midway",
269         "Pacific/Noumea",
270         "Pacific/Pago_Pago",
271         "Pacific/Tahiti",
272         "Pacific/Tarawa",
273         "Pacific/Tongatapu",
274         "PST8PDT"
275 };
276
277 Locale
278 _LocaleManagerImpl::GetSystemLocale(void)
279 {
280         char* pRegionPtr;
281         if (runtime_info_get_value_string(RUNTIME_INFO_KEY_REGION, &pRegionPtr) == RUNTIME_INFO_ERROR_NONE)
282         {
283                 SetLastResult(E_SUCCESS);
284
285                 Locale ospLoc = _LocaleImpl(pRegionPtr).GetOspLocale();
286                 free(pRegionPtr);
287                 return ospLoc;
288         }
289
290         SetLastResult(E_SYSTEM);
291         return Locale(LANGUAGE_INVALID, COUNTRY_INVALID, null);
292 }
293
294 IList*
295 _LocaleManagerImpl::GetAvailableLocalesN(void)
296 {
297         result r = E_SUCCESS;
298         int count = 0;
299         const U_ICU_NAMESPACE::Locale* pIcuLocaleList = U_ICU_NAMESPACE::Locale::getAvailableLocales(count);
300         SysTryReturn(NID_LCL, count > 0, null, E_SYSTEM,
301                                 "[%s] The method cannot proceed due to a severe system error.", GetErrorMessage(E_SYSTEM));
302
303         std::unique_ptr<LinkedList, AllElementsDeleter> pAvailableLocaleList(new (std::nothrow) LinkedList());
304         SysTryReturn(NID_LCL, pAvailableLocaleList, null, E_OUT_OF_MEMORY,
305                                 "[%s] Memory allocation failed", GetErrorMessage(E_OUT_OF_MEMORY));
306
307         for (int i = 0; i < count; i++)
308         {
309                 SysTryReturn(NID_LCL, (pIcuLocaleList + i) != null, null, E_SYSTEM,
310                                         "[%s] The method cannot proceed due to a severe system error.",GetErrorMessage(E_SYSTEM));
311
312                 Locale ospLocale = _LocaleImpl(*(pIcuLocaleList + i)).GetOspLocale();
313                 if (_LocaleImpl::IsSupported(ospLocale))
314                 {
315                         std::unique_ptr< Locale > pLocale(new (std::nothrow) Locale(ospLocale));
316                         SysTryReturn(NID_LCL, pLocale, null, E_OUT_OF_MEMORY,
317                                                 "[%s] Memory allocation failed", GetErrorMessage(E_OUT_OF_MEMORY));
318                         if (!pAvailableLocaleList->Contains(*(pLocale.get())))
319                         {
320                                 r = pAvailableLocaleList->Add(*(pLocale.get()));
321                                 SysTryReturn(NID_LCL, !IsFailed(r), null, E_SYSTEM, "It is failed to make the locale list");
322                                 pLocale.release();
323                         }
324                 }
325         }
326
327         SetLastResult(E_SUCCESS);
328         return pAvailableLocaleList.release();
329 }
330
331 String
332 _LocaleManagerImpl::GetSelectedLanguage(void)
333 {
334         char* pLanguagePtr;
335
336         int ret = runtime_info_get_value_string(RUNTIME_INFO_KEY_LANGUAGE, &pLanguagePtr);
337         SysTryReturn(NID_LCL, ret == RUNTIME_INFO_ERROR_NONE, String(), E_SYSTEM,
338                         "[%s] The method cannot proceed due to a severe system error.", GetErrorMessage(E_SYSTEM));
339         String language(_LocaleImpl(pLanguagePtr).GetLanguageCodeString(false));
340         free(pLanguagePtr);
341
342         return language;
343 }
344
345 IList*
346 _LocaleManagerImpl::GetAvailableLanguagesN(void)
347 {
348         xmlDocPtr doc = null;
349         xmlNodePtr cur = null;
350
351         std::unique_ptr<ArrayList, AllElementsDeleter> pAvailableLanguageList(new (std::nothrow) ArrayList());
352         SysTryCatch(NID_LCL, pAvailableLanguageList, null, E_OUT_OF_MEMORY,"[%s] Memory allocation failed", GetErrorMessage(E_OUT_OF_MEMORY));
353
354         doc = xmlParseFile(LANGUAGE_LIST_FILE_PATH);
355         SysTryCatch(NID_LCL, doc != null, , E_FILE_NOT_FOUND, "[E_FILE_NOT_FOUND] It is failed to get the langlist from the resource.");
356
357         cur = xmlDocGetRootElement(doc);
358         SysTryCatch(NID_LCL, cur != null, , E_EMPTY_BODY, "[E_EMPTY_BODY] It is empty document.");
359         SysTryCatch(NID_LCL, xmlStrcmp(cur->name, (const xmlChar *) "langlist") == 0, , E_INVALID_CONTENT, "[E_INVALID_CONTENT] The document is wrong type");
360
361         cur = cur->xmlChildrenNode;
362
363         pAvailableLanguageList->Construct();
364
365         for (xmlNodePtr cur_node = cur; cur_node; cur_node = cur_node->next)
366         {
367                 if (cur_node->type == XML_ELEMENT_NODE)
368                 {
369                         char* pLocId = (char*)xmlGetProp(cur_node, (const xmlChar *)"id");
370                         Locale loc = _LocaleImpl(pLocId).GetOspLocale();
371                         std::unique_ptr<String> pLanguageLocaleID(new (std::nothrow) String(loc.GetLanguageCodeString()));
372                         SysTryCatch(NID_LCL, pLanguageLocaleID, null, E_OUT_OF_MEMORY,"[%s] Memory allocation failed",GetErrorMessage(E_OUT_OF_MEMORY));
373
374                         result r = pAvailableLanguageList->Add(pLanguageLocaleID.get());
375                         SysTryCatch(NID_LCL, r == E_SUCCESS, null, E_SYSTEM,
376                                         "[%s] It is failed to add a locale string [%ls].", GetErrorMessage(E_SYSTEM), pLanguageLocaleID->GetPointer());
377                         pLanguageLocaleID.release();
378                 }
379         }
380
381         SetLastResult(E_SUCCESS);
382
383         if (doc)
384         {
385                 xmlFreeDoc(doc);
386         }
387
388         return pAvailableLanguageList.release();
389
390 CATCH:
391         if (doc)
392         {
393                 xmlFreeDoc(doc);
394         }
395         SysLog(NID_LCL, "It is calling fallback api.");
396         return GetAvailableLanguagesFallbackN();
397 }
398
399
400 IList*
401 _LocaleManagerImpl::GetAvailableLanguagesFallbackN(void)
402 {
403         std::unique_ptr<IList, AllElementsDeleter> pLocaleList (GetAvailableLocalesN());
404         std::unique_ptr<HashMap> pLanguageMap(new (std::nothrow) HashMap());
405
406         SysTryReturn(NID_LCL, pLanguageMap, null, E_OUT_OF_MEMORY,"[%s] Memory allocation failed", GetErrorMessage(E_OUT_OF_MEMORY));
407
408         pLanguageMap->Construct();
409
410         for (int i = 0; i < pLocaleList->GetCount() ; i++)
411         {
412                 Locale* pLocale = (Locale*)pLocaleList->GetAt(i);
413                 std::unique_ptr<String> pLanguageCode(new (std::nothrow) String(pLocale->GetLanguageCodeString()));
414                 SysTryReturn(NID_LCL, pLanguageCode, null, E_OUT_OF_MEMORY,"[%s] Memory allocation failed", GetErrorMessage(E_OUT_OF_MEMORY));
415
416                 if (!pLanguageMap->ContainsKey(*pLanguageCode))
417                 {
418                         std::unique_ptr<String> pDummyValue(new (std::nothrow) String());
419                         SysTryReturn(NID_LCL, pDummyValue, null, E_OUT_OF_MEMORY,"[%s] Memory allocation failed", GetErrorMessage(E_OUT_OF_MEMORY));
420
421                         result r = pLanguageMap->Add(*(pLanguageCode.get()), *(pDummyValue.get()));
422                         SysTryReturn(NID_LCL, !IsFailed(r), null, E_SYSTEM, "It is failed to make a language list.");
423                         pLanguageCode.release();
424                         pDummyValue.release();
425                 }
426         }
427
428         IList* pAvailableLanguageList;
429         pAvailableLanguageList = pLanguageMap->GetKeysN();
430         SetLastResult(E_SUCCESS);
431         pLanguageMap->RemoveAll();
432         return pAvailableLanguageList;
433 }
434
435
436 IMap*
437 _LocaleManagerImpl::GetAvailableTimeZonesN(U_ICU_NAMESPACE::StringEnumeration* pIcuTZStrList)
438 {
439         SysTryReturn(NID_LCL, pIcuTZStrList, null, E_SYSTEM,
440                                 "[%s] The method cannot proceed due to a severe system error.",GetErrorMessage(E_SYSTEM));
441
442         std::unique_ptr<HashMap, AllElementsDeleter> pTimeZoneMap(new (std::nothrow) HashMap());
443
444         SysTryReturn(NID_LCL, pTimeZoneMap, null, E_OUT_OF_MEMORY,
445                         "[%s] Memory allocation failed", GetErrorMessage(E_OUT_OF_MEMORY));
446         pTimeZoneMap->Construct();
447         result r = E_SUCCESS;
448         int resultLength = -1;
449         UErrorCode ec = U_ZERO_ERROR;
450         const char* pIcuTZStr = pIcuTZStrList->next(&resultLength, ec);
451         IMap* pTZMap = GetAvailableTimeZonesN();
452
453         r = GetLastResult();
454         SysTryReturn(NID_LCL, pTZMap, null, r, "[%s] Fail to get available time zone list", GetErrorMessage(r));
455
456         while (pIcuTZStr != null)
457         {
458                 std::unique_ptr< String > pTimeZone(new (std::nothrow) String(pIcuTZStr));
459                 SysTryReturn(NID_LCL, pTimeZone, null, E_OUT_OF_MEMORY,
460                                         "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
461                 if (!pTimeZoneMap->ContainsKey(*(pTimeZone.get())) && pTZMap->ContainsKey(*(pTimeZone.get())))
462                 {
463                         std::unique_ptr< String > pDummyValue(new  (std::nothrow) String());
464                         SysTryReturn(NID_LCL, pDummyValue, null, E_OUT_OF_MEMORY,"[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
465                         r = pTimeZoneMap->Add(*(pTimeZone.get()), *(pDummyValue.get()));
466                         if (IsFailed(r))
467                         {
468                                 pTZMap->RemoveAll();
469                                 delete pTZMap;
470                                 SetLastResult(E_SYSTEM);
471                                 return null;
472                         }
473                         pTimeZone.release();
474                         pDummyValue.release();
475                 }
476
477                 pIcuTZStr = pIcuTZStrList->next(&resultLength, ec);
478         }
479         SetLastResult(E_SUCCESS);
480         pTZMap->RemoveAll();
481         delete pTZMap;
482         return pTimeZoneMap.release();
483 }
484
485
486 IMap*
487 _LocaleManagerImpl::GetAvailableTimeZonesN(void)
488 {
489         File file;
490         String tzFilePath(TIMEZONE_LIST_FILE_PATH);
491         result r = E_SUCCESS;
492
493         std::unique_ptr<HashMap, AllElementsDeleter> pTimeZoneMap(new (std::nothrow) HashMap());
494         SysTryCatch(NID_LCL, pTimeZoneMap, null, E_OUT_OF_MEMORY,
495                         "[%s] Memory allocation failed", GetErrorMessage(E_OUT_OF_MEMORY));
496         r = file.Construct(tzFilePath, "r");
497         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.");
498
499         pTimeZoneMap->Construct();
500
501         do
502         {
503                 std::unique_ptr<String> pTimeZone(new (std::nothrow) String());
504                 SysTryCatch(NID_LCL, pTimeZone, null, E_OUT_OF_MEMORY,
505                                 "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
506                 r = file.Read(*(pTimeZone.get()));
507                 if ( r == E_END_OF_FILE)
508                 {
509                         break;
510                 }
511                 SysTryCatch(NID_LCL, r == E_SUCCESS, , r, "[%s] It is failed to read the tzlist.", GetErrorMessage(r));
512                 pTimeZone->Replace(L"\n", L"\0");
513
514                 if (!pTimeZoneMap->ContainsKey(*(pTimeZone.get())))
515                 {
516                         std::unique_ptr<String> pDummyValue(new (std::nothrow) String());
517                         SysTryCatch(NID_LCL, pDummyValue, null, E_OUT_OF_MEMORY,
518                                         "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
519
520                         r = pTimeZoneMap->Add(*(pTimeZone.get()), *(pDummyValue.get()));
521                         SysTryCatch(NID_LCL, r == E_SUCCESS, , r,"[%s] It is failed to add the tz into the tz map.", GetErrorMessage(r));
522                         pTimeZone.release();
523                         pDummyValue.release();
524                 }
525         }while (1);
526
527         SetLastResult(E_SUCCESS);
528         return pTimeZoneMap.release();
529
530 CATCH:
531         return GetAvailableTimeZonesFallbackN();
532 }
533
534
535 IMap*
536 _LocaleManagerImpl::GetAvailableTimeZonesFallbackN(void)
537 {
538         std::unique_ptr<HashMap, AllElementsDeleter> pTimeZoneMap(new (std::nothrow) HashMap());
539         SysTryReturn(NID_LCL, pTimeZoneMap, null, E_OUT_OF_MEMORY,
540                         "[%s] Memory allocation failed", GetErrorMessage(E_OUT_OF_MEMORY));
541
542         result r = E_SUCCESS;
543         int index = 0;
544                 
545         pTimeZoneMap->Construct();
546         
547         do
548         {
549                 std::unique_ptr< String > pTimeZone(new (std::nothrow) String(TimeZoneList[index++]));
550                 SysTryReturn(NID_LCL, pTimeZone, null, E_OUT_OF_MEMORY,
551                         "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
552
553                 if (!pTimeZoneMap->ContainsKey(*(pTimeZone.get())))
554                 {
555                         std::unique_ptr< String > pDummyValue (new  (std::nothrow) String());
556                         SysTryReturn(NID_LCL, pDummyValue, null, E_OUT_OF_MEMORY,"[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
557
558                         r = pTimeZoneMap->Add(*(pTimeZone.get()), *(pDummyValue.get()));
559                         SysTryReturn(NID_LCL, !IsFailed(r), null, E_SYSTEM, "It is failed to make Timezone list.");
560                         
561                         pTimeZone.release();
562                         pDummyValue.release();
563                 }
564         }while (index < TIMEZONE_MAX);
565
566         SetLastResult(E_SUCCESS);
567         return pTimeZoneMap.release();
568 }
569
570
571 IMap*
572 _LocaleManagerImpl::GetAvailableTimeZonesN(int rawOffset)
573 {
574         return GetAvailableTimeZonesN(U_ICU_NAMESPACE::TimeZone::createEnumeration(rawOffset * _TimeZoneImpl::ONE_MIN_IN_MILLISEC));
575 }
576
577
578 TimeZone
579 _LocaleManagerImpl::GetSystemTimeZone(void)
580 {
581         char tz[PATH_MAX + 1];
582         int len = readlink("/opt/etc/localtime", tz, PATH_MAX);
583
584         SysTryReturn(NID_LCL, len > 0, TimeZone(-1, ""), E_SYSTEM, "It is failed to get System Time Zone");
585         tz[len] = '\0';
586         SysTryReturn(NID_LCL, len > 20, TimeZone(-1, ""), E_SYSTEM, "It is failed to get System Time Zone");
587
588         String tzId(tz + 20);
589         SysLog(NID_LCL, "System TimeZone id [%ls]", tzId.GetPointer());
590         TimeZone timeZone;
591         result r = Tizen::Locales::TimeZone::GetTimeZone(tzId, timeZone);
592         SysTryReturn(NID_LCL, r == E_SUCCESS, TimeZone(-1, ""), r, "[%s] error occurs.", GetErrorMessage(r));
593         return timeZone;
594 }
595
596 result
597 _LocaleManagerImpl::IsSupportedLocale(const Tizen::Locales::Locale& locale, bool& isSupportedLocale)
598 {
599         isSupportedLocale = _LocaleImpl::IsSupported(locale);
600         return E_SUCCESS;
601 }
602
603 };
604 };      // Tizen::Locales