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)
75 int _is_file_accessible(const char *path);
77 static bool dl_is_supported_image_type_load(char *path);
78 static bool dl_font_config_set(char *font_name);
79 static char *dl_get_font_info(char *str);
80 static int dl_is_available_font(char *str);
81 static void dl_font_size_set();
82 static void dl_font_config_set_notification();
86 * VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR has a path of the ringtone file which user choose
87 * @return the ringtone file path specified by user in normal case
88 * if it's not accessable, return the default ringtone path
90 int system_setting_get_incoming_call_ringtone(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
94 if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR, &vconf_value)) {
95 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
98 /* check to see if it's accessable -> OK */
99 /* no --> default ringtone path VCONFKEY_SETAPPL_CALL_RINGTONE_DEFAULT_PATH_STR */
100 int is_load = _is_file_accessible(vconf_value);
102 *value = vconf_value;
103 } else { /* not zero on errro */
104 *value = vconf_get_str(VCONFKEY_SETAPPL_CALL_RINGTONE_DEFAULT_PATH_STR);
107 /**value = vconf_value; */
108 return SYSTEM_SETTINGS_ERROR_NONE;
112 int system_setting_get_email_alert_ringtone(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
116 if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, &vconf_value)) {
117 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
120 /* check to see if it's accessable -> OK */
121 /* no --> default ringtone path VCONFKEY_SETAPPL_NOTI_RINGTONE_DEFAULT_PATH_STR */
122 int is_load = _is_file_accessible(vconf_value);
124 *value = vconf_value;
125 } else { /* not zero on errro */
126 *value = vconf_get_str(VCONFKEY_SETAPPL_NOTI_RINGTONE_DEFAULT_PATH_STR);
129 return SYSTEM_SETTINGS_ERROR_NONE;
133 int system_setting_get_wallpaper_home_screen(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
137 if (system_setting_vconf_get_value_string(VCONFKEY_BGSET, &vconf_value)) {
138 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
140 *value = vconf_value;
141 return SYSTEM_SETTINGS_ERROR_NONE;
145 int system_setting_get_wallpaper_lock_screen(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
150 if (system_setting_vconf_get_value_string(VCONFKEY_IDLE_LOCK_BGSET, &vconf_value)) {
151 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
153 *value = vconf_value;
155 return SYSTEM_SETTINGS_ERROR_NONE;
159 /* [int] vconf GET */
160 int system_setting_get_font_size(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
165 if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, &vconf_value)) {
166 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
168 *value = (void *)vconf_value;
170 return SYSTEM_SETTINGS_ERROR_NONE;
174 int system_setting_get_default_font_type(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
177 char *font_name = dl_get_font_info("default");
179 *value = (void *)font_name;
180 return SYSTEM_SETTINGS_ERROR_NONE;
182 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
186 /* [int] vconf GET */
187 int system_setting_get_font_type(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
190 char *font_name = dl_get_font_info("cur");
191 *value = (void *)font_name;
193 return SYSTEM_SETTINGS_ERROR_NONE;
197 int system_setting_get_motion_activation(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
202 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_MOTION_ACTIVATION, &vconf_value)) {
203 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
205 *value = (void *)vconf_value;
207 return SYSTEM_SETTINGS_ERROR_NONE;
210 int system_setting_get_usb_debugging_option(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
215 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_USB_DEBUG_MODE_BOOL, &vconf_value)) {
216 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
218 *value = (void *)vconf_value;
220 return SYSTEM_SETTINGS_ERROR_NONE;
223 int system_setting_get_3g_data_network(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
228 if (system_setting_vconf_get_value_bool(VCONFKEY_3G_ENABLE, &vconf_value)) {
229 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
231 *value = (void *)vconf_value;
233 return SYSTEM_SETTINGS_ERROR_NONE;
235 /*////////////////////////////////////////////////////////////////////////////////////////////////// */
239 * get current lock scren app package name (string)
241 * @return SYSTEM_SETTINGS_ERROR_LOCKSCREEN_APP_PASSWORD_MODE raise exception if current lock type is 'password'
243 int system_setting_get_lockscreen_app(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
246 char *pkg_name = NULL;
248 system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_SCREEN_LOCK_TYPE_INT, &locktype);
250 if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_3RD_LOCK_PKG_NAME_STR, &pkg_name)) {
251 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
254 if (pkg_name && strcmp(pkg_name, "com.samsung.lockscreen") == 0 && locktype == SETTING_SCREEN_LOCK_TYPE_PASSWORD) {
255 return SYSTEM_SETTINGS_ERROR_LOCKSCREEN_APP_PASSWORD_MODE;
259 return SYSTEM_SETTINGS_ERROR_NONE;
263 /*////////////////////////////////////////////////////////////////////////////////////////////////// */
265 int _is_file_accessible(const char *path)
268 int ret = access(path , R_OK);
270 SETTING_TRACE("found the file %s", path);
273 /* error code : 13 */
274 SETTING_TRACE("found the file %s --- error code : %d ", path, errno);
281 /*////////////////////////////////////////////////////////////////////////////////////////////////// */
282 // @todo move to CMake
283 #define DEF_RINGTONE_FILE_PATH "/opt/share/settings/Ringtones"
284 #define USR_RINGTONE_FILE_PATH "/home/owner/content/Sounds/Ringtones"
285 #define JSONFILE "/opt/home/owner/apps_rw/org.tizen.setting/data/.user-ringtones.json"
288 static char* _get_json_file_path()
295 int system_setting_add_incoming_call_ringtone(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
298 char* pathval = (char*)value;
302 JsonParser *parser = ss_json_ringtone_open_file(JSONFILE);
304 JsonParser *parser = ss_json_ringtone_load_from_data();
307 JsonNode *root = json_parser_get_root(parser);
311 int ret = SYSTEM_SETTINGS_ERROR_NONE;
312 if (false == ss_json_ringtone_contain(root, pathval)) {
313 SETTING_TRACE("---> dirname is : %s ", dirname(strdup(pathval)));
314 SETTING_TRACE("---> basename is : %s ", basename(strdup(pathval)));
315 // @todo : MAKE SURE THE ACTUAL FILE IS THERE ON PATHVAL(SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER)
316 ss_json_ringtone_add(root, JSONFILE, pathval, pathval);
317 SETTING_TRACE("pathval is : %s -- OK", pathval);
319 SETTING_TRACE("pathval is duplicated : %s", pathval);
320 SETTING_TRACE("---> dirname is : %s ", dirname(strdup(pathval)));
321 SETTING_TRACE("---> basename is : %s ", basename(strdup(pathval)));
322 ret = SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
326 g_object_unref(parser);
333 int system_setting_del_incoming_call_ringtone(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
336 char* pathval = (char*)value;
339 JsonParser* parser = ss_json_ringtone_open_file(JSONFILE);
341 JsonParser* parser = ss_json_ringtone_load_from_data();
343 JsonNode *root = json_parser_get_root(parser);
345 ss_json_ringtone_remove(root, JSONFILE, pathval);
346 //void ss_json_ringtone_remove(JsonNode *root, char* filename, char* path_to_del)
348 ss_json_ringtone_print(root);
350 g_object_unref(parser);
354 return SYSTEM_SETTINGS_ERROR_NONE;
358 static int _compare_cb(const void *d1, const void *d2)
360 fileNodeInfo *pNode1 = (fileNodeInfo *)d1;
361 fileNodeInfo *pNode2 = (fileNodeInfo *)d2;
363 return strcmp(pNode1->media_name, pNode2->media_name);
367 * get the RINGTONE list
369 static void _get_default_ringtones(system_settings_key_e key, system_setting_data_type_e data_type, system_settings_iter_cb callback, void *data)
373 Eina_List *filelist = NULL;
375 fileNodeInfo *node = NULL;
378 //-----------------------------------------------------------------------------------------------------------------
379 // 1. get the default ringtone list
380 //-----------------------------------------------------------------------------------------------------------------
381 int ret = get_filelist_from_dir_path(DEF_RINGTONE_FILE_PATH, &filelist);
383 SETTING_TRACE("Failed to get filelist, ret = %d %s", ret, DEF_RINGTONE_FILE_PATH);
385 filelist = eina_list_sort(filelist, eina_list_count(filelist), _compare_cb);
387 EINA_LIST_FOREACH(filelist, l, node)
389 SETTING_TRACE("file path = (%d) : name:%s path:%s [%s]", ret, node->name, node->path, node->media_name);
390 // @todo assert NULL check
393 snprintf(temp, 1024, "%s/%s", node->path, node->name);
394 char* path = strdup(temp);
395 bool ret = callback(idx, (void *)(path), data);
401 SETTING_TRACE("quit the iteration by return value == false : %d", ret);
406 SETTING_TRACE("--> system_setting_data_iterator is NULL");
412 EINA_LIST_FOREACH(filelist, l, node)
416 FREE(node->media_name);
419 eina_list_free(filelist);
424 static void _get_user_ringtones(system_settings_key_e key, system_setting_data_type_e data_type, system_settings_iter_cb callback, void *data)
430 JsonParser* parser = ss_json_ringtone_open_file(JSONFILE);
432 JsonParser* parser = ss_json_ringtone_load_from_data();
435 JsonNode *root = json_parser_get_root(parser);
436 int size = json_array_get_length(json_node_get_array(root));
439 for (i = 0; i < size ; i++) {
440 JsonObject *ringtone = json_array_get_object_element(json_node_get_array(root), i);
441 char *nameval = (char *)json_object_get_string_member(ringtone, "name");
442 char *pathval = (char *)json_object_get_string_member(ringtone, "path");
443 SETTING_TRACE("(%s) --- (%s) \n", nameval, pathval);
445 char* path = strdup(pathval);
446 bool ret = callback(i, (void *)(path), data);
448 SETTING_TRACE("quit the iteration by return value == false : %d", ret);
452 SETTING_TRACE("--> callback is NULL");
457 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)
461 _get_default_ringtones(key, data_type, callback, data);
462 //-----------------------------------------------------------------------------------------------------------------
463 // 2. get the USER ringtone list
464 //-----------------------------------------------------------------------------------------------------------------
465 _get_user_ringtones(key, data_type, callback, data);
467 return SYSTEM_SETTINGS_ERROR_NONE;
471 /* LCOV_EXCL_START */
472 int system_setting_set_incoming_call_ringtone(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
476 vconf_value = (char *)value;
478 int ret = _is_file_accessible(vconf_value);
480 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR, vconf_value)) {
481 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
484 /* @todo add a common ret_handler */
488 return SYSTEM_SETTINGS_ERROR_NONE;
493 /* LCOV_EXCL_START */
494 int system_setting_set_email_alert_ringtone(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
498 vconf_value = (char *)value;
500 int ret = _is_file_accessible(vconf_value);
502 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, vconf_value)) {
503 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
506 /*return SYSTEM_SETTINGS_ERROR_IO_ERROR;*/
507 /* @todo add a common ret_handler */
511 return SYSTEM_SETTINGS_ERROR_NONE;
515 /* LCOV_EXCL_START */
516 static bool dl_is_supported_image_type_load(char *path)
521 bool (*image_type_check)(char *path);
523 handle = dlopen("/usr/lib/libsystem-settings-util.so.0.1.0", RTLD_LAZY);
525 SETTING_TRACE("ERROR!! canNOT find libsystem-settings-util.so.0.1.0");
529 image_type_check = dlsym(handle, "__is_supported_image_type_load");
530 if ((error = dlerror()) != NULL) {
531 SETTING_TRACE("ERROR!! canNOT find __is_supported_image_type_load function at libsystem-settings-util.so.0.1.0");
536 ret = image_type_check(path);
543 /* LCOV_EXCL_START */
544 static int dl_is_available_font(char *str)
549 int (*check_available_font)(char *font_name);
551 handle = dlopen("/usr/lib/libsystem-settings-util.so.0.1.0", RTLD_LAZY);
553 SETTING_TRACE("ERROR!! canNOT find libsystem-settings-util.so.0.1.0");
557 check_available_font = dlsym(handle, "__is_available_font");
558 if ((error = dlerror()) != NULL) {
559 SETTING_TRACE("ERROR!! canNOT find __is_available_font function at libsystem-settings-util.so.0.1.0");
564 ret = check_available_font(str);
571 /* LCOV_EXCL_START */
572 static void dl_font_size_set()
576 void (*set_font_size)();
578 handle = dlopen("/usr/lib/libsystem-settings-util.so.0.1.0", RTLD_LAZY);
580 SETTING_TRACE("ERROR!! canNOT find libsystem-settings-util.so.0.1.0");
584 set_font_size = dlsym(handle, "__font_size_set");
585 if ((error = dlerror()) != NULL) {
586 SETTING_TRACE("ERROR!! canNOT find __font_size_set function at libsystem-settings-util.so.0.1.0");
598 /* LCOV_EXCL_START */
599 static void dl_font_config_set_notification()
603 void (*set_font_nodification)();
605 handle = dlopen("/usr/lib/libsystem-settings-util.so.0.1.0", RTLD_LAZY);
607 SETTING_TRACE("ERROR!! canNOT find libsystem-settings-util.so.0.1.0");
611 set_font_nodification = dlsym(handle, "font_config_set_notification");
612 if ((error = dlerror()) != NULL) {
613 SETTING_TRACE("ERROR!! canNOT find font_config_set_notification function at libsystem-settings-util.so.0.1.0");
618 set_font_nodification();
625 /* LCOV_EXCL_START */
626 static bool dl_font_config_set(char *font_name)
631 bool (*check_font_type)(char *font_name);
633 handle = dlopen("/usr/lib/libsystem-settings-util.so.0.1.0", RTLD_LAZY);
635 SETTING_TRACE("ERROR!! canNOT find libsystem-settings-util.so.0.1.0");
639 check_font_type = dlsym(handle, "font_config_set");
640 if ((error = dlerror()) != NULL) {
641 SETTING_TRACE("ERROR!! canNOT find font_config_set function at libsystem-settings-util.so.0.1.0");
646 ret = check_font_type(font_name);
653 /* LCOV_EXCL_START */
654 static char *dl_get_font_info(char *str)
659 char *(*get_font_info)();
661 handle = dlopen("/usr/lib/libsystem-settings-util.so.0.1.0", RTLD_LAZY);
663 SETTING_TRACE("ERROR!! canNOT find libsystem-settings-util.so.0.1.0");
667 if (strcmp(str, "cur") == 0)
668 get_font_info = dlsym(handle, "_get_cur_font");
670 get_font_info = dlsym(handle, "_get_default_font");
672 if ((error = dlerror()) != NULL) {
673 SETTING_TRACE("ERROR!! canNOT find %s function at libsystem-settings-util.so.0.1.0", str);
678 ret = get_font_info();
685 /* LCOV_EXCL_START */
686 #define PATH_EXT_CHECK_REG ".(jpe?g|jpg|png|gif)$"
687 bool __is_supported_image_type_by_ext(char *file_path)
691 regmatch_t str[2048 + 1];
693 if (!file_path) return false;
696 if ((ret = regcomp(&fsm, PATH_EXT_CHECK_REG, REG_ICASE | REG_EXTENDED))) {
697 SETTING_TRACE("regular expresstion fail");
702 if (regexec(&fsm, file_path, strlen(file_path) + 1, str, 0) == REG_NOMATCH) {
703 /*SETTING_TRACE("FAILED - %s", file_path[i]); */
706 /*SETTING_TRACE("MATCHED - %s", file_path[i]); */
712 #ifdef TIZEN_WEARABLE
713 /* LCOV_EXCL_START */
714 static int system_setting_get_extended_wallpaper_num(const char *file_path, unsigned int *num)
718 const char *find_str = "extended_wallpaper_";
721 if (!(ch = strstr(file_path, find_str))) {
722 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
724 strncpy(buffer, file_path, ch - file_path);
725 buffer[ch - file_path] = 0;
726 sprintf(buffer + (ch - file_path), "%s%s", "", ch + strlen(find_str));
728 if (!isdigit(buffer[0])) {
729 SETTING_TRACE("%s is not number", buffer);
730 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
735 return SYSTEM_SETTINGS_ERROR_NONE;
739 /* LCOV_EXCL_START */
740 static int system_setting_copy_extended_wallpaper(const char *dest_file_path, const char *source_file_path)
743 if (!source_file_path || !dest_file_path) {
744 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
750 fd = open(source_file_path, O_RDONLY);
752 SETTING_TRACE("file open failed: %s", source_file_path);
753 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
757 fd2 = open(dest_file_path, O_WRONLY | O_CREAT, S_IRWXU | S_IRWXG | S_IRWXO);
759 SETTING_TRACE("file creation failed: %s", dest_file_path);
761 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
764 while (read(fd, buf, sizeof(buf) - 1) > 0) {
765 write(fd2, buf, sizeof(buf) - 1);
771 if (chmod(dest_file_path, S_IRWXU | S_IRWXG | S_IRWXO) < 0) {
772 SETTING_TRACE("chmod failed: %s", dest_file_path);
775 return SYSTEM_SETTINGS_ERROR_NONE;
779 /* LCOV_EXCL_START */
780 static int system_setting_remove_oldest_extended_wallpaper()
785 char *min_image_name = NULL;
786 unsigned int min_image_num = 0;
787 unsigned int temp_image_num = 0;
790 if ((dp = opendir(_TZ_SYS_DATA"/setting/wallpaper")) == NULL) {
791 SETTING_TRACE("opendir error");
792 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
795 while ((dirp = readdir(dp))) {
796 if (!strcmp(dirp->d_name, ".") || !strcmp(dirp->d_name, ".."))
799 if (system_setting_get_extended_wallpaper_num(dirp->d_name, &temp_image_num)
800 != SYSTEM_SETTINGS_ERROR_NONE) {
801 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
804 if ((image_count == 0) || (min_image_num > temp_image_num)) {
805 min_image_num = temp_image_num;
806 min_image_name = dirp->d_name;
813 if (min_image_name) {
814 snprintf(buf, sizeof(buf) - 1, _TZ_SYS_DATA"/setting/wallpaper/%s", min_image_name);
815 if (remove(buf) < 0) { /* remove oldest image */
816 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
820 return SYSTEM_SETTINGS_ERROR_NONE;
824 /* LCOV_EXCL_START */
825 static int system_setting_check_extended_wallpaper(const char *file_path)
829 if (!file_path || !strlen(file_path))
831 snprintf(buffer, 512, "%s/.bgwallpaper", tzplatform_getenv(TZ_USER_CONTENT));
832 return (strstr(file_path, buffer) != NULL);
836 #define WALLPAPER_MAX_COUNT 10
838 /* LCOV_EXCL_START */
839 int system_setting_set_wallpaper_home_screen(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
843 vconf_value = (char *)value;
845 bool isok = dl_is_supported_image_type_load(vconf_value);
848 SETTING_TRACE("path : %s is not supported file format", vconf_value);
849 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
851 SETTING_TRACE("path : %s is SUPPORT file format", vconf_value);
854 /* error handling here */
855 if (_is_file_accessible(vconf_value) != 0)
856 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
858 if (system_setting_vconf_set_value_string(VCONFKEY_BGSET, vconf_value)) {
859 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
863 #ifdef TIZEN_WEARABLE
864 if (system_setting_check_extended_wallpaper(vconf_value)) { /* New extended wallpaper */
867 unsigned int max_image_num = 0;
868 unsigned int temp_image_num = 0;
871 if ((dp = opendir(_TZ_SYS_DATA"/setting/wallpaper")) == NULL) {
872 SETTING_TRACE("Setting - dir open error!");
873 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
876 /* Check a max number of wallpapers */
877 while ((dirp = readdir(dp))) {
878 if (!strcmp(dirp->d_name, ".") || !strcmp(dirp->d_name, ".."))
881 if (system_setting_get_extended_wallpaper_num(dirp->d_name, &temp_image_num)
882 != SYSTEM_SETTINGS_ERROR_NONE) {
885 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
888 if ((image_count == 0) || (max_image_num < temp_image_num)) {
889 max_image_num = temp_image_num;
897 /* Numbering rule: Gear is odd number */
898 max_image_num = (max_image_num % 2 == 0) ? max_image_num + 1
901 char file_name_buffer[512];
902 snprintf(file_name_buffer, sizeof(file_name_buffer) - 1,
903 _TZ_SYS_DATA"/setting/wallpaper/extended_wallpaper_%d.jpg", max_image_num);
905 /* Copy image to _TZ_SYS_DATA/setting/wallpaper/ */
906 if (system_setting_copy_extended_wallpaper(file_name_buffer, vconf_value)
907 != SYSTEM_SETTINGS_ERROR_NONE) {
908 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
911 /* remove oldest wallpaper */
912 if (image_count >= WALLPAPER_MAX_COUNT) {
913 if (system_setting_remove_oldest_extended_wallpaper()
914 != SYSTEM_SETTINGS_ERROR_NONE) {
915 remove(file_name_buffer);
916 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
920 if (system_setting_vconf_set_value_string(VCONFKEY_BGSET, file_name_buffer)) {
921 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
924 if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_WALLPAPER_CHANGED_NOTI_INT,
925 VCONFKEY_WALLPAPER_CHANGED_NOTI_GEAR)) {
926 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
929 if (system_setting_vconf_set_value_string(VCONFKEY_BGSET, vconf_value)) {
930 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
935 return SYSTEM_SETTINGS_ERROR_NONE;
939 /* LCOV_EXCL_START */
940 int system_setting_set_wallpaper_lock_screen(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
944 vconf_value = (char *)value;
946 bool isok = dl_is_supported_image_type_load(vconf_value);
949 SETTING_TRACE("path : %s is not supported file format", vconf_value);
950 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
952 SETTING_TRACE("path : %s is SUPPORT file format", vconf_value);
955 /* error handling here */
956 if (_is_file_accessible(vconf_value) != 0)
957 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
959 if (system_setting_vconf_set_value_string(VCONFKEY_IDLE_LOCK_BGSET, vconf_value)) {
960 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
963 return SYSTEM_SETTINGS_ERROR_NONE;
967 /* LCOV_EXCL_START */
968 int system_setting_set_font_size(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
972 vconf_value = (int *)value;
974 if (*vconf_value < 0 || *vconf_value > SYSTEM_SETTINGS_FONT_SIZE_GIANT) {
975 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
978 if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, *vconf_value)) {
979 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
983 return SYSTEM_SETTINGS_ERROR_NONE;
989 /* LCOV_EXCL_START */
990 void *font_conf_doc_parse(char *doc_name, char *font_name)
993 xmlDocPtr doc = NULL;
994 xmlNodePtr cur = NULL;
995 xmlNodePtr cur2 = NULL;
996 xmlNodePtr cur3 = NULL;
999 doc = xmlParseFile(doc_name);
1001 cur = xmlDocGetRootElement(doc);
1009 if (xmlStrcmp(cur->name, (const xmlChar *)"fontconfig")) {
1015 cur = cur->xmlChildrenNode;
1017 bool is_changed = false;
1018 while (cur != NULL) {
1019 if ((!xmlStrcmp(cur->name, (const xmlChar *)"match"))) {
1020 cur2 = cur->xmlChildrenNode;
1021 while (cur2 != NULL) {
1022 if ((!xmlStrcmp(cur2->name, (const xmlChar *)"edit"))) {
1023 xmlChar *name = xmlGetProp(cur2, (const xmlChar *)"name");
1024 /* if name is not 'family', break */
1025 if (xmlStrcmp(name, (const xmlChar *)"family")) {
1033 cur3 = cur2->xmlChildrenNode;
1034 while (cur3 != NULL) {
1035 if ((!xmlStrcmp(cur3->name, (const xmlChar *)"string"))) {
1036 xmlNodeSetContent(cur3->xmlChildrenNode, (const xmlChar *)font_name);
1037 key = xmlNodeListGetString(doc, cur3->xmlChildrenNode, 1);
1047 } else if ((!xmlStrcmp(cur->name, (const xmlChar *)"alias"))) {
1048 cur2 = cur->xmlChildrenNode;
1049 while (cur2 != NULL) {
1050 if ((!xmlStrcmp(cur2->name, (const xmlChar *)"family"))) {
1051 xmlNodeSetContent(cur2->xmlChildrenNode, (const xmlChar *)font_name);
1052 key = xmlNodeListGetString(doc, cur2->xmlChildrenNode, 1);
1056 } else if ((!xmlStrcmp(cur2->name, (const xmlChar *)"prefer"))) {
1057 cur3 = cur2->xmlChildrenNode;
1058 while (cur3 != NULL) {
1059 if ((!xmlStrcmp(cur3->name, (const xmlChar *)"family"))) {
1060 xmlNodeSetContent(cur3->xmlChildrenNode, (const xmlChar *)font_name);
1061 key = xmlNodeListGetString(doc, cur3->xmlChildrenNode, 1);
1085 /* LCOV_EXCL_STOP */
1087 /* LCOV_EXCL_START */
1088 int system_setting_set_font_type(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1090 SETTING_TRACE_BEGIN;
1091 char *font_name = NULL;
1092 font_name = (char *)value;
1094 /* get current font list */
1095 int is_found = dl_is_available_font(font_name);
1098 SETTING_TRACE("found font : %s ", font_name);
1100 SETTING_TRACE(" NOT found font : %s ", font_name);
1101 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1104 bool bsave = dl_font_config_set(font_name);
1107 SETTING_TRACE(" font type save error by font_config_set() ");
1108 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1110 SETTING_TRACE(" save OK - font_config_set() ");
1113 xmlDocPtr doc = (xmlDocPtr)font_conf_doc_parse(SETTING_FONT_CONF_FILE, font_name);
1115 xmlSaveFormatFile(SETTING_FONT_CONF_FILE, doc, 0);
1120 dl_font_config_set_notification();
1123 vconf_value = (char *)value;
1125 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, vconf_value)) {
1126 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1128 return SYSTEM_SETTINGS_ERROR_NONE;
1130 /* LCOV_EXCL_STOP */
1132 /* LCOV_EXCL_START */
1133 int system_setting_set_motion_activation(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1135 SETTING_TRACE_BEGIN;
1137 vconf_value = (bool *)value;
1138 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_MOTION_ACTIVATION, *vconf_value)) {
1139 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1141 return SYSTEM_SETTINGS_ERROR_NONE;
1143 /* LCOV_EXCL_STOP */
1145 /* LCOV_EXCL_START */
1146 int system_setting_set_usb_debugging_option(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1148 SETTING_TRACE_BEGIN;
1150 vconf_value = (bool *)value;
1151 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_USB_DEBUG_MODE_BOOL, *vconf_value)) {
1152 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1154 return SYSTEM_SETTINGS_ERROR_NONE;
1157 /* LCOV_EXCL_STOP */
1159 /* LCOV_EXCL_START */
1160 int system_setting_set_3g_data_network(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1162 SETTING_TRACE_BEGIN;
1164 vconf_value = (bool *)value;
1165 if (system_setting_vconf_set_value_bool(VCONFKEY_3G_ENABLE, *vconf_value)) {
1166 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1169 return SYSTEM_SETTINGS_ERROR_NONE;
1171 /* LCOV_EXCL_STOP */
1173 /* LCOV_EXCL_START */
1174 static int category_func(const char *name, void *user_data)
1176 SETTING_TRACE_BEGIN;
1177 static char *category = "lock-screen";
1178 if (name && !strcmp(name, category)) {
1179 SETTING_TRACE(" SAME ");
1182 SETTING_TRACE(" DIFFERENT -- %s, category -- %s ", name, category);
1188 /* LCOV_EXCL_STOP */
1192 * set 'swipe type' if current lockscreen app is 'com.samsung.lockscreen'
1196 /* LCOV_EXCL_START */
1197 int system_setting_set_lockscreen_app(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1199 SETTING_TRACE_BEGIN;
1201 vconf_value = (char *)value; /* ex) com.samsung.lockscreen */
1204 pkgmgrinfo_appinfo_h handle;
1205 r = pkgmgrinfo_appinfo_get_appinfo(vconf_value, &handle);
1206 if (r != PMINFO_R_OK) {
1207 SETTING_TRACE("*** pkginfo failed ");
1208 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
1210 SETTING_TRACE("%x", handle);
1213 int ret = pkgmgrinfo_appinfo_foreach_category(handle, category_func, (void *)"lock-screen");
1214 if (ret != PMINFO_R_OK) {
1215 pkgmgrinfo_appinfo_destroy_appinfo(handle);
1216 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
1219 pkgmgrinfo_appinfo_destroy_appinfo(handle);
1220 /*----------------------------------------------------------------------------------- */
1222 if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_SCREEN_LOCK_TYPE_INT, &locktype)) {
1223 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1226 if (locktype == SETTING_SCREEN_LOCK_TYPE_PASSWORD)
1227 return SYSTEM_SETTINGS_ERROR_LOCKSCREEN_APP_PASSWORD_MODE;
1229 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_3RD_LOCK_PKG_NAME_STR, vconf_value)) {
1230 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1233 if (vconf_value && strcmp(vconf_value, "com.samsung.lockscreen") == 0) {
1234 if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_SCREEN_LOCK_TYPE_INT, SETTING_SCREEN_LOCK_TYPE_SWIPE)) {
1235 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1238 return SYSTEM_SETTINGS_ERROR_NONE;
1240 /* LCOV_EXCL_STOP */
1242 /*/////////////////////////////////////////////////////////////////////////////////////////////// */
1245 int system_setting_set_changed_callback_incoming_call_ringtone(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1247 SETTING_TRACE_BEGIN;
1248 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR, SYSTEM_SETTINGS_KEY_INCOMING_CALL_RINGTONE, 0, user_data);
1251 int system_setting_unset_changed_callback_incoming_call_ringtone(system_settings_key_e key)
1253 SETTING_TRACE_BEGIN;
1254 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR, 0);
1257 int system_setting_set_changed_callback_email_alert_ringtone(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1259 SETTING_TRACE_BEGIN;
1260 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, SYSTEM_SETTINGS_KEY_EMAIL_ALERT_RINGTONE, 0, user_data);
1263 int system_setting_unset_changed_callback_email_alert_ringtone(system_settings_key_e key)
1265 SETTING_TRACE_BEGIN;
1266 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, 0);
1269 int system_setting_set_changed_callback_wallpaper_home_screen(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1271 SETTING_TRACE_BEGIN;
1272 return system_setting_vconf_set_changed_cb(VCONFKEY_BGSET, SYSTEM_SETTINGS_KEY_WALLPAPER_HOME_SCREEN, 0, user_data);
1275 int system_setting_unset_changed_callback_wallpaper_home_screen(system_settings_key_e key)
1277 SETTING_TRACE_BEGIN;
1278 return system_setting_vconf_unset_changed_cb(VCONFKEY_BGSET, 0);
1281 int system_setting_set_changed_callback_wallpaper_lock_screen(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1283 SETTING_TRACE_BEGIN;
1284 return system_setting_vconf_set_changed_cb(VCONFKEY_IDLE_LOCK_BGSET, SYSTEM_SETTINGS_KEY_WALLPAPER_LOCK_SCREEN, 0, user_data);
1287 int system_setting_unset_changed_callback_wallpaper_lock_screen(system_settings_key_e key)
1289 SETTING_TRACE_BEGIN;
1290 return system_setting_vconf_unset_changed_cb(VCONFKEY_IDLE_LOCK_BGSET, 0);
1293 int system_setting_set_changed_callback_font_size(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1295 SETTING_TRACE_BEGIN;
1296 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, SYSTEM_SETTINGS_KEY_FONT_SIZE, 1, user_data);
1299 int system_setting_unset_changed_callback_font_size(system_settings_key_e key)
1301 SETTING_TRACE_BEGIN;
1302 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, 1);
1305 int system_setting_set_changed_callback_usb_debugging_option(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1307 SETTING_TRACE_BEGIN;
1308 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_USB_DEBUG_MODE_BOOL, SYSTEM_SETTINGS_KEY_USB_DEBUGGING_ENABLED, 1, user_data);
1311 int system_setting_unset_changed_callback_usb_debugging_option(system_settings_key_e key)
1313 SETTING_TRACE_BEGIN;
1314 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_USB_DEBUG_MODE_BOOL, 1);
1317 int system_setting_set_changed_callback_3g_data_network(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1319 SETTING_TRACE_BEGIN;
1320 return system_setting_vconf_set_changed_cb(VCONFKEY_3G_ENABLE, SYSTEM_SETTINGS_KEY_3G_DATA_NETWORK_ENABLED, 1, user_data);
1323 int system_setting_unset_changed_callback_3g_data_network(system_settings_key_e key)
1325 SETTING_TRACE_BEGIN;
1326 return system_setting_vconf_unset_changed_cb(VCONFKEY_3G_ENABLE, 1);
1329 int system_setting_set_changed_callback_lockscreen_app(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1331 SETTING_TRACE_BEGIN;
1332 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_3RD_LOCK_PKG_NAME_STR, SYSTEM_SETTINGS_KEY_LOCKSCREEN_APP, 1, user_data);
1335 int system_setting_unset_changed_callback_lockscreen_app(system_settings_key_e key)
1337 SETTING_TRACE_BEGIN;
1338 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_3RD_LOCK_PKG_NAME_STR, 1);
1343 * @todo need to add custom event notification method
1345 int system_setting_set_changed_callback_font_type(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1347 SETTING_TRACE_BEGIN;
1348 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, SYSTEM_SETTINGS_KEY_FONT_TYPE, 2, user_data);
1351 int system_setting_unset_changed_callback_font_type(system_settings_key_e key)
1353 SETTING_TRACE_BEGIN;
1354 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, 2);
1357 /* TODO : 2th argument, callback, is not in use. */
1358 int system_setting_set_changed_callback_motion_activation(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1360 SETTING_TRACE_BEGIN;
1361 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_MOTION_ACTIVATION, SYSTEM_SETTINGS_KEY_MOTION_ACTIVATION, 3, user_data);
1364 int system_setting_unset_changed_callback_motion_activation(system_settings_key_e key)
1366 SETTING_TRACE_BEGIN;
1367 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_MOTION_ACTIVATION, 3);
1370 /*//////////////////////////////////////////////////////////////////////////////////////// */
1371 /*--------------------------------------- */
1372 int system_setting_get_locale_country(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1374 SETTING_TRACE_BEGIN;
1375 char *vconf_value = NULL;
1376 if (system_setting_vconf_get_value_string(VCONFKEY_REGIONFORMAT, &vconf_value)) {
1377 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1380 /* parsing validation */
1383 snprintf(arr, 20, "%s", vconf_value);
1385 *value = strdup(arr);
1389 return SYSTEM_SETTINGS_ERROR_NONE;
1392 /* LCOV_EXCL_START */
1393 int system_setting_set_locale_country(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1395 SETTING_TRACE_BEGIN;
1396 char *vconf_value = NULL;
1397 vconf_value = (char *)value;
1399 char *ext = "UTF-8";
1402 snprintf(arr, 20, "%s.%s", vconf_value, ext);
1404 if (system_setting_vconf_set_value_string(VCONFKEY_REGIONFORMAT, arr)) {
1405 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1407 return SYSTEM_SETTINGS_ERROR_NONE;
1409 /* LCOV_EXCL_STOP */
1411 int system_setting_set_changed_callback_locale_country(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1413 SETTING_TRACE_BEGIN;
1414 return system_setting_vconf_set_changed_cb(VCONFKEY_REGIONFORMAT, SYSTEM_SETTINGS_KEY_LOCALE_COUNTRY, 3, user_data);
1417 int system_setting_unset_changed_callback_locale_country(system_settings_key_e key)
1419 SETTING_TRACE_BEGIN;
1420 return system_setting_vconf_unset_changed_cb(VCONFKEY_REGIONFORMAT, 3);
1424 /*--------------------------------------- */
1425 int system_setting_get_locale_language(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1427 SETTING_TRACE_BEGIN;
1428 char *vconf_value = NULL;
1429 if (system_setting_vconf_get_value_string(VCONFKEY_LANGSET, &vconf_value)) {
1430 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1433 /* parsing validation */
1436 snprintf(arr, 20, "%s", vconf_value);
1438 *value = strdup(arr);
1441 return SYSTEM_SETTINGS_ERROR_NONE;
1444 /* LCOV_EXCL_START */
1445 int system_setting_set_locale_language(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1447 SETTING_TRACE_BEGIN;
1448 char *vconf_value = NULL;
1449 vconf_value = (char *)value;
1451 char *ext = "UTF-8";
1454 snprintf(arr, 20, "%s.%s", vconf_value, ext);
1456 if (system_setting_vconf_set_value_string(VCONFKEY_LANGSET, arr)) {
1457 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1459 return SYSTEM_SETTINGS_ERROR_NONE;
1461 /* LCOV_EXCL_STOP */
1463 int system_setting_set_changed_callback_locale_language(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1465 SETTING_TRACE_BEGIN;
1466 /*return system_setting_vconf_set_changed_cb(VCONFKEY_LANGSET, SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, 3, user_data ); */
1467 return system_setting_vconf_set_changed_cb(VCONFKEY_LANGSET, SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, 100, user_data);
1470 int system_setting_unset_changed_callback_locale_language(system_settings_key_e key)
1472 SETTING_TRACE_BEGIN;
1473 return system_setting_vconf_unset_changed_cb(VCONFKEY_LANGSET, 100);
1476 /*--------------------------------------- */
1477 /* LCOV_EXCL_START */
1478 int system_setting_get_locale_timeformat_24hour(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1480 SETTING_TRACE_BEGIN;
1483 if (system_setting_vconf_get_value_int(VCONFKEY_REGIONFORMAT_TIME1224, &vconf_value)) {
1484 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1487 bool ret_value = true;
1488 if (vconf_value == VCONFKEY_TIME_FORMAT_12)
1490 else if (vconf_value == VCONFKEY_TIME_FORMAT_24)
1493 *value = (void *)ret_value;
1495 return SYSTEM_SETTINGS_ERROR_NONE;
1497 /* LCOV_EXCL_STOP */
1499 int system_setting_set_locale_timeformat_24hour(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1501 SETTING_TRACE_BEGIN;
1504 vconf_value = (bool *)value;
1507 if (system_setting_vconf_set_value_int(VCONFKEY_REGIONFORMAT_TIME1224, VCONFKEY_TIME_FORMAT_24)) {
1508 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1512 if (system_setting_vconf_set_value_int(VCONFKEY_REGIONFORMAT_TIME1224, VCONFKEY_TIME_FORMAT_12)) {
1513 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1518 return SYSTEM_SETTINGS_ERROR_NONE;
1521 int system_setting_set_changed_callback_locale_timeformat_24hour(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1523 SETTING_TRACE_BEGIN;
1524 return system_setting_vconf_set_changed_cb(VCONFKEY_REGIONFORMAT_TIME1224, SYSTEM_SETTINGS_KEY_LOCALE_TIMEFORMAT_24HOUR, 3, user_data);
1527 int system_setting_unset_changed_callback_locale_timeformat_24hour(system_settings_key_e key)
1529 SETTING_TRACE_BEGIN;
1530 return system_setting_vconf_unset_changed_cb(VCONFKEY_REGIONFORMAT_TIME1224, 3);
1533 int system_setting_get_locale_timezone(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1536 ssize_t len = readlink(SETTING_TZONE_SYMLINK_PATH, tzpath, sizeof(tzpath)-1);
1540 SETTING_TRACE("parse error for SETTING_TZONE_SYMLINK_PATH");
1541 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1544 SETTING_TRACE("tzpath : %s ", &tzpath[20]);
1545 *value = strdup(&tzpath[20]);
1546 return SYSTEM_SETTINGS_ERROR_NONE;
1549 /* LCOV_EXCL_START */
1550 int system_setting_set_locale_timezone(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1552 SETTING_TRACE_BEGIN;
1553 char *timezone_value = NULL;
1554 timezone_value = (char *)value;
1557 snprintf(tz_path, 1024, "/usr/share/zoneinfo/%s", timezone_value);
1559 int is_load = _is_file_accessible(tz_path);
1561 alarmmgr_set_timezone(tz_path);
1563 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_TIMEZONE_ID, timezone_value)) {
1564 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1566 return SYSTEM_SETTINGS_ERROR_NONE;
1568 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
1570 /* LCOV_EXCL_STOP */
1574 /* LCOV_EXCL_START */
1575 int system_setting_set_changed_callback_locale_timezone(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1577 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_TIMEZONE_ID, SYSTEM_SETTINGS_KEY_LOCALE_TIMEZONE, 4, user_data);
1579 /* LCOV_EXCL_STOP */
1581 /* LCOV_EXCL_START */
1582 int system_setting_unset_changed_callback_locale_timezone(system_settings_key_e key)
1584 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_TIMEZONE_ID, 4);
1586 /* LCOV_EXCL_STOP */
1588 /* LCOV_EXCL_START */
1589 int system_setting_set_changed_callback_locale_timezone_changed(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1591 SETTING_TRACE_BEGIN;
1592 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
1594 /* LCOV_EXCL_STOP */
1596 /* LCOV_EXCL_START */
1597 int system_setting_unset_changed_callback_locale_timezone_changed(system_settings_key_e key)
1599 SETTING_TRACE_BEGIN;
1600 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
1602 /* LCOV_EXCL_STOP */
1605 /* LCOV_EXCL_START */
1606 int system_setting_get_time_changed(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1608 SETTING_TRACE_BEGIN;
1610 cur_tick = time(NULL);
1611 *value = (void *)cur_tick;
1612 /* struct tm * localtime = time (cur_tick); */
1613 /* printf("%s\n", ctime(&cur_tick); */
1614 return SYSTEM_SETTINGS_ERROR_NONE;
1617 /* LCOV_EXCL_STOP */
1619 int system_setting_set_changed_callback_time_changed(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1621 SETTING_TRACE_BEGIN;
1622 return system_setting_vconf_set_changed_cb(VCONFKEY_SYSTEM_TIME_CHANGED, SYSTEM_SETTINGS_KEY_TIME_CHANGED, 3, user_data);
1625 int system_setting_unset_changed_callback_time_changed(system_settings_key_e key)
1627 SETTING_TRACE_BEGIN;
1628 return system_setting_vconf_unset_changed_cb(VCONFKEY_SYSTEM_TIME_CHANGED, 3);
1633 /* SYSTEM_SETTINGS_KEY_SOUND_LOCK */
1634 int system_setting_get_sound_lock(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1636 SETTING_TRACE_BEGIN;
1639 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_SOUND_LOCK_BOOL, &vconf_value)) {
1640 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1642 *value = (void *)vconf_value;
1644 return SYSTEM_SETTINGS_ERROR_NONE;
1647 int system_setting_set_changed_callback_sound_lock(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1649 SETTING_TRACE_BEGIN;
1650 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_SOUND_LOCK_BOOL, SYSTEM_SETTINGS_KEY_SOUND_LOCK, 3, user_data);
1653 int system_setting_unset_changed_callback_sound_lock(system_settings_key_e key)
1655 SETTING_TRACE_BEGIN;
1656 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_SOUND_LOCK_BOOL, 3);
1660 * a = VCONFKEY_SETAPPL_SOUND_STATUS_BOOL b = VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL
1662 * a == false, b == false --> silent mode
1663 * a == true, b == false --> sound mode
1664 * a == false, b == true --> vibration mode
1666 /* LCOV_EXCL_START */
1667 int system_setting_get_sound_silent_mode(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1669 SETTING_TRACE_BEGIN;
1674 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, &sound_cond)) {
1675 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1678 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, &vib_cond)) {
1679 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1682 if (sound_cond == false && vib_cond == false) {
1684 *value = (void *)vconf_value;
1686 vconf_value = false;
1687 *value = (void *)vconf_value;
1689 return SYSTEM_SETTINGS_ERROR_NONE;
1691 /* LCOV_EXCL_STOP */
1694 * a = VCONFKEY_SETAPPL_SOUND_STATUS_BOOL b = VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL
1696 * a == false, b == false --> silent mode
1697 * a == true, b == false --> sound mode
1699 int system_setting_set_sound_silent_mode(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1701 SETTING_TRACE_BEGIN;
1704 vconf_value = (bool *)value;
1706 bool vconf_sound = false;
1707 bool vconf_vib = false;
1710 vconf_sound = false;
1717 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, vconf_sound)) {
1718 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1720 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, vconf_vib)) {
1721 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1724 return SYSTEM_SETTINGS_ERROR_NONE;
1730 int system_setting_set_changed_callback_sound_silent_mode(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1732 SETTING_TRACE_BEGIN;
1733 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, SYSTEM_SETTINGS_KEY_SOUND_SILENT_MODE, 3, user_data);
1737 int system_setting_unset_changed_callback_sound_silent_mode(system_settings_key_e key)
1739 SETTING_TRACE_BEGIN;
1740 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, 3);
1743 /* SYSTEM_SETTINGS_KEY_SOUND_TOUCH */
1744 int system_setting_get_sound_touch(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1746 SETTING_TRACE_BEGIN;
1749 int ret = system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL, &vconf_value);
1750 if (ret != SYSTEM_SETTINGS_ERROR_NONE) {
1753 *value = (void *)vconf_value;
1757 int system_setting_set_changed_callback_sound_touch(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1759 SETTING_TRACE_BEGIN;
1760 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL, SYSTEM_SETTINGS_KEY_SOUND_TOUCH, 2, user_data);
1763 int system_setting_unset_changed_callback_sound_touch(system_settings_key_e key)
1765 SETTING_TRACE_BEGIN;
1766 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL, 2);
1770 /* SYSTEM_SETTINGS_KEY_SOUND_LOCK */
1771 int system_setting_get_sound_lock(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1775 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_SOUND_LOCK_BOOL, &vconf_value)) {
1776 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1778 *value = (void *)vconf_value;
1780 return SYSTEM_SETTINGS_ERROR_NONE;
1784 int system_setting_get_auto_rotation_mode(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1786 SETTING_TRACE_BEGIN;
1789 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, &vconf_value)) {
1790 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1792 *value = (void *)vconf_value;
1794 return SYSTEM_SETTINGS_ERROR_NONE;
1797 /* LCOV_EXCL_START */
1798 int system_setting_set_auto_rotation_mode(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1800 SETTING_TRACE_BEGIN;
1802 vconf_value = (bool *)value;
1803 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, *vconf_value)) {
1804 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1807 return SYSTEM_SETTINGS_ERROR_NONE;
1809 /* LCOV_EXCL_STOP */
1811 int system_setting_set_changed_callback_auto_rotation_mode(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1813 SETTING_TRACE_BEGIN;
1814 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, SYSTEM_SETTINGS_KEY_DISPLAY_SCREEN_ROTATION_AUTO, 2, user_data);
1817 int system_setting_unset_changed_callback_auto_rotation_mode(system_settings_key_e key)
1819 SETTING_TRACE_BEGIN;
1820 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, 2);
1823 int system_setting_get_screen_backlight_time(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1825 SETTING_TRACE_BEGIN;
1828 if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, &vconf_value)) {
1829 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1831 *value = (void *)vconf_value;
1833 return SYSTEM_SETTINGS_ERROR_NONE;
1837 /* LCOV_EXCL_START */
1838 int system_setting_set_screen_backlight_time(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1840 SETTING_TRACE_BEGIN;
1842 vconf_value = (int *)value;
1844 if (!(*vconf_value > 0 && *vconf_value < 600)) {
1845 SETTING_TRACE(" ERR Betweeny here 0 ~ 600");
1846 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
1849 if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, *vconf_value)) {
1850 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1853 return SYSTEM_SETTINGS_ERROR_NONE;
1855 /* LCOV_EXCL_STOP */
1857 int system_setting_set_changed_callback_screen_backlight_time(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1859 SETTING_TRACE_BEGIN;
1860 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, SYSTEM_SETTINGS_KEY_DISPLAY_SCREEN_ROTATION_AUTO, 2, user_data);
1863 int system_setting_unset_changed_callback_screen_backlight_time(system_settings_key_e key)
1865 SETTING_TRACE_BEGIN;
1866 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, 2);
1869 int system_setting_get_sound_notification(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1871 SETTING_TRACE_BEGIN;
1872 char *vconf_value = NULL;
1873 if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, &vconf_value)) {
1874 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1877 *value = vconf_value;
1878 return SYSTEM_SETTINGS_ERROR_NONE;
1881 /* LCOV_EXCL_START */
1882 int system_setting_set_sound_notification(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1884 SETTING_TRACE_BEGIN;
1885 char *vconf_value = NULL;
1886 vconf_value = (char *)value;
1888 int is_load = _is_file_accessible(vconf_value);
1890 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, vconf_value)) {
1891 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1894 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1897 return SYSTEM_SETTINGS_ERROR_NONE;
1899 /* LCOV_EXCL_STOP */
1901 int system_setting_set_changed_callback_sound_notification(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1903 SETTING_TRACE_BEGIN;
1904 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, SYSTEM_SETTINGS_KEY_INCOMING_CALL_RINGTONE, 0, user_data);
1907 int system_setting_unset_changed_callback_sound_notification(system_settings_key_e key)
1909 SETTING_TRACE_BEGIN;
1910 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, 0);
1913 int system_setting_get_notification_repetition_period(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1915 SETTING_TRACE_BEGIN;
1918 if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_NOTI_MSG_ALERT_REP_TYPE_INT, &vconf_value)) {
1919 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1921 *value = (void *)vconf_value;
1923 return SYSTEM_SETTINGS_ERROR_NONE;
1926 /* LCOV_EXCL_START */
1927 int system_setting_set_notification_repetition_period(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1929 SETTING_TRACE_BEGIN;
1931 vconf_value = (int *)value;
1933 if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_NOTI_MSG_ALERT_REP_TYPE_INT, *vconf_value)) {
1934 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1937 return SYSTEM_SETTINGS_ERROR_NONE;
1939 /* LCOV_EXCL_STOP */
1941 int system_setting_set_changed_callback_notification_repetition_period(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1943 SETTING_TRACE_BEGIN;
1944 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);
1947 int system_setting_unset_changed_callback_notification_repetition_period(system_settings_key_e key)
1949 SETTING_TRACE_BEGIN;
1950 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_ALERT_REP_TYPE_INT, 1);
1953 int system_setting_get_device_name(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1955 SETTING_TRACE_BEGIN;
1956 char *vconf_value = NULL;
1957 if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_DEVICE_NAME_STR, &vconf_value)) {
1958 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1961 *value = vconf_value;
1962 return SYSTEM_SETTINGS_ERROR_NONE;
1965 /* LCOV_EXCL_START */
1966 int system_setting_set_device_name(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1968 SETTING_TRACE_BEGIN;
1969 char *vconf_value = NULL;
1970 vconf_value = (char *)value;
1972 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_DEVICE_NAME_STR, vconf_value)) {
1973 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1976 return SYSTEM_SETTINGS_ERROR_NONE;
1978 /* LCOV_EXCL_STOP */
1980 int system_setting_set_changed_callback_device_name(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1982 SETTING_TRACE_BEGIN;
1983 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_DEVICE_NAME_STR, SYSTEM_SETTINGS_KEY_DEVICE_NAME, 0, user_data);
1986 int system_setting_unset_changed_callback_device_name(system_settings_key_e key)
1988 SETTING_TRACE_BEGIN;
1989 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_DEVICE_NAME_STR, 0);
1992 /*---------------------------------------------- */
1993 int system_setting_get_network_flight_mode(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1995 SETTING_TRACE_BEGIN;
1997 if (system_setting_vconf_get_value_bool(VCONFKEY_TELEPHONY_FLIGHT_MODE, &vconf_value)) {
1998 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2000 *value = (void *)vconf_value;
2002 return SYSTEM_SETTINGS_ERROR_NONE;
2005 int system_setting_set_changed_callback_network_flight_mode(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
2007 SETTING_TRACE_BEGIN;
2008 return system_setting_vconf_set_changed_cb(VCONFKEY_TELEPHONY_FLIGHT_MODE, SYSTEM_SETTINGS_KEY_NETWORK_FLIGHT_MODE, 3, user_data);
2011 int system_setting_unset_changed_callback_network_flight_mode(system_settings_key_e key)
2013 SETTING_TRACE_BEGIN;
2014 return system_setting_vconf_unset_changed_cb(VCONFKEY_TELEPHONY_FLIGHT_MODE, 3);
2017 int system_setting_get_network_wifi_notification(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
2019 SETTING_TRACE_BEGIN;
2021 if (system_setting_vconf_get_value_int(VCONFKEY_WIFI_ENABLE_QS, &vconf_value)) {
2022 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2025 bret = (vconf_value == VCONFKEY_WIFI_QS_ENABLE) ? true : false;
2027 *value = (void *)bret;
2028 return SYSTEM_SETTINGS_ERROR_NONE;
2031 int system_setting_set_changed_callback_network_wifi_notification(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
2033 SETTING_TRACE_BEGIN;
2034 return system_setting_vconf_set_changed_cb(VCONFKEY_WIFI_ENABLE_QS, SYSTEM_SETTINGS_KEY_NETWORK_WIFI_NOTIFICATION, 4, user_data);
2037 int system_setting_unset_changed_callback_network_wifi_notification(system_settings_key_e key)
2039 SETTING_TRACE_BEGIN;
2040 return system_setting_vconf_unset_changed_cb(VCONFKEY_WIFI_ENABLE_QS, 4);
2043 /* LCOV_EXCL_START */
2044 int system_setting_get_lock_state(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
2048 if (system_setting_vconf_get_value_int(VCONFKEY_IDLE_LOCK_STATE_READ_ONLY, &vconf_value)) {
2049 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2051 *value = (void *)vconf_value;
2053 return SYSTEM_SETTINGS_ERROR_NONE;
2055 /* LCOV_EXCL_STOP */
2057 /* LCOV_EXCL_START */
2058 int system_setting_set_lock_state(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
2060 SETTING_TRACE_BEGIN;
2062 vconf_value = (int *)value;
2064 if (system_setting_vconf_set_value_int(VCONFKEY_IDLE_LOCK_STATE_READ_ONLY, *vconf_value)) {
2065 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2068 return SYSTEM_SETTINGS_ERROR_NONE;
2070 /* LCOV_EXCL_STOP */
2072 /* LCOV_EXCL_START */
2073 int system_setting_set_changed_callback_lock_state(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
2075 return system_setting_vconf_set_changed_cb(VCONFKEY_IDLE_LOCK_STATE_READ_ONLY, SYSTEM_SETTINGS_KEY_LOCK_STATE, 4, user_data);
2077 /* LCOV_EXCL_STOP */
2079 /* LCOV_EXCL_START */
2080 int system_setting_unset_changed_callback_lock_state(system_settings_key_e key)
2082 return system_setting_vconf_unset_changed_cb(VCONFKEY_IDLE_LOCK_STATE_READ_ONLY, 4);
2084 /* LCOV_EXCL_STOP */
2086 //----------------------------------------------------------------------------------------------------------------------------
2088 #define DEFAULT_ADS_ID "00000000-0000-0000-0000-000000000000"
2090 int system_setting_get_ads_id(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
2092 SETTING_TRACE_BEGIN;
2093 int optout_value = 0;
2094 if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_AD_ID_OPT_OUT, &optout_value)) {
2095 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2098 if (optout_value == 1) {
2099 *value = strdup(DEFAULT_ADS_ID);
2100 return SYSTEM_SETTINGS_ERROR_NONE;
2103 char *vconf_value = NULL;
2104 if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_AD_ID, &vconf_value)) {
2105 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2108 *value = vconf_value;
2109 return SYSTEM_SETTINGS_ERROR_NONE;
2114 void make_ad_id(void)
2117 char uuid_unparsed[50] = {0};
2118 uuid_generate(uuid_value);
2119 uuid_unparse(uuid_value, uuid_unparsed);
2120 system_setting_set_ad_id(key, uuid_unparsed); //example of setting the value
2123 /* LCOV_EXCL_START */
2124 int system_setting_set_ads_id(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
2126 SETTING_TRACE_BEGIN;
2127 char *vconf_value = NULL;
2128 vconf_value = (char *)value;
2130 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_AD_ID, vconf_value)) {
2131 SETTING_TRACE("Setting VCONFKEY_SETAPPL_AD_ID failed");
2132 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2135 return SYSTEM_SETTINGS_ERROR_NONE;
2137 /* LCOV_EXCL_STOP */
2139 int system_setting_set_changed_callback_ads_id(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
2141 SETTING_TRACE_BEGIN;
2142 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_AD_ID, SYSTEM_SETTINGS_KEY_ADS_ID, 0, user_data);
2145 int system_setting_unset_changed_callback_ads_id(system_settings_key_e key)
2147 SETTING_TRACE_BEGIN;
2148 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_AD_ID, 0);