2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
25 #include <sys/types.h>
36 #include <libxml/xmlmemory.h>
37 #include <libxml/parser.h>
39 #include <fontconfig/fontconfig.h>
41 #include <pkgmgr-info.h>
42 #include <package_manager.h>
43 #include <app_manager.h>
45 #include <system_settings.h>
46 #include <system_settings_private.h>
47 #include <system_settings_ringtones.h>
48 #include <system_settings_json.h>
50 #include <system-setting-config.h>
52 #include <tzplatform_config.h>
55 #include <system_info.h>
57 #define SETTING_FONT_CONF_FILE _TZ_SYS_ETC"/fonts/conf.avail/99-tizen.conf"
58 #define SETTING_DEFAULT_FONT_CONF_FILE _TZ_SYS_ETC"/fonts/conf.avail/99-tizen.conf"
60 #define SETTING_TIME_ZONEINFO_PATH "/usr/share/zoneinfo/"
61 #define SETTING_TIME_SHARE_LOCAL_PATH "/usr/share/locale"
62 #define SETTING_TZONE_SYMLINK_PATH "/opt/etc/localtime"
65 #define __FREE(del, arg) do { \
67 del((void *)(arg)); /*cast any argument to (void*) to avoid build warring*/\
71 #define FREE(arg) __FREE(free, arg)
73 #ifdef SETTING_ARCH_64
74 #define SETTING_UTILS_SO_FILE_PATH "/usr/lib64/libsystem-settings-util.so.0.1.0"
76 #define SETTING_UTILS_SO_FILE_PATH "/usr/lib/libsystem-settings-util.so.0.1.0"
79 int _is_file_accessible(const char *path);
81 static bool dl_is_supported_image_type_load(char *path);
82 static bool dl_font_config_set(char *font_name);
83 static char *dl_get_default_font_info();
84 static int dl_is_available_font(char *str);
85 static void dl_font_size_set();
86 static void dl_font_config_set_notification();
89 * VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR has a path of the ringtone file which user choose
90 * @return the ringtone file path specified by user in normal case
91 * if it's not accessable, return the default ringtone path
93 int system_setting_get_incoming_call_ringtone(system_settings_key_e key, void **value)
97 if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR, &vconf_value)) {
98 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
101 /* check to see if it's accessable -> OK */
102 /* no --> default ringtone path VCONFKEY_SETAPPL_CALL_RINGTONE_DEFAULT_PATH_STR */
103 int is_load = _is_file_accessible(vconf_value);
105 *value = vconf_value;
106 } else { /* not zero on errro */
107 *value = vconf_get_str(VCONFKEY_SETAPPL_CALL_RINGTONE_DEFAULT_PATH_STR);
110 /**value = vconf_value; */
111 return SYSTEM_SETTINGS_ERROR_NONE;
115 int system_setting_get_email_alert_ringtone(system_settings_key_e key, void **value)
119 if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, &vconf_value)) {
120 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
123 /* check to see if it's accessable -> OK */
124 /* no --> default ringtone path VCONFKEY_SETAPPL_NOTI_RINGTONE_DEFAULT_PATH_STR */
125 int is_load = _is_file_accessible(vconf_value);
127 *value = vconf_value;
128 } else { /* not zero on errro */
129 *value = vconf_get_str(VCONFKEY_SETAPPL_NOTI_RINGTONE_DEFAULT_PATH_STR);
132 return SYSTEM_SETTINGS_ERROR_NONE;
136 int system_setting_get_wallpaper_home_screen(system_settings_key_e key, void **value)
140 if (system_setting_vconf_get_value_string(VCONFKEY_BGSET, &vconf_value)) {
141 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
143 *value = vconf_value;
144 return SYSTEM_SETTINGS_ERROR_NONE;
148 int system_setting_get_wallpaper_lock_screen(system_settings_key_e key, void **value)
153 if (system_setting_vconf_get_value_string(VCONFKEY_IDLE_LOCK_BGSET, &vconf_value)) {
154 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
156 *value = vconf_value;
158 return SYSTEM_SETTINGS_ERROR_NONE;
162 /* [int] vconf GET */
163 int system_setting_get_font_size(system_settings_key_e key, void **value)
167 int ** val = (int**)value;
169 if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, &vconf_value)) {
170 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
174 return SYSTEM_SETTINGS_ERROR_NONE;
178 int system_setting_get_default_font_type(system_settings_key_e key, void **value)
181 char *font_name = dl_get_default_font_info();
183 *value = (void *)font_name;
184 return SYSTEM_SETTINGS_ERROR_NONE;
186 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
190 /* [int] vconf GET */
191 int system_setting_get_font_type(system_settings_key_e key, void **value)
194 char *font_name = NULL;
196 if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, &font_name)) {
197 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
201 return SYSTEM_SETTINGS_ERROR_NONE;
205 int system_setting_get_motion_activation(system_settings_key_e key, void **value)
210 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_MOTION_ACTIVATION, &vconf_value)) {
211 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
213 *value = (void *)vconf_value;
215 return SYSTEM_SETTINGS_ERROR_NONE;
218 int system_setting_get_usb_debugging_option(system_settings_key_e key, void **value)
223 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_USB_DEBUG_MODE_BOOL, &vconf_value)) {
224 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
226 *value = (void *)vconf_value;
228 return SYSTEM_SETTINGS_ERROR_NONE;
231 int system_setting_get_3g_data_network(system_settings_key_e key, void **value)
236 if (system_setting_vconf_get_value_bool(VCONFKEY_3G_ENABLE, &vconf_value)) {
237 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
239 *value = (void *)vconf_value;
241 return SYSTEM_SETTINGS_ERROR_NONE;
243 /*////////////////////////////////////////////////////////////////////////////////////////////////// */
247 * get current lock scren app package name (string)
249 * @return SYSTEM_SETTINGS_ERROR_LOCKSCREEN_APP_PASSWORD_MODE raise exception if current lock type is 'password'
251 int system_setting_get_lockscreen_app(system_settings_key_e key, void **value)
254 char *pkg_name = NULL;
256 if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_SCREEN_LOCK_TYPE_INT, &locktype)) {
257 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
260 if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_3RD_LOCK_PKG_NAME_STR, &pkg_name)) {
261 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
264 if (pkg_name && strcmp(pkg_name, "com.samsung.lockscreen") == 0 && locktype == SETTING_SCREEN_LOCK_TYPE_PASSWORD) {
265 return SYSTEM_SETTINGS_ERROR_LOCKSCREEN_APP_PASSWORD_MODE;
269 return SYSTEM_SETTINGS_ERROR_NONE;
273 /*////////////////////////////////////////////////////////////////////////////////////////////////// */
275 int _is_file_accessible(const char *path)
278 int ret = access(path , R_OK);
280 SETTING_TRACE("found the file %s", path);
283 /* error code : 13 */
284 SETTING_TRACE("found the file %s --- error code : %d ", path, errno);
291 /*////////////////////////////////////////////////////////////////////////////////////////////////// */
292 // @todo move to CMake
293 #define DEF_RINGTONE_FILE_PATH SETTING_DEF_RES"/Ringtones"
295 #define USR_RINGTONE_FILE_PATH "/home/owner/content/Sounds/Ringtones"
296 #define JSONFILE "/opt/home/owner/apps_rw/org.tizen.setting/data/.user-ringtones.json"
299 static char* _get_json_file_path()
306 int system_setting_add_incoming_call_ringtone(system_settings_key_e key, void *value)
309 char* pathval = (char*)value;
310 char* dnameval = NULL;
311 char* baseval = NULL;
315 JsonParser *parser = ss_json_ringtone_open_file(JSONFILE);
317 JsonParser *parser = ss_json_ringtone_load_from_data();
320 JsonNode *root = json_parser_get_root(parser);
324 int ret = SYSTEM_SETTINGS_ERROR_NONE;
325 if (false == ss_json_ringtone_contain(root, pathval)) {
326 // @todo : MAKE SURE THE ACTUAL FILE IS THERE ON PATHVAL(SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER)
327 ss_json_ringtone_add(root, JSONFILE, pathval, pathval);
328 SETTING_TRACE("pathval is : %s -- OK", pathval);
330 SETTING_TRACE("pathval is duplicated : %s", pathval);
331 ret = SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
334 dnameval = strdup(pathval);
335 baseval = strdup(pathval);
336 if (dnameval && baseval) {
337 SETTING_TRACE("---> dirname is : %s ", dirname(dnameval));
338 SETTING_TRACE("---> basename is : %s ", basename(baseval));
344 g_object_unref(parser);
351 int system_setting_del_incoming_call_ringtone(system_settings_key_e key, void *value)
354 char* pathval = (char*)value;
357 JsonParser* parser = ss_json_ringtone_open_file(JSONFILE);
359 JsonParser* parser = ss_json_ringtone_load_from_data();
361 JsonNode *root = json_parser_get_root(parser);
363 ss_json_ringtone_remove(root, JSONFILE, pathval);
364 //void ss_json_ringtone_remove(JsonNode *root, char* filename, char* path_to_del)
366 ss_json_ringtone_print(root);
368 g_object_unref(parser);
372 return SYSTEM_SETTINGS_ERROR_NONE;
376 /* LCOV_EXCL_START */
377 static int _compare_cb(const void *d1, const void *d2)
379 fileNodeInfo *pNode1 = (fileNodeInfo *)d1;
380 fileNodeInfo *pNode2 = (fileNodeInfo *)d2;
382 return strcmp(pNode1->media_name, pNode2->media_name);
387 * get the RINGTONE list
389 static void _get_default_ringtones(system_settings_key_e key, system_settings_iter_cb callback, void *data)
393 Eina_List *filelist = NULL;
395 fileNodeInfo *node = NULL;
398 //-----------------------------------------------------------------------------------------------------------------
399 // 1. get the default ringtone list
400 //-----------------------------------------------------------------------------------------------------------------
401 int ret = get_filelist_from_dir_path(DEF_RINGTONE_FILE_PATH, &filelist);
403 SETTING_TRACE("Failed to get filelist, ret = %d %s", ret, DEF_RINGTONE_FILE_PATH);
405 filelist = eina_list_sort(filelist, eina_list_count(filelist), _compare_cb);
407 EINA_LIST_FOREACH(filelist, l, node)
409 SETTING_TRACE("file path = (%d) : name:%s path:%s [%s]", ret, node->name, node->path, node->media_name);
410 // @todo assert NULL check
413 snprintf(temp, 1024, "%s/%s", node->path, node->name);
414 char* path = strdup(temp);
415 bool ret = callback(idx, (void *)(path), data);
421 SETTING_TRACE("quit the iteration by return value == false : %d", ret);
426 SETTING_TRACE("--> system_setting_data_iterator is NULL");
432 EINA_LIST_FOREACH(filelist, l, node)
436 FREE(node->media_name);
439 eina_list_free(filelist);
444 static void _get_user_ringtones(system_settings_key_e key, system_settings_iter_cb callback, void *data)
450 JsonParser* parser = ss_json_ringtone_open_file(JSONFILE);
452 JsonParser* parser = ss_json_ringtone_load_from_data();
455 JsonNode *root = json_parser_get_root(parser);
456 int size = json_array_get_length(json_node_get_array(root));
459 for (i = 0; i < size ; i++) {
460 JsonObject *ringtone = json_array_get_object_element(json_node_get_array(root), i);
461 char *nameval = (char *)json_object_get_string_member(ringtone, "name");
462 char *pathval = (char *)json_object_get_string_member(ringtone, "path");
463 SETTING_TRACE("(%s) --- (%s) \n", nameval, pathval);
464 if (callback && pathval) {
465 char* path = strdup(pathval);
466 bool ret = callback(i, (void *)(path), data);
468 SETTING_TRACE("quit the iteration by return value == false : %d", ret);
473 SETTING_TRACE("--> callback is NULL");
477 g_object_unref(parser);
480 int system_setting_list_incoming_call_ringtone(system_settings_key_e key, system_settings_iter_cb callback, void *data)
484 _get_default_ringtones(key, callback, data);
485 //-----------------------------------------------------------------------------------------------------------------
486 // 2. get the USER ringtone list
487 //-----------------------------------------------------------------------------------------------------------------
488 _get_user_ringtones(key, callback, data);
490 return SYSTEM_SETTINGS_ERROR_NONE;
494 /* LCOV_EXCL_START */
495 int system_setting_set_incoming_call_ringtone(system_settings_key_e key, void *value)
499 vconf_value = (char *)value;
501 int ret = _is_file_accessible(vconf_value);
503 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR, vconf_value)) {
504 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
507 /* @todo add a common ret_handler */
511 return SYSTEM_SETTINGS_ERROR_NONE;
516 /* LCOV_EXCL_START */
517 int system_setting_set_email_alert_ringtone(system_settings_key_e key, void *value)
521 vconf_value = (char *)value;
523 int ret = _is_file_accessible(vconf_value);
525 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, vconf_value)) {
526 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
529 /*return SYSTEM_SETTINGS_ERROR_IO_ERROR;*/
530 /* @todo add a common ret_handler */
534 return SYSTEM_SETTINGS_ERROR_NONE;
538 /* LCOV_EXCL_START */
539 static bool dl_is_supported_image_type_load(char *path)
544 bool (*image_type_check)(char *path);
546 handle = dlopen(SETTING_UTILS_SO_FILE_PATH, RTLD_LAZY);
548 SETTING_TRACE("ERROR!! canNOT find libsystem-settings-util.so.0.1.0");
552 image_type_check = dlsym(handle, "__is_supported_image_type_load");
553 if ((error = dlerror()) != NULL) {
554 SETTING_TRACE("ERROR!! canNOT find __is_supported_image_type_load function at libsystem-settings-util.so.0.1.0");
559 ret = image_type_check(path);
566 /* LCOV_EXCL_START */
567 static int dl_is_available_font(char *str)
572 int (*check_available_font)(char *font_name);
574 handle = dlopen(SETTING_UTILS_SO_FILE_PATH, RTLD_LAZY);
576 SETTING_TRACE("ERROR!! canNOT find libsystem-settings-util.so.0.1.0");
580 check_available_font = dlsym(handle, "__is_available_font");
581 if ((error = dlerror()) != NULL) {
582 SETTING_TRACE("ERROR!! canNOT find __is_available_font function at libsystem-settings-util.so.0.1.0");
587 ret = check_available_font(str);
594 /* LCOV_EXCL_START */
595 static void dl_font_size_set()
599 void (*set_font_size)();
601 handle = dlopen(SETTING_UTILS_SO_FILE_PATH, RTLD_LAZY);
603 SETTING_TRACE("ERROR!! canNOT find libsystem-settings-util.so.0.1.0");
607 set_font_size = dlsym(handle, "__font_size_set");
608 if ((error = dlerror()) != NULL) {
609 SETTING_TRACE("ERROR!! canNOT find __font_size_set function at libsystem-settings-util.so.0.1.0");
621 /* LCOV_EXCL_START */
622 static void dl_font_config_set_notification()
626 void (*set_font_nodification)();
628 handle = dlopen(SETTING_UTILS_SO_FILE_PATH, RTLD_LAZY);
630 SETTING_TRACE("ERROR!! canNOT find libsystem-settings-util.so.0.1.0");
634 set_font_nodification = dlsym(handle, "font_config_set_notification");
635 if ((error = dlerror()) != NULL) {
636 SETTING_TRACE("ERROR!! canNOT find font_config_set_notification function at libsystem-settings-util.so.0.1.0");
641 set_font_nodification();
648 /* LCOV_EXCL_START */
649 static bool dl_font_config_set(char *font_name)
654 bool (*check_font_type)(char *font_name);
656 handle = dlopen(SETTING_UTILS_SO_FILE_PATH, RTLD_LAZY);
658 SETTING_TRACE("ERROR!! canNOT find libsystem-settings-util.so.0.1.0");
662 check_font_type = dlsym(handle, "font_config_set");
663 if ((error = dlerror()) != NULL) {
664 SETTING_TRACE("ERROR!! canNOT find font_config_set function at libsystem-settings-util.so.0.1.0");
669 ret = check_font_type(font_name);
676 /* LCOV_EXCL_START */
677 static char *dl_get_default_font_info()
682 char *(*get_font_info)();
684 handle = dlopen(SETTING_UTILS_SO_FILE_PATH, RTLD_LAZY);
686 SETTING_TRACE("ERROR!! canNOT find libsystem-settings-util.so.0.1.0");
690 get_font_info = dlsym(handle, "_get_default_font");
692 if ((error = dlerror()) != NULL) {
693 SETTING_TRACE("ERROR!! canNOT find _get_default_font function at libsystem-settings-util.so.0.1.0");
698 ret = get_font_info();
705 #ifdef TIZEN_WEARABLE
706 /* LCOV_EXCL_START */
707 static int system_setting_get_extended_wallpaper_num(const char *file_path, unsigned int *num)
711 const char *find_str = "extended_wallpaper_";
714 if (!(ch = strstr(file_path, find_str))) {
715 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
717 strncpy(buffer, file_path, ch - file_path);
718 buffer[ch - file_path] = 0;
719 sprintf(buffer + (ch - file_path), "%s%s", "", ch + strlen(find_str));
721 if (!isdigit(buffer[0])) {
722 SETTING_TRACE("%s is not number", buffer);
723 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
728 return SYSTEM_SETTINGS_ERROR_NONE;
732 /* LCOV_EXCL_START */
733 static int system_setting_copy_extended_wallpaper(const char *dest_file_path, const char *source_file_path)
736 if (!source_file_path || !dest_file_path) {
737 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
743 fd = open(source_file_path, O_RDONLY);
745 SETTING_TRACE("file open failed: %s", source_file_path);
746 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
750 fd2 = open(dest_file_path, O_WRONLY | O_CREAT, S_IRWXU | S_IRWXG | S_IRWXO);
752 SETTING_TRACE("file creation failed: %s", dest_file_path);
754 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
757 while (read(fd, buf, sizeof(buf) - 1) > 0) {
758 write(fd2, buf, sizeof(buf) - 1);
764 if (chmod(dest_file_path, S_IRWXU | S_IRWXG | S_IRWXO) < 0) {
765 SETTING_TRACE("chmod failed: %s", dest_file_path);
768 return SYSTEM_SETTINGS_ERROR_NONE;
772 /* LCOV_EXCL_START */
773 static int system_setting_remove_oldest_extended_wallpaper()
778 char *min_image_name = NULL;
779 unsigned int min_image_num = 0;
780 unsigned int temp_image_num = 0;
783 if ((dp = opendir(_TZ_SYS_DATA"/setting/wallpaper")) == NULL) {
784 SETTING_TRACE("opendir error");
785 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
788 while ((dirp = readdir(dp))) {
789 if (!strcmp(dirp->d_name, ".") || !strcmp(dirp->d_name, ".."))
792 if (system_setting_get_extended_wallpaper_num(dirp->d_name, &temp_image_num)
793 != SYSTEM_SETTINGS_ERROR_NONE) {
794 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
797 if ((image_count == 0) || (min_image_num > temp_image_num)) {
798 min_image_num = temp_image_num;
799 min_image_name = dirp->d_name;
806 if (min_image_name) {
807 snprintf(buf, sizeof(buf) - 1, _TZ_SYS_DATA"/setting/wallpaper/%s", min_image_name);
808 if (remove(buf) < 0) { /* remove oldest image */
809 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
813 return SYSTEM_SETTINGS_ERROR_NONE;
817 /* LCOV_EXCL_START */
818 static int system_setting_check_extended_wallpaper(const char *file_path)
822 if (!file_path || !strlen(file_path))
824 snprintf(buffer, 512, "%s/.bgwallpaper", tzplatform_getenv(TZ_USER_CONTENT));
825 return (strstr(file_path, buffer) != NULL);
829 #define WALLPAPER_MAX_COUNT 10
831 /* LCOV_EXCL_START */
832 int system_setting_set_wallpaper_home_screen(system_settings_key_e key, void *value)
836 vconf_value = (char *)value;
838 bool isok = dl_is_supported_image_type_load(vconf_value);
841 SETTING_TRACE("path : %s is not supported file format", vconf_value);
842 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
844 SETTING_TRACE("path : %s is SUPPORT file format", vconf_value);
847 /* error handling here */
848 if (_is_file_accessible(vconf_value) != 0)
849 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
851 if (system_setting_vconf_set_value_string(VCONFKEY_BGSET, vconf_value)) {
852 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
856 #ifdef TIZEN_WEARABLE
857 if (system_setting_check_extended_wallpaper(vconf_value)) { /* New extended wallpaper */
860 unsigned int max_image_num = 0;
861 unsigned int temp_image_num = 0;
864 if ((dp = opendir(_TZ_SYS_DATA"/setting/wallpaper")) == NULL) {
865 SETTING_TRACE("Setting - dir open error!");
866 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
869 /* Check a max number of wallpapers */
870 while ((dirp = readdir(dp))) {
871 if (!strcmp(dirp->d_name, ".") || !strcmp(dirp->d_name, ".."))
874 if (system_setting_get_extended_wallpaper_num(dirp->d_name, &temp_image_num)
875 != SYSTEM_SETTINGS_ERROR_NONE) {
878 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
881 if ((image_count == 0) || (max_image_num < temp_image_num)) {
882 max_image_num = temp_image_num;
890 /* Numbering rule: Gear is odd number */
891 max_image_num = (max_image_num % 2 == 0) ? max_image_num + 1
894 char file_name_buffer[512];
895 snprintf(file_name_buffer, sizeof(file_name_buffer) - 1,
896 _TZ_SYS_DATA"/setting/wallpaper/extended_wallpaper_%d.jpg", max_image_num);
898 /* Copy image to _TZ_SYS_DATA/setting/wallpaper/ */
899 if (system_setting_copy_extended_wallpaper(file_name_buffer, vconf_value)
900 != SYSTEM_SETTINGS_ERROR_NONE) {
901 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
904 /* remove oldest wallpaper */
905 if (image_count >= WALLPAPER_MAX_COUNT) {
906 if (system_setting_remove_oldest_extended_wallpaper()
907 != SYSTEM_SETTINGS_ERROR_NONE) {
908 remove(file_name_buffer);
909 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
913 if (system_setting_vconf_set_value_string(VCONFKEY_BGSET, file_name_buffer)) {
914 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
917 if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_WALLPAPER_CHANGED_NOTI_INT,
918 VCONFKEY_WALLPAPER_CHANGED_NOTI_GEAR)) {
919 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
922 if (system_setting_vconf_set_value_string(VCONFKEY_BGSET, vconf_value)) {
923 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
928 return SYSTEM_SETTINGS_ERROR_NONE;
932 /* LCOV_EXCL_START */
933 int system_setting_set_wallpaper_lock_screen(system_settings_key_e key, void *value)
937 vconf_value = (char *)value;
939 bool isok = dl_is_supported_image_type_load(vconf_value);
942 SETTING_TRACE("path : %s is not supported file format", vconf_value);
943 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
945 SETTING_TRACE("path : %s is SUPPORT file format", vconf_value);
948 /* error handling here */
949 if (_is_file_accessible(vconf_value) != 0)
950 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
952 if (system_setting_vconf_set_value_string(VCONFKEY_IDLE_LOCK_BGSET, vconf_value)) {
953 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
956 return SYSTEM_SETTINGS_ERROR_NONE;
960 /* LCOV_EXCL_START */
961 int system_setting_set_font_size(system_settings_key_e key, void *value)
965 vconf_value = *(int **)value;
967 if (*vconf_value < 0 || *vconf_value > SYSTEM_SETTINGS_FONT_SIZE_GIANT) {
968 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
971 if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, *vconf_value)) {
972 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
976 return SYSTEM_SETTINGS_ERROR_NONE;
982 /* LCOV_EXCL_START */
983 void *font_conf_doc_parse(char *doc_name, char *font_name)
986 xmlDocPtr doc = NULL;
987 xmlNodePtr cur = NULL;
988 xmlNodePtr cur2 = NULL;
989 xmlNodePtr cur3 = NULL;
992 doc = xmlParseFile(doc_name);
994 cur = xmlDocGetRootElement(doc);
1002 if (xmlStrcmp(cur->name, (const xmlChar *)"fontconfig")) {
1008 cur = cur->xmlChildrenNode;
1010 bool is_changed = false;
1011 while (cur != NULL) {
1012 if ((!xmlStrcmp(cur->name, (const xmlChar *)"match"))) {
1013 cur2 = cur->xmlChildrenNode;
1014 while (cur2 != NULL) {
1015 if ((!xmlStrcmp(cur2->name, (const xmlChar *)"edit"))) {
1016 xmlChar *name = xmlGetProp(cur2, (const xmlChar *)"name");
1017 /* if name is not 'family', break */
1018 if (xmlStrcmp(name, (const xmlChar *)"family")) {
1026 cur3 = cur2->xmlChildrenNode;
1027 while (cur3 != NULL) {
1028 if ((!xmlStrcmp(cur3->name, (const xmlChar *)"string"))) {
1029 xmlNodeSetContent(cur3->xmlChildrenNode, (const xmlChar *)font_name);
1030 key = xmlNodeListGetString(doc, cur3->xmlChildrenNode, 1);
1040 } else if ((!xmlStrcmp(cur->name, (const xmlChar *)"alias"))) {
1041 cur2 = cur->xmlChildrenNode;
1042 while (cur2 != NULL) {
1043 if ((!xmlStrcmp(cur2->name, (const xmlChar *)"family"))) {
1044 xmlNodeSetContent(cur2->xmlChildrenNode, (const xmlChar *)font_name);
1045 key = xmlNodeListGetString(doc, cur2->xmlChildrenNode, 1);
1049 } else if ((!xmlStrcmp(cur2->name, (const xmlChar *)"prefer"))) {
1050 cur3 = cur2->xmlChildrenNode;
1051 while (cur3 != NULL) {
1052 if ((!xmlStrcmp(cur3->name, (const xmlChar *)"family"))) {
1053 xmlNodeSetContent(cur3->xmlChildrenNode, (const xmlChar *)font_name);
1054 key = xmlNodeListGetString(doc, cur3->xmlChildrenNode, 1);
1078 /* LCOV_EXCL_STOP */
1080 /* LCOV_EXCL_START */
1081 int system_setting_set_font_type(system_settings_key_e key, void *value)
1083 SETTING_TRACE_BEGIN;
1084 char *font_name = NULL;
1085 font_name = (char *)value;
1087 /* get current font list */
1088 int is_found = dl_is_available_font(font_name);
1090 if (is_found == 1) {
1091 SETTING_TRACE("found font : %s ", font_name);
1093 SETTING_TRACE(" NOT found font : %s ", font_name);
1094 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1097 bool bsave = dl_font_config_set(font_name);
1100 SETTING_TRACE(" font type save error by font_config_set() ");
1101 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1103 SETTING_TRACE(" save OK - font_config_set() ");
1106 xmlDocPtr doc = (xmlDocPtr)font_conf_doc_parse(SETTING_FONT_CONF_FILE, font_name);
1108 xmlSaveFormatFile(SETTING_FONT_CONF_FILE, doc, 0);
1113 dl_font_config_set_notification();
1116 vconf_value = (char *)value;
1118 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, vconf_value)) {
1119 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1121 return SYSTEM_SETTINGS_ERROR_NONE;
1123 /* LCOV_EXCL_STOP */
1125 /* LCOV_EXCL_START */
1126 int system_setting_set_motion_activation(system_settings_key_e key, void *value)
1128 SETTING_TRACE_BEGIN;
1130 vconf_value = (bool *)value;
1131 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_MOTION_ACTIVATION, *vconf_value)) {
1132 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1134 return SYSTEM_SETTINGS_ERROR_NONE;
1136 /* LCOV_EXCL_STOP */
1138 /* LCOV_EXCL_START */
1139 int system_setting_set_usb_debugging_option(system_settings_key_e key, void *value)
1141 SETTING_TRACE_BEGIN;
1143 vconf_value = (bool *)value;
1144 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_USB_DEBUG_MODE_BOOL, *vconf_value)) {
1145 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1147 return SYSTEM_SETTINGS_ERROR_NONE;
1150 /* LCOV_EXCL_STOP */
1152 /* LCOV_EXCL_START */
1153 int system_setting_set_3g_data_network(system_settings_key_e key, void *value)
1155 SETTING_TRACE_BEGIN;
1157 vconf_value = (bool *)value;
1158 if (system_setting_vconf_set_value_bool(VCONFKEY_3G_ENABLE, *vconf_value)) {
1159 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1162 return SYSTEM_SETTINGS_ERROR_NONE;
1164 /* LCOV_EXCL_STOP */
1166 /* LCOV_EXCL_START */
1167 static int category_func(const char *name, void *user_data)
1169 SETTING_TRACE_BEGIN;
1170 static char *category = "lock-screen";
1171 if (name && !strcmp(name, category)) {
1172 SETTING_TRACE(" SAME ");
1175 SETTING_TRACE(" DIFFERENT -- %s, category -- %s ", name, category);
1181 /* LCOV_EXCL_STOP */
1185 * set 'swipe type' if current lockscreen app is 'com.samsung.lockscreen'
1189 /* LCOV_EXCL_START */
1190 int system_setting_set_lockscreen_app(system_settings_key_e key, void *value)
1192 SETTING_TRACE_BEGIN;
1194 vconf_value = (char *)value; /* ex) com.samsung.lockscreen */
1197 pkgmgrinfo_appinfo_h handle;
1198 r = pkgmgrinfo_appinfo_get_appinfo(vconf_value, &handle);
1199 if (r != PMINFO_R_OK) {
1200 SETTING_TRACE("*** pkginfo failed ");
1201 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
1203 SETTING_TRACE("%p", handle);
1206 int ret = pkgmgrinfo_appinfo_foreach_category(handle, category_func, (void *)"lock-screen");
1207 if (ret != PMINFO_R_OK) {
1208 pkgmgrinfo_appinfo_destroy_appinfo(handle);
1209 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
1212 pkgmgrinfo_appinfo_destroy_appinfo(handle);
1213 /*----------------------------------------------------------------------------------- */
1215 if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_SCREEN_LOCK_TYPE_INT, &locktype)) {
1216 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1219 if (locktype == SETTING_SCREEN_LOCK_TYPE_PASSWORD)
1220 return SYSTEM_SETTINGS_ERROR_LOCKSCREEN_APP_PASSWORD_MODE;
1222 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_3RD_LOCK_PKG_NAME_STR, vconf_value)) {
1223 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1226 if (vconf_value && strcmp(vconf_value, "com.samsung.lockscreen") == 0) {
1227 if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_SCREEN_LOCK_TYPE_INT, SETTING_SCREEN_LOCK_TYPE_SWIPE)) {
1228 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1231 return SYSTEM_SETTINGS_ERROR_NONE;
1233 /* LCOV_EXCL_STOP */
1235 /*/////////////////////////////////////////////////////////////////////////////////////////////// */
1238 int system_setting_set_changed_callback_incoming_call_ringtone(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1240 SETTING_TRACE_BEGIN;
1241 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR, SYSTEM_SETTINGS_KEY_INCOMING_CALL_RINGTONE, 0, user_data);
1244 int system_setting_unset_changed_callback_incoming_call_ringtone(system_settings_key_e key)
1246 SETTING_TRACE_BEGIN;
1247 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR, 0);
1250 int system_setting_set_changed_callback_email_alert_ringtone(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1252 SETTING_TRACE_BEGIN;
1253 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, SYSTEM_SETTINGS_KEY_EMAIL_ALERT_RINGTONE, 0, user_data);
1256 int system_setting_unset_changed_callback_email_alert_ringtone(system_settings_key_e key)
1258 SETTING_TRACE_BEGIN;
1259 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, 0);
1262 int system_setting_set_changed_callback_wallpaper_home_screen(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1264 SETTING_TRACE_BEGIN;
1265 return system_setting_vconf_set_changed_cb(VCONFKEY_BGSET, SYSTEM_SETTINGS_KEY_WALLPAPER_HOME_SCREEN, 0, user_data);
1268 int system_setting_unset_changed_callback_wallpaper_home_screen(system_settings_key_e key)
1270 SETTING_TRACE_BEGIN;
1271 return system_setting_vconf_unset_changed_cb(VCONFKEY_BGSET, 0);
1274 int system_setting_set_changed_callback_wallpaper_lock_screen(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1276 SETTING_TRACE_BEGIN;
1277 return system_setting_vconf_set_changed_cb(VCONFKEY_IDLE_LOCK_BGSET, SYSTEM_SETTINGS_KEY_WALLPAPER_LOCK_SCREEN, 0, user_data);
1280 int system_setting_unset_changed_callback_wallpaper_lock_screen(system_settings_key_e key)
1282 SETTING_TRACE_BEGIN;
1283 return system_setting_vconf_unset_changed_cb(VCONFKEY_IDLE_LOCK_BGSET, 0);
1286 int system_setting_set_changed_callback_font_size(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1288 SETTING_TRACE_BEGIN;
1289 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, SYSTEM_SETTINGS_KEY_FONT_SIZE, 1, user_data);
1292 int system_setting_unset_changed_callback_font_size(system_settings_key_e key)
1294 SETTING_TRACE_BEGIN;
1295 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, 1);
1298 int system_setting_set_changed_callback_usb_debugging_option(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1300 SETTING_TRACE_BEGIN;
1301 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_USB_DEBUG_MODE_BOOL, SYSTEM_SETTINGS_KEY_USB_DEBUGGING_ENABLED, 1, user_data);
1304 int system_setting_unset_changed_callback_usb_debugging_option(system_settings_key_e key)
1306 SETTING_TRACE_BEGIN;
1307 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_USB_DEBUG_MODE_BOOL, 1);
1310 int system_setting_set_changed_callback_3g_data_network(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1312 SETTING_TRACE_BEGIN;
1313 return system_setting_vconf_set_changed_cb(VCONFKEY_3G_ENABLE, SYSTEM_SETTINGS_KEY_3G_DATA_NETWORK_ENABLED, 1, user_data);
1316 int system_setting_unset_changed_callback_3g_data_network(system_settings_key_e key)
1318 SETTING_TRACE_BEGIN;
1319 return system_setting_vconf_unset_changed_cb(VCONFKEY_3G_ENABLE, 1);
1322 int system_setting_set_changed_callback_lockscreen_app(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1324 SETTING_TRACE_BEGIN;
1325 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_3RD_LOCK_PKG_NAME_STR, SYSTEM_SETTINGS_KEY_LOCKSCREEN_APP, 1, user_data);
1328 int system_setting_unset_changed_callback_lockscreen_app(system_settings_key_e key)
1330 SETTING_TRACE_BEGIN;
1331 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_3RD_LOCK_PKG_NAME_STR, 1);
1336 * @todo need to add custom event notification method
1338 int system_setting_set_changed_callback_font_type(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1340 SETTING_TRACE_BEGIN;
1341 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, SYSTEM_SETTINGS_KEY_FONT_TYPE, 2, user_data);
1344 int system_setting_unset_changed_callback_font_type(system_settings_key_e key)
1346 SETTING_TRACE_BEGIN;
1347 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, 2);
1350 /* TODO : 2th argument, callback, is not in use. */
1351 int system_setting_set_changed_callback_motion_activation(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1353 SETTING_TRACE_BEGIN;
1354 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_MOTION_ACTIVATION, SYSTEM_SETTINGS_KEY_MOTION_ACTIVATION, 3, user_data);
1357 int system_setting_unset_changed_callback_motion_activation(system_settings_key_e key)
1359 SETTING_TRACE_BEGIN;
1360 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_MOTION_ACTIVATION, 3);
1363 /*//////////////////////////////////////////////////////////////////////////////////////// */
1364 /*--------------------------------------- */
1365 int system_setting_get_locale_country(system_settings_key_e key, void **value)
1367 SETTING_TRACE_BEGIN;
1368 char *vconf_value = NULL;
1369 if (system_setting_vconf_get_value_string(VCONFKEY_REGIONFORMAT, &vconf_value)) {
1370 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1373 /* parsing validation */
1376 snprintf(arr, 20, "%s", vconf_value);
1378 *value = strdup(arr);
1382 return SYSTEM_SETTINGS_ERROR_NONE;
1385 /* LCOV_EXCL_START */
1386 int system_setting_set_locale_country(system_settings_key_e key, void *value)
1388 SETTING_TRACE_BEGIN;
1389 char *vconf_value = NULL;
1390 vconf_value = (char *)value;
1392 char *ext = "UTF-8";
1395 snprintf(arr, 20, "%s.%s", vconf_value, ext);
1397 if (system_setting_vconf_set_value_string(VCONFKEY_REGIONFORMAT, arr)) {
1398 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1400 return SYSTEM_SETTINGS_ERROR_NONE;
1402 /* LCOV_EXCL_STOP */
1404 int system_setting_set_changed_callback_locale_country(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1406 SETTING_TRACE_BEGIN;
1407 return system_setting_vconf_set_changed_cb(VCONFKEY_REGIONFORMAT, SYSTEM_SETTINGS_KEY_LOCALE_COUNTRY, 3, user_data);
1410 int system_setting_unset_changed_callback_locale_country(system_settings_key_e key)
1412 SETTING_TRACE_BEGIN;
1413 return system_setting_vconf_unset_changed_cb(VCONFKEY_REGIONFORMAT, 3);
1417 /*--------------------------------------- */
1418 int system_setting_get_locale_language(system_settings_key_e key, void **value)
1420 SETTING_TRACE_BEGIN;
1421 char *vconf_value = NULL;
1422 if (system_setting_vconf_get_value_string(VCONFKEY_LANGSET, &vconf_value)) {
1423 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1426 /* parsing validation */
1429 snprintf(arr, 20, "%s", vconf_value);
1431 *value = strdup(arr);
1434 return SYSTEM_SETTINGS_ERROR_NONE;
1437 /* LCOV_EXCL_START */
1438 int system_setting_set_locale_language(system_settings_key_e key, void *value)
1440 SETTING_TRACE_BEGIN;
1441 char *vconf_value = NULL;
1442 vconf_value = (char *)value;
1444 char *ext = "UTF-8";
1447 snprintf(arr, 20, "%s.%s", vconf_value, ext);
1449 if (system_setting_vconf_set_value_string(VCONFKEY_LANGSET, arr)) {
1450 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1452 return SYSTEM_SETTINGS_ERROR_NONE;
1454 /* LCOV_EXCL_STOP */
1456 int system_setting_set_changed_callback_locale_language(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1458 SETTING_TRACE_BEGIN;
1459 /*return system_setting_vconf_set_changed_cb(VCONFKEY_LANGSET, SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, 3, user_data ); */
1460 return system_setting_vconf_set_changed_cb(VCONFKEY_LANGSET, SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, 100, user_data);
1463 int system_setting_unset_changed_callback_locale_language(system_settings_key_e key)
1465 SETTING_TRACE_BEGIN;
1466 return system_setting_vconf_unset_changed_cb(VCONFKEY_LANGSET, 100);
1469 /*--------------------------------------- */
1470 /* LCOV_EXCL_START */
1471 int system_setting_get_locale_timeformat_24hour(system_settings_key_e key, void **value)
1473 SETTING_TRACE_BEGIN;
1476 if (system_setting_vconf_get_value_int(VCONFKEY_REGIONFORMAT_TIME1224, &vconf_value)) {
1477 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1480 bool ret_value = true;
1481 if (vconf_value == VCONFKEY_TIME_FORMAT_12)
1483 else if (vconf_value == VCONFKEY_TIME_FORMAT_24)
1486 *value = (void *)ret_value;
1488 return SYSTEM_SETTINGS_ERROR_NONE;
1490 /* LCOV_EXCL_STOP */
1492 int system_setting_set_locale_timeformat_24hour(system_settings_key_e key, void *value)
1494 SETTING_TRACE_BEGIN;
1497 vconf_value = (bool *)value;
1500 if (system_setting_vconf_set_value_int(VCONFKEY_REGIONFORMAT_TIME1224, VCONFKEY_TIME_FORMAT_24)) {
1501 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1505 if (system_setting_vconf_set_value_int(VCONFKEY_REGIONFORMAT_TIME1224, VCONFKEY_TIME_FORMAT_12)) {
1506 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1511 return SYSTEM_SETTINGS_ERROR_NONE;
1514 int system_setting_set_changed_callback_locale_timeformat_24hour(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1516 SETTING_TRACE_BEGIN;
1517 return system_setting_vconf_set_changed_cb(VCONFKEY_REGIONFORMAT_TIME1224, SYSTEM_SETTINGS_KEY_LOCALE_TIMEFORMAT_24HOUR, 3, user_data);
1520 int system_setting_unset_changed_callback_locale_timeformat_24hour(system_settings_key_e key)
1522 SETTING_TRACE_BEGIN;
1523 return system_setting_vconf_unset_changed_cb(VCONFKEY_REGIONFORMAT_TIME1224, 3);
1526 int system_setting_get_locale_timezone(system_settings_key_e key, void **value)
1529 ssize_t len = readlink(SETTING_TZONE_SYMLINK_PATH, tzpath, sizeof(tzpath)-1);
1533 SETTING_TRACE("parse error for SETTING_TZONE_SYMLINK_PATH");
1534 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1537 SETTING_TRACE("tzpath : %s ", &tzpath[20]);
1538 *value = strdup(&tzpath[20]);
1539 return SYSTEM_SETTINGS_ERROR_NONE;
1542 /* LCOV_EXCL_START */
1543 int system_setting_set_locale_timezone(system_settings_key_e key, void *value)
1545 SETTING_TRACE_BEGIN;
1546 char *timezone_value = NULL;
1547 timezone_value = (char *)value;
1550 snprintf(tz_path, 1024, "/usr/share/zoneinfo/%s", timezone_value);
1552 int is_load = _is_file_accessible(tz_path);
1554 alarmmgr_set_timezone(tz_path);
1556 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_TIMEZONE_ID, timezone_value)) {
1557 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1559 return SYSTEM_SETTINGS_ERROR_NONE;
1561 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
1563 /* LCOV_EXCL_STOP */
1567 /* LCOV_EXCL_START */
1568 int system_setting_set_changed_callback_locale_timezone(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1570 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_TIMEZONE_ID, SYSTEM_SETTINGS_KEY_LOCALE_TIMEZONE, 4, user_data);
1572 /* LCOV_EXCL_STOP */
1574 /* LCOV_EXCL_START */
1575 int system_setting_unset_changed_callback_locale_timezone(system_settings_key_e key)
1577 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_TIMEZONE_ID, 4);
1579 /* LCOV_EXCL_STOP */
1581 /* LCOV_EXCL_START */
1582 int system_setting_set_changed_callback_locale_timezone_changed(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1584 SETTING_TRACE_BEGIN;
1585 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
1587 /* LCOV_EXCL_STOP */
1589 /* LCOV_EXCL_START */
1590 int system_setting_unset_changed_callback_locale_timezone_changed(system_settings_key_e key)
1592 SETTING_TRACE_BEGIN;
1593 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
1595 /* LCOV_EXCL_STOP */
1598 /* LCOV_EXCL_START */
1599 int system_setting_get_time_changed(system_settings_key_e key, void **value)
1601 SETTING_TRACE_BEGIN;
1603 int ** val = (int**)value;
1604 cur_tick = time(NULL);
1606 /* struct tm * localtime = time (cur_tick); */
1607 /* printf("%s\n", ctime(&cur_tick); */
1608 return SYSTEM_SETTINGS_ERROR_NONE;
1611 /* LCOV_EXCL_STOP */
1613 int system_setting_set_changed_callback_time_changed(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1615 SETTING_TRACE_BEGIN;
1616 return system_setting_vconf_set_changed_cb(VCONFKEY_SYSTEM_TIME_CHANGED, SYSTEM_SETTINGS_KEY_TIME_CHANGED, 3, user_data);
1619 int system_setting_unset_changed_callback_time_changed(system_settings_key_e key)
1621 SETTING_TRACE_BEGIN;
1622 return system_setting_vconf_unset_changed_cb(VCONFKEY_SYSTEM_TIME_CHANGED, 3);
1627 /* SYSTEM_SETTINGS_KEY_SOUND_LOCK */
1628 int system_setting_get_sound_lock(system_settings_key_e key, void **value)
1630 SETTING_TRACE_BEGIN;
1633 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_SOUND_LOCK_BOOL, &vconf_value)) {
1634 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1636 *value = (void *)vconf_value;
1638 return SYSTEM_SETTINGS_ERROR_NONE;
1641 int system_setting_set_changed_callback_sound_lock(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1643 SETTING_TRACE_BEGIN;
1644 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_SOUND_LOCK_BOOL, SYSTEM_SETTINGS_KEY_SOUND_LOCK, 3, user_data);
1647 int system_setting_unset_changed_callback_sound_lock(system_settings_key_e key)
1649 SETTING_TRACE_BEGIN;
1650 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_SOUND_LOCK_BOOL, 3);
1654 * a = VCONFKEY_SETAPPL_SOUND_STATUS_BOOL b = VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL
1656 * a == false, b == false --> silent mode
1657 * a == true, b == false --> sound mode
1658 * a == false, b == true --> vibration mode
1660 /* LCOV_EXCL_START */
1661 int system_setting_get_sound_silent_mode(system_settings_key_e key, void **value)
1663 SETTING_TRACE_BEGIN;
1668 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, &sound_cond)) {
1669 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1672 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, &vib_cond)) {
1673 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1676 if (sound_cond == false && vib_cond == false) {
1678 *value = (void *)vconf_value;
1680 vconf_value = false;
1681 *value = (void *)vconf_value;
1683 return SYSTEM_SETTINGS_ERROR_NONE;
1685 /* LCOV_EXCL_STOP */
1688 * a = VCONFKEY_SETAPPL_SOUND_STATUS_BOOL b = VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL
1690 * a == false, b == false --> silent mode
1691 * a == true, b == false --> sound mode
1693 int system_setting_set_sound_silent_mode(system_settings_key_e key, void *value)
1695 SETTING_TRACE_BEGIN;
1698 vconf_value = (bool *)value;
1700 bool vconf_sound = false;
1701 bool vconf_vib = false;
1704 vconf_sound = false;
1711 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, vconf_sound)) {
1712 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1714 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, vconf_vib)) {
1715 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1718 return SYSTEM_SETTINGS_ERROR_NONE;
1724 int system_setting_set_changed_callback_sound_silent_mode(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1726 SETTING_TRACE_BEGIN;
1727 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, SYSTEM_SETTINGS_KEY_SOUND_SILENT_MODE, 3, user_data);
1731 int system_setting_unset_changed_callback_sound_silent_mode(system_settings_key_e key)
1733 SETTING_TRACE_BEGIN;
1734 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, 3);
1737 /* SYSTEM_SETTINGS_KEY_SOUND_TOUCH */
1738 int system_setting_get_sound_touch(system_settings_key_e key, void **value)
1740 SETTING_TRACE_BEGIN;
1743 int ret = system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL, &vconf_value);
1744 if (ret != SYSTEM_SETTINGS_ERROR_NONE) {
1747 *value = (void *)vconf_value;
1751 int system_setting_set_changed_callback_sound_touch(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1753 SETTING_TRACE_BEGIN;
1754 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL, SYSTEM_SETTINGS_KEY_SOUND_TOUCH, 2, user_data);
1757 int system_setting_unset_changed_callback_sound_touch(system_settings_key_e key)
1759 SETTING_TRACE_BEGIN;
1760 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL, 2);
1764 /* SYSTEM_SETTINGS_KEY_SOUND_LOCK */
1765 int system_setting_get_sound_lock(system_settings_key_e key, void **value)
1769 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_SOUND_LOCK_BOOL, &vconf_value)) {
1770 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1772 *value = (void *)vconf_value;
1774 return SYSTEM_SETTINGS_ERROR_NONE;
1778 int system_setting_get_auto_rotation_mode(system_settings_key_e key, void **value)
1780 SETTING_TRACE_BEGIN;
1783 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, &vconf_value)) {
1784 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1786 *value = (void *)vconf_value;
1788 return SYSTEM_SETTINGS_ERROR_NONE;
1791 /* LCOV_EXCL_START */
1792 int system_setting_set_auto_rotation_mode(system_settings_key_e key, void *value)
1794 SETTING_TRACE_BEGIN;
1796 vconf_value = (bool *)value;
1797 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, *vconf_value)) {
1798 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1801 return SYSTEM_SETTINGS_ERROR_NONE;
1803 /* LCOV_EXCL_STOP */
1805 int system_setting_set_changed_callback_auto_rotation_mode(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1807 SETTING_TRACE_BEGIN;
1808 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, SYSTEM_SETTINGS_KEY_DISPLAY_SCREEN_ROTATION_AUTO, 2, user_data);
1811 int system_setting_unset_changed_callback_auto_rotation_mode(system_settings_key_e key)
1813 SETTING_TRACE_BEGIN;
1814 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, 2);
1817 int system_setting_get_screen_backlight_time(system_settings_key_e key, void **value)
1819 SETTING_TRACE_BEGIN;
1821 int ** val = (int**)value;
1823 if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, &vconf_value)) {
1824 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1826 **val = vconf_value;
1828 return SYSTEM_SETTINGS_ERROR_NONE;
1832 /* LCOV_EXCL_START */
1833 int system_setting_set_screen_backlight_time(system_settings_key_e key, void *value)
1835 SETTING_TRACE_BEGIN;
1837 vconf_value = *(int **)value;
1839 if (!(*vconf_value > 0 && *vconf_value <= 600)) {
1840 SETTING_TRACE(" ERR Betweeny here 0 ~ 600");
1841 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
1844 if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, *vconf_value)) {
1845 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1848 return SYSTEM_SETTINGS_ERROR_NONE;
1850 /* LCOV_EXCL_STOP */
1852 int system_setting_set_changed_callback_screen_backlight_time(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1854 SETTING_TRACE_BEGIN;
1855 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, SYSTEM_SETTINGS_KEY_SCREEN_BACKLIGHT_TIME, 2, user_data);
1858 int system_setting_unset_changed_callback_screen_backlight_time(system_settings_key_e key)
1860 SETTING_TRACE_BEGIN;
1861 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, 2);
1864 int system_setting_get_sound_notification(system_settings_key_e key, void **value)
1866 SETTING_TRACE_BEGIN;
1867 char *vconf_value = NULL;
1868 if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, &vconf_value)) {
1869 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1872 *value = vconf_value;
1873 return SYSTEM_SETTINGS_ERROR_NONE;
1876 /* LCOV_EXCL_START */
1877 int system_setting_set_sound_notification(system_settings_key_e key, void *value)
1879 SETTING_TRACE_BEGIN;
1880 char *vconf_value = NULL;
1881 vconf_value = (char *)value;
1883 int is_load = _is_file_accessible(vconf_value);
1885 //SETTING_TRACE(" system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, %s) TRY", vconf_value);
1886 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, vconf_value)) {
1887 //SETTING_TRACE(" system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, %s) FAIL", vconf_value);
1888 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1891 //SETTING_TRACE(" is_file_accessibile FAILED - system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, %s) FAIL", vconf_value);
1892 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1895 return SYSTEM_SETTINGS_ERROR_NONE;
1897 /* LCOV_EXCL_STOP */
1899 int system_setting_set_changed_callback_sound_notification(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1901 SETTING_TRACE_BEGIN;
1902 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, SYSTEM_SETTINGS_KEY_SOUND_NOTIFICATION, 0, user_data);
1905 int system_setting_unset_changed_callback_sound_notification(system_settings_key_e key)
1907 SETTING_TRACE_BEGIN;
1908 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, 0);
1911 int system_setting_get_notification_repetition_period(system_settings_key_e key, void **value)
1913 SETTING_TRACE_BEGIN;
1914 int ** val = (int**)value;
1917 if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_NOTI_MSG_ALERT_REP_TYPE_INT, &vconf_value)) {
1918 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1920 **val = vconf_value;
1922 return SYSTEM_SETTINGS_ERROR_NONE;
1925 /* LCOV_EXCL_START */
1926 int system_setting_set_notification_repetition_period(system_settings_key_e key, void *value)
1928 SETTING_TRACE_BEGIN;
1930 vconf_value = *(int **)value;
1932 if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_NOTI_MSG_ALERT_REP_TYPE_INT, *vconf_value)) {
1933 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1936 return SYSTEM_SETTINGS_ERROR_NONE;
1938 /* LCOV_EXCL_STOP */
1940 int system_setting_set_changed_callback_notification_repetition_period(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1942 SETTING_TRACE_BEGIN;
1943 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);
1946 int system_setting_unset_changed_callback_notification_repetition_period(system_settings_key_e key)
1948 SETTING_TRACE_BEGIN;
1949 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_ALERT_REP_TYPE_INT, 1);
1952 int system_setting_get_device_name(system_settings_key_e key, void **value)
1954 SETTING_TRACE_BEGIN;
1955 char *vconf_value = NULL;
1956 if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_DEVICE_NAME_STR, &vconf_value)) {
1957 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1960 *value = vconf_value;
1961 return SYSTEM_SETTINGS_ERROR_NONE;
1964 /* LCOV_EXCL_START */
1965 int system_setting_set_device_name(system_settings_key_e key, void *value)
1967 SETTING_TRACE_BEGIN;
1968 char *vconf_value = NULL;
1969 vconf_value = (char *)value;
1971 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_DEVICE_NAME_STR, vconf_value)) {
1972 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1975 return SYSTEM_SETTINGS_ERROR_NONE;
1977 /* LCOV_EXCL_STOP */
1979 int system_setting_set_changed_callback_device_name(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1981 SETTING_TRACE_BEGIN;
1982 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_DEVICE_NAME_STR, SYSTEM_SETTINGS_KEY_DEVICE_NAME, 0, user_data);
1985 int system_setting_unset_changed_callback_device_name(system_settings_key_e key)
1987 SETTING_TRACE_BEGIN;
1988 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_DEVICE_NAME_STR, 0);
1991 /*---------------------------------------------- */
1992 int system_setting_get_network_flight_mode(system_settings_key_e key, void **value)
1994 SETTING_TRACE_BEGIN;
1996 if (system_setting_vconf_get_value_bool(VCONFKEY_TELEPHONY_FLIGHT_MODE, &vconf_value)) {
1997 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1999 *value = (void *)vconf_value;
2001 return SYSTEM_SETTINGS_ERROR_NONE;
2004 int system_setting_set_changed_callback_network_flight_mode(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
2006 SETTING_TRACE_BEGIN;
2007 return system_setting_vconf_set_changed_cb(VCONFKEY_TELEPHONY_FLIGHT_MODE, SYSTEM_SETTINGS_KEY_NETWORK_FLIGHT_MODE, 3, user_data);
2010 int system_setting_unset_changed_callback_network_flight_mode(system_settings_key_e key)
2012 SETTING_TRACE_BEGIN;
2013 return system_setting_vconf_unset_changed_cb(VCONFKEY_TELEPHONY_FLIGHT_MODE, 3);
2016 int system_setting_get_network_wifi_notification(system_settings_key_e key, void **value)
2018 SETTING_TRACE_BEGIN;
2020 if (system_setting_vconf_get_value_int(VCONFKEY_WIFI_ENABLE_QS, &vconf_value)) {
2021 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2024 bret = (vconf_value == VCONFKEY_WIFI_QS_ENABLE) ? true : false;
2026 *value = (void *)bret;
2027 return SYSTEM_SETTINGS_ERROR_NONE;
2030 int system_setting_set_changed_callback_network_wifi_notification(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
2032 SETTING_TRACE_BEGIN;
2033 return system_setting_vconf_set_changed_cb(VCONFKEY_WIFI_ENABLE_QS, SYSTEM_SETTINGS_KEY_NETWORK_WIFI_NOTIFICATION, 4, user_data);
2036 int system_setting_unset_changed_callback_network_wifi_notification(system_settings_key_e key)
2038 SETTING_TRACE_BEGIN;
2039 return system_setting_vconf_unset_changed_cb(VCONFKEY_WIFI_ENABLE_QS, 4);
2042 /* LCOV_EXCL_START */
2043 int system_setting_get_lock_state(system_settings_key_e key, void **value)
2046 int ** val = (int**)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 **val = 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, 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, 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 int system_setting_set_ads_id(system_settings_key_e key, void *value)
2125 SETTING_TRACE_BEGIN;
2126 char *vconf_value = NULL;
2127 vconf_value = (char *)value;
2129 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_AD_ID, vconf_value)) {
2130 SETTING_TRACE("Setting VCONFKEY_SETAPPL_AD_ID failed");
2131 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2134 return SYSTEM_SETTINGS_ERROR_NONE;
2137 int system_setting_set_changed_callback_ads_id(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
2139 SETTING_TRACE_BEGIN;
2140 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_AD_ID, SYSTEM_SETTINGS_KEY_ADS_ID, 0, user_data);
2143 int system_setting_unset_changed_callback_ads_id(system_settings_key_e key)
2145 SETTING_TRACE_BEGIN;
2146 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_AD_ID, 0);
2149 int system_settings_feature_check_bool(char *path)
2151 bool profile_data = false;
2152 int ret = system_info_get_platform_bool(path, &profile_data);
2153 if (ret != SYSTEM_INFO_ERROR_NONE) {
2154 SETTING_TRACE("Setting - reading profile string failed, %d", ret);
2155 return SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED;
2158 ret = (profile_data == true) ? SYSTEM_SETTINGS_ERROR_NONE : SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED;
2164 int system_setting_feature_check_incoming_call(void *value)
2166 static bool first_query = true;
2167 static int ret = SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED;
2169 if (first_query == true) {
2170 ret = system_settings_feature_check_bool(SETTING_INCOMING_CALL_PATH);
2171 first_query = false;
2177 int system_setting_feature_check_home_screen(void *value)
2179 static bool first_query = true;
2180 static int ret = SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED;
2182 if (first_query == true) {
2183 ret = system_settings_feature_check_bool(SETTING_HOME_SCREEN_PATH);
2184 first_query = false;
2190 int system_setting_feature_check_lock_screen(void *value)
2192 static bool first_query = true;
2193 static int ret = SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED;
2195 if (first_query == true) {
2196 ret = system_settings_feature_check_bool(SETTING_LOCK_SCREEN_PATH);
2197 first_query = false;
2203 int system_setting_feature_check_notification_email(void *value)
2205 static bool first_query = true;
2206 static int ret = SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED;
2208 if (first_query == true) {
2209 ret = system_settings_feature_check_bool(SETTING_NOTIFICATION_EMAIL_PATH);
2210 first_query = false;
2216 int system_setting_feature_check_wifi(void *value)
2218 static bool first_query = true;
2219 static int ret = SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED;
2221 if (first_query == true) {
2222 ret = system_settings_feature_check_bool(SETTING_WIFI_PATH);
2223 first_query = false;
2229 int system_setting_feature_check_telephony(void *value)
2231 static bool first_query = true;
2232 static int ret = SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED;
2234 if (first_query == true) {
2235 ret = system_settings_feature_check_bool(SETTING_TELEPHONY_PATH);
2236 first_query = false;
2243 int system_setting_feature_check_font(void *value)
2245 static bool first_query = true;
2246 static int ret = SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED;
2248 if (first_query == true) {
2249 ret = system_settings_feature_check_bool(SETTING_FONT_PATH);
2250 first_query = false;
2256 int system_setting_feature_check_accessibility_grayscale(void *value)
2258 static bool first_query = true;
2259 static int ret = SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED;
2261 if (first_query == true) {
2262 ret = system_settings_feature_check_bool(SETTING_ACCESSIBILITY_GRAYSCALE_PATH);
2263 first_query = false;
2269 int system_setting_feature_check_accessibility_negative(void *value)
2271 static bool first_query = true;
2272 static int ret = SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED;
2274 if (first_query == true) {
2275 ret = system_settings_feature_check_bool(SETTING_ACCESSIBILITY_NEGATIVE_PATH);
2276 first_query = false;
2282 /* LCOV_EXCL_START */
2283 int system_setting_get_uds_state(system_settings_key_e key, void **value)
2285 int ** p_value = (int**)value;
2287 char *vconf_string_value = NULL;
2289 if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_UDSM, &vconf_value)) {
2290 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2293 SETTING_TRACE("[%s] udsm: %d", __FUNCTION__, vconf_value);
2295 if (vconf_value == SYSTEM_SETTINGS_UDS_ON) {
2296 if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_UDSM_PKGID_LIST, &vconf_string_value))
2297 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2299 if (vconf_string_value) {
2300 if (!strcmp(vconf_string_value, "NONE")) {
2301 vconf_value = SYSTEM_SETTINGS_UDS_ON;
2303 char *app_id = NULL;
2304 char *package_id = NULL;
2305 pid_t pid = getpid();
2306 app_manager_get_app_id(pid, &app_id);
2310 result = package_manager_get_package_id_by_app_id(app_id, &package_id);
2311 if (result != PACKAGE_MANAGER_ERROR_NONE) {
2312 SETTING_TRACE("package_manager_get_package_id_by_app_id returned error! %d", result);
2313 if (vconf_string_value)
2314 free(vconf_string_value);
2315 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2318 SETTING_TRACE("[%s] udsm_pkg_list : %s", __FUNCTION__, vconf_string_value);
2321 if (package_id && strstr(vconf_string_value, package_id)) {
2322 vconf_value = SYSTEM_SETTINGS_UDS_ON_WHITELISTED;
2323 SETTING_TRACE("[%s] pkg id : %s", __FUNCTION__, package_id);
2325 vconf_value = SYSTEM_SETTINGS_UDS_ON;
2329 if (vconf_string_value)
2330 free(vconf_string_value);
2334 **p_value = vconf_value;
2337 return SYSTEM_SETTINGS_ERROR_NONE;
2339 /* LCOV_EXCL_STOP */
2341 /* LCOV_EXCL_START */
2342 int system_setting_set_changed_callback_uds_state(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
2344 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_UDSM, SYSTEM_SETTINGS_KEY_ULTRA_DATA_SAVE, 4, user_data);
2346 /* LCOV_EXCL_STOP */
2348 /* LCOV_EXCL_START */
2349 int system_setting_unset_changed_callback_uds_state(system_settings_key_e key)
2351 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_UDSM, 4);
2353 /* LCOV_EXCL_STOP */
2355 /* LCOV_EXCL_START */
2356 int system_setting_set_changed_callback_uds_pkg_list(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
2358 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_UDSM_PKGID_LIST, SYSTEM_SETTINGS_KEY_ULTRA_DATA_SAVE_PKG_LIST, 4, user_data);
2360 /* LCOV_EXCL_STOP */
2362 /* LCOV_EXCL_START */
2363 int system_setting_unset_changed_callback_uds_pkg_list(system_settings_key_e key)
2365 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_UDSM_PKGID_LIST, 4);
2367 /* LCOV_EXCL_STOP */
2369 /* SYSTEM_SETTINGS_KEY_ACCESSIBILITY_TTS */
2370 int system_setting_get_accessibility_tts(system_settings_key_e key, void **value)
2372 SETTING_TRACE_BEGIN;
2375 int ret = system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_ACCESSIBILITY_TTS, &vconf_value);
2376 if (ret != SYSTEM_SETTINGS_ERROR_NONE) {
2379 *value = (void *)vconf_value;
2383 int system_setting_set_changed_callback_accessibility_tts(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
2385 SETTING_TRACE_BEGIN;
2386 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_TTS, SYSTEM_SETTINGS_KEY_ACCESSIBILITY_TTS, 2, user_data);
2389 int system_setting_unset_changed_callback_accessibility_tts(system_settings_key_e key)
2391 SETTING_TRACE_BEGIN;
2392 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_TTS, 2);
2395 /* SYSTEM_SETTINGS_KEY_VIBRATION */
2396 int system_setting_get_vibration(system_settings_key_e key, void **value)
2398 SETTING_TRACE_BEGIN;
2401 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, &vconf_value)) {
2402 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2404 *value = (void *)vconf_value;
2406 return SYSTEM_SETTINGS_ERROR_NONE;
2409 /* LCOV_EXCL_START */
2410 int system_setting_set_vibration(system_settings_key_e key, void *value)
2412 SETTING_TRACE_BEGIN;
2414 vconf_value = (bool *)value;
2415 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, *vconf_value)) {
2416 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2419 return SYSTEM_SETTINGS_ERROR_NONE;
2421 /* LCOV_EXCL_STOP */
2423 int system_setting_set_changed_callback_vibration(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
2425 SETTING_TRACE_BEGIN;
2426 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, SYSTEM_SETTINGS_KEY_VIBRATION, 2, user_data);
2429 int system_setting_unset_changed_callback_vibration(system_settings_key_e key)
2431 SETTING_TRACE_BEGIN;
2432 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, 2);
2435 /* SYSTEM_SETTINGS_KEY_AUTOMATIC_TIME_UPDATE */
2436 int system_setting_get_automatic_time_update(system_settings_key_e key, void **value)
2438 SETTING_TRACE_BEGIN;
2441 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_STATE_AUTOMATIC_TIME_UPDATE_BOOL, &vconf_value)) {
2442 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2444 *value = (void *)vconf_value;
2446 return SYSTEM_SETTINGS_ERROR_NONE;
2449 /* LCOV_EXCL_START */
2450 int system_setting_set_automatic_time_update(system_settings_key_e key, void *value)
2452 SETTING_TRACE_BEGIN;
2454 vconf_value = (bool *)value;
2455 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_STATE_AUTOMATIC_TIME_UPDATE_BOOL, *vconf_value)) {
2456 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2459 return SYSTEM_SETTINGS_ERROR_NONE;
2461 /* LCOV_EXCL_STOP */
2463 int system_setting_set_changed_callback_automatic_time_update(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
2465 SETTING_TRACE_BEGIN;
2466 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_STATE_AUTOMATIC_TIME_UPDATE_BOOL, SYSTEM_SETTINGS_KEY_AUTOMATIC_TIME_UPDATE, 2, user_data);
2469 int system_setting_unset_changed_callback_automatic_time_update(system_settings_key_e key)
2471 SETTING_TRACE_BEGIN;
2472 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_STATE_AUTOMATIC_TIME_UPDATE_BOOL, 2);
2475 /* SYSTEM_SETTINGS_KEY_DEVELOPER_OPTION_STATE */
2476 int system_setting_get_developer_option_state(system_settings_key_e key, void **value)
2478 SETTING_TRACE_BEGIN;
2481 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_DEVELOPER_OPTION_STATE, &vconf_value)) {
2482 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2484 *value = (void *)vconf_value;
2486 return SYSTEM_SETTINGS_ERROR_NONE;
2489 /* LCOV_EXCL_START */
2490 int system_setting_set_developer_option_state(system_settings_key_e key, void *value)
2492 SETTING_TRACE_BEGIN;
2494 vconf_value = (bool *)value;
2495 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_DEVELOPER_OPTION_STATE, *vconf_value)) {
2496 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2499 return SYSTEM_SETTINGS_ERROR_NONE;
2501 /* LCOV_EXCL_STOP */
2503 int system_setting_set_changed_callback_developer_option_state(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
2505 SETTING_TRACE_BEGIN;
2506 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_DEVELOPER_OPTION_STATE, SYSTEM_SETTINGS_KEY_DEVELOPER_OPTION_STATE, 2, user_data);
2509 int system_setting_unset_changed_callback_developer_option_state(system_settings_key_e key)
2511 SETTING_TRACE_BEGIN;
2512 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_DEVELOPER_OPTION_STATE, 2);
2515 /* SYSTEM_SETTINGS_KEY_ACCESSIBILITY_GRAYSCALE */
2516 int system_setting_get_accessibility_grayscale(system_settings_key_e key, void **value)
2518 SETTING_TRACE_BEGIN;
2521 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_ACCESSIBILITY_GREYSCALE, &vconf_value)) {
2522 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2524 *value = (void *)vconf_value;
2526 return SYSTEM_SETTINGS_ERROR_NONE;
2529 /* LCOV_EXCL_START */
2530 int system_setting_set_accessibility_grayscale(system_settings_key_e key, void *value)
2532 SETTING_TRACE_BEGIN;
2534 vconf_value = (bool *)value;
2535 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_ACCESSIBILITY_GREYSCALE, *vconf_value)) {
2536 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2539 return SYSTEM_SETTINGS_ERROR_NONE;
2541 /* LCOV_EXCL_STOP */
2543 int system_setting_set_changed_callback_accessibility_grayscale(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
2545 SETTING_TRACE_BEGIN;
2546 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_GREYSCALE, SYSTEM_SETTINGS_KEY_ACCESSIBILITY_GRAYSCALE, 2, user_data);
2549 int system_setting_unset_changed_callback_accessibility_grayscale(system_settings_key_e key)
2551 SETTING_TRACE_BEGIN;
2552 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_GREYSCALE, 2);
2555 /* SYSTEM_SETTINGS_KEY_ACCESSIBILITY_NEGATIVE_COLOR */
2556 int system_setting_get_accessibility_negative_color(system_settings_key_e key, void **value)
2558 SETTING_TRACE_BEGIN;
2561 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_ACCESSIBILITY_HIGH_CONTRAST, &vconf_value)) {
2562 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2564 *value = (void *)vconf_value;
2566 return SYSTEM_SETTINGS_ERROR_NONE;
2569 /* LCOV_EXCL_START */
2570 int system_setting_set_accessibility_negative_color(system_settings_key_e key, void *value)
2572 SETTING_TRACE_BEGIN;
2574 vconf_value = (bool *)value;
2575 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_ACCESSIBILITY_HIGH_CONTRAST, *vconf_value)) {
2576 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2579 return SYSTEM_SETTINGS_ERROR_NONE;
2581 /* LCOV_EXCL_STOP */
2583 int system_setting_set_changed_callback_accessibility_negative_color(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
2585 SETTING_TRACE_BEGIN;
2586 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_HIGH_CONTRAST, SYSTEM_SETTINGS_KEY_ACCESSIBILITY_NEGATIVE_COLOR, 2, user_data);
2589 int system_setting_unset_changed_callback_accessibility_negative_color(system_settings_key_e key)
2591 SETTING_TRACE_BEGIN;
2592 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_HIGH_CONTRAST, 2);