2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
25 #include <sys/types.h>
36 #include <libxml/xmlmemory.h>
37 #include <libxml/parser.h>
39 #include <fontconfig/fontconfig.h>
41 #include <pkgmgr-info.h>
42 #include <package_manager.h>
43 #include <app_manager.h>
45 #include <system_settings.h>
46 #include <system_settings_private.h>
47 #include <system_settings_ringtones.h>
48 #include <system_settings_json.h>
51 #include <tzplatform_config.h>
56 #define SETTING_FONT_CONF_FILE _TZ_SYS_ETC"/fonts/conf.avail/99-tizen.conf"
57 #define SETTING_DEFAULT_FONT_CONF_FILE _TZ_SYS_ETC"/fonts/conf.avail/99-tizen.conf"
59 #define SETTING_TIME_ZONEINFO_PATH "/usr/share/zoneinfo/"
60 #define SETTING_TIME_SHARE_LOCAL_PATH "/usr/share/locale"
61 #define SETTING_TZONE_SYMLINK_PATH "/opt/etc/localtime"
64 #define __FREE(del, arg) do { \
66 del((void *)(arg)); /*cast any argument to (void*) to avoid build warring*/\
70 #define FREE(arg) __FREE(free, arg)
72 #ifdef SETTING_ARCH_64
73 #define SETTING_UTILS_SO_FILE_PATH "/usr/lib64/libsystem-settings-util.so.0.1.0"
75 #define SETTING_UTILS_SO_FILE_PATH "/usr/lib/libsystem-settings-util.so.0.1.0"
78 int _is_file_accessible(const char *path);
80 static bool dl_is_supported_image_type_load(char *path);
81 static bool dl_font_config_set(char *font_name);
82 static char *dl_get_font_info(char *str);
83 static int dl_is_available_font(char *str);
84 static void dl_font_size_set();
85 static void dl_font_config_set_notification();
88 #ifndef VCONFKEY_SETAPPL_UDSM
89 #define VCONFKEY_SETAPPL_UDSM "db/setting/udsm"
92 #ifndef VCONFKEY_SETAPPL_UDSM_PKGID_LIST
93 #define VCONFKEY_SETAPPL_UDSM_PKGID_LIST "db/setting/udsm/pkgid_list"
98 * VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR has a path of the ringtone file which user choose
99 * @return the ringtone file path specified by user in normal case
100 * if it's not accessable, return the default ringtone path
102 int system_setting_get_incoming_call_ringtone(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
106 if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR, &vconf_value)) {
107 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
110 /* check to see if it's accessable -> OK */
111 /* no --> default ringtone path VCONFKEY_SETAPPL_CALL_RINGTONE_DEFAULT_PATH_STR */
112 int is_load = _is_file_accessible(vconf_value);
114 *value = vconf_value;
115 } else { /* not zero on errro */
116 *value = vconf_get_str(VCONFKEY_SETAPPL_CALL_RINGTONE_DEFAULT_PATH_STR);
119 /**value = vconf_value; */
120 return SYSTEM_SETTINGS_ERROR_NONE;
124 int system_setting_get_email_alert_ringtone(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
128 if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, &vconf_value)) {
129 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
132 /* check to see if it's accessable -> OK */
133 /* no --> default ringtone path VCONFKEY_SETAPPL_NOTI_RINGTONE_DEFAULT_PATH_STR */
134 int is_load = _is_file_accessible(vconf_value);
136 *value = vconf_value;
137 } else { /* not zero on errro */
138 *value = vconf_get_str(VCONFKEY_SETAPPL_NOTI_RINGTONE_DEFAULT_PATH_STR);
141 return SYSTEM_SETTINGS_ERROR_NONE;
145 int system_setting_get_wallpaper_home_screen(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
149 if (system_setting_vconf_get_value_string(VCONFKEY_BGSET, &vconf_value)) {
150 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
152 *value = vconf_value;
153 return SYSTEM_SETTINGS_ERROR_NONE;
157 int system_setting_get_wallpaper_lock_screen(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
162 if (system_setting_vconf_get_value_string(VCONFKEY_IDLE_LOCK_BGSET, &vconf_value)) {
163 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
165 *value = vconf_value;
167 return SYSTEM_SETTINGS_ERROR_NONE;
171 /* [int] vconf GET */
172 int system_setting_get_font_size(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
176 int ** val = (int**)value;
178 if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, &vconf_value)) {
179 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
183 return SYSTEM_SETTINGS_ERROR_NONE;
187 int system_setting_get_default_font_type(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
190 char *font_name = dl_get_font_info("default");
192 *value = (void *)font_name;
193 return SYSTEM_SETTINGS_ERROR_NONE;
195 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
199 /* [int] vconf GET */
200 int system_setting_get_font_type(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
203 char *font_name = dl_get_font_info("cur");
204 *value = (void *)font_name;
206 return SYSTEM_SETTINGS_ERROR_NONE;
210 int system_setting_get_motion_activation(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
215 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_MOTION_ACTIVATION, &vconf_value)) {
216 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
218 *value = (void *)vconf_value;
220 return SYSTEM_SETTINGS_ERROR_NONE;
223 int system_setting_get_usb_debugging_option(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
228 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_USB_DEBUG_MODE_BOOL, &vconf_value)) {
229 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
231 *value = (void *)vconf_value;
233 return SYSTEM_SETTINGS_ERROR_NONE;
236 int system_setting_get_3g_data_network(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
241 if (system_setting_vconf_get_value_bool(VCONFKEY_3G_ENABLE, &vconf_value)) {
242 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
244 *value = (void *)vconf_value;
246 return SYSTEM_SETTINGS_ERROR_NONE;
248 /*////////////////////////////////////////////////////////////////////////////////////////////////// */
252 * get current lock scren app package name (string)
254 * @return SYSTEM_SETTINGS_ERROR_LOCKSCREEN_APP_PASSWORD_MODE raise exception if current lock type is 'password'
256 int system_setting_get_lockscreen_app(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
259 char *pkg_name = NULL;
261 system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_SCREEN_LOCK_TYPE_INT, &locktype);
263 if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_3RD_LOCK_PKG_NAME_STR, &pkg_name)) {
264 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
267 if (pkg_name && strcmp(pkg_name, "com.samsung.lockscreen") == 0 && locktype == SETTING_SCREEN_LOCK_TYPE_PASSWORD) {
268 return SYSTEM_SETTINGS_ERROR_LOCKSCREEN_APP_PASSWORD_MODE;
272 return SYSTEM_SETTINGS_ERROR_NONE;
276 /*////////////////////////////////////////////////////////////////////////////////////////////////// */
278 int _is_file_accessible(const char *path)
281 int ret = access(path , R_OK);
283 SETTING_TRACE("found the file %s", path);
286 /* error code : 13 */
287 SETTING_TRACE("found the file %s --- error code : %d ", path, errno);
294 /*////////////////////////////////////////////////////////////////////////////////////////////////// */
295 // @todo move to CMake
296 #define DEF_RINGTONE_FILE_PATH "/opt/share/settings/Ringtones"
297 #define USR_RINGTONE_FILE_PATH "/home/owner/content/Sounds/Ringtones"
298 #define JSONFILE "/opt/home/owner/apps_rw/org.tizen.setting/data/.user-ringtones.json"
301 static char* _get_json_file_path()
308 int system_setting_add_incoming_call_ringtone(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
311 char* pathval = (char*)value;
315 JsonParser *parser = ss_json_ringtone_open_file(JSONFILE);
317 JsonParser *parser = ss_json_ringtone_load_from_data();
320 JsonNode *root = json_parser_get_root(parser);
324 int ret = SYSTEM_SETTINGS_ERROR_NONE;
325 if (false == ss_json_ringtone_contain(root, pathval)) {
326 SETTING_TRACE("---> dirname is : %s ", dirname(strdup(pathval)));
327 SETTING_TRACE("---> basename is : %s ", basename(strdup(pathval)));
328 // @todo : MAKE SURE THE ACTUAL FILE IS THERE ON PATHVAL(SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER)
329 ss_json_ringtone_add(root, JSONFILE, pathval, pathval);
330 SETTING_TRACE("pathval is : %s -- OK", pathval);
332 SETTING_TRACE("pathval is duplicated : %s", pathval);
333 SETTING_TRACE("---> dirname is : %s ", dirname(strdup(pathval)));
334 SETTING_TRACE("---> basename is : %s ", basename(strdup(pathval)));
335 ret = SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
339 g_object_unref(parser);
346 int system_setting_del_incoming_call_ringtone(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
349 char* pathval = (char*)value;
352 JsonParser* parser = ss_json_ringtone_open_file(JSONFILE);
354 JsonParser* parser = ss_json_ringtone_load_from_data();
356 JsonNode *root = json_parser_get_root(parser);
358 ss_json_ringtone_remove(root, JSONFILE, pathval);
359 //void ss_json_ringtone_remove(JsonNode *root, char* filename, char* path_to_del)
361 ss_json_ringtone_print(root);
363 g_object_unref(parser);
367 return SYSTEM_SETTINGS_ERROR_NONE;
371 static int _compare_cb(const void *d1, const void *d2)
373 fileNodeInfo *pNode1 = (fileNodeInfo *)d1;
374 fileNodeInfo *pNode2 = (fileNodeInfo *)d2;
376 return strcmp(pNode1->media_name, pNode2->media_name);
380 * get the RINGTONE list
382 static void _get_default_ringtones(system_settings_key_e key, system_setting_data_type_e data_type, system_settings_iter_cb callback, void *data)
386 Eina_List *filelist = NULL;
388 fileNodeInfo *node = NULL;
391 //-----------------------------------------------------------------------------------------------------------------
392 // 1. get the default ringtone list
393 //-----------------------------------------------------------------------------------------------------------------
394 int ret = get_filelist_from_dir_path(DEF_RINGTONE_FILE_PATH, &filelist);
396 SETTING_TRACE("Failed to get filelist, ret = %d %s", ret, DEF_RINGTONE_FILE_PATH);
398 filelist = eina_list_sort(filelist, eina_list_count(filelist), _compare_cb);
400 EINA_LIST_FOREACH(filelist, l, node)
402 SETTING_TRACE("file path = (%d) : name:%s path:%s [%s]", ret, node->name, node->path, node->media_name);
403 // @todo assert NULL check
406 snprintf(temp, 1024, "%s/%s", node->path, node->name);
407 char* path = strdup(temp);
408 bool ret = callback(idx, (void *)(path), data);
414 SETTING_TRACE("quit the iteration by return value == false : %d", ret);
419 SETTING_TRACE("--> system_setting_data_iterator is NULL");
425 EINA_LIST_FOREACH(filelist, l, node)
429 FREE(node->media_name);
432 eina_list_free(filelist);
437 static void _get_user_ringtones(system_settings_key_e key, system_setting_data_type_e data_type, system_settings_iter_cb callback, void *data)
443 JsonParser* parser = ss_json_ringtone_open_file(JSONFILE);
445 JsonParser* parser = ss_json_ringtone_load_from_data();
448 JsonNode *root = json_parser_get_root(parser);
449 int size = json_array_get_length(json_node_get_array(root));
452 for (i = 0; i < size ; i++) {
453 JsonObject *ringtone = json_array_get_object_element(json_node_get_array(root), i);
454 char *nameval = (char *)json_object_get_string_member(ringtone, "name");
455 char *pathval = (char *)json_object_get_string_member(ringtone, "path");
456 SETTING_TRACE("(%s) --- (%s) \n", nameval, pathval);
458 char* path = strdup(pathval);
459 bool ret = callback(i, (void *)(path), data);
461 SETTING_TRACE("quit the iteration by return value == false : %d", ret);
465 SETTING_TRACE("--> callback is NULL");
470 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)
474 _get_default_ringtones(key, data_type, callback, data);
475 //-----------------------------------------------------------------------------------------------------------------
476 // 2. get the USER ringtone list
477 //-----------------------------------------------------------------------------------------------------------------
478 _get_user_ringtones(key, data_type, callback, data);
480 return SYSTEM_SETTINGS_ERROR_NONE;
484 /* LCOV_EXCL_START */
485 int system_setting_set_incoming_call_ringtone(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
489 vconf_value = (char *)value;
491 int ret = _is_file_accessible(vconf_value);
493 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR, vconf_value)) {
494 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
497 /* @todo add a common ret_handler */
501 return SYSTEM_SETTINGS_ERROR_NONE;
506 /* LCOV_EXCL_START */
507 int system_setting_set_email_alert_ringtone(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
511 vconf_value = (char *)value;
513 int ret = _is_file_accessible(vconf_value);
515 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, vconf_value)) {
516 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
519 /*return SYSTEM_SETTINGS_ERROR_IO_ERROR;*/
520 /* @todo add a common ret_handler */
524 return SYSTEM_SETTINGS_ERROR_NONE;
528 /* LCOV_EXCL_START */
529 static bool dl_is_supported_image_type_load(char *path)
534 bool (*image_type_check)(char *path);
536 handle = dlopen(SETTING_UTILS_SO_FILE_PATH, RTLD_LAZY);
538 SETTING_TRACE("ERROR!! canNOT find libsystem-settings-util.so.0.1.0");
542 image_type_check = dlsym(handle, "__is_supported_image_type_load");
543 if ((error = dlerror()) != NULL) {
544 SETTING_TRACE("ERROR!! canNOT find __is_supported_image_type_load function at libsystem-settings-util.so.0.1.0");
549 ret = image_type_check(path);
556 /* LCOV_EXCL_START */
557 static int dl_is_available_font(char *str)
562 int (*check_available_font)(char *font_name);
564 handle = dlopen(SETTING_UTILS_SO_FILE_PATH, RTLD_LAZY);
566 SETTING_TRACE("ERROR!! canNOT find libsystem-settings-util.so.0.1.0");
570 check_available_font = dlsym(handle, "__is_available_font");
571 if ((error = dlerror()) != NULL) {
572 SETTING_TRACE("ERROR!! canNOT find __is_available_font function at libsystem-settings-util.so.0.1.0");
577 ret = check_available_font(str);
584 /* LCOV_EXCL_START */
585 static void dl_font_size_set()
589 void (*set_font_size)();
591 handle = dlopen(SETTING_UTILS_SO_FILE_PATH, RTLD_LAZY);
593 SETTING_TRACE("ERROR!! canNOT find libsystem-settings-util.so.0.1.0");
597 set_font_size = dlsym(handle, "__font_size_set");
598 if ((error = dlerror()) != NULL) {
599 SETTING_TRACE("ERROR!! canNOT find __font_size_set function at libsystem-settings-util.so.0.1.0");
611 /* LCOV_EXCL_START */
612 static void dl_font_config_set_notification()
616 void (*set_font_nodification)();
618 handle = dlopen(SETTING_UTILS_SO_FILE_PATH, RTLD_LAZY);
620 SETTING_TRACE("ERROR!! canNOT find libsystem-settings-util.so.0.1.0");
624 set_font_nodification = dlsym(handle, "font_config_set_notification");
625 if ((error = dlerror()) != NULL) {
626 SETTING_TRACE("ERROR!! canNOT find font_config_set_notification function at libsystem-settings-util.so.0.1.0");
631 set_font_nodification();
638 /* LCOV_EXCL_START */
639 static bool dl_font_config_set(char *font_name)
644 bool (*check_font_type)(char *font_name);
646 handle = dlopen(SETTING_UTILS_SO_FILE_PATH, RTLD_LAZY);
648 SETTING_TRACE("ERROR!! canNOT find libsystem-settings-util.so.0.1.0");
652 check_font_type = dlsym(handle, "font_config_set");
653 if ((error = dlerror()) != NULL) {
654 SETTING_TRACE("ERROR!! canNOT find font_config_set function at libsystem-settings-util.so.0.1.0");
659 ret = check_font_type(font_name);
666 /* LCOV_EXCL_START */
667 static char *dl_get_font_info(char *str)
672 char *(*get_font_info)();
674 handle = dlopen(SETTING_UTILS_SO_FILE_PATH, RTLD_LAZY);
676 SETTING_TRACE("ERROR!! canNOT find libsystem-settings-util.so.0.1.0");
680 if (strcmp(str, "cur") == 0)
681 get_font_info = dlsym(handle, "_get_cur_font");
683 get_font_info = dlsym(handle, "_get_default_font");
685 if ((error = dlerror()) != NULL) {
686 SETTING_TRACE("ERROR!! canNOT find %s function at libsystem-settings-util.so.0.1.0", str);
691 ret = get_font_info();
698 /* LCOV_EXCL_START */
699 #define PATH_EXT_CHECK_REG ".(jpe?g|jpg|png|gif)$"
700 bool __is_supported_image_type_by_ext(char *file_path)
704 regmatch_t str[2048 + 1];
706 if (!file_path) return false;
709 if ((ret = regcomp(&fsm, PATH_EXT_CHECK_REG, REG_ICASE | REG_EXTENDED))) {
710 SETTING_TRACE("regular expresstion fail");
715 if (regexec(&fsm, file_path, strlen(file_path) + 1, str, 0) == REG_NOMATCH) {
716 /*SETTING_TRACE("FAILED - %s", file_path[i]); */
719 /*SETTING_TRACE("MATCHED - %s", file_path[i]); */
725 #ifdef TIZEN_WEARABLE
726 /* LCOV_EXCL_START */
727 static int system_setting_get_extended_wallpaper_num(const char *file_path, unsigned int *num)
731 const char *find_str = "extended_wallpaper_";
734 if (!(ch = strstr(file_path, find_str))) {
735 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
737 strncpy(buffer, file_path, ch - file_path);
738 buffer[ch - file_path] = 0;
739 sprintf(buffer + (ch - file_path), "%s%s", "", ch + strlen(find_str));
741 if (!isdigit(buffer[0])) {
742 SETTING_TRACE("%s is not number", buffer);
743 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
748 return SYSTEM_SETTINGS_ERROR_NONE;
752 /* LCOV_EXCL_START */
753 static int system_setting_copy_extended_wallpaper(const char *dest_file_path, const char *source_file_path)
756 if (!source_file_path || !dest_file_path) {
757 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
763 fd = open(source_file_path, O_RDONLY);
765 SETTING_TRACE("file open failed: %s", source_file_path);
766 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
770 fd2 = open(dest_file_path, O_WRONLY | O_CREAT, S_IRWXU | S_IRWXG | S_IRWXO);
772 SETTING_TRACE("file creation failed: %s", dest_file_path);
774 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
777 while (read(fd, buf, sizeof(buf) - 1) > 0) {
778 write(fd2, buf, sizeof(buf) - 1);
784 if (chmod(dest_file_path, S_IRWXU | S_IRWXG | S_IRWXO) < 0) {
785 SETTING_TRACE("chmod failed: %s", dest_file_path);
788 return SYSTEM_SETTINGS_ERROR_NONE;
792 /* LCOV_EXCL_START */
793 static int system_setting_remove_oldest_extended_wallpaper()
798 char *min_image_name = NULL;
799 unsigned int min_image_num = 0;
800 unsigned int temp_image_num = 0;
803 if ((dp = opendir(_TZ_SYS_DATA"/setting/wallpaper")) == NULL) {
804 SETTING_TRACE("opendir error");
805 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
808 while ((dirp = readdir(dp))) {
809 if (!strcmp(dirp->d_name, ".") || !strcmp(dirp->d_name, ".."))
812 if (system_setting_get_extended_wallpaper_num(dirp->d_name, &temp_image_num)
813 != SYSTEM_SETTINGS_ERROR_NONE) {
814 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
817 if ((image_count == 0) || (min_image_num > temp_image_num)) {
818 min_image_num = temp_image_num;
819 min_image_name = dirp->d_name;
826 if (min_image_name) {
827 snprintf(buf, sizeof(buf) - 1, _TZ_SYS_DATA"/setting/wallpaper/%s", min_image_name);
828 if (remove(buf) < 0) { /* remove oldest image */
829 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
833 return SYSTEM_SETTINGS_ERROR_NONE;
837 /* LCOV_EXCL_START */
838 static int system_setting_check_extended_wallpaper(const char *file_path)
842 if (!file_path || !strlen(file_path))
844 snprintf(buffer, 512, "%s/.bgwallpaper", tzplatform_getenv(TZ_USER_CONTENT));
845 return (strstr(file_path, buffer) != NULL);
849 #define WALLPAPER_MAX_COUNT 10
851 /* LCOV_EXCL_START */
852 int system_setting_set_wallpaper_home_screen(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
856 vconf_value = (char *)value;
858 bool isok = dl_is_supported_image_type_load(vconf_value);
861 SETTING_TRACE("path : %s is not supported file format", vconf_value);
862 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
864 SETTING_TRACE("path : %s is SUPPORT file format", vconf_value);
867 /* error handling here */
868 if (_is_file_accessible(vconf_value) != 0)
869 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
871 if (system_setting_vconf_set_value_string(VCONFKEY_BGSET, vconf_value)) {
872 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
876 #ifdef TIZEN_WEARABLE
877 if (system_setting_check_extended_wallpaper(vconf_value)) { /* New extended wallpaper */
880 unsigned int max_image_num = 0;
881 unsigned int temp_image_num = 0;
884 if ((dp = opendir(_TZ_SYS_DATA"/setting/wallpaper")) == NULL) {
885 SETTING_TRACE("Setting - dir open error!");
886 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
889 /* Check a max number of wallpapers */
890 while ((dirp = readdir(dp))) {
891 if (!strcmp(dirp->d_name, ".") || !strcmp(dirp->d_name, ".."))
894 if (system_setting_get_extended_wallpaper_num(dirp->d_name, &temp_image_num)
895 != SYSTEM_SETTINGS_ERROR_NONE) {
898 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
901 if ((image_count == 0) || (max_image_num < temp_image_num)) {
902 max_image_num = temp_image_num;
910 /* Numbering rule: Gear is odd number */
911 max_image_num = (max_image_num % 2 == 0) ? max_image_num + 1
914 char file_name_buffer[512];
915 snprintf(file_name_buffer, sizeof(file_name_buffer) - 1,
916 _TZ_SYS_DATA"/setting/wallpaper/extended_wallpaper_%d.jpg", max_image_num);
918 /* Copy image to _TZ_SYS_DATA/setting/wallpaper/ */
919 if (system_setting_copy_extended_wallpaper(file_name_buffer, vconf_value)
920 != SYSTEM_SETTINGS_ERROR_NONE) {
921 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
924 /* remove oldest wallpaper */
925 if (image_count >= WALLPAPER_MAX_COUNT) {
926 if (system_setting_remove_oldest_extended_wallpaper()
927 != SYSTEM_SETTINGS_ERROR_NONE) {
928 remove(file_name_buffer);
929 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
933 if (system_setting_vconf_set_value_string(VCONFKEY_BGSET, file_name_buffer)) {
934 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
937 if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_WALLPAPER_CHANGED_NOTI_INT,
938 VCONFKEY_WALLPAPER_CHANGED_NOTI_GEAR)) {
939 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
942 if (system_setting_vconf_set_value_string(VCONFKEY_BGSET, vconf_value)) {
943 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
948 return SYSTEM_SETTINGS_ERROR_NONE;
952 /* LCOV_EXCL_START */
953 int system_setting_set_wallpaper_lock_screen(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
957 vconf_value = (char *)value;
959 bool isok = dl_is_supported_image_type_load(vconf_value);
962 SETTING_TRACE("path : %s is not supported file format", vconf_value);
963 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
965 SETTING_TRACE("path : %s is SUPPORT file format", vconf_value);
968 /* error handling here */
969 if (_is_file_accessible(vconf_value) != 0)
970 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
972 if (system_setting_vconf_set_value_string(VCONFKEY_IDLE_LOCK_BGSET, vconf_value)) {
973 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
976 return SYSTEM_SETTINGS_ERROR_NONE;
980 /* LCOV_EXCL_START */
981 int system_setting_set_font_size(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
985 vconf_value = *(int **)value;
987 if (*vconf_value < 0 || *vconf_value > SYSTEM_SETTINGS_FONT_SIZE_GIANT) {
988 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
991 if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, *vconf_value)) {
992 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
996 return SYSTEM_SETTINGS_ERROR_NONE;
1002 /* LCOV_EXCL_START */
1003 void *font_conf_doc_parse(char *doc_name, char *font_name)
1005 SETTING_TRACE_BEGIN;
1006 xmlDocPtr doc = NULL;
1007 xmlNodePtr cur = NULL;
1008 xmlNodePtr cur2 = NULL;
1009 xmlNodePtr cur3 = NULL;
1010 xmlChar *key = NULL;
1012 doc = xmlParseFile(doc_name);
1014 cur = xmlDocGetRootElement(doc);
1022 if (xmlStrcmp(cur->name, (const xmlChar *)"fontconfig")) {
1028 cur = cur->xmlChildrenNode;
1030 bool is_changed = false;
1031 while (cur != NULL) {
1032 if ((!xmlStrcmp(cur->name, (const xmlChar *)"match"))) {
1033 cur2 = cur->xmlChildrenNode;
1034 while (cur2 != NULL) {
1035 if ((!xmlStrcmp(cur2->name, (const xmlChar *)"edit"))) {
1036 xmlChar *name = xmlGetProp(cur2, (const xmlChar *)"name");
1037 /* if name is not 'family', break */
1038 if (xmlStrcmp(name, (const xmlChar *)"family")) {
1046 cur3 = cur2->xmlChildrenNode;
1047 while (cur3 != NULL) {
1048 if ((!xmlStrcmp(cur3->name, (const xmlChar *)"string"))) {
1049 xmlNodeSetContent(cur3->xmlChildrenNode, (const xmlChar *)font_name);
1050 key = xmlNodeListGetString(doc, cur3->xmlChildrenNode, 1);
1060 } else if ((!xmlStrcmp(cur->name, (const xmlChar *)"alias"))) {
1061 cur2 = cur->xmlChildrenNode;
1062 while (cur2 != NULL) {
1063 if ((!xmlStrcmp(cur2->name, (const xmlChar *)"family"))) {
1064 xmlNodeSetContent(cur2->xmlChildrenNode, (const xmlChar *)font_name);
1065 key = xmlNodeListGetString(doc, cur2->xmlChildrenNode, 1);
1069 } else if ((!xmlStrcmp(cur2->name, (const xmlChar *)"prefer"))) {
1070 cur3 = cur2->xmlChildrenNode;
1071 while (cur3 != NULL) {
1072 if ((!xmlStrcmp(cur3->name, (const xmlChar *)"family"))) {
1073 xmlNodeSetContent(cur3->xmlChildrenNode, (const xmlChar *)font_name);
1074 key = xmlNodeListGetString(doc, cur3->xmlChildrenNode, 1);
1098 /* LCOV_EXCL_STOP */
1100 /* LCOV_EXCL_START */
1101 int system_setting_set_font_type(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1103 SETTING_TRACE_BEGIN;
1104 char *font_name = NULL;
1105 font_name = (char *)value;
1107 /* get current font list */
1108 int is_found = dl_is_available_font(font_name);
1111 SETTING_TRACE("found font : %s ", font_name);
1113 SETTING_TRACE(" NOT found font : %s ", font_name);
1114 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1117 bool bsave = dl_font_config_set(font_name);
1120 SETTING_TRACE(" font type save error by font_config_set() ");
1121 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1123 SETTING_TRACE(" save OK - font_config_set() ");
1126 xmlDocPtr doc = (xmlDocPtr)font_conf_doc_parse(SETTING_FONT_CONF_FILE, font_name);
1128 xmlSaveFormatFile(SETTING_FONT_CONF_FILE, doc, 0);
1133 dl_font_config_set_notification();
1136 vconf_value = (char *)value;
1138 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, vconf_value)) {
1139 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1141 return SYSTEM_SETTINGS_ERROR_NONE;
1143 /* LCOV_EXCL_STOP */
1145 /* LCOV_EXCL_START */
1146 int system_setting_set_motion_activation(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1148 SETTING_TRACE_BEGIN;
1150 vconf_value = (bool *)value;
1151 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_MOTION_ACTIVATION, *vconf_value)) {
1152 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1154 return SYSTEM_SETTINGS_ERROR_NONE;
1156 /* LCOV_EXCL_STOP */
1158 /* LCOV_EXCL_START */
1159 int system_setting_set_usb_debugging_option(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1161 SETTING_TRACE_BEGIN;
1163 vconf_value = (bool *)value;
1164 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_USB_DEBUG_MODE_BOOL, *vconf_value)) {
1165 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1167 return SYSTEM_SETTINGS_ERROR_NONE;
1170 /* LCOV_EXCL_STOP */
1172 /* LCOV_EXCL_START */
1173 int system_setting_set_3g_data_network(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1175 SETTING_TRACE_BEGIN;
1177 vconf_value = (bool *)value;
1178 if (system_setting_vconf_set_value_bool(VCONFKEY_3G_ENABLE, *vconf_value)) {
1179 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1182 return SYSTEM_SETTINGS_ERROR_NONE;
1184 /* LCOV_EXCL_STOP */
1186 /* LCOV_EXCL_START */
1187 static int category_func(const char *name, void *user_data)
1189 SETTING_TRACE_BEGIN;
1190 static char *category = "lock-screen";
1191 if (name && !strcmp(name, category)) {
1192 SETTING_TRACE(" SAME ");
1195 SETTING_TRACE(" DIFFERENT -- %s, category -- %s ", name, category);
1201 /* LCOV_EXCL_STOP */
1205 * set 'swipe type' if current lockscreen app is 'com.samsung.lockscreen'
1209 /* LCOV_EXCL_START */
1210 int system_setting_set_lockscreen_app(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1212 SETTING_TRACE_BEGIN;
1214 vconf_value = (char *)value; /* ex) com.samsung.lockscreen */
1217 pkgmgrinfo_appinfo_h handle;
1218 r = pkgmgrinfo_appinfo_get_appinfo(vconf_value, &handle);
1219 if (r != PMINFO_R_OK) {
1220 SETTING_TRACE("*** pkginfo failed ");
1221 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
1223 SETTING_TRACE("%x", handle);
1226 int ret = pkgmgrinfo_appinfo_foreach_category(handle, category_func, (void *)"lock-screen");
1227 if (ret != PMINFO_R_OK) {
1228 pkgmgrinfo_appinfo_destroy_appinfo(handle);
1229 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
1232 pkgmgrinfo_appinfo_destroy_appinfo(handle);
1233 /*----------------------------------------------------------------------------------- */
1235 if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_SCREEN_LOCK_TYPE_INT, &locktype)) {
1236 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1239 if (locktype == SETTING_SCREEN_LOCK_TYPE_PASSWORD)
1240 return SYSTEM_SETTINGS_ERROR_LOCKSCREEN_APP_PASSWORD_MODE;
1242 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_3RD_LOCK_PKG_NAME_STR, vconf_value)) {
1243 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1246 if (vconf_value && strcmp(vconf_value, "com.samsung.lockscreen") == 0) {
1247 if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_SCREEN_LOCK_TYPE_INT, SETTING_SCREEN_LOCK_TYPE_SWIPE)) {
1248 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1251 return SYSTEM_SETTINGS_ERROR_NONE;
1253 /* LCOV_EXCL_STOP */
1255 /*/////////////////////////////////////////////////////////////////////////////////////////////// */
1258 int system_setting_set_changed_callback_incoming_call_ringtone(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1260 SETTING_TRACE_BEGIN;
1261 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR, SYSTEM_SETTINGS_KEY_INCOMING_CALL_RINGTONE, 0, user_data);
1264 int system_setting_unset_changed_callback_incoming_call_ringtone(system_settings_key_e key)
1266 SETTING_TRACE_BEGIN;
1267 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR, 0);
1270 int system_setting_set_changed_callback_email_alert_ringtone(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1272 SETTING_TRACE_BEGIN;
1273 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, SYSTEM_SETTINGS_KEY_EMAIL_ALERT_RINGTONE, 0, user_data);
1276 int system_setting_unset_changed_callback_email_alert_ringtone(system_settings_key_e key)
1278 SETTING_TRACE_BEGIN;
1279 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, 0);
1282 int system_setting_set_changed_callback_wallpaper_home_screen(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1284 SETTING_TRACE_BEGIN;
1285 return system_setting_vconf_set_changed_cb(VCONFKEY_BGSET, SYSTEM_SETTINGS_KEY_WALLPAPER_HOME_SCREEN, 0, user_data);
1288 int system_setting_unset_changed_callback_wallpaper_home_screen(system_settings_key_e key)
1290 SETTING_TRACE_BEGIN;
1291 return system_setting_vconf_unset_changed_cb(VCONFKEY_BGSET, 0);
1294 int system_setting_set_changed_callback_wallpaper_lock_screen(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1296 SETTING_TRACE_BEGIN;
1297 return system_setting_vconf_set_changed_cb(VCONFKEY_IDLE_LOCK_BGSET, SYSTEM_SETTINGS_KEY_WALLPAPER_LOCK_SCREEN, 0, user_data);
1300 int system_setting_unset_changed_callback_wallpaper_lock_screen(system_settings_key_e key)
1302 SETTING_TRACE_BEGIN;
1303 return system_setting_vconf_unset_changed_cb(VCONFKEY_IDLE_LOCK_BGSET, 0);
1306 int system_setting_set_changed_callback_font_size(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1308 SETTING_TRACE_BEGIN;
1309 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, SYSTEM_SETTINGS_KEY_FONT_SIZE, 1, user_data);
1312 int system_setting_unset_changed_callback_font_size(system_settings_key_e key)
1314 SETTING_TRACE_BEGIN;
1315 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, 1);
1318 int system_setting_set_changed_callback_usb_debugging_option(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1320 SETTING_TRACE_BEGIN;
1321 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_USB_DEBUG_MODE_BOOL, SYSTEM_SETTINGS_KEY_USB_DEBUGGING_ENABLED, 1, user_data);
1324 int system_setting_unset_changed_callback_usb_debugging_option(system_settings_key_e key)
1326 SETTING_TRACE_BEGIN;
1327 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_USB_DEBUG_MODE_BOOL, 1);
1330 int system_setting_set_changed_callback_3g_data_network(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1332 SETTING_TRACE_BEGIN;
1333 return system_setting_vconf_set_changed_cb(VCONFKEY_3G_ENABLE, SYSTEM_SETTINGS_KEY_3G_DATA_NETWORK_ENABLED, 1, user_data);
1336 int system_setting_unset_changed_callback_3g_data_network(system_settings_key_e key)
1338 SETTING_TRACE_BEGIN;
1339 return system_setting_vconf_unset_changed_cb(VCONFKEY_3G_ENABLE, 1);
1342 int system_setting_set_changed_callback_lockscreen_app(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1344 SETTING_TRACE_BEGIN;
1345 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_3RD_LOCK_PKG_NAME_STR, SYSTEM_SETTINGS_KEY_LOCKSCREEN_APP, 1, user_data);
1348 int system_setting_unset_changed_callback_lockscreen_app(system_settings_key_e key)
1350 SETTING_TRACE_BEGIN;
1351 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_3RD_LOCK_PKG_NAME_STR, 1);
1356 * @todo need to add custom event notification method
1358 int system_setting_set_changed_callback_font_type(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1360 SETTING_TRACE_BEGIN;
1361 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, SYSTEM_SETTINGS_KEY_FONT_TYPE, 2, user_data);
1364 int system_setting_unset_changed_callback_font_type(system_settings_key_e key)
1366 SETTING_TRACE_BEGIN;
1367 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, 2);
1370 /* TODO : 2th argument, callback, is not in use. */
1371 int system_setting_set_changed_callback_motion_activation(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1373 SETTING_TRACE_BEGIN;
1374 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_MOTION_ACTIVATION, SYSTEM_SETTINGS_KEY_MOTION_ACTIVATION, 3, user_data);
1377 int system_setting_unset_changed_callback_motion_activation(system_settings_key_e key)
1379 SETTING_TRACE_BEGIN;
1380 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_MOTION_ACTIVATION, 3);
1383 /*//////////////////////////////////////////////////////////////////////////////////////// */
1384 /*--------------------------------------- */
1385 int system_setting_get_locale_country(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1387 SETTING_TRACE_BEGIN;
1388 char *vconf_value = NULL;
1389 if (system_setting_vconf_get_value_string(VCONFKEY_REGIONFORMAT, &vconf_value)) {
1390 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1393 /* parsing validation */
1396 snprintf(arr, 20, "%s", vconf_value);
1398 *value = strdup(arr);
1402 return SYSTEM_SETTINGS_ERROR_NONE;
1405 /* LCOV_EXCL_START */
1406 int system_setting_set_locale_country(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1408 SETTING_TRACE_BEGIN;
1409 char *vconf_value = NULL;
1410 vconf_value = (char *)value;
1412 char *ext = "UTF-8";
1415 snprintf(arr, 20, "%s.%s", vconf_value, ext);
1417 if (system_setting_vconf_set_value_string(VCONFKEY_REGIONFORMAT, arr)) {
1418 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1420 return SYSTEM_SETTINGS_ERROR_NONE;
1422 /* LCOV_EXCL_STOP */
1424 int system_setting_set_changed_callback_locale_country(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1426 SETTING_TRACE_BEGIN;
1427 return system_setting_vconf_set_changed_cb(VCONFKEY_REGIONFORMAT, SYSTEM_SETTINGS_KEY_LOCALE_COUNTRY, 3, user_data);
1430 int system_setting_unset_changed_callback_locale_country(system_settings_key_e key)
1432 SETTING_TRACE_BEGIN;
1433 return system_setting_vconf_unset_changed_cb(VCONFKEY_REGIONFORMAT, 3);
1437 /*--------------------------------------- */
1438 int system_setting_get_locale_language(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1440 SETTING_TRACE_BEGIN;
1441 char *vconf_value = NULL;
1442 if (system_setting_vconf_get_value_string(VCONFKEY_LANGSET, &vconf_value)) {
1443 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1446 /* parsing validation */
1449 snprintf(arr, 20, "%s", vconf_value);
1451 *value = strdup(arr);
1454 return SYSTEM_SETTINGS_ERROR_NONE;
1457 /* LCOV_EXCL_START */
1458 int system_setting_set_locale_language(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1460 SETTING_TRACE_BEGIN;
1461 char *vconf_value = NULL;
1462 vconf_value = (char *)value;
1464 char *ext = "UTF-8";
1467 snprintf(arr, 20, "%s.%s", vconf_value, ext);
1469 if (system_setting_vconf_set_value_string(VCONFKEY_LANGSET, arr)) {
1470 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1472 return SYSTEM_SETTINGS_ERROR_NONE;
1474 /* LCOV_EXCL_STOP */
1476 int system_setting_set_changed_callback_locale_language(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1478 SETTING_TRACE_BEGIN;
1479 /*return system_setting_vconf_set_changed_cb(VCONFKEY_LANGSET, SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, 3, user_data ); */
1480 return system_setting_vconf_set_changed_cb(VCONFKEY_LANGSET, SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, 100, user_data);
1483 int system_setting_unset_changed_callback_locale_language(system_settings_key_e key)
1485 SETTING_TRACE_BEGIN;
1486 return system_setting_vconf_unset_changed_cb(VCONFKEY_LANGSET, 100);
1489 /*--------------------------------------- */
1490 /* LCOV_EXCL_START */
1491 int system_setting_get_locale_timeformat_24hour(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1493 SETTING_TRACE_BEGIN;
1496 if (system_setting_vconf_get_value_int(VCONFKEY_REGIONFORMAT_TIME1224, &vconf_value)) {
1497 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1500 bool ret_value = true;
1501 if (vconf_value == VCONFKEY_TIME_FORMAT_12)
1503 else if (vconf_value == VCONFKEY_TIME_FORMAT_24)
1506 *value = (void *)ret_value;
1508 return SYSTEM_SETTINGS_ERROR_NONE;
1510 /* LCOV_EXCL_STOP */
1512 int system_setting_set_locale_timeformat_24hour(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1514 SETTING_TRACE_BEGIN;
1517 vconf_value = (bool *)value;
1520 if (system_setting_vconf_set_value_int(VCONFKEY_REGIONFORMAT_TIME1224, VCONFKEY_TIME_FORMAT_24)) {
1521 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1525 if (system_setting_vconf_set_value_int(VCONFKEY_REGIONFORMAT_TIME1224, VCONFKEY_TIME_FORMAT_12)) {
1526 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1531 return SYSTEM_SETTINGS_ERROR_NONE;
1534 int system_setting_set_changed_callback_locale_timeformat_24hour(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1536 SETTING_TRACE_BEGIN;
1537 return system_setting_vconf_set_changed_cb(VCONFKEY_REGIONFORMAT_TIME1224, SYSTEM_SETTINGS_KEY_LOCALE_TIMEFORMAT_24HOUR, 3, user_data);
1540 int system_setting_unset_changed_callback_locale_timeformat_24hour(system_settings_key_e key)
1542 SETTING_TRACE_BEGIN;
1543 return system_setting_vconf_unset_changed_cb(VCONFKEY_REGIONFORMAT_TIME1224, 3);
1546 int system_setting_get_locale_timezone(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1549 ssize_t len = readlink(SETTING_TZONE_SYMLINK_PATH, tzpath, sizeof(tzpath)-1);
1553 SETTING_TRACE("parse error for SETTING_TZONE_SYMLINK_PATH");
1554 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1557 SETTING_TRACE("tzpath : %s ", &tzpath[20]);
1558 *value = strdup(&tzpath[20]);
1559 return SYSTEM_SETTINGS_ERROR_NONE;
1562 /* LCOV_EXCL_START */
1563 int system_setting_set_locale_timezone(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1565 SETTING_TRACE_BEGIN;
1566 char *timezone_value = NULL;
1567 timezone_value = (char *)value;
1570 snprintf(tz_path, 1024, "/usr/share/zoneinfo/%s", timezone_value);
1572 int is_load = _is_file_accessible(tz_path);
1574 alarmmgr_set_timezone(tz_path);
1576 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_TIMEZONE_ID, timezone_value)) {
1577 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1579 return SYSTEM_SETTINGS_ERROR_NONE;
1581 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
1583 /* LCOV_EXCL_STOP */
1587 /* LCOV_EXCL_START */
1588 int system_setting_set_changed_callback_locale_timezone(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1590 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_TIMEZONE_ID, SYSTEM_SETTINGS_KEY_LOCALE_TIMEZONE, 4, user_data);
1592 /* LCOV_EXCL_STOP */
1594 /* LCOV_EXCL_START */
1595 int system_setting_unset_changed_callback_locale_timezone(system_settings_key_e key)
1597 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_TIMEZONE_ID, 4);
1599 /* LCOV_EXCL_STOP */
1601 /* LCOV_EXCL_START */
1602 int system_setting_set_changed_callback_locale_timezone_changed(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1604 SETTING_TRACE_BEGIN;
1605 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
1607 /* LCOV_EXCL_STOP */
1609 /* LCOV_EXCL_START */
1610 int system_setting_unset_changed_callback_locale_timezone_changed(system_settings_key_e key)
1612 SETTING_TRACE_BEGIN;
1613 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
1615 /* LCOV_EXCL_STOP */
1618 /* LCOV_EXCL_START */
1619 int system_setting_get_time_changed(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1621 SETTING_TRACE_BEGIN;
1623 int ** val = (int**)value;
1624 cur_tick = time(NULL);
1626 /* struct tm * localtime = time (cur_tick); */
1627 /* printf("%s\n", ctime(&cur_tick); */
1628 return SYSTEM_SETTINGS_ERROR_NONE;
1631 /* LCOV_EXCL_STOP */
1633 int system_setting_set_changed_callback_time_changed(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1635 SETTING_TRACE_BEGIN;
1636 return system_setting_vconf_set_changed_cb(VCONFKEY_SYSTEM_TIME_CHANGED, SYSTEM_SETTINGS_KEY_TIME_CHANGED, 3, user_data);
1639 int system_setting_unset_changed_callback_time_changed(system_settings_key_e key)
1641 SETTING_TRACE_BEGIN;
1642 return system_setting_vconf_unset_changed_cb(VCONFKEY_SYSTEM_TIME_CHANGED, 3);
1647 /* SYSTEM_SETTINGS_KEY_SOUND_LOCK */
1648 int system_setting_get_sound_lock(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1650 SETTING_TRACE_BEGIN;
1653 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_SOUND_LOCK_BOOL, &vconf_value)) {
1654 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1656 *value = (void *)vconf_value;
1658 return SYSTEM_SETTINGS_ERROR_NONE;
1661 int system_setting_set_changed_callback_sound_lock(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1663 SETTING_TRACE_BEGIN;
1664 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_SOUND_LOCK_BOOL, SYSTEM_SETTINGS_KEY_SOUND_LOCK, 3, user_data);
1667 int system_setting_unset_changed_callback_sound_lock(system_settings_key_e key)
1669 SETTING_TRACE_BEGIN;
1670 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_SOUND_LOCK_BOOL, 3);
1674 * a = VCONFKEY_SETAPPL_SOUND_STATUS_BOOL b = VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL
1676 * a == false, b == false --> silent mode
1677 * a == true, b == false --> sound mode
1678 * a == false, b == true --> vibration mode
1680 /* LCOV_EXCL_START */
1681 int system_setting_get_sound_silent_mode(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1683 SETTING_TRACE_BEGIN;
1688 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, &sound_cond)) {
1689 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1692 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, &vib_cond)) {
1693 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1696 if (sound_cond == false && vib_cond == false) {
1698 *value = (void *)vconf_value;
1700 vconf_value = false;
1701 *value = (void *)vconf_value;
1703 return SYSTEM_SETTINGS_ERROR_NONE;
1705 /* LCOV_EXCL_STOP */
1708 * a = VCONFKEY_SETAPPL_SOUND_STATUS_BOOL b = VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL
1710 * a == false, b == false --> silent mode
1711 * a == true, b == false --> sound mode
1713 int system_setting_set_sound_silent_mode(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1715 SETTING_TRACE_BEGIN;
1718 vconf_value = (bool *)value;
1720 bool vconf_sound = false;
1721 bool vconf_vib = false;
1724 vconf_sound = false;
1731 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, vconf_sound)) {
1732 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1734 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, vconf_vib)) {
1735 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1738 return SYSTEM_SETTINGS_ERROR_NONE;
1744 int system_setting_set_changed_callback_sound_silent_mode(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1746 SETTING_TRACE_BEGIN;
1747 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, SYSTEM_SETTINGS_KEY_SOUND_SILENT_MODE, 3, user_data);
1751 int system_setting_unset_changed_callback_sound_silent_mode(system_settings_key_e key)
1753 SETTING_TRACE_BEGIN;
1754 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, 3);
1757 /* SYSTEM_SETTINGS_KEY_SOUND_TOUCH */
1758 int system_setting_get_sound_touch(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1760 SETTING_TRACE_BEGIN;
1763 int ret = system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL, &vconf_value);
1764 if (ret != SYSTEM_SETTINGS_ERROR_NONE) {
1767 *value = (void *)vconf_value;
1771 int system_setting_set_changed_callback_sound_touch(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1773 SETTING_TRACE_BEGIN;
1774 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL, SYSTEM_SETTINGS_KEY_SOUND_TOUCH, 2, user_data);
1777 int system_setting_unset_changed_callback_sound_touch(system_settings_key_e key)
1779 SETTING_TRACE_BEGIN;
1780 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL, 2);
1784 /* SYSTEM_SETTINGS_KEY_SOUND_LOCK */
1785 int system_setting_get_sound_lock(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1789 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_SOUND_LOCK_BOOL, &vconf_value)) {
1790 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1792 *value = (void *)vconf_value;
1794 return SYSTEM_SETTINGS_ERROR_NONE;
1798 int system_setting_get_auto_rotation_mode(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1800 SETTING_TRACE_BEGIN;
1803 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, &vconf_value)) {
1804 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1806 *value = (void *)vconf_value;
1808 return SYSTEM_SETTINGS_ERROR_NONE;
1811 /* LCOV_EXCL_START */
1812 int system_setting_set_auto_rotation_mode(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1814 SETTING_TRACE_BEGIN;
1816 vconf_value = (bool *)value;
1817 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, *vconf_value)) {
1818 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1821 return SYSTEM_SETTINGS_ERROR_NONE;
1823 /* LCOV_EXCL_STOP */
1825 int system_setting_set_changed_callback_auto_rotation_mode(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1827 SETTING_TRACE_BEGIN;
1828 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, SYSTEM_SETTINGS_KEY_DISPLAY_SCREEN_ROTATION_AUTO, 2, user_data);
1831 int system_setting_unset_changed_callback_auto_rotation_mode(system_settings_key_e key)
1833 SETTING_TRACE_BEGIN;
1834 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, 2);
1837 int system_setting_get_screen_backlight_time(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1839 SETTING_TRACE_BEGIN;
1841 int ** val = (int**)value;
1843 if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, &vconf_value)) {
1844 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1846 **val = vconf_value;
1848 return SYSTEM_SETTINGS_ERROR_NONE;
1852 /* LCOV_EXCL_START */
1853 int system_setting_set_screen_backlight_time(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1855 SETTING_TRACE_BEGIN;
1857 vconf_value = *(int **)value;
1859 if (!(*vconf_value > 0 && *vconf_value <= 600)) {
1860 SETTING_TRACE(" ERR Betweeny here 0 ~ 600");
1861 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
1864 if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, *vconf_value)) {
1865 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1868 return SYSTEM_SETTINGS_ERROR_NONE;
1870 /* LCOV_EXCL_STOP */
1872 int system_setting_set_changed_callback_screen_backlight_time(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1874 SETTING_TRACE_BEGIN;
1875 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, SYSTEM_SETTINGS_KEY_SCREEN_BACKLIGHT_TIME, 2, user_data);
1878 int system_setting_unset_changed_callback_screen_backlight_time(system_settings_key_e key)
1880 SETTING_TRACE_BEGIN;
1881 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, 2);
1884 int system_setting_get_sound_notification(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1886 SETTING_TRACE_BEGIN;
1887 char *vconf_value = NULL;
1888 if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, &vconf_value)) {
1889 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1892 *value = vconf_value;
1893 return SYSTEM_SETTINGS_ERROR_NONE;
1896 /* LCOV_EXCL_START */
1897 int system_setting_set_sound_notification(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1899 SETTING_TRACE_BEGIN;
1900 char *vconf_value = NULL;
1901 vconf_value = (char *)value;
1903 int is_load = _is_file_accessible(vconf_value);
1905 //SETTING_TRACE(" system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, %s) TRY", vconf_value);
1906 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, vconf_value)) {
1907 //SETTING_TRACE(" system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, %s) FAIL", vconf_value);
1908 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1911 //SETTING_TRACE(" is_file_accessibile FAILED - system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, %s) FAIL", vconf_value);
1912 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1915 return SYSTEM_SETTINGS_ERROR_NONE;
1917 /* LCOV_EXCL_STOP */
1919 int system_setting_set_changed_callback_sound_notification(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1921 SETTING_TRACE_BEGIN;
1922 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, SYSTEM_SETTINGS_KEY_SOUND_NOTIFICATION, 0, user_data);
1925 int system_setting_unset_changed_callback_sound_notification(system_settings_key_e key)
1927 SETTING_TRACE_BEGIN;
1928 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, 0);
1931 int system_setting_get_notification_repetition_period(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1933 SETTING_TRACE_BEGIN;
1934 int ** val = (int**)value;
1937 if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_NOTI_MSG_ALERT_REP_TYPE_INT, &vconf_value)) {
1938 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1940 **val = vconf_value;
1942 return SYSTEM_SETTINGS_ERROR_NONE;
1945 /* LCOV_EXCL_START */
1946 int system_setting_set_notification_repetition_period(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1948 SETTING_TRACE_BEGIN;
1950 vconf_value = *(int **)value;
1952 if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_NOTI_MSG_ALERT_REP_TYPE_INT, *vconf_value)) {
1953 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1956 return SYSTEM_SETTINGS_ERROR_NONE;
1958 /* LCOV_EXCL_STOP */
1960 int system_setting_set_changed_callback_notification_repetition_period(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1962 SETTING_TRACE_BEGIN;
1963 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_ALERT_REP_TYPE_INT, SYSTEM_SETTINGS_KEY_SOUND_NOTIFICATION_REPETITION_PERIOD, 1, user_data);
1966 int system_setting_unset_changed_callback_notification_repetition_period(system_settings_key_e key)
1968 SETTING_TRACE_BEGIN;
1969 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_ALERT_REP_TYPE_INT, 1);
1972 int system_setting_get_device_name(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1974 SETTING_TRACE_BEGIN;
1975 char *vconf_value = NULL;
1976 if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_DEVICE_NAME_STR, &vconf_value)) {
1977 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1980 *value = vconf_value;
1981 return SYSTEM_SETTINGS_ERROR_NONE;
1984 /* LCOV_EXCL_START */
1985 int system_setting_set_device_name(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1987 SETTING_TRACE_BEGIN;
1988 char *vconf_value = NULL;
1989 vconf_value = (char *)value;
1991 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_DEVICE_NAME_STR, vconf_value)) {
1992 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1995 return SYSTEM_SETTINGS_ERROR_NONE;
1997 /* LCOV_EXCL_STOP */
1999 int system_setting_set_changed_callback_device_name(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
2001 SETTING_TRACE_BEGIN;
2002 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_DEVICE_NAME_STR, SYSTEM_SETTINGS_KEY_DEVICE_NAME, 0, user_data);
2005 int system_setting_unset_changed_callback_device_name(system_settings_key_e key)
2007 SETTING_TRACE_BEGIN;
2008 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_DEVICE_NAME_STR, 0);
2011 /*---------------------------------------------- */
2012 int system_setting_get_network_flight_mode(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
2014 SETTING_TRACE_BEGIN;
2016 if (system_setting_vconf_get_value_bool(VCONFKEY_TELEPHONY_FLIGHT_MODE, &vconf_value)) {
2017 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2019 *value = (void *)vconf_value;
2021 return SYSTEM_SETTINGS_ERROR_NONE;
2024 int system_setting_set_changed_callback_network_flight_mode(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
2026 SETTING_TRACE_BEGIN;
2027 return system_setting_vconf_set_changed_cb(VCONFKEY_TELEPHONY_FLIGHT_MODE, SYSTEM_SETTINGS_KEY_NETWORK_FLIGHT_MODE, 3, user_data);
2030 int system_setting_unset_changed_callback_network_flight_mode(system_settings_key_e key)
2032 SETTING_TRACE_BEGIN;
2033 return system_setting_vconf_unset_changed_cb(VCONFKEY_TELEPHONY_FLIGHT_MODE, 3);
2036 int system_setting_get_network_wifi_notification(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
2038 SETTING_TRACE_BEGIN;
2040 if (system_setting_vconf_get_value_int(VCONFKEY_WIFI_ENABLE_QS, &vconf_value)) {
2041 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2044 bret = (vconf_value == VCONFKEY_WIFI_QS_ENABLE) ? true : false;
2046 *value = (void *)bret;
2047 return SYSTEM_SETTINGS_ERROR_NONE;
2050 int system_setting_set_changed_callback_network_wifi_notification(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
2052 SETTING_TRACE_BEGIN;
2053 return system_setting_vconf_set_changed_cb(VCONFKEY_WIFI_ENABLE_QS, SYSTEM_SETTINGS_KEY_NETWORK_WIFI_NOTIFICATION, 4, user_data);
2056 int system_setting_unset_changed_callback_network_wifi_notification(system_settings_key_e key)
2058 SETTING_TRACE_BEGIN;
2059 return system_setting_vconf_unset_changed_cb(VCONFKEY_WIFI_ENABLE_QS, 4);
2062 /* LCOV_EXCL_START */
2063 int system_setting_get_lock_state(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
2066 int ** val = (int**)value;
2068 if (system_setting_vconf_get_value_int(VCONFKEY_IDLE_LOCK_STATE_READ_ONLY, &vconf_value)) {
2069 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2071 **val = vconf_value;
2073 return SYSTEM_SETTINGS_ERROR_NONE;
2075 /* LCOV_EXCL_STOP */
2077 /* LCOV_EXCL_START */
2078 int system_setting_set_lock_state(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
2080 SETTING_TRACE_BEGIN;
2082 vconf_value = *(int **)value;
2084 if (system_setting_vconf_set_value_int(VCONFKEY_IDLE_LOCK_STATE_READ_ONLY, *vconf_value)) {
2085 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2088 return SYSTEM_SETTINGS_ERROR_NONE;
2090 /* LCOV_EXCL_STOP */
2092 /* LCOV_EXCL_START */
2093 int system_setting_set_changed_callback_lock_state(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
2095 return system_setting_vconf_set_changed_cb(VCONFKEY_IDLE_LOCK_STATE_READ_ONLY, SYSTEM_SETTINGS_KEY_LOCK_STATE, 4, user_data);
2097 /* LCOV_EXCL_STOP */
2099 /* LCOV_EXCL_START */
2100 int system_setting_unset_changed_callback_lock_state(system_settings_key_e key)
2102 return system_setting_vconf_unset_changed_cb(VCONFKEY_IDLE_LOCK_STATE_READ_ONLY, 4);
2104 /* LCOV_EXCL_STOP */
2106 //----------------------------------------------------------------------------------------------------------------------------
2108 #define DEFAULT_ADS_ID "00000000-0000-0000-0000-000000000000"
2110 int system_setting_get_ads_id(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
2112 SETTING_TRACE_BEGIN;
2113 int optout_value = 0;
2114 if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_AD_ID_OPT_OUT, &optout_value)) {
2115 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2118 if (optout_value == 1) {
2119 *value = strdup(DEFAULT_ADS_ID);
2120 return SYSTEM_SETTINGS_ERROR_NONE;
2123 char *vconf_value = NULL;
2124 if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_AD_ID, &vconf_value)) {
2125 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2128 *value = vconf_value;
2129 return SYSTEM_SETTINGS_ERROR_NONE;
2134 void make_ad_id(void)
2137 char uuid_unparsed[50] = {0};
2138 uuid_generate(uuid_value);
2139 uuid_unparse(uuid_value, uuid_unparsed);
2140 system_setting_set_ad_id(key, uuid_unparsed); //example of setting the value
2143 /* LCOV_EXCL_START */
2144 int system_setting_set_ads_id(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
2146 SETTING_TRACE_BEGIN;
2147 char *vconf_value = NULL;
2148 vconf_value = (char *)value;
2150 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_AD_ID, vconf_value)) {
2151 SETTING_TRACE("Setting VCONFKEY_SETAPPL_AD_ID failed");
2152 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2155 return SYSTEM_SETTINGS_ERROR_NONE;
2157 /* LCOV_EXCL_STOP */
2159 int system_setting_set_changed_callback_ads_id(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
2161 SETTING_TRACE_BEGIN;
2162 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_AD_ID, SYSTEM_SETTINGS_KEY_ADS_ID, 0, user_data);
2165 int system_setting_unset_changed_callback_ads_id(system_settings_key_e key)
2167 SETTING_TRACE_BEGIN;
2168 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_AD_ID, 0);
2171 //----------------------------------------------------------------------------------------------------------------------------
2173 /* LCOV_EXCL_START */
2174 int system_setting_get_uds_state(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
2176 int ** p_value = (int**)value;
2178 char *vconf_string_value = NULL;
2180 if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_UDSM, &vconf_value)) {
2181 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2184 SETTING_TRACE("[%s] udsm: %d", __FUNCTION__, vconf_value);
2186 if (vconf_value == SYSTEM_SETTINGS_UDS_ON) {
2187 if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_UDSM_PKGID_LIST, &vconf_string_value))
2188 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2190 if (vconf_string_value) {
2191 if (!strcmp(vconf_string_value, "NONE")) {
2192 vconf_value = SYSTEM_SETTINGS_UDS_ON;
2194 char *app_id = NULL;
2195 char *package_id = NULL;
2196 pid_t pid = getpid();
2197 app_manager_get_app_id(pid, &app_id);
2200 package_manager_get_package_id_by_app_id(app_id, &package_id);
2201 SETTING_TRACE("[%s] udsm_pkg_list : %s", __FUNCTION__, vconf_string_value);
2204 if (package_id && strstr(vconf_string_value, package_id)) {
2205 vconf_value = SYSTEM_SETTINGS_UDS_ON_WHITELISTED;
2206 SETTING_TRACE("[%s] pkg id : %s", __FUNCTION__, package_id);
2208 vconf_value = SYSTEM_SETTINGS_UDS_ON;
2212 if (vconf_string_value)
2213 free(vconf_string_value);
2217 **p_value = vconf_value;
2220 return SYSTEM_SETTINGS_ERROR_NONE;
2222 /* LCOV_EXCL_STOP */
2224 /* LCOV_EXCL_START */
2225 int system_setting_set_changed_callback_uds_state(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
2227 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_UDSM, SYSTEM_SETTINGS_KEY_ULTRA_DATA_SAVE, 4, user_data);
2229 /* LCOV_EXCL_STOP */
2231 /* LCOV_EXCL_START */
2232 int system_setting_unset_changed_callback_uds_state(system_settings_key_e key)
2234 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_UDSM, 4);
2236 /* LCOV_EXCL_STOP */
2238 /* LCOV_EXCL_START */
2239 int system_setting_set_changed_callback_uds_pkg_list(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
2241 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_UDSM_PKGID_LIST, SYSTEM_SETTINGS_KEY_ULTRA_DATA_SAVE_PKG_LIST, 4, user_data);
2243 /* LCOV_EXCL_STOP */
2245 /* LCOV_EXCL_START */
2246 int system_setting_unset_changed_callback_uds_pkg_list(system_settings_key_e key)
2248 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_UDSM_PKGID_LIST, 4);
2250 /* LCOV_EXCL_STOP */