X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Fsystem_setting_platform.c;h=2c8751824025a187b68c145e19d5cf01c76fe03f;hb=ca7f192e42a066759d7e43c78c6d492d0b675fb6;hp=3c8182a86cbbaf3bfaf722e1d14a244f30cc22f8;hpb=c61cca5a4845ba69cd0916a026f7a81f6d7c122b;p=platform%2Fcore%2Fapi%2Fsystem-settings.git diff --git a/src/system_setting_platform.c b/src/system_setting_platform.c index 3c8182a..2c87518 100644 --- a/src/system_setting_platform.c +++ b/src/system_setting_platform.c @@ -19,11 +19,13 @@ #include #include #include +#include #include #include #include #include +#include #include @@ -36,64 +38,69 @@ #include -//#include - -#include -#include -#include - #include +#include +#include #include #include +#include +#include -#ifdef USE_EFL_ASSIST -#include -#endif +#include -#ifdef TIZEN_WEARABLE -#define SMALL_FONT_DPI (-90) -#endif -#ifdef TIZEN_MOBILE -#define SMALL_FONT_DPI (-80) -#endif -#define MIDDLE_FONT_DPI (-100) -#ifdef TIZEN_WEARABLE -#define LARGE_FONT_DPI (-110) -#endif -#ifdef TIZEN_MOBILE -#define LARGE_FONT_DPI (-150) -#endif -#define HUGE_FONT_DPI (-190) -#define GIANT_FONT_DPI (-250) +#include +#include + +#include + +#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 "/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) -#define SETTING_FONT_PRELOAD_FONT_PATH "/usr/share/fonts" -#define SETTING_FONT_DOWNLOADED_FONT_PATH "/opt/share/fonts" +#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 -#define SETTING_FONT_CONF_FILE "/opt/etc/fonts/conf.avail/99-slp.conf" -#define SETTING_DEFAULT_FONT_CONF_FILE "/usr/opt/etc/fonts/conf.avail/99-slp.conf" +int _is_file_accessible(const char *path); -#define SETTING_STR_LEN 256 +static bool dl_is_supported_image_type_load(char *path); +static bool dl_font_config_set(char *font_name); +static char *dl_get_default_font_info(); +static int dl_is_available_font(char *str); +static void dl_font_size_set(); +static void dl_font_config_set_notification(); -#define SETTING_TIME_ZONEINFO_PATH "/usr/share/zoneinfo/" -#define SETTING_TIME_SHARE_LOCAL_PATH "/usr/share/locale" -#define SETTING_TZONE_SYMLINK_PATH "/etc/localtime" +#ifndef VCONFKEY_SETAPPL_UDSM +#define VCONFKEY_SETAPPL_UDSM "db/setting/udsm" +#endif -static char *_get_cur_font(); -static void __font_size_set(); -static int __font_size_get(); -static char *_get_default_font(); +#ifndef VCONFKEY_SETAPPL_UDSM_PKGID_LIST +#define VCONFKEY_SETAPPL_UDSM_PKGID_LIST "db/setting/udsm/pkgid_list" +#endif -static bool font_config_set(char *font_name); -static void 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) +int system_setting_get_incoming_call_ringtone(system_settings_key_e key, void **value) { SETTING_TRACE_BEGIN; char *vconf_value; @@ -115,7 +122,7 @@ int system_setting_get_incoming_call_ringtone(system_settings_key_e key, system_ } -int system_setting_get_email_alert_ringtone(system_settings_key_e key, system_setting_data_type_e data_type, void **value) +int system_setting_get_email_alert_ringtone(system_settings_key_e key, void **value) { SETTING_TRACE_BEGIN; char *vconf_value; @@ -136,7 +143,7 @@ int system_setting_get_email_alert_ringtone(system_settings_key_e key, system_se } -int system_setting_get_wallpaper_home_screen(system_settings_key_e key, system_setting_data_type_e data_type, void **value) +int system_setting_get_wallpaper_home_screen(system_settings_key_e key, void **value) { SETTING_TRACE_BEGIN; char *vconf_value; @@ -148,7 +155,7 @@ int system_setting_get_wallpaper_home_screen(system_settings_key_e key, system_s } -int system_setting_get_wallpaper_lock_screen(system_settings_key_e key, system_setting_data_type_e data_type, void **value) +int system_setting_get_wallpaper_lock_screen(system_settings_key_e key, void **value) { SETTING_TRACE_BEGIN; char *vconf_value; @@ -163,24 +170,25 @@ int system_setting_get_wallpaper_lock_screen(system_settings_key_e key, system_s /* [int] vconf GET */ -int system_setting_get_font_size(system_settings_key_e key, system_setting_data_type_e data_type, void **value) +int system_setting_get_font_size(system_settings_key_e key, void **value) { 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; } -int system_setting_get_default_font_type(system_settings_key_e key, system_setting_data_type_e data_type, void **value) +int system_setting_get_default_font_type(system_settings_key_e key, void **value) { SETTING_TRACE_BEGIN; - char *font_name = _get_default_font(); + char *font_name = dl_get_default_font_info(); if (font_name) { *value = (void *)font_name; return SYSTEM_SETTINGS_ERROR_NONE; @@ -190,17 +198,21 @@ int system_setting_get_default_font_type(system_settings_key_e key, system_setti } /* [int] vconf GET */ -int system_setting_get_font_type(system_settings_key_e key, system_setting_data_type_e data_type, void **value) +int system_setting_get_font_type(system_settings_key_e key, void **value) { SETTING_TRACE_BEGIN; - char *font_name = _get_cur_font(); - *value = (void *)font_name; + char *font_name = NULL; + + if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, &font_name)) { + return SYSTEM_SETTINGS_ERROR_IO_ERROR; + } + *value = font_name; return SYSTEM_SETTINGS_ERROR_NONE; } -int system_setting_get_motion_activation(system_settings_key_e key, system_setting_data_type_e data_type, void **value) +int system_setting_get_motion_activation(system_settings_key_e key, void **value) { SETTING_TRACE_BEGIN; bool vconf_value; @@ -213,7 +225,7 @@ int system_setting_get_motion_activation(system_settings_key_e key, system_setti return SYSTEM_SETTINGS_ERROR_NONE; } -int system_setting_get_usb_debugging_option(system_settings_key_e key, system_setting_data_type_e data_type, void **value) +int system_setting_get_usb_debugging_option(system_settings_key_e key, void **value) { SETTING_TRACE_BEGIN; bool vconf_value; @@ -226,7 +238,7 @@ int system_setting_get_usb_debugging_option(system_settings_key_e key, system_se return SYSTEM_SETTINGS_ERROR_NONE; } -int system_setting_get_3g_data_network(system_settings_key_e key, system_setting_data_type_e data_type, void **value) +int system_setting_get_3g_data_network(system_settings_key_e key, void **value) { SETTING_TRACE_BEGIN; bool vconf_value; @@ -246,12 +258,14 @@ int system_setting_get_3g_data_network(system_settings_key_e key, system_setting * * @return SYSTEM_SETTINGS_ERROR_LOCKSCREEN_APP_PASSWORD_MODE raise exception if current lock type is 'password' */ -int system_setting_get_lockscreen_app(system_settings_key_e key, system_setting_data_type_e data_type, void **value) +int system_setting_get_lockscreen_app(system_settings_key_e key, void **value) { SETTING_TRACE_BEGIN; char *pkg_name = NULL; int locktype = -1; - system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_SCREEN_LOCK_TYPE_INT, &locktype); + if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_SCREEN_LOCK_TYPE_INT, &locktype)) { + return SYSTEM_SETTINGS_ERROR_IO_ERROR; + } if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_3RD_LOCK_PKG_NAME_STR, &pkg_name)) { return SYSTEM_SETTINGS_ERROR_IO_ERROR; @@ -276,13 +290,214 @@ int _is_file_accessible(const char *path) SETTING_TRACE("found the file %s", path); return 0; } else { - // error code : 13 + /* error code : 13 */ SETTING_TRACE("found the file %s --- error code : %d ", path, errno); - return -errno; + return -errno; + } +} + + + +/*////////////////////////////////////////////////////////////////////////////////////////////////// */ +// @todo move to CMake +#define DEF_RINGTONE_FILE_PATH SETTING_DEF_RES"/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, void *value) +{ + SETTING_TRACE_BEGIN; + char* pathval = (char*)value; + char* dnameval = NULL; + char* baseval = NULL; + +#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)) { + // @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); + ret = SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER; + } + + dnameval = strdup(pathval); + baseval = strdup(pathval); + if (dnameval && baseval) { + SETTING_TRACE("---> dirname is : %s ", dirname(dnameval)); + SETTING_TRACE("---> basename is : %s ", basename(baseval)); + } + FREE(dnameval); + FREE(baseval); + + if (parser) { + g_object_unref(parser); + parser = NULL; + } + + return ret; +} + +int system_setting_del_incoming_call_ringtone(system_settings_key_e key, 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_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_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_settings_iter_cb callback, void *data) +{ + SETTING_TRACE_BEGIN; + + _get_default_ringtones(key, callback, data); + //----------------------------------------------------------------------------------------------------------------- + // 2. get the USER ringtone list + //----------------------------------------------------------------------------------------------------------------- + _get_user_ringtones(key, callback, data); + + return SYSTEM_SETTINGS_ERROR_NONE; } -int system_setting_set_incoming_call_ringtone(system_settings_key_e key, system_setting_data_type_e data_type, void *value) + +/* LCOV_EXCL_START */ +int system_setting_set_incoming_call_ringtone(system_settings_key_e key, void *value) { SETTING_TRACE_BEGIN; char *vconf_value; @@ -300,9 +515,11 @@ int system_setting_set_incoming_call_ringtone(system_settings_key_e key, system_ return SYSTEM_SETTINGS_ERROR_NONE; } +/* LCOV_EXCL_STOP */ -int system_setting_set_email_alert_ringtone(system_settings_key_e key, system_setting_data_type_e data_type, void *value) +/* LCOV_EXCL_START */ +int system_setting_set_email_alert_ringtone(system_settings_key_e key, void *value) { SETTING_TRACE_BEGIN; char *vconf_value; @@ -321,78 +538,177 @@ int system_setting_set_email_alert_ringtone(system_settings_key_e key, system_se return SYSTEM_SETTINGS_ERROR_NONE; } +/* LCOV_EXCL_STOP */ + +/* LCOV_EXCL_START */ +static bool dl_is_supported_image_type_load(char *path) +{ + void *handle = NULL; + char *error; + bool ret = false; + bool (*image_type_check)(char *path); + + 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) { + 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); + if (handle) + dlclose(handle); + return ret; +} +/* LCOV_EXCL_STOP */ -bool __is_supported_image_type_load(char *path) +/* LCOV_EXCL_START */ +static int dl_is_available_font(char *str) { - SETTING_TRACE_BEGIN; - //evas_init(); - ecore_evas_init(); - Ecore_Evas *ee; - Evas *evas; + void *handle = NULL; + char *error; + int ret = false; + int (*check_available_font)(char *font_name); - ee = ecore_evas_new(NULL, 0, 0, 100, 100, NULL); - evas = ecore_evas_get(ee); + 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 __is_available_font function at libsystem-settings-util.so.0.1.0"); + if (handle) + dlclose(handle); + return false; + } + ret = check_available_font(str); + if (handle) + dlclose(handle); + return ret; +} +/* LCOV_EXCL_STOP */ - Evas_Object *img = evas_object_image_add(evas); - evas_object_image_file_set(img, path, NULL); - Evas_Load_Error ret = evas_object_image_load_error_get(img); +/* LCOV_EXCL_START */ +static void dl_font_size_set() +{ + void *handle = NULL; + char *error; + void (*set_font_size)(); - bool result = false; - if (ret == EVAS_LOAD_ERROR_NONE) { - SETTING_TRACE("%s - OK", path); - result = true; - } else { - SETTING_TRACE("%s - NO", path); - result = false; + handle = dlopen(SETTING_UTILS_SO_FILE_PATH, RTLD_LAZY); + if (!handle) { + SETTING_TRACE("ERROR!! canNOT find libsystem-settings-util.so.0.1.0"); + return; } - ecore_evas_free(ee); - evas_shutdown(); - return result; + + set_font_size = dlsym(handle, "__font_size_set"); + 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(); + if (handle) + dlclose(handle); + return; } +/* LCOV_EXCL_STOP */ -bool __is_supported_image_type(char *path) +/* LCOV_EXCL_START */ +static void dl_font_config_set_notification() { - SETTING_TRACE_BEGIN; - bool ret = false; + void *handle = NULL; + char *error; + void (*set_font_nodification)(); + + handle = dlopen(SETTING_UTILS_SO_FILE_PATH, RTLD_LAZY); + if (!handle) { + SETTING_TRACE("ERROR!! canNOT find libsystem-settings-util.so.0.1.0"); + return; + } - evas_init(); - if (evas_object_image_extension_can_load_get(path)) - ret = true; - else - ret = false; + set_font_nodification = dlsym(handle, "font_config_set_notification"); + 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(); + if (handle) + dlclose(handle); + return; +} +/* LCOV_EXCL_STOP */ + +/* LCOV_EXCL_START */ +static bool dl_font_config_set(char *font_name) +{ + void *handle = NULL; + char *error; + bool ret = false; + bool (*check_font_type)(char *font_name); - evas_shutdown(); + 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) { + 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); + if (handle) + dlclose(handle); return ret; } +/* LCOV_EXCL_STOP */ -#define PATH_EXT_CHECK_REG ".(jpe?g|jpg|png|gif)$" -bool __is_supported_image_type_by_ext(char *file_path) +/* LCOV_EXCL_START */ +static char *dl_get_default_font_info() { - SETTING_TRACE_BEGIN; - regex_t fsm; - regmatch_t str[2048 + 1]; - - if (!file_path) return false; + void *handle = NULL; + char *error; + char *ret = NULL; + char *(*get_font_info)(); - int ret = false; - if (ret = regcomp(&fsm, PATH_EXT_CHECK_REG, REG_ICASE | REG_EXTENDED)) { - SETTING_TRACE("regular expresstion fail"); - return 1; + 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; } - /* code */ - if (regexec(&fsm, file_path, strlen(file_path) + 1, str, 0) == REG_NOMATCH) { - /*SETTING_TRACE("FAILED - %s", file_path[i]); */ - ret = 0; - } else { - /*SETTING_TRACE("MATCHED - %s", file_path[i]); */ - ret = 1; + get_font_info = dlsym(handle, "_get_default_font"); + + if ((error = dlerror()) != NULL) { + SETTING_TRACE("ERROR!! canNOT find _get_default_font function at libsystem-settings-util.so.0.1.0"); + if (handle) + dlclose(handle); + return false; } + ret = get_font_info(); + if (handle) + dlclose(handle); 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; @@ -416,7 +732,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; @@ -454,7 +772,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; @@ -465,7 +785,7 @@ static int system_setting_remove_oldest_extended_wallpaper() unsigned int temp_image_num = 0; int image_count = 0; - if ((dp = opendir("/opt/usr/data/setting/wallpaper")) == NULL) { + if ((dp = opendir(_TZ_SYS_DATA"/setting/wallpaper")) == NULL) { SETTING_TRACE("opendir error"); return SYSTEM_SETTINGS_ERROR_IO_ERROR; } @@ -489,7 +809,7 @@ static int system_setting_remove_oldest_extended_wallpaper() char buf[512]; if (min_image_name) { - snprintf(buf, sizeof(buf) - 1, "/opt/usr/data/setting/wallpaper/%s", min_image_name); + snprintf(buf, sizeof(buf) - 1, _TZ_SYS_DATA"/setting/wallpaper/%s", min_image_name); if (remove(buf) < 0) { /* remove oldest image */ return SYSTEM_SETTINGS_ERROR_IO_ERROR; } @@ -497,25 +817,30 @@ 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]; SETTING_TRACE_BEGIN; if (!file_path || !strlen(file_path)) return 0; - return (strstr(file_path, "/opt/usr/media/.bgwallpaper") != NULL); + 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 - -int system_setting_set_wallpaper_home_screen(system_settings_key_e key, system_setting_data_type_e data_type, void *value) +/* LCOV_EXCL_START */ +int system_setting_set_wallpaper_home_screen(system_settings_key_e key, void *value) { SETTING_TRACE_BEGIN; char *vconf_value; vconf_value = (char *)value; - bool isok = __is_supported_image_type_load(vconf_value); + bool isok = dl_is_supported_image_type_load(vconf_value); if (!isok) { /* not supported */ SETTING_TRACE("path : %s is not supported file format", vconf_value); @@ -535,13 +860,13 @@ int system_setting_set_wallpaper_home_screen(system_settings_key_e key, system_s #ifdef TIZEN_WEARABLE if (system_setting_check_extended_wallpaper(vconf_value)) { /* New extended wallpaper */ - DIR *dp; + DIR *dp = NULL; struct dirent *dirp; unsigned int max_image_num = 0; unsigned int temp_image_num = 0; int image_count = 0; - if ((dp = opendir("/opt/usr/data/setting/wallpaper")) == NULL) { + if ((dp = opendir(_TZ_SYS_DATA"/setting/wallpaper")) == NULL) { SETTING_TRACE("Setting - dir open error!"); return SYSTEM_SETTINGS_ERROR_IO_ERROR; } @@ -553,6 +878,8 @@ int system_setting_set_wallpaper_home_screen(system_settings_key_e key, system_s if (system_setting_get_extended_wallpaper_num(dirp->d_name, &temp_image_num) != SYSTEM_SETTINGS_ERROR_NONE) { + if (dp) + closedir(dp); return SYSTEM_SETTINGS_ERROR_IO_ERROR; } @@ -562,16 +889,18 @@ int system_setting_set_wallpaper_home_screen(system_settings_key_e key, system_s image_count++; } + if (dp) + closedir(dp); /* 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, - "/opt/usr/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 /opt/usr/data/setting/wallpaper/ */ + /* Copy image to _TZ_SYS_DATA/setting/wallpaper/ */ if (system_setting_copy_extended_wallpaper(file_name_buffer, vconf_value) != SYSTEM_SETTINGS_ERROR_NONE) { return SYSTEM_SETTINGS_ERROR_IO_ERROR; @@ -591,7 +920,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 { @@ -603,14 +932,16 @@ int system_setting_set_wallpaper_home_screen(system_settings_key_e key, system_s return SYSTEM_SETTINGS_ERROR_NONE; } +/* LCOV_EXCL_STOP */ -int system_setting_set_wallpaper_lock_screen(system_settings_key_e key, system_setting_data_type_e data_type, void *value) +/* LCOV_EXCL_START */ +int system_setting_set_wallpaper_lock_screen(system_settings_key_e key, void *value) { SETTING_TRACE_BEGIN; char *vconf_value; vconf_value = (char *)value; - bool isok = __is_supported_image_type_load(vconf_value); + bool isok = dl_is_supported_image_type_load(vconf_value); if (!isok) { /* not supported */ SETTING_TRACE("path : %s is not supported file format", vconf_value); @@ -629,12 +960,14 @@ int system_setting_set_wallpaper_lock_screen(system_settings_key_e key, system_s return SYSTEM_SETTINGS_ERROR_NONE; } +/* LCOV_EXCL_STOP */ -int system_setting_set_font_size(system_settings_key_e key, system_setting_data_type_e data_type, void *value) +/* LCOV_EXCL_START */ +int system_setting_set_font_size(system_settings_key_e key, 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; @@ -643,13 +976,15 @@ int system_setting_set_font_size(system_settings_key_e key, system_setting_data_ if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, *vconf_value)) { return SYSTEM_SETTINGS_ERROR_IO_ERROR; } - __font_size_set(); + dl_font_size_set(); 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; @@ -677,7 +1012,7 @@ void *font_conf_doc_parse(char *doc_name, char *font_name) cur = cur->xmlChildrenNode; - Eina_Bool is_changed = EINA_FALSE; + bool is_changed = false; while (cur != NULL) { if ((!xmlStrcmp(cur->name, (const xmlChar *)"match"))) { cur2 = cur->xmlChildrenNode; @@ -700,7 +1035,7 @@ void *font_conf_doc_parse(char *doc_name, char *font_name) key = xmlNodeListGetString(doc, cur3->xmlChildrenNode, 1); xmlFree(key); key = NULL; - is_changed = EINA_TRUE; + is_changed = true; } cur3 = cur3->next; } @@ -715,7 +1050,7 @@ void *font_conf_doc_parse(char *doc_name, char *font_name) key = xmlNodeListGetString(doc, cur2->xmlChildrenNode, 1); xmlFree(key); key = NULL; - is_changed = EINA_TRUE; + is_changed = true; } else if ((!xmlStrcmp(cur2->name, (const xmlChar *)"prefer"))) { cur3 = cur2->xmlChildrenNode; while (cur3 != NULL) { @@ -724,7 +1059,7 @@ void *font_conf_doc_parse(char *doc_name, char *font_name) key = xmlNodeListGetString(doc, cur3->xmlChildrenNode, 1); xmlFree(key); key = NULL; - is_changed = EINA_TRUE; + is_changed = true; cur3 = cur3->next; return doc; } @@ -745,15 +1080,17 @@ void *font_conf_doc_parse(char *doc_name, char *font_name) return NULL; } } +/* LCOV_EXCL_STOP */ -int system_setting_set_font_type(system_settings_key_e key, system_setting_data_type_e data_type, void *value) +/* LCOV_EXCL_START */ +int system_setting_set_font_type(system_settings_key_e key, void *value) { SETTING_TRACE_BEGIN; char *font_name = NULL; font_name = (char *)value; /* get current font list */ - int is_found = __is_available_font(font_name); + int is_found = dl_is_available_font(font_name); if (is_found) { SETTING_TRACE("found font : %s ", font_name); @@ -762,7 +1099,7 @@ int system_setting_set_font_type(system_settings_key_e key, system_setting_data_ return SYSTEM_SETTINGS_ERROR_IO_ERROR; } - bool bsave = font_config_set(font_name); + bool bsave = dl_font_config_set(font_name); if (!bsave) { SETTING_TRACE(" font type save error by font_config_set() "); @@ -778,7 +1115,7 @@ int system_setting_set_font_type(system_settings_key_e key, system_setting_data_ doc = NULL; } - font_config_set_notification(); + dl_font_config_set_notification(); char *vconf_value; vconf_value = (char *)value; @@ -788,8 +1125,10 @@ int system_setting_set_font_type(system_settings_key_e key, system_setting_data_ } return SYSTEM_SETTINGS_ERROR_NONE; } +/* LCOV_EXCL_STOP */ -int system_setting_set_motion_activation(system_settings_key_e key, system_setting_data_type_e data_type, void *value) +/* LCOV_EXCL_START */ +int system_setting_set_motion_activation(system_settings_key_e key, void *value) { SETTING_TRACE_BEGIN; bool *vconf_value; @@ -799,8 +1138,10 @@ int system_setting_set_motion_activation(system_settings_key_e key, system_setti } return SYSTEM_SETTINGS_ERROR_NONE; } +/* LCOV_EXCL_STOP */ -int system_setting_set_usb_debugging_option(system_settings_key_e key, system_setting_data_type_e data_type, void *value) +/* LCOV_EXCL_START */ +int system_setting_set_usb_debugging_option(system_settings_key_e key, void *value) { SETTING_TRACE_BEGIN; bool *vconf_value; @@ -811,8 +1152,10 @@ int system_setting_set_usb_debugging_option(system_settings_key_e key, system_se return SYSTEM_SETTINGS_ERROR_NONE; } +/* LCOV_EXCL_STOP */ -int system_setting_set_3g_data_network(system_settings_key_e key, system_setting_data_type_e data_type, void *value) +/* LCOV_EXCL_START */ +int system_setting_set_3g_data_network(system_settings_key_e key, void *value) { SETTING_TRACE_BEGIN; bool *vconf_value; @@ -823,7 +1166,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; @@ -838,13 +1183,16 @@ 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' * */ -int system_setting_set_lockscreen_app(system_settings_key_e key, system_setting_data_type_e data_type, void *value) + +/* LCOV_EXCL_START */ +int system_setting_set_lockscreen_app(system_settings_key_e key, void *value) { SETTING_TRACE_BEGIN; char *vconf_value; @@ -852,7 +1200,6 @@ int system_setting_set_lockscreen_app(system_settings_key_e key, system_setting_ int r = 0; pkgmgrinfo_appinfo_h handle; - char *apptype = NULL; r = pkgmgrinfo_appinfo_get_appinfo(vconf_value, &handle); if (r != PMINFO_R_OK) { SETTING_TRACE("*** pkginfo failed "); @@ -888,6 +1235,7 @@ int system_setting_set_lockscreen_app(system_settings_key_e key, system_setting_ } return SYSTEM_SETTINGS_ERROR_NONE; } +/* LCOV_EXCL_STOP */ /*/////////////////////////////////////////////////////////////////////////////////////////////// */ /* */ @@ -1017,513 +1365,105 @@ int system_setting_unset_changed_callback_motion_activation(system_settings_key_ return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_MOTION_ACTIVATION, 3); } -static char *_get_cur_font() +/*//////////////////////////////////////////////////////////////////////////////////////// */ +/*--------------------------------------- */ +int system_setting_get_locale_country(system_settings_key_e key, void **value) { SETTING_TRACE_BEGIN; - xmlDocPtr doc = NULL; - xmlNodePtr cur = NULL; - xmlNodePtr cur2 = NULL; - xmlNodePtr cur3 = NULL; - xmlChar *key = NULL; - - char *font_name = NULL; - - doc = xmlParseFile(SETTING_FONT_CONF_FILE); + char *vconf_value = NULL; + if (system_setting_vconf_get_value_string(VCONFKEY_REGIONFORMAT, &vconf_value)) { + return SYSTEM_SETTINGS_ERROR_IO_ERROR; + } - cur = xmlDocGetRootElement(doc); + /* parsing validation */ + /* en_US.UTF-8 */ + char arr[20]; + snprintf(arr, 20, "%s", vconf_value); + arr[5] = '\0'; + *value = strdup(arr); + free(vconf_value); + vconf_value = NULL; - if (cur == NULL) { - xmlFreeDoc(doc); - doc = NULL; - return NULL; - } + return SYSTEM_SETTINGS_ERROR_NONE; +} - if (xmlStrcmp(cur->name, (const xmlChar *)"fontconfig")) { - xmlFreeDoc(doc); - doc = NULL; - return NULL; - } +/* LCOV_EXCL_START */ +int system_setting_set_locale_country(system_settings_key_e key, void *value) +{ + SETTING_TRACE_BEGIN; + char *vconf_value = NULL; + vconf_value = (char *)value; - cur = cur->xmlChildrenNode; + char *ext = "UTF-8"; - while (cur != NULL) { - if ((!xmlStrcmp(cur->name, (const xmlChar *)"match"))) { - cur2 = cur->xmlChildrenNode; - while (cur2 != NULL) { - if ((!xmlStrcmp(cur2->name, (const xmlChar *)"edit"))) { - cur3 = cur2->xmlChildrenNode; - while (cur3 != NULL) { - if ((!xmlStrcmp(cur3->name, (const xmlChar *)"string"))) { - key = xmlNodeListGetString(doc, cur3->xmlChildrenNode, 1); + char arr[20]; + snprintf(arr, 20, "%s.%s", vconf_value, ext); - font_name = g_strdup((char *)key); - xmlFree(key); - key = NULL; - xmlFreeDoc(doc); - doc = NULL; - return font_name; - } - cur3 = cur3->next; - } - } - cur2 = cur2->next; - } - } - cur = cur->next; + if (system_setting_vconf_set_value_string(VCONFKEY_REGIONFORMAT, arr)) { + return SYSTEM_SETTINGS_ERROR_IO_ERROR; } - - xmlFreeDoc(doc); - doc = NULL; - return NULL; + return SYSTEM_SETTINGS_ERROR_NONE; } +/* LCOV_EXCL_STOP */ -static void font_config_set_notification() +int system_setting_set_changed_callback_locale_country(system_settings_key_e key, system_settings_changed_cb callback, void *user_data) { SETTING_TRACE_BEGIN; -#if 0 - /* notification */ - Ecore_X_Window ecore_win = ecore_x_window_root_first_get(); - Ecore_X_Atom atom = ecore_x_atom_get("FONT_TYPE_change"); - ecore_x_window_prop_string_set(ecore_win, atom, "tizen"); -#endif + return system_setting_vconf_set_changed_cb(VCONFKEY_REGIONFORMAT, SYSTEM_SETTINGS_KEY_LOCALE_COUNTRY, 3, user_data); } -int __is_available_font(char *font_name) +int system_setting_unset_changed_callback_locale_country(system_settings_key_e key) { SETTING_TRACE_BEGIN; - FcObjectSet *os = NULL; - FcFontSet *fs = NULL; - FcPattern *pat = NULL; - Eina_List *list = NULL; - FcConfig *font_config = NULL; - - int ret = 0; - - if (font_name == NULL) - return -1; + return system_setting_vconf_unset_changed_cb(VCONFKEY_REGIONFORMAT, 3); +} - font_config = FcInitLoadConfigAndFonts(); - /*setting_retvm_if(font_config == NULL, NULL, "Failed: FcInitLoadConfigAndFonts"); */ +/*--------------------------------------- */ +int system_setting_get_locale_language(system_settings_key_e key, void **value) +{ + SETTING_TRACE_BEGIN; + char *vconf_value = NULL; + if (system_setting_vconf_get_value_string(VCONFKEY_LANGSET, &vconf_value)) { + return SYSTEM_SETTINGS_ERROR_IO_ERROR; + } - char *locale = setlocale(0, NULL); + /* parsing validation */ + /* en_US.UTF-8 */ + char arr[20]; + snprintf(arr, 20, "%s", vconf_value); + arr[5] = '\0'; + *value = strdup(arr); + free(vconf_value); + vconf_value = NULL; + return SYSTEM_SETTINGS_ERROR_NONE; +} - pat = FcPatternCreate(); +/* LCOV_EXCL_START */ +int system_setting_set_locale_language(system_settings_key_e key, void *value) +{ + SETTING_TRACE_BEGIN; + char *vconf_value = NULL; + vconf_value = (char *)value; - os = FcObjectSetBuild(FC_FAMILY, FC_FILE, FC_FAMILYLANG, (char *) 0); + char *ext = "UTF-8"; - if (os) { - fs = FcFontList(font_config, pat, os); - FcObjectSetDestroy(os); - os = NULL; - } + char arr[20]; + snprintf(arr, 20, "%s.%s", vconf_value, ext); - if (pat) { - FcPatternDestroy(pat); - pat = NULL; + if (system_setting_vconf_set_value_string(VCONFKEY_LANGSET, arr)) { + return SYSTEM_SETTINGS_ERROR_IO_ERROR; } + return SYSTEM_SETTINGS_ERROR_NONE; +} +/* LCOV_EXCL_STOP */ - if (fs) { - int j; - SETTING_TRACE("fs->nfont = %d", fs->nfont); - - for (j = 0; j < fs->nfont; j++) { - FcChar8 *family = NULL; - FcChar8 *file = NULL; - - if (FcPatternGetString(fs->fonts[j], FC_FILE, 0, &file) == FcResultMatch) { - int preload_path_len = strlen(SETTING_FONT_PRELOAD_FONT_PATH); - int download_path_len = strlen(SETTING_FONT_DOWNLOADED_FONT_PATH); - - if (file && (!strncmp((const char *)file, SETTING_FONT_PRELOAD_FONT_PATH, preload_path_len) - || !strncmp((const char *)file, SETTING_FONT_DOWNLOADED_FONT_PATH, download_path_len))) { - char *family_result = NULL; - FcChar8 *lang = NULL; - int id = 0; - if (FcPatternGetString(fs->fonts[j], FC_FAMILY, id, &family) != FcResultMatch) { - break; - } - if (FcPatternGetString(fs->fonts[j], FC_FAMILYLANG, id, &lang) != FcResultMatch) { - break; - } - family_result = (char *)family; - - /* Find proper family name for current locale. */ - while (locale && family && lang) { - if (!strncmp(locale, (char *)lang, strlen((char *)lang))) { - family_result = (char *)family; - break; - } - - /* I will set english as default family language. */ - /* If there is no proper family language for current locale, */ - /* we have to show the english family name. */ - if (!strcmp(lang, "en")) { - family_result = (char *)family; - } - id++; - if (FcPatternGetString(fs->fonts[j], FC_FAMILY, id, &family) != FcResultMatch) { - break; - } - if (FcPatternGetString(fs->fonts[j], FC_FAMILYLANG, id, &lang) != FcResultMatch) { - break; - } - } - - if (family_result) { - SETTING_TRACE("-------- FONT - family_result = %s", (char *)family_result); - if (strcmp(family_result, font_name) == 0) { - ret = 1; - break; - } - } - } - } - } - FcFontSetDestroy(fs); - fs = NULL; - } - FcConfigDestroy(font_config); - font_config = NULL; - return ret; -} - - -static char *_get_default_font() -{ - SETTING_TRACE_BEGIN; - xmlDocPtr doc = NULL; - xmlNodePtr cur = NULL; - xmlNodePtr cur2 = NULL; - xmlNodePtr cur3 = NULL; - xmlChar *key = NULL; - struct _xmlAttr *properties = NULL; - char *default_font_name = NULL; - - doc = xmlParseFile(SETTING_DEFAULT_FONT_CONF_FILE); - - cur = xmlDocGetRootElement(doc); - - if (cur == NULL) { - xmlFreeDoc(doc); - doc = NULL; - return NULL; - } - - if (xmlStrcmp(cur->name, (const xmlChar *)"fontconfig")) { - xmlFreeDoc(doc); - doc = NULL; - return NULL; - } - - cur = cur->xmlChildrenNode; - - while (cur != NULL) { - if ((!xmlStrcmp(cur->name, (const xmlChar *)"match"))) { - cur2 = cur->xmlChildrenNode; - while (cur2 != NULL) { - if ((!xmlStrcmp(cur2->name, (const xmlChar *)"edit"))) { - properties = cur2->properties; - /*find the "name" property*/ - while (NULL != properties) { - if (!xmlStrcmp(properties->name, (const xmlChar *)"name")) { - break; - } - properties = properties->next; - } - - /*If the value of "name" property is "family", then get the child node string, - it shall be the default font type*/ - if (NULL != properties && !xmlStrcmp(properties->children->content, (const xmlChar *)"family")) { - cur3 = cur2->xmlChildrenNode; - while (cur3 != NULL) { - if ((!xmlStrcmp(cur3->name, (const xmlChar *)"string"))) { - key = xmlNodeListGetString(doc, cur3->xmlChildrenNode, 1); - default_font_name = g_strdup((char *)key); - xmlFree(key); - key = NULL; - xmlFreeDoc(doc); - doc = NULL; - return default_font_name; - } - cur3 = cur3->next; - } - } - } - cur2 = cur2->next; - } - } - cur = cur->next; - } - - xmlFreeDoc(doc); - doc = NULL; - return NULL; -} - -static bool font_config_set(char *font_name) -{ - SETTING_TRACE_BEGIN; - Eina_List *text_classes = NULL; - Elm_Text_Class *etc = NULL; - const Eina_List *l = NULL; - Eina_List *fo_list = NULL; - Elm_Font_Overlay *efo = NULL; - - int font_size = __font_size_get(); - int size = 0; - - text_classes = elm_config_text_classes_list_get(); - - fo_list = (Eina_List *)elm_config_font_overlay_list_get(); - - Eina_List *ll = NULL; - Eina_List *l_next = NULL; - - Eina_Bool slp_medium_exist = EINA_FALSE; - Eina_Bool slp_roman_exist = EINA_FALSE; - Eina_Bool slp_bold_exist = EINA_FALSE; - Eina_Bool slp_regular_exist = EINA_FALSE; - - /* Tizen */ - Eina_Bool tizen_exist = EINA_FALSE; - - EINA_LIST_FOREACH_SAFE(fo_list, ll, l_next, efo) { - if (!strcmp(efo->text_class, "tizen_medium")) { - elm_config_font_overlay_set(efo->text_class, (const char *)font_name, efo->size); - slp_medium_exist = EINA_TRUE; - } else if (!strcmp(efo->text_class, "tizen_roman")) { - elm_config_font_overlay_set(efo->text_class, (const char *)font_name, efo->size); - slp_roman_exist = EINA_TRUE; - } else if (!strcmp(efo->text_class, "tizen_bold")) { - elm_config_font_overlay_set(efo->text_class, (const char *)font_name, efo->size); - slp_bold_exist = EINA_TRUE; - } else if (!strcmp(efo->text_class, "tizen_regular")) { - elm_config_font_overlay_set(efo->text_class, (const char *)font_name, efo->size); - slp_regular_exist = EINA_TRUE; - } - - /* Tizen */ - if (!strcmp(efo->text_class, "tizen")) { - elm_config_font_overlay_set(efo->text_class, (const char *)font_name, efo->size); - tizen_exist = EINA_TRUE; - } - - } - - /* if slp_XX do not exist, need to set them, font size is -100(100%) */ - if (slp_medium_exist == EINA_FALSE) { - elm_config_font_overlay_set("tizen_medium", (const char *)font_name, MIDDLE_FONT_DPI); - } - if (slp_roman_exist == EINA_FALSE) { - elm_config_font_overlay_set("tizen_roman", (const char *)font_name, MIDDLE_FONT_DPI); - } - if (slp_bold_exist == EINA_FALSE) { - elm_config_font_overlay_set("tizen_bold", (const char *)font_name, MIDDLE_FONT_DPI); - } - if (slp_regular_exist == EINA_FALSE) { - elm_config_font_overlay_set("tizen_regular", (const char *)font_name, MIDDLE_FONT_DPI); - } - - /* Tizen */ - if (tizen_exist == EINA_FALSE) { - elm_config_font_overlay_set("tizen", (const char *)font_name, MIDDLE_FONT_DPI); - } - - elm_config_font_overlay_set("tizen", (const char *)font_name, MIDDLE_FONT_DPI); - - /* Tizen */ - elm_config_font_overlay_set("tizen", (const char *)font_name, MIDDLE_FONT_DPI); - - EINA_LIST_FOREACH(text_classes, l, etc) { - ll = NULL; - - size = font_size; - EINA_LIST_FOREACH(fo_list, ll, efo) { - if (!strcmp(etc->name, efo->text_class)) { - size = efo->size; - } - } - elm_config_font_overlay_set(etc->name, (const char *)font_name, size); - } - elm_config_text_classes_list_free(text_classes); - text_classes = NULL; - - /* add new function */ -#ifdef USE_EFL_ASSIST - ea_theme_system_font_set(font_name, font_size); - ea_theme_system_fonts_apply(); -#endif - - elm_config_font_overlay_apply(); - elm_config_all_flush(); - elm_config_save(); - return 1; -} - -static void __font_size_set() -{ - SETTING_TRACE_BEGIN; - Eina_List *text_classes = NULL; - Elm_Text_Class *etc = NULL; - const Eina_List *l = NULL; - int font_size = __font_size_get(); - char *font_name = _get_cur_font(); - - if (font_size == -1) { - return; - } - - text_classes = elm_config_text_classes_list_get(); - - EINA_LIST_FOREACH(text_classes, l, etc) { - elm_config_font_overlay_set(etc->name, font_name, font_size); - } - - elm_config_text_classes_list_free(text_classes); - -#ifdef USE_EFL_ASSIST - ea_theme_system_font_set(font_name, font_size); - ea_theme_system_fonts_apply(); -#endif - - elm_config_font_overlay_apply(); - elm_config_all_flush(); - elm_config_save(); - - text_classes = NULL; - g_free(font_name); -} - -static int __font_size_get() -{ - SETTING_TRACE_BEGIN; - int font_size = -1; - int err = -1; - - int vconf_value = -1; - if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, &vconf_value)) { - return -1; - } - - switch (vconf_value) { - case SYSTEM_SETTINGS_FONT_SIZE_SMALL: - font_size = SMALL_FONT_DPI; - break; - case SYSTEM_SETTINGS_FONT_SIZE_NORMAL: - font_size = MIDDLE_FONT_DPI; - break; - case SYSTEM_SETTINGS_FONT_SIZE_LARGE: - font_size = LARGE_FONT_DPI; - break; - case SYSTEM_SETTINGS_FONT_SIZE_HUGE: - font_size = HUGE_FONT_DPI; - break; - case SYSTEM_SETTINGS_FONT_SIZE_GIANT: - font_size = GIANT_FONT_DPI; - break; - default: - font_size = MIDDLE_FONT_DPI; - break; - } - return font_size; -} - -/*//////////////////////////////////////////////////////////////////////////////////////// */ -/*--------------------------------------- */ -int system_setting_get_locale_country(system_settings_key_e key, system_setting_data_type_e data_type, void **value) -{ - SETTING_TRACE_BEGIN; - char *vconf_value = NULL; - if (system_setting_vconf_get_value_string(VCONFKEY_REGIONFORMAT, &vconf_value)) { - return SYSTEM_SETTINGS_ERROR_IO_ERROR; - } - - /* parsing validation */ - /* en_US.UTF-8 */ - char arr[20]; - snprintf(arr, 20, vconf_value); - arr[5] = '\0'; - *value = strdup(arr); - free(vconf_value); - vconf_value = NULL; - - return SYSTEM_SETTINGS_ERROR_NONE; -} - -int system_setting_set_locale_country(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; - - char *ext = "UTF-8"; - - char arr[20]; - snprintf(arr, 20, "%s.%s", vconf_value, ext); - - if (system_setting_vconf_set_value_string(VCONFKEY_REGIONFORMAT, arr)) { - return SYSTEM_SETTINGS_ERROR_IO_ERROR; - } - return SYSTEM_SETTINGS_ERROR_NONE; -} - -int system_setting_set_changed_callback_locale_country(system_settings_key_e key, system_settings_changed_cb callback, void *user_data) -{ - SETTING_TRACE_BEGIN; - return system_setting_vconf_set_changed_cb(VCONFKEY_REGIONFORMAT, SYSTEM_SETTINGS_KEY_LOCALE_COUNTRY, 3, user_data); -} - -int system_setting_unset_changed_callback_locale_country(system_settings_key_e key) -{ - SETTING_TRACE_BEGIN; - return system_setting_vconf_unset_changed_cb(VCONFKEY_REGIONFORMAT, 3); -} - - -/*--------------------------------------- */ -int system_setting_get_locale_language(system_settings_key_e key, system_setting_data_type_e data_type, void **value) -{ - SETTING_TRACE_BEGIN; - char *vconf_value = NULL; - if (system_setting_vconf_get_value_string(VCONFKEY_LANGSET, &vconf_value)) { - return SYSTEM_SETTINGS_ERROR_IO_ERROR; - } - - /* parsing validation */ - /* en_US.UTF-8 */ - char arr[20]; - snprintf(arr, 20, vconf_value); - arr[5] = '\0'; - *value = strdup(arr); - free(vconf_value); - vconf_value = NULL; - return SYSTEM_SETTINGS_ERROR_NONE; -} - -int system_setting_set_locale_language(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; - - char *ext = "UTF-8"; - - char arr[20]; - snprintf(arr, 20, "%s.%s", vconf_value, ext); - - if (system_setting_vconf_set_value_string(VCONFKEY_LANGSET, arr)) { - return SYSTEM_SETTINGS_ERROR_IO_ERROR; - } - return SYSTEM_SETTINGS_ERROR_NONE; -} - -int system_setting_set_changed_callback_locale_language(system_settings_key_e key, system_settings_changed_cb callback, void *user_data) -{ - SETTING_TRACE_BEGIN; - /*return system_setting_vconf_set_changed_cb(VCONFKEY_LANGSET, SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, 3, user_data ); */ - return system_setting_vconf_set_changed_cb(VCONFKEY_LANGSET, SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, 100, user_data); -} +int system_setting_set_changed_callback_locale_language(system_settings_key_e key, system_settings_changed_cb callback, void *user_data) +{ + SETTING_TRACE_BEGIN; + /*return system_setting_vconf_set_changed_cb(VCONFKEY_LANGSET, SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, 3, user_data ); */ + return system_setting_vconf_set_changed_cb(VCONFKEY_LANGSET, SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, 100, user_data); +} int system_setting_unset_changed_callback_locale_language(system_settings_key_e key) { @@ -1532,7 +1472,8 @@ int system_setting_unset_changed_callback_locale_language(system_settings_key_e } /*--------------------------------------- */ -int system_setting_get_locale_timeformat_24hour(system_settings_key_e key, system_setting_data_type_e data_type, void **value) +/* LCOV_EXCL_START */ +int system_setting_get_locale_timeformat_24hour(system_settings_key_e key, void **value) { SETTING_TRACE_BEGIN; int vconf_value; @@ -1541,7 +1482,7 @@ int system_setting_get_locale_timeformat_24hour(system_settings_key_e key, syste return SYSTEM_SETTINGS_ERROR_IO_ERROR; } - bool ret_value; + bool ret_value = true; if (vconf_value == VCONFKEY_TIME_FORMAT_12) ret_value = false; else if (vconf_value == VCONFKEY_TIME_FORMAT_24) @@ -1551,8 +1492,9 @@ 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) +int system_setting_set_locale_timeformat_24hour(system_settings_key_e key, void *value) { SETTING_TRACE_BEGIN; bool *vconf_value; @@ -1586,51 +1528,92 @@ int system_setting_unset_changed_callback_locale_timeformat_24hour(system_settin return system_setting_vconf_unset_changed_cb(VCONFKEY_REGIONFORMAT_TIME1224, 3); } -int system_setting_get_locale_timezone(system_settings_key_e key, system_setting_data_type_e data_type, void **value) +int system_setting_get_locale_timezone(system_settings_key_e key, 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, 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 */ -int system_setting_get_time_changed(system_settings_key_e key, system_setting_data_type_e data_type, void **value) +/* LCOV_EXCL_START */ +int system_setting_get_time_changed(system_settings_key_e key, 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) { @@ -1647,7 +1630,7 @@ int system_setting_unset_changed_callback_time_changed(system_settings_key_e key /* SYSTEM_SETTINGS_KEY_SOUND_LOCK */ -int system_setting_get_sound_lock(system_settings_key_e key, system_setting_data_type_e data_type, void **value) +int system_setting_get_sound_lock(system_settings_key_e key, void **value) { SETTING_TRACE_BEGIN; bool vconf_value; @@ -1679,7 +1662,8 @@ 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 */ -int system_setting_get_sound_silent_mode(system_settings_key_e key, system_setting_data_type_e data_type, void **value) +/* LCOV_EXCL_START */ +int system_setting_get_sound_silent_mode(system_settings_key_e key, void **value) { SETTING_TRACE_BEGIN; bool sound_cond; @@ -1703,6 +1687,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 @@ -1710,7 +1695,7 @@ int system_setting_get_sound_silent_mode(system_settings_key_e key, system_setti * a == false, b == false --> silent mode * a == true, b == false --> sound mode */ -int system_setting_set_sound_silent_mode(system_settings_key_e key, system_setting_data_type_e data_type, void *value) +int system_setting_set_sound_silent_mode(system_settings_key_e key, void *value) { SETTING_TRACE_BEGIN; bool *vconf_value; @@ -1755,7 +1740,7 @@ int system_setting_unset_changed_callback_sound_silent_mode(system_settings_key_ } /* SYSTEM_SETTINGS_KEY_SOUND_TOUCH */ -int system_setting_get_sound_touch(system_settings_key_e key, system_setting_data_type_e data_type, void **value) +int system_setting_get_sound_touch(system_settings_key_e key, void **value) { SETTING_TRACE_BEGIN; bool vconf_value; @@ -1782,7 +1767,7 @@ int system_setting_unset_changed_callback_sound_touch(system_settings_key_e key) #if 0 /* SYSTEM_SETTINGS_KEY_SOUND_LOCK */ -int system_setting_get_sound_lock(system_settings_key_e key, system_setting_data_type_e data_type, void **value) +int system_setting_get_sound_lock(system_settings_key_e key, void **value) { bool vconf_value; @@ -1795,7 +1780,7 @@ int system_setting_get_sound_lock(system_settings_key_e key, system_setting_data } #endif -int system_setting_get_auto_rotation_mode(system_settings_key_e key, system_setting_data_type_e data_type, void **value) +int system_setting_get_auto_rotation_mode(system_settings_key_e key, void **value) { SETTING_TRACE_BEGIN; bool vconf_value; @@ -1808,7 +1793,8 @@ int system_setting_get_auto_rotation_mode(system_settings_key_e key, system_sett return SYSTEM_SETTINGS_ERROR_NONE; } -int system_setting_set_auto_rotation_mode(system_settings_key_e key, system_setting_data_type_e data_type, void *value) +/* LCOV_EXCL_START */ +int system_setting_set_auto_rotation_mode(system_settings_key_e key, void *value) { SETTING_TRACE_BEGIN; bool *vconf_value; @@ -1819,6 +1805,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) { @@ -1832,27 +1819,29 @@ int system_setting_unset_changed_callback_auto_rotation_mode(system_settings_key return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, 2); } -int system_setting_get_screen_backlight_time(system_settings_key_e key, system_setting_data_type_e data_type, void **value) +int system_setting_get_screen_backlight_time(system_settings_key_e key, void **value) { 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; } -int system_setting_set_screen_backlight_time(system_settings_key_e key, system_setting_data_type_e data_type, void *value) +/* LCOV_EXCL_START */ +int system_setting_set_screen_backlight_time(system_settings_key_e key, 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; } @@ -1863,11 +1852,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) @@ -1876,7 +1866,7 @@ int system_setting_unset_changed_callback_screen_backlight_time(system_settings_ return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, 2); } -int system_setting_get_sound_notification(system_settings_key_e key, system_setting_data_type_e data_type, void **value) +int system_setting_get_sound_notification(system_settings_key_e key, void **value) { SETTING_TRACE_BEGIN; char *vconf_value = NULL; @@ -1888,7 +1878,8 @@ int system_setting_get_sound_notification(system_settings_key_e key, system_sett return SYSTEM_SETTINGS_ERROR_NONE; } -int system_setting_set_sound_notification(system_settings_key_e key, system_setting_data_type_e data_type, void *value) +/* LCOV_EXCL_START */ +int system_setting_set_sound_notification(system_settings_key_e key, void *value) { SETTING_TRACE_BEGIN; char *vconf_value = NULL; @@ -1896,20 +1887,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) @@ -1918,24 +1913,26 @@ int system_setting_unset_changed_callback_sound_notification(system_settings_key return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, 0); } -int system_setting_get_notification_repetition_period(system_settings_key_e key, system_setting_data_type_e data_type, void **value) +int system_setting_get_notification_repetition_period(system_settings_key_e key, 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; } -int system_setting_set_notification_repetition_period(system_settings_key_e key, system_setting_data_type_e data_type, void *value) +/* LCOV_EXCL_START */ +int system_setting_set_notification_repetition_period(system_settings_key_e key, 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; @@ -1943,6 +1940,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) { @@ -1956,7 +1954,7 @@ int system_setting_unset_changed_callback_notification_repetition_period(system_ return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_ALERT_REP_TYPE_INT, 1); } -int system_setting_get_device_name(system_settings_key_e key, system_setting_data_type_e data_type, void **value) +int system_setting_get_device_name(system_settings_key_e key, void **value) { SETTING_TRACE_BEGIN; char *vconf_value = NULL; @@ -1968,7 +1966,8 @@ int system_setting_get_device_name(system_settings_key_e key, system_setting_dat return SYSTEM_SETTINGS_ERROR_NONE; } -int system_setting_set_device_name(system_settings_key_e key, system_setting_data_type_e data_type, void *value) +/* LCOV_EXCL_START */ +int system_setting_set_device_name(system_settings_key_e key, void *value) { SETTING_TRACE_BEGIN; char *vconf_value = NULL; @@ -1980,6 +1979,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) { @@ -1994,7 +1994,7 @@ int system_setting_unset_changed_callback_device_name(system_settings_key_e key) } /*---------------------------------------------- */ -int system_setting_get_network_flight_mode(system_settings_key_e key, system_setting_data_type_e data_type, void **value) +int system_setting_get_network_flight_mode(system_settings_key_e key, void **value) { SETTING_TRACE_BEGIN; bool vconf_value; @@ -2018,7 +2018,7 @@ int system_setting_unset_changed_callback_network_flight_mode(system_settings_ke return system_setting_vconf_unset_changed_cb(VCONFKEY_TELEPHONY_FLIGHT_MODE, 3); } -int system_setting_get_network_wifi_notification(system_settings_key_e key, system_setting_data_type_e data_type, void **value) +int system_setting_get_network_wifi_notification(system_settings_key_e key, void **value) { SETTING_TRACE_BEGIN; int vconf_value; @@ -2044,23 +2044,27 @@ int system_setting_unset_changed_callback_network_wifi_notification(system_setti return system_setting_vconf_unset_changed_cb(VCONFKEY_WIFI_ENABLE_QS, 4); } -int system_setting_get_lock_state(system_settings_key_e key, system_setting_data_type_e data_type, void **value) +/* LCOV_EXCL_START */ +int system_setting_get_lock_state(system_settings_key_e key, 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 */ -int system_setting_set_lock_state(system_settings_key_e key, system_setting_data_type_e data_type, void *value) +/* LCOV_EXCL_START */ +int system_setting_set_lock_state(system_settings_key_e key, 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; @@ -2068,15 +2072,348 @@ 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, 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, 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); +} + +int system_settings_feature_check_bool(char *path) +{ + bool profile_data = false; + int ret = system_info_get_platform_bool(path, &profile_data); + if (ret != SYSTEM_INFO_ERROR_NONE) { + SETTING_TRACE("Setting - reading profile string failed, %d", ret); + return SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED; + } + + ret = (profile_data == true) ? SYSTEM_SETTINGS_ERROR_NONE : SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED; + + return ret; + +} + +int system_setting_feature_check_incoming_call(void * value) +{ + static bool first_query = true; + static int ret = SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED; + + if (first_query == true) { + ret = system_settings_feature_check_bool(SETTING_INCOMING_CALL_PATH); + first_query = false; + } + + return ret; +} + +int system_setting_feature_check_home_screen(void * value) +{ + static bool first_query = true; + static int ret = SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED; + + if (first_query == true) { + ret = system_settings_feature_check_bool(SETTING_HOME_SCREEN_PATH); + first_query = false; + } + + return ret; +} + +int system_setting_feature_check_lock_screen(void * value) +{ + static bool first_query = true; + static int ret = SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED; + + if (first_query == true) { + ret = system_settings_feature_check_bool(SETTING_LOCK_SCREEN_PATH); + first_query = false; + } + + return ret; +} + +int system_setting_feature_check_notification_email(void * value) +{ + static bool first_query = true; + static int ret = SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED; + + if (first_query == true) { + ret = system_settings_feature_check_bool(SETTING_NOTIFICATION_EMAIL_PATH); + first_query = false; + } + + return ret; +} + +int system_setting_feature_check_wifi(void * value) +{ + static bool first_query = true; + static int ret = SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED; + + if (first_query == true) { + ret = system_settings_feature_check_bool(SETTING_WIFI_PATH); + first_query = false; + } + + return ret; +} + +int system_setting_feature_check_telephony(void * value) +{ + static bool first_query = true; + static int ret = SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED; + + if (first_query == true) { + ret = system_settings_feature_check_bool(SETTING_TELEPHONY_PATH); + first_query = false; + } + + return ret; +} + +/* LCOV_EXCL_START */ +int system_setting_get_uds_state(system_settings_key_e key, void **value) +{ + int ** p_value = (int**)value; + int vconf_value; + char *vconf_string_value = NULL; + + if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_UDSM, &vconf_value)) { + return SYSTEM_SETTINGS_ERROR_IO_ERROR; + } + + SETTING_TRACE("[%s] udsm: %d", __FUNCTION__, vconf_value); + + if (vconf_value == SYSTEM_SETTINGS_UDS_ON) { + if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_UDSM_PKGID_LIST, &vconf_string_value)) + return SYSTEM_SETTINGS_ERROR_IO_ERROR; + + if (vconf_string_value) { + if (!strcmp(vconf_string_value, "NONE")) { + vconf_value = SYSTEM_SETTINGS_UDS_ON; + } else { + char *app_id = NULL; + char *package_id = NULL; + pid_t pid = getpid(); + app_manager_get_app_id(pid, &app_id); + + if (app_id) { + package_manager_get_package_id_by_app_id(app_id, &package_id); + SETTING_TRACE("[%s] udsm_pkg_list : %s", __FUNCTION__, vconf_string_value); + } + + if (package_id && strstr(vconf_string_value, package_id)) { + vconf_value = SYSTEM_SETTINGS_UDS_ON_WHITELISTED; + SETTING_TRACE("[%s] pkg id : %s", __FUNCTION__, package_id); + } else { + vconf_value = SYSTEM_SETTINGS_UDS_ON; + } + + } + if (vconf_string_value) + free(vconf_string_value); + } + } + + **p_value = vconf_value; + + + return SYSTEM_SETTINGS_ERROR_NONE; +} +/* LCOV_EXCL_STOP */ + +/* LCOV_EXCL_START */ +int system_setting_set_changed_callback_uds_state(system_settings_key_e key, system_settings_changed_cb callback, void *user_data) +{ + return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_UDSM, SYSTEM_SETTINGS_KEY_ULTRA_DATA_SAVE, 4, user_data); +} +/* LCOV_EXCL_STOP */ + +/* LCOV_EXCL_START */ +int system_setting_unset_changed_callback_uds_state(system_settings_key_e key) +{ + return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_UDSM, 4); +} +/* LCOV_EXCL_STOP */ + +/* LCOV_EXCL_START */ +int system_setting_set_changed_callback_uds_pkg_list(system_settings_key_e key, system_settings_changed_cb callback, void *user_data) +{ + return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_UDSM_PKGID_LIST, SYSTEM_SETTINGS_KEY_ULTRA_DATA_SAVE_PKG_LIST, 4, user_data); +} +/* LCOV_EXCL_STOP */ + +/* LCOV_EXCL_START */ +int system_setting_unset_changed_callback_uds_pkg_list(system_settings_key_e key) +{ + return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_UDSM_PKGID_LIST, 4); +} +/* LCOV_EXCL_STOP */ + +/* SYSTEM_SETTINGS_KEY_ACCESSIBILITY_TTS */ +int system_setting_get_accessibility_tts(system_settings_key_e key, void **value) +{ + SETTING_TRACE_BEGIN; + bool vconf_value; + + int ret = system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_ACCESSIBILITY_TTS, &vconf_value); + if (ret != SYSTEM_SETTINGS_ERROR_NONE) { + return ret; + } + *value = (void *)vconf_value; + return ret; +} +int system_setting_set_changed_callback_accessibility_tts(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_ACCESSIBILITY_TTS, SYSTEM_SETTINGS_KEY_ACCESSIBILITY_TTS, 2, user_data); +} + +int system_setting_unset_changed_callback_accessibility_tts(system_settings_key_e key) +{ + SETTING_TRACE_BEGIN; + return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_TTS, 2); +} +/* SYSTEM_SETTINGS_KEY_VIBRATION */ +int system_setting_get_vibration(system_settings_key_e key, void **value) +{ + SETTING_TRACE_BEGIN; + bool vconf_value; + + if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, &vconf_value)) { + return SYSTEM_SETTINGS_ERROR_IO_ERROR; + } + *value = (void *)vconf_value; + + return SYSTEM_SETTINGS_ERROR_NONE; +} + +/* LCOV_EXCL_START */ +int system_setting_set_vibration(system_settings_key_e key, void *value) +{ + SETTING_TRACE_BEGIN; + bool *vconf_value; + vconf_value = (bool *)value; + if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, *vconf_value)) { + return SYSTEM_SETTINGS_ERROR_IO_ERROR; + } + + return SYSTEM_SETTINGS_ERROR_NONE; +} +/* LCOV_EXCL_STOP */ + +int system_setting_set_changed_callback_vibration(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_VIBRATION_STATUS_BOOL, SYSTEM_SETTINGS_KEY_VIBRATION, 2, user_data); +} + +int system_setting_unset_changed_callback_vibration(system_settings_key_e key) +{ + SETTING_TRACE_BEGIN; + return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, 2); +} + +#ifdef UNIT_TEST +static void simple_test_case(void) +{ + /* a suitable test */ + g_assert(g_bit_storage(1) == 1); + + /* a test with verbose error message */ + g_assert_cmpint(g_bit_storage(1), ==, 1); +} + +static void simple_test_case02(void) +{ + /* a suitable test */ + g_assert(g_bit_storage(1) == 1); + + /* a test with verbose error message */ + g_assert_cmpint(g_bit_storage(1), ==, 1); +} +void unittest_platform() +{ + /* hook up your test functions */ + g_test_add_func("/Simple Test Case", simple_test_case); + g_test_add_func("/Simple Test Case02", simple_test_case02); + /* run tests from the suite */ +} +#endif