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>
48 #include <system-setting-config.h>
50 #include <tzplatform_config.h>
55 #define SETTING_FONT_CONF_FILE _TZ_SYS_ETC"/fonts/conf.avail/99-tizen.conf"
56 #define SETTING_DEFAULT_FONT_CONF_FILE _TZ_SYS_ETC"/fonts/conf.avail/99-tizen.conf"
58 #define SETTING_TIME_ZONEINFO_PATH "/usr/share/zoneinfo/"
59 #define SETTING_TIME_SHARE_LOCAL_PATH "/usr/share/locale"
60 #define SETTING_TZONE_SYMLINK_PATH "/opt/etc/localtime"
63 #define __FREE(del, arg) do { \
65 del((void *)(arg)); /*cast any argument to (void*) to avoid build warring*/\
69 #define FREE(arg) __FREE(free, arg)
71 #ifdef SETTING_ARCH_64
72 #define SETTING_UTILS_SO_FILE_PATH "/usr/lib64/libsystem-settings-util.so.0.1.0"
74 #define SETTING_UTILS_SO_FILE_PATH "/usr/lib/libsystem-settings-util.so.0.1.0"
77 int _is_file_accessible(const char *path);
79 static bool dl_is_supported_image_type_load(char *path);
80 static bool dl_font_config_set(char *font_name);
81 static char *dl_get_font_info(char *str);
82 static int dl_is_available_font(char *str);
83 static void dl_font_size_set();
84 static void dl_font_config_set_notification();
88 * VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR has a path of the ringtone file which user choose
89 * @return the ringtone file path specified by user in normal case
90 * if it's not accessable, return the default ringtone path
92 int system_setting_get_incoming_call_ringtone(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
96 if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR, &vconf_value)) {
97 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
100 /* check to see if it's accessable -> OK */
101 /* no --> default ringtone path VCONFKEY_SETAPPL_CALL_RINGTONE_DEFAULT_PATH_STR */
102 int is_load = _is_file_accessible(vconf_value);
104 *value = vconf_value;
105 } else { /* not zero on errro */
106 *value = vconf_get_str(VCONFKEY_SETAPPL_CALL_RINGTONE_DEFAULT_PATH_STR);
109 /**value = vconf_value; */
110 return SYSTEM_SETTINGS_ERROR_NONE;
114 int system_setting_get_email_alert_ringtone(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
118 if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, &vconf_value)) {
119 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
122 /* check to see if it's accessable -> OK */
123 /* no --> default ringtone path VCONFKEY_SETAPPL_NOTI_RINGTONE_DEFAULT_PATH_STR */
124 int is_load = _is_file_accessible(vconf_value);
126 *value = vconf_value;
127 } else { /* not zero on errro */
128 *value = vconf_get_str(VCONFKEY_SETAPPL_NOTI_RINGTONE_DEFAULT_PATH_STR);
131 return SYSTEM_SETTINGS_ERROR_NONE;
135 int system_setting_get_wallpaper_home_screen(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
139 if (system_setting_vconf_get_value_string(VCONFKEY_BGSET, &vconf_value)) {
140 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
142 *value = vconf_value;
143 return SYSTEM_SETTINGS_ERROR_NONE;
147 int system_setting_get_wallpaper_lock_screen(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
152 if (system_setting_vconf_get_value_string(VCONFKEY_IDLE_LOCK_BGSET, &vconf_value)) {
153 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
155 *value = vconf_value;
157 return SYSTEM_SETTINGS_ERROR_NONE;
161 /* [int] vconf GET */
162 int system_setting_get_font_size(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
166 int ** val = (int**)value;
168 if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, &vconf_value)) {
169 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
173 return SYSTEM_SETTINGS_ERROR_NONE;
177 int system_setting_get_default_font_type(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
180 char *font_name = dl_get_font_info("default");
182 *value = (void *)font_name;
183 return SYSTEM_SETTINGS_ERROR_NONE;
185 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
189 /* [int] vconf GET */
190 int system_setting_get_font_type(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
193 char *font_name = dl_get_font_info("cur");
194 *value = (void *)font_name;
196 return SYSTEM_SETTINGS_ERROR_NONE;
200 int system_setting_get_motion_activation(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
205 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_MOTION_ACTIVATION, &vconf_value)) {
206 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
208 *value = (void *)vconf_value;
210 return SYSTEM_SETTINGS_ERROR_NONE;
213 int system_setting_get_usb_debugging_option(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
218 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_USB_DEBUG_MODE_BOOL, &vconf_value)) {
219 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
221 *value = (void *)vconf_value;
223 return SYSTEM_SETTINGS_ERROR_NONE;
226 int system_setting_get_3g_data_network(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
231 if (system_setting_vconf_get_value_bool(VCONFKEY_3G_ENABLE, &vconf_value)) {
232 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
234 *value = (void *)vconf_value;
236 return SYSTEM_SETTINGS_ERROR_NONE;
238 /*////////////////////////////////////////////////////////////////////////////////////////////////// */
242 * get current lock scren app package name (string)
244 * @return SYSTEM_SETTINGS_ERROR_LOCKSCREEN_APP_PASSWORD_MODE raise exception if current lock type is 'password'
246 int system_setting_get_lockscreen_app(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
249 char *pkg_name = NULL;
251 system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_SCREEN_LOCK_TYPE_INT, &locktype);
253 if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_3RD_LOCK_PKG_NAME_STR, &pkg_name)) {
254 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
257 if (pkg_name && strcmp(pkg_name, "com.samsung.lockscreen") == 0 && locktype == SETTING_SCREEN_LOCK_TYPE_PASSWORD) {
258 return SYSTEM_SETTINGS_ERROR_LOCKSCREEN_APP_PASSWORD_MODE;
262 return SYSTEM_SETTINGS_ERROR_NONE;
266 /*////////////////////////////////////////////////////////////////////////////////////////////////// */
268 int _is_file_accessible(const char *path)
271 int ret = access(path , R_OK);
273 SETTING_TRACE("found the file %s", path);
276 /* error code : 13 */
277 SETTING_TRACE("found the file %s --- error code : %d ", path, errno);
284 /*////////////////////////////////////////////////////////////////////////////////////////////////// */
285 // @todo move to CMake
286 #define DEF_RINGTONE_FILE_PATH SETTING_DEF_RES"/Ringtones"
288 #define USR_RINGTONE_FILE_PATH "/home/owner/content/Sounds/Ringtones"
289 #define JSONFILE "/opt/home/owner/apps_rw/org.tizen.setting/data/.user-ringtones.json"
292 static char* _get_json_file_path()
299 int system_setting_add_incoming_call_ringtone(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
302 char* pathval = (char*)value;
306 JsonParser *parser = ss_json_ringtone_open_file(JSONFILE);
308 JsonParser *parser = ss_json_ringtone_load_from_data();
311 JsonNode *root = json_parser_get_root(parser);
315 int ret = SYSTEM_SETTINGS_ERROR_NONE;
316 if (false == ss_json_ringtone_contain(root, pathval)) {
317 SETTING_TRACE("---> dirname is : %s ", dirname(strdup(pathval)));
318 SETTING_TRACE("---> basename is : %s ", basename(strdup(pathval)));
319 // @todo : MAKE SURE THE ACTUAL FILE IS THERE ON PATHVAL(SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER)
320 ss_json_ringtone_add(root, JSONFILE, pathval, pathval);
321 SETTING_TRACE("pathval is : %s -- OK", pathval);
323 SETTING_TRACE("pathval is duplicated : %s", pathval);
324 SETTING_TRACE("---> dirname is : %s ", dirname(strdup(pathval)));
325 SETTING_TRACE("---> basename is : %s ", basename(strdup(pathval)));
326 ret = SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
330 g_object_unref(parser);
337 int system_setting_del_incoming_call_ringtone(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
340 char* pathval = (char*)value;
343 JsonParser* parser = ss_json_ringtone_open_file(JSONFILE);
345 JsonParser* parser = ss_json_ringtone_load_from_data();
347 JsonNode *root = json_parser_get_root(parser);
349 ss_json_ringtone_remove(root, JSONFILE, pathval);
350 //void ss_json_ringtone_remove(JsonNode *root, char* filename, char* path_to_del)
352 ss_json_ringtone_print(root);
354 g_object_unref(parser);
358 return SYSTEM_SETTINGS_ERROR_NONE;
362 static int _compare_cb(const void *d1, const void *d2)
364 fileNodeInfo *pNode1 = (fileNodeInfo *)d1;
365 fileNodeInfo *pNode2 = (fileNodeInfo *)d2;
367 return strcmp(pNode1->media_name, pNode2->media_name);
371 * get the RINGTONE list
373 static void _get_default_ringtones(system_settings_key_e key, system_setting_data_type_e data_type, system_settings_iter_cb callback, void *data)
377 Eina_List *filelist = NULL;
379 fileNodeInfo *node = NULL;
382 //-----------------------------------------------------------------------------------------------------------------
383 // 1. get the default ringtone list
384 //-----------------------------------------------------------------------------------------------------------------
385 int ret = get_filelist_from_dir_path(DEF_RINGTONE_FILE_PATH, &filelist);
387 SETTING_TRACE("Failed to get filelist, ret = %d %s", ret, DEF_RINGTONE_FILE_PATH);
389 filelist = eina_list_sort(filelist, eina_list_count(filelist), _compare_cb);
391 EINA_LIST_FOREACH(filelist, l, node)
393 SETTING_TRACE("file path = (%d) : name:%s path:%s [%s]", ret, node->name, node->path, node->media_name);
394 // @todo assert NULL check
397 snprintf(temp, 1024, "%s/%s", node->path, node->name);
398 char* path = strdup(temp);
399 bool ret = callback(idx, (void *)(path), data);
405 SETTING_TRACE("quit the iteration by return value == false : %d", ret);
410 SETTING_TRACE("--> system_setting_data_iterator is NULL");
416 EINA_LIST_FOREACH(filelist, l, node)
420 FREE(node->media_name);
423 eina_list_free(filelist);
428 static void _get_user_ringtones(system_settings_key_e key, system_setting_data_type_e data_type, system_settings_iter_cb callback, void *data)
434 JsonParser* parser = ss_json_ringtone_open_file(JSONFILE);
436 JsonParser* parser = ss_json_ringtone_load_from_data();
439 JsonNode *root = json_parser_get_root(parser);
440 int size = json_array_get_length(json_node_get_array(root));
443 for (i = 0; i < size ; i++) {
444 JsonObject *ringtone = json_array_get_object_element(json_node_get_array(root), i);
445 char *nameval = (char *)json_object_get_string_member(ringtone, "name");
446 char *pathval = (char *)json_object_get_string_member(ringtone, "path");
447 SETTING_TRACE("(%s) --- (%s) \n", nameval, pathval);
449 char* path = strdup(pathval);
450 bool ret = callback(i, (void *)(path), data);
452 SETTING_TRACE("quit the iteration by return value == false : %d", ret);
456 SETTING_TRACE("--> callback is NULL");
461 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)
465 _get_default_ringtones(key, data_type, callback, data);
466 //-----------------------------------------------------------------------------------------------------------------
467 // 2. get the USER ringtone list
468 //-----------------------------------------------------------------------------------------------------------------
469 _get_user_ringtones(key, data_type, callback, data);
471 return SYSTEM_SETTINGS_ERROR_NONE;
475 /* LCOV_EXCL_START */
476 int system_setting_set_incoming_call_ringtone(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
480 vconf_value = (char *)value;
482 int ret = _is_file_accessible(vconf_value);
484 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR, vconf_value)) {
485 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
488 /* @todo add a common ret_handler */
492 return SYSTEM_SETTINGS_ERROR_NONE;
497 /* LCOV_EXCL_START */
498 int system_setting_set_email_alert_ringtone(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
502 vconf_value = (char *)value;
504 int ret = _is_file_accessible(vconf_value);
506 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, vconf_value)) {
507 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
510 /*return SYSTEM_SETTINGS_ERROR_IO_ERROR;*/
511 /* @todo add a common ret_handler */
515 return SYSTEM_SETTINGS_ERROR_NONE;
519 /* LCOV_EXCL_START */
520 static bool dl_is_supported_image_type_load(char *path)
525 bool (*image_type_check)(char *path);
527 handle = dlopen(SETTING_UTILS_SO_FILE_PATH, RTLD_LAZY);
529 SETTING_TRACE("ERROR!! canNOT find libsystem-settings-util.so.0.1.0");
533 image_type_check = dlsym(handle, "__is_supported_image_type_load");
534 if ((error = dlerror()) != NULL) {
535 SETTING_TRACE("ERROR!! canNOT find __is_supported_image_type_load function at libsystem-settings-util.so.0.1.0");
540 ret = image_type_check(path);
547 /* LCOV_EXCL_START */
548 static int dl_is_available_font(char *str)
553 int (*check_available_font)(char *font_name);
555 handle = dlopen(SETTING_UTILS_SO_FILE_PATH, RTLD_LAZY);
557 SETTING_TRACE("ERROR!! canNOT find libsystem-settings-util.so.0.1.0");
561 check_available_font = dlsym(handle, "__is_available_font");
562 if ((error = dlerror()) != NULL) {
563 SETTING_TRACE("ERROR!! canNOT find __is_available_font function at libsystem-settings-util.so.0.1.0");
568 ret = check_available_font(str);
575 /* LCOV_EXCL_START */
576 static void dl_font_size_set()
580 void (*set_font_size)();
582 handle = dlopen(SETTING_UTILS_SO_FILE_PATH, RTLD_LAZY);
584 SETTING_TRACE("ERROR!! canNOT find libsystem-settings-util.so.0.1.0");
588 set_font_size = dlsym(handle, "__font_size_set");
589 if ((error = dlerror()) != NULL) {
590 SETTING_TRACE("ERROR!! canNOT find __font_size_set function at libsystem-settings-util.so.0.1.0");
602 /* LCOV_EXCL_START */
603 static void dl_font_config_set_notification()
607 void (*set_font_nodification)();
609 handle = dlopen(SETTING_UTILS_SO_FILE_PATH, RTLD_LAZY);
611 SETTING_TRACE("ERROR!! canNOT find libsystem-settings-util.so.0.1.0");
615 set_font_nodification = dlsym(handle, "font_config_set_notification");
616 if ((error = dlerror()) != NULL) {
617 SETTING_TRACE("ERROR!! canNOT find font_config_set_notification function at libsystem-settings-util.so.0.1.0");
622 set_font_nodification();
629 /* LCOV_EXCL_START */
630 static bool dl_font_config_set(char *font_name)
635 bool (*check_font_type)(char *font_name);
637 handle = dlopen(SETTING_UTILS_SO_FILE_PATH, RTLD_LAZY);
639 SETTING_TRACE("ERROR!! canNOT find libsystem-settings-util.so.0.1.0");
643 check_font_type = dlsym(handle, "font_config_set");
644 if ((error = dlerror()) != NULL) {
645 SETTING_TRACE("ERROR!! canNOT find font_config_set function at libsystem-settings-util.so.0.1.0");
650 ret = check_font_type(font_name);
657 /* LCOV_EXCL_START */
658 static char *dl_get_font_info(char *str)
663 char *(*get_font_info)();
665 handle = dlopen(SETTING_UTILS_SO_FILE_PATH, RTLD_LAZY);
667 SETTING_TRACE("ERROR!! canNOT find libsystem-settings-util.so.0.1.0");
671 if (strcmp(str, "cur") == 0)
672 get_font_info = dlsym(handle, "_get_cur_font");
674 get_font_info = dlsym(handle, "_get_default_font");
676 if ((error = dlerror()) != NULL) {
677 SETTING_TRACE("ERROR!! canNOT find %s function at libsystem-settings-util.so.0.1.0", str);
682 ret = get_font_info();
689 /* LCOV_EXCL_START */
690 #define PATH_EXT_CHECK_REG ".(jpe?g|jpg|png|gif)$"
691 bool __is_supported_image_type_by_ext(char *file_path)
695 regmatch_t str[2048 + 1];
697 if (!file_path) return false;
700 if ((ret = regcomp(&fsm, PATH_EXT_CHECK_REG, REG_ICASE | REG_EXTENDED))) {
701 SETTING_TRACE("regular expresstion fail");
706 if (regexec(&fsm, file_path, strlen(file_path) + 1, str, 0) == REG_NOMATCH) {
707 /*SETTING_TRACE("FAILED - %s", file_path[i]); */
710 /*SETTING_TRACE("MATCHED - %s", file_path[i]); */
716 #ifdef TIZEN_WEARABLE
717 /* LCOV_EXCL_START */
718 static int system_setting_get_extended_wallpaper_num(const char *file_path, unsigned int *num)
722 const char *find_str = "extended_wallpaper_";
725 if (!(ch = strstr(file_path, find_str))) {
726 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
728 strncpy(buffer, file_path, ch - file_path);
729 buffer[ch - file_path] = 0;
730 sprintf(buffer + (ch - file_path), "%s%s", "", ch + strlen(find_str));
732 if (!isdigit(buffer[0])) {
733 SETTING_TRACE("%s is not number", buffer);
734 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
739 return SYSTEM_SETTINGS_ERROR_NONE;
743 /* LCOV_EXCL_START */
744 static int system_setting_copy_extended_wallpaper(const char *dest_file_path, const char *source_file_path)
747 if (!source_file_path || !dest_file_path) {
748 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
754 fd = open(source_file_path, O_RDONLY);
756 SETTING_TRACE("file open failed: %s", source_file_path);
757 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
761 fd2 = open(dest_file_path, O_WRONLY | O_CREAT, S_IRWXU | S_IRWXG | S_IRWXO);
763 SETTING_TRACE("file creation failed: %s", dest_file_path);
765 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
768 while (read(fd, buf, sizeof(buf) - 1) > 0) {
769 write(fd2, buf, sizeof(buf) - 1);
775 if (chmod(dest_file_path, S_IRWXU | S_IRWXG | S_IRWXO) < 0) {
776 SETTING_TRACE("chmod failed: %s", dest_file_path);
779 return SYSTEM_SETTINGS_ERROR_NONE;
783 /* LCOV_EXCL_START */
784 static int system_setting_remove_oldest_extended_wallpaper()
789 char *min_image_name = NULL;
790 unsigned int min_image_num = 0;
791 unsigned int temp_image_num = 0;
794 if ((dp = opendir(_TZ_SYS_DATA"/setting/wallpaper")) == NULL) {
795 SETTING_TRACE("opendir error");
796 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
799 while ((dirp = readdir(dp))) {
800 if (!strcmp(dirp->d_name, ".") || !strcmp(dirp->d_name, ".."))
803 if (system_setting_get_extended_wallpaper_num(dirp->d_name, &temp_image_num)
804 != SYSTEM_SETTINGS_ERROR_NONE) {
805 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
808 if ((image_count == 0) || (min_image_num > temp_image_num)) {
809 min_image_num = temp_image_num;
810 min_image_name = dirp->d_name;
817 if (min_image_name) {
818 snprintf(buf, sizeof(buf) - 1, _TZ_SYS_DATA"/setting/wallpaper/%s", min_image_name);
819 if (remove(buf) < 0) { /* remove oldest image */
820 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
824 return SYSTEM_SETTINGS_ERROR_NONE;
828 /* LCOV_EXCL_START */
829 static int system_setting_check_extended_wallpaper(const char *file_path)
833 if (!file_path || !strlen(file_path))
835 snprintf(buffer, 512, "%s/.bgwallpaper", tzplatform_getenv(TZ_USER_CONTENT));
836 return (strstr(file_path, buffer) != NULL);
840 #define WALLPAPER_MAX_COUNT 10
842 /* LCOV_EXCL_START */
843 int system_setting_set_wallpaper_home_screen(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
847 vconf_value = (char *)value;
849 bool isok = dl_is_supported_image_type_load(vconf_value);
852 SETTING_TRACE("path : %s is not supported file format", vconf_value);
853 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
855 SETTING_TRACE("path : %s is SUPPORT file format", vconf_value);
858 /* error handling here */
859 if (_is_file_accessible(vconf_value) != 0)
860 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
862 if (system_setting_vconf_set_value_string(VCONFKEY_BGSET, vconf_value)) {
863 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
867 #ifdef TIZEN_WEARABLE
868 if (system_setting_check_extended_wallpaper(vconf_value)) { /* New extended wallpaper */
871 unsigned int max_image_num = 0;
872 unsigned int temp_image_num = 0;
875 if ((dp = opendir(_TZ_SYS_DATA"/setting/wallpaper")) == NULL) {
876 SETTING_TRACE("Setting - dir open error!");
877 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
880 /* Check a max number of wallpapers */
881 while ((dirp = readdir(dp))) {
882 if (!strcmp(dirp->d_name, ".") || !strcmp(dirp->d_name, ".."))
885 if (system_setting_get_extended_wallpaper_num(dirp->d_name, &temp_image_num)
886 != SYSTEM_SETTINGS_ERROR_NONE) {
889 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
892 if ((image_count == 0) || (max_image_num < temp_image_num)) {
893 max_image_num = temp_image_num;
901 /* Numbering rule: Gear is odd number */
902 max_image_num = (max_image_num % 2 == 0) ? max_image_num + 1
905 char file_name_buffer[512];
906 snprintf(file_name_buffer, sizeof(file_name_buffer) - 1,
907 _TZ_SYS_DATA"/setting/wallpaper/extended_wallpaper_%d.jpg", max_image_num);
909 /* Copy image to _TZ_SYS_DATA/setting/wallpaper/ */
910 if (system_setting_copy_extended_wallpaper(file_name_buffer, vconf_value)
911 != SYSTEM_SETTINGS_ERROR_NONE) {
912 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
915 /* remove oldest wallpaper */
916 if (image_count >= WALLPAPER_MAX_COUNT) {
917 if (system_setting_remove_oldest_extended_wallpaper()
918 != SYSTEM_SETTINGS_ERROR_NONE) {
919 remove(file_name_buffer);
920 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
924 if (system_setting_vconf_set_value_string(VCONFKEY_BGSET, file_name_buffer)) {
925 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
928 if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_WALLPAPER_CHANGED_NOTI_INT,
929 VCONFKEY_WALLPAPER_CHANGED_NOTI_GEAR)) {
930 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
933 if (system_setting_vconf_set_value_string(VCONFKEY_BGSET, vconf_value)) {
934 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
939 return SYSTEM_SETTINGS_ERROR_NONE;
943 /* LCOV_EXCL_START */
944 int system_setting_set_wallpaper_lock_screen(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
948 vconf_value = (char *)value;
950 bool isok = dl_is_supported_image_type_load(vconf_value);
953 SETTING_TRACE("path : %s is not supported file format", vconf_value);
954 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
956 SETTING_TRACE("path : %s is SUPPORT file format", vconf_value);
959 /* error handling here */
960 if (_is_file_accessible(vconf_value) != 0)
961 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
963 if (system_setting_vconf_set_value_string(VCONFKEY_IDLE_LOCK_BGSET, vconf_value)) {
964 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
967 return SYSTEM_SETTINGS_ERROR_NONE;
971 /* LCOV_EXCL_START */
972 int system_setting_set_font_size(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
976 vconf_value = *(int **)value;
978 if (*vconf_value < 0 || *vconf_value > SYSTEM_SETTINGS_FONT_SIZE_GIANT) {
979 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
982 if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, *vconf_value)) {
983 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
987 return SYSTEM_SETTINGS_ERROR_NONE;
993 /* LCOV_EXCL_START */
994 void *font_conf_doc_parse(char *doc_name, char *font_name)
997 xmlDocPtr doc = NULL;
998 xmlNodePtr cur = NULL;
999 xmlNodePtr cur2 = NULL;
1000 xmlNodePtr cur3 = NULL;
1001 xmlChar *key = NULL;
1003 doc = xmlParseFile(doc_name);
1005 cur = xmlDocGetRootElement(doc);
1013 if (xmlStrcmp(cur->name, (const xmlChar *)"fontconfig")) {
1019 cur = cur->xmlChildrenNode;
1021 bool is_changed = false;
1022 while (cur != NULL) {
1023 if ((!xmlStrcmp(cur->name, (const xmlChar *)"match"))) {
1024 cur2 = cur->xmlChildrenNode;
1025 while (cur2 != NULL) {
1026 if ((!xmlStrcmp(cur2->name, (const xmlChar *)"edit"))) {
1027 xmlChar *name = xmlGetProp(cur2, (const xmlChar *)"name");
1028 /* if name is not 'family', break */
1029 if (xmlStrcmp(name, (const xmlChar *)"family")) {
1037 cur3 = cur2->xmlChildrenNode;
1038 while (cur3 != NULL) {
1039 if ((!xmlStrcmp(cur3->name, (const xmlChar *)"string"))) {
1040 xmlNodeSetContent(cur3->xmlChildrenNode, (const xmlChar *)font_name);
1041 key = xmlNodeListGetString(doc, cur3->xmlChildrenNode, 1);
1051 } else if ((!xmlStrcmp(cur->name, (const xmlChar *)"alias"))) {
1052 cur2 = cur->xmlChildrenNode;
1053 while (cur2 != NULL) {
1054 if ((!xmlStrcmp(cur2->name, (const xmlChar *)"family"))) {
1055 xmlNodeSetContent(cur2->xmlChildrenNode, (const xmlChar *)font_name);
1056 key = xmlNodeListGetString(doc, cur2->xmlChildrenNode, 1);
1060 } else if ((!xmlStrcmp(cur2->name, (const xmlChar *)"prefer"))) {
1061 cur3 = cur2->xmlChildrenNode;
1062 while (cur3 != NULL) {
1063 if ((!xmlStrcmp(cur3->name, (const xmlChar *)"family"))) {
1064 xmlNodeSetContent(cur3->xmlChildrenNode, (const xmlChar *)font_name);
1065 key = xmlNodeListGetString(doc, cur3->xmlChildrenNode, 1);
1089 /* LCOV_EXCL_STOP */
1091 /* LCOV_EXCL_START */
1092 int system_setting_set_font_type(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1094 SETTING_TRACE_BEGIN;
1095 char *font_name = NULL;
1096 font_name = (char *)value;
1098 /* get current font list */
1099 int is_found = dl_is_available_font(font_name);
1102 SETTING_TRACE("found font : %s ", font_name);
1104 SETTING_TRACE(" NOT found font : %s ", font_name);
1105 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1108 bool bsave = dl_font_config_set(font_name);
1111 SETTING_TRACE(" font type save error by font_config_set() ");
1112 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1114 SETTING_TRACE(" save OK - font_config_set() ");
1117 xmlDocPtr doc = (xmlDocPtr)font_conf_doc_parse(SETTING_FONT_CONF_FILE, font_name);
1119 xmlSaveFormatFile(SETTING_FONT_CONF_FILE, doc, 0);
1124 dl_font_config_set_notification();
1127 vconf_value = (char *)value;
1129 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, vconf_value)) {
1130 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1132 return SYSTEM_SETTINGS_ERROR_NONE;
1134 /* LCOV_EXCL_STOP */
1136 /* LCOV_EXCL_START */
1137 int system_setting_set_motion_activation(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1139 SETTING_TRACE_BEGIN;
1141 vconf_value = (bool *)value;
1142 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_MOTION_ACTIVATION, *vconf_value)) {
1143 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1145 return SYSTEM_SETTINGS_ERROR_NONE;
1147 /* LCOV_EXCL_STOP */
1149 /* LCOV_EXCL_START */
1150 int system_setting_set_usb_debugging_option(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1152 SETTING_TRACE_BEGIN;
1154 vconf_value = (bool *)value;
1155 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_USB_DEBUG_MODE_BOOL, *vconf_value)) {
1156 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1158 return SYSTEM_SETTINGS_ERROR_NONE;
1161 /* LCOV_EXCL_STOP */
1163 /* LCOV_EXCL_START */
1164 int system_setting_set_3g_data_network(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1166 SETTING_TRACE_BEGIN;
1168 vconf_value = (bool *)value;
1169 if (system_setting_vconf_set_value_bool(VCONFKEY_3G_ENABLE, *vconf_value)) {
1170 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1173 return SYSTEM_SETTINGS_ERROR_NONE;
1175 /* LCOV_EXCL_STOP */
1177 /* LCOV_EXCL_START */
1178 static int category_func(const char *name, void *user_data)
1180 SETTING_TRACE_BEGIN;
1181 static char *category = "lock-screen";
1182 if (name && !strcmp(name, category)) {
1183 SETTING_TRACE(" SAME ");
1186 SETTING_TRACE(" DIFFERENT -- %s, category -- %s ", name, category);
1192 /* LCOV_EXCL_STOP */
1196 * set 'swipe type' if current lockscreen app is 'com.samsung.lockscreen'
1200 /* LCOV_EXCL_START */
1201 int system_setting_set_lockscreen_app(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1203 SETTING_TRACE_BEGIN;
1205 vconf_value = (char *)value; /* ex) com.samsung.lockscreen */
1208 pkgmgrinfo_appinfo_h handle;
1209 r = pkgmgrinfo_appinfo_get_appinfo(vconf_value, &handle);
1210 if (r != PMINFO_R_OK) {
1211 SETTING_TRACE("*** pkginfo failed ");
1212 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
1214 SETTING_TRACE("%x", handle);
1217 int ret = pkgmgrinfo_appinfo_foreach_category(handle, category_func, (void *)"lock-screen");
1218 if (ret != PMINFO_R_OK) {
1219 pkgmgrinfo_appinfo_destroy_appinfo(handle);
1220 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
1223 pkgmgrinfo_appinfo_destroy_appinfo(handle);
1224 /*----------------------------------------------------------------------------------- */
1226 if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_SCREEN_LOCK_TYPE_INT, &locktype)) {
1227 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1230 if (locktype == SETTING_SCREEN_LOCK_TYPE_PASSWORD)
1231 return SYSTEM_SETTINGS_ERROR_LOCKSCREEN_APP_PASSWORD_MODE;
1233 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_3RD_LOCK_PKG_NAME_STR, vconf_value)) {
1234 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1237 if (vconf_value && strcmp(vconf_value, "com.samsung.lockscreen") == 0) {
1238 if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_SCREEN_LOCK_TYPE_INT, SETTING_SCREEN_LOCK_TYPE_SWIPE)) {
1239 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1242 return SYSTEM_SETTINGS_ERROR_NONE;
1244 /* LCOV_EXCL_STOP */
1246 /*/////////////////////////////////////////////////////////////////////////////////////////////// */
1249 int system_setting_set_changed_callback_incoming_call_ringtone(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1251 SETTING_TRACE_BEGIN;
1252 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR, SYSTEM_SETTINGS_KEY_INCOMING_CALL_RINGTONE, 0, user_data);
1255 int system_setting_unset_changed_callback_incoming_call_ringtone(system_settings_key_e key)
1257 SETTING_TRACE_BEGIN;
1258 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR, 0);
1261 int system_setting_set_changed_callback_email_alert_ringtone(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1263 SETTING_TRACE_BEGIN;
1264 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, SYSTEM_SETTINGS_KEY_EMAIL_ALERT_RINGTONE, 0, user_data);
1267 int system_setting_unset_changed_callback_email_alert_ringtone(system_settings_key_e key)
1269 SETTING_TRACE_BEGIN;
1270 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, 0);
1273 int system_setting_set_changed_callback_wallpaper_home_screen(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1275 SETTING_TRACE_BEGIN;
1276 return system_setting_vconf_set_changed_cb(VCONFKEY_BGSET, SYSTEM_SETTINGS_KEY_WALLPAPER_HOME_SCREEN, 0, user_data);
1279 int system_setting_unset_changed_callback_wallpaper_home_screen(system_settings_key_e key)
1281 SETTING_TRACE_BEGIN;
1282 return system_setting_vconf_unset_changed_cb(VCONFKEY_BGSET, 0);
1285 int system_setting_set_changed_callback_wallpaper_lock_screen(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1287 SETTING_TRACE_BEGIN;
1288 return system_setting_vconf_set_changed_cb(VCONFKEY_IDLE_LOCK_BGSET, SYSTEM_SETTINGS_KEY_WALLPAPER_LOCK_SCREEN, 0, user_data);
1291 int system_setting_unset_changed_callback_wallpaper_lock_screen(system_settings_key_e key)
1293 SETTING_TRACE_BEGIN;
1294 return system_setting_vconf_unset_changed_cb(VCONFKEY_IDLE_LOCK_BGSET, 0);
1297 int system_setting_set_changed_callback_font_size(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1299 SETTING_TRACE_BEGIN;
1300 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, SYSTEM_SETTINGS_KEY_FONT_SIZE, 1, user_data);
1303 int system_setting_unset_changed_callback_font_size(system_settings_key_e key)
1305 SETTING_TRACE_BEGIN;
1306 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, 1);
1309 int system_setting_set_changed_callback_usb_debugging_option(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1311 SETTING_TRACE_BEGIN;
1312 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_USB_DEBUG_MODE_BOOL, SYSTEM_SETTINGS_KEY_USB_DEBUGGING_ENABLED, 1, user_data);
1315 int system_setting_unset_changed_callback_usb_debugging_option(system_settings_key_e key)
1317 SETTING_TRACE_BEGIN;
1318 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_USB_DEBUG_MODE_BOOL, 1);
1321 int system_setting_set_changed_callback_3g_data_network(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1323 SETTING_TRACE_BEGIN;
1324 return system_setting_vconf_set_changed_cb(VCONFKEY_3G_ENABLE, SYSTEM_SETTINGS_KEY_3G_DATA_NETWORK_ENABLED, 1, user_data);
1327 int system_setting_unset_changed_callback_3g_data_network(system_settings_key_e key)
1329 SETTING_TRACE_BEGIN;
1330 return system_setting_vconf_unset_changed_cb(VCONFKEY_3G_ENABLE, 1);
1333 int system_setting_set_changed_callback_lockscreen_app(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1335 SETTING_TRACE_BEGIN;
1336 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_3RD_LOCK_PKG_NAME_STR, SYSTEM_SETTINGS_KEY_LOCKSCREEN_APP, 1, user_data);
1339 int system_setting_unset_changed_callback_lockscreen_app(system_settings_key_e key)
1341 SETTING_TRACE_BEGIN;
1342 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_3RD_LOCK_PKG_NAME_STR, 1);
1347 * @todo need to add custom event notification method
1349 int system_setting_set_changed_callback_font_type(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1351 SETTING_TRACE_BEGIN;
1352 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, SYSTEM_SETTINGS_KEY_FONT_TYPE, 2, user_data);
1355 int system_setting_unset_changed_callback_font_type(system_settings_key_e key)
1357 SETTING_TRACE_BEGIN;
1358 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, 2);
1361 /* TODO : 2th argument, callback, is not in use. */
1362 int system_setting_set_changed_callback_motion_activation(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1364 SETTING_TRACE_BEGIN;
1365 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_MOTION_ACTIVATION, SYSTEM_SETTINGS_KEY_MOTION_ACTIVATION, 3, user_data);
1368 int system_setting_unset_changed_callback_motion_activation(system_settings_key_e key)
1370 SETTING_TRACE_BEGIN;
1371 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_MOTION_ACTIVATION, 3);
1374 /*//////////////////////////////////////////////////////////////////////////////////////// */
1375 /*--------------------------------------- */
1376 int system_setting_get_locale_country(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1378 SETTING_TRACE_BEGIN;
1379 char *vconf_value = NULL;
1380 if (system_setting_vconf_get_value_string(VCONFKEY_REGIONFORMAT, &vconf_value)) {
1381 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1384 /* parsing validation */
1387 snprintf(arr, 20, "%s", vconf_value);
1389 *value = strdup(arr);
1393 return SYSTEM_SETTINGS_ERROR_NONE;
1396 /* LCOV_EXCL_START */
1397 int system_setting_set_locale_country(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1399 SETTING_TRACE_BEGIN;
1400 char *vconf_value = NULL;
1401 vconf_value = (char *)value;
1403 char *ext = "UTF-8";
1406 snprintf(arr, 20, "%s.%s", vconf_value, ext);
1408 if (system_setting_vconf_set_value_string(VCONFKEY_REGIONFORMAT, arr)) {
1409 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1411 return SYSTEM_SETTINGS_ERROR_NONE;
1413 /* LCOV_EXCL_STOP */
1415 int system_setting_set_changed_callback_locale_country(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1417 SETTING_TRACE_BEGIN;
1418 return system_setting_vconf_set_changed_cb(VCONFKEY_REGIONFORMAT, SYSTEM_SETTINGS_KEY_LOCALE_COUNTRY, 3, user_data);
1421 int system_setting_unset_changed_callback_locale_country(system_settings_key_e key)
1423 SETTING_TRACE_BEGIN;
1424 return system_setting_vconf_unset_changed_cb(VCONFKEY_REGIONFORMAT, 3);
1428 /*--------------------------------------- */
1429 int system_setting_get_locale_language(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1431 SETTING_TRACE_BEGIN;
1432 char *vconf_value = NULL;
1433 if (system_setting_vconf_get_value_string(VCONFKEY_LANGSET, &vconf_value)) {
1434 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1437 /* parsing validation */
1440 snprintf(arr, 20, "%s", vconf_value);
1442 *value = strdup(arr);
1445 return SYSTEM_SETTINGS_ERROR_NONE;
1448 /* LCOV_EXCL_START */
1449 int system_setting_set_locale_language(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1451 SETTING_TRACE_BEGIN;
1452 char *vconf_value = NULL;
1453 vconf_value = (char *)value;
1455 char *ext = "UTF-8";
1458 snprintf(arr, 20, "%s.%s", vconf_value, ext);
1460 if (system_setting_vconf_set_value_string(VCONFKEY_LANGSET, arr)) {
1461 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1463 return SYSTEM_SETTINGS_ERROR_NONE;
1465 /* LCOV_EXCL_STOP */
1467 int system_setting_set_changed_callback_locale_language(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1469 SETTING_TRACE_BEGIN;
1470 /*return system_setting_vconf_set_changed_cb(VCONFKEY_LANGSET, SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, 3, user_data ); */
1471 return system_setting_vconf_set_changed_cb(VCONFKEY_LANGSET, SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, 100, user_data);
1474 int system_setting_unset_changed_callback_locale_language(system_settings_key_e key)
1476 SETTING_TRACE_BEGIN;
1477 return system_setting_vconf_unset_changed_cb(VCONFKEY_LANGSET, 100);
1480 /*--------------------------------------- */
1481 /* LCOV_EXCL_START */
1482 int system_setting_get_locale_timeformat_24hour(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1484 SETTING_TRACE_BEGIN;
1487 if (system_setting_vconf_get_value_int(VCONFKEY_REGIONFORMAT_TIME1224, &vconf_value)) {
1488 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1491 bool ret_value = true;
1492 if (vconf_value == VCONFKEY_TIME_FORMAT_12)
1494 else if (vconf_value == VCONFKEY_TIME_FORMAT_24)
1497 *value = (void *)ret_value;
1499 return SYSTEM_SETTINGS_ERROR_NONE;
1501 /* LCOV_EXCL_STOP */
1503 int system_setting_set_locale_timeformat_24hour(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1505 SETTING_TRACE_BEGIN;
1508 vconf_value = (bool *)value;
1511 if (system_setting_vconf_set_value_int(VCONFKEY_REGIONFORMAT_TIME1224, VCONFKEY_TIME_FORMAT_24)) {
1512 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1516 if (system_setting_vconf_set_value_int(VCONFKEY_REGIONFORMAT_TIME1224, VCONFKEY_TIME_FORMAT_12)) {
1517 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1522 return SYSTEM_SETTINGS_ERROR_NONE;
1525 int system_setting_set_changed_callback_locale_timeformat_24hour(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1527 SETTING_TRACE_BEGIN;
1528 return system_setting_vconf_set_changed_cb(VCONFKEY_REGIONFORMAT_TIME1224, SYSTEM_SETTINGS_KEY_LOCALE_TIMEFORMAT_24HOUR, 3, user_data);
1531 int system_setting_unset_changed_callback_locale_timeformat_24hour(system_settings_key_e key)
1533 SETTING_TRACE_BEGIN;
1534 return system_setting_vconf_unset_changed_cb(VCONFKEY_REGIONFORMAT_TIME1224, 3);
1537 int system_setting_get_locale_timezone(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1540 ssize_t len = readlink(SETTING_TZONE_SYMLINK_PATH, tzpath, sizeof(tzpath)-1);
1544 SETTING_TRACE("parse error for SETTING_TZONE_SYMLINK_PATH");
1545 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1548 SETTING_TRACE("tzpath : %s ", &tzpath[20]);
1549 *value = strdup(&tzpath[20]);
1550 return SYSTEM_SETTINGS_ERROR_NONE;
1553 /* LCOV_EXCL_START */
1554 int system_setting_set_locale_timezone(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1556 SETTING_TRACE_BEGIN;
1557 char *timezone_value = NULL;
1558 timezone_value = (char *)value;
1561 snprintf(tz_path, 1024, "/usr/share/zoneinfo/%s", timezone_value);
1563 int is_load = _is_file_accessible(tz_path);
1565 alarmmgr_set_timezone(tz_path);
1567 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_TIMEZONE_ID, timezone_value)) {
1568 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1570 return SYSTEM_SETTINGS_ERROR_NONE;
1572 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
1574 /* LCOV_EXCL_STOP */
1578 /* LCOV_EXCL_START */
1579 int system_setting_set_changed_callback_locale_timezone(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1581 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_TIMEZONE_ID, SYSTEM_SETTINGS_KEY_LOCALE_TIMEZONE, 4, user_data);
1583 /* LCOV_EXCL_STOP */
1585 /* LCOV_EXCL_START */
1586 int system_setting_unset_changed_callback_locale_timezone(system_settings_key_e key)
1588 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_TIMEZONE_ID, 4);
1590 /* LCOV_EXCL_STOP */
1592 /* LCOV_EXCL_START */
1593 int system_setting_set_changed_callback_locale_timezone_changed(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1595 SETTING_TRACE_BEGIN;
1596 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
1598 /* LCOV_EXCL_STOP */
1600 /* LCOV_EXCL_START */
1601 int system_setting_unset_changed_callback_locale_timezone_changed(system_settings_key_e key)
1603 SETTING_TRACE_BEGIN;
1604 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
1606 /* LCOV_EXCL_STOP */
1609 /* LCOV_EXCL_START */
1610 int system_setting_get_time_changed(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1612 SETTING_TRACE_BEGIN;
1614 int ** val = (int**)value;
1615 cur_tick = time(NULL);
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;
1832 int ** val = (int**)value;
1834 if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, &vconf_value)) {
1835 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1837 **val = vconf_value;
1839 return SYSTEM_SETTINGS_ERROR_NONE;
1843 /* LCOV_EXCL_START */
1844 int system_setting_set_screen_backlight_time(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1846 SETTING_TRACE_BEGIN;
1848 vconf_value = *(int **)value;
1850 if (!(*vconf_value > 0 && *vconf_value <= 600)) {
1851 SETTING_TRACE(" ERR Betweeny here 0 ~ 600");
1852 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
1855 if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, *vconf_value)) {
1856 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1859 return SYSTEM_SETTINGS_ERROR_NONE;
1861 /* LCOV_EXCL_STOP */
1863 int system_setting_set_changed_callback_screen_backlight_time(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1865 SETTING_TRACE_BEGIN;
1866 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, SYSTEM_SETTINGS_KEY_SCREEN_BACKLIGHT_TIME, 2, user_data);
1869 int system_setting_unset_changed_callback_screen_backlight_time(system_settings_key_e key)
1871 SETTING_TRACE_BEGIN;
1872 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, 2);
1875 int system_setting_get_sound_notification(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1877 SETTING_TRACE_BEGIN;
1878 char *vconf_value = NULL;
1879 if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, &vconf_value)) {
1880 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1883 *value = vconf_value;
1884 return SYSTEM_SETTINGS_ERROR_NONE;
1887 /* LCOV_EXCL_START */
1888 int system_setting_set_sound_notification(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1890 SETTING_TRACE_BEGIN;
1891 char *vconf_value = NULL;
1892 vconf_value = (char *)value;
1894 int is_load = _is_file_accessible(vconf_value);
1896 //SETTING_TRACE(" system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, %s) TRY", vconf_value);
1897 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, vconf_value)) {
1898 //SETTING_TRACE(" system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, %s) FAIL", vconf_value);
1899 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1902 //SETTING_TRACE(" is_file_accessibile FAILED - system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, %s) FAIL", vconf_value);
1903 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1906 return SYSTEM_SETTINGS_ERROR_NONE;
1908 /* LCOV_EXCL_STOP */
1910 int system_setting_set_changed_callback_sound_notification(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1912 SETTING_TRACE_BEGIN;
1913 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, SYSTEM_SETTINGS_KEY_SOUND_NOTIFICATION, 0, user_data);
1916 int system_setting_unset_changed_callback_sound_notification(system_settings_key_e key)
1918 SETTING_TRACE_BEGIN;
1919 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, 0);
1922 int system_setting_get_notification_repetition_period(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1924 SETTING_TRACE_BEGIN;
1925 int ** val = (int**)value;
1928 if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_NOTI_MSG_ALERT_REP_TYPE_INT, &vconf_value)) {
1929 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1931 **val = vconf_value;
1933 return SYSTEM_SETTINGS_ERROR_NONE;
1936 /* LCOV_EXCL_START */
1937 int system_setting_set_notification_repetition_period(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1939 SETTING_TRACE_BEGIN;
1941 vconf_value = *(int **)value;
1943 if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_NOTI_MSG_ALERT_REP_TYPE_INT, *vconf_value)) {
1944 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1947 return SYSTEM_SETTINGS_ERROR_NONE;
1949 /* LCOV_EXCL_STOP */
1951 int system_setting_set_changed_callback_notification_repetition_period(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1953 SETTING_TRACE_BEGIN;
1954 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);
1957 int system_setting_unset_changed_callback_notification_repetition_period(system_settings_key_e key)
1959 SETTING_TRACE_BEGIN;
1960 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_ALERT_REP_TYPE_INT, 1);
1963 int system_setting_get_device_name(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1965 SETTING_TRACE_BEGIN;
1966 char *vconf_value = NULL;
1967 if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_DEVICE_NAME_STR, &vconf_value)) {
1968 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1971 *value = vconf_value;
1972 return SYSTEM_SETTINGS_ERROR_NONE;
1975 /* LCOV_EXCL_START */
1976 int system_setting_set_device_name(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1978 SETTING_TRACE_BEGIN;
1979 char *vconf_value = NULL;
1980 vconf_value = (char *)value;
1982 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_DEVICE_NAME_STR, vconf_value)) {
1983 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1986 return SYSTEM_SETTINGS_ERROR_NONE;
1988 /* LCOV_EXCL_STOP */
1990 int system_setting_set_changed_callback_device_name(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1992 SETTING_TRACE_BEGIN;
1993 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_DEVICE_NAME_STR, SYSTEM_SETTINGS_KEY_DEVICE_NAME, 0, user_data);
1996 int system_setting_unset_changed_callback_device_name(system_settings_key_e key)
1998 SETTING_TRACE_BEGIN;
1999 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_DEVICE_NAME_STR, 0);
2002 /*---------------------------------------------- */
2003 int system_setting_get_network_flight_mode(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
2005 SETTING_TRACE_BEGIN;
2007 if (system_setting_vconf_get_value_bool(VCONFKEY_TELEPHONY_FLIGHT_MODE, &vconf_value)) {
2008 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2010 *value = (void *)vconf_value;
2012 return SYSTEM_SETTINGS_ERROR_NONE;
2015 int system_setting_set_changed_callback_network_flight_mode(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
2017 SETTING_TRACE_BEGIN;
2018 return system_setting_vconf_set_changed_cb(VCONFKEY_TELEPHONY_FLIGHT_MODE, SYSTEM_SETTINGS_KEY_NETWORK_FLIGHT_MODE, 3, user_data);
2021 int system_setting_unset_changed_callback_network_flight_mode(system_settings_key_e key)
2023 SETTING_TRACE_BEGIN;
2024 return system_setting_vconf_unset_changed_cb(VCONFKEY_TELEPHONY_FLIGHT_MODE, 3);
2027 int system_setting_get_network_wifi_notification(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
2029 SETTING_TRACE_BEGIN;
2031 if (system_setting_vconf_get_value_int(VCONFKEY_WIFI_ENABLE_QS, &vconf_value)) {
2032 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2035 bret = (vconf_value == VCONFKEY_WIFI_QS_ENABLE) ? true : false;
2037 *value = (void *)bret;
2038 return SYSTEM_SETTINGS_ERROR_NONE;
2041 int system_setting_set_changed_callback_network_wifi_notification(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
2043 SETTING_TRACE_BEGIN;
2044 return system_setting_vconf_set_changed_cb(VCONFKEY_WIFI_ENABLE_QS, SYSTEM_SETTINGS_KEY_NETWORK_WIFI_NOTIFICATION, 4, user_data);
2047 int system_setting_unset_changed_callback_network_wifi_notification(system_settings_key_e key)
2049 SETTING_TRACE_BEGIN;
2050 return system_setting_vconf_unset_changed_cb(VCONFKEY_WIFI_ENABLE_QS, 4);
2053 /* LCOV_EXCL_START */
2054 int system_setting_get_lock_state(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
2057 int ** val = (int**)value;
2059 if (system_setting_vconf_get_value_int(VCONFKEY_IDLE_LOCK_STATE_READ_ONLY, &vconf_value)) {
2060 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2062 **val = vconf_value;
2064 return SYSTEM_SETTINGS_ERROR_NONE;
2066 /* LCOV_EXCL_STOP */
2068 /* LCOV_EXCL_START */
2069 int system_setting_set_lock_state(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
2071 SETTING_TRACE_BEGIN;
2073 vconf_value = *(int **)value;
2075 if (system_setting_vconf_set_value_int(VCONFKEY_IDLE_LOCK_STATE_READ_ONLY, *vconf_value)) {
2076 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2079 return SYSTEM_SETTINGS_ERROR_NONE;
2081 /* LCOV_EXCL_STOP */
2083 /* LCOV_EXCL_START */
2084 int system_setting_set_changed_callback_lock_state(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
2086 return system_setting_vconf_set_changed_cb(VCONFKEY_IDLE_LOCK_STATE_READ_ONLY, SYSTEM_SETTINGS_KEY_LOCK_STATE, 4, user_data);
2088 /* LCOV_EXCL_STOP */
2090 /* LCOV_EXCL_START */
2091 int system_setting_unset_changed_callback_lock_state(system_settings_key_e key)
2093 return system_setting_vconf_unset_changed_cb(VCONFKEY_IDLE_LOCK_STATE_READ_ONLY, 4);
2095 /* LCOV_EXCL_STOP */
2097 //----------------------------------------------------------------------------------------------------------------------------
2099 #define DEFAULT_ADS_ID "00000000-0000-0000-0000-000000000000"
2101 int system_setting_get_ads_id(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
2103 SETTING_TRACE_BEGIN;
2104 int optout_value = 0;
2105 if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_AD_ID_OPT_OUT, &optout_value)) {
2106 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2109 if (optout_value == 1) {
2110 *value = strdup(DEFAULT_ADS_ID);
2111 return SYSTEM_SETTINGS_ERROR_NONE;
2114 char *vconf_value = NULL;
2115 if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_AD_ID, &vconf_value)) {
2116 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2119 *value = vconf_value;
2120 return SYSTEM_SETTINGS_ERROR_NONE;
2125 void make_ad_id(void)
2128 char uuid_unparsed[50] = {0};
2129 uuid_generate(uuid_value);
2130 uuid_unparse(uuid_value, uuid_unparsed);
2131 system_setting_set_ad_id(key, uuid_unparsed); //example of setting the value
2134 /* LCOV_EXCL_START */
2135 int system_setting_set_ads_id(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
2137 SETTING_TRACE_BEGIN;
2138 char *vconf_value = NULL;
2139 vconf_value = (char *)value;
2141 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_AD_ID, vconf_value)) {
2142 SETTING_TRACE("Setting VCONFKEY_SETAPPL_AD_ID failed");
2143 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2146 return SYSTEM_SETTINGS_ERROR_NONE;
2148 /* LCOV_EXCL_STOP */
2150 int system_setting_set_changed_callback_ads_id(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
2152 SETTING_TRACE_BEGIN;
2153 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_AD_ID, SYSTEM_SETTINGS_KEY_ADS_ID, 0, user_data);
2156 int system_setting_unset_changed_callback_ads_id(system_settings_key_e key)
2158 SETTING_TRACE_BEGIN;
2159 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_AD_ID, 0);