Fix to check SYSTEM_SETTINGS_KEY_AUTOMATIC_TIME_UPDATE feature
[platform/core/api/system-settings.git] / src / sst_time_N_locale.c
index 27f9b55..6116f5a 100644 (file)
 #include <vconf.h>
 #include "sst.h"
 #include "sst_vconf.h"
-#include "sst_utils.h"
+#include "sst_misc.h"
 #include "sst_interface.h"
 
-int sst_locale_get_country(sst_interface *iface, void **value)
+int sst_locale_get_country(sst_interface *iface, char **value)
 {
        char *locale = NULL;
-       if (sst_vconf_get_string(iface->vconf_key, &locale)) {
-               ERR("sst_vconf_get_string(%s) Fail", iface->vconf_key);
+       if (sst_vconf_get_str_ally(iface->vconf_key, &locale)) {
+               ERR("sst_vconf_get_str_ally(%s) Fail", iface->vconf_key);
                return SYSTEM_SETTINGS_ERROR_IO_ERROR;
        }
 
@@ -43,6 +43,7 @@ int sst_locale_get_country(sst_interface *iface, void **value)
        }
        if (sizeof(country) <= i) {
                ERR("Invalid locale(%s)", locale);
+               free(locale);
                return SYSTEM_SETTINGS_ERROR_IO_ERROR;
        }
 
@@ -52,9 +53,8 @@ int sst_locale_get_country(sst_interface *iface, void **value)
        return SYSTEM_SETTINGS_ERROR_NONE;
 }
 
-int sst_locale_set_country(sst_interface *iface, void *value)
+int sst_locale_set_country(sst_interface *iface, const char *country)
 {
-       char *country = value;
        const char *codeset = "UTF-8";
 
        char locale[100];
@@ -68,7 +68,7 @@ int sst_locale_set_country(sst_interface *iface, void *value)
        return SYSTEM_SETTINGS_ERROR_NONE;
 }
 
-int sst_locale_get_language(sst_interface *iface, void **value)
+int sst_locale_get_language(sst_interface *iface, char **value)
 {
        //It is same data with sst_locale_get_country()
        int ret = sst_locale_get_country(iface, value);
@@ -80,7 +80,7 @@ int sst_locale_get_language(sst_interface *iface, void **value)
        return SYSTEM_SETTINGS_ERROR_NONE;
 }
 
-int sst_locale_set_language(sst_interface *iface, void *value)
+int sst_locale_set_language(sst_interface *iface, const char *value)
 {
        //It is same data with sst_locale_set_country()
        int ret = sst_locale_set_country(iface, value);
@@ -92,29 +92,28 @@ int sst_locale_set_language(sst_interface *iface, void *value)
        return SYSTEM_SETTINGS_ERROR_NONE;
 }
 
-int sst_locale_get_timeformat_24hour(sst_interface *iface, void **value)
+int sst_locale_get_timeformat_24hour(sst_interface *iface, bool *value)
 {
-       int int_val;
+       int time_fmt;
 
-       if (vconf_get_int(iface->vconf_key, &int_val)) {
+       if (vconf_get_int(iface->vconf_key, &time_fmt)) {
                ERR("vconf_get_int(%s) Fail", iface->vconf_key);
                return SYSTEM_SETTINGS_ERROR_IO_ERROR;
        }
 
-       bool ret_value = true;
-       if (int_val == VCONFKEY_TIME_FORMAT_12)
-               ret_value = false;
-       else if (int_val == VCONFKEY_TIME_FORMAT_24)
-               ret_value = true;
+       bool result = true;
+       if (time_fmt == VCONFKEY_TIME_FORMAT_12)
+               result = false;
+       else if (time_fmt == VCONFKEY_TIME_FORMAT_24)
+               result = true;
 
-       *value = (void*)ret_value;
+       *value = result;
 
        return SYSTEM_SETTINGS_ERROR_NONE;
 }
 
-int sst_locale_set_timeformat_24hour(sst_interface *iface, void *value)
+int sst_locale_set_timeformat_24hour(sst_interface *iface, bool is_24hour)
 {
-       bool is_24hour = *(bool*)value;
        int vconf_val;
 
        if (is_24hour)
@@ -130,7 +129,7 @@ int sst_locale_set_timeformat_24hour(sst_interface *iface, void *value)
        return SYSTEM_SETTINGS_ERROR_NONE;
 }
 
-int sst_locale_get_timezone(sst_interface *iface, void **value)
+int sst_locale_get_timezone(sst_interface *iface, char **value)
 {
        char tzpath[PATH_MAX];
        ssize_t len = readlink(SETTING_TZONE_SYMLINK_PATH, tzpath, sizeof(tzpath) - 1);
@@ -147,15 +146,13 @@ int sst_locale_get_timezone(sst_interface *iface, void **value)
        return SYSTEM_SETTINGS_ERROR_NONE;
 }
 
-int sst_locale_set_timezone(sst_interface *iface, void *value)
+int sst_locale_set_timezone(sst_interface *iface, const char *timezone)
 {
-       char *timezone = value;
-
        char tzpath[PATH_MAX];
        snprintf(tzpath, sizeof(tzpath), SETTING_TIME_ZONEINFO_PATH"/%s", timezone);
 
-       if (false == sst_utils_exist(tzpath)) {
-               ERR("sst_utils_exist(%s) Fail", tzpath);
+       if (false == sst_misc_file_exists(tzpath)) {
+               ERR("sst_misc_file_exists(%s) Fail", tzpath);
                return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
        }
 
@@ -172,11 +169,12 @@ int sst_locale_set_timezone(sst_interface *iface, void *value)
 }
 
 //TODO : checking this function is being used or not.
-int sst_time_get_changed(sst_interface *iface, void **value)
+int sst_time_get_changed(sst_interface *iface, int *value)
 {
        time_t cur_tick;
-       int ** val = (int**)value;
+
        cur_tick = time(NULL);
-       **val = cur_tick;
+       *value = cur_tick;
+
        return SYSTEM_SETTINGS_ERROR_NONE;
 }