#include <libxml/parser.h>
#include <libxml/tree.h>
+#include <FIo.h>
#include <FBaseSysLog.h>
#include <FBase_StringConverter.h>
using namespace Tizen::Base;
using namespace Tizen::Base::Utility;
using namespace Tizen::Base::Collection;
+using namespace Tizen::Io;
namespace Tizen { namespace Locales
{
-static const char* LANGLIST_FILE_PATH ="/opt/data/setting/langlist.xml";
+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 int TIMEZONE_MAX = 224;
static const char* TimeZoneList[TIMEZONE_MAX] =
{
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));
- doc = xmlParseFile(LANGLIST_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.");
cur = xmlDocGetRootElement(doc);
xmlFreeDoc(doc);
}
SysLog(NID_LCL, "It is calling fallback api.");
- return GetAvailableLanguagesFallBackN();
+ return GetAvailableLanguagesFallbackN();
}
IList*
-_LocaleManagerImpl::GetAvailableLanguagesFallBackN(void)
+_LocaleManagerImpl::GetAvailableLanguagesFallbackN(void)
{
std::unique_ptr<IList, AllElementsDeleter> pLocaleList (GetAvailableLocalesN());
std::unique_ptr<HashMap> pLanguageMap(new (std::nothrow) HashMap());
return pTimeZoneMap.release();
}
+
IMap*
_LocaleManagerImpl::GetAvailableTimeZonesN(void)
{
+ File file;
+ String tzFilePath(TIMEZONE_LIST_FILE_PATH);
+ result r = E_SUCCESS;
+
std::unique_ptr<HashMap, AllElementsDeleter> pTimeZoneMap(new (std::nothrow) HashMap());
+ SysTryCatch(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.");
+ pTimeZoneMap->Construct();
+
+ do
+ {
+ std::unique_ptr<String> pTimeZone(new (std::nothrow) String());
+ SysTryCatch(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));
+ 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,
+ "[%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 add the tz into the tz map.", GetErrorMessage(r));
+ pTimeZone.release();
+ pDummyValue.release();
+ }
+ }while (1);
+
+ SetLastResult(E_SUCCESS);
+ return pTimeZoneMap.release();
+
+CATCH:
+ return GetAvailableTimeZonesFallbackN();
+}
+
+
+IMap*
+_LocaleManagerImpl::GetAvailableTimeZonesFallbackN(void)
+{
+ std::unique_ptr<HashMap, AllElementsDeleter> pTimeZoneMap(new (std::nothrow) HashMap());
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
{
- String* pTimeZone = new (std::nothrow) String(TimeZoneList[index++]);
+ 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));
+ "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
if (!pTimeZoneMap->ContainsKey(*pTimeZone))
{
return pTimeZoneMap.release();
}
+
IMap*
_LocaleManagerImpl::GetAvailableTimeZonesN(int rawOffset)
{