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>
43 #include <system_settings.h>
44 #include <system_settings_private.h>
45 #include <system_settings_ringtones.h>
46 #include <system_settings_json.h>
49 #include <tzplatform_config.h>
53 #include <efl_assist.h>
58 #define SETTING_FONT_CONF_FILE _TZ_SYS_ETC"/fonts/conf.avail/99-tizen.conf"
59 #define SETTING_DEFAULT_FONT_CONF_FILE _TZ_SYS_ETC"/fonts/conf.avail/99-tizen.conf"
61 #define SETTING_TIME_ZONEINFO_PATH "/usr/share/zoneinfo/"
62 #define SETTING_TIME_SHARE_LOCAL_PATH "/usr/share/locale"
63 #define SETTING_TZONE_SYMLINK_PATH "/opt/etc/localtime"
66 #define __FREE(del, arg) do { \
68 del((void *)(arg)); /*cast any argument to (void*) to avoid build warring*/\
72 #define FREE(arg) __FREE(free, arg)
74 #ifdef SETTING_ARCH_64
75 #define SETTING_UTILS_SO_FILE_PATH "/usr/lib64/libsystem-settings-util.so.0.1.0"
77 #define SETTING_UTILS_SO_FILE_PATH "/usr/lib/libsystem-settings-util.so.0.1.0"
80 int _is_file_accessible(const char *path);
82 static bool dl_is_supported_image_type_load(char *path);
83 static bool dl_font_config_set(char *font_name);
84 static char *dl_get_font_info(char *str);
85 static int dl_is_available_font(char *str);
86 static void dl_font_size_set();
87 static void dl_font_config_set_notification();
91 * VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR has a path of the ringtone file which user choose
92 * @return the ringtone file path specified by user in normal case
93 * if it's not accessable, return the default ringtone path
95 int system_setting_get_incoming_call_ringtone(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
99 if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR, &vconf_value)) {
100 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
103 /* check to see if it's accessable -> OK */
104 /* no --> default ringtone path VCONFKEY_SETAPPL_CALL_RINGTONE_DEFAULT_PATH_STR */
105 int is_load = _is_file_accessible(vconf_value);
107 *value = vconf_value;
108 } else { /* not zero on errro */
109 *value = vconf_get_str(VCONFKEY_SETAPPL_CALL_RINGTONE_DEFAULT_PATH_STR);
112 /**value = vconf_value; */
113 return SYSTEM_SETTINGS_ERROR_NONE;
117 int system_setting_get_email_alert_ringtone(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
121 if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, &vconf_value)) {
122 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
125 /* check to see if it's accessable -> OK */
126 /* no --> default ringtone path VCONFKEY_SETAPPL_NOTI_RINGTONE_DEFAULT_PATH_STR */
127 int is_load = _is_file_accessible(vconf_value);
129 *value = vconf_value;
130 } else { /* not zero on errro */
131 *value = vconf_get_str(VCONFKEY_SETAPPL_NOTI_RINGTONE_DEFAULT_PATH_STR);
134 return SYSTEM_SETTINGS_ERROR_NONE;
138 int system_setting_get_wallpaper_home_screen(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
142 if (system_setting_vconf_get_value_string(VCONFKEY_BGSET, &vconf_value)) {
143 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
145 *value = vconf_value;
146 return SYSTEM_SETTINGS_ERROR_NONE;
150 int system_setting_get_wallpaper_lock_screen(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
155 if (system_setting_vconf_get_value_string(VCONFKEY_IDLE_LOCK_BGSET, &vconf_value)) {
156 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
158 *value = vconf_value;
160 return SYSTEM_SETTINGS_ERROR_NONE;
164 /* [int] vconf GET */
165 int system_setting_get_font_size(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
170 if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, &vconf_value)) {
171 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
173 *value = (void *)vconf_value;
175 return SYSTEM_SETTINGS_ERROR_NONE;
179 int system_setting_get_default_font_type(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
182 char *font_name = dl_get_font_info("default");
184 *value = (void *)font_name;
185 return SYSTEM_SETTINGS_ERROR_NONE;
187 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
191 /* [int] vconf GET */
192 int system_setting_get_font_type(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
195 char *font_name = dl_get_font_info("cur");
196 *value = (void *)font_name;
198 return SYSTEM_SETTINGS_ERROR_NONE;
202 int system_setting_get_motion_activation(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
207 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_MOTION_ACTIVATION, &vconf_value)) {
208 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
210 *value = (void *)vconf_value;
212 return SYSTEM_SETTINGS_ERROR_NONE;
215 int system_setting_get_usb_debugging_option(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
220 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_USB_DEBUG_MODE_BOOL, &vconf_value)) {
221 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
223 *value = (void *)vconf_value;
225 return SYSTEM_SETTINGS_ERROR_NONE;
228 int system_setting_get_3g_data_network(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
233 if (system_setting_vconf_get_value_bool(VCONFKEY_3G_ENABLE, &vconf_value)) {
234 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
236 *value = (void *)vconf_value;
238 return SYSTEM_SETTINGS_ERROR_NONE;
240 /*////////////////////////////////////////////////////////////////////////////////////////////////// */
244 * get current lock scren app package name (string)
246 * @return SYSTEM_SETTINGS_ERROR_LOCKSCREEN_APP_PASSWORD_MODE raise exception if current lock type is 'password'
248 int system_setting_get_lockscreen_app(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
251 char *pkg_name = NULL;
253 system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_SCREEN_LOCK_TYPE_INT, &locktype);
255 if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_3RD_LOCK_PKG_NAME_STR, &pkg_name)) {
256 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
259 if (pkg_name && strcmp(pkg_name, "com.samsung.lockscreen") == 0 && locktype == SETTING_SCREEN_LOCK_TYPE_PASSWORD) {
260 return SYSTEM_SETTINGS_ERROR_LOCKSCREEN_APP_PASSWORD_MODE;
264 return SYSTEM_SETTINGS_ERROR_NONE;
268 /*////////////////////////////////////////////////////////////////////////////////////////////////// */
270 int _is_file_accessible(const char *path)
273 int ret = access(path , R_OK);
275 SETTING_TRACE("found the file %s", path);
278 /* error code : 13 */
279 SETTING_TRACE("found the file %s --- error code : %d ", path, errno);
286 /*////////////////////////////////////////////////////////////////////////////////////////////////// */
287 // @todo move to CMake
288 #define DEF_RINGTONE_FILE_PATH "/opt/share/settings/Ringtones"
289 #define USR_RINGTONE_FILE_PATH "/home/owner/content/Sounds/Ringtones"
290 #define JSONFILE "/opt/home/owner/apps_rw/org.tizen.setting/data/.user-ringtones.json"
293 static char* _get_json_file_path()
300 int system_setting_add_incoming_call_ringtone(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
303 char* pathval = (char*)value;
307 JsonParser *parser = ss_json_ringtone_open_file(JSONFILE);
309 JsonParser *parser = ss_json_ringtone_load_from_data();
312 JsonNode *root = json_parser_get_root(parser);
316 int ret = SYSTEM_SETTINGS_ERROR_NONE;
317 if (false == ss_json_ringtone_contain(root, pathval)) {
318 SETTING_TRACE("---> dirname is : %s ", dirname(strdup(pathval)));
319 SETTING_TRACE("---> basename is : %s ", basename(strdup(pathval)));
320 // @todo : MAKE SURE THE ACTUAL FILE IS THERE ON PATHVAL(SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER)
321 ss_json_ringtone_add(root, JSONFILE, pathval, pathval);
322 SETTING_TRACE("pathval is : %s -- OK", pathval);
324 SETTING_TRACE("pathval is duplicated : %s", pathval);
325 SETTING_TRACE("---> dirname is : %s ", dirname(strdup(pathval)));
326 SETTING_TRACE("---> basename is : %s ", basename(strdup(pathval)));
327 ret = SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
331 g_object_unref(parser);
338 int system_setting_del_incoming_call_ringtone(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
341 char* pathval = (char*)value;
344 JsonParser* parser = ss_json_ringtone_open_file(JSONFILE);
346 JsonParser* parser = ss_json_ringtone_load_from_data();
348 JsonNode *root = json_parser_get_root(parser);
350 ss_json_ringtone_remove(root, JSONFILE, pathval);
351 //void ss_json_ringtone_remove(JsonNode *root, char* filename, char* path_to_del)
353 ss_json_ringtone_print(root);
355 g_object_unref(parser);
359 return SYSTEM_SETTINGS_ERROR_NONE;
363 static int _compare_cb(const void *d1, const void *d2)
365 fileNodeInfo *pNode1 = (fileNodeInfo *)d1;
366 fileNodeInfo *pNode2 = (fileNodeInfo *)d2;
368 return strcmp(pNode1->media_name, pNode2->media_name);
372 * get the RINGTONE list
374 static void _get_default_ringtones(system_settings_key_e key, system_setting_data_type_e data_type, system_settings_iter_cb callback, void *data)
378 Eina_List *filelist = NULL;
380 fileNodeInfo *node = NULL;
383 //-----------------------------------------------------------------------------------------------------------------
384 // 1. get the default ringtone list
385 //-----------------------------------------------------------------------------------------------------------------
386 int ret = get_filelist_from_dir_path(DEF_RINGTONE_FILE_PATH, &filelist);
388 SETTING_TRACE("Failed to get filelist, ret = %d %s", ret, DEF_RINGTONE_FILE_PATH);
390 filelist = eina_list_sort(filelist, eina_list_count(filelist), _compare_cb);
392 EINA_LIST_FOREACH(filelist, l, node)
394 SETTING_TRACE("file path = (%d) : name:%s path:%s [%s]", ret, node->name, node->path, node->media_name);
395 // @todo assert NULL check
398 snprintf(temp, 1024, "%s/%s", node->path, node->name);
399 char* path = strdup(temp);
400 bool ret = callback(idx, (void *)(path), data);
406 SETTING_TRACE("quit the iteration by return value == false : %d", ret);
411 SETTING_TRACE("--> system_setting_data_iterator is NULL");
417 EINA_LIST_FOREACH(filelist, l, node)
421 FREE(node->media_name);
424 eina_list_free(filelist);
429 static void _get_user_ringtones(system_settings_key_e key, system_setting_data_type_e data_type, system_settings_iter_cb callback, void *data)
435 JsonParser* parser = ss_json_ringtone_open_file(JSONFILE);
437 JsonParser* parser = ss_json_ringtone_load_from_data();
440 JsonNode *root = json_parser_get_root(parser);
441 int size = json_array_get_length(json_node_get_array(root));
444 for (i = 0; i < size ; i++) {
445 JsonObject *ringtone = json_array_get_object_element(json_node_get_array(root), i);
446 char *nameval = (char *)json_object_get_string_member(ringtone, "name");
447 char *pathval = (char *)json_object_get_string_member(ringtone, "path");
448 SETTING_TRACE("(%s) --- (%s) \n", nameval, pathval);
450 char* path = strdup(pathval);
451 bool ret = callback(i, (void *)(path), data);
453 SETTING_TRACE("quit the iteration by return value == false : %d", ret);
457 SETTING_TRACE("--> callback is NULL");
462 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)
466 _get_default_ringtones(key, data_type, callback, data);
467 //-----------------------------------------------------------------------------------------------------------------
468 // 2. get the USER ringtone list
469 //-----------------------------------------------------------------------------------------------------------------
470 _get_user_ringtones(key, data_type, callback, data);
472 return SYSTEM_SETTINGS_ERROR_NONE;
476 /* LCOV_EXCL_START */
477 int system_setting_set_incoming_call_ringtone(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
481 vconf_value = (char *)value;
483 int ret = _is_file_accessible(vconf_value);
485 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR, vconf_value)) {
486 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
489 /* @todo add a common ret_handler */
493 return SYSTEM_SETTINGS_ERROR_NONE;
498 /* LCOV_EXCL_START */
499 int system_setting_set_email_alert_ringtone(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
503 vconf_value = (char *)value;
505 int ret = _is_file_accessible(vconf_value);
507 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, vconf_value)) {
508 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
511 /*return SYSTEM_SETTINGS_ERROR_IO_ERROR;*/
512 /* @todo add a common ret_handler */
516 return SYSTEM_SETTINGS_ERROR_NONE;
520 /* LCOV_EXCL_START */
521 static bool dl_is_supported_image_type_load(char *path)
526 bool (*image_type_check)(char *path);
528 handle = dlopen(SETTING_UTILS_SO_FILE_PATH, RTLD_LAZY);
530 SETTING_TRACE("ERROR!! canNOT find libsystem-settings-util.so.0.1.0");
534 image_type_check = dlsym(handle, "__is_supported_image_type_load");
535 if ((error = dlerror()) != NULL) {
536 SETTING_TRACE("ERROR!! canNOT find __is_supported_image_type_load function at libsystem-settings-util.so.0.1.0");
541 ret = image_type_check(path);
548 /* LCOV_EXCL_START */
549 static int dl_is_available_font(char *str)
554 int (*check_available_font)(char *font_name);
556 handle = dlopen(SETTING_UTILS_SO_FILE_PATH, RTLD_LAZY);
558 SETTING_TRACE("ERROR!! canNOT find libsystem-settings-util.so.0.1.0");
562 check_available_font = dlsym(handle, "__is_available_font");
563 if ((error = dlerror()) != NULL) {
564 SETTING_TRACE("ERROR!! canNOT find __is_available_font function at libsystem-settings-util.so.0.1.0");
569 ret = check_available_font(str);
576 /* LCOV_EXCL_START */
577 static void dl_font_size_set()
581 void (*set_font_size)();
583 handle = dlopen(SETTING_UTILS_SO_FILE_PATH, RTLD_LAZY);
585 SETTING_TRACE("ERROR!! canNOT find libsystem-settings-util.so.0.1.0");
589 set_font_size = dlsym(handle, "__font_size_set");
590 if ((error = dlerror()) != NULL) {
591 SETTING_TRACE("ERROR!! canNOT find __font_size_set function at libsystem-settings-util.so.0.1.0");
603 /* LCOV_EXCL_START */
604 static void dl_font_config_set_notification()
608 void (*set_font_nodification)();
610 handle = dlopen(SETTING_UTILS_SO_FILE_PATH, RTLD_LAZY);
612 SETTING_TRACE("ERROR!! canNOT find libsystem-settings-util.so.0.1.0");
616 set_font_nodification = dlsym(handle, "font_config_set_notification");
617 if ((error = dlerror()) != NULL) {
618 SETTING_TRACE("ERROR!! canNOT find font_config_set_notification function at libsystem-settings-util.so.0.1.0");
623 set_font_nodification();
630 /* LCOV_EXCL_START */
631 static bool dl_font_config_set(char *font_name)
636 bool (*check_font_type)(char *font_name);
638 handle = dlopen(SETTING_UTILS_SO_FILE_PATH, RTLD_LAZY);
640 SETTING_TRACE("ERROR!! canNOT find libsystem-settings-util.so.0.1.0");
644 check_font_type = dlsym(handle, "font_config_set");
645 if ((error = dlerror()) != NULL) {
646 SETTING_TRACE("ERROR!! canNOT find font_config_set function at libsystem-settings-util.so.0.1.0");
651 ret = check_font_type(font_name);
658 /* LCOV_EXCL_START */
659 static char *dl_get_font_info(char *str)
664 char *(*get_font_info)();
666 handle = dlopen(SETTING_UTILS_SO_FILE_PATH, RTLD_LAZY);
668 SETTING_TRACE("ERROR!! canNOT find libsystem-settings-util.so.0.1.0");
672 if (strcmp(str, "cur") == 0)
673 get_font_info = dlsym(handle, "_get_cur_font");
675 get_font_info = dlsym(handle, "_get_default_font");
677 if ((error = dlerror()) != NULL) {
678 SETTING_TRACE("ERROR!! canNOT find %s function at libsystem-settings-util.so.0.1.0", str);
683 ret = get_font_info();
690 /* LCOV_EXCL_START */
691 #define PATH_EXT_CHECK_REG ".(jpe?g|jpg|png|gif)$"
692 bool __is_supported_image_type_by_ext(char *file_path)
696 regmatch_t str[2048 + 1];
698 if (!file_path) return false;
701 if ((ret = regcomp(&fsm, PATH_EXT_CHECK_REG, REG_ICASE | REG_EXTENDED))) {
702 SETTING_TRACE("regular expresstion fail");
707 if (regexec(&fsm, file_path, strlen(file_path) + 1, str, 0) == REG_NOMATCH) {
708 /*SETTING_TRACE("FAILED - %s", file_path[i]); */
711 /*SETTING_TRACE("MATCHED - %s", file_path[i]); */
717 #ifdef TIZEN_WEARABLE
718 /* LCOV_EXCL_START */
719 static int system_setting_get_extended_wallpaper_num(const char *file_path, unsigned int *num)
723 const char *find_str = "extended_wallpaper_";
726 if (!(ch = strstr(file_path, find_str))) {
727 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
729 strncpy(buffer, file_path, ch - file_path);
730 buffer[ch - file_path] = 0;
731 sprintf(buffer + (ch - file_path), "%s%s", "", ch + strlen(find_str));
733 if (!isdigit(buffer[0])) {
734 SETTING_TRACE("%s is not number", buffer);
735 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
740 return SYSTEM_SETTINGS_ERROR_NONE;
744 /* LCOV_EXCL_START */
745 static int system_setting_copy_extended_wallpaper(const char *dest_file_path, const char *source_file_path)
748 if (!source_file_path || !dest_file_path) {
749 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
755 fd = open(source_file_path, O_RDONLY);
757 SETTING_TRACE("file open failed: %s", source_file_path);
758 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
762 fd2 = open(dest_file_path, O_WRONLY | O_CREAT, S_IRWXU | S_IRWXG | S_IRWXO);
764 SETTING_TRACE("file creation failed: %s", dest_file_path);
766 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
769 while (read(fd, buf, sizeof(buf) - 1) > 0) {
770 write(fd2, buf, sizeof(buf) - 1);
776 if (chmod(dest_file_path, S_IRWXU | S_IRWXG | S_IRWXO) < 0) {
777 SETTING_TRACE("chmod failed: %s", dest_file_path);
780 return SYSTEM_SETTINGS_ERROR_NONE;
784 /* LCOV_EXCL_START */
785 static int system_setting_remove_oldest_extended_wallpaper()
790 char *min_image_name = NULL;
791 unsigned int min_image_num = 0;
792 unsigned int temp_image_num = 0;
795 if ((dp = opendir(_TZ_SYS_DATA"/setting/wallpaper")) == NULL) {
796 SETTING_TRACE("opendir error");
797 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
800 while ((dirp = readdir(dp))) {
801 if (!strcmp(dirp->d_name, ".") || !strcmp(dirp->d_name, ".."))
804 if (system_setting_get_extended_wallpaper_num(dirp->d_name, &temp_image_num)
805 != SYSTEM_SETTINGS_ERROR_NONE) {
806 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
809 if ((image_count == 0) || (min_image_num > temp_image_num)) {
810 min_image_num = temp_image_num;
811 min_image_name = dirp->d_name;
818 if (min_image_name) {
819 snprintf(buf, sizeof(buf) - 1, _TZ_SYS_DATA"/setting/wallpaper/%s", min_image_name);
820 if (remove(buf) < 0) { /* remove oldest image */
821 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
825 return SYSTEM_SETTINGS_ERROR_NONE;
829 /* LCOV_EXCL_START */
830 static int system_setting_check_extended_wallpaper(const char *file_path)
834 if (!file_path || !strlen(file_path))
836 snprintf(buffer, 512, "%s/.bgwallpaper", tzplatform_getenv(TZ_USER_CONTENT));
837 return (strstr(file_path, buffer) != NULL);
841 #define WALLPAPER_MAX_COUNT 10
843 /* LCOV_EXCL_START */
844 int system_setting_set_wallpaper_home_screen(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
848 vconf_value = (char *)value;
850 bool isok = dl_is_supported_image_type_load(vconf_value);
853 SETTING_TRACE("path : %s is not supported file format", vconf_value);
854 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
856 SETTING_TRACE("path : %s is SUPPORT file format", vconf_value);
859 /* error handling here */
860 if (_is_file_accessible(vconf_value) != 0)
861 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
863 if (system_setting_vconf_set_value_string(VCONFKEY_BGSET, vconf_value)) {
864 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
868 #ifdef TIZEN_WEARABLE
869 if (system_setting_check_extended_wallpaper(vconf_value)) { /* New extended wallpaper */
872 unsigned int max_image_num = 0;
873 unsigned int temp_image_num = 0;
876 if ((dp = opendir(_TZ_SYS_DATA"/setting/wallpaper")) == NULL) {
877 SETTING_TRACE("Setting - dir open error!");
878 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
881 /* Check a max number of wallpapers */
882 while ((dirp = readdir(dp))) {
883 if (!strcmp(dirp->d_name, ".") || !strcmp(dirp->d_name, ".."))
886 if (system_setting_get_extended_wallpaper_num(dirp->d_name, &temp_image_num)
887 != SYSTEM_SETTINGS_ERROR_NONE) {
890 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
893 if ((image_count == 0) || (max_image_num < temp_image_num)) {
894 max_image_num = temp_image_num;
902 /* Numbering rule: Gear is odd number */
903 max_image_num = (max_image_num % 2 == 0) ? max_image_num + 1
906 char file_name_buffer[512];
907 snprintf(file_name_buffer, sizeof(file_name_buffer) - 1,
908 _TZ_SYS_DATA"/setting/wallpaper/extended_wallpaper_%d.jpg", max_image_num);
910 /* Copy image to _TZ_SYS_DATA/setting/wallpaper/ */
911 if (system_setting_copy_extended_wallpaper(file_name_buffer, vconf_value)
912 != SYSTEM_SETTINGS_ERROR_NONE) {
913 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
916 /* remove oldest wallpaper */
917 if (image_count >= WALLPAPER_MAX_COUNT) {
918 if (system_setting_remove_oldest_extended_wallpaper()
919 != SYSTEM_SETTINGS_ERROR_NONE) {
920 remove(file_name_buffer);
921 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
925 if (system_setting_vconf_set_value_string(VCONFKEY_BGSET, file_name_buffer)) {
926 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
929 if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_WALLPAPER_CHANGED_NOTI_INT,
930 VCONFKEY_WALLPAPER_CHANGED_NOTI_GEAR)) {
931 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
934 if (system_setting_vconf_set_value_string(VCONFKEY_BGSET, vconf_value)) {
935 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
940 return SYSTEM_SETTINGS_ERROR_NONE;
944 /* LCOV_EXCL_START */
945 int system_setting_set_wallpaper_lock_screen(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
949 vconf_value = (char *)value;
951 bool isok = dl_is_supported_image_type_load(vconf_value);
954 SETTING_TRACE("path : %s is not supported file format", vconf_value);
955 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
957 SETTING_TRACE("path : %s is SUPPORT file format", vconf_value);
960 /* error handling here */
961 if (_is_file_accessible(vconf_value) != 0)
962 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
964 if (system_setting_vconf_set_value_string(VCONFKEY_IDLE_LOCK_BGSET, vconf_value)) {
965 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
968 return SYSTEM_SETTINGS_ERROR_NONE;
972 /* LCOV_EXCL_START */
973 int system_setting_set_font_size(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
977 vconf_value = (int *)value;
979 if (*vconf_value < 0 || *vconf_value > SYSTEM_SETTINGS_FONT_SIZE_GIANT) {
980 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
983 if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, *vconf_value)) {
984 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
988 return SYSTEM_SETTINGS_ERROR_NONE;
994 /* LCOV_EXCL_START */
995 void *font_conf_doc_parse(char *doc_name, char *font_name)
998 xmlDocPtr doc = NULL;
999 xmlNodePtr cur = NULL;
1000 xmlNodePtr cur2 = NULL;
1001 xmlNodePtr cur3 = NULL;
1002 xmlChar *key = NULL;
1004 doc = xmlParseFile(doc_name);
1006 cur = xmlDocGetRootElement(doc);
1014 if (xmlStrcmp(cur->name, (const xmlChar *)"fontconfig")) {
1020 cur = cur->xmlChildrenNode;
1022 bool is_changed = false;
1023 while (cur != NULL) {
1024 if ((!xmlStrcmp(cur->name, (const xmlChar *)"match"))) {
1025 cur2 = cur->xmlChildrenNode;
1026 while (cur2 != NULL) {
1027 if ((!xmlStrcmp(cur2->name, (const xmlChar *)"edit"))) {
1028 xmlChar *name = xmlGetProp(cur2, (const xmlChar *)"name");
1029 /* if name is not 'family', break */
1030 if (xmlStrcmp(name, (const xmlChar *)"family")) {
1038 cur3 = cur2->xmlChildrenNode;
1039 while (cur3 != NULL) {
1040 if ((!xmlStrcmp(cur3->name, (const xmlChar *)"string"))) {
1041 xmlNodeSetContent(cur3->xmlChildrenNode, (const xmlChar *)font_name);
1042 key = xmlNodeListGetString(doc, cur3->xmlChildrenNode, 1);
1052 } else if ((!xmlStrcmp(cur->name, (const xmlChar *)"alias"))) {
1053 cur2 = cur->xmlChildrenNode;
1054 while (cur2 != NULL) {
1055 if ((!xmlStrcmp(cur2->name, (const xmlChar *)"family"))) {
1056 xmlNodeSetContent(cur2->xmlChildrenNode, (const xmlChar *)font_name);
1057 key = xmlNodeListGetString(doc, cur2->xmlChildrenNode, 1);
1061 } else if ((!xmlStrcmp(cur2->name, (const xmlChar *)"prefer"))) {
1062 cur3 = cur2->xmlChildrenNode;
1063 while (cur3 != NULL) {
1064 if ((!xmlStrcmp(cur3->name, (const xmlChar *)"family"))) {
1065 xmlNodeSetContent(cur3->xmlChildrenNode, (const xmlChar *)font_name);
1066 key = xmlNodeListGetString(doc, cur3->xmlChildrenNode, 1);
1090 /* LCOV_EXCL_STOP */
1092 /* LCOV_EXCL_START */
1093 int system_setting_set_font_type(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1095 SETTING_TRACE_BEGIN;
1096 char *font_name = NULL;
1097 font_name = (char *)value;
1099 /* get current font list */
1100 int is_found = dl_is_available_font(font_name);
1103 SETTING_TRACE("found font : %s ", font_name);
1105 SETTING_TRACE(" NOT found font : %s ", font_name);
1106 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1109 bool bsave = dl_font_config_set(font_name);
1112 SETTING_TRACE(" font type save error by font_config_set() ");
1113 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1115 SETTING_TRACE(" save OK - font_config_set() ");
1118 xmlDocPtr doc = (xmlDocPtr)font_conf_doc_parse(SETTING_FONT_CONF_FILE, font_name);
1120 xmlSaveFormatFile(SETTING_FONT_CONF_FILE, doc, 0);
1125 dl_font_config_set_notification();
1128 vconf_value = (char *)value;
1130 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, vconf_value)) {
1131 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1133 return SYSTEM_SETTINGS_ERROR_NONE;
1135 /* LCOV_EXCL_STOP */
1137 /* LCOV_EXCL_START */
1138 int system_setting_set_motion_activation(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1140 SETTING_TRACE_BEGIN;
1142 vconf_value = (bool *)value;
1143 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_MOTION_ACTIVATION, *vconf_value)) {
1144 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1146 return SYSTEM_SETTINGS_ERROR_NONE;
1148 /* LCOV_EXCL_STOP */
1150 /* LCOV_EXCL_START */
1151 int system_setting_set_usb_debugging_option(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1153 SETTING_TRACE_BEGIN;
1155 vconf_value = (bool *)value;
1156 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_USB_DEBUG_MODE_BOOL, *vconf_value)) {
1157 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1159 return SYSTEM_SETTINGS_ERROR_NONE;
1162 /* LCOV_EXCL_STOP */
1164 /* LCOV_EXCL_START */
1165 int system_setting_set_3g_data_network(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1167 SETTING_TRACE_BEGIN;
1169 vconf_value = (bool *)value;
1170 if (system_setting_vconf_set_value_bool(VCONFKEY_3G_ENABLE, *vconf_value)) {
1171 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1174 return SYSTEM_SETTINGS_ERROR_NONE;
1176 /* LCOV_EXCL_STOP */
1178 /* LCOV_EXCL_START */
1179 static int category_func(const char *name, void *user_data)
1181 SETTING_TRACE_BEGIN;
1182 static char *category = "lock-screen";
1183 if (name && !strcmp(name, category)) {
1184 SETTING_TRACE(" SAME ");
1187 SETTING_TRACE(" DIFFERENT -- %s, category -- %s ", name, category);
1193 /* LCOV_EXCL_STOP */
1197 * set 'swipe type' if current lockscreen app is 'com.samsung.lockscreen'
1201 /* LCOV_EXCL_START */
1202 int system_setting_set_lockscreen_app(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1204 SETTING_TRACE_BEGIN;
1206 vconf_value = (char *)value; /* ex) com.samsung.lockscreen */
1209 pkgmgrinfo_appinfo_h handle;
1210 r = pkgmgrinfo_appinfo_get_appinfo(vconf_value, &handle);
1211 if (r != PMINFO_R_OK) {
1212 SETTING_TRACE("*** pkginfo failed ");
1213 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
1215 SETTING_TRACE("%x", handle);
1218 int ret = pkgmgrinfo_appinfo_foreach_category(handle, category_func, (void *)"lock-screen");
1219 if (ret != PMINFO_R_OK) {
1220 pkgmgrinfo_appinfo_destroy_appinfo(handle);
1221 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
1224 pkgmgrinfo_appinfo_destroy_appinfo(handle);
1225 /*----------------------------------------------------------------------------------- */
1227 if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_SCREEN_LOCK_TYPE_INT, &locktype)) {
1228 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1231 if (locktype == SETTING_SCREEN_LOCK_TYPE_PASSWORD)
1232 return SYSTEM_SETTINGS_ERROR_LOCKSCREEN_APP_PASSWORD_MODE;
1234 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_3RD_LOCK_PKG_NAME_STR, vconf_value)) {
1235 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1238 if (vconf_value && strcmp(vconf_value, "com.samsung.lockscreen") == 0) {
1239 if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_SCREEN_LOCK_TYPE_INT, SETTING_SCREEN_LOCK_TYPE_SWIPE)) {
1240 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1243 return SYSTEM_SETTINGS_ERROR_NONE;
1245 /* LCOV_EXCL_STOP */
1247 /*/////////////////////////////////////////////////////////////////////////////////////////////// */
1250 int system_setting_set_changed_callback_incoming_call_ringtone(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1252 SETTING_TRACE_BEGIN;
1253 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR, SYSTEM_SETTINGS_KEY_INCOMING_CALL_RINGTONE, 0, user_data);
1256 int system_setting_unset_changed_callback_incoming_call_ringtone(system_settings_key_e key)
1258 SETTING_TRACE_BEGIN;
1259 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR, 0);
1262 int system_setting_set_changed_callback_email_alert_ringtone(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1264 SETTING_TRACE_BEGIN;
1265 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, SYSTEM_SETTINGS_KEY_EMAIL_ALERT_RINGTONE, 0, user_data);
1268 int system_setting_unset_changed_callback_email_alert_ringtone(system_settings_key_e key)
1270 SETTING_TRACE_BEGIN;
1271 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, 0);
1274 int system_setting_set_changed_callback_wallpaper_home_screen(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1276 SETTING_TRACE_BEGIN;
1277 return system_setting_vconf_set_changed_cb(VCONFKEY_BGSET, SYSTEM_SETTINGS_KEY_WALLPAPER_HOME_SCREEN, 0, user_data);
1280 int system_setting_unset_changed_callback_wallpaper_home_screen(system_settings_key_e key)
1282 SETTING_TRACE_BEGIN;
1283 return system_setting_vconf_unset_changed_cb(VCONFKEY_BGSET, 0);
1286 int system_setting_set_changed_callback_wallpaper_lock_screen(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1288 SETTING_TRACE_BEGIN;
1289 return system_setting_vconf_set_changed_cb(VCONFKEY_IDLE_LOCK_BGSET, SYSTEM_SETTINGS_KEY_WALLPAPER_LOCK_SCREEN, 0, user_data);
1292 int system_setting_unset_changed_callback_wallpaper_lock_screen(system_settings_key_e key)
1294 SETTING_TRACE_BEGIN;
1295 return system_setting_vconf_unset_changed_cb(VCONFKEY_IDLE_LOCK_BGSET, 0);
1298 int system_setting_set_changed_callback_font_size(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1300 SETTING_TRACE_BEGIN;
1301 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, SYSTEM_SETTINGS_KEY_FONT_SIZE, 1, user_data);
1304 int system_setting_unset_changed_callback_font_size(system_settings_key_e key)
1306 SETTING_TRACE_BEGIN;
1307 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, 1);
1310 int system_setting_set_changed_callback_usb_debugging_option(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1312 SETTING_TRACE_BEGIN;
1313 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_USB_DEBUG_MODE_BOOL, SYSTEM_SETTINGS_KEY_USB_DEBUGGING_ENABLED, 1, user_data);
1316 int system_setting_unset_changed_callback_usb_debugging_option(system_settings_key_e key)
1318 SETTING_TRACE_BEGIN;
1319 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_USB_DEBUG_MODE_BOOL, 1);
1322 int system_setting_set_changed_callback_3g_data_network(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1324 SETTING_TRACE_BEGIN;
1325 return system_setting_vconf_set_changed_cb(VCONFKEY_3G_ENABLE, SYSTEM_SETTINGS_KEY_3G_DATA_NETWORK_ENABLED, 1, user_data);
1328 int system_setting_unset_changed_callback_3g_data_network(system_settings_key_e key)
1330 SETTING_TRACE_BEGIN;
1331 return system_setting_vconf_unset_changed_cb(VCONFKEY_3G_ENABLE, 1);
1334 int system_setting_set_changed_callback_lockscreen_app(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1336 SETTING_TRACE_BEGIN;
1337 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_3RD_LOCK_PKG_NAME_STR, SYSTEM_SETTINGS_KEY_LOCKSCREEN_APP, 1, user_data);
1340 int system_setting_unset_changed_callback_lockscreen_app(system_settings_key_e key)
1342 SETTING_TRACE_BEGIN;
1343 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_3RD_LOCK_PKG_NAME_STR, 1);
1348 * @todo need to add custom event notification method
1350 int system_setting_set_changed_callback_font_type(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1352 SETTING_TRACE_BEGIN;
1353 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, SYSTEM_SETTINGS_KEY_FONT_TYPE, 2, user_data);
1356 int system_setting_unset_changed_callback_font_type(system_settings_key_e key)
1358 SETTING_TRACE_BEGIN;
1359 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, 2);
1362 /* TODO : 2th argument, callback, is not in use. */
1363 int system_setting_set_changed_callback_motion_activation(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1365 SETTING_TRACE_BEGIN;
1366 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_MOTION_ACTIVATION, SYSTEM_SETTINGS_KEY_MOTION_ACTIVATION, 3, user_data);
1369 int system_setting_unset_changed_callback_motion_activation(system_settings_key_e key)
1371 SETTING_TRACE_BEGIN;
1372 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_MOTION_ACTIVATION, 3);
1375 /*//////////////////////////////////////////////////////////////////////////////////////// */
1376 /*--------------------------------------- */
1377 int system_setting_get_locale_country(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1379 SETTING_TRACE_BEGIN;
1380 char *vconf_value = NULL;
1381 if (system_setting_vconf_get_value_string(VCONFKEY_REGIONFORMAT, &vconf_value)) {
1382 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1385 /* parsing validation */
1388 snprintf(arr, 20, "%s", vconf_value);
1390 *value = strdup(arr);
1394 return SYSTEM_SETTINGS_ERROR_NONE;
1397 /* LCOV_EXCL_START */
1398 int system_setting_set_locale_country(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1400 SETTING_TRACE_BEGIN;
1401 char *vconf_value = NULL;
1402 vconf_value = (char *)value;
1404 char *ext = "UTF-8";
1407 snprintf(arr, 20, "%s.%s", vconf_value, ext);
1409 if (system_setting_vconf_set_value_string(VCONFKEY_REGIONFORMAT, arr)) {
1410 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1412 return SYSTEM_SETTINGS_ERROR_NONE;
1414 /* LCOV_EXCL_STOP */
1416 int system_setting_set_changed_callback_locale_country(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1418 SETTING_TRACE_BEGIN;
1419 return system_setting_vconf_set_changed_cb(VCONFKEY_REGIONFORMAT, SYSTEM_SETTINGS_KEY_LOCALE_COUNTRY, 3, user_data);
1422 int system_setting_unset_changed_callback_locale_country(system_settings_key_e key)
1424 SETTING_TRACE_BEGIN;
1425 return system_setting_vconf_unset_changed_cb(VCONFKEY_REGIONFORMAT, 3);
1429 /*--------------------------------------- */
1430 int system_setting_get_locale_language(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1432 SETTING_TRACE_BEGIN;
1433 char *vconf_value = NULL;
1434 if (system_setting_vconf_get_value_string(VCONFKEY_LANGSET, &vconf_value)) {
1435 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1438 /* parsing validation */
1441 snprintf(arr, 20, "%s", vconf_value);
1443 *value = strdup(arr);
1446 return SYSTEM_SETTINGS_ERROR_NONE;
1449 /* LCOV_EXCL_START */
1450 int system_setting_set_locale_language(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1452 SETTING_TRACE_BEGIN;
1453 char *vconf_value = NULL;
1454 vconf_value = (char *)value;
1456 char *ext = "UTF-8";
1459 snprintf(arr, 20, "%s.%s", vconf_value, ext);
1461 if (system_setting_vconf_set_value_string(VCONFKEY_LANGSET, arr)) {
1462 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1464 return SYSTEM_SETTINGS_ERROR_NONE;
1466 /* LCOV_EXCL_STOP */
1468 int system_setting_set_changed_callback_locale_language(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1470 SETTING_TRACE_BEGIN;
1471 /*return system_setting_vconf_set_changed_cb(VCONFKEY_LANGSET, SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, 3, user_data ); */
1472 return system_setting_vconf_set_changed_cb(VCONFKEY_LANGSET, SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, 100, user_data);
1475 int system_setting_unset_changed_callback_locale_language(system_settings_key_e key)
1477 SETTING_TRACE_BEGIN;
1478 return system_setting_vconf_unset_changed_cb(VCONFKEY_LANGSET, 100);
1481 /*--------------------------------------- */
1482 /* LCOV_EXCL_START */
1483 int system_setting_get_locale_timeformat_24hour(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1485 SETTING_TRACE_BEGIN;
1488 if (system_setting_vconf_get_value_int(VCONFKEY_REGIONFORMAT_TIME1224, &vconf_value)) {
1489 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1492 bool ret_value = true;
1493 if (vconf_value == VCONFKEY_TIME_FORMAT_12)
1495 else if (vconf_value == VCONFKEY_TIME_FORMAT_24)
1498 *value = (void *)ret_value;
1500 return SYSTEM_SETTINGS_ERROR_NONE;
1502 /* LCOV_EXCL_STOP */
1504 int system_setting_set_locale_timeformat_24hour(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1506 SETTING_TRACE_BEGIN;
1509 vconf_value = (bool *)value;
1512 if (system_setting_vconf_set_value_int(VCONFKEY_REGIONFORMAT_TIME1224, VCONFKEY_TIME_FORMAT_24)) {
1513 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1517 if (system_setting_vconf_set_value_int(VCONFKEY_REGIONFORMAT_TIME1224, VCONFKEY_TIME_FORMAT_12)) {
1518 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1523 return SYSTEM_SETTINGS_ERROR_NONE;
1526 int system_setting_set_changed_callback_locale_timeformat_24hour(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1528 SETTING_TRACE_BEGIN;
1529 return system_setting_vconf_set_changed_cb(VCONFKEY_REGIONFORMAT_TIME1224, SYSTEM_SETTINGS_KEY_LOCALE_TIMEFORMAT_24HOUR, 3, user_data);
1532 int system_setting_unset_changed_callback_locale_timeformat_24hour(system_settings_key_e key)
1534 SETTING_TRACE_BEGIN;
1535 return system_setting_vconf_unset_changed_cb(VCONFKEY_REGIONFORMAT_TIME1224, 3);
1538 int system_setting_get_locale_timezone(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1541 ssize_t len = readlink(SETTING_TZONE_SYMLINK_PATH, tzpath, sizeof(tzpath)-1);
1545 SETTING_TRACE("parse error for SETTING_TZONE_SYMLINK_PATH");
1546 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1549 SETTING_TRACE("tzpath : %s ", &tzpath[20]);
1550 *value = strdup(&tzpath[20]);
1551 return SYSTEM_SETTINGS_ERROR_NONE;
1554 /* LCOV_EXCL_START */
1555 int system_setting_set_locale_timezone(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1557 SETTING_TRACE_BEGIN;
1558 char *timezone_value = NULL;
1559 timezone_value = (char *)value;
1562 snprintf(tz_path, 1024, "/usr/share/zoneinfo/%s", timezone_value);
1564 int is_load = _is_file_accessible(tz_path);
1566 alarmmgr_set_timezone(tz_path);
1568 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_TIMEZONE_ID, timezone_value)) {
1569 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1571 return SYSTEM_SETTINGS_ERROR_NONE;
1573 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
1575 /* LCOV_EXCL_STOP */
1579 /* LCOV_EXCL_START */
1580 int system_setting_set_changed_callback_locale_timezone(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1582 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_TIMEZONE_ID, SYSTEM_SETTINGS_KEY_LOCALE_TIMEZONE, 4, user_data);
1584 /* LCOV_EXCL_STOP */
1586 /* LCOV_EXCL_START */
1587 int system_setting_unset_changed_callback_locale_timezone(system_settings_key_e key)
1589 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_TIMEZONE_ID, 4);
1591 /* LCOV_EXCL_STOP */
1593 /* LCOV_EXCL_START */
1594 int system_setting_set_changed_callback_locale_timezone_changed(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1596 SETTING_TRACE_BEGIN;
1597 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
1599 /* LCOV_EXCL_STOP */
1601 /* LCOV_EXCL_START */
1602 int system_setting_unset_changed_callback_locale_timezone_changed(system_settings_key_e key)
1604 SETTING_TRACE_BEGIN;
1605 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
1607 /* LCOV_EXCL_STOP */
1610 /* LCOV_EXCL_START */
1611 int system_setting_get_time_changed(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1613 SETTING_TRACE_BEGIN;
1615 cur_tick = time(NULL);
1616 *value = (void *)cur_tick;
1617 /* struct tm * localtime = time (cur_tick); */
1618 /* printf("%s\n", ctime(&cur_tick); */
1619 return SYSTEM_SETTINGS_ERROR_NONE;
1622 /* LCOV_EXCL_STOP */
1624 int system_setting_set_changed_callback_time_changed(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1626 SETTING_TRACE_BEGIN;
1627 return system_setting_vconf_set_changed_cb(VCONFKEY_SYSTEM_TIME_CHANGED, SYSTEM_SETTINGS_KEY_TIME_CHANGED, 3, user_data);
1630 int system_setting_unset_changed_callback_time_changed(system_settings_key_e key)
1632 SETTING_TRACE_BEGIN;
1633 return system_setting_vconf_unset_changed_cb(VCONFKEY_SYSTEM_TIME_CHANGED, 3);
1638 /* SYSTEM_SETTINGS_KEY_SOUND_LOCK */
1639 int system_setting_get_sound_lock(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1641 SETTING_TRACE_BEGIN;
1644 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_SOUND_LOCK_BOOL, &vconf_value)) {
1645 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1647 *value = (void *)vconf_value;
1649 return SYSTEM_SETTINGS_ERROR_NONE;
1652 int system_setting_set_changed_callback_sound_lock(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1654 SETTING_TRACE_BEGIN;
1655 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_SOUND_LOCK_BOOL, SYSTEM_SETTINGS_KEY_SOUND_LOCK, 3, user_data);
1658 int system_setting_unset_changed_callback_sound_lock(system_settings_key_e key)
1660 SETTING_TRACE_BEGIN;
1661 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_SOUND_LOCK_BOOL, 3);
1665 * a = VCONFKEY_SETAPPL_SOUND_STATUS_BOOL b = VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL
1667 * a == false, b == false --> silent mode
1668 * a == true, b == false --> sound mode
1669 * a == false, b == true --> vibration mode
1671 /* LCOV_EXCL_START */
1672 int system_setting_get_sound_silent_mode(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1674 SETTING_TRACE_BEGIN;
1679 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, &sound_cond)) {
1680 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1683 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, &vib_cond)) {
1684 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1687 if (sound_cond == false && vib_cond == false) {
1689 *value = (void *)vconf_value;
1691 vconf_value = false;
1692 *value = (void *)vconf_value;
1694 return SYSTEM_SETTINGS_ERROR_NONE;
1696 /* LCOV_EXCL_STOP */
1699 * a = VCONFKEY_SETAPPL_SOUND_STATUS_BOOL b = VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL
1701 * a == false, b == false --> silent mode
1702 * a == true, b == false --> sound mode
1704 int system_setting_set_sound_silent_mode(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1706 SETTING_TRACE_BEGIN;
1709 vconf_value = (bool *)value;
1711 bool vconf_sound = false;
1712 bool vconf_vib = false;
1715 vconf_sound = false;
1722 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, vconf_sound)) {
1723 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1725 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, vconf_vib)) {
1726 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1729 return SYSTEM_SETTINGS_ERROR_NONE;
1735 int system_setting_set_changed_callback_sound_silent_mode(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1737 SETTING_TRACE_BEGIN;
1738 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, SYSTEM_SETTINGS_KEY_SOUND_SILENT_MODE, 3, user_data);
1742 int system_setting_unset_changed_callback_sound_silent_mode(system_settings_key_e key)
1744 SETTING_TRACE_BEGIN;
1745 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, 3);
1748 /* SYSTEM_SETTINGS_KEY_SOUND_TOUCH */
1749 int system_setting_get_sound_touch(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1751 SETTING_TRACE_BEGIN;
1754 int ret = system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL, &vconf_value);
1755 if (ret != SYSTEM_SETTINGS_ERROR_NONE) {
1758 *value = (void *)vconf_value;
1762 int system_setting_set_changed_callback_sound_touch(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1764 SETTING_TRACE_BEGIN;
1765 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL, SYSTEM_SETTINGS_KEY_SOUND_TOUCH, 2, user_data);
1768 int system_setting_unset_changed_callback_sound_touch(system_settings_key_e key)
1770 SETTING_TRACE_BEGIN;
1771 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL, 2);
1775 /* SYSTEM_SETTINGS_KEY_SOUND_LOCK */
1776 int system_setting_get_sound_lock(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1780 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_SOUND_LOCK_BOOL, &vconf_value)) {
1781 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1783 *value = (void *)vconf_value;
1785 return SYSTEM_SETTINGS_ERROR_NONE;
1789 int system_setting_get_auto_rotation_mode(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1791 SETTING_TRACE_BEGIN;
1794 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, &vconf_value)) {
1795 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1797 *value = (void *)vconf_value;
1799 return SYSTEM_SETTINGS_ERROR_NONE;
1802 /* LCOV_EXCL_START */
1803 int system_setting_set_auto_rotation_mode(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1805 SETTING_TRACE_BEGIN;
1807 vconf_value = (bool *)value;
1808 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, *vconf_value)) {
1809 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1812 return SYSTEM_SETTINGS_ERROR_NONE;
1814 /* LCOV_EXCL_STOP */
1816 int system_setting_set_changed_callback_auto_rotation_mode(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1818 SETTING_TRACE_BEGIN;
1819 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, SYSTEM_SETTINGS_KEY_DISPLAY_SCREEN_ROTATION_AUTO, 2, user_data);
1822 int system_setting_unset_changed_callback_auto_rotation_mode(system_settings_key_e key)
1824 SETTING_TRACE_BEGIN;
1825 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, 2);
1828 int system_setting_get_screen_backlight_time(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1830 SETTING_TRACE_BEGIN;
1833 if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, &vconf_value)) {
1834 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1836 *value = (void *)vconf_value;
1838 return SYSTEM_SETTINGS_ERROR_NONE;
1842 /* LCOV_EXCL_START */
1843 int system_setting_set_screen_backlight_time(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1845 SETTING_TRACE_BEGIN;
1847 vconf_value = (int *)value;
1849 if (!(*vconf_value > 0 && *vconf_value < 600)) {
1850 SETTING_TRACE(" ERR Betweeny here 0 ~ 600");
1851 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
1854 if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, *vconf_value)) {
1855 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1858 return SYSTEM_SETTINGS_ERROR_NONE;
1860 /* LCOV_EXCL_STOP */
1862 int system_setting_set_changed_callback_screen_backlight_time(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1864 SETTING_TRACE_BEGIN;
1865 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, SYSTEM_SETTINGS_KEY_DISPLAY_SCREEN_ROTATION_AUTO, 2, user_data);
1868 int system_setting_unset_changed_callback_screen_backlight_time(system_settings_key_e key)
1870 SETTING_TRACE_BEGIN;
1871 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, 2);
1874 int system_setting_get_sound_notification(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1876 SETTING_TRACE_BEGIN;
1877 char *vconf_value = NULL;
1878 if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, &vconf_value)) {
1879 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1882 *value = vconf_value;
1883 return SYSTEM_SETTINGS_ERROR_NONE;
1886 /* LCOV_EXCL_START */
1887 int system_setting_set_sound_notification(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1889 SETTING_TRACE_BEGIN;
1890 char *vconf_value = NULL;
1891 vconf_value = (char *)value;
1893 int is_load = _is_file_accessible(vconf_value);
1895 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, vconf_value)) {
1896 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1899 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1902 return SYSTEM_SETTINGS_ERROR_NONE;
1904 /* LCOV_EXCL_STOP */
1906 int system_setting_set_changed_callback_sound_notification(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1908 SETTING_TRACE_BEGIN;
1909 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, SYSTEM_SETTINGS_KEY_INCOMING_CALL_RINGTONE, 0, user_data);
1912 int system_setting_unset_changed_callback_sound_notification(system_settings_key_e key)
1914 SETTING_TRACE_BEGIN;
1915 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, 0);
1918 int system_setting_get_notification_repetition_period(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1920 SETTING_TRACE_BEGIN;
1923 if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_NOTI_MSG_ALERT_REP_TYPE_INT, &vconf_value)) {
1924 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1926 *value = (void *)vconf_value;
1928 return SYSTEM_SETTINGS_ERROR_NONE;
1931 /* LCOV_EXCL_START */
1932 int system_setting_set_notification_repetition_period(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1934 SETTING_TRACE_BEGIN;
1936 vconf_value = (int *)value;
1938 if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_NOTI_MSG_ALERT_REP_TYPE_INT, *vconf_value)) {
1939 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1942 return SYSTEM_SETTINGS_ERROR_NONE;
1944 /* LCOV_EXCL_STOP */
1946 int system_setting_set_changed_callback_notification_repetition_period(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1948 SETTING_TRACE_BEGIN;
1949 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);
1952 int system_setting_unset_changed_callback_notification_repetition_period(system_settings_key_e key)
1954 SETTING_TRACE_BEGIN;
1955 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_ALERT_REP_TYPE_INT, 1);
1958 int system_setting_get_device_name(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1960 SETTING_TRACE_BEGIN;
1961 char *vconf_value = NULL;
1962 if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_DEVICE_NAME_STR, &vconf_value)) {
1963 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1966 *value = vconf_value;
1967 return SYSTEM_SETTINGS_ERROR_NONE;
1970 /* LCOV_EXCL_START */
1971 int system_setting_set_device_name(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1973 SETTING_TRACE_BEGIN;
1974 char *vconf_value = NULL;
1975 vconf_value = (char *)value;
1977 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_DEVICE_NAME_STR, vconf_value)) {
1978 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1981 return SYSTEM_SETTINGS_ERROR_NONE;
1983 /* LCOV_EXCL_STOP */
1985 int system_setting_set_changed_callback_device_name(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1987 SETTING_TRACE_BEGIN;
1988 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_DEVICE_NAME_STR, SYSTEM_SETTINGS_KEY_DEVICE_NAME, 0, user_data);
1991 int system_setting_unset_changed_callback_device_name(system_settings_key_e key)
1993 SETTING_TRACE_BEGIN;
1994 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_DEVICE_NAME_STR, 0);
1997 /*---------------------------------------------- */
1998 int system_setting_get_network_flight_mode(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
2000 SETTING_TRACE_BEGIN;
2002 if (system_setting_vconf_get_value_bool(VCONFKEY_TELEPHONY_FLIGHT_MODE, &vconf_value)) {
2003 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2005 *value = (void *)vconf_value;
2007 return SYSTEM_SETTINGS_ERROR_NONE;
2010 int system_setting_set_changed_callback_network_flight_mode(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
2012 SETTING_TRACE_BEGIN;
2013 return system_setting_vconf_set_changed_cb(VCONFKEY_TELEPHONY_FLIGHT_MODE, SYSTEM_SETTINGS_KEY_NETWORK_FLIGHT_MODE, 3, user_data);
2016 int system_setting_unset_changed_callback_network_flight_mode(system_settings_key_e key)
2018 SETTING_TRACE_BEGIN;
2019 return system_setting_vconf_unset_changed_cb(VCONFKEY_TELEPHONY_FLIGHT_MODE, 3);
2022 int system_setting_get_network_wifi_notification(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
2024 SETTING_TRACE_BEGIN;
2026 if (system_setting_vconf_get_value_int(VCONFKEY_WIFI_ENABLE_QS, &vconf_value)) {
2027 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2030 bret = (vconf_value == VCONFKEY_WIFI_QS_ENABLE) ? true : false;
2032 *value = (void *)bret;
2033 return SYSTEM_SETTINGS_ERROR_NONE;
2036 int system_setting_set_changed_callback_network_wifi_notification(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
2038 SETTING_TRACE_BEGIN;
2039 return system_setting_vconf_set_changed_cb(VCONFKEY_WIFI_ENABLE_QS, SYSTEM_SETTINGS_KEY_NETWORK_WIFI_NOTIFICATION, 4, user_data);
2042 int system_setting_unset_changed_callback_network_wifi_notification(system_settings_key_e key)
2044 SETTING_TRACE_BEGIN;
2045 return system_setting_vconf_unset_changed_cb(VCONFKEY_WIFI_ENABLE_QS, 4);
2048 /* LCOV_EXCL_START */
2049 int system_setting_get_lock_state(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
2053 if (system_setting_vconf_get_value_int(VCONFKEY_IDLE_LOCK_STATE_READ_ONLY, &vconf_value)) {
2054 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2056 *value = (void *)vconf_value;
2058 return SYSTEM_SETTINGS_ERROR_NONE;
2060 /* LCOV_EXCL_STOP */
2062 /* LCOV_EXCL_START */
2063 int system_setting_set_lock_state(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
2065 SETTING_TRACE_BEGIN;
2067 vconf_value = (int *)value;
2069 if (system_setting_vconf_set_value_int(VCONFKEY_IDLE_LOCK_STATE_READ_ONLY, *vconf_value)) {
2070 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2073 return SYSTEM_SETTINGS_ERROR_NONE;
2075 /* LCOV_EXCL_STOP */
2077 /* LCOV_EXCL_START */
2078 int system_setting_set_changed_callback_lock_state(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
2080 return system_setting_vconf_set_changed_cb(VCONFKEY_IDLE_LOCK_STATE_READ_ONLY, SYSTEM_SETTINGS_KEY_LOCK_STATE, 4, user_data);
2082 /* LCOV_EXCL_STOP */
2084 /* LCOV_EXCL_START */
2085 int system_setting_unset_changed_callback_lock_state(system_settings_key_e key)
2087 return system_setting_vconf_unset_changed_cb(VCONFKEY_IDLE_LOCK_STATE_READ_ONLY, 4);
2089 /* LCOV_EXCL_STOP */
2091 //----------------------------------------------------------------------------------------------------------------------------
2093 #define DEFAULT_ADS_ID "00000000-0000-0000-0000-000000000000"
2095 int system_setting_get_ads_id(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
2097 SETTING_TRACE_BEGIN;
2098 int optout_value = 0;
2099 if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_AD_ID_OPT_OUT, &optout_value)) {
2100 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2103 if (optout_value == 1) {
2104 *value = strdup(DEFAULT_ADS_ID);
2105 return SYSTEM_SETTINGS_ERROR_NONE;
2108 char *vconf_value = NULL;
2109 if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_AD_ID, &vconf_value)) {
2110 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2113 *value = vconf_value;
2114 return SYSTEM_SETTINGS_ERROR_NONE;
2119 void make_ad_id(void)
2122 char uuid_unparsed[50] = {0};
2123 uuid_generate(uuid_value);
2124 uuid_unparse(uuid_value, uuid_unparsed);
2125 system_setting_set_ad_id(key, uuid_unparsed); //example of setting the value
2128 /* LCOV_EXCL_START */
2129 int system_setting_set_ads_id(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
2131 SETTING_TRACE_BEGIN;
2132 char *vconf_value = NULL;
2133 vconf_value = (char *)value;
2135 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_AD_ID, vconf_value)) {
2136 SETTING_TRACE("Setting VCONFKEY_SETAPPL_AD_ID failed");
2137 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2140 return SYSTEM_SETTINGS_ERROR_NONE;
2142 /* LCOV_EXCL_STOP */
2144 int system_setting_set_changed_callback_ads_id(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
2146 SETTING_TRACE_BEGIN;
2147 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_AD_ID, SYSTEM_SETTINGS_KEY_ADS_ID, 0, user_data);
2150 int system_setting_unset_changed_callback_ads_id(system_settings_key_e key)
2152 SETTING_TRACE_BEGIN;
2153 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_AD_ID, 0);