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