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>
54 #define SETTING_FONT_CONF_FILE _TZ_SYS_ETC"/fonts/conf.avail/99-tizen.conf"
55 #define SETTING_DEFAULT_FONT_CONF_FILE _TZ_SYS_ETC"/fonts/conf.avail/99-tizen.conf"
57 #define SETTING_TIME_ZONEINFO_PATH "/usr/share/zoneinfo/"
58 #define SETTING_TIME_SHARE_LOCAL_PATH "/usr/share/locale"
59 #define SETTING_TZONE_SYMLINK_PATH "/opt/etc/localtime"
62 #define __FREE(del, arg) do { \
64 del((void *)(arg)); /*cast any argument to (void*) to avoid build warring*/\
68 #define FREE(arg) __FREE(free, arg)
70 #ifdef SETTING_ARCH_64
71 #define SETTING_UTILS_SO_FILE_PATH "/usr/lib64/libsystem-settings-util.so.0.1.0"
73 #define SETTING_UTILS_SO_FILE_PATH "/usr/lib/libsystem-settings-util.so.0.1.0"
76 int _is_file_accessible(const char *path);
78 static bool dl_is_supported_image_type_load(char *path);
79 static bool dl_font_config_set(char *font_name);
80 static char *dl_get_font_info(char *str);
81 static int dl_is_available_font(char *str);
82 static void dl_font_size_set();
83 static void dl_font_config_set_notification();
87 * VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR has a path of the ringtone file which user choose
88 * @return the ringtone file path specified by user in normal case
89 * if it's not accessable, return the default ringtone path
91 int system_setting_get_incoming_call_ringtone(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
95 if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR, &vconf_value)) {
96 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
99 /* check to see if it's accessable -> OK */
100 /* no --> default ringtone path VCONFKEY_SETAPPL_CALL_RINGTONE_DEFAULT_PATH_STR */
101 int is_load = _is_file_accessible(vconf_value);
103 *value = vconf_value;
104 } else { /* not zero on errro */
105 *value = vconf_get_str(VCONFKEY_SETAPPL_CALL_RINGTONE_DEFAULT_PATH_STR);
108 /**value = vconf_value; */
109 return SYSTEM_SETTINGS_ERROR_NONE;
113 int system_setting_get_email_alert_ringtone(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
117 if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, &vconf_value)) {
118 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
121 /* check to see if it's accessable -> OK */
122 /* no --> default ringtone path VCONFKEY_SETAPPL_NOTI_RINGTONE_DEFAULT_PATH_STR */
123 int is_load = _is_file_accessible(vconf_value);
125 *value = vconf_value;
126 } else { /* not zero on errro */
127 *value = vconf_get_str(VCONFKEY_SETAPPL_NOTI_RINGTONE_DEFAULT_PATH_STR);
130 return SYSTEM_SETTINGS_ERROR_NONE;
134 int system_setting_get_wallpaper_home_screen(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
138 if (system_setting_vconf_get_value_string(VCONFKEY_BGSET, &vconf_value)) {
139 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
141 *value = vconf_value;
142 return SYSTEM_SETTINGS_ERROR_NONE;
146 int system_setting_get_wallpaper_lock_screen(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
151 if (system_setting_vconf_get_value_string(VCONFKEY_IDLE_LOCK_BGSET, &vconf_value)) {
152 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
154 *value = vconf_value;
156 return SYSTEM_SETTINGS_ERROR_NONE;
160 /* [int] vconf GET */
161 int system_setting_get_font_size(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
165 int ** val = (int**)value;
167 if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, &vconf_value)) {
168 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
172 return SYSTEM_SETTINGS_ERROR_NONE;
176 int system_setting_get_default_font_type(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
179 char *font_name = dl_get_font_info("default");
181 *value = (void *)font_name;
182 return SYSTEM_SETTINGS_ERROR_NONE;
184 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
188 /* [int] vconf GET */
189 int system_setting_get_font_type(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
192 char *font_name = dl_get_font_info("cur");
193 *value = (void *)font_name;
195 return SYSTEM_SETTINGS_ERROR_NONE;
199 int system_setting_get_motion_activation(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
204 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_MOTION_ACTIVATION, &vconf_value)) {
205 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
207 *value = (void *)vconf_value;
209 return SYSTEM_SETTINGS_ERROR_NONE;
212 int system_setting_get_usb_debugging_option(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
217 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_USB_DEBUG_MODE_BOOL, &vconf_value)) {
218 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
220 *value = (void *)vconf_value;
222 return SYSTEM_SETTINGS_ERROR_NONE;
225 int system_setting_get_3g_data_network(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
230 if (system_setting_vconf_get_value_bool(VCONFKEY_3G_ENABLE, &vconf_value)) {
231 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
233 *value = (void *)vconf_value;
235 return SYSTEM_SETTINGS_ERROR_NONE;
237 /*////////////////////////////////////////////////////////////////////////////////////////////////// */
241 * get current lock scren app package name (string)
243 * @return SYSTEM_SETTINGS_ERROR_LOCKSCREEN_APP_PASSWORD_MODE raise exception if current lock type is 'password'
245 int system_setting_get_lockscreen_app(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
248 char *pkg_name = NULL;
250 system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_SCREEN_LOCK_TYPE_INT, &locktype);
252 if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_3RD_LOCK_PKG_NAME_STR, &pkg_name)) {
253 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
256 if (pkg_name && strcmp(pkg_name, "com.samsung.lockscreen") == 0 && locktype == SETTING_SCREEN_LOCK_TYPE_PASSWORD) {
257 return SYSTEM_SETTINGS_ERROR_LOCKSCREEN_APP_PASSWORD_MODE;
261 return SYSTEM_SETTINGS_ERROR_NONE;
265 /*////////////////////////////////////////////////////////////////////////////////////////////////// */
267 int _is_file_accessible(const char *path)
270 int ret = access(path , R_OK);
272 SETTING_TRACE("found the file %s", path);
275 /* error code : 13 */
276 SETTING_TRACE("found the file %s --- error code : %d ", path, errno);
283 /*////////////////////////////////////////////////////////////////////////////////////////////////// */
284 // @todo move to CMake
285 #define DEF_RINGTONE_FILE_PATH SETTING_DEF_RES"/Ringtones"
287 #define USR_RINGTONE_FILE_PATH "/home/owner/content/Sounds/Ringtones"
288 #define JSONFILE "/opt/home/owner/apps_rw/org.tizen.setting/data/.user-ringtones.json"
291 static char* _get_json_file_path()
298 int system_setting_add_incoming_call_ringtone(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
301 char* pathval = (char*)value;
305 JsonParser *parser = ss_json_ringtone_open_file(JSONFILE);
307 JsonParser *parser = ss_json_ringtone_load_from_data();
310 JsonNode *root = json_parser_get_root(parser);
314 int ret = SYSTEM_SETTINGS_ERROR_NONE;
315 if (false == ss_json_ringtone_contain(root, pathval)) {
316 SETTING_TRACE("---> dirname is : %s ", dirname(strdup(pathval)));
317 SETTING_TRACE("---> basename is : %s ", basename(strdup(pathval)));
318 // @todo : MAKE SURE THE ACTUAL FILE IS THERE ON PATHVAL(SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER)
319 ss_json_ringtone_add(root, JSONFILE, pathval, pathval);
320 SETTING_TRACE("pathval is : %s -- OK", pathval);
322 SETTING_TRACE("pathval is duplicated : %s", pathval);
323 SETTING_TRACE("---> dirname is : %s ", dirname(strdup(pathval)));
324 SETTING_TRACE("---> basename is : %s ", basename(strdup(pathval)));
325 ret = SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
329 g_object_unref(parser);
336 int system_setting_del_incoming_call_ringtone(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
339 char* pathval = (char*)value;
342 JsonParser* parser = ss_json_ringtone_open_file(JSONFILE);
344 JsonParser* parser = ss_json_ringtone_load_from_data();
346 JsonNode *root = json_parser_get_root(parser);
348 ss_json_ringtone_remove(root, JSONFILE, pathval);
349 //void ss_json_ringtone_remove(JsonNode *root, char* filename, char* path_to_del)
351 ss_json_ringtone_print(root);
353 g_object_unref(parser);
357 return SYSTEM_SETTINGS_ERROR_NONE;
361 static int _compare_cb(const void *d1, const void *d2)
363 fileNodeInfo *pNode1 = (fileNodeInfo *)d1;
364 fileNodeInfo *pNode2 = (fileNodeInfo *)d2;
366 return strcmp(pNode1->media_name, pNode2->media_name);
370 * get the RINGTONE list
372 static void _get_default_ringtones(system_settings_key_e key, system_setting_data_type_e data_type, system_settings_iter_cb callback, void *data)
376 Eina_List *filelist = NULL;
378 fileNodeInfo *node = NULL;
381 //-----------------------------------------------------------------------------------------------------------------
382 // 1. get the default ringtone list
383 //-----------------------------------------------------------------------------------------------------------------
384 int ret = get_filelist_from_dir_path(DEF_RINGTONE_FILE_PATH, &filelist);
386 SETTING_TRACE("Failed to get filelist, ret = %d %s", ret, DEF_RINGTONE_FILE_PATH);
388 filelist = eina_list_sort(filelist, eina_list_count(filelist), _compare_cb);
390 EINA_LIST_FOREACH(filelist, l, node)
392 SETTING_TRACE("file path = (%d) : name:%s path:%s [%s]", ret, node->name, node->path, node->media_name);
393 // @todo assert NULL check
396 snprintf(temp, 1024, "%s/%s", node->path, node->name);
397 char* path = strdup(temp);
398 bool ret = callback(idx, (void *)(path), data);
404 SETTING_TRACE("quit the iteration by return value == false : %d", ret);
409 SETTING_TRACE("--> system_setting_data_iterator is NULL");
415 EINA_LIST_FOREACH(filelist, l, node)
419 FREE(node->media_name);
422 eina_list_free(filelist);
427 static void _get_user_ringtones(system_settings_key_e key, system_setting_data_type_e data_type, system_settings_iter_cb callback, void *data)
433 JsonParser* parser = ss_json_ringtone_open_file(JSONFILE);
435 JsonParser* parser = ss_json_ringtone_load_from_data();
438 JsonNode *root = json_parser_get_root(parser);
439 int size = json_array_get_length(json_node_get_array(root));
442 for (i = 0; i < size ; i++) {
443 JsonObject *ringtone = json_array_get_object_element(json_node_get_array(root), i);
444 char *nameval = (char *)json_object_get_string_member(ringtone, "name");
445 char *pathval = (char *)json_object_get_string_member(ringtone, "path");
446 SETTING_TRACE("(%s) --- (%s) \n", nameval, pathval);
448 char* path = strdup(pathval);
449 bool ret = callback(i, (void *)(path), data);
451 SETTING_TRACE("quit the iteration by return value == false : %d", ret);
455 SETTING_TRACE("--> callback is NULL");
460 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)
464 _get_default_ringtones(key, data_type, callback, data);
465 //-----------------------------------------------------------------------------------------------------------------
466 // 2. get the USER ringtone list
467 //-----------------------------------------------------------------------------------------------------------------
468 _get_user_ringtones(key, data_type, callback, data);
470 return SYSTEM_SETTINGS_ERROR_NONE;
474 /* LCOV_EXCL_START */
475 int system_setting_set_incoming_call_ringtone(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
479 vconf_value = (char *)value;
481 int ret = _is_file_accessible(vconf_value);
483 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR, vconf_value)) {
484 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
487 /* @todo add a common ret_handler */
491 return SYSTEM_SETTINGS_ERROR_NONE;
496 /* LCOV_EXCL_START */
497 int system_setting_set_email_alert_ringtone(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
501 vconf_value = (char *)value;
503 int ret = _is_file_accessible(vconf_value);
505 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, vconf_value)) {
506 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
509 /*return SYSTEM_SETTINGS_ERROR_IO_ERROR;*/
510 /* @todo add a common ret_handler */
514 return SYSTEM_SETTINGS_ERROR_NONE;
518 /* LCOV_EXCL_START */
519 static bool dl_is_supported_image_type_load(char *path)
524 bool (*image_type_check)(char *path);
526 handle = dlopen(SETTING_UTILS_SO_FILE_PATH, RTLD_LAZY);
528 SETTING_TRACE("ERROR!! canNOT find libsystem-settings-util.so.0.1.0");
532 image_type_check = dlsym(handle, "__is_supported_image_type_load");
533 if ((error = dlerror()) != NULL) {
534 SETTING_TRACE("ERROR!! canNOT find __is_supported_image_type_load function at libsystem-settings-util.so.0.1.0");
539 ret = image_type_check(path);
546 /* LCOV_EXCL_START */
547 static int dl_is_available_font(char *str)
552 int (*check_available_font)(char *font_name);
554 handle = dlopen(SETTING_UTILS_SO_FILE_PATH, RTLD_LAZY);
556 SETTING_TRACE("ERROR!! canNOT find libsystem-settings-util.so.0.1.0");
560 check_available_font = dlsym(handle, "__is_available_font");
561 if ((error = dlerror()) != NULL) {
562 SETTING_TRACE("ERROR!! canNOT find __is_available_font function at libsystem-settings-util.so.0.1.0");
567 ret = check_available_font(str);
574 /* LCOV_EXCL_START */
575 static void dl_font_size_set()
579 void (*set_font_size)();
581 handle = dlopen(SETTING_UTILS_SO_FILE_PATH, RTLD_LAZY);
583 SETTING_TRACE("ERROR!! canNOT find libsystem-settings-util.so.0.1.0");
587 set_font_size = dlsym(handle, "__font_size_set");
588 if ((error = dlerror()) != NULL) {
589 SETTING_TRACE("ERROR!! canNOT find __font_size_set function at libsystem-settings-util.so.0.1.0");
601 /* LCOV_EXCL_START */
602 static void dl_font_config_set_notification()
606 void (*set_font_nodification)();
608 handle = dlopen(SETTING_UTILS_SO_FILE_PATH, RTLD_LAZY);
610 SETTING_TRACE("ERROR!! canNOT find libsystem-settings-util.so.0.1.0");
614 set_font_nodification = dlsym(handle, "font_config_set_notification");
615 if ((error = dlerror()) != NULL) {
616 SETTING_TRACE("ERROR!! canNOT find font_config_set_notification function at libsystem-settings-util.so.0.1.0");
621 set_font_nodification();
628 /* LCOV_EXCL_START */
629 static bool dl_font_config_set(char *font_name)
634 bool (*check_font_type)(char *font_name);
636 handle = dlopen(SETTING_UTILS_SO_FILE_PATH, RTLD_LAZY);
638 SETTING_TRACE("ERROR!! canNOT find libsystem-settings-util.so.0.1.0");
642 check_font_type = dlsym(handle, "font_config_set");
643 if ((error = dlerror()) != NULL) {
644 SETTING_TRACE("ERROR!! canNOT find font_config_set function at libsystem-settings-util.so.0.1.0");
649 ret = check_font_type(font_name);
656 /* LCOV_EXCL_START */
657 static char *dl_get_font_info(char *str)
662 char *(*get_font_info)();
664 handle = dlopen(SETTING_UTILS_SO_FILE_PATH, RTLD_LAZY);
666 SETTING_TRACE("ERROR!! canNOT find libsystem-settings-util.so.0.1.0");
670 if (strcmp(str, "cur") == 0)
671 get_font_info = dlsym(handle, "_get_cur_font");
673 get_font_info = dlsym(handle, "_get_default_font");
675 if ((error = dlerror()) != NULL) {
676 SETTING_TRACE("ERROR!! canNOT find %s function at libsystem-settings-util.so.0.1.0", str);
681 ret = get_font_info();
688 /* LCOV_EXCL_START */
689 #define PATH_EXT_CHECK_REG ".(jpe?g|jpg|png|gif)$"
690 bool __is_supported_image_type_by_ext(char *file_path)
694 regmatch_t str[2048 + 1];
696 if (!file_path) return false;
699 if ((ret = regcomp(&fsm, PATH_EXT_CHECK_REG, REG_ICASE | REG_EXTENDED))) {
700 SETTING_TRACE("regular expresstion fail");
705 if (regexec(&fsm, file_path, strlen(file_path) + 1, str, 0) == REG_NOMATCH) {
706 /*SETTING_TRACE("FAILED - %s", file_path[i]); */
709 /*SETTING_TRACE("MATCHED - %s", file_path[i]); */
715 #ifdef TIZEN_WEARABLE
716 /* LCOV_EXCL_START */
717 static int system_setting_get_extended_wallpaper_num(const char *file_path, unsigned int *num)
721 const char *find_str = "extended_wallpaper_";
724 if (!(ch = strstr(file_path, find_str))) {
725 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
727 strncpy(buffer, file_path, ch - file_path);
728 buffer[ch - file_path] = 0;
729 sprintf(buffer + (ch - file_path), "%s%s", "", ch + strlen(find_str));
731 if (!isdigit(buffer[0])) {
732 SETTING_TRACE("%s is not number", buffer);
733 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
738 return SYSTEM_SETTINGS_ERROR_NONE;
742 /* LCOV_EXCL_START */
743 static int system_setting_copy_extended_wallpaper(const char *dest_file_path, const char *source_file_path)
746 if (!source_file_path || !dest_file_path) {
747 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
753 fd = open(source_file_path, O_RDONLY);
755 SETTING_TRACE("file open failed: %s", source_file_path);
756 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
760 fd2 = open(dest_file_path, O_WRONLY | O_CREAT, S_IRWXU | S_IRWXG | S_IRWXO);
762 SETTING_TRACE("file creation failed: %s", dest_file_path);
764 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
767 while (read(fd, buf, sizeof(buf) - 1) > 0) {
768 write(fd2, buf, sizeof(buf) - 1);
774 if (chmod(dest_file_path, S_IRWXU | S_IRWXG | S_IRWXO) < 0) {
775 SETTING_TRACE("chmod failed: %s", dest_file_path);
778 return SYSTEM_SETTINGS_ERROR_NONE;
782 /* LCOV_EXCL_START */
783 static int system_setting_remove_oldest_extended_wallpaper()
788 char *min_image_name = NULL;
789 unsigned int min_image_num = 0;
790 unsigned int temp_image_num = 0;
793 if ((dp = opendir(_TZ_SYS_DATA"/setting/wallpaper")) == NULL) {
794 SETTING_TRACE("opendir error");
795 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
798 while ((dirp = readdir(dp))) {
799 if (!strcmp(dirp->d_name, ".") || !strcmp(dirp->d_name, ".."))
802 if (system_setting_get_extended_wallpaper_num(dirp->d_name, &temp_image_num)
803 != SYSTEM_SETTINGS_ERROR_NONE) {
804 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
807 if ((image_count == 0) || (min_image_num > temp_image_num)) {
808 min_image_num = temp_image_num;
809 min_image_name = dirp->d_name;
816 if (min_image_name) {
817 snprintf(buf, sizeof(buf) - 1, _TZ_SYS_DATA"/setting/wallpaper/%s", min_image_name);
818 if (remove(buf) < 0) { /* remove oldest image */
819 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
823 return SYSTEM_SETTINGS_ERROR_NONE;
827 /* LCOV_EXCL_START */
828 static int system_setting_check_extended_wallpaper(const char *file_path)
832 if (!file_path || !strlen(file_path))
834 snprintf(buffer, 512, "%s/.bgwallpaper", tzplatform_getenv(TZ_USER_CONTENT));
835 return (strstr(file_path, buffer) != NULL);
839 #define WALLPAPER_MAX_COUNT 10
841 /* LCOV_EXCL_START */
842 int system_setting_set_wallpaper_home_screen(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
846 vconf_value = (char *)value;
848 bool isok = dl_is_supported_image_type_load(vconf_value);
851 SETTING_TRACE("path : %s is not supported file format", vconf_value);
852 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
854 SETTING_TRACE("path : %s is SUPPORT file format", vconf_value);
857 /* error handling here */
858 if (_is_file_accessible(vconf_value) != 0)
859 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
861 if (system_setting_vconf_set_value_string(VCONFKEY_BGSET, vconf_value)) {
862 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
866 #ifdef TIZEN_WEARABLE
867 if (system_setting_check_extended_wallpaper(vconf_value)) { /* New extended wallpaper */
870 unsigned int max_image_num = 0;
871 unsigned int temp_image_num = 0;
874 if ((dp = opendir(_TZ_SYS_DATA"/setting/wallpaper")) == NULL) {
875 SETTING_TRACE("Setting - dir open error!");
876 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
879 /* Check a max number of wallpapers */
880 while ((dirp = readdir(dp))) {
881 if (!strcmp(dirp->d_name, ".") || !strcmp(dirp->d_name, ".."))
884 if (system_setting_get_extended_wallpaper_num(dirp->d_name, &temp_image_num)
885 != SYSTEM_SETTINGS_ERROR_NONE) {
888 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
891 if ((image_count == 0) || (max_image_num < temp_image_num)) {
892 max_image_num = temp_image_num;
900 /* Numbering rule: Gear is odd number */
901 max_image_num = (max_image_num % 2 == 0) ? max_image_num + 1
904 char file_name_buffer[512];
905 snprintf(file_name_buffer, sizeof(file_name_buffer) - 1,
906 _TZ_SYS_DATA"/setting/wallpaper/extended_wallpaper_%d.jpg", max_image_num);
908 /* Copy image to _TZ_SYS_DATA/setting/wallpaper/ */
909 if (system_setting_copy_extended_wallpaper(file_name_buffer, vconf_value)
910 != SYSTEM_SETTINGS_ERROR_NONE) {
911 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
914 /* remove oldest wallpaper */
915 if (image_count >= WALLPAPER_MAX_COUNT) {
916 if (system_setting_remove_oldest_extended_wallpaper()
917 != SYSTEM_SETTINGS_ERROR_NONE) {
918 remove(file_name_buffer);
919 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
923 if (system_setting_vconf_set_value_string(VCONFKEY_BGSET, file_name_buffer)) {
924 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
927 if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_WALLPAPER_CHANGED_NOTI_INT,
928 VCONFKEY_WALLPAPER_CHANGED_NOTI_GEAR)) {
929 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
932 if (system_setting_vconf_set_value_string(VCONFKEY_BGSET, vconf_value)) {
933 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
938 return SYSTEM_SETTINGS_ERROR_NONE;
942 /* LCOV_EXCL_START */
943 int system_setting_set_wallpaper_lock_screen(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
947 vconf_value = (char *)value;
949 bool isok = dl_is_supported_image_type_load(vconf_value);
952 SETTING_TRACE("path : %s is not supported file format", vconf_value);
953 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
955 SETTING_TRACE("path : %s is SUPPORT file format", vconf_value);
958 /* error handling here */
959 if (_is_file_accessible(vconf_value) != 0)
960 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
962 if (system_setting_vconf_set_value_string(VCONFKEY_IDLE_LOCK_BGSET, vconf_value)) {
963 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
966 return SYSTEM_SETTINGS_ERROR_NONE;
970 /* LCOV_EXCL_START */
971 int system_setting_set_font_size(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
975 vconf_value = *(int **)value;
977 if (*vconf_value < 0 || *vconf_value > SYSTEM_SETTINGS_FONT_SIZE_GIANT) {
978 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
981 if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, *vconf_value)) {
982 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
986 return SYSTEM_SETTINGS_ERROR_NONE;
992 /* LCOV_EXCL_START */
993 void *font_conf_doc_parse(char *doc_name, char *font_name)
996 xmlDocPtr doc = NULL;
997 xmlNodePtr cur = NULL;
998 xmlNodePtr cur2 = NULL;
999 xmlNodePtr cur3 = NULL;
1000 xmlChar *key = NULL;
1002 doc = xmlParseFile(doc_name);
1004 cur = xmlDocGetRootElement(doc);
1012 if (xmlStrcmp(cur->name, (const xmlChar *)"fontconfig")) {
1018 cur = cur->xmlChildrenNode;
1020 bool is_changed = false;
1021 while (cur != NULL) {
1022 if ((!xmlStrcmp(cur->name, (const xmlChar *)"match"))) {
1023 cur2 = cur->xmlChildrenNode;
1024 while (cur2 != NULL) {
1025 if ((!xmlStrcmp(cur2->name, (const xmlChar *)"edit"))) {
1026 xmlChar *name = xmlGetProp(cur2, (const xmlChar *)"name");
1027 /* if name is not 'family', break */
1028 if (xmlStrcmp(name, (const xmlChar *)"family")) {
1036 cur3 = cur2->xmlChildrenNode;
1037 while (cur3 != NULL) {
1038 if ((!xmlStrcmp(cur3->name, (const xmlChar *)"string"))) {
1039 xmlNodeSetContent(cur3->xmlChildrenNode, (const xmlChar *)font_name);
1040 key = xmlNodeListGetString(doc, cur3->xmlChildrenNode, 1);
1050 } else if ((!xmlStrcmp(cur->name, (const xmlChar *)"alias"))) {
1051 cur2 = cur->xmlChildrenNode;
1052 while (cur2 != NULL) {
1053 if ((!xmlStrcmp(cur2->name, (const xmlChar *)"family"))) {
1054 xmlNodeSetContent(cur2->xmlChildrenNode, (const xmlChar *)font_name);
1055 key = xmlNodeListGetString(doc, cur2->xmlChildrenNode, 1);
1059 } else if ((!xmlStrcmp(cur2->name, (const xmlChar *)"prefer"))) {
1060 cur3 = cur2->xmlChildrenNode;
1061 while (cur3 != NULL) {
1062 if ((!xmlStrcmp(cur3->name, (const xmlChar *)"family"))) {
1063 xmlNodeSetContent(cur3->xmlChildrenNode, (const xmlChar *)font_name);
1064 key = xmlNodeListGetString(doc, cur3->xmlChildrenNode, 1);
1088 /* LCOV_EXCL_STOP */
1090 /* LCOV_EXCL_START */
1091 int system_setting_set_font_type(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1093 SETTING_TRACE_BEGIN;
1094 char *font_name = NULL;
1095 font_name = (char *)value;
1097 /* get current font list */
1098 int is_found = dl_is_available_font(font_name);
1101 SETTING_TRACE("found font : %s ", font_name);
1103 SETTING_TRACE(" NOT found font : %s ", font_name);
1104 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1107 bool bsave = dl_font_config_set(font_name);
1110 SETTING_TRACE(" font type save error by font_config_set() ");
1111 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1113 SETTING_TRACE(" save OK - font_config_set() ");
1116 xmlDocPtr doc = (xmlDocPtr)font_conf_doc_parse(SETTING_FONT_CONF_FILE, font_name);
1118 xmlSaveFormatFile(SETTING_FONT_CONF_FILE, doc, 0);
1123 dl_font_config_set_notification();
1126 vconf_value = (char *)value;
1128 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, vconf_value)) {
1129 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1131 return SYSTEM_SETTINGS_ERROR_NONE;
1133 /* LCOV_EXCL_STOP */
1135 /* LCOV_EXCL_START */
1136 int system_setting_set_motion_activation(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1138 SETTING_TRACE_BEGIN;
1140 vconf_value = (bool *)value;
1141 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_MOTION_ACTIVATION, *vconf_value)) {
1142 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1144 return SYSTEM_SETTINGS_ERROR_NONE;
1146 /* LCOV_EXCL_STOP */
1148 /* LCOV_EXCL_START */
1149 int system_setting_set_usb_debugging_option(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1151 SETTING_TRACE_BEGIN;
1153 vconf_value = (bool *)value;
1154 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_USB_DEBUG_MODE_BOOL, *vconf_value)) {
1155 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1157 return SYSTEM_SETTINGS_ERROR_NONE;
1160 /* LCOV_EXCL_STOP */
1162 /* LCOV_EXCL_START */
1163 int system_setting_set_3g_data_network(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1165 SETTING_TRACE_BEGIN;
1167 vconf_value = (bool *)value;
1168 if (system_setting_vconf_set_value_bool(VCONFKEY_3G_ENABLE, *vconf_value)) {
1169 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1172 return SYSTEM_SETTINGS_ERROR_NONE;
1174 /* LCOV_EXCL_STOP */
1176 /* LCOV_EXCL_START */
1177 static int category_func(const char *name, void *user_data)
1179 SETTING_TRACE_BEGIN;
1180 static char *category = "lock-screen";
1181 if (name && !strcmp(name, category)) {
1182 SETTING_TRACE(" SAME ");
1185 SETTING_TRACE(" DIFFERENT -- %s, category -- %s ", name, category);
1191 /* LCOV_EXCL_STOP */
1195 * set 'swipe type' if current lockscreen app is 'com.samsung.lockscreen'
1199 /* LCOV_EXCL_START */
1200 int system_setting_set_lockscreen_app(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1202 SETTING_TRACE_BEGIN;
1204 vconf_value = (char *)value; /* ex) com.samsung.lockscreen */
1207 pkgmgrinfo_appinfo_h handle;
1208 r = pkgmgrinfo_appinfo_get_appinfo(vconf_value, &handle);
1209 if (r != PMINFO_R_OK) {
1210 SETTING_TRACE("*** pkginfo failed ");
1211 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
1213 SETTING_TRACE("%x", handle);
1216 int ret = pkgmgrinfo_appinfo_foreach_category(handle, category_func, (void *)"lock-screen");
1217 if (ret != PMINFO_R_OK) {
1218 pkgmgrinfo_appinfo_destroy_appinfo(handle);
1219 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
1222 pkgmgrinfo_appinfo_destroy_appinfo(handle);
1223 /*----------------------------------------------------------------------------------- */
1225 if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_SCREEN_LOCK_TYPE_INT, &locktype)) {
1226 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1229 if (locktype == SETTING_SCREEN_LOCK_TYPE_PASSWORD)
1230 return SYSTEM_SETTINGS_ERROR_LOCKSCREEN_APP_PASSWORD_MODE;
1232 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_3RD_LOCK_PKG_NAME_STR, vconf_value)) {
1233 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1236 if (vconf_value && strcmp(vconf_value, "com.samsung.lockscreen") == 0) {
1237 if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_SCREEN_LOCK_TYPE_INT, SETTING_SCREEN_LOCK_TYPE_SWIPE)) {
1238 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1241 return SYSTEM_SETTINGS_ERROR_NONE;
1243 /* LCOV_EXCL_STOP */
1245 /*/////////////////////////////////////////////////////////////////////////////////////////////// */
1248 int system_setting_set_changed_callback_incoming_call_ringtone(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1250 SETTING_TRACE_BEGIN;
1251 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR, SYSTEM_SETTINGS_KEY_INCOMING_CALL_RINGTONE, 0, user_data);
1254 int system_setting_unset_changed_callback_incoming_call_ringtone(system_settings_key_e key)
1256 SETTING_TRACE_BEGIN;
1257 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR, 0);
1260 int system_setting_set_changed_callback_email_alert_ringtone(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1262 SETTING_TRACE_BEGIN;
1263 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, SYSTEM_SETTINGS_KEY_EMAIL_ALERT_RINGTONE, 0, user_data);
1266 int system_setting_unset_changed_callback_email_alert_ringtone(system_settings_key_e key)
1268 SETTING_TRACE_BEGIN;
1269 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, 0);
1272 int system_setting_set_changed_callback_wallpaper_home_screen(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1274 SETTING_TRACE_BEGIN;
1275 return system_setting_vconf_set_changed_cb(VCONFKEY_BGSET, SYSTEM_SETTINGS_KEY_WALLPAPER_HOME_SCREEN, 0, user_data);
1278 int system_setting_unset_changed_callback_wallpaper_home_screen(system_settings_key_e key)
1280 SETTING_TRACE_BEGIN;
1281 return system_setting_vconf_unset_changed_cb(VCONFKEY_BGSET, 0);
1284 int system_setting_set_changed_callback_wallpaper_lock_screen(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1286 SETTING_TRACE_BEGIN;
1287 return system_setting_vconf_set_changed_cb(VCONFKEY_IDLE_LOCK_BGSET, SYSTEM_SETTINGS_KEY_WALLPAPER_LOCK_SCREEN, 0, user_data);
1290 int system_setting_unset_changed_callback_wallpaper_lock_screen(system_settings_key_e key)
1292 SETTING_TRACE_BEGIN;
1293 return system_setting_vconf_unset_changed_cb(VCONFKEY_IDLE_LOCK_BGSET, 0);
1296 int system_setting_set_changed_callback_font_size(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1298 SETTING_TRACE_BEGIN;
1299 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, SYSTEM_SETTINGS_KEY_FONT_SIZE, 1, user_data);
1302 int system_setting_unset_changed_callback_font_size(system_settings_key_e key)
1304 SETTING_TRACE_BEGIN;
1305 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, 1);
1308 int system_setting_set_changed_callback_usb_debugging_option(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1310 SETTING_TRACE_BEGIN;
1311 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_USB_DEBUG_MODE_BOOL, SYSTEM_SETTINGS_KEY_USB_DEBUGGING_ENABLED, 1, user_data);
1314 int system_setting_unset_changed_callback_usb_debugging_option(system_settings_key_e key)
1316 SETTING_TRACE_BEGIN;
1317 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_USB_DEBUG_MODE_BOOL, 1);
1320 int system_setting_set_changed_callback_3g_data_network(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1322 SETTING_TRACE_BEGIN;
1323 return system_setting_vconf_set_changed_cb(VCONFKEY_3G_ENABLE, SYSTEM_SETTINGS_KEY_3G_DATA_NETWORK_ENABLED, 1, user_data);
1326 int system_setting_unset_changed_callback_3g_data_network(system_settings_key_e key)
1328 SETTING_TRACE_BEGIN;
1329 return system_setting_vconf_unset_changed_cb(VCONFKEY_3G_ENABLE, 1);
1332 int system_setting_set_changed_callback_lockscreen_app(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1334 SETTING_TRACE_BEGIN;
1335 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_3RD_LOCK_PKG_NAME_STR, SYSTEM_SETTINGS_KEY_LOCKSCREEN_APP, 1, user_data);
1338 int system_setting_unset_changed_callback_lockscreen_app(system_settings_key_e key)
1340 SETTING_TRACE_BEGIN;
1341 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_3RD_LOCK_PKG_NAME_STR, 1);
1346 * @todo need to add custom event notification method
1348 int system_setting_set_changed_callback_font_type(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1350 SETTING_TRACE_BEGIN;
1351 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, SYSTEM_SETTINGS_KEY_FONT_TYPE, 2, user_data);
1354 int system_setting_unset_changed_callback_font_type(system_settings_key_e key)
1356 SETTING_TRACE_BEGIN;
1357 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, 2);
1360 /* TODO : 2th argument, callback, is not in use. */
1361 int system_setting_set_changed_callback_motion_activation(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1363 SETTING_TRACE_BEGIN;
1364 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_MOTION_ACTIVATION, SYSTEM_SETTINGS_KEY_MOTION_ACTIVATION, 3, user_data);
1367 int system_setting_unset_changed_callback_motion_activation(system_settings_key_e key)
1369 SETTING_TRACE_BEGIN;
1370 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_MOTION_ACTIVATION, 3);
1373 /*//////////////////////////////////////////////////////////////////////////////////////// */
1374 /*--------------------------------------- */
1375 int system_setting_get_locale_country(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1377 SETTING_TRACE_BEGIN;
1378 char *vconf_value = NULL;
1379 if (system_setting_vconf_get_value_string(VCONFKEY_REGIONFORMAT, &vconf_value)) {
1380 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1383 /* parsing validation */
1386 snprintf(arr, 20, "%s", vconf_value);
1388 *value = strdup(arr);
1392 return SYSTEM_SETTINGS_ERROR_NONE;
1395 /* LCOV_EXCL_START */
1396 int system_setting_set_locale_country(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1398 SETTING_TRACE_BEGIN;
1399 char *vconf_value = NULL;
1400 vconf_value = (char *)value;
1402 char *ext = "UTF-8";
1405 snprintf(arr, 20, "%s.%s", vconf_value, ext);
1407 if (system_setting_vconf_set_value_string(VCONFKEY_REGIONFORMAT, arr)) {
1408 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1410 return SYSTEM_SETTINGS_ERROR_NONE;
1412 /* LCOV_EXCL_STOP */
1414 int system_setting_set_changed_callback_locale_country(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1416 SETTING_TRACE_BEGIN;
1417 return system_setting_vconf_set_changed_cb(VCONFKEY_REGIONFORMAT, SYSTEM_SETTINGS_KEY_LOCALE_COUNTRY, 3, user_data);
1420 int system_setting_unset_changed_callback_locale_country(system_settings_key_e key)
1422 SETTING_TRACE_BEGIN;
1423 return system_setting_vconf_unset_changed_cb(VCONFKEY_REGIONFORMAT, 3);
1427 /*--------------------------------------- */
1428 int system_setting_get_locale_language(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1430 SETTING_TRACE_BEGIN;
1431 char *vconf_value = NULL;
1432 if (system_setting_vconf_get_value_string(VCONFKEY_LANGSET, &vconf_value)) {
1433 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1436 /* parsing validation */
1439 snprintf(arr, 20, "%s", vconf_value);
1441 *value = strdup(arr);
1444 return SYSTEM_SETTINGS_ERROR_NONE;
1447 /* LCOV_EXCL_START */
1448 int system_setting_set_locale_language(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1450 SETTING_TRACE_BEGIN;
1451 char *vconf_value = NULL;
1452 vconf_value = (char *)value;
1454 char *ext = "UTF-8";
1457 snprintf(arr, 20, "%s.%s", vconf_value, ext);
1459 if (system_setting_vconf_set_value_string(VCONFKEY_LANGSET, arr)) {
1460 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1462 return SYSTEM_SETTINGS_ERROR_NONE;
1464 /* LCOV_EXCL_STOP */
1466 int system_setting_set_changed_callback_locale_language(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1468 SETTING_TRACE_BEGIN;
1469 /*return system_setting_vconf_set_changed_cb(VCONFKEY_LANGSET, SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, 3, user_data ); */
1470 return system_setting_vconf_set_changed_cb(VCONFKEY_LANGSET, SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, 100, user_data);
1473 int system_setting_unset_changed_callback_locale_language(system_settings_key_e key)
1475 SETTING_TRACE_BEGIN;
1476 return system_setting_vconf_unset_changed_cb(VCONFKEY_LANGSET, 100);
1479 /*--------------------------------------- */
1480 /* LCOV_EXCL_START */
1481 int system_setting_get_locale_timeformat_24hour(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1483 SETTING_TRACE_BEGIN;
1486 if (system_setting_vconf_get_value_int(VCONFKEY_REGIONFORMAT_TIME1224, &vconf_value)) {
1487 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1490 bool ret_value = true;
1491 if (vconf_value == VCONFKEY_TIME_FORMAT_12)
1493 else if (vconf_value == VCONFKEY_TIME_FORMAT_24)
1496 *value = (void *)ret_value;
1498 return SYSTEM_SETTINGS_ERROR_NONE;
1500 /* LCOV_EXCL_STOP */
1502 int system_setting_set_locale_timeformat_24hour(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1504 SETTING_TRACE_BEGIN;
1507 vconf_value = (bool *)value;
1510 if (system_setting_vconf_set_value_int(VCONFKEY_REGIONFORMAT_TIME1224, VCONFKEY_TIME_FORMAT_24)) {
1511 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1515 if (system_setting_vconf_set_value_int(VCONFKEY_REGIONFORMAT_TIME1224, VCONFKEY_TIME_FORMAT_12)) {
1516 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1521 return SYSTEM_SETTINGS_ERROR_NONE;
1524 int system_setting_set_changed_callback_locale_timeformat_24hour(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1526 SETTING_TRACE_BEGIN;
1527 return system_setting_vconf_set_changed_cb(VCONFKEY_REGIONFORMAT_TIME1224, SYSTEM_SETTINGS_KEY_LOCALE_TIMEFORMAT_24HOUR, 3, user_data);
1530 int system_setting_unset_changed_callback_locale_timeformat_24hour(system_settings_key_e key)
1532 SETTING_TRACE_BEGIN;
1533 return system_setting_vconf_unset_changed_cb(VCONFKEY_REGIONFORMAT_TIME1224, 3);
1536 int system_setting_get_locale_timezone(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1539 ssize_t len = readlink(SETTING_TZONE_SYMLINK_PATH, tzpath, sizeof(tzpath)-1);
1543 SETTING_TRACE("parse error for SETTING_TZONE_SYMLINK_PATH");
1544 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1547 SETTING_TRACE("tzpath : %s ", &tzpath[20]);
1548 *value = strdup(&tzpath[20]);
1549 return SYSTEM_SETTINGS_ERROR_NONE;
1552 /* LCOV_EXCL_START */
1553 int system_setting_set_locale_timezone(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1555 SETTING_TRACE_BEGIN;
1556 char *timezone_value = NULL;
1557 timezone_value = (char *)value;
1560 snprintf(tz_path, 1024, "/usr/share/zoneinfo/%s", timezone_value);
1562 int is_load = _is_file_accessible(tz_path);
1564 alarmmgr_set_timezone(tz_path);
1566 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_TIMEZONE_ID, timezone_value)) {
1567 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1569 return SYSTEM_SETTINGS_ERROR_NONE;
1571 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
1573 /* LCOV_EXCL_STOP */
1577 /* LCOV_EXCL_START */
1578 int system_setting_set_changed_callback_locale_timezone(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1580 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_TIMEZONE_ID, SYSTEM_SETTINGS_KEY_LOCALE_TIMEZONE, 4, user_data);
1582 /* LCOV_EXCL_STOP */
1584 /* LCOV_EXCL_START */
1585 int system_setting_unset_changed_callback_locale_timezone(system_settings_key_e key)
1587 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_TIMEZONE_ID, 4);
1589 /* LCOV_EXCL_STOP */
1591 /* LCOV_EXCL_START */
1592 int system_setting_set_changed_callback_locale_timezone_changed(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1594 SETTING_TRACE_BEGIN;
1595 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
1597 /* LCOV_EXCL_STOP */
1599 /* LCOV_EXCL_START */
1600 int system_setting_unset_changed_callback_locale_timezone_changed(system_settings_key_e key)
1602 SETTING_TRACE_BEGIN;
1603 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
1605 /* LCOV_EXCL_STOP */
1608 /* LCOV_EXCL_START */
1609 int system_setting_get_time_changed(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1611 SETTING_TRACE_BEGIN;
1613 int ** val = (int**)value;
1614 cur_tick = time(NULL);
1616 /* struct tm * localtime = time (cur_tick); */
1617 /* printf("%s\n", ctime(&cur_tick); */
1618 return SYSTEM_SETTINGS_ERROR_NONE;
1621 /* LCOV_EXCL_STOP */
1623 int system_setting_set_changed_callback_time_changed(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1625 SETTING_TRACE_BEGIN;
1626 return system_setting_vconf_set_changed_cb(VCONFKEY_SYSTEM_TIME_CHANGED, SYSTEM_SETTINGS_KEY_TIME_CHANGED, 3, user_data);
1629 int system_setting_unset_changed_callback_time_changed(system_settings_key_e key)
1631 SETTING_TRACE_BEGIN;
1632 return system_setting_vconf_unset_changed_cb(VCONFKEY_SYSTEM_TIME_CHANGED, 3);
1637 /* SYSTEM_SETTINGS_KEY_SOUND_LOCK */
1638 int system_setting_get_sound_lock(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1640 SETTING_TRACE_BEGIN;
1643 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_SOUND_LOCK_BOOL, &vconf_value)) {
1644 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1646 *value = (void *)vconf_value;
1648 return SYSTEM_SETTINGS_ERROR_NONE;
1651 int system_setting_set_changed_callback_sound_lock(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1653 SETTING_TRACE_BEGIN;
1654 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_SOUND_LOCK_BOOL, SYSTEM_SETTINGS_KEY_SOUND_LOCK, 3, user_data);
1657 int system_setting_unset_changed_callback_sound_lock(system_settings_key_e key)
1659 SETTING_TRACE_BEGIN;
1660 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_SOUND_LOCK_BOOL, 3);
1664 * a = VCONFKEY_SETAPPL_SOUND_STATUS_BOOL b = VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL
1666 * a == false, b == false --> silent mode
1667 * a == true, b == false --> sound mode
1668 * a == false, b == true --> vibration mode
1670 /* LCOV_EXCL_START */
1671 int system_setting_get_sound_silent_mode(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1673 SETTING_TRACE_BEGIN;
1678 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, &sound_cond)) {
1679 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1682 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, &vib_cond)) {
1683 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1686 if (sound_cond == false && vib_cond == false) {
1688 *value = (void *)vconf_value;
1690 vconf_value = false;
1691 *value = (void *)vconf_value;
1693 return SYSTEM_SETTINGS_ERROR_NONE;
1695 /* LCOV_EXCL_STOP */
1698 * a = VCONFKEY_SETAPPL_SOUND_STATUS_BOOL b = VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL
1700 * a == false, b == false --> silent mode
1701 * a == true, b == false --> sound mode
1703 int system_setting_set_sound_silent_mode(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1705 SETTING_TRACE_BEGIN;
1708 vconf_value = (bool *)value;
1710 bool vconf_sound = false;
1711 bool vconf_vib = false;
1714 vconf_sound = false;
1721 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, vconf_sound)) {
1722 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1724 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, vconf_vib)) {
1725 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1728 return SYSTEM_SETTINGS_ERROR_NONE;
1734 int system_setting_set_changed_callback_sound_silent_mode(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1736 SETTING_TRACE_BEGIN;
1737 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, SYSTEM_SETTINGS_KEY_SOUND_SILENT_MODE, 3, user_data);
1741 int system_setting_unset_changed_callback_sound_silent_mode(system_settings_key_e key)
1743 SETTING_TRACE_BEGIN;
1744 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, 3);
1747 /* SYSTEM_SETTINGS_KEY_SOUND_TOUCH */
1748 int system_setting_get_sound_touch(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1750 SETTING_TRACE_BEGIN;
1753 int ret = system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL, &vconf_value);
1754 if (ret != SYSTEM_SETTINGS_ERROR_NONE) {
1757 *value = (void *)vconf_value;
1761 int system_setting_set_changed_callback_sound_touch(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1763 SETTING_TRACE_BEGIN;
1764 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL, SYSTEM_SETTINGS_KEY_SOUND_TOUCH, 2, user_data);
1767 int system_setting_unset_changed_callback_sound_touch(system_settings_key_e key)
1769 SETTING_TRACE_BEGIN;
1770 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL, 2);
1774 /* SYSTEM_SETTINGS_KEY_SOUND_LOCK */
1775 int system_setting_get_sound_lock(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1779 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_SOUND_LOCK_BOOL, &vconf_value)) {
1780 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1782 *value = (void *)vconf_value;
1784 return SYSTEM_SETTINGS_ERROR_NONE;
1788 int system_setting_get_auto_rotation_mode(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1790 SETTING_TRACE_BEGIN;
1793 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, &vconf_value)) {
1794 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1796 *value = (void *)vconf_value;
1798 return SYSTEM_SETTINGS_ERROR_NONE;
1801 /* LCOV_EXCL_START */
1802 int system_setting_set_auto_rotation_mode(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1804 SETTING_TRACE_BEGIN;
1806 vconf_value = (bool *)value;
1807 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, *vconf_value)) {
1808 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1811 return SYSTEM_SETTINGS_ERROR_NONE;
1813 /* LCOV_EXCL_STOP */
1815 int system_setting_set_changed_callback_auto_rotation_mode(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1817 SETTING_TRACE_BEGIN;
1818 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, SYSTEM_SETTINGS_KEY_DISPLAY_SCREEN_ROTATION_AUTO, 2, user_data);
1821 int system_setting_unset_changed_callback_auto_rotation_mode(system_settings_key_e key)
1823 SETTING_TRACE_BEGIN;
1824 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, 2);
1827 int system_setting_get_screen_backlight_time(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1829 SETTING_TRACE_BEGIN;
1831 int ** val = (int**)value;
1833 if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, &vconf_value)) {
1834 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1836 **val = vconf_value;
1838 return SYSTEM_SETTINGS_ERROR_NONE;
1842 /* LCOV_EXCL_START */
1843 int system_setting_set_screen_backlight_time(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1845 SETTING_TRACE_BEGIN;
1847 vconf_value = *(int **)value;
1849 if (!(*vconf_value > 0 && *vconf_value <= 600)) {
1850 SETTING_TRACE(" ERR Betweeny here 0 ~ 600");
1851 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
1854 if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, *vconf_value)) {
1855 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1858 return SYSTEM_SETTINGS_ERROR_NONE;
1860 /* LCOV_EXCL_STOP */
1862 int system_setting_set_changed_callback_screen_backlight_time(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1864 SETTING_TRACE_BEGIN;
1865 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, SYSTEM_SETTINGS_KEY_SCREEN_BACKLIGHT_TIME, 2, user_data);
1868 int system_setting_unset_changed_callback_screen_backlight_time(system_settings_key_e key)
1870 SETTING_TRACE_BEGIN;
1871 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, 2);
1874 int system_setting_get_sound_notification(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1876 SETTING_TRACE_BEGIN;
1877 char *vconf_value = NULL;
1878 if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, &vconf_value)) {
1879 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1882 *value = vconf_value;
1883 return SYSTEM_SETTINGS_ERROR_NONE;
1886 /* LCOV_EXCL_START */
1887 int system_setting_set_sound_notification(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1889 SETTING_TRACE_BEGIN;
1890 char *vconf_value = NULL;
1891 vconf_value = (char *)value;
1893 int is_load = _is_file_accessible(vconf_value);
1895 //SETTING_TRACE(" system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, %s) TRY", vconf_value);
1896 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, vconf_value)) {
1897 //SETTING_TRACE(" system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, %s) FAIL", vconf_value);
1898 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1901 //SETTING_TRACE(" is_file_accessibile FAILED - system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, %s) FAIL", vconf_value);
1902 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1905 return SYSTEM_SETTINGS_ERROR_NONE;
1907 /* LCOV_EXCL_STOP */
1909 int system_setting_set_changed_callback_sound_notification(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1911 SETTING_TRACE_BEGIN;
1912 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, SYSTEM_SETTINGS_KEY_SOUND_NOTIFICATION, 0, user_data);
1915 int system_setting_unset_changed_callback_sound_notification(system_settings_key_e key)
1917 SETTING_TRACE_BEGIN;
1918 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, 0);
1921 int system_setting_get_notification_repetition_period(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1923 SETTING_TRACE_BEGIN;
1924 int ** val = (int**)value;
1927 if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_NOTI_MSG_ALERT_REP_TYPE_INT, &vconf_value)) {
1928 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1930 **val = vconf_value;
1932 return SYSTEM_SETTINGS_ERROR_NONE;
1935 /* LCOV_EXCL_START */
1936 int system_setting_set_notification_repetition_period(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1938 SETTING_TRACE_BEGIN;
1940 vconf_value = *(int **)value;
1942 if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_NOTI_MSG_ALERT_REP_TYPE_INT, *vconf_value)) {
1943 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1946 return SYSTEM_SETTINGS_ERROR_NONE;
1948 /* LCOV_EXCL_STOP */
1950 int system_setting_set_changed_callback_notification_repetition_period(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1952 SETTING_TRACE_BEGIN;
1953 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);
1956 int system_setting_unset_changed_callback_notification_repetition_period(system_settings_key_e key)
1958 SETTING_TRACE_BEGIN;
1959 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_ALERT_REP_TYPE_INT, 1);
1962 int system_setting_get_device_name(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1964 SETTING_TRACE_BEGIN;
1965 char *vconf_value = NULL;
1966 if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_DEVICE_NAME_STR, &vconf_value)) {
1967 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1970 *value = vconf_value;
1971 return SYSTEM_SETTINGS_ERROR_NONE;
1974 /* LCOV_EXCL_START */
1975 int system_setting_set_device_name(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1977 SETTING_TRACE_BEGIN;
1978 char *vconf_value = NULL;
1979 vconf_value = (char *)value;
1981 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_DEVICE_NAME_STR, vconf_value)) {
1982 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1985 return SYSTEM_SETTINGS_ERROR_NONE;
1987 /* LCOV_EXCL_STOP */
1989 int system_setting_set_changed_callback_device_name(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1991 SETTING_TRACE_BEGIN;
1992 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_DEVICE_NAME_STR, SYSTEM_SETTINGS_KEY_DEVICE_NAME, 0, user_data);
1995 int system_setting_unset_changed_callback_device_name(system_settings_key_e key)
1997 SETTING_TRACE_BEGIN;
1998 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_DEVICE_NAME_STR, 0);
2001 /*---------------------------------------------- */
2002 int system_setting_get_network_flight_mode(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
2004 SETTING_TRACE_BEGIN;
2006 if (system_setting_vconf_get_value_bool(VCONFKEY_TELEPHONY_FLIGHT_MODE, &vconf_value)) {
2007 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2009 *value = (void *)vconf_value;
2011 return SYSTEM_SETTINGS_ERROR_NONE;
2014 int system_setting_set_changed_callback_network_flight_mode(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
2016 SETTING_TRACE_BEGIN;
2017 return system_setting_vconf_set_changed_cb(VCONFKEY_TELEPHONY_FLIGHT_MODE, SYSTEM_SETTINGS_KEY_NETWORK_FLIGHT_MODE, 3, user_data);
2020 int system_setting_unset_changed_callback_network_flight_mode(system_settings_key_e key)
2022 SETTING_TRACE_BEGIN;
2023 return system_setting_vconf_unset_changed_cb(VCONFKEY_TELEPHONY_FLIGHT_MODE, 3);
2026 int system_setting_get_network_wifi_notification(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
2028 SETTING_TRACE_BEGIN;
2030 if (system_setting_vconf_get_value_int(VCONFKEY_WIFI_ENABLE_QS, &vconf_value)) {
2031 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2034 bret = (vconf_value == VCONFKEY_WIFI_QS_ENABLE) ? true : false;
2036 *value = (void *)bret;
2037 return SYSTEM_SETTINGS_ERROR_NONE;
2040 int system_setting_set_changed_callback_network_wifi_notification(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
2042 SETTING_TRACE_BEGIN;
2043 return system_setting_vconf_set_changed_cb(VCONFKEY_WIFI_ENABLE_QS, SYSTEM_SETTINGS_KEY_NETWORK_WIFI_NOTIFICATION, 4, user_data);
2046 int system_setting_unset_changed_callback_network_wifi_notification(system_settings_key_e key)
2048 SETTING_TRACE_BEGIN;
2049 return system_setting_vconf_unset_changed_cb(VCONFKEY_WIFI_ENABLE_QS, 4);
2052 /* LCOV_EXCL_START */
2053 int system_setting_get_lock_state(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
2056 int ** val = (int**)value;
2058 if (system_setting_vconf_get_value_int(VCONFKEY_IDLE_LOCK_STATE_READ_ONLY, &vconf_value)) {
2059 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2061 **val = vconf_value;
2063 return SYSTEM_SETTINGS_ERROR_NONE;
2065 /* LCOV_EXCL_STOP */
2067 /* LCOV_EXCL_START */
2068 int system_setting_set_lock_state(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
2070 SETTING_TRACE_BEGIN;
2072 vconf_value = *(int **)value;
2074 if (system_setting_vconf_set_value_int(VCONFKEY_IDLE_LOCK_STATE_READ_ONLY, *vconf_value)) {
2075 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2078 return SYSTEM_SETTINGS_ERROR_NONE;
2080 /* LCOV_EXCL_STOP */
2082 /* LCOV_EXCL_START */
2083 int system_setting_set_changed_callback_lock_state(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
2085 return system_setting_vconf_set_changed_cb(VCONFKEY_IDLE_LOCK_STATE_READ_ONLY, SYSTEM_SETTINGS_KEY_LOCK_STATE, 4, user_data);
2087 /* LCOV_EXCL_STOP */
2089 /* LCOV_EXCL_START */
2090 int system_setting_unset_changed_callback_lock_state(system_settings_key_e key)
2092 return system_setting_vconf_unset_changed_cb(VCONFKEY_IDLE_LOCK_STATE_READ_ONLY, 4);
2094 /* LCOV_EXCL_STOP */
2096 //----------------------------------------------------------------------------------------------------------------------------
2098 #define DEFAULT_ADS_ID "00000000-0000-0000-0000-000000000000"
2100 int system_setting_get_ads_id(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
2102 SETTING_TRACE_BEGIN;
2103 int optout_value = 0;
2104 if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_AD_ID_OPT_OUT, &optout_value)) {
2105 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2108 if (optout_value == 1) {
2109 *value = strdup(DEFAULT_ADS_ID);
2110 return SYSTEM_SETTINGS_ERROR_NONE;
2113 char *vconf_value = NULL;
2114 if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_AD_ID, &vconf_value)) {
2115 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2118 *value = vconf_value;
2119 return SYSTEM_SETTINGS_ERROR_NONE;
2124 void make_ad_id(void)
2127 char uuid_unparsed[50] = {0};
2128 uuid_generate(uuid_value);
2129 uuid_unparse(uuid_value, uuid_unparsed);
2130 system_setting_set_ad_id(key, uuid_unparsed); //example of setting the value
2133 /* LCOV_EXCL_START */
2134 int system_setting_set_ads_id(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
2136 SETTING_TRACE_BEGIN;
2137 char *vconf_value = NULL;
2138 vconf_value = (char *)value;
2140 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_AD_ID, vconf_value)) {
2141 SETTING_TRACE("Setting VCONFKEY_SETAPPL_AD_ID failed");
2142 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2145 return SYSTEM_SETTINGS_ERROR_NONE;
2147 /* LCOV_EXCL_STOP */
2149 int system_setting_set_changed_callback_ads_id(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
2151 SETTING_TRACE_BEGIN;
2152 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_AD_ID, SYSTEM_SETTINGS_KEY_ADS_ID, 0, user_data);
2155 int system_setting_unset_changed_callback_ads_id(system_settings_key_e key)
2157 SETTING_TRACE_BEGIN;
2158 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_AD_ID, 0);