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.
26 #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 gint _compare_cb(gconstpointer d1, gconstpointer 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 GList *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);
406 filelist = g_list_sort(filelist, _compare_cb);
408 for (iter = filelist; iter != NULL; iter = g_list_next(iter)) {
409 node = (fileNodeInfo *)iter->data;
410 SETTING_TRACE("file path = (%d) : name:%s path:%s [%s]", ret, node->name, node->path, node->media_name);
411 // @todo assert NULL check
414 snprintf(temp, 1024, "%s/%s", node->path, node->name);
415 char* path = strdup(temp);
416 bool ret = callback(idx, (void *)(path), data);
422 SETTING_TRACE("quit the iteration by return value == false : %d", ret);
427 SETTING_TRACE("--> system_setting_data_iterator is NULL");
431 for (iter = filelist; iter != NULL; iter = g_list_next(iter)) {
432 node = (fileNodeInfo *)iter->data;
435 FREE(node->media_name);
438 g_list_free(filelist);
443 static void _get_user_ringtones(system_settings_key_e key, system_settings_iter_cb callback, void *data)
449 JsonParser* parser = ss_json_ringtone_open_file(JSONFILE);
451 JsonParser* parser = ss_json_ringtone_load_from_data();
454 JsonNode *root = json_parser_get_root(parser);
455 int size = json_array_get_length(json_node_get_array(root));
458 for (i = 0; i < size ; i++) {
459 JsonObject *ringtone = json_array_get_object_element(json_node_get_array(root), i);
460 char *nameval = (char *)json_object_get_string_member(ringtone, "name");
461 char *pathval = (char *)json_object_get_string_member(ringtone, "path");
462 SETTING_TRACE("(%s) --- (%s) \n", nameval, pathval);
463 if (callback && pathval) {
464 char* path = strdup(pathval);
465 bool ret = callback(i, (void *)(path), data);
467 SETTING_TRACE("quit the iteration by return value == false : %d", ret);
472 SETTING_TRACE("--> callback is NULL");
476 g_object_unref(parser);
479 int system_setting_list_incoming_call_ringtone(system_settings_key_e key, system_settings_iter_cb callback, void *data)
483 _get_default_ringtones(key, callback, data);
484 //-----------------------------------------------------------------------------------------------------------------
485 // 2. get the USER ringtone list
486 //-----------------------------------------------------------------------------------------------------------------
487 _get_user_ringtones(key, callback, data);
489 return SYSTEM_SETTINGS_ERROR_NONE;
493 /* LCOV_EXCL_START */
494 int system_setting_set_incoming_call_ringtone(system_settings_key_e key, void *value)
498 vconf_value = (char *)value;
500 int ret = _is_file_accessible(vconf_value);
502 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR, vconf_value)) {
503 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
506 /* @todo add a common ret_handler */
510 return SYSTEM_SETTINGS_ERROR_NONE;
515 /* LCOV_EXCL_START */
516 int system_setting_set_email_alert_ringtone(system_settings_key_e key, void *value)
520 vconf_value = (char *)value;
522 int ret = _is_file_accessible(vconf_value);
524 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, vconf_value)) {
525 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
528 /*return SYSTEM_SETTINGS_ERROR_IO_ERROR;*/
529 /* @todo add a common ret_handler */
533 return SYSTEM_SETTINGS_ERROR_NONE;
537 /* LCOV_EXCL_START */
538 static bool dl_is_supported_image_type_load(char *path)
543 bool (*image_type_check)(char *path);
545 handle = dlopen(SETTING_UTILS_SO_FILE_PATH, RTLD_LAZY);
547 SETTING_TRACE("ERROR!! canNOT find libsystem-settings-util.so.0.1.0");
551 image_type_check = dlsym(handle, "__is_supported_image_type_load");
552 if ((error = dlerror()) != NULL) {
553 SETTING_TRACE("ERROR!! canNOT find __is_supported_image_type_load function at libsystem-settings-util.so.0.1.0");
558 ret = image_type_check(path);
565 /* LCOV_EXCL_START */
566 static int dl_is_available_font(char *str)
571 int (*check_available_font)(char *font_name);
573 handle = dlopen(SETTING_UTILS_SO_FILE_PATH, RTLD_LAZY);
575 SETTING_TRACE("ERROR!! canNOT find libsystem-settings-util.so.0.1.0");
579 check_available_font = dlsym(handle, "__is_available_font");
580 if ((error = dlerror()) != NULL) {
581 SETTING_TRACE("ERROR!! canNOT find __is_available_font function at libsystem-settings-util.so.0.1.0");
586 ret = check_available_font(str);
593 /* LCOV_EXCL_START */
594 static void dl_font_size_set()
598 void (*set_font_size)();
600 handle = dlopen(SETTING_UTILS_SO_FILE_PATH, RTLD_LAZY);
602 SETTING_TRACE("ERROR!! canNOT find libsystem-settings-util.so.0.1.0");
606 set_font_size = dlsym(handle, "__font_size_set");
607 if ((error = dlerror()) != NULL) {
608 SETTING_TRACE("ERROR!! canNOT find __font_size_set function at libsystem-settings-util.so.0.1.0");
620 /* LCOV_EXCL_START */
621 static void dl_font_config_set_notification()
625 void (*set_font_nodification)();
627 handle = dlopen(SETTING_UTILS_SO_FILE_PATH, RTLD_LAZY);
629 SETTING_TRACE("ERROR!! canNOT find libsystem-settings-util.so.0.1.0");
633 set_font_nodification = dlsym(handle, "font_config_set_notification");
634 if ((error = dlerror()) != NULL) {
635 SETTING_TRACE("ERROR!! canNOT find font_config_set_notification function at libsystem-settings-util.so.0.1.0");
640 set_font_nodification();
647 /* LCOV_EXCL_START */
648 static bool dl_font_config_set(char *font_name)
653 bool (*check_font_type)(char *font_name);
655 handle = dlopen(SETTING_UTILS_SO_FILE_PATH, RTLD_LAZY);
657 SETTING_TRACE("ERROR!! canNOT find libsystem-settings-util.so.0.1.0");
661 check_font_type = dlsym(handle, "font_config_set");
662 if ((error = dlerror()) != NULL) {
663 SETTING_TRACE("ERROR!! canNOT find font_config_set function at libsystem-settings-util.so.0.1.0");
668 ret = check_font_type(font_name);
675 /* LCOV_EXCL_START */
676 static char *dl_get_default_font_info()
681 char *(*get_font_info)();
683 handle = dlopen(SETTING_UTILS_SO_FILE_PATH, RTLD_LAZY);
685 SETTING_TRACE("ERROR!! canNOT find libsystem-settings-util.so.0.1.0");
689 get_font_info = dlsym(handle, "_get_default_font");
691 if ((error = dlerror()) != NULL) {
692 SETTING_TRACE("ERROR!! canNOT find _get_default_font function at libsystem-settings-util.so.0.1.0");
697 ret = get_font_info();
704 #ifdef TIZEN_WEARABLE
705 /* LCOV_EXCL_START */
706 static int system_setting_get_extended_wallpaper_num(const char *file_path, unsigned int *num)
710 const char *find_str = "extended_wallpaper_";
713 if (!(ch = strstr(file_path, find_str))) {
714 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
716 strncpy(buffer, file_path, ch - file_path);
717 buffer[ch - file_path] = 0;
718 sprintf(buffer + (ch - file_path), "%s%s", "", ch + strlen(find_str));
720 if (!isdigit(buffer[0])) {
721 SETTING_TRACE("%s is not number", buffer);
722 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
727 return SYSTEM_SETTINGS_ERROR_NONE;
731 /* LCOV_EXCL_START */
732 static int system_setting_copy_extended_wallpaper(const char *dest_file_path, const char *source_file_path)
735 if (!source_file_path || !dest_file_path) {
736 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
742 fd = open(source_file_path, O_RDONLY);
744 SETTING_TRACE("file open failed: %s", source_file_path);
745 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
749 fd2 = open(dest_file_path, O_WRONLY | O_CREAT, S_IRWXU | S_IRWXG | S_IRWXO);
751 SETTING_TRACE("file creation failed: %s", dest_file_path);
753 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
756 while (read(fd, buf, sizeof(buf) - 1) > 0) {
757 write(fd2, buf, sizeof(buf) - 1);
763 if (chmod(dest_file_path, S_IRWXU | S_IRWXG | S_IRWXO) < 0) {
764 SETTING_TRACE("chmod failed: %s", dest_file_path);
767 return SYSTEM_SETTINGS_ERROR_NONE;
771 /* LCOV_EXCL_START */
772 static int system_setting_remove_oldest_extended_wallpaper()
777 char *min_image_name = NULL;
778 unsigned int min_image_num = 0;
779 unsigned int temp_image_num = 0;
782 if ((dp = opendir(_TZ_SYS_DATA"/setting/wallpaper")) == NULL) {
783 SETTING_TRACE("opendir error");
784 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
787 while ((dirp = readdir(dp))) {
788 if (!strcmp(dirp->d_name, ".") || !strcmp(dirp->d_name, ".."))
791 if (system_setting_get_extended_wallpaper_num(dirp->d_name, &temp_image_num)
792 != SYSTEM_SETTINGS_ERROR_NONE) {
793 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
796 if ((image_count == 0) || (min_image_num > temp_image_num)) {
797 min_image_num = temp_image_num;
798 min_image_name = dirp->d_name;
805 if (min_image_name) {
806 snprintf(buf, sizeof(buf) - 1, _TZ_SYS_DATA"/setting/wallpaper/%s", min_image_name);
807 if (remove(buf) < 0) { /* remove oldest image */
808 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
812 return SYSTEM_SETTINGS_ERROR_NONE;
816 /* LCOV_EXCL_START */
817 static int system_setting_check_extended_wallpaper(const char *file_path)
821 if (!file_path || !strlen(file_path))
823 snprintf(buffer, 512, "%s/.bgwallpaper", tzplatform_getenv(TZ_USER_CONTENT));
824 return (strstr(file_path, buffer) != NULL);
828 #define WALLPAPER_MAX_COUNT 10
830 /* LCOV_EXCL_START */
831 int system_setting_set_wallpaper_home_screen(system_settings_key_e key, void *value)
835 vconf_value = (char *)value;
837 bool isok = dl_is_supported_image_type_load(vconf_value);
840 SETTING_TRACE("path : %s is not supported file format", vconf_value);
841 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
843 SETTING_TRACE("path : %s is SUPPORT file format", vconf_value);
846 /* error handling here */
847 if (_is_file_accessible(vconf_value) != 0)
848 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
850 if (system_setting_vconf_set_value_string(VCONFKEY_BGSET, vconf_value)) {
851 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
855 #ifdef TIZEN_WEARABLE
856 if (system_setting_check_extended_wallpaper(vconf_value)) { /* New extended wallpaper */
859 unsigned int max_image_num = 0;
860 unsigned int temp_image_num = 0;
863 if ((dp = opendir(_TZ_SYS_DATA"/setting/wallpaper")) == NULL) {
864 SETTING_TRACE("Setting - dir open error!");
865 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
868 /* Check a max number of wallpapers */
869 while ((dirp = readdir(dp))) {
870 if (!strcmp(dirp->d_name, ".") || !strcmp(dirp->d_name, ".."))
873 if (system_setting_get_extended_wallpaper_num(dirp->d_name, &temp_image_num)
874 != SYSTEM_SETTINGS_ERROR_NONE) {
877 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
880 if ((image_count == 0) || (max_image_num < temp_image_num)) {
881 max_image_num = temp_image_num;
889 /* Numbering rule: Gear is odd number */
890 max_image_num = (max_image_num % 2 == 0) ? max_image_num + 1
893 char file_name_buffer[512];
894 snprintf(file_name_buffer, sizeof(file_name_buffer) - 1,
895 _TZ_SYS_DATA"/setting/wallpaper/extended_wallpaper_%d.jpg", max_image_num);
897 /* Copy image to _TZ_SYS_DATA/setting/wallpaper/ */
898 if (system_setting_copy_extended_wallpaper(file_name_buffer, vconf_value)
899 != SYSTEM_SETTINGS_ERROR_NONE) {
900 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
903 /* remove oldest wallpaper */
904 if (image_count >= WALLPAPER_MAX_COUNT) {
905 if (system_setting_remove_oldest_extended_wallpaper()
906 != SYSTEM_SETTINGS_ERROR_NONE) {
907 remove(file_name_buffer);
908 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
912 if (system_setting_vconf_set_value_string(VCONFKEY_BGSET, file_name_buffer)) {
913 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
916 if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_WALLPAPER_CHANGED_NOTI_INT,
917 VCONFKEY_WALLPAPER_CHANGED_NOTI_GEAR)) {
918 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
921 if (system_setting_vconf_set_value_string(VCONFKEY_BGSET, vconf_value)) {
922 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
927 return SYSTEM_SETTINGS_ERROR_NONE;
931 /* LCOV_EXCL_START */
932 int system_setting_set_wallpaper_lock_screen(system_settings_key_e key, void *value)
936 vconf_value = (char *)value;
938 bool isok = dl_is_supported_image_type_load(vconf_value);
941 SETTING_TRACE("path : %s is not supported file format", vconf_value);
942 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
944 SETTING_TRACE("path : %s is SUPPORT file format", vconf_value);
947 /* error handling here */
948 if (_is_file_accessible(vconf_value) != 0)
949 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
951 if (system_setting_vconf_set_value_string(VCONFKEY_IDLE_LOCK_BGSET, vconf_value)) {
952 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
955 return SYSTEM_SETTINGS_ERROR_NONE;
959 /* LCOV_EXCL_START */
960 int system_setting_set_font_size(system_settings_key_e key, void *value)
964 vconf_value = *(int **)value;
966 if (*vconf_value < 0 || *vconf_value > SYSTEM_SETTINGS_FONT_SIZE_GIANT) {
967 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
970 if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, *vconf_value)) {
971 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
975 return SYSTEM_SETTINGS_ERROR_NONE;
981 /* LCOV_EXCL_START */
982 void *font_conf_doc_parse(char *doc_name, char *font_name)
985 xmlDocPtr doc = NULL;
986 xmlNodePtr cur = NULL;
987 xmlNodePtr cur2 = NULL;
988 xmlNodePtr cur3 = NULL;
991 doc = xmlParseFile(doc_name);
993 cur = xmlDocGetRootElement(doc);
1001 if (xmlStrcmp(cur->name, (const xmlChar *)"fontconfig")) {
1007 cur = cur->xmlChildrenNode;
1009 bool is_changed = false;
1010 while (cur != NULL) {
1011 if ((!xmlStrcmp(cur->name, (const xmlChar *)"match"))) {
1012 cur2 = cur->xmlChildrenNode;
1013 while (cur2 != NULL) {
1014 if ((!xmlStrcmp(cur2->name, (const xmlChar *)"edit"))) {
1015 xmlChar *name = xmlGetProp(cur2, (const xmlChar *)"name");
1016 /* if name is not 'family', break */
1017 if (xmlStrcmp(name, (const xmlChar *)"family")) {
1025 cur3 = cur2->xmlChildrenNode;
1026 while (cur3 != NULL) {
1027 if ((!xmlStrcmp(cur3->name, (const xmlChar *)"string"))) {
1028 xmlNodeSetContent(cur3->xmlChildrenNode, (const xmlChar *)font_name);
1029 key = xmlNodeListGetString(doc, cur3->xmlChildrenNode, 1);
1039 } else if ((!xmlStrcmp(cur->name, (const xmlChar *)"alias"))) {
1040 cur2 = cur->xmlChildrenNode;
1041 while (cur2 != NULL) {
1042 if ((!xmlStrcmp(cur2->name, (const xmlChar *)"family"))) {
1043 xmlNodeSetContent(cur2->xmlChildrenNode, (const xmlChar *)font_name);
1044 key = xmlNodeListGetString(doc, cur2->xmlChildrenNode, 1);
1048 } else if ((!xmlStrcmp(cur2->name, (const xmlChar *)"prefer"))) {
1049 cur3 = cur2->xmlChildrenNode;
1050 while (cur3 != NULL) {
1051 if ((!xmlStrcmp(cur3->name, (const xmlChar *)"family"))) {
1052 xmlNodeSetContent(cur3->xmlChildrenNode, (const xmlChar *)font_name);
1053 key = xmlNodeListGetString(doc, cur3->xmlChildrenNode, 1);
1077 /* LCOV_EXCL_STOP */
1079 /* LCOV_EXCL_START */
1080 int system_setting_set_font_type(system_settings_key_e key, void *value)
1082 SETTING_TRACE_BEGIN;
1083 char *font_name = NULL;
1084 font_name = (char *)value;
1086 /* get current font list */
1087 int is_found = dl_is_available_font(font_name);
1089 if (is_found == 1) {
1090 SETTING_TRACE("found font : %s ", font_name);
1092 SETTING_TRACE(" NOT found font : %s ", font_name);
1093 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1096 bool bsave = dl_font_config_set(font_name);
1099 SETTING_TRACE(" font type save error by font_config_set() ");
1100 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1102 SETTING_TRACE(" save OK - font_config_set() ");
1105 xmlDocPtr doc = (xmlDocPtr)font_conf_doc_parse(SETTING_FONT_CONF_FILE, font_name);
1107 xmlSaveFormatFile(SETTING_FONT_CONF_FILE, doc, 0);
1112 dl_font_config_set_notification();
1115 vconf_value = (char *)value;
1117 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, vconf_value)) {
1118 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1120 return SYSTEM_SETTINGS_ERROR_NONE;
1122 /* LCOV_EXCL_STOP */
1124 /* LCOV_EXCL_START */
1125 int system_setting_set_motion_activation(system_settings_key_e key, void *value)
1127 SETTING_TRACE_BEGIN;
1129 vconf_value = (bool *)value;
1130 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_MOTION_ACTIVATION, *vconf_value)) {
1131 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1133 return SYSTEM_SETTINGS_ERROR_NONE;
1135 /* LCOV_EXCL_STOP */
1137 /* LCOV_EXCL_START */
1138 int system_setting_set_usb_debugging_option(system_settings_key_e key, void *value)
1140 SETTING_TRACE_BEGIN;
1142 vconf_value = (bool *)value;
1143 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_USB_DEBUG_MODE_BOOL, *vconf_value)) {
1144 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1146 return SYSTEM_SETTINGS_ERROR_NONE;
1149 /* LCOV_EXCL_STOP */
1151 /* LCOV_EXCL_START */
1152 int system_setting_set_3g_data_network(system_settings_key_e key, void *value)
1154 SETTING_TRACE_BEGIN;
1156 vconf_value = (bool *)value;
1157 if (system_setting_vconf_set_value_bool(VCONFKEY_3G_ENABLE, *vconf_value)) {
1158 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1161 return SYSTEM_SETTINGS_ERROR_NONE;
1163 /* LCOV_EXCL_STOP */
1165 /* LCOV_EXCL_START */
1166 static int category_func(const char *name, void *user_data)
1168 SETTING_TRACE_BEGIN;
1169 static char *category = "lock-screen";
1170 if (name && !strcmp(name, category)) {
1171 SETTING_TRACE(" SAME ");
1174 SETTING_TRACE(" DIFFERENT -- %s, category -- %s ", name, category);
1180 /* LCOV_EXCL_STOP */
1184 * set 'swipe type' if current lockscreen app is 'com.samsung.lockscreen'
1188 /* LCOV_EXCL_START */
1189 int system_setting_set_lockscreen_app(system_settings_key_e key, void *value)
1191 SETTING_TRACE_BEGIN;
1193 vconf_value = (char *)value; /* ex) com.samsung.lockscreen */
1196 pkgmgrinfo_appinfo_h handle;
1197 r = pkgmgrinfo_appinfo_get_appinfo(vconf_value, &handle);
1198 if (r != PMINFO_R_OK) {
1199 SETTING_TRACE("*** pkginfo failed ");
1200 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
1202 SETTING_TRACE("%p", handle);
1205 int ret = pkgmgrinfo_appinfo_foreach_category(handle, category_func, (void *)"lock-screen");
1206 if (ret != PMINFO_R_OK) {
1207 pkgmgrinfo_appinfo_destroy_appinfo(handle);
1208 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
1211 pkgmgrinfo_appinfo_destroy_appinfo(handle);
1212 /*----------------------------------------------------------------------------------- */
1214 if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_SCREEN_LOCK_TYPE_INT, &locktype)) {
1215 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1218 if (locktype == SETTING_SCREEN_LOCK_TYPE_PASSWORD)
1219 return SYSTEM_SETTINGS_ERROR_LOCKSCREEN_APP_PASSWORD_MODE;
1221 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_3RD_LOCK_PKG_NAME_STR, vconf_value)) {
1222 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1225 if (vconf_value && strcmp(vconf_value, "com.samsung.lockscreen") == 0) {
1226 if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_SCREEN_LOCK_TYPE_INT, SETTING_SCREEN_LOCK_TYPE_SWIPE)) {
1227 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1230 return SYSTEM_SETTINGS_ERROR_NONE;
1232 /* LCOV_EXCL_STOP */
1234 /*/////////////////////////////////////////////////////////////////////////////////////////////// */
1237 int system_setting_set_changed_callback_incoming_call_ringtone(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1239 SETTING_TRACE_BEGIN;
1240 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR, SYSTEM_SETTINGS_KEY_INCOMING_CALL_RINGTONE, 0, user_data);
1243 int system_setting_unset_changed_callback_incoming_call_ringtone(system_settings_key_e key)
1245 SETTING_TRACE_BEGIN;
1246 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR, 0);
1249 int system_setting_set_changed_callback_email_alert_ringtone(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1251 SETTING_TRACE_BEGIN;
1252 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, SYSTEM_SETTINGS_KEY_EMAIL_ALERT_RINGTONE, 0, user_data);
1255 int system_setting_unset_changed_callback_email_alert_ringtone(system_settings_key_e key)
1257 SETTING_TRACE_BEGIN;
1258 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, 0);
1261 int system_setting_set_changed_callback_wallpaper_home_screen(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1263 SETTING_TRACE_BEGIN;
1264 return system_setting_vconf_set_changed_cb(VCONFKEY_BGSET, SYSTEM_SETTINGS_KEY_WALLPAPER_HOME_SCREEN, 0, user_data);
1267 int system_setting_unset_changed_callback_wallpaper_home_screen(system_settings_key_e key)
1269 SETTING_TRACE_BEGIN;
1270 return system_setting_vconf_unset_changed_cb(VCONFKEY_BGSET, 0);
1273 int system_setting_set_changed_callback_wallpaper_lock_screen(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1275 SETTING_TRACE_BEGIN;
1276 return system_setting_vconf_set_changed_cb(VCONFKEY_IDLE_LOCK_BGSET, SYSTEM_SETTINGS_KEY_WALLPAPER_LOCK_SCREEN, 0, user_data);
1279 int system_setting_unset_changed_callback_wallpaper_lock_screen(system_settings_key_e key)
1281 SETTING_TRACE_BEGIN;
1282 return system_setting_vconf_unset_changed_cb(VCONFKEY_IDLE_LOCK_BGSET, 0);
1285 int system_setting_set_changed_callback_font_size(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1287 SETTING_TRACE_BEGIN;
1288 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, SYSTEM_SETTINGS_KEY_FONT_SIZE, 1, user_data);
1291 int system_setting_unset_changed_callback_font_size(system_settings_key_e key)
1293 SETTING_TRACE_BEGIN;
1294 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, 1);
1297 int system_setting_set_changed_callback_usb_debugging_option(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1299 SETTING_TRACE_BEGIN;
1300 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_USB_DEBUG_MODE_BOOL, SYSTEM_SETTINGS_KEY_USB_DEBUGGING_ENABLED, 1, user_data);
1303 int system_setting_unset_changed_callback_usb_debugging_option(system_settings_key_e key)
1305 SETTING_TRACE_BEGIN;
1306 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_USB_DEBUG_MODE_BOOL, 1);
1309 int system_setting_set_changed_callback_3g_data_network(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1311 SETTING_TRACE_BEGIN;
1312 return system_setting_vconf_set_changed_cb(VCONFKEY_3G_ENABLE, SYSTEM_SETTINGS_KEY_3G_DATA_NETWORK_ENABLED, 1, user_data);
1315 int system_setting_unset_changed_callback_3g_data_network(system_settings_key_e key)
1317 SETTING_TRACE_BEGIN;
1318 return system_setting_vconf_unset_changed_cb(VCONFKEY_3G_ENABLE, 1);
1321 int system_setting_set_changed_callback_lockscreen_app(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1323 SETTING_TRACE_BEGIN;
1324 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_3RD_LOCK_PKG_NAME_STR, SYSTEM_SETTINGS_KEY_LOCKSCREEN_APP, 1, user_data);
1327 int system_setting_unset_changed_callback_lockscreen_app(system_settings_key_e key)
1329 SETTING_TRACE_BEGIN;
1330 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_3RD_LOCK_PKG_NAME_STR, 1);
1335 * @todo need to add custom event notification method
1337 int system_setting_set_changed_callback_font_type(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1339 SETTING_TRACE_BEGIN;
1340 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, SYSTEM_SETTINGS_KEY_FONT_TYPE, 2, user_data);
1343 int system_setting_unset_changed_callback_font_type(system_settings_key_e key)
1345 SETTING_TRACE_BEGIN;
1346 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, 2);
1349 /* TODO : 2th argument, callback, is not in use. */
1350 int system_setting_set_changed_callback_motion_activation(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1352 SETTING_TRACE_BEGIN;
1353 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_MOTION_ACTIVATION, SYSTEM_SETTINGS_KEY_MOTION_ACTIVATION, 3, user_data);
1356 int system_setting_unset_changed_callback_motion_activation(system_settings_key_e key)
1358 SETTING_TRACE_BEGIN;
1359 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_MOTION_ACTIVATION, 3);
1362 /*//////////////////////////////////////////////////////////////////////////////////////// */
1363 /*--------------------------------------- */
1364 int system_setting_get_locale_country(system_settings_key_e key, void **value)
1366 SETTING_TRACE_BEGIN;
1367 char *vconf_value = NULL;
1368 if (system_setting_vconf_get_value_string(VCONFKEY_REGIONFORMAT, &vconf_value)) {
1369 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1372 /* parsing validation */
1375 snprintf(arr, 20, "%s", vconf_value);
1377 *value = strdup(arr);
1381 return SYSTEM_SETTINGS_ERROR_NONE;
1384 /* LCOV_EXCL_START */
1385 int system_setting_set_locale_country(system_settings_key_e key, void *value)
1387 SETTING_TRACE_BEGIN;
1388 char *vconf_value = NULL;
1389 vconf_value = (char *)value;
1391 char *ext = "UTF-8";
1394 snprintf(arr, 20, "%s.%s", vconf_value, ext);
1396 if (system_setting_vconf_set_value_string(VCONFKEY_REGIONFORMAT, arr)) {
1397 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1399 return SYSTEM_SETTINGS_ERROR_NONE;
1401 /* LCOV_EXCL_STOP */
1403 int system_setting_set_changed_callback_locale_country(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1405 SETTING_TRACE_BEGIN;
1406 return system_setting_vconf_set_changed_cb(VCONFKEY_REGIONFORMAT, SYSTEM_SETTINGS_KEY_LOCALE_COUNTRY, 3, user_data);
1409 int system_setting_unset_changed_callback_locale_country(system_settings_key_e key)
1411 SETTING_TRACE_BEGIN;
1412 return system_setting_vconf_unset_changed_cb(VCONFKEY_REGIONFORMAT, 3);
1416 /*--------------------------------------- */
1417 int system_setting_get_locale_language(system_settings_key_e key, void **value)
1419 SETTING_TRACE_BEGIN;
1420 char *vconf_value = NULL;
1421 if (system_setting_vconf_get_value_string(VCONFKEY_LANGSET, &vconf_value)) {
1422 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1425 /* parsing validation */
1428 snprintf(arr, 20, "%s", vconf_value);
1430 *value = strdup(arr);
1433 return SYSTEM_SETTINGS_ERROR_NONE;
1436 /* LCOV_EXCL_START */
1437 int system_setting_set_locale_language(system_settings_key_e key, void *value)
1439 SETTING_TRACE_BEGIN;
1440 char *vconf_value = NULL;
1441 vconf_value = (char *)value;
1443 char *ext = "UTF-8";
1446 snprintf(arr, 20, "%s.%s", vconf_value, ext);
1448 if (system_setting_vconf_set_value_string(VCONFKEY_LANGSET, arr)) {
1449 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1451 return SYSTEM_SETTINGS_ERROR_NONE;
1453 /* LCOV_EXCL_STOP */
1455 int system_setting_set_changed_callback_locale_language(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1457 SETTING_TRACE_BEGIN;
1458 /*return system_setting_vconf_set_changed_cb(VCONFKEY_LANGSET, SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, 3, user_data ); */
1459 return system_setting_vconf_set_changed_cb(VCONFKEY_LANGSET, SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, 100, user_data);
1462 int system_setting_unset_changed_callback_locale_language(system_settings_key_e key)
1464 SETTING_TRACE_BEGIN;
1465 return system_setting_vconf_unset_changed_cb(VCONFKEY_LANGSET, 100);
1468 /*--------------------------------------- */
1469 /* LCOV_EXCL_START */
1470 int system_setting_get_locale_timeformat_24hour(system_settings_key_e key, void **value)
1472 SETTING_TRACE_BEGIN;
1475 if (system_setting_vconf_get_value_int(VCONFKEY_REGIONFORMAT_TIME1224, &vconf_value)) {
1476 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1479 bool ret_value = true;
1480 if (vconf_value == VCONFKEY_TIME_FORMAT_12)
1482 else if (vconf_value == VCONFKEY_TIME_FORMAT_24)
1485 *value = (void *)ret_value;
1487 return SYSTEM_SETTINGS_ERROR_NONE;
1489 /* LCOV_EXCL_STOP */
1491 int system_setting_set_locale_timeformat_24hour(system_settings_key_e key, void *value)
1493 SETTING_TRACE_BEGIN;
1496 vconf_value = (bool *)value;
1499 if (system_setting_vconf_set_value_int(VCONFKEY_REGIONFORMAT_TIME1224, VCONFKEY_TIME_FORMAT_24)) {
1500 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1504 if (system_setting_vconf_set_value_int(VCONFKEY_REGIONFORMAT_TIME1224, VCONFKEY_TIME_FORMAT_12)) {
1505 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1510 return SYSTEM_SETTINGS_ERROR_NONE;
1513 int system_setting_set_changed_callback_locale_timeformat_24hour(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1515 SETTING_TRACE_BEGIN;
1516 return system_setting_vconf_set_changed_cb(VCONFKEY_REGIONFORMAT_TIME1224, SYSTEM_SETTINGS_KEY_LOCALE_TIMEFORMAT_24HOUR, 3, user_data);
1519 int system_setting_unset_changed_callback_locale_timeformat_24hour(system_settings_key_e key)
1521 SETTING_TRACE_BEGIN;
1522 return system_setting_vconf_unset_changed_cb(VCONFKEY_REGIONFORMAT_TIME1224, 3);
1525 int system_setting_get_locale_timezone(system_settings_key_e key, void **value)
1528 ssize_t len = readlink(SETTING_TZONE_SYMLINK_PATH, tzpath, sizeof(tzpath)-1);
1532 SETTING_TRACE("parse error for SETTING_TZONE_SYMLINK_PATH");
1533 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1536 SETTING_TRACE("tzpath : %s ", &tzpath[20]);
1537 *value = strdup(&tzpath[20]);
1538 return SYSTEM_SETTINGS_ERROR_NONE;
1541 /* LCOV_EXCL_START */
1542 int system_setting_set_locale_timezone(system_settings_key_e key, void *value)
1544 SETTING_TRACE_BEGIN;
1545 char *timezone_value = NULL;
1546 timezone_value = (char *)value;
1549 snprintf(tz_path, 1024, "/usr/share/zoneinfo/%s", timezone_value);
1551 int is_load = _is_file_accessible(tz_path);
1553 alarmmgr_set_timezone(tz_path);
1555 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_TIMEZONE_ID, timezone_value)) {
1556 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1558 return SYSTEM_SETTINGS_ERROR_NONE;
1560 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
1562 /* LCOV_EXCL_STOP */
1566 /* LCOV_EXCL_START */
1567 int system_setting_set_changed_callback_locale_timezone(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1569 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_TIMEZONE_ID, SYSTEM_SETTINGS_KEY_LOCALE_TIMEZONE, 4, user_data);
1571 /* LCOV_EXCL_STOP */
1573 /* LCOV_EXCL_START */
1574 int system_setting_unset_changed_callback_locale_timezone(system_settings_key_e key)
1576 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_TIMEZONE_ID, 4);
1578 /* LCOV_EXCL_STOP */
1580 /* LCOV_EXCL_START */
1581 int system_setting_set_changed_callback_locale_timezone_changed(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1583 SETTING_TRACE_BEGIN;
1584 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
1586 /* LCOV_EXCL_STOP */
1588 /* LCOV_EXCL_START */
1589 int system_setting_unset_changed_callback_locale_timezone_changed(system_settings_key_e key)
1591 SETTING_TRACE_BEGIN;
1592 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
1594 /* LCOV_EXCL_STOP */
1597 /* LCOV_EXCL_START */
1598 int system_setting_get_time_changed(system_settings_key_e key, void **value)
1600 SETTING_TRACE_BEGIN;
1602 int ** val = (int**)value;
1603 cur_tick = time(NULL);
1605 /* struct tm * localtime = time (cur_tick); */
1606 /* printf("%s\n", ctime(&cur_tick); */
1607 return SYSTEM_SETTINGS_ERROR_NONE;
1610 /* LCOV_EXCL_STOP */
1612 int system_setting_set_changed_callback_time_changed(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1614 SETTING_TRACE_BEGIN;
1615 return system_setting_vconf_set_changed_cb(VCONFKEY_SYSTEM_TIME_CHANGED, SYSTEM_SETTINGS_KEY_TIME_CHANGED, 3, user_data);
1618 int system_setting_unset_changed_callback_time_changed(system_settings_key_e key)
1620 SETTING_TRACE_BEGIN;
1621 return system_setting_vconf_unset_changed_cb(VCONFKEY_SYSTEM_TIME_CHANGED, 3);
1626 /* SYSTEM_SETTINGS_KEY_SOUND_LOCK */
1627 int system_setting_get_sound_lock(system_settings_key_e key, void **value)
1629 SETTING_TRACE_BEGIN;
1632 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_SOUND_LOCK_BOOL, &vconf_value)) {
1633 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1635 *value = (void *)vconf_value;
1637 return SYSTEM_SETTINGS_ERROR_NONE;
1640 int system_setting_set_changed_callback_sound_lock(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1642 SETTING_TRACE_BEGIN;
1643 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_SOUND_LOCK_BOOL, SYSTEM_SETTINGS_KEY_SOUND_LOCK, 3, user_data);
1646 int system_setting_unset_changed_callback_sound_lock(system_settings_key_e key)
1648 SETTING_TRACE_BEGIN;
1649 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_SOUND_LOCK_BOOL, 3);
1653 * a = VCONFKEY_SETAPPL_SOUND_STATUS_BOOL b = VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL
1655 * a == false, b == false --> silent mode
1656 * a == true, b == false --> sound mode
1657 * a == false, b == true --> vibration mode
1659 /* LCOV_EXCL_START */
1660 int system_setting_get_sound_silent_mode(system_settings_key_e key, void **value)
1662 SETTING_TRACE_BEGIN;
1667 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, &sound_cond)) {
1668 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1671 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, &vib_cond)) {
1672 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1675 if (sound_cond == false && vib_cond == false) {
1677 *value = (void *)vconf_value;
1679 vconf_value = false;
1680 *value = (void *)vconf_value;
1682 return SYSTEM_SETTINGS_ERROR_NONE;
1684 /* LCOV_EXCL_STOP */
1687 * a = VCONFKEY_SETAPPL_SOUND_STATUS_BOOL b = VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL
1689 * a == false, b == false --> silent mode
1690 * a == true, b == false --> sound mode
1692 int system_setting_set_sound_silent_mode(system_settings_key_e key, void *value)
1694 SETTING_TRACE_BEGIN;
1697 vconf_value = (bool *)value;
1699 bool vconf_sound = false;
1700 bool vconf_vib = false;
1703 vconf_sound = false;
1710 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, vconf_sound)) {
1711 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1713 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, vconf_vib)) {
1714 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1717 return SYSTEM_SETTINGS_ERROR_NONE;
1723 int system_setting_set_changed_callback_sound_silent_mode(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1725 SETTING_TRACE_BEGIN;
1726 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, SYSTEM_SETTINGS_KEY_SOUND_SILENT_MODE, 3, user_data);
1730 int system_setting_unset_changed_callback_sound_silent_mode(system_settings_key_e key)
1732 SETTING_TRACE_BEGIN;
1733 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, 3);
1736 /* SYSTEM_SETTINGS_KEY_SOUND_TOUCH */
1737 int system_setting_get_sound_touch(system_settings_key_e key, void **value)
1739 SETTING_TRACE_BEGIN;
1742 int ret = system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL, &vconf_value);
1743 if (ret != SYSTEM_SETTINGS_ERROR_NONE) {
1746 *value = (void *)vconf_value;
1750 int system_setting_set_changed_callback_sound_touch(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1752 SETTING_TRACE_BEGIN;
1753 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL, SYSTEM_SETTINGS_KEY_SOUND_TOUCH, 2, user_data);
1756 int system_setting_unset_changed_callback_sound_touch(system_settings_key_e key)
1758 SETTING_TRACE_BEGIN;
1759 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL, 2);
1763 /* SYSTEM_SETTINGS_KEY_SOUND_LOCK */
1764 int system_setting_get_sound_lock(system_settings_key_e key, void **value)
1768 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_SOUND_LOCK_BOOL, &vconf_value)) {
1769 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1771 *value = (void *)vconf_value;
1773 return SYSTEM_SETTINGS_ERROR_NONE;
1777 int system_setting_get_auto_rotation_mode(system_settings_key_e key, void **value)
1779 SETTING_TRACE_BEGIN;
1782 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, &vconf_value)) {
1783 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1785 *value = (void *)vconf_value;
1787 return SYSTEM_SETTINGS_ERROR_NONE;
1790 /* LCOV_EXCL_START */
1791 int system_setting_set_auto_rotation_mode(system_settings_key_e key, void *value)
1793 SETTING_TRACE_BEGIN;
1795 vconf_value = (bool *)value;
1796 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, *vconf_value)) {
1797 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1800 return SYSTEM_SETTINGS_ERROR_NONE;
1802 /* LCOV_EXCL_STOP */
1804 int system_setting_set_changed_callback_auto_rotation_mode(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1806 SETTING_TRACE_BEGIN;
1807 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, SYSTEM_SETTINGS_KEY_DISPLAY_SCREEN_ROTATION_AUTO, 2, user_data);
1810 int system_setting_unset_changed_callback_auto_rotation_mode(system_settings_key_e key)
1812 SETTING_TRACE_BEGIN;
1813 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, 2);
1816 int system_setting_get_screen_backlight_time(system_settings_key_e key, void **value)
1818 SETTING_TRACE_BEGIN;
1820 int ** val = (int**)value;
1822 if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, &vconf_value)) {
1823 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1825 **val = vconf_value;
1827 return SYSTEM_SETTINGS_ERROR_NONE;
1831 /* LCOV_EXCL_START */
1832 int system_setting_set_screen_backlight_time(system_settings_key_e key, void *value)
1834 SETTING_TRACE_BEGIN;
1836 vconf_value = *(int **)value;
1838 if (!(*vconf_value > 0 && *vconf_value <= 600)) {
1839 SETTING_TRACE(" ERR Betweeny here 0 ~ 600");
1840 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
1843 if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, *vconf_value)) {
1844 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1847 return SYSTEM_SETTINGS_ERROR_NONE;
1849 /* LCOV_EXCL_STOP */
1851 int system_setting_set_changed_callback_screen_backlight_time(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1853 SETTING_TRACE_BEGIN;
1854 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, SYSTEM_SETTINGS_KEY_SCREEN_BACKLIGHT_TIME, 2, user_data);
1857 int system_setting_unset_changed_callback_screen_backlight_time(system_settings_key_e key)
1859 SETTING_TRACE_BEGIN;
1860 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, 2);
1863 int system_setting_get_sound_notification(system_settings_key_e key, void **value)
1865 SETTING_TRACE_BEGIN;
1866 char *vconf_value = NULL;
1867 if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, &vconf_value)) {
1868 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1871 *value = vconf_value;
1872 return SYSTEM_SETTINGS_ERROR_NONE;
1875 /* LCOV_EXCL_START */
1876 int system_setting_set_sound_notification(system_settings_key_e key, void *value)
1878 SETTING_TRACE_BEGIN;
1879 char *vconf_value = NULL;
1880 vconf_value = (char *)value;
1882 int is_load = _is_file_accessible(vconf_value);
1884 //SETTING_TRACE(" system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, %s) TRY", vconf_value);
1885 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, vconf_value)) {
1886 //SETTING_TRACE(" system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, %s) FAIL", vconf_value);
1887 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1890 //SETTING_TRACE(" is_file_accessibile FAILED - system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, %s) FAIL", vconf_value);
1891 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1894 return SYSTEM_SETTINGS_ERROR_NONE;
1896 /* LCOV_EXCL_STOP */
1898 int system_setting_set_changed_callback_sound_notification(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1900 SETTING_TRACE_BEGIN;
1901 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, SYSTEM_SETTINGS_KEY_SOUND_NOTIFICATION, 0, user_data);
1904 int system_setting_unset_changed_callback_sound_notification(system_settings_key_e key)
1906 SETTING_TRACE_BEGIN;
1907 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, 0);
1910 int system_setting_get_notification_repetition_period(system_settings_key_e key, void **value)
1912 SETTING_TRACE_BEGIN;
1913 int ** val = (int**)value;
1916 if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_NOTI_MSG_ALERT_REP_TYPE_INT, &vconf_value)) {
1917 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1919 **val = vconf_value;
1921 return SYSTEM_SETTINGS_ERROR_NONE;
1924 /* LCOV_EXCL_START */
1925 int system_setting_set_notification_repetition_period(system_settings_key_e key, void *value)
1927 SETTING_TRACE_BEGIN;
1929 vconf_value = *(int **)value;
1931 if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_NOTI_MSG_ALERT_REP_TYPE_INT, *vconf_value)) {
1932 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1935 return SYSTEM_SETTINGS_ERROR_NONE;
1937 /* LCOV_EXCL_STOP */
1939 int system_setting_set_changed_callback_notification_repetition_period(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1941 SETTING_TRACE_BEGIN;
1942 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);
1945 int system_setting_unset_changed_callback_notification_repetition_period(system_settings_key_e key)
1947 SETTING_TRACE_BEGIN;
1948 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_ALERT_REP_TYPE_INT, 1);
1951 int system_setting_get_device_name(system_settings_key_e key, void **value)
1953 SETTING_TRACE_BEGIN;
1954 char *vconf_value = NULL;
1955 if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_DEVICE_NAME_STR, &vconf_value)) {
1956 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1959 *value = vconf_value;
1960 return SYSTEM_SETTINGS_ERROR_NONE;
1963 /* LCOV_EXCL_START */
1964 int system_setting_set_device_name(system_settings_key_e key, void *value)
1966 SETTING_TRACE_BEGIN;
1967 char *vconf_value = NULL;
1968 vconf_value = (char *)value;
1970 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_DEVICE_NAME_STR, vconf_value)) {
1971 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1974 return SYSTEM_SETTINGS_ERROR_NONE;
1976 /* LCOV_EXCL_STOP */
1978 int system_setting_set_changed_callback_device_name(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1980 SETTING_TRACE_BEGIN;
1981 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_DEVICE_NAME_STR, SYSTEM_SETTINGS_KEY_DEVICE_NAME, 0, user_data);
1984 int system_setting_unset_changed_callback_device_name(system_settings_key_e key)
1986 SETTING_TRACE_BEGIN;
1987 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_DEVICE_NAME_STR, 0);
1990 /*---------------------------------------------- */
1991 int system_setting_get_network_flight_mode(system_settings_key_e key, void **value)
1993 SETTING_TRACE_BEGIN;
1995 if (system_setting_vconf_get_value_bool(VCONFKEY_TELEPHONY_FLIGHT_MODE, &vconf_value)) {
1996 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1998 *value = (void *)vconf_value;
2000 return SYSTEM_SETTINGS_ERROR_NONE;
2003 int system_setting_set_changed_callback_network_flight_mode(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
2005 SETTING_TRACE_BEGIN;
2006 return system_setting_vconf_set_changed_cb(VCONFKEY_TELEPHONY_FLIGHT_MODE, SYSTEM_SETTINGS_KEY_NETWORK_FLIGHT_MODE, 3, user_data);
2009 int system_setting_unset_changed_callback_network_flight_mode(system_settings_key_e key)
2011 SETTING_TRACE_BEGIN;
2012 return system_setting_vconf_unset_changed_cb(VCONFKEY_TELEPHONY_FLIGHT_MODE, 3);
2015 int system_setting_get_network_wifi_notification(system_settings_key_e key, void **value)
2017 SETTING_TRACE_BEGIN;
2019 if (system_setting_vconf_get_value_int(VCONFKEY_WIFI_ENABLE_QS, &vconf_value)) {
2020 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2023 bret = (vconf_value == VCONFKEY_WIFI_QS_ENABLE) ? true : false;
2025 *value = (void *)bret;
2026 return SYSTEM_SETTINGS_ERROR_NONE;
2029 int system_setting_set_changed_callback_network_wifi_notification(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
2031 SETTING_TRACE_BEGIN;
2032 return system_setting_vconf_set_changed_cb(VCONFKEY_WIFI_ENABLE_QS, SYSTEM_SETTINGS_KEY_NETWORK_WIFI_NOTIFICATION, 4, user_data);
2035 int system_setting_unset_changed_callback_network_wifi_notification(system_settings_key_e key)
2037 SETTING_TRACE_BEGIN;
2038 return system_setting_vconf_unset_changed_cb(VCONFKEY_WIFI_ENABLE_QS, 4);
2041 /* LCOV_EXCL_START */
2042 int system_setting_get_lock_state(system_settings_key_e key, void **value)
2045 int ** val = (int**)value;
2047 if (system_setting_vconf_get_value_int(VCONFKEY_IDLE_LOCK_STATE_READ_ONLY, &vconf_value)) {
2048 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2050 **val = vconf_value;
2052 return SYSTEM_SETTINGS_ERROR_NONE;
2054 /* LCOV_EXCL_STOP */
2056 /* LCOV_EXCL_START */
2057 int system_setting_set_lock_state(system_settings_key_e key, void *value)
2059 SETTING_TRACE_BEGIN;
2061 vconf_value = *(int **)value;
2063 if (system_setting_vconf_set_value_int(VCONFKEY_IDLE_LOCK_STATE_READ_ONLY, *vconf_value)) {
2064 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2067 return SYSTEM_SETTINGS_ERROR_NONE;
2069 /* LCOV_EXCL_STOP */
2071 /* LCOV_EXCL_START */
2072 int system_setting_set_changed_callback_lock_state(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
2074 return system_setting_vconf_set_changed_cb(VCONFKEY_IDLE_LOCK_STATE_READ_ONLY, SYSTEM_SETTINGS_KEY_LOCK_STATE, 4, user_data);
2076 /* LCOV_EXCL_STOP */
2078 /* LCOV_EXCL_START */
2079 int system_setting_unset_changed_callback_lock_state(system_settings_key_e key)
2081 return system_setting_vconf_unset_changed_cb(VCONFKEY_IDLE_LOCK_STATE_READ_ONLY, 4);
2083 /* LCOV_EXCL_STOP */
2085 //----------------------------------------------------------------------------------------------------------------------------
2087 #define DEFAULT_ADS_ID "00000000-0000-0000-0000-000000000000"
2089 int system_setting_get_ads_id(system_settings_key_e key, void **value)
2091 SETTING_TRACE_BEGIN;
2092 int optout_value = 0;
2093 if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_AD_ID_OPT_OUT, &optout_value)) {
2094 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2097 if (optout_value == 1) {
2098 *value = strdup(DEFAULT_ADS_ID);
2099 return SYSTEM_SETTINGS_ERROR_NONE;
2102 char *vconf_value = NULL;
2103 if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_AD_ID, &vconf_value)) {
2104 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2107 *value = vconf_value;
2108 return SYSTEM_SETTINGS_ERROR_NONE;
2113 void make_ad_id(void)
2116 char uuid_unparsed[50] = {0};
2117 uuid_generate(uuid_value);
2118 uuid_unparse(uuid_value, uuid_unparsed);
2119 system_setting_set_ad_id(key, uuid_unparsed); //example of setting the value
2122 int system_setting_set_ads_id(system_settings_key_e key, void *value)
2124 SETTING_TRACE_BEGIN;
2125 char *vconf_value = NULL;
2126 vconf_value = (char *)value;
2128 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_AD_ID, vconf_value)) {
2129 SETTING_TRACE("Setting VCONFKEY_SETAPPL_AD_ID failed");
2130 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2133 return SYSTEM_SETTINGS_ERROR_NONE;
2136 int system_setting_set_changed_callback_ads_id(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
2138 SETTING_TRACE_BEGIN;
2139 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_AD_ID, SYSTEM_SETTINGS_KEY_ADS_ID, 0, user_data);
2142 int system_setting_unset_changed_callback_ads_id(system_settings_key_e key)
2144 SETTING_TRACE_BEGIN;
2145 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_AD_ID, 0);
2148 int system_settings_feature_check_bool(char *path)
2150 bool profile_data = false;
2151 int ret = system_info_get_platform_bool(path, &profile_data);
2152 if (ret != SYSTEM_INFO_ERROR_NONE) {
2153 SETTING_TRACE("Setting - reading profile string failed, %d", ret);
2154 return SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED;
2157 ret = (profile_data == true) ? SYSTEM_SETTINGS_ERROR_NONE : SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED;
2163 int system_setting_feature_check_incoming_call(void *value)
2165 static bool first_query = true;
2166 static int ret = SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED;
2168 if (first_query == true) {
2169 ret = system_settings_feature_check_bool(SETTING_INCOMING_CALL_PATH);
2170 first_query = false;
2176 int system_setting_feature_check_home_screen(void *value)
2178 static bool first_query = true;
2179 static int ret = SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED;
2181 if (first_query == true) {
2182 ret = system_settings_feature_check_bool(SETTING_HOME_SCREEN_PATH);
2183 first_query = false;
2189 int system_setting_feature_check_lock_screen(void *value)
2191 static bool first_query = true;
2192 static int ret = SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED;
2194 if (first_query == true) {
2195 ret = system_settings_feature_check_bool(SETTING_LOCK_SCREEN_PATH);
2196 first_query = false;
2202 int system_setting_feature_check_notification_email(void *value)
2204 static bool first_query = true;
2205 static int ret = SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED;
2207 if (first_query == true) {
2208 ret = system_settings_feature_check_bool(SETTING_NOTIFICATION_EMAIL_PATH);
2209 first_query = false;
2215 int system_setting_feature_check_wifi(void *value)
2217 static bool first_query = true;
2218 static int ret = SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED;
2220 if (first_query == true) {
2221 ret = system_settings_feature_check_bool(SETTING_WIFI_PATH);
2222 first_query = false;
2228 int system_setting_feature_check_telephony(void *value)
2230 static bool first_query = true;
2231 static int ret = SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED;
2233 if (first_query == true) {
2234 ret = system_settings_feature_check_bool(SETTING_TELEPHONY_PATH);
2235 first_query = false;
2242 int system_setting_feature_check_font(void *value)
2244 static bool first_query = true;
2245 static int ret = SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED;
2247 if (first_query == true) {
2248 ret = system_settings_feature_check_bool(SETTING_FONT_PATH);
2249 first_query = false;
2255 int system_setting_feature_check_accessibility_grayscale(void *value)
2257 static bool first_query = true;
2258 static int ret = SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED;
2260 if (first_query == true) {
2261 ret = system_settings_feature_check_bool(SETTING_ACCESSIBILITY_GRAYSCALE_PATH);
2262 first_query = false;
2268 int system_setting_feature_check_accessibility_negative(void *value)
2270 static bool first_query = true;
2271 static int ret = SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED;
2273 if (first_query == true) {
2274 ret = system_settings_feature_check_bool(SETTING_ACCESSIBILITY_NEGATIVE_PATH);
2275 first_query = false;
2281 /* LCOV_EXCL_START */
2282 int system_setting_get_uds_state(system_settings_key_e key, void **value)
2284 int ** p_value = (int**)value;
2286 char *vconf_string_value = NULL;
2288 if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_UDSM, &vconf_value)) {
2289 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2292 SETTING_TRACE("[%s] udsm: %d", __FUNCTION__, vconf_value);
2294 if (vconf_value == SYSTEM_SETTINGS_UDS_ON) {
2295 if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_UDSM_PKGID_LIST, &vconf_string_value))
2296 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2298 if (vconf_string_value) {
2299 if (!strcmp(vconf_string_value, "NONE")) {
2300 vconf_value = SYSTEM_SETTINGS_UDS_ON;
2302 char *app_id = NULL;
2303 char *package_id = NULL;
2304 pid_t pid = getpid();
2305 app_manager_get_app_id(pid, &app_id);
2309 result = package_manager_get_package_id_by_app_id(app_id, &package_id);
2310 if (result != PACKAGE_MANAGER_ERROR_NONE) {
2311 SETTING_TRACE("package_manager_get_package_id_by_app_id returned error! %d", result);
2312 if (vconf_string_value)
2313 free(vconf_string_value);
2314 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2317 SETTING_TRACE("[%s] udsm_pkg_list : %s", __FUNCTION__, vconf_string_value);
2320 if (package_id && strstr(vconf_string_value, package_id)) {
2321 vconf_value = SYSTEM_SETTINGS_UDS_ON_WHITELISTED;
2322 SETTING_TRACE("[%s] pkg id : %s", __FUNCTION__, package_id);
2324 vconf_value = SYSTEM_SETTINGS_UDS_ON;
2328 if (vconf_string_value)
2329 free(vconf_string_value);
2333 **p_value = vconf_value;
2336 return SYSTEM_SETTINGS_ERROR_NONE;
2338 /* LCOV_EXCL_STOP */
2340 /* LCOV_EXCL_START */
2341 int system_setting_set_changed_callback_uds_state(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
2343 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_UDSM, SYSTEM_SETTINGS_KEY_ULTRA_DATA_SAVE, 4, user_data);
2345 /* LCOV_EXCL_STOP */
2347 /* LCOV_EXCL_START */
2348 int system_setting_unset_changed_callback_uds_state(system_settings_key_e key)
2350 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_UDSM, 4);
2352 /* LCOV_EXCL_STOP */
2354 /* LCOV_EXCL_START */
2355 int system_setting_set_changed_callback_uds_pkg_list(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
2357 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_UDSM_PKGID_LIST, SYSTEM_SETTINGS_KEY_ULTRA_DATA_SAVE_PKG_LIST, 4, user_data);
2359 /* LCOV_EXCL_STOP */
2361 /* LCOV_EXCL_START */
2362 int system_setting_unset_changed_callback_uds_pkg_list(system_settings_key_e key)
2364 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_UDSM_PKGID_LIST, 4);
2366 /* LCOV_EXCL_STOP */
2368 /* SYSTEM_SETTINGS_KEY_ACCESSIBILITY_TTS */
2369 int system_setting_get_accessibility_tts(system_settings_key_e key, void **value)
2371 SETTING_TRACE_BEGIN;
2374 int ret = system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_ACCESSIBILITY_TTS, &vconf_value);
2375 if (ret != SYSTEM_SETTINGS_ERROR_NONE) {
2378 *value = (void *)vconf_value;
2382 /* LCOV_EXCL_START */
2383 int system_setting_set_accessibility_tts(system_settings_key_e key, void *value)
2385 SETTING_TRACE_BEGIN;
2387 vconf_value = (bool *)value;
2388 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_ACCESSIBILITY_TTS, *vconf_value)) {
2389 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2392 return SYSTEM_SETTINGS_ERROR_NONE;
2394 /* LCOV_EXCL_STOP */
2396 int system_setting_set_changed_callback_accessibility_tts(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
2398 SETTING_TRACE_BEGIN;
2399 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_TTS, SYSTEM_SETTINGS_KEY_ACCESSIBILITY_TTS, 2, user_data);
2402 int system_setting_unset_changed_callback_accessibility_tts(system_settings_key_e key)
2404 SETTING_TRACE_BEGIN;
2405 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_TTS, 2);
2408 /* SYSTEM_SETTINGS_KEY_VIBRATION */
2409 int system_setting_get_vibration(system_settings_key_e key, void **value)
2411 SETTING_TRACE_BEGIN;
2414 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, &vconf_value)) {
2415 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2417 *value = (void *)vconf_value;
2419 return SYSTEM_SETTINGS_ERROR_NONE;
2422 /* LCOV_EXCL_START */
2423 int system_setting_set_vibration(system_settings_key_e key, void *value)
2425 SETTING_TRACE_BEGIN;
2427 vconf_value = (bool *)value;
2428 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, *vconf_value)) {
2429 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2432 return SYSTEM_SETTINGS_ERROR_NONE;
2434 /* LCOV_EXCL_STOP */
2436 int system_setting_set_changed_callback_vibration(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
2438 SETTING_TRACE_BEGIN;
2439 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, SYSTEM_SETTINGS_KEY_VIBRATION, 2, user_data);
2442 int system_setting_unset_changed_callback_vibration(system_settings_key_e key)
2444 SETTING_TRACE_BEGIN;
2445 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, 2);
2448 /* SYSTEM_SETTINGS_KEY_AUTOMATIC_TIME_UPDATE */
2449 int system_setting_get_automatic_time_update(system_settings_key_e key, void **value)
2451 SETTING_TRACE_BEGIN;
2454 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_STATE_AUTOMATIC_TIME_UPDATE_BOOL, &vconf_value)) {
2455 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2457 *value = (void *)vconf_value;
2459 return SYSTEM_SETTINGS_ERROR_NONE;
2462 /* LCOV_EXCL_START */
2463 int system_setting_set_automatic_time_update(system_settings_key_e key, void *value)
2465 SETTING_TRACE_BEGIN;
2467 vconf_value = (bool *)value;
2468 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_STATE_AUTOMATIC_TIME_UPDATE_BOOL, *vconf_value)) {
2469 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2472 return SYSTEM_SETTINGS_ERROR_NONE;
2474 /* LCOV_EXCL_STOP */
2476 int system_setting_set_changed_callback_automatic_time_update(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
2478 SETTING_TRACE_BEGIN;
2479 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_STATE_AUTOMATIC_TIME_UPDATE_BOOL, SYSTEM_SETTINGS_KEY_AUTOMATIC_TIME_UPDATE, 2, user_data);
2482 int system_setting_unset_changed_callback_automatic_time_update(system_settings_key_e key)
2484 SETTING_TRACE_BEGIN;
2485 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_STATE_AUTOMATIC_TIME_UPDATE_BOOL, 2);
2488 /* SYSTEM_SETTINGS_KEY_DEVELOPER_OPTION_STATE */
2489 int system_setting_get_developer_option_state(system_settings_key_e key, void **value)
2491 SETTING_TRACE_BEGIN;
2494 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_DEVELOPER_OPTION_STATE, &vconf_value)) {
2495 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2497 *value = (void *)vconf_value;
2499 return SYSTEM_SETTINGS_ERROR_NONE;
2502 /* LCOV_EXCL_START */
2503 int system_setting_set_developer_option_state(system_settings_key_e key, void *value)
2505 SETTING_TRACE_BEGIN;
2507 vconf_value = (bool *)value;
2508 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_DEVELOPER_OPTION_STATE, *vconf_value)) {
2509 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2512 return SYSTEM_SETTINGS_ERROR_NONE;
2514 /* LCOV_EXCL_STOP */
2516 int system_setting_set_changed_callback_developer_option_state(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
2518 SETTING_TRACE_BEGIN;
2519 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_DEVELOPER_OPTION_STATE, SYSTEM_SETTINGS_KEY_DEVELOPER_OPTION_STATE, 2, user_data);
2522 int system_setting_unset_changed_callback_developer_option_state(system_settings_key_e key)
2524 SETTING_TRACE_BEGIN;
2525 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_DEVELOPER_OPTION_STATE, 2);
2528 /* SYSTEM_SETTINGS_KEY_ACCESSIBILITY_GRAYSCALE */
2529 int system_setting_get_accessibility_grayscale(system_settings_key_e key, void **value)
2531 SETTING_TRACE_BEGIN;
2534 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_ACCESSIBILITY_GREYSCALE, &vconf_value)) {
2535 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2537 *value = (void *)vconf_value;
2539 return SYSTEM_SETTINGS_ERROR_NONE;
2542 /* LCOV_EXCL_START */
2543 int system_setting_set_accessibility_grayscale(system_settings_key_e key, void *value)
2545 SETTING_TRACE_BEGIN;
2547 vconf_value = (bool *)value;
2548 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_ACCESSIBILITY_GREYSCALE, *vconf_value)) {
2549 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2552 return SYSTEM_SETTINGS_ERROR_NONE;
2554 /* LCOV_EXCL_STOP */
2556 int system_setting_set_changed_callback_accessibility_grayscale(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
2558 SETTING_TRACE_BEGIN;
2559 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_GREYSCALE, SYSTEM_SETTINGS_KEY_ACCESSIBILITY_GRAYSCALE, 2, user_data);
2562 int system_setting_unset_changed_callback_accessibility_grayscale(system_settings_key_e key)
2564 SETTING_TRACE_BEGIN;
2565 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_GREYSCALE, 2);
2568 /* SYSTEM_SETTINGS_KEY_ACCESSIBILITY_NEGATIVE_COLOR */
2569 int system_setting_get_accessibility_negative_color(system_settings_key_e key, void **value)
2571 SETTING_TRACE_BEGIN;
2574 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_ACCESSIBILITY_HIGH_CONTRAST, &vconf_value)) {
2575 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2577 *value = (void *)vconf_value;
2579 return SYSTEM_SETTINGS_ERROR_NONE;
2582 /* LCOV_EXCL_START */
2583 int system_setting_set_accessibility_negative_color(system_settings_key_e key, void *value)
2585 SETTING_TRACE_BEGIN;
2587 vconf_value = (bool *)value;
2588 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_ACCESSIBILITY_HIGH_CONTRAST, *vconf_value)) {
2589 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2592 return SYSTEM_SETTINGS_ERROR_NONE;
2594 /* LCOV_EXCL_STOP */
2596 int system_setting_set_changed_callback_accessibility_negative_color(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
2598 SETTING_TRACE_BEGIN;
2599 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_HIGH_CONTRAST, SYSTEM_SETTINGS_KEY_ACCESSIBILITY_NEGATIVE_COLOR, 2, user_data);
2602 int system_setting_unset_changed_callback_accessibility_negative_color(system_settings_key_e key)
2604 SETTING_TRACE_BEGIN;
2605 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_HIGH_CONTRAST, 2);