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>
37 #include <libxml/xmlmemory.h>
38 #include <libxml/parser.h>
40 #include <fontconfig/fontconfig.h>
42 #include <pkgmgr-info.h>
43 #include <package_manager.h>
44 #include <app_manager.h>
46 #include <system_settings.h>
47 #include <system_settings_private.h>
48 #include <system_settings_ringtones.h>
49 #include <system_settings_json.h>
51 #include <system-setting-config.h>
53 #include <tzplatform_config.h>
56 #include <system_info.h>
58 #define SETTING_FONT_CONF_FILE _TZ_SYS_ETC"/fonts/conf.avail/99-tizen.conf"
59 #define SETTING_DEFAULT_FONT_CONF_FILE _TZ_SYS_ETC"/fonts/conf.avail/99-tizen.conf"
61 #define SETTING_TIME_ZONEINFO_PATH "/usr/share/zoneinfo/"
62 #define SETTING_TIME_SHARE_LOCAL_PATH "/usr/share/locale"
63 #define SETTING_TZONE_SYMLINK_PATH "/opt/etc/localtime"
66 #define __FREE(del, arg) do { \
68 del((void *)(arg)); /*cast any argument to (void*) to avoid build warring*/\
72 #define FREE(arg) __FREE(free, arg)
74 #ifdef SETTING_ARCH_64
75 #define SETTING_UTILS_SO_FILE_PATH "/usr/lib64/libsystem-settings-util.so.0.1.0"
77 #define SETTING_UTILS_SO_FILE_PATH "/usr/lib/libsystem-settings-util.so.0.1.0"
80 int _is_file_accessible(const char *path);
82 static bool dl_is_supported_image_type_load(char *path);
83 static bool dl_font_config_set(char *font_name);
84 static char *dl_get_default_font_info();
85 static int dl_is_available_font(char *str);
86 static void dl_font_size_set();
87 static void dl_font_config_set_notification();
90 * VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR has a path of the ringtone file which user choose
91 * @return the ringtone file path specified by user in normal case
92 * if it's not accessable, return the default ringtone path
94 int system_setting_get_incoming_call_ringtone(system_settings_key_e key, void **value)
98 if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR, &vconf_value)) {
99 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
102 /* check to see if it's accessable -> OK */
103 /* no --> default ringtone path VCONFKEY_SETAPPL_CALL_RINGTONE_DEFAULT_PATH_STR */
104 int is_load = _is_file_accessible(vconf_value);
106 *value = vconf_value;
107 } else { /* not zero on errro */
108 *value = vconf_get_str(VCONFKEY_SETAPPL_CALL_RINGTONE_DEFAULT_PATH_STR);
111 /**value = vconf_value; */
112 return SYSTEM_SETTINGS_ERROR_NONE;
116 int system_setting_get_email_alert_ringtone(system_settings_key_e key, void **value)
120 if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, &vconf_value)) {
121 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
124 /* check to see if it's accessable -> OK */
125 /* no --> default ringtone path VCONFKEY_SETAPPL_NOTI_RINGTONE_DEFAULT_PATH_STR */
126 int is_load = _is_file_accessible(vconf_value);
128 *value = vconf_value;
129 } else { /* not zero on errro */
130 *value = vconf_get_str(VCONFKEY_SETAPPL_NOTI_RINGTONE_DEFAULT_PATH_STR);
133 return SYSTEM_SETTINGS_ERROR_NONE;
137 int system_setting_get_wallpaper_home_screen(system_settings_key_e key, void **value)
141 if (system_setting_vconf_get_value_string(VCONFKEY_BGSET, &vconf_value)) {
142 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
144 *value = vconf_value;
145 return SYSTEM_SETTINGS_ERROR_NONE;
149 int system_setting_get_wallpaper_lock_screen(system_settings_key_e key, void **value)
154 if (system_setting_vconf_get_value_string(VCONFKEY_IDLE_LOCK_BGSET, &vconf_value)) {
155 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
157 *value = vconf_value;
159 return SYSTEM_SETTINGS_ERROR_NONE;
163 /* [int] vconf GET */
164 int system_setting_get_font_size(system_settings_key_e key, void **value)
168 int ** val = (int**)value;
170 if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, &vconf_value)) {
171 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
175 return SYSTEM_SETTINGS_ERROR_NONE;
179 int system_setting_get_default_font_type(system_settings_key_e key, void **value)
182 char *font_name = dl_get_default_font_info();
184 *value = (void *)font_name;
185 return SYSTEM_SETTINGS_ERROR_NONE;
187 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
191 /* [int] vconf GET */
192 int system_setting_get_font_type(system_settings_key_e key, void **value)
195 char *font_name = NULL;
197 if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, &font_name)) {
198 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
202 return SYSTEM_SETTINGS_ERROR_NONE;
206 int system_setting_get_motion_activation(system_settings_key_e key, void **value)
211 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_MOTION_ACTIVATION, &vconf_value)) {
212 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
214 *value = (void *)vconf_value;
216 return SYSTEM_SETTINGS_ERROR_NONE;
219 int system_setting_get_usb_debugging_option(system_settings_key_e key, void **value)
224 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_USB_DEBUG_MODE_BOOL, &vconf_value)) {
225 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
227 *value = (void *)vconf_value;
229 return SYSTEM_SETTINGS_ERROR_NONE;
232 int system_setting_get_3g_data_network(system_settings_key_e key, void **value)
237 if (system_setting_vconf_get_value_bool(VCONFKEY_3G_ENABLE, &vconf_value)) {
238 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
240 *value = (void *)vconf_value;
242 return SYSTEM_SETTINGS_ERROR_NONE;
244 /*////////////////////////////////////////////////////////////////////////////////////////////////// */
248 * get current lock scren app package name (string)
250 * @return SYSTEM_SETTINGS_ERROR_LOCKSCREEN_APP_PASSWORD_MODE raise exception if current lock type is 'password'
252 int system_setting_get_lockscreen_app(system_settings_key_e key, void **value)
255 char *pkg_name = NULL;
257 if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_SCREEN_LOCK_TYPE_INT, &locktype)) {
258 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
261 if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_3RD_LOCK_PKG_NAME_STR, &pkg_name)) {
262 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
265 if (pkg_name && strcmp(pkg_name, "com.samsung.lockscreen") == 0 && locktype == SETTING_SCREEN_LOCK_TYPE_PASSWORD) {
266 return SYSTEM_SETTINGS_ERROR_LOCKSCREEN_APP_PASSWORD_MODE;
270 return SYSTEM_SETTINGS_ERROR_NONE;
274 /*////////////////////////////////////////////////////////////////////////////////////////////////// */
276 int _is_file_accessible(const char *path)
279 int ret = access(path , R_OK);
281 SETTING_TRACE("found the file %s", path);
284 /* error code : 13 */
285 SETTING_TRACE("found the file %s --- error code : %d ", path, errno);
292 /*////////////////////////////////////////////////////////////////////////////////////////////////// */
293 // @todo move to CMake
294 #define DEF_RINGTONE_FILE_PATH SETTING_DEF_RES"/Ringtones"
296 #define USR_RINGTONE_FILE_PATH "/home/owner/content/Sounds/Ringtones"
297 #define JSONFILE "/opt/home/owner/apps_rw/org.tizen.setting/data/.user-ringtones.json"
300 static char* _get_json_file_path()
307 int system_setting_add_incoming_call_ringtone(system_settings_key_e key, void *value)
310 char* pathval = (char*)value;
311 char* dnameval = NULL;
312 char* baseval = NULL;
316 JsonParser *parser = ss_json_ringtone_open_file(JSONFILE);
318 JsonParser *parser = ss_json_ringtone_load_from_data();
321 JsonNode *root = json_parser_get_root(parser);
325 int ret = SYSTEM_SETTINGS_ERROR_NONE;
326 if (false == ss_json_ringtone_contain(root, pathval)) {
327 // @todo : MAKE SURE THE ACTUAL FILE IS THERE ON PATHVAL(SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER)
328 ss_json_ringtone_add(root, JSONFILE, pathval, pathval);
329 SETTING_TRACE("pathval is : %s -- OK", pathval);
331 SETTING_TRACE("pathval is duplicated : %s", pathval);
332 ret = SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
335 dnameval = strdup(pathval);
336 baseval = strdup(pathval);
337 if (dnameval && baseval) {
338 SETTING_TRACE("---> dirname is : %s ", dirname(dnameval));
339 SETTING_TRACE("---> basename is : %s ", basename(baseval));
345 g_object_unref(parser);
352 int system_setting_del_incoming_call_ringtone(system_settings_key_e key, void *value)
355 char* pathval = (char*)value;
358 JsonParser* parser = ss_json_ringtone_open_file(JSONFILE);
360 JsonParser* parser = ss_json_ringtone_load_from_data();
362 JsonNode *root = json_parser_get_root(parser);
364 ss_json_ringtone_remove(root, JSONFILE, pathval);
365 //void ss_json_ringtone_remove(JsonNode *root, char* filename, char* path_to_del)
367 ss_json_ringtone_print(root);
369 g_object_unref(parser);
373 return SYSTEM_SETTINGS_ERROR_NONE;
377 /* LCOV_EXCL_START */
378 static int _compare_cb(const void *d1, const void *d2)
380 fileNodeInfo *pNode1 = (fileNodeInfo *)d1;
381 fileNodeInfo *pNode2 = (fileNodeInfo *)d2;
383 return strcmp(pNode1->media_name, pNode2->media_name);
388 * get the RINGTONE list
390 static void _get_default_ringtones(system_settings_key_e key, system_settings_iter_cb callback, void *data)
394 Eina_List *filelist = NULL;
396 fileNodeInfo *node = NULL;
399 //-----------------------------------------------------------------------------------------------------------------
400 // 1. get the default ringtone list
401 //-----------------------------------------------------------------------------------------------------------------
402 int ret = get_filelist_from_dir_path(DEF_RINGTONE_FILE_PATH, &filelist);
404 SETTING_TRACE("Failed to get filelist, ret = %d %s", ret, DEF_RINGTONE_FILE_PATH);
406 filelist = eina_list_sort(filelist, eina_list_count(filelist), _compare_cb);
408 EINA_LIST_FOREACH(filelist, l, node)
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");
433 EINA_LIST_FOREACH(filelist, l, node)
437 FREE(node->media_name);
440 eina_list_free(filelist);
445 static void _get_user_ringtones(system_settings_key_e key, system_settings_iter_cb callback, void *data)
451 JsonParser* parser = ss_json_ringtone_open_file(JSONFILE);
453 JsonParser* parser = ss_json_ringtone_load_from_data();
456 JsonNode *root = json_parser_get_root(parser);
457 int size = json_array_get_length(json_node_get_array(root));
460 for (i = 0; i < size ; i++) {
461 JsonObject *ringtone = json_array_get_object_element(json_node_get_array(root), i);
462 char *nameval = (char *)json_object_get_string_member(ringtone, "name");
463 char *pathval = (char *)json_object_get_string_member(ringtone, "path");
464 SETTING_TRACE("(%s) --- (%s) \n", nameval, pathval);
465 if (callback && pathval) {
466 char* path = strdup(pathval);
467 bool ret = callback(i, (void *)(path), data);
469 SETTING_TRACE("quit the iteration by return value == false : %d", ret);
474 SETTING_TRACE("--> callback is NULL");
478 g_object_unref(parser);
481 int system_setting_list_incoming_call_ringtone(system_settings_key_e key, system_settings_iter_cb callback, void *data)
485 _get_default_ringtones(key, callback, data);
486 //-----------------------------------------------------------------------------------------------------------------
487 // 2. get the USER ringtone list
488 //-----------------------------------------------------------------------------------------------------------------
489 _get_user_ringtones(key, callback, data);
491 return SYSTEM_SETTINGS_ERROR_NONE;
495 /* LCOV_EXCL_START */
496 int system_setting_set_incoming_call_ringtone(system_settings_key_e key, void *value)
500 vconf_value = (char *)value;
502 int ret = _is_file_accessible(vconf_value);
504 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR, vconf_value)) {
505 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
508 /* @todo add a common ret_handler */
512 return SYSTEM_SETTINGS_ERROR_NONE;
517 /* LCOV_EXCL_START */
518 int system_setting_set_email_alert_ringtone(system_settings_key_e key, void *value)
522 vconf_value = (char *)value;
524 int ret = _is_file_accessible(vconf_value);
526 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, vconf_value)) {
527 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
530 /*return SYSTEM_SETTINGS_ERROR_IO_ERROR;*/
531 /* @todo add a common ret_handler */
535 return SYSTEM_SETTINGS_ERROR_NONE;
539 /* LCOV_EXCL_START */
540 static bool dl_is_supported_image_type_load(char *path)
545 bool (*image_type_check)(char *path);
547 handle = dlopen(SETTING_UTILS_SO_FILE_PATH, RTLD_LAZY);
549 SETTING_TRACE("ERROR!! canNOT find libsystem-settings-util.so.0.1.0");
553 image_type_check = dlsym(handle, "__is_supported_image_type_load");
554 if ((error = dlerror()) != NULL) {
555 SETTING_TRACE("ERROR!! canNOT find __is_supported_image_type_load function at libsystem-settings-util.so.0.1.0");
560 ret = image_type_check(path);
567 /* LCOV_EXCL_START */
568 static int dl_is_available_font(char *str)
573 int (*check_available_font)(char *font_name);
575 handle = dlopen(SETTING_UTILS_SO_FILE_PATH, RTLD_LAZY);
577 SETTING_TRACE("ERROR!! canNOT find libsystem-settings-util.so.0.1.0");
581 check_available_font = dlsym(handle, "__is_available_font");
582 if ((error = dlerror()) != NULL) {
583 SETTING_TRACE("ERROR!! canNOT find __is_available_font function at libsystem-settings-util.so.0.1.0");
588 ret = check_available_font(str);
595 /* LCOV_EXCL_START */
596 static void dl_font_size_set()
600 void (*set_font_size)();
602 handle = dlopen(SETTING_UTILS_SO_FILE_PATH, RTLD_LAZY);
604 SETTING_TRACE("ERROR!! canNOT find libsystem-settings-util.so.0.1.0");
608 set_font_size = dlsym(handle, "__font_size_set");
609 if ((error = dlerror()) != NULL) {
610 SETTING_TRACE("ERROR!! canNOT find __font_size_set function at libsystem-settings-util.so.0.1.0");
622 /* LCOV_EXCL_START */
623 static void dl_font_config_set_notification()
627 void (*set_font_nodification)();
629 handle = dlopen(SETTING_UTILS_SO_FILE_PATH, RTLD_LAZY);
631 SETTING_TRACE("ERROR!! canNOT find libsystem-settings-util.so.0.1.0");
635 set_font_nodification = dlsym(handle, "font_config_set_notification");
636 if ((error = dlerror()) != NULL) {
637 SETTING_TRACE("ERROR!! canNOT find font_config_set_notification function at libsystem-settings-util.so.0.1.0");
642 set_font_nodification();
649 /* LCOV_EXCL_START */
650 static bool dl_font_config_set(char *font_name)
655 bool (*check_font_type)(char *font_name);
657 handle = dlopen(SETTING_UTILS_SO_FILE_PATH, RTLD_LAZY);
659 SETTING_TRACE("ERROR!! canNOT find libsystem-settings-util.so.0.1.0");
663 check_font_type = dlsym(handle, "font_config_set");
664 if ((error = dlerror()) != NULL) {
665 SETTING_TRACE("ERROR!! canNOT find font_config_set function at libsystem-settings-util.so.0.1.0");
670 ret = check_font_type(font_name);
677 /* LCOV_EXCL_START */
678 static char *dl_get_default_font_info()
683 char *(*get_font_info)();
685 handle = dlopen(SETTING_UTILS_SO_FILE_PATH, RTLD_LAZY);
687 SETTING_TRACE("ERROR!! canNOT find libsystem-settings-util.so.0.1.0");
691 get_font_info = dlsym(handle, "_get_default_font");
693 if ((error = dlerror()) != NULL) {
694 SETTING_TRACE("ERROR!! canNOT find _get_default_font function at libsystem-settings-util.so.0.1.0");
699 ret = get_font_info();
706 #ifdef TIZEN_WEARABLE
707 /* LCOV_EXCL_START */
708 static int system_setting_get_extended_wallpaper_num(const char *file_path, unsigned int *num)
712 const char *find_str = "extended_wallpaper_";
715 if (!(ch = strstr(file_path, find_str))) {
716 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
718 strncpy(buffer, file_path, ch - file_path);
719 buffer[ch - file_path] = 0;
720 sprintf(buffer + (ch - file_path), "%s%s", "", ch + strlen(find_str));
722 if (!isdigit(buffer[0])) {
723 SETTING_TRACE("%s is not number", buffer);
724 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
729 return SYSTEM_SETTINGS_ERROR_NONE;
733 /* LCOV_EXCL_START */
734 static int system_setting_copy_extended_wallpaper(const char *dest_file_path, const char *source_file_path)
737 if (!source_file_path || !dest_file_path) {
738 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
744 fd = open(source_file_path, O_RDONLY);
746 SETTING_TRACE("file open failed: %s", source_file_path);
747 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
751 fd2 = open(dest_file_path, O_WRONLY | O_CREAT, S_IRWXU | S_IRWXG | S_IRWXO);
753 SETTING_TRACE("file creation failed: %s", dest_file_path);
755 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
758 while (read(fd, buf, sizeof(buf) - 1) > 0) {
759 write(fd2, buf, sizeof(buf) - 1);
765 if (chmod(dest_file_path, S_IRWXU | S_IRWXG | S_IRWXO) < 0) {
766 SETTING_TRACE("chmod failed: %s", dest_file_path);
769 return SYSTEM_SETTINGS_ERROR_NONE;
773 /* LCOV_EXCL_START */
774 static int system_setting_remove_oldest_extended_wallpaper()
779 char *min_image_name = NULL;
780 unsigned int min_image_num = 0;
781 unsigned int temp_image_num = 0;
784 if ((dp = opendir(_TZ_SYS_DATA"/setting/wallpaper")) == NULL) {
785 SETTING_TRACE("opendir error");
786 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
789 while ((dirp = readdir(dp))) {
790 if (!strcmp(dirp->d_name, ".") || !strcmp(dirp->d_name, ".."))
793 if (system_setting_get_extended_wallpaper_num(dirp->d_name, &temp_image_num)
794 != SYSTEM_SETTINGS_ERROR_NONE) {
795 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
798 if ((image_count == 0) || (min_image_num > temp_image_num)) {
799 min_image_num = temp_image_num;
800 min_image_name = dirp->d_name;
807 if (min_image_name) {
808 snprintf(buf, sizeof(buf) - 1, _TZ_SYS_DATA"/setting/wallpaper/%s", min_image_name);
809 if (remove(buf) < 0) { /* remove oldest image */
810 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
814 return SYSTEM_SETTINGS_ERROR_NONE;
818 /* LCOV_EXCL_START */
819 static int system_setting_check_extended_wallpaper(const char *file_path)
823 if (!file_path || !strlen(file_path))
825 snprintf(buffer, 512, "%s/.bgwallpaper", tzplatform_getenv(TZ_USER_CONTENT));
826 return (strstr(file_path, buffer) != NULL);
830 #define WALLPAPER_MAX_COUNT 10
832 /* LCOV_EXCL_START */
833 int system_setting_set_wallpaper_home_screen(system_settings_key_e key, void *value)
837 vconf_value = (char *)value;
839 bool isok = dl_is_supported_image_type_load(vconf_value);
842 SETTING_TRACE("path : %s is not supported file format", vconf_value);
843 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
845 SETTING_TRACE("path : %s is SUPPORT file format", vconf_value);
848 /* error handling here */
849 if (_is_file_accessible(vconf_value) != 0)
850 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
852 if (system_setting_vconf_set_value_string(VCONFKEY_BGSET, vconf_value)) {
853 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
857 #ifdef TIZEN_WEARABLE
858 if (system_setting_check_extended_wallpaper(vconf_value)) { /* New extended wallpaper */
861 unsigned int max_image_num = 0;
862 unsigned int temp_image_num = 0;
865 if ((dp = opendir(_TZ_SYS_DATA"/setting/wallpaper")) == NULL) {
866 SETTING_TRACE("Setting - dir open error!");
867 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
870 /* Check a max number of wallpapers */
871 while ((dirp = readdir(dp))) {
872 if (!strcmp(dirp->d_name, ".") || !strcmp(dirp->d_name, ".."))
875 if (system_setting_get_extended_wallpaper_num(dirp->d_name, &temp_image_num)
876 != SYSTEM_SETTINGS_ERROR_NONE) {
879 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
882 if ((image_count == 0) || (max_image_num < temp_image_num)) {
883 max_image_num = temp_image_num;
891 /* Numbering rule: Gear is odd number */
892 max_image_num = (max_image_num % 2 == 0) ? max_image_num + 1
895 char file_name_buffer[512];
896 snprintf(file_name_buffer, sizeof(file_name_buffer) - 1,
897 _TZ_SYS_DATA"/setting/wallpaper/extended_wallpaper_%d.jpg", max_image_num);
899 /* Copy image to _TZ_SYS_DATA/setting/wallpaper/ */
900 if (system_setting_copy_extended_wallpaper(file_name_buffer, vconf_value)
901 != SYSTEM_SETTINGS_ERROR_NONE) {
902 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
905 /* remove oldest wallpaper */
906 if (image_count >= WALLPAPER_MAX_COUNT) {
907 if (system_setting_remove_oldest_extended_wallpaper()
908 != SYSTEM_SETTINGS_ERROR_NONE) {
909 remove(file_name_buffer);
910 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
914 if (system_setting_vconf_set_value_string(VCONFKEY_BGSET, file_name_buffer)) {
915 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
918 if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_WALLPAPER_CHANGED_NOTI_INT,
919 VCONFKEY_WALLPAPER_CHANGED_NOTI_GEAR)) {
920 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
923 if (system_setting_vconf_set_value_string(VCONFKEY_BGSET, vconf_value)) {
924 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
929 return SYSTEM_SETTINGS_ERROR_NONE;
933 /* LCOV_EXCL_START */
934 int system_setting_set_wallpaper_lock_screen(system_settings_key_e key, void *value)
938 vconf_value = (char *)value;
940 bool isok = dl_is_supported_image_type_load(vconf_value);
943 SETTING_TRACE("path : %s is not supported file format", vconf_value);
944 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
946 SETTING_TRACE("path : %s is SUPPORT file format", vconf_value);
949 /* error handling here */
950 if (_is_file_accessible(vconf_value) != 0)
951 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
953 if (system_setting_vconf_set_value_string(VCONFKEY_IDLE_LOCK_BGSET, vconf_value)) {
954 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
957 return SYSTEM_SETTINGS_ERROR_NONE;
961 /* LCOV_EXCL_START */
962 int system_setting_set_font_size(system_settings_key_e key, void *value)
966 vconf_value = *(int **)value;
968 if (*vconf_value < 0 || *vconf_value > SYSTEM_SETTINGS_FONT_SIZE_GIANT) {
969 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
972 if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, *vconf_value)) {
973 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
977 return SYSTEM_SETTINGS_ERROR_NONE;
983 /* LCOV_EXCL_START */
984 void *font_conf_doc_parse(char *doc_name, char *font_name)
987 xmlDocPtr doc = NULL;
988 xmlNodePtr cur = NULL;
989 xmlNodePtr cur2 = NULL;
990 xmlNodePtr cur3 = NULL;
993 doc = xmlParseFile(doc_name);
995 cur = xmlDocGetRootElement(doc);
1003 if (xmlStrcmp(cur->name, (const xmlChar *)"fontconfig")) {
1009 cur = cur->xmlChildrenNode;
1011 bool is_changed = false;
1012 while (cur != NULL) {
1013 if ((!xmlStrcmp(cur->name, (const xmlChar *)"match"))) {
1014 cur2 = cur->xmlChildrenNode;
1015 while (cur2 != NULL) {
1016 if ((!xmlStrcmp(cur2->name, (const xmlChar *)"edit"))) {
1017 xmlChar *name = xmlGetProp(cur2, (const xmlChar *)"name");
1018 /* if name is not 'family', break */
1019 if (xmlStrcmp(name, (const xmlChar *)"family")) {
1027 cur3 = cur2->xmlChildrenNode;
1028 while (cur3 != NULL) {
1029 if ((!xmlStrcmp(cur3->name, (const xmlChar *)"string"))) {
1030 xmlNodeSetContent(cur3->xmlChildrenNode, (const xmlChar *)font_name);
1031 key = xmlNodeListGetString(doc, cur3->xmlChildrenNode, 1);
1041 } else if ((!xmlStrcmp(cur->name, (const xmlChar *)"alias"))) {
1042 cur2 = cur->xmlChildrenNode;
1043 while (cur2 != NULL) {
1044 if ((!xmlStrcmp(cur2->name, (const xmlChar *)"family"))) {
1045 xmlNodeSetContent(cur2->xmlChildrenNode, (const xmlChar *)font_name);
1046 key = xmlNodeListGetString(doc, cur2->xmlChildrenNode, 1);
1050 } else if ((!xmlStrcmp(cur2->name, (const xmlChar *)"prefer"))) {
1051 cur3 = cur2->xmlChildrenNode;
1052 while (cur3 != NULL) {
1053 if ((!xmlStrcmp(cur3->name, (const xmlChar *)"family"))) {
1054 xmlNodeSetContent(cur3->xmlChildrenNode, (const xmlChar *)font_name);
1055 key = xmlNodeListGetString(doc, cur3->xmlChildrenNode, 1);
1079 /* LCOV_EXCL_STOP */
1081 /* LCOV_EXCL_START */
1082 int system_setting_set_font_type(system_settings_key_e key, void *value)
1084 SETTING_TRACE_BEGIN;
1085 char *font_name = NULL;
1086 font_name = (char *)value;
1088 /* get current font list */
1089 int is_found = dl_is_available_font(font_name);
1091 if (is_found == 1) {
1092 SETTING_TRACE("found font : %s ", font_name);
1094 SETTING_TRACE(" NOT found font : %s ", font_name);
1095 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1098 bool bsave = dl_font_config_set(font_name);
1101 SETTING_TRACE(" font type save error by font_config_set() ");
1102 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1104 SETTING_TRACE(" save OK - font_config_set() ");
1107 xmlDocPtr doc = (xmlDocPtr)font_conf_doc_parse(SETTING_FONT_CONF_FILE, font_name);
1109 xmlSaveFormatFile(SETTING_FONT_CONF_FILE, doc, 0);
1114 dl_font_config_set_notification();
1117 vconf_value = (char *)value;
1119 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, vconf_value)) {
1120 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1122 return SYSTEM_SETTINGS_ERROR_NONE;
1124 /* LCOV_EXCL_STOP */
1126 /* LCOV_EXCL_START */
1127 int system_setting_set_motion_activation(system_settings_key_e key, void *value)
1129 SETTING_TRACE_BEGIN;
1131 vconf_value = (bool *)value;
1132 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_MOTION_ACTIVATION, *vconf_value)) {
1133 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1135 return SYSTEM_SETTINGS_ERROR_NONE;
1137 /* LCOV_EXCL_STOP */
1139 /* LCOV_EXCL_START */
1140 int system_setting_set_usb_debugging_option(system_settings_key_e key, void *value)
1142 SETTING_TRACE_BEGIN;
1144 vconf_value = (bool *)value;
1145 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_USB_DEBUG_MODE_BOOL, *vconf_value)) {
1146 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1148 return SYSTEM_SETTINGS_ERROR_NONE;
1151 /* LCOV_EXCL_STOP */
1153 /* LCOV_EXCL_START */
1154 int system_setting_set_3g_data_network(system_settings_key_e key, void *value)
1156 SETTING_TRACE_BEGIN;
1158 vconf_value = (bool *)value;
1159 if (system_setting_vconf_set_value_bool(VCONFKEY_3G_ENABLE, *vconf_value)) {
1160 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1163 return SYSTEM_SETTINGS_ERROR_NONE;
1165 /* LCOV_EXCL_STOP */
1167 /* LCOV_EXCL_START */
1168 static int category_func(const char *name, void *user_data)
1170 SETTING_TRACE_BEGIN;
1171 static char *category = "lock-screen";
1172 if (name && !strcmp(name, category)) {
1173 SETTING_TRACE(" SAME ");
1176 SETTING_TRACE(" DIFFERENT -- %s, category -- %s ", name, category);
1182 /* LCOV_EXCL_STOP */
1186 * set 'swipe type' if current lockscreen app is 'com.samsung.lockscreen'
1190 /* LCOV_EXCL_START */
1191 int system_setting_set_lockscreen_app(system_settings_key_e key, void *value)
1193 SETTING_TRACE_BEGIN;
1195 vconf_value = (char *)value; /* ex) com.samsung.lockscreen */
1198 pkgmgrinfo_appinfo_h handle;
1199 r = pkgmgrinfo_appinfo_get_appinfo(vconf_value, &handle);
1200 if (r != PMINFO_R_OK) {
1201 SETTING_TRACE("*** pkginfo failed ");
1202 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
1204 SETTING_TRACE("%p", handle);
1207 int ret = pkgmgrinfo_appinfo_foreach_category(handle, category_func, (void *)"lock-screen");
1208 if (ret != PMINFO_R_OK) {
1209 pkgmgrinfo_appinfo_destroy_appinfo(handle);
1210 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
1213 pkgmgrinfo_appinfo_destroy_appinfo(handle);
1214 /*----------------------------------------------------------------------------------- */
1216 if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_SCREEN_LOCK_TYPE_INT, &locktype)) {
1217 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1220 if (locktype == SETTING_SCREEN_LOCK_TYPE_PASSWORD)
1221 return SYSTEM_SETTINGS_ERROR_LOCKSCREEN_APP_PASSWORD_MODE;
1223 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_3RD_LOCK_PKG_NAME_STR, vconf_value)) {
1224 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1227 if (vconf_value && strcmp(vconf_value, "com.samsung.lockscreen") == 0) {
1228 if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_SCREEN_LOCK_TYPE_INT, SETTING_SCREEN_LOCK_TYPE_SWIPE)) {
1229 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1232 return SYSTEM_SETTINGS_ERROR_NONE;
1234 /* LCOV_EXCL_STOP */
1236 /*/////////////////////////////////////////////////////////////////////////////////////////////// */
1239 int system_setting_set_changed_callback_incoming_call_ringtone(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1241 SETTING_TRACE_BEGIN;
1242 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR, SYSTEM_SETTINGS_KEY_INCOMING_CALL_RINGTONE, 0, user_data);
1245 int system_setting_unset_changed_callback_incoming_call_ringtone(system_settings_key_e key)
1247 SETTING_TRACE_BEGIN;
1248 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR, 0);
1251 int system_setting_set_changed_callback_email_alert_ringtone(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1253 SETTING_TRACE_BEGIN;
1254 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, SYSTEM_SETTINGS_KEY_EMAIL_ALERT_RINGTONE, 0, user_data);
1257 int system_setting_unset_changed_callback_email_alert_ringtone(system_settings_key_e key)
1259 SETTING_TRACE_BEGIN;
1260 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, 0);
1263 int system_setting_set_changed_callback_wallpaper_home_screen(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1265 SETTING_TRACE_BEGIN;
1266 return system_setting_vconf_set_changed_cb(VCONFKEY_BGSET, SYSTEM_SETTINGS_KEY_WALLPAPER_HOME_SCREEN, 0, user_data);
1269 int system_setting_unset_changed_callback_wallpaper_home_screen(system_settings_key_e key)
1271 SETTING_TRACE_BEGIN;
1272 return system_setting_vconf_unset_changed_cb(VCONFKEY_BGSET, 0);
1275 int system_setting_set_changed_callback_wallpaper_lock_screen(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1277 SETTING_TRACE_BEGIN;
1278 return system_setting_vconf_set_changed_cb(VCONFKEY_IDLE_LOCK_BGSET, SYSTEM_SETTINGS_KEY_WALLPAPER_LOCK_SCREEN, 0, user_data);
1281 int system_setting_unset_changed_callback_wallpaper_lock_screen(system_settings_key_e key)
1283 SETTING_TRACE_BEGIN;
1284 return system_setting_vconf_unset_changed_cb(VCONFKEY_IDLE_LOCK_BGSET, 0);
1287 int system_setting_set_changed_callback_font_size(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1289 SETTING_TRACE_BEGIN;
1290 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, SYSTEM_SETTINGS_KEY_FONT_SIZE, 1, user_data);
1293 int system_setting_unset_changed_callback_font_size(system_settings_key_e key)
1295 SETTING_TRACE_BEGIN;
1296 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, 1);
1299 int system_setting_set_changed_callback_usb_debugging_option(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1301 SETTING_TRACE_BEGIN;
1302 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_USB_DEBUG_MODE_BOOL, SYSTEM_SETTINGS_KEY_USB_DEBUGGING_ENABLED, 1, user_data);
1305 int system_setting_unset_changed_callback_usb_debugging_option(system_settings_key_e key)
1307 SETTING_TRACE_BEGIN;
1308 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_USB_DEBUG_MODE_BOOL, 1);
1311 int system_setting_set_changed_callback_3g_data_network(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1313 SETTING_TRACE_BEGIN;
1314 return system_setting_vconf_set_changed_cb(VCONFKEY_3G_ENABLE, SYSTEM_SETTINGS_KEY_3G_DATA_NETWORK_ENABLED, 1, user_data);
1317 int system_setting_unset_changed_callback_3g_data_network(system_settings_key_e key)
1319 SETTING_TRACE_BEGIN;
1320 return system_setting_vconf_unset_changed_cb(VCONFKEY_3G_ENABLE, 1);
1323 int system_setting_set_changed_callback_lockscreen_app(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1325 SETTING_TRACE_BEGIN;
1326 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_3RD_LOCK_PKG_NAME_STR, SYSTEM_SETTINGS_KEY_LOCKSCREEN_APP, 1, user_data);
1329 int system_setting_unset_changed_callback_lockscreen_app(system_settings_key_e key)
1331 SETTING_TRACE_BEGIN;
1332 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_3RD_LOCK_PKG_NAME_STR, 1);
1337 * @todo need to add custom event notification method
1339 int system_setting_set_changed_callback_font_type(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1341 SETTING_TRACE_BEGIN;
1342 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, SYSTEM_SETTINGS_KEY_FONT_TYPE, 2, user_data);
1345 int system_setting_unset_changed_callback_font_type(system_settings_key_e key)
1347 SETTING_TRACE_BEGIN;
1348 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, 2);
1351 /* TODO : 2th argument, callback, is not in use. */
1352 int system_setting_set_changed_callback_motion_activation(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1354 SETTING_TRACE_BEGIN;
1355 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_MOTION_ACTIVATION, SYSTEM_SETTINGS_KEY_MOTION_ACTIVATION, 3, user_data);
1358 int system_setting_unset_changed_callback_motion_activation(system_settings_key_e key)
1360 SETTING_TRACE_BEGIN;
1361 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_MOTION_ACTIVATION, 3);
1364 /*//////////////////////////////////////////////////////////////////////////////////////// */
1365 /*--------------------------------------- */
1366 int system_setting_get_locale_country(system_settings_key_e key, void **value)
1368 SETTING_TRACE_BEGIN;
1369 char *vconf_value = NULL;
1370 if (system_setting_vconf_get_value_string(VCONFKEY_REGIONFORMAT, &vconf_value)) {
1371 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1374 /* parsing validation */
1377 snprintf(arr, 20, "%s", vconf_value);
1379 *value = strdup(arr);
1383 return SYSTEM_SETTINGS_ERROR_NONE;
1386 /* LCOV_EXCL_START */
1387 int system_setting_set_locale_country(system_settings_key_e key, void *value)
1389 SETTING_TRACE_BEGIN;
1390 char *vconf_value = NULL;
1391 vconf_value = (char *)value;
1393 char *ext = "UTF-8";
1396 snprintf(arr, 20, "%s.%s", vconf_value, ext);
1398 if (system_setting_vconf_set_value_string(VCONFKEY_REGIONFORMAT, arr)) {
1399 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1401 return SYSTEM_SETTINGS_ERROR_NONE;
1403 /* LCOV_EXCL_STOP */
1405 int system_setting_set_changed_callback_locale_country(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1407 SETTING_TRACE_BEGIN;
1408 return system_setting_vconf_set_changed_cb(VCONFKEY_REGIONFORMAT, SYSTEM_SETTINGS_KEY_LOCALE_COUNTRY, 3, user_data);
1411 int system_setting_unset_changed_callback_locale_country(system_settings_key_e key)
1413 SETTING_TRACE_BEGIN;
1414 return system_setting_vconf_unset_changed_cb(VCONFKEY_REGIONFORMAT, 3);
1418 /*--------------------------------------- */
1419 int system_setting_get_locale_language(system_settings_key_e key, void **value)
1421 SETTING_TRACE_BEGIN;
1422 char *vconf_value = NULL;
1423 if (system_setting_vconf_get_value_string(VCONFKEY_LANGSET, &vconf_value)) {
1424 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1427 /* parsing validation */
1430 snprintf(arr, 20, "%s", vconf_value);
1432 *value = strdup(arr);
1435 return SYSTEM_SETTINGS_ERROR_NONE;
1438 /* LCOV_EXCL_START */
1439 int system_setting_set_locale_language(system_settings_key_e key, void *value)
1441 SETTING_TRACE_BEGIN;
1442 char *vconf_value = NULL;
1443 vconf_value = (char *)value;
1445 char *ext = "UTF-8";
1448 snprintf(arr, 20, "%s.%s", vconf_value, ext);
1450 if (system_setting_vconf_set_value_string(VCONFKEY_LANGSET, arr)) {
1451 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1453 return SYSTEM_SETTINGS_ERROR_NONE;
1455 /* LCOV_EXCL_STOP */
1457 int system_setting_set_changed_callback_locale_language(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1459 SETTING_TRACE_BEGIN;
1460 /*return system_setting_vconf_set_changed_cb(VCONFKEY_LANGSET, SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, 3, user_data ); */
1461 return system_setting_vconf_set_changed_cb(VCONFKEY_LANGSET, SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, 100, user_data);
1464 int system_setting_unset_changed_callback_locale_language(system_settings_key_e key)
1466 SETTING_TRACE_BEGIN;
1467 return system_setting_vconf_unset_changed_cb(VCONFKEY_LANGSET, 100);
1470 /*--------------------------------------- */
1471 /* LCOV_EXCL_START */
1472 int system_setting_get_locale_timeformat_24hour(system_settings_key_e key, void **value)
1474 SETTING_TRACE_BEGIN;
1477 if (system_setting_vconf_get_value_int(VCONFKEY_REGIONFORMAT_TIME1224, &vconf_value)) {
1478 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1481 bool ret_value = true;
1482 if (vconf_value == VCONFKEY_TIME_FORMAT_12)
1484 else if (vconf_value == VCONFKEY_TIME_FORMAT_24)
1487 *value = (void *)ret_value;
1489 return SYSTEM_SETTINGS_ERROR_NONE;
1491 /* LCOV_EXCL_STOP */
1493 int system_setting_set_locale_timeformat_24hour(system_settings_key_e key, void *value)
1495 SETTING_TRACE_BEGIN;
1498 vconf_value = (bool *)value;
1501 if (system_setting_vconf_set_value_int(VCONFKEY_REGIONFORMAT_TIME1224, VCONFKEY_TIME_FORMAT_24)) {
1502 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1506 if (system_setting_vconf_set_value_int(VCONFKEY_REGIONFORMAT_TIME1224, VCONFKEY_TIME_FORMAT_12)) {
1507 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1512 return SYSTEM_SETTINGS_ERROR_NONE;
1515 int system_setting_set_changed_callback_locale_timeformat_24hour(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1517 SETTING_TRACE_BEGIN;
1518 return system_setting_vconf_set_changed_cb(VCONFKEY_REGIONFORMAT_TIME1224, SYSTEM_SETTINGS_KEY_LOCALE_TIMEFORMAT_24HOUR, 3, user_data);
1521 int system_setting_unset_changed_callback_locale_timeformat_24hour(system_settings_key_e key)
1523 SETTING_TRACE_BEGIN;
1524 return system_setting_vconf_unset_changed_cb(VCONFKEY_REGIONFORMAT_TIME1224, 3);
1527 int system_setting_get_locale_timezone(system_settings_key_e key, void **value)
1530 ssize_t len = readlink(SETTING_TZONE_SYMLINK_PATH, tzpath, sizeof(tzpath)-1);
1534 SETTING_TRACE("parse error for SETTING_TZONE_SYMLINK_PATH");
1535 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1538 SETTING_TRACE("tzpath : %s ", &tzpath[20]);
1539 *value = strdup(&tzpath[20]);
1540 return SYSTEM_SETTINGS_ERROR_NONE;
1543 /* LCOV_EXCL_START */
1544 int system_setting_set_locale_timezone(system_settings_key_e key, void *value)
1546 SETTING_TRACE_BEGIN;
1547 char *timezone_value = NULL;
1548 timezone_value = (char *)value;
1551 snprintf(tz_path, 1024, "/usr/share/zoneinfo/%s", timezone_value);
1553 int is_load = _is_file_accessible(tz_path);
1555 alarmmgr_set_timezone(tz_path);
1557 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_TIMEZONE_ID, timezone_value)) {
1558 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1560 return SYSTEM_SETTINGS_ERROR_NONE;
1562 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
1564 /* LCOV_EXCL_STOP */
1568 /* LCOV_EXCL_START */
1569 int system_setting_set_changed_callback_locale_timezone(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1571 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_TIMEZONE_ID, SYSTEM_SETTINGS_KEY_LOCALE_TIMEZONE, 4, user_data);
1573 /* LCOV_EXCL_STOP */
1575 /* LCOV_EXCL_START */
1576 int system_setting_unset_changed_callback_locale_timezone(system_settings_key_e key)
1578 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_TIMEZONE_ID, 4);
1580 /* LCOV_EXCL_STOP */
1582 /* LCOV_EXCL_START */
1583 int system_setting_set_changed_callback_locale_timezone_changed(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1585 SETTING_TRACE_BEGIN;
1586 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
1588 /* LCOV_EXCL_STOP */
1590 /* LCOV_EXCL_START */
1591 int system_setting_unset_changed_callback_locale_timezone_changed(system_settings_key_e key)
1593 SETTING_TRACE_BEGIN;
1594 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
1596 /* LCOV_EXCL_STOP */
1599 /* LCOV_EXCL_START */
1600 int system_setting_get_time_changed(system_settings_key_e key, void **value)
1602 SETTING_TRACE_BEGIN;
1604 int ** val = (int**)value;
1605 cur_tick = time(NULL);
1607 /* struct tm * localtime = time (cur_tick); */
1608 /* printf("%s\n", ctime(&cur_tick); */
1609 return SYSTEM_SETTINGS_ERROR_NONE;
1612 /* LCOV_EXCL_STOP */
1614 int system_setting_set_changed_callback_time_changed(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1616 SETTING_TRACE_BEGIN;
1617 return system_setting_vconf_set_changed_cb(VCONFKEY_SYSTEM_TIME_CHANGED, SYSTEM_SETTINGS_KEY_TIME_CHANGED, 3, user_data);
1620 int system_setting_unset_changed_callback_time_changed(system_settings_key_e key)
1622 SETTING_TRACE_BEGIN;
1623 return system_setting_vconf_unset_changed_cb(VCONFKEY_SYSTEM_TIME_CHANGED, 3);
1628 /* SYSTEM_SETTINGS_KEY_SOUND_LOCK */
1629 int system_setting_get_sound_lock(system_settings_key_e key, void **value)
1631 SETTING_TRACE_BEGIN;
1634 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_SOUND_LOCK_BOOL, &vconf_value)) {
1635 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1637 *value = (void *)vconf_value;
1639 return SYSTEM_SETTINGS_ERROR_NONE;
1642 int system_setting_set_changed_callback_sound_lock(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1644 SETTING_TRACE_BEGIN;
1645 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_SOUND_LOCK_BOOL, SYSTEM_SETTINGS_KEY_SOUND_LOCK, 3, user_data);
1648 int system_setting_unset_changed_callback_sound_lock(system_settings_key_e key)
1650 SETTING_TRACE_BEGIN;
1651 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_SOUND_LOCK_BOOL, 3);
1655 * a = VCONFKEY_SETAPPL_SOUND_STATUS_BOOL b = VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL
1657 * a == false, b == false --> silent mode
1658 * a == true, b == false --> sound mode
1659 * a == false, b == true --> vibration mode
1661 /* LCOV_EXCL_START */
1662 int system_setting_get_sound_silent_mode(system_settings_key_e key, void **value)
1664 SETTING_TRACE_BEGIN;
1669 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, &sound_cond)) {
1670 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1673 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, &vib_cond)) {
1674 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1677 if (sound_cond == false && vib_cond == false) {
1679 *value = (void *)vconf_value;
1681 vconf_value = false;
1682 *value = (void *)vconf_value;
1684 return SYSTEM_SETTINGS_ERROR_NONE;
1686 /* LCOV_EXCL_STOP */
1689 * a = VCONFKEY_SETAPPL_SOUND_STATUS_BOOL b = VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL
1691 * a == false, b == false --> silent mode
1692 * a == true, b == false --> sound mode
1694 int system_setting_set_sound_silent_mode(system_settings_key_e key, void *value)
1696 SETTING_TRACE_BEGIN;
1699 vconf_value = (bool *)value;
1701 bool vconf_sound = false;
1702 bool vconf_vib = false;
1705 vconf_sound = false;
1712 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, vconf_sound)) {
1713 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1715 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, vconf_vib)) {
1716 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1719 return SYSTEM_SETTINGS_ERROR_NONE;
1725 int system_setting_set_changed_callback_sound_silent_mode(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1727 SETTING_TRACE_BEGIN;
1728 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, SYSTEM_SETTINGS_KEY_SOUND_SILENT_MODE, 3, user_data);
1732 int system_setting_unset_changed_callback_sound_silent_mode(system_settings_key_e key)
1734 SETTING_TRACE_BEGIN;
1735 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, 3);
1738 /* SYSTEM_SETTINGS_KEY_SOUND_TOUCH */
1739 int system_setting_get_sound_touch(system_settings_key_e key, void **value)
1741 SETTING_TRACE_BEGIN;
1744 int ret = system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL, &vconf_value);
1745 if (ret != SYSTEM_SETTINGS_ERROR_NONE) {
1748 *value = (void *)vconf_value;
1752 int system_setting_set_changed_callback_sound_touch(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1754 SETTING_TRACE_BEGIN;
1755 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL, SYSTEM_SETTINGS_KEY_SOUND_TOUCH, 2, user_data);
1758 int system_setting_unset_changed_callback_sound_touch(system_settings_key_e key)
1760 SETTING_TRACE_BEGIN;
1761 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL, 2);
1765 /* SYSTEM_SETTINGS_KEY_SOUND_LOCK */
1766 int system_setting_get_sound_lock(system_settings_key_e key, void **value)
1770 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_SOUND_LOCK_BOOL, &vconf_value)) {
1771 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1773 *value = (void *)vconf_value;
1775 return SYSTEM_SETTINGS_ERROR_NONE;
1779 int system_setting_get_auto_rotation_mode(system_settings_key_e key, void **value)
1781 SETTING_TRACE_BEGIN;
1784 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, &vconf_value)) {
1785 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1787 *value = (void *)vconf_value;
1789 return SYSTEM_SETTINGS_ERROR_NONE;
1792 /* LCOV_EXCL_START */
1793 int system_setting_set_auto_rotation_mode(system_settings_key_e key, void *value)
1795 SETTING_TRACE_BEGIN;
1797 vconf_value = (bool *)value;
1798 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, *vconf_value)) {
1799 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1802 return SYSTEM_SETTINGS_ERROR_NONE;
1804 /* LCOV_EXCL_STOP */
1806 int system_setting_set_changed_callback_auto_rotation_mode(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1808 SETTING_TRACE_BEGIN;
1809 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, SYSTEM_SETTINGS_KEY_DISPLAY_SCREEN_ROTATION_AUTO, 2, user_data);
1812 int system_setting_unset_changed_callback_auto_rotation_mode(system_settings_key_e key)
1814 SETTING_TRACE_BEGIN;
1815 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, 2);
1818 int system_setting_get_screen_backlight_time(system_settings_key_e key, void **value)
1820 SETTING_TRACE_BEGIN;
1822 int ** val = (int**)value;
1824 if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, &vconf_value)) {
1825 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1827 **val = vconf_value;
1829 return SYSTEM_SETTINGS_ERROR_NONE;
1833 /* LCOV_EXCL_START */
1834 int system_setting_set_screen_backlight_time(system_settings_key_e key, void *value)
1836 SETTING_TRACE_BEGIN;
1838 vconf_value = *(int **)value;
1840 if (!(*vconf_value > 0 && *vconf_value <= 600)) {
1841 SETTING_TRACE(" ERR Betweeny here 0 ~ 600");
1842 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
1845 if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, *vconf_value)) {
1846 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1849 return SYSTEM_SETTINGS_ERROR_NONE;
1851 /* LCOV_EXCL_STOP */
1853 int system_setting_set_changed_callback_screen_backlight_time(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1855 SETTING_TRACE_BEGIN;
1856 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, SYSTEM_SETTINGS_KEY_SCREEN_BACKLIGHT_TIME, 2, user_data);
1859 int system_setting_unset_changed_callback_screen_backlight_time(system_settings_key_e key)
1861 SETTING_TRACE_BEGIN;
1862 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, 2);
1865 int system_setting_get_sound_notification(system_settings_key_e key, void **value)
1867 SETTING_TRACE_BEGIN;
1868 char *vconf_value = NULL;
1869 if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, &vconf_value)) {
1870 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1873 *value = vconf_value;
1874 return SYSTEM_SETTINGS_ERROR_NONE;
1877 /* LCOV_EXCL_START */
1878 int system_setting_set_sound_notification(system_settings_key_e key, void *value)
1880 SETTING_TRACE_BEGIN;
1881 char *vconf_value = NULL;
1882 vconf_value = (char *)value;
1884 int is_load = _is_file_accessible(vconf_value);
1886 //SETTING_TRACE(" system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, %s) TRY", vconf_value);
1887 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, vconf_value)) {
1888 //SETTING_TRACE(" system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, %s) FAIL", vconf_value);
1889 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1892 //SETTING_TRACE(" is_file_accessibile FAILED - system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, %s) FAIL", vconf_value);
1893 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1896 return SYSTEM_SETTINGS_ERROR_NONE;
1898 /* LCOV_EXCL_STOP */
1900 int system_setting_set_changed_callback_sound_notification(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1902 SETTING_TRACE_BEGIN;
1903 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, SYSTEM_SETTINGS_KEY_SOUND_NOTIFICATION, 0, user_data);
1906 int system_setting_unset_changed_callback_sound_notification(system_settings_key_e key)
1908 SETTING_TRACE_BEGIN;
1909 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, 0);
1912 int system_setting_get_notification_repetition_period(system_settings_key_e key, void **value)
1914 SETTING_TRACE_BEGIN;
1915 int ** val = (int**)value;
1918 if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_NOTI_MSG_ALERT_REP_TYPE_INT, &vconf_value)) {
1919 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1921 **val = vconf_value;
1923 return SYSTEM_SETTINGS_ERROR_NONE;
1926 /* LCOV_EXCL_START */
1927 int system_setting_set_notification_repetition_period(system_settings_key_e key, void *value)
1929 SETTING_TRACE_BEGIN;
1931 vconf_value = *(int **)value;
1933 if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_NOTI_MSG_ALERT_REP_TYPE_INT, *vconf_value)) {
1934 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1937 return SYSTEM_SETTINGS_ERROR_NONE;
1939 /* LCOV_EXCL_STOP */
1941 int system_setting_set_changed_callback_notification_repetition_period(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1943 SETTING_TRACE_BEGIN;
1944 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_ALERT_REP_TYPE_INT, SYSTEM_SETTINGS_KEY_SOUND_NOTIFICATION_REPETITION_PERIOD, 1, user_data);
1947 int system_setting_unset_changed_callback_notification_repetition_period(system_settings_key_e key)
1949 SETTING_TRACE_BEGIN;
1950 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_ALERT_REP_TYPE_INT, 1);
1953 int system_setting_get_device_name(system_settings_key_e key, void **value)
1955 SETTING_TRACE_BEGIN;
1956 char *vconf_value = NULL;
1957 if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_DEVICE_NAME_STR, &vconf_value)) {
1958 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1961 *value = vconf_value;
1962 return SYSTEM_SETTINGS_ERROR_NONE;
1965 /* LCOV_EXCL_START */
1966 int system_setting_set_device_name(system_settings_key_e key, void *value)
1968 SETTING_TRACE_BEGIN;
1969 char *vconf_value = NULL;
1970 vconf_value = (char *)value;
1972 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_DEVICE_NAME_STR, vconf_value)) {
1973 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1976 return SYSTEM_SETTINGS_ERROR_NONE;
1978 /* LCOV_EXCL_STOP */
1980 int system_setting_set_changed_callback_device_name(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1982 SETTING_TRACE_BEGIN;
1983 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_DEVICE_NAME_STR, SYSTEM_SETTINGS_KEY_DEVICE_NAME, 0, user_data);
1986 int system_setting_unset_changed_callback_device_name(system_settings_key_e key)
1988 SETTING_TRACE_BEGIN;
1989 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_DEVICE_NAME_STR, 0);
1992 /*---------------------------------------------- */
1993 int system_setting_get_network_flight_mode(system_settings_key_e key, void **value)
1995 SETTING_TRACE_BEGIN;
1997 if (system_setting_vconf_get_value_bool(VCONFKEY_TELEPHONY_FLIGHT_MODE, &vconf_value)) {
1998 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2000 *value = (void *)vconf_value;
2002 return SYSTEM_SETTINGS_ERROR_NONE;
2005 int system_setting_set_changed_callback_network_flight_mode(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
2007 SETTING_TRACE_BEGIN;
2008 return system_setting_vconf_set_changed_cb(VCONFKEY_TELEPHONY_FLIGHT_MODE, SYSTEM_SETTINGS_KEY_NETWORK_FLIGHT_MODE, 3, user_data);
2011 int system_setting_unset_changed_callback_network_flight_mode(system_settings_key_e key)
2013 SETTING_TRACE_BEGIN;
2014 return system_setting_vconf_unset_changed_cb(VCONFKEY_TELEPHONY_FLIGHT_MODE, 3);
2017 int system_setting_get_network_wifi_notification(system_settings_key_e key, void **value)
2019 SETTING_TRACE_BEGIN;
2021 if (system_setting_vconf_get_value_int(VCONFKEY_WIFI_ENABLE_QS, &vconf_value)) {
2022 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2025 bret = (vconf_value == VCONFKEY_WIFI_QS_ENABLE) ? true : false;
2027 *value = (void *)bret;
2028 return SYSTEM_SETTINGS_ERROR_NONE;
2031 int system_setting_set_changed_callback_network_wifi_notification(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
2033 SETTING_TRACE_BEGIN;
2034 return system_setting_vconf_set_changed_cb(VCONFKEY_WIFI_ENABLE_QS, SYSTEM_SETTINGS_KEY_NETWORK_WIFI_NOTIFICATION, 4, user_data);
2037 int system_setting_unset_changed_callback_network_wifi_notification(system_settings_key_e key)
2039 SETTING_TRACE_BEGIN;
2040 return system_setting_vconf_unset_changed_cb(VCONFKEY_WIFI_ENABLE_QS, 4);
2043 /* LCOV_EXCL_START */
2044 int system_setting_get_lock_state(system_settings_key_e key, void **value)
2047 int ** val = (int**)value;
2049 if (system_setting_vconf_get_value_int(VCONFKEY_IDLE_LOCK_STATE_READ_ONLY, &vconf_value)) {
2050 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2052 **val = vconf_value;
2054 return SYSTEM_SETTINGS_ERROR_NONE;
2056 /* LCOV_EXCL_STOP */
2058 /* LCOV_EXCL_START */
2059 int system_setting_set_lock_state(system_settings_key_e key, void *value)
2061 SETTING_TRACE_BEGIN;
2063 vconf_value = *(int **)value;
2065 if (system_setting_vconf_set_value_int(VCONFKEY_IDLE_LOCK_STATE_READ_ONLY, *vconf_value)) {
2066 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2069 return SYSTEM_SETTINGS_ERROR_NONE;
2071 /* LCOV_EXCL_STOP */
2073 /* LCOV_EXCL_START */
2074 int system_setting_set_changed_callback_lock_state(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
2076 return system_setting_vconf_set_changed_cb(VCONFKEY_IDLE_LOCK_STATE_READ_ONLY, SYSTEM_SETTINGS_KEY_LOCK_STATE, 4, user_data);
2078 /* LCOV_EXCL_STOP */
2080 /* LCOV_EXCL_START */
2081 int system_setting_unset_changed_callback_lock_state(system_settings_key_e key)
2083 return system_setting_vconf_unset_changed_cb(VCONFKEY_IDLE_LOCK_STATE_READ_ONLY, 4);
2085 /* LCOV_EXCL_STOP */
2087 //----------------------------------------------------------------------------------------------------------------------------
2089 #define DEFAULT_ADS_ID "00000000-0000-0000-0000-000000000000"
2091 int system_setting_get_ads_id(system_settings_key_e key, void **value)
2093 SETTING_TRACE_BEGIN;
2094 int optout_value = 0;
2095 if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_AD_ID_OPT_OUT, &optout_value)) {
2096 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2099 if (optout_value == 1) {
2100 *value = strdup(DEFAULT_ADS_ID);
2101 return SYSTEM_SETTINGS_ERROR_NONE;
2104 char *vconf_value = NULL;
2105 if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_AD_ID, &vconf_value)) {
2106 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2109 *value = vconf_value;
2110 return SYSTEM_SETTINGS_ERROR_NONE;
2115 void make_ad_id(void)
2118 char uuid_unparsed[50] = {0};
2119 uuid_generate(uuid_value);
2120 uuid_unparse(uuid_value, uuid_unparsed);
2121 system_setting_set_ad_id(key, uuid_unparsed); //example of setting the value
2124 int system_setting_set_ads_id(system_settings_key_e key, void *value)
2126 SETTING_TRACE_BEGIN;
2127 char *vconf_value = NULL;
2128 vconf_value = (char *)value;
2130 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_AD_ID, vconf_value)) {
2131 SETTING_TRACE("Setting VCONFKEY_SETAPPL_AD_ID failed");
2132 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2135 return SYSTEM_SETTINGS_ERROR_NONE;
2138 int system_setting_set_changed_callback_ads_id(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
2140 SETTING_TRACE_BEGIN;
2141 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_AD_ID, SYSTEM_SETTINGS_KEY_ADS_ID, 0, user_data);
2144 int system_setting_unset_changed_callback_ads_id(system_settings_key_e key)
2146 SETTING_TRACE_BEGIN;
2147 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_AD_ID, 0);
2150 int system_settings_feature_check_bool(char *path)
2152 bool profile_data = false;
2153 int ret = system_info_get_platform_bool(path, &profile_data);
2154 if (ret != SYSTEM_INFO_ERROR_NONE) {
2155 SETTING_TRACE("Setting - reading profile string failed, %d", ret);
2156 return SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED;
2159 ret = (profile_data == true) ? SYSTEM_SETTINGS_ERROR_NONE : SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED;
2165 int system_setting_feature_check_incoming_call(void *value)
2167 static bool first_query = true;
2168 static int ret = SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED;
2170 if (first_query == true) {
2171 ret = system_settings_feature_check_bool(SETTING_INCOMING_CALL_PATH);
2172 first_query = false;
2178 int system_setting_feature_check_home_screen(void *value)
2180 static bool first_query = true;
2181 static int ret = SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED;
2183 if (first_query == true) {
2184 ret = system_settings_feature_check_bool(SETTING_HOME_SCREEN_PATH);
2185 first_query = false;
2191 int system_setting_feature_check_lock_screen(void *value)
2193 static bool first_query = true;
2194 static int ret = SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED;
2196 if (first_query == true) {
2197 ret = system_settings_feature_check_bool(SETTING_LOCK_SCREEN_PATH);
2198 first_query = false;
2204 int system_setting_feature_check_notification_email(void *value)
2206 static bool first_query = true;
2207 static int ret = SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED;
2209 if (first_query == true) {
2210 ret = system_settings_feature_check_bool(SETTING_NOTIFICATION_EMAIL_PATH);
2211 first_query = false;
2217 int system_setting_feature_check_wifi(void *value)
2219 static bool first_query = true;
2220 static int ret = SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED;
2222 if (first_query == true) {
2223 ret = system_settings_feature_check_bool(SETTING_WIFI_PATH);
2224 first_query = false;
2230 int system_setting_feature_check_telephony(void *value)
2232 static bool first_query = true;
2233 static int ret = SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED;
2235 if (first_query == true) {
2236 ret = system_settings_feature_check_bool(SETTING_TELEPHONY_PATH);
2237 first_query = false;
2244 int system_setting_feature_check_font(void *value)
2246 static bool first_query = true;
2247 static int ret = SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED;
2249 if (first_query == true) {
2250 ret = system_settings_feature_check_bool(SETTING_FONT_PATH);
2251 first_query = false;
2257 int system_setting_feature_check_accessibility_grayscale(void *value)
2259 static bool first_query = true;
2260 static int ret = SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED;
2262 if (first_query == true) {
2263 ret = system_settings_feature_check_bool(SETTING_ACCESSIBILITY_GRAYSCALE_PATH);
2264 first_query = false;
2270 int system_setting_feature_check_accessibility_negative(void *value)
2272 static bool first_query = true;
2273 static int ret = SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED;
2275 if (first_query == true) {
2276 ret = system_settings_feature_check_bool(SETTING_ACCESSIBILITY_NEGATIVE_PATH);
2277 first_query = false;
2283 /* LCOV_EXCL_START */
2284 int system_setting_get_uds_state(system_settings_key_e key, void **value)
2286 int ** p_value = (int**)value;
2288 char *vconf_string_value = NULL;
2290 if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_UDSM, &vconf_value)) {
2291 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2294 SETTING_TRACE("[%s] udsm: %d", __FUNCTION__, vconf_value);
2296 if (vconf_value == SYSTEM_SETTINGS_UDS_ON) {
2297 if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_UDSM_PKGID_LIST, &vconf_string_value))
2298 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2300 if (vconf_string_value) {
2301 if (!strcmp(vconf_string_value, "NONE")) {
2302 vconf_value = SYSTEM_SETTINGS_UDS_ON;
2304 char *app_id = NULL;
2305 char *package_id = NULL;
2306 pid_t pid = getpid();
2307 app_manager_get_app_id(pid, &app_id);
2311 result = package_manager_get_package_id_by_app_id(app_id, &package_id);
2312 if (result != PACKAGE_MANAGER_ERROR_NONE) {
2313 SETTING_TRACE("package_manager_get_package_id_by_app_id returned error! %d", result);
2314 if (vconf_string_value)
2315 free(vconf_string_value);
2316 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2319 SETTING_TRACE("[%s] udsm_pkg_list : %s", __FUNCTION__, vconf_string_value);
2322 if (package_id && strstr(vconf_string_value, package_id)) {
2323 vconf_value = SYSTEM_SETTINGS_UDS_ON_WHITELISTED;
2324 SETTING_TRACE("[%s] pkg id : %s", __FUNCTION__, package_id);
2326 vconf_value = SYSTEM_SETTINGS_UDS_ON;
2330 if (vconf_string_value)
2331 free(vconf_string_value);
2335 **p_value = vconf_value;
2338 return SYSTEM_SETTINGS_ERROR_NONE;
2340 /* LCOV_EXCL_STOP */
2342 /* LCOV_EXCL_START */
2343 int system_setting_set_changed_callback_uds_state(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
2345 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_UDSM, SYSTEM_SETTINGS_KEY_ULTRA_DATA_SAVE, 4, user_data);
2347 /* LCOV_EXCL_STOP */
2349 /* LCOV_EXCL_START */
2350 int system_setting_unset_changed_callback_uds_state(system_settings_key_e key)
2352 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_UDSM, 4);
2354 /* LCOV_EXCL_STOP */
2356 /* LCOV_EXCL_START */
2357 int system_setting_set_changed_callback_uds_pkg_list(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
2359 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_UDSM_PKGID_LIST, SYSTEM_SETTINGS_KEY_ULTRA_DATA_SAVE_PKG_LIST, 4, user_data);
2361 /* LCOV_EXCL_STOP */
2363 /* LCOV_EXCL_START */
2364 int system_setting_unset_changed_callback_uds_pkg_list(system_settings_key_e key)
2366 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_UDSM_PKGID_LIST, 4);
2368 /* LCOV_EXCL_STOP */
2370 /* SYSTEM_SETTINGS_KEY_ACCESSIBILITY_TTS */
2371 int system_setting_get_accessibility_tts(system_settings_key_e key, void **value)
2373 SETTING_TRACE_BEGIN;
2376 int ret = system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_ACCESSIBILITY_TTS, &vconf_value);
2377 if (ret != SYSTEM_SETTINGS_ERROR_NONE) {
2380 *value = (void *)vconf_value;
2384 /* LCOV_EXCL_START */
2385 int system_setting_set_accessibility_tts(system_settings_key_e key, void *value)
2387 SETTING_TRACE_BEGIN;
2389 vconf_value = (bool *)value;
2390 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_ACCESSIBILITY_TTS, *vconf_value)) {
2391 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2394 return SYSTEM_SETTINGS_ERROR_NONE;
2396 /* LCOV_EXCL_STOP */
2398 int system_setting_set_changed_callback_accessibility_tts(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
2400 SETTING_TRACE_BEGIN;
2401 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_TTS, SYSTEM_SETTINGS_KEY_ACCESSIBILITY_TTS, 2, user_data);
2404 int system_setting_unset_changed_callback_accessibility_tts(system_settings_key_e key)
2406 SETTING_TRACE_BEGIN;
2407 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_TTS, 2);
2410 /* SYSTEM_SETTINGS_KEY_VIBRATION */
2411 int system_setting_get_vibration(system_settings_key_e key, void **value)
2413 SETTING_TRACE_BEGIN;
2416 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, &vconf_value)) {
2417 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2419 *value = (void *)vconf_value;
2421 return SYSTEM_SETTINGS_ERROR_NONE;
2424 /* LCOV_EXCL_START */
2425 int system_setting_set_vibration(system_settings_key_e key, void *value)
2427 SETTING_TRACE_BEGIN;
2429 vconf_value = (bool *)value;
2430 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, *vconf_value)) {
2431 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2434 return SYSTEM_SETTINGS_ERROR_NONE;
2436 /* LCOV_EXCL_STOP */
2438 int system_setting_set_changed_callback_vibration(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
2440 SETTING_TRACE_BEGIN;
2441 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, SYSTEM_SETTINGS_KEY_VIBRATION, 2, user_data);
2444 int system_setting_unset_changed_callback_vibration(system_settings_key_e key)
2446 SETTING_TRACE_BEGIN;
2447 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, 2);
2450 /* SYSTEM_SETTINGS_KEY_AUTOMATIC_TIME_UPDATE */
2451 int system_setting_get_automatic_time_update(system_settings_key_e key, void **value)
2453 SETTING_TRACE_BEGIN;
2456 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_STATE_AUTOMATIC_TIME_UPDATE_BOOL, &vconf_value)) {
2457 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2459 *value = (void *)vconf_value;
2461 return SYSTEM_SETTINGS_ERROR_NONE;
2464 /* LCOV_EXCL_START */
2465 int system_setting_set_automatic_time_update(system_settings_key_e key, void *value)
2467 SETTING_TRACE_BEGIN;
2469 vconf_value = (bool *)value;
2470 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_STATE_AUTOMATIC_TIME_UPDATE_BOOL, *vconf_value)) {
2471 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2474 return SYSTEM_SETTINGS_ERROR_NONE;
2476 /* LCOV_EXCL_STOP */
2478 int system_setting_set_changed_callback_automatic_time_update(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
2480 SETTING_TRACE_BEGIN;
2481 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_STATE_AUTOMATIC_TIME_UPDATE_BOOL, SYSTEM_SETTINGS_KEY_AUTOMATIC_TIME_UPDATE, 2, user_data);
2484 int system_setting_unset_changed_callback_automatic_time_update(system_settings_key_e key)
2486 SETTING_TRACE_BEGIN;
2487 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_STATE_AUTOMATIC_TIME_UPDATE_BOOL, 2);
2490 /* SYSTEM_SETTINGS_KEY_DEVELOPER_OPTION_STATE */
2491 int system_setting_get_developer_option_state(system_settings_key_e key, void **value)
2493 SETTING_TRACE_BEGIN;
2496 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_DEVELOPER_OPTION_STATE, &vconf_value)) {
2497 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2499 *value = (void *)vconf_value;
2501 return SYSTEM_SETTINGS_ERROR_NONE;
2504 /* LCOV_EXCL_START */
2505 int system_setting_set_developer_option_state(system_settings_key_e key, void *value)
2507 SETTING_TRACE_BEGIN;
2509 vconf_value = (bool *)value;
2510 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_DEVELOPER_OPTION_STATE, *vconf_value)) {
2511 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2514 return SYSTEM_SETTINGS_ERROR_NONE;
2516 /* LCOV_EXCL_STOP */
2518 int system_setting_set_changed_callback_developer_option_state(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
2520 SETTING_TRACE_BEGIN;
2521 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_DEVELOPER_OPTION_STATE, SYSTEM_SETTINGS_KEY_DEVELOPER_OPTION_STATE, 2, user_data);
2524 int system_setting_unset_changed_callback_developer_option_state(system_settings_key_e key)
2526 SETTING_TRACE_BEGIN;
2527 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_DEVELOPER_OPTION_STATE, 2);
2530 /* SYSTEM_SETTINGS_KEY_ACCESSIBILITY_GRAYSCALE */
2531 int system_setting_get_accessibility_grayscale(system_settings_key_e key, void **value)
2533 SETTING_TRACE_BEGIN;
2536 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_ACCESSIBILITY_GREYSCALE, &vconf_value)) {
2537 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2539 *value = (void *)vconf_value;
2541 return SYSTEM_SETTINGS_ERROR_NONE;
2544 /* LCOV_EXCL_START */
2545 int system_setting_set_accessibility_grayscale(system_settings_key_e key, void *value)
2547 SETTING_TRACE_BEGIN;
2549 vconf_value = (bool *)value;
2550 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_ACCESSIBILITY_GREYSCALE, *vconf_value)) {
2551 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2554 return SYSTEM_SETTINGS_ERROR_NONE;
2556 /* LCOV_EXCL_STOP */
2558 int system_setting_set_changed_callback_accessibility_grayscale(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
2560 SETTING_TRACE_BEGIN;
2561 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_GREYSCALE, SYSTEM_SETTINGS_KEY_ACCESSIBILITY_GRAYSCALE, 2, user_data);
2564 int system_setting_unset_changed_callback_accessibility_grayscale(system_settings_key_e key)
2566 SETTING_TRACE_BEGIN;
2567 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_GREYSCALE, 2);
2570 /* SYSTEM_SETTINGS_KEY_ACCESSIBILITY_NEGATIVE_COLOR */
2571 int system_setting_get_accessibility_negative_color(system_settings_key_e key, void **value)
2573 SETTING_TRACE_BEGIN;
2576 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_ACCESSIBILITY_HIGH_CONTRAST, &vconf_value)) {
2577 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2579 *value = (void *)vconf_value;
2581 return SYSTEM_SETTINGS_ERROR_NONE;
2584 /* LCOV_EXCL_START */
2585 int system_setting_set_accessibility_negative_color(system_settings_key_e key, void *value)
2587 SETTING_TRACE_BEGIN;
2589 vconf_value = (bool *)value;
2590 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_ACCESSIBILITY_HIGH_CONTRAST, *vconf_value)) {
2591 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2594 return SYSTEM_SETTINGS_ERROR_NONE;
2596 /* LCOV_EXCL_STOP */
2598 int system_setting_set_changed_callback_accessibility_negative_color(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
2600 SETTING_TRACE_BEGIN;
2601 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_HIGH_CONTRAST, SYSTEM_SETTINGS_KEY_ACCESSIBILITY_NEGATIVE_COLOR, 2, user_data);
2604 int system_setting_unset_changed_callback_accessibility_negative_color(system_settings_key_e key)
2606 SETTING_TRACE_BEGIN;
2607 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_HIGH_CONTRAST, 2);