fix callback port number & betweeny bug
[platform/core/api/system-settings.git] / src / system_setting_platform.c
index e3a1a15..e0fd469 100644 (file)
@@ -25,6 +25,7 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
+#include <aul.h>
 
 #include <regex.h>
 
 
 #include <system_settings.h>
 #include <system_settings_private.h>
+#include <system_settings_ringtones.h>
+#include <system_settings_json.h>
+
 
 #include <tzplatform_config.h>
+#include <alarm.h>
 
 #ifdef USE_EFL_ASSIST
 #include <efl_assist.h>
 #endif
 
+
+
 #define SETTING_FONT_CONF_FILE _TZ_SYS_ETC"/fonts/conf.avail/99-tizen.conf"
 #define SETTING_DEFAULT_FONT_CONF_FILE _TZ_SYS_ETC"/fonts/conf.avail/99-tizen.conf"
 
 #define SETTING_TIME_ZONEINFO_PATH             "/usr/share/zoneinfo/"
 #define SETTING_TIME_SHARE_LOCAL_PATH  "/usr/share/locale"
-#define SETTING_TZONE_SYMLINK_PATH             "/etc/localtime"
+#define SETTING_TZONE_SYMLINK_PATH             "/opt/etc/localtime"
 
 
+#define __FREE(del, arg) do { \
+               if (arg) { \
+                       del((void *)(arg)); /*cast any argument to (void*) to avoid build warring*/\
+                       arg = NULL; \
+               } \
+       } while (0);
+#define FREE(arg) __FREE(free, arg)
+
+#ifdef SETTING_ARCH_64
+#define SETTING_UTILS_SO_FILE_PATH "/usr/lib64/libsystem-settings-util.so.0.1.0"
+#else
+#define SETTING_UTILS_SO_FILE_PATH "/usr/lib/libsystem-settings-util.so.0.1.0"
+#endif
+
 int _is_file_accessible(const char *path);
 
-bool dl_is_supported_image_type_load(char *path);
-bool dl_font_config_set(char *font_name);
-char *dl_get_font_info(char *str);
-int *dl_is_available_font(char *str);
-void dl_font_size_set();
-void dl_font_config_set_notification();
+static bool dl_is_supported_image_type_load(char *path);
+static bool dl_font_config_set(char *font_name);
+static char *dl_get_font_info(char *str);
+static int dl_is_available_font(char *str);
+static void dl_font_size_set();
+static void dl_font_config_set_notification();
 
 
 /**
  * VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR has a path of the ringtone file which user choose
  * @return the ringtone file path specified by user in normal case
- *         if it's not accessable, return the default ringtone path
+ *                if it's not accessable, return the default ringtone path
  */
 int system_setting_get_incoming_call_ringtone(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
 {
@@ -145,11 +166,12 @@ int system_setting_get_font_size(system_settings_key_e key, system_setting_data_
 {
        SETTING_TRACE_BEGIN;
        int vconf_value;
+       int ** val = (int**)value;
 
        if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, &vconf_value)) {
                return SYSTEM_SETTINGS_ERROR_IO_ERROR;
        }
-       *value = (void *)vconf_value;
+       **val = vconf_value;
 
        return SYSTEM_SETTINGS_ERROR_NONE;
 }
@@ -260,6 +282,199 @@ int _is_file_accessible(const char *path)
        }
 }
 
