2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
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
8 // http://www.apache.org/licenses/LICENSE-2.0
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.
18 * @file FLclLocaleManager.cpp
19 * @brief This is the implementation file for LocaleManager class.
23 #include <unique_ptr.h>
24 #include <FBaseSysLog.h>
25 #include <FLclLocaleManager.h>
26 #include "FLcl_LocaleManagerImpl.h"
28 using namespace Tizen::Base;
29 using namespace Tizen::Base::Collection;
30 using namespace Tizen::Base::Utility;
32 namespace Tizen { namespace Locales
35 LocaleManager::LocaleManager(void)
36 : __pLocaleManagerImpl(null)
41 LocaleManager::~LocaleManager(void)
47 LocaleManager::Construct(void)
54 LocaleManager::GetSystemLocale(void) const
57 return _LocaleManagerImpl::GetSystemLocale();
62 LocaleManager::GetAvailableLocalesN(void) const
65 return _LocaleManagerImpl::GetAvailableLocalesN();
70 LocaleManager::GetSelectedLanguage(void) const
73 return _LocaleManagerImpl::GetSelectedLanguage();
78 LocaleManager::GetAvailableLanguagesN(void) const
81 return _LocaleManagerImpl::GetAvailableLanguagesN();
86 LocaleManager::GetAvailableTimeZonesN(void) const
89 std::unique_ptr<IMap> pTimeZoneMap(_LocaleManagerImpl::GetAvailableTimeZonesN());
90 std::unique_ptr<IList> pList(pTimeZoneMap->GetKeysN());
91 std::unique_ptr<ArrayList> pArrayList(new (std::nothrow) ArrayList(SingleObjectDeleter));
92 SysTryReturn(NID_LCL, pArrayList, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
94 pArrayList->Construct();
96 for (int i = 0; i < pList->GetCount(); i++)
98 std::unique_ptr<String> pTz(new (std::nothrow) String(*((String*)(pList->GetAt(i)))));
99 SysTryReturn(NID_LCL, pTz, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
100 result r = pArrayList->Add(pTz.get());
101 SysTryReturn(NID_LCL, !IsFailed(r), null, E_SYSTEM, "[E_SYSTEM] It is failed to get the tz list.");
104 return pArrayList.release();
109 LocaleManager::GetAvailableTimeZonesN(int rawOffset) const
112 std::unique_ptr<IMap> pTimeZoneMap(_LocaleManagerImpl::GetAvailableTimeZonesN(rawOffset));
113 std::unique_ptr<IList> pList(pTimeZoneMap->GetKeysN());
114 std::unique_ptr<ArrayList> pArrayList(new (std::nothrow) ArrayList(SingleObjectDeleter));
115 SysTryReturn(NID_LCL, pArrayList, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
117 pArrayList->Construct();
119 for (int i = 0; i < pList->GetCount(); i++)
121 std::unique_ptr<String> pTz(new (std::nothrow) String(*((String*)(pList->GetAt(i)))));
122 SysTryReturn(NID_LCL, pTz, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
123 result r = pArrayList->Add(pTz.get());
124 SysTryReturn(NID_LCL, !IsFailed(r), null, E_SYSTEM, "[E_SYSTEM] It is failed to get the tz list.");
127 return pArrayList.release();
131 LocaleManager::GetSystemTimeZone(void) const
134 return _LocaleManagerImpl::GetSystemTimeZone();
138 LocaleManager::IsSupportedLocale(const Locale& locale, bool& isSupportedLocale)
141 return _LocaleManagerImpl::IsSupportedLocale(locale, isSupportedLocale);