#include <unicode/timezone.h>
#include <libxml/parser.h>
#include <libxml/tree.h>
+#include <vconf.h>
#include <FIo.h>
#include <FBaseSysLog.h>
}
};
+struct FreeCharPtr
+{
+ void operator ()(char* p)
+ {
+ if (p != null)
+ {
+ free(p);
+ }
+ }
+};
+
namespace Tizen { namespace Locales
{
static const char* LANGUAGE_LIST_FILE_PATH ="/opt/data/setting/langlist.xml";
{
if (cur_node->type == XML_ELEMENT_NODE)
{
- std::unique_ptr < char > pLocId((char*)xmlGetProp(cur_node, (const xmlChar *)"id"));
+ std::unique_ptr < char, FreeCharPtr > pLocId((char*)xmlGetProp(cur_node, (const xmlChar *)"id"));
Locale loc = _LocaleImpl(pLocId.get()).GetOspLocale();
std::unique_ptr<String> pLanguageLocaleID(new (std::nothrow) String(loc.GetLanguageCodeString()));
SysTryReturn(NID_LCL, pLanguageLocaleID, null, E_OUT_OF_MEMORY,"[%s] Memory allocation failed",GetErrorMessage(E_OUT_OF_MEMORY));
{
if (cur_node->type == XML_ELEMENT_NODE)
{
- std::unique_ptr< char > pLocId((char*)xmlGetProp(cur_node, (const xmlChar *)"id"));
+ std::unique_ptr< char, FreeCharPtr> pLocId((char*)xmlGetProp(cur_node, (const xmlChar *)"id"));
Locale loc = _LocaleImpl(pLocId.get()).GetOspLocale();
if (_LocaleImpl::IsSupported(loc))
{
TimeZone
_LocaleManagerImpl::GetSystemTimeZone(void)
{
- char tz[PATH_MAX + 1];
- int len = readlink("/opt/etc/localtime", tz, PATH_MAX);
-
- SysTryReturn(NID_LCL, len > 0, TimeZone(-1, ""), E_SYSTEM, "It is failed to get System Time Zone");
- tz[len] = '\0';
- SysTryReturn(NID_LCL, len > 20, TimeZone(-1, ""), E_SYSTEM, "It is failed to get System Time Zone");
-
- String tzId(tz + 20);
- SysLog(NID_LCL, "System TimeZone id [%ls]", tzId.GetPointer());
+ std::unique_ptr< char, FreeCharPtr> tzId(vconf_get_str(VCONFKEY_SETAPPL_TIMEZONE_ID));
+ SysTryReturn(NID_LCL, tzId, TimeZone(-1, ""), E_SYSTEM, "It is failed to get System Time Zone");
+ SysLog(NID_LCL, "System TimeZone id [%s]", tzId.get());
TimeZone timeZone;
DateTime utcTime;
pGmTime = gmtime(&currTime);
utcTime.SetValue(pGmTime->tm_year + 1900, pGmTime->tm_mon + 1, pGmTime->tm_mday, pGmTime->tm_hour, pGmTime->tm_min, pGmTime->tm_sec);
- result r = Tizen::Locales::TimeZone::GetTimeZone(tzId, utcTime, timeZone);
+ result r = Tizen::Locales::TimeZone::GetTimeZone(String(tzId.get()), utcTime, timeZone);
SysTryReturn(NID_LCL, r == E_SUCCESS, TimeZone(-1, ""), r, "[%s] error occurs.", GetErrorMessage(r));
return timeZone;
}