+
+
+/*////////////////////////////////////////////////////////////////////////////////////////////////// */
+// @todo move to CMake
+#define DEF_RINGTONE_FILE_PATH "/opt/share/settings/Ringtones"
+#define USR_RINGTONE_FILE_PATH "/home/owner/content/Sounds/Ringtones"
+#define JSONFILE "/opt/home/owner/apps_rw/org.tizen.setting/data/.user-ringtones.json"
+
+#if 0
+static char* _get_json_file_path()
+{
+       // for testing
+       return JSONFILE;
+}
+#endif
+
+int system_setting_add_incoming_call_ringtone(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
+{
+       SETTING_TRACE_BEGIN;
+       char* pathval = (char*)value;
+
+#ifdef USE_JSONFILE
+       // NOT IN USE
+       JsonParser *parser = ss_json_ringtone_open_file(JSONFILE);
+#else
+       JsonParser *parser = ss_json_ringtone_load_from_data();
+#endif
+
+       JsonNode *root = json_parser_get_root(parser);
+
+       // dirname
+       // basename
+       int ret = SYSTEM_SETTINGS_ERROR_NONE;
+       if (false == ss_json_ringtone_contain(root, pathval)) {
+               SETTING_TRACE("---> dirname is : %s ", dirname(strdup(pathval)));
+               SETTING_TRACE("---> basename is : %s ", basename(strdup(pathval)));
+               // @todo : MAKE SURE THE ACTUAL FILE IS THERE ON PATHVAL(SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER)
+               ss_json_ringtone_add(root, JSONFILE, pathval, pathval);
+               SETTING_TRACE("pathval is : %s -- OK", pathval);
+       } else {
+               SETTING_TRACE("pathval is duplicated : %s", pathval);
+               SETTING_TRACE("---> dirname is : %s ", dirname(strdup(pathval)));
+               SETTING_TRACE("---> basename is : %s ", basename(strdup(pathval)));
+               ret = SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
+       }
+
+       if (parser) {
+               g_object_unref(parser);
+               parser = NULL;
+       }
+
+       return ret;
+}
+
+int system_setting_del_incoming_call_ringtone(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
+{
+       SETTING_TRACE_BEGIN;
+       char* pathval = (char*)value;
+#ifdef USE_JSONFILE
+       // NOT IN USE
+       JsonParser* parser = ss_json_ringtone_open_file(JSONFILE);
+#else
+       JsonParser* parser = ss_json_ringtone_load_from_data();
+#endif
+       JsonNode *root = json_parser_get_root(parser);
+
+       ss_json_ringtone_remove(root, JSONFILE, pathval);
+       //void ss_json_ringtone_remove(JsonNode *root,  char* filename, char* path_to_del)
+
+       ss_json_ringtone_print(root);
+       if (parser) {
+               g_object_unref(parser);
+               parser = NULL;
+       }
+
+       return SYSTEM_SETTINGS_ERROR_NONE;
+}
+
+
+static int _compare_cb(const void *d1, const void *d2)
+{
+       fileNodeInfo *pNode1 = (fileNodeInfo *)d1;
+       fileNodeInfo *pNode2 = (fileNodeInfo *)d2;
+
+       return strcmp(pNode1->media_name, pNode2->media_name);
+}
+
+/*
+ * get the RINGTONE list
+ */
+static void _get_default_ringtones(system_settings_key_e key, system_setting_data_type_e data_type,  system_settings_iter_cb callback, void *data)
+{
+       SETTING_TRACE_BEGIN;
+       /*Get file list */
+       Eina_List *filelist = NULL;
+       Eina_List *l = NULL;
+       fileNodeInfo *node = NULL;
+       int idx = 0;
+
+       //-----------------------------------------------------------------------------------------------------------------
+       // 1. get the default ringtone list
+       //-----------------------------------------------------------------------------------------------------------------
+       int ret = get_filelist_from_dir_path(DEF_RINGTONE_FILE_PATH, &filelist);
+       if (ret != 0) {
+               SETTING_TRACE("Failed to get filelist, ret = %d %s", ret, DEF_RINGTONE_FILE_PATH);
+       }
+       filelist = eina_list_sort(filelist, eina_list_count(filelist), _compare_cb);
+
+       EINA_LIST_FOREACH(filelist, l, node)
+       {
+               SETTING_TRACE("file path = (%d) : name:%s path:%s [%s]", ret, node->name, node->path, node->media_name);
+               // @todo assert NULL check
+               if (callback) {
+                       char temp[1024];
+                       snprintf(temp, 1024, "%s/%s", node->path, node->name);
+                       char* path = strdup(temp);
+                       bool ret = callback(idx, (void *)(path), data);
+                       if (path) {
+                               free(path);
+                               path = NULL;
+                       }
+                       if (ret == false) {
+                               SETTING_TRACE("quit the iteration by return value == false : %d", ret);
+                               break;
+                       }
+
+               } else {
+                       SETTING_TRACE("--> system_setting_data_iterator is NULL");
+               }
+       }
+
+       l = NULL;
+       node = NULL;
+       EINA_LIST_FOREACH(filelist, l, node)
+       {
+               FREE(node->path);
+               FREE(node->name);
+               FREE(node->media_name);
+               FREE(node);
+       }
+       eina_list_free(filelist);
+       filelist = NULL;
+
+}
+
+static void _get_user_ringtones(system_settings_key_e key, system_setting_data_type_e data_type, system_settings_iter_cb callback, void *data)
+{
+       SETTING_TRACE_BEGIN;
+
+#ifdef USE_JSONFILE
+       // NOT IN USE
+       JsonParser* parser = ss_json_ringtone_open_file(JSONFILE);
+#else
+       JsonParser* parser = ss_json_ringtone_load_from_data();
+#endif
+
+       JsonNode *root = json_parser_get_root(parser);
+       int size = json_array_get_length(json_node_get_array(root));
+
+       int i = 0;
+       for (i = 0; i < size ; i++) {
+               JsonObject *ringtone = json_array_get_object_element(json_node_get_array(root), i);
+               char *nameval = (char *)json_object_get_string_member(ringtone, "name");
+               char *pathval = (char *)json_object_get_string_member(ringtone, "path");
+               SETTING_TRACE("(%s) --- (%s) \n", nameval, pathval);
+               if (callback) {
+                       char* path = strdup(pathval);
+                       bool ret = callback(i, (void *)(path), data);
+                       if (ret == false) {
+                               SETTING_TRACE("quit the iteration by return value == false : %d", ret);
+                               break;
+                       }
+               } else {
+                       SETTING_TRACE("--> callback is NULL");
+               }
+       }
+}
+
+int system_setting_list_incoming_call_ringtone(system_settings_key_e key, system_setting_data_type_e data_type, system_settings_iter_cb callback, void *data)
+{
+       SETTING_TRACE_BEGIN;
+
+       _get_default_ringtones(key, data_type, callback, data);
+       //-----------------------------------------------------------------------------------------------------------------
+       // 2. get the USER ringtone list
+       //-----------------------------------------------------------------------------------------------------------------
+       _get_user_ringtones(key, data_type, callback, data);
+
+       return SYSTEM_SETTINGS_ERROR_NONE;
+}
+
+
+/*  LCOV_EXCL_START */
 int system_setting_set_incoming_call_ringtone(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
 {
        SETTING_TRACE_BEGIN;
@@ -278,8 +493,10 @@ int system_setting_set_incoming_call_ringtone(system_settings_key_e key, system_
 
        return SYSTEM_SETTINGS_ERROR_NONE;
 }
+/*  LCOV_EXCL_STOP */
 
 
+/*  LCOV_EXCL_START */
 int system_setting_set_email_alert_ringtone(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
 {
        SETTING_TRACE_BEGIN;
@@ -299,153 +516,179 @@ int system_setting_set_email_alert_ringtone(system_settings_key_e key, system_se
 
        return SYSTEM_SETTINGS_ERROR_NONE;
 }
+/*  LCOV_EXCL_STOP */
 
-bool dl_is_supported_image_type_load(char *path)
+/*  LCOV_EXCL_START */
+static bool dl_is_supported_image_type_load(char *path)
 {
-       void *handle;
-       int error;
+       void *handle = NULL;
+       char *error;
        bool ret = false;
        bool (*image_type_check)(char *path);
 
-       handle = dlopen("/usr/lib/libsystem-settings-util.so.0.1.0",  RTLD_LAZY);
-       if(!handle)
-       {
+       handle = dlopen(SETTING_UTILS_SO_FILE_PATH,  RTLD_LAZY);
+       if (!handle) {
                SETTING_TRACE("ERROR!! canNOT find libsystem-settings-util.so.0.1.0");
                return false;
        }
 
        image_type_check = dlsym(handle, "__is_supported_image_type_load");
-       if((error = dlerror()) != NULL) {
+       if ((error = dlerror()) != NULL) {
                SETTING_TRACE("ERROR!! canNOT find __is_supported_image_type_load function at libsystem-settings-util.so.0.1.0");
+               if (handle)
+                       dlclose(handle);
                return false;
        }
        ret = image_type_check(path);
-       dlclose(handle);
+       if (handle)
+               dlclose(handle);
        return ret;
 }
+/*  LCOV_EXCL_STOP */
 
-int *dl_is_available_font(char *str)
+/*  LCOV_EXCL_START */
+static int dl_is_available_font(char *str)
 {
-       void *handle;
-       int error;
+       void *handle = NULL;
+       char *error;
        int ret = false;
        int (*check_available_font)(char *font_name);
 
-       handle = dlopen("/usr/lib/libsystem-settings-util.so.0.1.0",  RTLD_LAZY);
-       if(!handle)
-       {
+       handle = dlopen(SETTING_UTILS_SO_FILE_PATH,  RTLD_LAZY);
+       if (!handle) {
                SETTING_TRACE("ERROR!! canNOT find libsystem-settings-util.so.0.1.0");
                return false;
        }
 
-       check_available_font = dlsym(handle, "_is_available_font");
-       if((error = dlerror()) != NULL) {
-               SETTING_TRACE("ERROR!! canNOT find font_config_set function at libsystem-settings-util.so.0.1.0");
+       check_available_font = dlsym(handle, "__is_available_font");
+       if ((error = dlerror()) != NULL) {
+               SETTING_TRACE("ERROR!! canNOT find __is_available_font function at libsystem-settings-util.so.0.1.0");
+               if (handle)
+                       dlclose(handle);
                return false;
        }
        ret = check_available_font(str);
-       dlclose(handle);
+       if (handle)
+               dlclose(handle);
        return ret;
 }
+/*  LCOV_EXCL_STOP */
 
-void dl_font_size_set()
+/*  LCOV_EXCL_START */
+static void dl_font_size_set()
 {
-       void *handle;
-       int error;
+       void *handle = NULL;
+       char *error;
        void (*set_font_size)();
 
-       handle = dlopen("/usr/lib/libsystem-settings-util.so.0.1.0",  RTLD_LAZY);
-       if(!handle)
-       {
+       handle = dlopen(SETTING_UTILS_SO_FILE_PATH,  RTLD_LAZY);
+       if (!handle) {
                SETTING_TRACE("ERROR!! canNOT find libsystem-settings-util.so.0.1.0");
                return;
        }
 
        set_font_size = dlsym(handle, "__font_size_set");
-       if((error = dlerror()) != NULL) {
-               SETTING_TRACE("ERROR!! canNOT find font_config_set function at libsystem-settings-util.so.0.1.0");
+       if ((error = dlerror()) != NULL) {
+               SETTING_TRACE("ERROR!! canNOT find __font_size_set function at libsystem-settings-util.so.0.1.0");
+               if (handle)
+                       dlclose(handle);
                return;
        }
        set_font_size();
-       dlclose(handle);
+       if (handle)
+               dlclose(handle);
        return;
 }
+/*  LCOV_EXCL_STOP */
 
-void dl_font_config_set_notification()
+/*  LCOV_EXCL_START */
+static void dl_font_config_set_notification()
 {
-       void *handle;
-       int error;
+       void *handle = NULL;
+       char *error;
        void (*set_font_nodification)();
 
-       handle = dlopen("/usr/lib/libsystem-settings-util.so.0.1.0",  RTLD_LAZY);
-       if(!handle)
-       {
+       handle = dlopen(SETTING_UTILS_SO_FILE_PATH,  RTLD_LAZY);
+       if (!handle) {
                SETTING_TRACE("ERROR!! canNOT find libsystem-settings-util.so.0.1.0");
                return;
        }
 
        set_font_nodification = dlsym(handle, "font_config_set_notification");
-       if((error = dlerror()) != NULL) {
-               SETTING_TRACE("ERROR!! canNOT find font_config_set function at libsystem-settings-util.so.0.1.0");
+       if ((error = dlerror()) != NULL) {
+               SETTING_TRACE("ERROR!! canNOT find font_config_set_notification function at libsystem-settings-util.so.0.1.0");
+               if (handle)
+                       dlclose(handle);
                return;
        }
        set_font_nodification();
-       dlclose(handle);
+       if (handle)
+               dlclose(handle);
        return;
 }
+/*  LCOV_EXCL_STOP */
 
-bool dl_font_config_set(char *font_name)
+/*  LCOV_EXCL_START */
+static bool dl_font_config_set(char *font_name)
 {
-       void *handle;
-       int error;
+       void *handle = NULL;
+       char *error;
        bool ret = false;
        bool (*check_font_type)(char *font_name);
 
-       handle = dlopen("/usr/lib/libsystem-settings-util.so.0.1.0",  RTLD_LAZY);
-       if(!handle)
-       {
+       handle = dlopen(SETTING_UTILS_SO_FILE_PATH,  RTLD_LAZY);
+       if (!handle) {
                SETTING_TRACE("ERROR!! canNOT find libsystem-settings-util.so.0.1.0");
                return false;
        }
 
        check_font_type = dlsym(handle, "font_config_set");
-       if((error = dlerror()) != NULL) {
+       if ((error = dlerror()) != NULL) {
                SETTING_TRACE("ERROR!! canNOT find font_config_set function at libsystem-settings-util.so.0.1.0");
+               if (handle)
+                       dlclose(handle);
                return false;
        }
        ret = check_font_type(font_name);
-       dlclose(handle);
+       if (handle)
+               dlclose(handle);
        return ret;
 }
+/*  LCOV_EXCL_STOP */
 
-char *dl_get_font_info(char *str)
+/*  LCOV_EXCL_START */
+static char *dl_get_font_info(char *str)
 {
-       void *handle;
-       int error;
-       charret = NULL;
+       void *handle = NULL;
+       char *error;
+       char *ret = NULL;
        char *(*get_font_info)();
 
-       handle = dlopen("/usr/lib/libsystem-settings-util.so.0.1.0",  RTLD_LAZY);
-       if(!handle)
-       {
+       handle = dlopen(SETTING_UTILS_SO_FILE_PATH,  RTLD_LAZY);
+       if (!handle) {
                SETTING_TRACE("ERROR!! canNOT find libsystem-settings-util.so.0.1.0");
                return false;
        }
 
-       if(strcmp(str,"cur") == 0)
+       if (strcmp(str, "cur") == 0)
                get_font_info = dlsym(handle, "_get_cur_font");
        else
                get_font_info = dlsym(handle, "_get_default_font");
 
-       if((error = dlerror()) != NULL) {
+       if ((error = dlerror()) != NULL) {
                SETTING_TRACE("ERROR!! canNOT find %s function at libsystem-settings-util.so.0.1.0", str);
+               if (handle)
+                       dlclose(handle);
                return false;
        }
        ret = get_font_info();
-       dlclose(handle);
+       if (handle)
+               dlclose(handle);
        return ret;
 }
+/*  LCOV_EXCL_STOP */
 
+/*  LCOV_EXCL_START */
 #define PATH_EXT_CHECK_REG ".(jpe?g|jpg|png|gif)$"
 bool __is_supported_image_type_by_ext(char *file_path)
 {
@@ -471,7 +714,9 @@ bool __is_supported_image_type_by_ext(char *file_path)
        }
        return ret;
 }
+/*  LCOV_EXCL_STOP */
 #ifdef TIZEN_WEARABLE
+/*  LCOV_EXCL_START */
 static int system_setting_get_extended_wallpaper_num(const char *file_path, unsigned int *num)
 {
        SETTING_TRACE_BEGIN;
@@ -495,7 +740,9 @@ static int system_setting_get_extended_wallpaper_num(const char *file_path, unsi
 
        return SYSTEM_SETTINGS_ERROR_NONE;
 }
+/*  LCOV_EXCL_STOP */
 
+/*  LCOV_EXCL_START */
 static int system_setting_copy_extended_wallpaper(const char *dest_file_path, const char *source_file_path)
 {
        SETTING_TRACE_BEGIN;
@@ -533,7 +780,9 @@ static int system_setting_copy_extended_wallpaper(const char *dest_file_path, co
 
        return SYSTEM_SETTINGS_ERROR_NONE;
 }
+/*  LCOV_EXCL_STOP */
 
+/*  LCOV_EXCL_START */
 static int system_setting_remove_oldest_extended_wallpaper()
 {
        SETTING_TRACE_BEGIN;
@@ -576,7 +825,9 @@ static int system_setting_remove_oldest_extended_wallpaper()
 
        return SYSTEM_SETTINGS_ERROR_NONE;
 }
+/*  LCOV_EXCL_STOP */
 
+/*  LCOV_EXCL_START */
 static int system_setting_check_extended_wallpaper(const char *file_path)
 {
        char buffer[512];
@@ -586,10 +837,11 @@ static int system_setting_check_extended_wallpaper(const char *file_path)
        snprintf(buffer, 512, "%s/.bgwallpaper", tzplatform_getenv(TZ_USER_CONTENT));
        return (strstr(file_path, buffer) != NULL);
 }
+/*  LCOV_EXCL_STOP */
 
 #define WALLPAPER_MAX_COUNT            10
 #endif
-
+/*  LCOV_EXCL_START */
 int system_setting_set_wallpaper_home_screen(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
 {
        SETTING_TRACE_BEGIN;
@@ -650,11 +902,11 @@ int system_setting_set_wallpaper_home_screen(system_settings_key_e key, system_s
 
                /* Numbering rule: Gear is odd number */
                max_image_num = (max_image_num % 2 == 0) ? max_image_num + 1
-                               : max_image_num + 2;
+                                                       : max_image_num + 2;
 
                char file_name_buffer[512];
                snprintf(file_name_buffer, sizeof(file_name_buffer) - 1,
-                        _TZ_SYS_DATA"/setting/wallpaper/extended_wallpaper_%d.jpg", max_image_num);
+                                       _TZ_SYS_DATA"/setting/wallpaper/extended_wallpaper_%d.jpg", max_image_num);
 
                /* Copy image to _TZ_SYS_DATA/setting/wallpaper/ */
                if (system_setting_copy_extended_wallpaper(file_name_buffer, vconf_value)
@@ -676,7 +928,7 @@ int system_setting_set_wallpaper_home_screen(system_settings_key_e key, system_s
                }
 
                if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_WALLPAPER_CHANGED_NOTI_INT,
-                                                      VCONFKEY_WALLPAPER_CHANGED_NOTI_GEAR)) {
+                                                                                                       VCONFKEY_WALLPAPER_CHANGED_NOTI_GEAR)) {
                        return SYSTEM_SETTINGS_ERROR_IO_ERROR;
                }
        } else {
@@ -688,7 +940,9 @@ int system_setting_set_wallpaper_home_screen(system_settings_key_e key, system_s
 
        return SYSTEM_SETTINGS_ERROR_NONE;
 }
+/*  LCOV_EXCL_STOP */
 
+/*  LCOV_EXCL_START */
 int system_setting_set_wallpaper_lock_screen(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
 {
        SETTING_TRACE_BEGIN;
@@ -714,12 +968,14 @@ int system_setting_set_wallpaper_lock_screen(system_settings_key_e key, system_s
 
        return SYSTEM_SETTINGS_ERROR_NONE;
 }
+/*  LCOV_EXCL_STOP */
 
+/*  LCOV_EXCL_START */
 int system_setting_set_font_size(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
 {
        SETTING_TRACE_BEGIN;
        int *vconf_value;
-       vconf_value = (int *)value;
+       vconf_value = *(int **)value;
 
        if (*vconf_value < 0 || *vconf_value > SYSTEM_SETTINGS_FONT_SIZE_GIANT) {
                return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
@@ -732,9 +988,11 @@ int system_setting_set_font_size(system_settings_key_e key, system_setting_data_
        SETTING_TRACE_END;
        return SYSTEM_SETTINGS_ERROR_NONE;
 }
+/*  LCOV_EXCL_STOP */
 /**
  * [internal API]
  */
+/*  LCOV_EXCL_START */
 void *font_conf_doc_parse(char *doc_name, char *font_name)
 {
        SETTING_TRACE_BEGIN;
@@ -830,7 +1088,9 @@ void *font_conf_doc_parse(char *doc_name, char *font_name)
                return NULL;
        }
 }
+/*  LCOV_EXCL_STOP */
 
+/*  LCOV_EXCL_START */
 int system_setting_set_font_type(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
 {
        SETTING_TRACE_BEGIN;
@@ -873,7 +1133,9 @@ int system_setting_set_font_type(system_settings_key_e key, system_setting_data_
        }
        return SYSTEM_SETTINGS_ERROR_NONE;
 }
+/*  LCOV_EXCL_STOP */
 
+/*  LCOV_EXCL_START */
 int system_setting_set_motion_activation(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
 {
        SETTING_TRACE_BEGIN;
@@ -884,7 +1146,9 @@ int system_setting_set_motion_activation(system_settings_key_e key, system_setti
        }
        return SYSTEM_SETTINGS_ERROR_NONE;
 }
+/*  LCOV_EXCL_STOP */
 
+/*  LCOV_EXCL_START */
 int system_setting_set_usb_debugging_option(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
 {
        SETTING_TRACE_BEGIN;
@@ -896,7 +1160,9 @@ int system_setting_set_usb_debugging_option(system_settings_key_e key, system_se
        return SYSTEM_SETTINGS_ERROR_NONE;
 
 }
+/*  LCOV_EXCL_STOP */
 
+/*  LCOV_EXCL_START */
 int system_setting_set_3g_data_network(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
 {
        SETTING_TRACE_BEGIN;
@@ -908,7 +1174,9 @@ int system_setting_set_3g_data_network(system_settings_key_e key, system_setting
 
        return SYSTEM_SETTINGS_ERROR_NONE;
 }
+/*  LCOV_EXCL_STOP */
 
+/*  LCOV_EXCL_START */
 static int category_func(const char *name, void *user_data)
 {
        SETTING_TRACE_BEGIN;
@@ -923,12 +1191,15 @@ static int category_func(const char *name, void *user_data)
 
        return 0;
 }
+/*  LCOV_EXCL_STOP */
 
 /**
  *
  * set 'swipe type' if current lockscreen app is 'com.samsung.lockscreen'
  *
  */
+
+/*  LCOV_EXCL_START */
 int system_setting_set_lockscreen_app(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
 {
        SETTING_TRACE_BEGIN;
@@ -972,6 +1243,7 @@ int system_setting_set_lockscreen_app(system_settings_key_e key, system_setting_
        }
        return SYSTEM_SETTINGS_ERROR_NONE;
 }
+/*  LCOV_EXCL_STOP */
 
 /*/////////////////////////////////////////////////////////////////////////////////////////////// */
 /* */
@@ -1123,6 +1395,7 @@ int system_setting_get_locale_country(system_settings_key_e key, system_setting_
        return SYSTEM_SETTINGS_ERROR_NONE;
 }
 
+/*  LCOV_EXCL_START */
 int system_setting_set_locale_country(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
 {
        SETTING_TRACE_BEGIN;
@@ -1139,6 +1412,7 @@ int system_setting_set_locale_country(system_settings_key_e key, system_setting_
        }
        return SYSTEM_SETTINGS_ERROR_NONE;
 }
+/*  LCOV_EXCL_STOP */
 
 int system_setting_set_changed_callback_locale_country(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
 {
@@ -1173,6 +1447,7 @@ int system_setting_get_locale_language(system_settings_key_e key, system_setting
        return SYSTEM_SETTINGS_ERROR_NONE;
 }
 
+/*  LCOV_EXCL_START */
 int system_setting_set_locale_language(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
 {
        SETTING_TRACE_BEGIN;
@@ -1189,6 +1464,7 @@ int system_setting_set_locale_language(system_settings_key_e key, system_setting
        }
        return SYSTEM_SETTINGS_ERROR_NONE;
 }
+/*  LCOV_EXCL_STOP */
 
 int system_setting_set_changed_callback_locale_language(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
 {
@@ -1204,6 +1480,7 @@ int system_setting_unset_changed_callback_locale_language(system_settings_key_e
 }
 
 /*--------------------------------------- */
+/*  LCOV_EXCL_START */
 int system_setting_get_locale_timeformat_24hour(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
 {
        SETTING_TRACE_BEGIN;
@@ -1223,6 +1500,7 @@ int system_setting_get_locale_timeformat_24hour(system_settings_key_e key, syste
 
        return SYSTEM_SETTINGS_ERROR_NONE;
 }
+/*  LCOV_EXCL_STOP */
 
 int system_setting_set_locale_timeformat_24hour(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
 {
@@ -1260,49 +1538,90 @@ int system_setting_unset_changed_callback_locale_timeformat_24hour(system_settin
 
 int system_setting_get_locale_timezone(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
 {
-       SETTING_TRACE_BEGIN;
-#if 0
        char tzpath[256];
-       ssize_t len = readlink(SETTING_TZONE_SYMLINK_PATH, tzpath, sizeof(tzpath) - 1);
+       ssize_t len = readlink(SETTING_TZONE_SYMLINK_PATH, tzpath, sizeof(tzpath)-1);
        if (len != -1) {
                tzpath[len] = '\0';
        } else {
                SETTING_TRACE("parse error for SETTING_TZONE_SYMLINK_PATH");
                return SYSTEM_SETTINGS_ERROR_IO_ERROR;
        }
-       /* "/usr/share/zoneinfo/Asia/Seoul" */
+
        SETTING_TRACE("tzpath : %s ", &tzpath[20]);
        *value = strdup(&tzpath[20]);
-#else
-       *value = vconf_get_str(VCONFKEY_SETAPPL_TIMEZONE_ID);
-#endif
        return SYSTEM_SETTINGS_ERROR_NONE;
 }
 
+/*  LCOV_EXCL_START */
+int system_setting_set_locale_timezone(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
+{
+       SETTING_TRACE_BEGIN;
+       char *timezone_value = NULL;
+       timezone_value = (char *)value;
+
+       char tz_path[1024];
+       snprintf(tz_path, 1024, "/usr/share/zoneinfo/%s", timezone_value);
+
+       int is_load = _is_file_accessible(tz_path);
+       if (is_load == 0) {
+               alarmmgr_set_timezone(tz_path);
+
+               if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_TIMEZONE_ID, timezone_value)) {
+                       return SYSTEM_SETTINGS_ERROR_IO_ERROR;
+               }
+               return SYSTEM_SETTINGS_ERROR_NONE;
+       }
+       return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
+}
+/*  LCOV_EXCL_STOP */
+
+
+
+/*  LCOV_EXCL_START */
+int system_setting_set_changed_callback_locale_timezone(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
+{
+       return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_TIMEZONE_ID, SYSTEM_SETTINGS_KEY_LOCALE_TIMEZONE, 4, user_data);
+}
+/*  LCOV_EXCL_STOP */
+
+/*  LCOV_EXCL_START */
+int system_setting_unset_changed_callback_locale_timezone(system_settings_key_e key)
+{
+       return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_TIMEZONE_ID, 4);
+}
+/*  LCOV_EXCL_STOP */
+
+/*  LCOV_EXCL_START */
 int system_setting_set_changed_callback_locale_timezone_changed(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
 {
        SETTING_TRACE_BEGIN;
        return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
 }
+/*  LCOV_EXCL_STOP */
 
+/*  LCOV_EXCL_START */
 int system_setting_unset_changed_callback_locale_timezone_changed(system_settings_key_e key)
 {
        SETTING_TRACE_BEGIN;
        return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
 }
+/*  LCOV_EXCL_STOP */
 
 
+/*  LCOV_EXCL_START */
 int system_setting_get_time_changed(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
 {
        SETTING_TRACE_BEGIN;
        time_t cur_tick;
+       int ** val = (int**)value;
        cur_tick = time(NULL);
-       *value = (void *)cur_tick;
+       **val = cur_tick;
        /* struct tm * localtime = time (cur_tick); */
        /* printf("%s\n", ctime(&cur_tick); */
        return SYSTEM_SETTINGS_ERROR_NONE;
 
 }
+/*  LCOV_EXCL_STOP */
 
 int system_setting_set_changed_callback_time_changed(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
 {
@@ -1351,6 +1670,7 @@ int system_setting_unset_changed_callback_sound_lock(system_settings_key_e key)
  * a == true, b == false --> sound mode
  * a == false, b == true --> vibration mode
  */
+/*  LCOV_EXCL_START */
 int system_setting_get_sound_silent_mode(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
 {
        SETTING_TRACE_BEGIN;
@@ -1375,6 +1695,7 @@ int system_setting_get_sound_silent_mode(system_settings_key_e key, system_setti
        }
        return SYSTEM_SETTINGS_ERROR_NONE;
 }
+/*  LCOV_EXCL_STOP */
 
 /**
  * a = VCONFKEY_SETAPPL_SOUND_STATUS_BOOL b = VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL
@@ -1480,6 +1801,7 @@ int system_setting_get_auto_rotation_mode(system_settings_key_e key, system_sett
        return SYSTEM_SETTINGS_ERROR_NONE;
 }
 
+/*  LCOV_EXCL_START */
 int system_setting_set_auto_rotation_mode(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
 {
        SETTING_TRACE_BEGIN;
@@ -1491,6 +1813,7 @@ int system_setting_set_auto_rotation_mode(system_settings_key_e key, system_sett
 
        return SYSTEM_SETTINGS_ERROR_NONE;
 }
+/*  LCOV_EXCL_STOP */
 
 int system_setting_set_changed_callback_auto_rotation_mode(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
 {
@@ -1508,23 +1831,25 @@ int system_setting_get_screen_backlight_time(system_settings_key_e key, system_s
 {
        SETTING_TRACE_BEGIN;
        int vconf_value;
+       int ** val = (int**)value;
 
        if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, &vconf_value)) {
                return SYSTEM_SETTINGS_ERROR_IO_ERROR;
        }
-       *value = (void *)vconf_value;
+       **val = vconf_value;
 
        return SYSTEM_SETTINGS_ERROR_NONE;
 }
 
 
+/*  LCOV_EXCL_START */
 int system_setting_set_screen_backlight_time(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
 {
        SETTING_TRACE_BEGIN;
        int *vconf_value;
-       vconf_value = (int *)value;
+       vconf_value = *(int **)value;
 
-       if (!(*vconf_value > 0 && *vconf_value < 600)) {
+       if (!(*vconf_value > 0 && *vconf_value <= 600)) {
                SETTING_TRACE(" ERR Betweeny here  0 ~ 600");
                return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
        }
@@ -1535,11 +1860,12 @@ int system_setting_set_screen_backlight_time(system_settings_key_e key, system_s
        SETTING_TRACE_END;
        return SYSTEM_SETTINGS_ERROR_NONE;
 }
+/*  LCOV_EXCL_STOP */
 
 int system_setting_set_changed_callback_screen_backlight_time(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
 {
        SETTING_TRACE_BEGIN;
-       return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, SYSTEM_SETTINGS_KEY_DISPLAY_SCREEN_ROTATION_AUTO, 2, user_data);
+       return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, SYSTEM_SETTINGS_KEY_SCREEN_BACKLIGHT_TIME, 2, user_data);
 }
 
 int system_setting_unset_changed_callback_screen_backlight_time(system_settings_key_e key)
@@ -1560,6 +1886,7 @@ int system_setting_get_sound_notification(system_settings_key_e key, system_sett
        return SYSTEM_SETTINGS_ERROR_NONE;
 }
 
+/*  LCOV_EXCL_START */
 int system_setting_set_sound_notification(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
 {
        SETTING_TRACE_BEGIN;
@@ -1568,20 +1895,24 @@ int system_setting_set_sound_notification(system_settings_key_e key, system_sett
 
        int is_load = _is_file_accessible(vconf_value);
        if (is_load == 0) {
+               //SETTING_TRACE(" system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, %s) TRY", vconf_value);
                if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, vconf_value)) {
+                       //SETTING_TRACE(" system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, %s) FAIL", vconf_value);
                        return SYSTEM_SETTINGS_ERROR_IO_ERROR;
                }
        } else {
+               //SETTING_TRACE(" is_file_accessibile FAILED - system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, %s) FAIL", vconf_value);
                return SYSTEM_SETTINGS_ERROR_IO_ERROR;
        }
 
        return SYSTEM_SETTINGS_ERROR_NONE;
 }
+/*  LCOV_EXCL_STOP */
 
 int system_setting_set_changed_callback_sound_notification(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
 {
        SETTING_TRACE_BEGIN;
-       return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, SYSTEM_SETTINGS_KEY_INCOMING_CALL_RINGTONE, 0, user_data);
+       return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, SYSTEM_SETTINGS_KEY_SOUND_NOTIFICATION, 0, user_data);
 }
 
 int system_setting_unset_changed_callback_sound_notification(system_settings_key_e key)
@@ -1593,21 +1924,23 @@ int system_setting_unset_changed_callback_sound_notification(system_settings_key
 int system_setting_get_notification_repetition_period(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
 {
        SETTING_TRACE_BEGIN;
+       int ** val = (int**)value;
        int vconf_value;
 
        if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_NOTI_MSG_ALERT_REP_TYPE_INT, &vconf_value)) {
                return SYSTEM_SETTINGS_ERROR_IO_ERROR;
        }
-       *value = (void *)vconf_value;
+       **val = vconf_value;
 
        return SYSTEM_SETTINGS_ERROR_NONE;
 }
 
+/*  LCOV_EXCL_START */
 int system_setting_set_notification_repetition_period(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
 {
        SETTING_TRACE_BEGIN;
        int *vconf_value;
-       vconf_value = (int *)value;
+       vconf_value = *(int **)value;
 
        if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_NOTI_MSG_ALERT_REP_TYPE_INT, *vconf_value)) {
                return SYSTEM_SETTINGS_ERROR_IO_ERROR;
@@ -1615,6 +1948,7 @@ int system_setting_set_notification_repetition_period(system_settings_key_e key,
        SETTING_TRACE_END;
        return SYSTEM_SETTINGS_ERROR_NONE;
 }
+/*  LCOV_EXCL_STOP */
 
 int system_setting_set_changed_callback_notification_repetition_period(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
 {
@@ -1640,6 +1974,7 @@ int system_setting_get_device_name(system_settings_key_e key, system_setting_dat
        return SYSTEM_SETTINGS_ERROR_NONE;
 }
 
+/*  LCOV_EXCL_START */
 int system_setting_set_device_name(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
 {
        SETTING_TRACE_BEGIN;
@@ -1652,6 +1987,7 @@ int system_setting_set_device_name(system_settings_key_e key, system_setting_dat
 
        return SYSTEM_SETTINGS_ERROR_NONE;
 }
+/*  LCOV_EXCL_STOP */
 
 int system_setting_set_changed_callback_device_name(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
 {
@@ -1716,23 +2052,27 @@ int system_setting_unset_changed_callback_network_wifi_notification(system_setti
        return system_setting_vconf_unset_changed_cb(VCONFKEY_WIFI_ENABLE_QS, 4);
 }
 
+/*  LCOV_EXCL_START */
 int system_setting_get_lock_state(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
 {
        int vconf_value;
+       int ** val = (int**)value;
 
        if (system_setting_vconf_get_value_int(VCONFKEY_IDLE_LOCK_STATE_READ_ONLY, &vconf_value)) {
                return SYSTEM_SETTINGS_ERROR_IO_ERROR;
        }
-       *value = (void *)vconf_value;
+       **val = vconf_value;
 
        return SYSTEM_SETTINGS_ERROR_NONE;
 }
+/*  LCOV_EXCL_STOP */
 
+/*  LCOV_EXCL_START */
 int system_setting_set_lock_state(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
 {
        SETTING_TRACE_BEGIN;
        int *vconf_value;
-       vconf_value = (int *)value;
+       vconf_value = *(int **)value;
 
        if (system_setting_vconf_set_value_int(VCONFKEY_IDLE_LOCK_STATE_READ_ONLY, *vconf_value)) {
                return SYSTEM_SETTINGS_ERROR_IO_ERROR;
@@ -1740,15 +2080,85 @@ int system_setting_set_lock_state(system_settings_key_e key, system_setting_data
        SETTING_TRACE_END;
        return SYSTEM_SETTINGS_ERROR_NONE;
 }
+/*  LCOV_EXCL_STOP */
 
+/*  LCOV_EXCL_START */
 int system_setting_set_changed_callback_lock_state(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
 {
        return system_setting_vconf_set_changed_cb(VCONFKEY_IDLE_LOCK_STATE_READ_ONLY, SYSTEM_SETTINGS_KEY_LOCK_STATE, 4, user_data);
 }
+/*  LCOV_EXCL_STOP */
 
+/*  LCOV_EXCL_START */
 int system_setting_unset_changed_callback_lock_state(system_settings_key_e key)
 {
        return system_setting_vconf_unset_changed_cb(VCONFKEY_IDLE_LOCK_STATE_READ_ONLY, 4);
 }
+/*  LCOV_EXCL_STOP */
+
+//----------------------------------------------------------------------------------------------------------------------------
+
+#define DEFAULT_ADS_ID "00000000-0000-0000-0000-000000000000"
+
+int system_setting_get_ads_id(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
+{
+       SETTING_TRACE_BEGIN;
+       int optout_value = 0;
+       if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_AD_ID_OPT_OUT, &optout_value)) {
+               return SYSTEM_SETTINGS_ERROR_IO_ERROR;
+       }
+
+       if (optout_value == 1) {
+               *value = strdup(DEFAULT_ADS_ID);
+               return SYSTEM_SETTINGS_ERROR_NONE;
+       }
+
+       char *vconf_value = NULL;
+       if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_AD_ID, &vconf_value)) {
+               return SYSTEM_SETTINGS_ERROR_IO_ERROR;
+       }
+
+       *value = vconf_value;
+       return SYSTEM_SETTINGS_ERROR_NONE;
+}
+
+
+#if 0
+void make_ad_id(void)
+{
+       uuid_t uuid_value;
+       char uuid_unparsed[50] = {0};
+       uuid_generate(uuid_value);
+       uuid_unparse(uuid_value, uuid_unparsed);
+       system_setting_set_ad_id(key, uuid_unparsed); //example of setting the value
+}
+#endif
+/*  LCOV_EXCL_START */
+int system_setting_set_ads_id(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
+{
+       SETTING_TRACE_BEGIN;
+       char *vconf_value = NULL;
+       vconf_value = (char *)value;
+
+       if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_AD_ID, vconf_value)) {
+               SETTING_TRACE("Setting VCONFKEY_SETAPPL_AD_ID failed");
+               return SYSTEM_SETTINGS_ERROR_IO_ERROR;
+       }
+
+       return SYSTEM_SETTINGS_ERROR_NONE;
+}
+/*  LCOV_EXCL_STOP */
+
+int system_setting_set_changed_callback_ads_id(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
+{
+       SETTING_TRACE_BEGIN;
+       return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_AD_ID, SYSTEM_SETTINGS_KEY_ADS_ID, 0, user_data);
+}
+
+int system_setting_unset_changed_callback_ads_id(system_settings_key_e key)
+{
+       SETTING_TRACE_BEGIN;
+       return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_AD_ID, 0);
+}