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)
96 char *vconf_value = NULL;
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);
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)
119 char *vconf_value = NULL;
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);
134 return SYSTEM_SETTINGS_ERROR_NONE;
138 int system_setting_get_wallpaper_home_screen(system_settings_key_e key, void **value)
142 if (system_setting_vconf_get_value_string(VCONFKEY_BGSET, &vconf_value)) {
143 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
145 *value = vconf_value;
146 return SYSTEM_SETTINGS_ERROR_NONE;
150 int system_setting_get_wallpaper_lock_screen(system_settings_key_e key, void **value)
155 if (system_setting_vconf_get_value_string(VCONFKEY_IDLE_LOCK_BGSET, &vconf_value)) {
156 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
158 *value = vconf_value;
160 return SYSTEM_SETTINGS_ERROR_NONE;
164 /* [int] vconf GET */
165 int system_setting_get_font_size(system_settings_key_e key, void **value)
169 int ** val = (int**)value;
171 if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, &vconf_value)) {
172 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
176 return SYSTEM_SETTINGS_ERROR_NONE;
180 int system_setting_get_default_font_type(system_settings_key_e key, void **value)
183 char *font_name = dl_get_default_font_info();
185 *value = (void *)font_name;
186 return SYSTEM_SETTINGS_ERROR_NONE;
188 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
192 /* [int] vconf GET */
193 int system_setting_get_font_type(system_settings_key_e key, void **value)
196 char *font_name = NULL;
198 if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, &font_name)) {
199 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
203 return SYSTEM_SETTINGS_ERROR_NONE;
207 int system_setting_get_motion_activation(system_settings_key_e key, void **value)
212 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_MOTION_ACTIVATION, &vconf_value)) {
213 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
215 *value = (void *)vconf_value;
217 return SYSTEM_SETTINGS_ERROR_NONE;
220 int system_setting_get_usb_debugging_option(system_settings_key_e key, void **value)
225 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_USB_DEBUG_MODE_BOOL, &vconf_value)) {
226 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
228 *value = (void *)vconf_value;
230 return SYSTEM_SETTINGS_ERROR_NONE;
233 int system_setting_get_3g_data_network(system_settings_key_e key, void **value)
238 if (system_setting_vconf_get_value_bool(VCONFKEY_3G_ENABLE, &vconf_value)) {
239 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
241 *value = (void *)vconf_value;
243 return SYSTEM_SETTINGS_ERROR_NONE;
245 /*////////////////////////////////////////////////////////////////////////////////////////////////// */
249 * get current lock scren app package name (string)
251 * @return SYSTEM_SETTINGS_ERROR_LOCKSCREEN_APP_PASSWORD_MODE raise exception if current lock type is 'password'
253 int system_setting_get_lockscreen_app(system_settings_key_e key, void **value)
256 char *pkg_name = NULL;
258 if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_SCREEN_LOCK_TYPE_INT, &locktype)) {
259 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
262 if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_3RD_LOCK_PKG_NAME_STR, &pkg_name)) {
263 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
266 if (pkg_name && strcmp(pkg_name, "com.samsung.lockscreen") == 0 && locktype == SETTING_SCREEN_LOCK_TYPE_PASSWORD) {
268 return SYSTEM_SETTINGS_ERROR_LOCKSCREEN_APP_PASSWORD_MODE;
272 return SYSTEM_SETTINGS_ERROR_NONE;
276 /*////////////////////////////////////////////////////////////////////////////////////////////////// */
278 int _is_file_accessible(const char *path)
281 int ret = access(path , R_OK);
283 SETTING_TRACE("found the file %s", path);
286 /* error code : 13 */
287 SETTING_TRACE("found the file %s --- error code : %d ", path, errno);
294 /*////////////////////////////////////////////////////////////////////////////////////////////////// */
295 // @todo move to CMake
296 #define DEF_RINGTONE_FILE_PATH SETTING_DEF_RES"/Ringtones"
298 #define USR_RINGTONE_FILE_PATH "/home/owner/content/Sounds/Ringtones"
299 #define JSONFILE "/opt/home/owner/apps_rw/org.tizen.setting/data/.user-ringtones.json"
302 static char* _get_json_file_path()
309 int system_setting_add_incoming_call_ringtone(system_settings_key_e key, void *value)
312 char* pathval = (char*)value;
313 char* dnameval = NULL;
314 char* baseval = NULL;
318 JsonParser *parser = ss_json_ringtone_open_file(JSONFILE);
320 JsonParser *parser = ss_json_ringtone_load_from_data();
323 JsonNode *root = json_parser_get_root(parser);
327 int ret = SYSTEM_SETTINGS_ERROR_NONE;
328 if (false == ss_json_ringtone_contain(root, pathval)) {
329 // @todo : MAKE SURE THE ACTUAL FILE IS THERE ON PATHVAL(SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER)
330 ss_json_ringtone_add(root, JSONFILE, pathval, pathval);
331 SETTING_TRACE("pathval is : %s -- OK", pathval);
333 SETTING_TRACE("pathval is duplicated : %s", pathval);
334 ret = SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
337 dnameval = strdup(pathval);
338 baseval = strdup(pathval);
339 if (dnameval && baseval) {
340 SETTING_TRACE("---> dirname is : %s ", dirname(dnameval));
341 SETTING_TRACE("---> basename is : %s ", basename(baseval));
347 g_object_unref(parser);
354 int system_setting_del_incoming_call_ringtone(system_settings_key_e key, void *value)
357 char* pathval = (char*)value;
360 JsonParser* parser = ss_json_ringtone_open_file(JSONFILE);
362 JsonParser* parser = ss_json_ringtone_load_from_data();
364 JsonNode *root = json_parser_get_root(parser);
366 ss_json_ringtone_remove(root, JSONFILE, pathval);
367 //void ss_json_ringtone_remove(JsonNode *root, char* filename, char* path_to_del)
369 ss_json_ringtone_print(root);
371 g_object_unref(parser);
375 return SYSTEM_SETTINGS_ERROR_NONE;
379 /* LCOV_EXCL_START */
380 gint _compare_cb(gconstpointer d1, gconstpointer d2)
382 fileNodeInfo *pNode1 = (fileNodeInfo *)d1;
383 fileNodeInfo *pNode2 = (fileNodeInfo *)d2;
385 return strcmp(pNode1->media_name, pNode2->media_name);
390 * get the RINGTONE list
392 static void _get_default_ringtones(system_settings_key_e key, system_settings_iter_cb callback, void *data)
396 GList *filelist = NULL;
398 fileNodeInfo *node = NULL;
401 //-----------------------------------------------------------------------------------------------------------------
402 // 1. get the default ringtone list
403 //-----------------------------------------------------------------------------------------------------------------
404 int ret = get_filelist_from_dir_path(DEF_RINGTONE_FILE_PATH, &filelist);
406 SETTING_TRACE("Failed to get filelist, ret = %d %s", ret, DEF_RINGTONE_FILE_PATH);
409 filelist = g_list_sort(filelist, _compare_cb);
411 for (iter = filelist; iter != NULL; iter = g_list_next(iter)) {
412 node = (fileNodeInfo *)iter->data;
413 SETTING_TRACE("file path = (%d) : name:%s path:%s [%s]", ret, node->name, node->path, node->media_name);
414 // @todo assert NULL check
417 snprintf(temp, 1024, "%s/%s", node->path, node->name);
418 char* path = strdup(temp);
419 bool ret = callback(idx, (void *)(path), data);
425 SETTING_TRACE("quit the iteration by return value == false : %d", ret);
430 SETTING_TRACE("--> system_setting_data_iterator is NULL");
434 for (iter = filelist; iter != NULL; iter = g_list_next(iter)) {
435 node = (fileNodeInfo *)iter->data;
438 FREE(node->media_name);
441 g_list_free(filelist);
446 static void _get_user_ringtones(system_settings_key_e key, system_settings_iter_cb callback, void *data)
452 JsonParser* parser = ss_json_ringtone_open_file(JSONFILE);
454 JsonParser* parser = ss_json_ringtone_load_from_data();
457 JsonNode *root = json_parser_get_root(parser);
458 int size = json_array_get_length(json_node_get_array(root));
461 for (i = 0; i < size ; i++) {
462 JsonObject *ringtone = json_array_get_object_element(json_node_get_array(root), i);
463 char *nameval = (char *)json_object_get_string_member(ringtone, "name");
464 char *pathval = (char *)json_object_get_string_member(ringtone, "path");
465 SETTING_TRACE("(%s) --- (%s) \n", nameval, pathval);
466 if (callback && pathval) {
467 char* path = strdup(pathval);
468 bool ret = callback(i, (void *)(path), data);
470 SETTING_TRACE("quit the iteration by return value == false : %d", ret);
475 SETTING_TRACE("--> callback is NULL");
479 g_object_unref(parser);
482 int system_setting_list_incoming_call_ringtone(system_settings_key_e key, system_settings_iter_cb callback, void *data)
486 _get_default_ringtones(key, callback, data);
487 //-----------------------------------------------------------------------------------------------------------------
488 // 2. get the USER ringtone list
489 //-----------------------------------------------------------------------------------------------------------------
490 _get_user_ringtones(key, callback, data);
492 return SYSTEM_SETTINGS_ERROR_NONE;
496 /* LCOV_EXCL_START */
497 int system_setting_set_incoming_call_ringtone(system_settings_key_e key, void *value)
501 vconf_value = (char *)value;
503 int ret = _is_file_accessible(vconf_value);
505 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR, vconf_value)) {
506 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
509 /* @todo add a common ret_handler */
513 return SYSTEM_SETTINGS_ERROR_NONE;
518 /* LCOV_EXCL_START */
519 int system_setting_set_email_alert_ringtone(system_settings_key_e key, void *value)
523 vconf_value = (char *)value;
525 int ret = _is_file_accessible(vconf_value);
527 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, vconf_value)) {
528 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
531 /*return SYSTEM_SETTINGS_ERROR_IO_ERROR;*/
532 /* @todo add a common ret_handler */
536 return SYSTEM_SETTINGS_ERROR_NONE;
540 /* LCOV_EXCL_START */
541 static bool dl_is_supported_image_type_load(char *path)
546 bool (*image_type_check)(char *path);
548 handle = dlopen(SETTING_UTILS_SO_FILE_PATH, RTLD_LAZY);
550 SETTING_TRACE("ERROR!! canNOT find libsystem-settings-util.so.0.1.0");
554 image_type_check = dlsym(handle, "__is_supported_image_type_load");
555 if ((error = dlerror()) != NULL) {
556 SETTING_TRACE("ERROR!! canNOT find __is_supported_image_type_load function at libsystem-settings-util.so.0.1.0");
561 ret = image_type_check(path);
568 /* LCOV_EXCL_START */
569 static int dl_is_available_font(char *str)
574 int (*check_available_font)(char *font_name);
576 handle = dlopen(SETTING_UTILS_SO_FILE_PATH, RTLD_LAZY);
578 SETTING_TRACE("ERROR!! canNOT find libsystem-settings-util.so.0.1.0");
582 check_available_font = dlsym(handle, "__is_available_font");
583 if ((error = dlerror()) != NULL) {
584 SETTING_TRACE("ERROR!! canNOT find __is_available_font function at libsystem-settings-util.so.0.1.0");
589 ret = check_available_font(str);
596 /* LCOV_EXCL_START */
597 static void dl_font_size_set()
601 void (*set_font_size)();
603 handle = dlopen(SETTING_UTILS_SO_FILE_PATH, RTLD_LAZY);
605 SETTING_TRACE("ERROR!! canNOT find libsystem-settings-util.so.0.1.0");
609 set_font_size = dlsym(handle, "__font_size_set");
610 if ((error = dlerror()) != NULL) {
611 SETTING_TRACE("ERROR!! canNOT find __font_size_set function at libsystem-settings-util.so.0.1.0");
623 /* LCOV_EXCL_START */
624 static void dl_font_config_set_notification()
628 void (*set_font_nodification)();
630 handle = dlopen(SETTING_UTILS_SO_FILE_PATH, RTLD_LAZY);
632 SETTING_TRACE("ERROR!! canNOT find libsystem-settings-util.so.0.1.0");
636 set_font_nodification = dlsym(handle, "font_config_set_notification");
637 if ((error = dlerror()) != NULL) {
638 SETTING_TRACE("ERROR!! canNOT find font_config_set_notification function at libsystem-settings-util.so.0.1.0");
643 set_font_nodification();
650 /* LCOV_EXCL_START */
651 static bool dl_font_config_set(char *font_name)
656 bool (*check_font_type)(char *font_name);
658 handle = dlopen(SETTING_UTILS_SO_FILE_PATH, RTLD_LAZY);
660 SETTING_TRACE("ERROR!! canNOT find libsystem-settings-util.so.0.1.0");
664 check_font_type = dlsym(handle, "font_config_set");
665 if ((error = dlerror()) != NULL) {
666 SETTING_TRACE("ERROR!! canNOT find font_config_set function at libsystem-settings-util.so.0.1.0");
671 ret = check_font_type(font_name);
678 /* LCOV_EXCL_START */
679 static char *dl_get_default_font_info()
684 char *(*get_font_info)();
686 handle = dlopen(SETTING_UTILS_SO_FILE_PATH, RTLD_LAZY);
688 SETTING_TRACE("ERROR!! canNOT find libsystem-settings-util.so.0.1.0");
692 get_font_info = dlsym(handle, "_get_default_font");
694 if ((error = dlerror()) != NULL) {
695 SETTING_TRACE("ERROR!! canNOT find _get_default_font function at libsystem-settings-util.so.0.1.0");
700 ret = get_font_info();
707 #ifdef TIZEN_WEARABLE
708 /* LCOV_EXCL_START */
709 static int system_setting_get_extended_wallpaper_num(const char *file_path, unsigned int *num)
713 const char *find_str = "extended_wallpaper_";
716 if (!(ch = strstr(file_path, find_str))) {
717 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
719 strncpy(buffer, file_path, ch - file_path);
720 buffer[ch - file_path] = 0;
721 sprintf(buffer + (ch - file_path), "%s%s", "", ch + strlen(find_str));
723 if (!isdigit(buffer[0])) {
724 SETTING_TRACE("%s is not number", buffer);
725 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
730 return SYSTEM_SETTINGS_ERROR_NONE;
734 /* LCOV_EXCL_START */
735 static int system_setting_copy_extended_wallpaper(const char *dest_file_path, const char *source_file_path)
738 if (!source_file_path || !dest_file_path) {
739 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
745 fd = open(source_file_path, O_RDONLY);
747 SETTING_TRACE("file open failed: %s", source_file_path);
748 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
752 fd2 = open(dest_file_path, O_WRONLY | O_CREAT, S_IRWXU | S_IRWXG | S_IRWXO);
754 SETTING_TRACE("file creation failed: %s", dest_file_path);
756 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
759 while (read(fd, buf, sizeof(buf) - 1) > 0) {
760 write(fd2, buf, sizeof(buf) - 1);
766 if (chmod(dest_file_path, S_IRWXU | S_IRWXG | S_IRWXO) < 0) {
767 SETTING_TRACE("chmod failed: %s", dest_file_path);
770 return SYSTEM_SETTINGS_ERROR_NONE;
774 /* LCOV_EXCL_START */
775 static int system_setting_remove_oldest_extended_wallpaper()
780 char *min_image_name = NULL;
781 unsigned int min_image_num = 0;
782 unsigned int temp_image_num = 0;
785 if ((dp = opendir(_TZ_SYS_DATA"/setting/wallpaper")) == NULL) {
786 SETTING_TRACE("opendir error");
787 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
790 while ((dirp = readdir(dp))) {
791 if (!strcmp(dirp->d_name, ".") || !strcmp(dirp->d_name, ".."))
794 if (system_setting_get_extended_wallpaper_num(dirp->d_name, &temp_image_num)
795 != SYSTEM_SETTINGS_ERROR_NONE) {
796 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
799 if ((image_count == 0) || (min_image_num > temp_image_num)) {
800 min_image_num = temp_image_num;
801 min_image_name = dirp->d_name;
808 if (min_image_name) {
809 snprintf(buf, sizeof(buf) - 1, _TZ_SYS_DATA"/setting/wallpaper/%s", min_image_name);
810 if (remove(buf) < 0) { /* remove oldest image */
811 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
815 return SYSTEM_SETTINGS_ERROR_NONE;
819 /* LCOV_EXCL_START */
820 static int system_setting_check_extended_wallpaper(const char *file_path)
824 if (!file_path || !strlen(file_path))
826 snprintf(buffer, 512, "%s/.bgwallpaper", tzplatform_getenv(TZ_USER_CONTENT));
827 return (strstr(file_path, buffer) != NULL);
831 #define WALLPAPER_MAX_COUNT 10
833 /* LCOV_EXCL_START */
834 int system_setting_set_wallpaper_home_screen(system_settings_key_e key, void *value)
838 vconf_value = (char *)value;
840 bool isok = dl_is_supported_image_type_load(vconf_value);
843 SETTING_TRACE("path : %s is not supported file format", vconf_value);
844 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
846 SETTING_TRACE("path : %s is SUPPORT file format", vconf_value);
849 /* error handling here */
850 if (_is_file_accessible(vconf_value) != 0)
851 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
853 if (system_setting_vconf_set_value_string(VCONFKEY_BGSET, vconf_value)) {
854 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
858 #ifdef TIZEN_WEARABLE
859 if (system_setting_check_extended_wallpaper(vconf_value)) { /* New extended wallpaper */
862 unsigned int max_image_num = 0;
863 unsigned int temp_image_num = 0;
866 if ((dp = opendir(_TZ_SYS_DATA"/setting/wallpaper")) == NULL) {
867 SETTING_TRACE("Setting - dir open error!");
868 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
871 /* Check a max number of wallpapers */
872 while ((dirp = readdir(dp))) {
873 if (!strcmp(dirp->d_name, ".") || !strcmp(dirp->d_name, ".."))
876 if (system_setting_get_extended_wallpaper_num(dirp->d_name, &temp_image_num)
877 != SYSTEM_SETTINGS_ERROR_NONE) {
880 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
883 if ((image_count == 0) || (max_image_num < temp_image_num)) {
884 max_image_num = temp_image_num;
892 /* Numbering rule: Gear is odd number */
893 max_image_num = (max_image_num % 2 == 0) ? max_image_num + 1
896 char file_name_buffer[512];
897 snprintf(file_name_buffer, sizeof(file_name_buffer) - 1,
898 _TZ_SYS_DATA"/setting/wallpaper/extended_wallpaper_%d.jpg", max_image_num);
900 /* Copy image to _TZ_SYS_DATA/setting/wallpaper/ */
901 if (system_setting_copy_extended_wallpaper(file_name_buffer, vconf_value)
902 != SYSTEM_SETTINGS_ERROR_NONE) {
903 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
906 /* remove oldest wallpaper */
907 if (image_count >= WALLPAPER_MAX_COUNT) {
908 if (system_setting_remove_oldest_extended_wallpaper()
909 != SYSTEM_SETTINGS_ERROR_NONE) {
910 remove(file_name_buffer);
911 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
915 if (system_setting_vconf_set_value_string(VCONFKEY_BGSET, file_name_buffer)) {
916 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
919 if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_WALLPAPER_CHANGED_NOTI_INT,
920 VCONFKEY_WALLPAPER_CHANGED_NOTI_GEAR)) {
921 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
924 if (system_setting_vconf_set_value_string(VCONFKEY_BGSET, vconf_value)) {
925 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
930 return SYSTEM_SETTINGS_ERROR_NONE;
934 /* LCOV_EXCL_START */
935 int system_setting_set_wallpaper_lock_screen(system_settings_key_e key, void *value)
939 vconf_value = (char *)value;
941 bool isok = dl_is_supported_image_type_load(vconf_value);
944 SETTING_TRACE("path : %s is not supported file format", vconf_value);
945 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
947 SETTING_TRACE("path : %s is SUPPORT file format", vconf_value);
950 /* error handling here */
951 if (_is_file_accessible(vconf_value) != 0)
952 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
954 if (system_setting_vconf_set_value_string(VCONFKEY_IDLE_LOCK_BGSET, vconf_value)) {
955 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
958 return SYSTEM_SETTINGS_ERROR_NONE;
962 /* LCOV_EXCL_START */
963 int system_setting_set_font_size(system_settings_key_e key, void *value)
967 vconf_value = *(int **)value;
969 if (*vconf_value < 0 || *vconf_value > SYSTEM_SETTINGS_FONT_SIZE_GIANT) {
970 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
973 if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, *vconf_value)) {
974 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
978 return SYSTEM_SETTINGS_ERROR_NONE;
984 /* LCOV_EXCL_START */
985 void *font_conf_doc_parse(char *doc_name, char *font_name)
988 xmlDocPtr doc = NULL;
989 xmlNodePtr cur = NULL;
990 xmlNodePtr cur2 = NULL;
991 xmlNodePtr cur3 = NULL;
994 doc = xmlParseFile(doc_name);
996 cur = xmlDocGetRootElement(doc);
1004 if (xmlStrcmp(cur->name, (const xmlChar *)"fontconfig")) {
1010 cur = cur->xmlChildrenNode;
1012 bool is_changed = false;
1013 while (cur != NULL) {
1014 if ((!xmlStrcmp(cur->name, (const xmlChar *)"match"))) {
1015 cur2 = cur->xmlChildrenNode;
1016 while (cur2 != NULL) {
1017 if ((!xmlStrcmp(cur2->name, (const xmlChar *)"edit"))) {
1018 xmlChar *name = xmlGetProp(cur2, (const xmlChar *)"name");
1019 /* if name is not 'family', break */
1020 if (xmlStrcmp(name, (const xmlChar *)"family")) {
1028 cur3 = cur2->xmlChildrenNode;
1029 while (cur3 != NULL) {
1030 if ((!xmlStrcmp(cur3->name, (const xmlChar *)"string"))) {
1031 xmlNodeSetContent(cur3->xmlChildrenNode, (const xmlChar *)font_name);
1032 key = xmlNodeListGetString(doc, cur3->xmlChildrenNode, 1);
1042 } else if ((!xmlStrcmp(cur->name, (const xmlChar *)"alias"))) {
1043 cur2 = cur->xmlChildrenNode;
1044 while (cur2 != NULL) {
1045 if ((!xmlStrcmp(cur2->name, (const xmlChar *)"family"))) {
1046 xmlNodeSetContent(cur2->xmlChildrenNode, (const xmlChar *)font_name);
1047 key = xmlNodeListGetString(doc, cur2->xmlChildrenNode, 1);
1051 } else if ((!xmlStrcmp(cur2->name, (const xmlChar *)"prefer"))) {
1052 cur3 = cur2->xmlChildrenNode;
1053 while (cur3 != NULL) {
1054 if ((!xmlStrcmp(cur3->name, (const xmlChar *)"family"))) {
1055 xmlNodeSetContent(cur3->xmlChildrenNode, (const xmlChar *)font_name);
1056 key = xmlNodeListGetString(doc, cur3->xmlChildrenNode, 1);
1080 /* LCOV_EXCL_STOP */
1082 /* LCOV_EXCL_START */
1083 int system_setting_set_font_type(system_settings_key_e key, void *value)
1085 SETTING_TRACE_BEGIN;
1086 char *font_name = NULL;
1087 font_name = (char *)value;
1089 /* get current font list */
1090 int is_found = dl_is_available_font(font_name);
1092 if (is_found == 1) {
1093 SETTING_TRACE("found font : %s ", font_name);
1095 SETTING_TRACE(" NOT found font : %s ", font_name);
1096 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1099 bool bsave = dl_font_config_set(font_name);
1102 SETTING_TRACE(" font type save error by font_config_set() ");
1103 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1105 SETTING_TRACE(" save OK - font_config_set() ");
1108 xmlDocPtr doc = (xmlDocPtr)font_conf_doc_parse(SETTING_FONT_CONF_FILE, font_name);
1110 xmlSaveFormatFile(SETTING_FONT_CONF_FILE, doc, 0);
1115 dl_font_config_set_notification();
1118 vconf_value = (char *)value;
1120 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, vconf_value)) {
1121 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1123 return SYSTEM_SETTINGS_ERROR_NONE;
1125 /* LCOV_EXCL_STOP */
1127 /* LCOV_EXCL_START */
1128 int system_setting_set_motion_activation(system_settings_key_e key, void *value)
1130 SETTING_TRACE_BEGIN;
1132 vconf_value = (bool *)value;
1133 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_MOTION_ACTIVATION, *vconf_value)) {
1134 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1136 return SYSTEM_SETTINGS_ERROR_NONE;
1138 /* LCOV_EXCL_STOP */
1140 /* LCOV_EXCL_START */
1141 int system_setting_set_usb_debugging_option(system_settings_key_e key, void *value)
1143 SETTING_TRACE_BEGIN;
1145 vconf_value = (bool *)value;
1146 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_USB_DEBUG_MODE_BOOL, *vconf_value)) {
1147 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1149 return SYSTEM_SETTINGS_ERROR_NONE;
1152 /* LCOV_EXCL_STOP */
1154 /* LCOV_EXCL_START */
1155 int system_setting_set_3g_data_network(system_settings_key_e key, void *value)
1157 SETTING_TRACE_BEGIN;
1159 vconf_value = (bool *)value;
1160 if (system_setting_vconf_set_value_bool(VCONFKEY_3G_ENABLE, *vconf_value)) {
1161 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1164 return SYSTEM_SETTINGS_ERROR_NONE;
1166 /* LCOV_EXCL_STOP */
1168 /* LCOV_EXCL_START */
1169 static int category_func(const char *name, void *user_data)
1171 SETTING_TRACE_BEGIN;
1172 static char *category = "lock-screen";
1173 if (name && !strcmp(name, category)) {
1174 SETTING_TRACE(" SAME ");
1177 SETTING_TRACE(" DIFFERENT -- %s, category -- %s ", name, category);
1183 /* LCOV_EXCL_STOP */
1187 * set 'swipe type' if current lockscreen app is 'com.samsung.lockscreen'
1191 /* LCOV_EXCL_START */
1192 int system_setting_set_lockscreen_app(system_settings_key_e key, void *value)
1194 SETTING_TRACE_BEGIN;
1196 vconf_value = (char *)value; /* ex) com.samsung.lockscreen */
1199 pkgmgrinfo_appinfo_h handle;
1200 r = pkgmgrinfo_appinfo_get_appinfo(vconf_value, &handle);
1201 if (r != PMINFO_R_OK) {
1202 SETTING_TRACE("*** pkginfo failed ");
1203 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
1205 SETTING_TRACE("%p", handle);
1208 int ret = pkgmgrinfo_appinfo_foreach_category(handle, category_func, (void *)"lock-screen");
1209 if (ret != PMINFO_R_OK) {
1210 pkgmgrinfo_appinfo_destroy_appinfo(handle);
1211 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
1214 pkgmgrinfo_appinfo_destroy_appinfo(handle);
1215 /*----------------------------------------------------------------------------------- */
1217 if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_SCREEN_LOCK_TYPE_INT, &locktype)) {
1218 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1221 if (locktype == SETTING_SCREEN_LOCK_TYPE_PASSWORD)
1222 return SYSTEM_SETTINGS_ERROR_LOCKSCREEN_APP_PASSWORD_MODE;
1224 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_3RD_LOCK_PKG_NAME_STR, vconf_value)) {
1225 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1228 if (vconf_value && strcmp(vconf_value, "com.samsung.lockscreen") == 0) {
1229 if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_SCREEN_LOCK_TYPE_INT, SETTING_SCREEN_LOCK_TYPE_SWIPE)) {
1230 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1233 return SYSTEM_SETTINGS_ERROR_NONE;
1235 /* LCOV_EXCL_STOP */
1237 /*/////////////////////////////////////////////////////////////////////////////////////////////// */
1240 int system_setting_set_changed_callback_incoming_call_ringtone(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1242 SETTING_TRACE_BEGIN;
1243 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR, SYSTEM_SETTINGS_KEY_INCOMING_CALL_RINGTONE, 0, user_data);
1246 int system_setting_unset_changed_callback_incoming_call_ringtone(system_settings_key_e key)
1248 SETTING_TRACE_BEGIN;
1249 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR, 0);
1252 int system_setting_set_changed_callback_email_alert_ringtone(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1254 SETTING_TRACE_BEGIN;
1255 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, SYSTEM_SETTINGS_KEY_EMAIL_ALERT_RINGTONE, 0, user_data);
1258 int system_setting_unset_changed_callback_email_alert_ringtone(system_settings_key_e key)
1260 SETTING_TRACE_BEGIN;
1261 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, 0);
1264 int system_setting_set_changed_callback_wallpaper_home_screen(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1266 SETTING_TRACE_BEGIN;
1267 return system_setting_vconf_set_changed_cb(VCONFKEY_BGSET, SYSTEM_SETTINGS_KEY_WALLPAPER_HOME_SCREEN, 0, user_data);
1270 int system_setting_unset_changed_callback_wallpaper_home_screen(system_settings_key_e key)
1272 SETTING_TRACE_BEGIN;
1273 return system_setting_vconf_unset_changed_cb(VCONFKEY_BGSET, 0);
1276 int system_setting_set_changed_callback_wallpaper_lock_screen(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1278 SETTING_TRACE_BEGIN;
1279 return system_setting_vconf_set_changed_cb(VCONFKEY_IDLE_LOCK_BGSET, SYSTEM_SETTINGS_KEY_WALLPAPER_LOCK_SCREEN, 0, user_data);
1282 int system_setting_unset_changed_callback_wallpaper_lock_screen(system_settings_key_e key)
1284 SETTING_TRACE_BEGIN;
1285 return system_setting_vconf_unset_changed_cb(VCONFKEY_IDLE_LOCK_BGSET, 0);
1288 int system_setting_set_changed_callback_font_size(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1290 SETTING_TRACE_BEGIN;
1291 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, SYSTEM_SETTINGS_KEY_FONT_SIZE, 1, user_data);
1294 int system_setting_unset_changed_callback_font_size(system_settings_key_e key)
1296 SETTING_TRACE_BEGIN;
1297 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, 1);
1300 int system_setting_set_changed_callback_usb_debugging_option(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1302 SETTING_TRACE_BEGIN;
1303 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_USB_DEBUG_MODE_BOOL, SYSTEM_SETTINGS_KEY_USB_DEBUGGING_ENABLED, 1, user_data);
1306 int system_setting_unset_changed_callback_usb_debugging_option(system_settings_key_e key)
1308 SETTING_TRACE_BEGIN;
1309 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_USB_DEBUG_MODE_BOOL, 1);
1312 int system_setting_set_changed_callback_3g_data_network(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1314 SETTING_TRACE_BEGIN;
1315 return system_setting_vconf_set_changed_cb(VCONFKEY_3G_ENABLE, SYSTEM_SETTINGS_KEY_3G_DATA_NETWORK_ENABLED, 1, user_data);
1318 int system_setting_unset_changed_callback_3g_data_network(system_settings_key_e key)
1320 SETTING_TRACE_BEGIN;
1321 return system_setting_vconf_unset_changed_cb(VCONFKEY_3G_ENABLE, 1);
1324 int system_setting_set_changed_callback_lockscreen_app(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1326 SETTING_TRACE_BEGIN;
1327 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_3RD_LOCK_PKG_NAME_STR, SYSTEM_SETTINGS_KEY_LOCKSCREEN_APP, 1, user_data);
1330 int system_setting_unset_changed_callback_lockscreen_app(system_settings_key_e key)
1332 SETTING_TRACE_BEGIN;
1333 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_3RD_LOCK_PKG_NAME_STR, 1);
1338 * @todo need to add custom event notification method
1340 int system_setting_set_changed_callback_font_type(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1342 SETTING_TRACE_BEGIN;
1343 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, SYSTEM_SETTINGS_KEY_FONT_TYPE, 2, user_data);
1346 int system_setting_unset_changed_callback_font_type(system_settings_key_e key)
1348 SETTING_TRACE_BEGIN;
1349 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, 2);
1352 /* TODO : 2th argument, callback, is not in use. */
1353 int system_setting_set_changed_callback_motion_activation(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1355 SETTING_TRACE_BEGIN;
1356 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_MOTION_ACTIVATION, SYSTEM_SETTINGS_KEY_MOTION_ACTIVATION, 3, user_data);
1359 int system_setting_unset_changed_callback_motion_activation(system_settings_key_e key)
1361 SETTING_TRACE_BEGIN;
1362 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_MOTION_ACTIVATION, 3);
1365 /*//////////////////////////////////////////////////////////////////////////////////////// */
1366 /*--------------------------------------- */
1367 int system_setting_get_locale_country(system_settings_key_e key, void **value)
1369 SETTING_TRACE_BEGIN;
1370 char *vconf_value = NULL;
1371 if (system_setting_vconf_get_value_string(VCONFKEY_REGIONFORMAT, &vconf_value)) {
1372 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1375 /* parsing validation */
1378 snprintf(arr, 20, "%s", vconf_value);
1380 *value = strdup(arr);
1384 return SYSTEM_SETTINGS_ERROR_NONE;
1387 /* LCOV_EXCL_START */
1388 int system_setting_set_locale_country(system_settings_key_e key, void *value)
1390 SETTING_TRACE_BEGIN;
1391 char *vconf_value = NULL;
1392 vconf_value = (char *)value;
1394 char *ext = "UTF-8";
1397 snprintf(arr, 20, "%s.%s", vconf_value, ext);
1399 if (system_setting_vconf_set_value_string(VCONFKEY_REGIONFORMAT, arr)) {
1400 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1402 return SYSTEM_SETTINGS_ERROR_NONE;
1404 /* LCOV_EXCL_STOP */
1406 int system_setting_set_changed_callback_locale_country(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1408 SETTING_TRACE_BEGIN;
1409 return system_setting_vconf_set_changed_cb(VCONFKEY_REGIONFORMAT, SYSTEM_SETTINGS_KEY_LOCALE_COUNTRY, 3, user_data);
1412 int system_setting_unset_changed_callback_locale_country(system_settings_key_e key)
1414 SETTING_TRACE_BEGIN;
1415 return system_setting_vconf_unset_changed_cb(VCONFKEY_REGIONFORMAT, 3);
1419 /*--------------------------------------- */
1420 int system_setting_get_locale_language(system_settings_key_e key, void **value)
1422 SETTING_TRACE_BEGIN;
1423 char *vconf_value = NULL;
1424 if (system_setting_vconf_get_value_string(VCONFKEY_LANGSET, &vconf_value)) {
1425 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1428 /* parsing validation */
1431 snprintf(arr, 20, "%s", vconf_value);
1433 *value = strdup(arr);
1436 return SYSTEM_SETTINGS_ERROR_NONE;
1439 /* LCOV_EXCL_START */
1440 int system_setting_set_locale_language(system_settings_key_e key, void *value)
1442 SETTING_TRACE_BEGIN;
1443 char *vconf_value = NULL;
1444 vconf_value = (char *)value;
1446 char *ext = "UTF-8";
1449 snprintf(arr, 20, "%s.%s", vconf_value, ext);
1451 if (system_setting_vconf_set_value_string(VCONFKEY_LANGSET, arr)) {
1452 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1454 return SYSTEM_SETTINGS_ERROR_NONE;
1456 /* LCOV_EXCL_STOP */
1458 int system_setting_set_changed_callback_locale_language(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1460 SETTING_TRACE_BEGIN;
1461 /*return system_setting_vconf_set_changed_cb(VCONFKEY_LANGSET, SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, 3, user_data ); */
1462 return system_setting_vconf_set_changed_cb(VCONFKEY_LANGSET, SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, 100, user_data);
1465 int system_setting_unset_changed_callback_locale_language(system_settings_key_e key)
1467 SETTING_TRACE_BEGIN;
1468 return system_setting_vconf_unset_changed_cb(VCONFKEY_LANGSET, 100);
1471 /*--------------------------------------- */
1472 /* LCOV_EXCL_START */
1473 int system_setting_get_locale_timeformat_24hour(system_settings_key_e key, void **value)
1475 SETTING_TRACE_BEGIN;
1478 if (system_setting_vconf_get_value_int(VCONFKEY_REGIONFORMAT_TIME1224, &vconf_value)) {
1479 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1482 bool ret_value = true;
1483 if (vconf_value == VCONFKEY_TIME_FORMAT_12)
1485 else if (vconf_value == VCONFKEY_TIME_FORMAT_24)
1488 *value = (void *)ret_value;
1490 return SYSTEM_SETTINGS_ERROR_NONE;
1492 /* LCOV_EXCL_STOP */
1494 int system_setting_set_locale_timeformat_24hour(system_settings_key_e key, void *value)
1496 SETTING_TRACE_BEGIN;
1499 vconf_value = (bool *)value;
1502 if (system_setting_vconf_set_value_int(VCONFKEY_REGIONFORMAT_TIME1224, VCONFKEY_TIME_FORMAT_24)) {
1503 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1507 if (system_setting_vconf_set_value_int(VCONFKEY_REGIONFORMAT_TIME1224, VCONFKEY_TIME_FORMAT_12)) {
1508 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1513 return SYSTEM_SETTINGS_ERROR_NONE;
1516 int system_setting_set_changed_callback_locale_timeformat_24hour(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1518 SETTING_TRACE_BEGIN;
1519 return system_setting_vconf_set_changed_cb(VCONFKEY_REGIONFORMAT_TIME1224, SYSTEM_SETTINGS_KEY_LOCALE_TIMEFORMAT_24HOUR, 3, user_data);
1522 int system_setting_unset_changed_callback_locale_timeformat_24hour(system_settings_key_e key)
1524 SETTING_TRACE_BEGIN;
1525 return system_setting_vconf_unset_changed_cb(VCONFKEY_REGIONFORMAT_TIME1224, 3);
1528 int system_setting_get_locale_timezone(system_settings_key_e key, void **value)
1531 ssize_t len = readlink(SETTING_TZONE_SYMLINK_PATH, tzpath, sizeof(tzpath)-1);
1535 SETTING_TRACE("parse error for SETTING_TZONE_SYMLINK_PATH");
1536 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1539 SETTING_TRACE("tzpath : %s ", &tzpath[20]);
1540 *value = strdup(&tzpath[20]);
1541 return SYSTEM_SETTINGS_ERROR_NONE;
1544 /* LCOV_EXCL_START */
1545 int system_setting_set_locale_timezone(system_settings_key_e key, void *value)
1547 SETTING_TRACE_BEGIN;
1548 char *timezone_value = NULL;
1549 timezone_value = (char *)value;
1552 snprintf(tz_path, 1024, "/usr/share/zoneinfo/%s", timezone_value);
1554 int is_load = _is_file_accessible(tz_path);
1556 alarmmgr_set_timezone(tz_path);
1558 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_TIMEZONE_ID, timezone_value)) {
1559 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1561 return SYSTEM_SETTINGS_ERROR_NONE;
1563 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
1565 /* LCOV_EXCL_STOP */
1569 /* LCOV_EXCL_START */
1570 int system_setting_set_changed_callback_locale_timezone(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1572 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_TIMEZONE_ID, SYSTEM_SETTINGS_KEY_LOCALE_TIMEZONE, 4, user_data);
1574 /* LCOV_EXCL_STOP */
1576 /* LCOV_EXCL_START */
1577 int system_setting_unset_changed_callback_locale_timezone(system_settings_key_e key)
1579 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_TIMEZONE_ID, 4);
1581 /* LCOV_EXCL_STOP */
1583 /* LCOV_EXCL_START */
1584 int system_setting_set_changed_callback_locale_timezone_changed(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1586 SETTING_TRACE_BEGIN;
1587 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
1589 /* LCOV_EXCL_STOP */
1591 /* LCOV_EXCL_START */
1592 int system_setting_unset_changed_callback_locale_timezone_changed(system_settings_key_e key)
1594 SETTING_TRACE_BEGIN;
1595 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
1597 /* LCOV_EXCL_STOP */
1600 /* LCOV_EXCL_START */
1601 int system_setting_get_time_changed(system_settings_key_e key, void **value)
1603 SETTING_TRACE_BEGIN;
1605 int ** val = (int**)value;
1606 cur_tick = time(NULL);
1608 /* struct tm * localtime = time (cur_tick); */
1609 /* printf("%s\n", ctime(&cur_tick); */
1610 return SYSTEM_SETTINGS_ERROR_NONE;
1613 /* LCOV_EXCL_STOP */
1615 int system_setting_set_changed_callback_time_changed(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1617 SETTING_TRACE_BEGIN;
1618 return system_setting_vconf_set_changed_cb(VCONFKEY_SYSTEM_TIME_CHANGED, SYSTEM_SETTINGS_KEY_TIME_CHANGED, 3, user_data);
1621 int system_setting_unset_changed_callback_time_changed(system_settings_key_e key)
1623 SETTING_TRACE_BEGIN;
1624 return system_setting_vconf_unset_changed_cb(VCONFKEY_SYSTEM_TIME_CHANGED, 3);
1629 /* SYSTEM_SETTINGS_KEY_SOUND_LOCK */
1630 int system_setting_get_sound_lock(system_settings_key_e key, void **value)
1632 SETTING_TRACE_BEGIN;
1635 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_SOUND_LOCK_BOOL, &vconf_value)) {
1636 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1638 *value = (void *)vconf_value;
1640 return SYSTEM_SETTINGS_ERROR_NONE;
1643 int system_setting_set_changed_callback_sound_lock(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1645 SETTING_TRACE_BEGIN;
1646 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_SOUND_LOCK_BOOL, SYSTEM_SETTINGS_KEY_SOUND_LOCK, 3, user_data);
1649 int system_setting_unset_changed_callback_sound_lock(system_settings_key_e key)
1651 SETTING_TRACE_BEGIN;
1652 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_SOUND_LOCK_BOOL, 3);
1656 * a = VCONFKEY_SETAPPL_SOUND_STATUS_BOOL b = VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL
1658 * a == false, b == false --> silent mode
1659 * a == true, b == false --> sound mode
1660 * a == false, b == true --> vibration mode
1662 /* LCOV_EXCL_START */
1663 int system_setting_get_sound_silent_mode(system_settings_key_e key, void **value)
1665 SETTING_TRACE_BEGIN;
1670 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, &sound_cond)) {
1671 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1674 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, &vib_cond)) {
1675 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1678 if (sound_cond == false && vib_cond == false) {
1680 *value = (void *)vconf_value;
1682 vconf_value = false;
1683 *value = (void *)vconf_value;
1685 return SYSTEM_SETTINGS_ERROR_NONE;
1687 /* LCOV_EXCL_STOP */
1690 * a = VCONFKEY_SETAPPL_SOUND_STATUS_BOOL b = VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL
1692 * a == false, b == false --> silent mode
1693 * a == true, b == false --> sound mode
1695 int system_setting_set_sound_silent_mode(system_settings_key_e key, void *value)
1697 SETTING_TRACE_BEGIN;
1700 vconf_value = (bool *)value;
1702 bool vconf_sound = false;
1703 bool vconf_vib = false;
1706 vconf_sound = false;
1713 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, vconf_sound)) {
1714 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1716 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, vconf_vib)) {
1717 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1720 return SYSTEM_SETTINGS_ERROR_NONE;
1726 int system_setting_set_changed_callback_sound_silent_mode(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1728 SETTING_TRACE_BEGIN;
1729 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, SYSTEM_SETTINGS_KEY_SOUND_SILENT_MODE, 3, user_data);
1733 int system_setting_unset_changed_callback_sound_silent_mode(system_settings_key_e key)
1735 SETTING_TRACE_BEGIN;
1736 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, 3);
1739 /* SYSTEM_SETTINGS_KEY_SOUND_TOUCH */
1740 int system_setting_get_sound_touch(system_settings_key_e key, void **value)
1742 SETTING_TRACE_BEGIN;
1745 int ret = system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL, &vconf_value);
1746 if (ret != SYSTEM_SETTINGS_ERROR_NONE) {
1749 *value = (void *)vconf_value;
1753 int system_setting_set_sound_touch(system_settings_key_e key, void *value)
1755 SETTING_TRACE_BEGIN;
1756 return system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL, *(bool *)value);
1760 int system_setting_set_changed_callback_sound_touch(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1762 SETTING_TRACE_BEGIN;
1763 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL, SYSTEM_SETTINGS_KEY_SOUND_TOUCH, 2, user_data);
1766 int system_setting_unset_changed_callback_sound_touch(system_settings_key_e key)
1768 SETTING_TRACE_BEGIN;
1769 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL, 2);
1773 /* SYSTEM_SETTINGS_KEY_SOUND_LOCK */
1774 int system_setting_get_sound_lock(system_settings_key_e key, void **value)
1778 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_SOUND_LOCK_BOOL, &vconf_value)) {
1779 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1781 *value = (void *)vconf_value;
1783 return SYSTEM_SETTINGS_ERROR_NONE;
1787 int system_setting_get_auto_rotation_mode(system_settings_key_e key, void **value)
1789 SETTING_TRACE_BEGIN;
1792 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, &vconf_value)) {
1793 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1795 *value = (void *)vconf_value;
1797 return SYSTEM_SETTINGS_ERROR_NONE;
1800 /* LCOV_EXCL_START */
1801 int system_setting_set_auto_rotation_mode(system_settings_key_e key, void *value)
1803 SETTING_TRACE_BEGIN;
1805 vconf_value = (bool *)value;
1806 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, *vconf_value)) {
1807 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1810 return SYSTEM_SETTINGS_ERROR_NONE;
1812 /* LCOV_EXCL_STOP */
1814 int system_setting_set_changed_callback_auto_rotation_mode(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1816 SETTING_TRACE_BEGIN;
1817 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, SYSTEM_SETTINGS_KEY_DISPLAY_SCREEN_ROTATION_AUTO, 2, user_data);
1820 int system_setting_unset_changed_callback_auto_rotation_mode(system_settings_key_e key)
1822 SETTING_TRACE_BEGIN;
1823 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, 2);
1826 int system_setting_get_screen_backlight_time(system_settings_key_e key, void **value)
1828 SETTING_TRACE_BEGIN;
1830 int ** val = (int**)value;
1832 if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, &vconf_value)) {
1833 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1835 **val = vconf_value;
1837 return SYSTEM_SETTINGS_ERROR_NONE;
1841 /* LCOV_EXCL_START */
1842 int system_setting_set_screen_backlight_time(system_settings_key_e key, void *value)
1844 SETTING_TRACE_BEGIN;
1846 vconf_value = *(int **)value;
1848 if (!(*vconf_value > 0 && *vconf_value <= 600)) {
1849 SETTING_TRACE(" ERR Betweeny here 0 ~ 600");
1850 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
1853 if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, *vconf_value)) {
1854 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1857 return SYSTEM_SETTINGS_ERROR_NONE;
1859 /* LCOV_EXCL_STOP */
1861 int system_setting_set_changed_callback_screen_backlight_time(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1863 SETTING_TRACE_BEGIN;
1864 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, SYSTEM_SETTINGS_KEY_SCREEN_BACKLIGHT_TIME, 2, user_data);
1867 int system_setting_unset_changed_callback_screen_backlight_time(system_settings_key_e key)
1869 SETTING_TRACE_BEGIN;
1870 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, 2);
1873 int system_setting_get_sound_notification(system_settings_key_e key, void **value)
1875 SETTING_TRACE_BEGIN;
1876 char *vconf_value = NULL;
1877 if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, &vconf_value)) {
1878 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1881 *value = vconf_value;
1882 return SYSTEM_SETTINGS_ERROR_NONE;
1885 /* LCOV_EXCL_START */
1886 int system_setting_set_sound_notification(system_settings_key_e key, void *value)
1888 SETTING_TRACE_BEGIN;
1889 char *vconf_value = NULL;
1890 vconf_value = (char *)value;
1892 int is_load = _is_file_accessible(vconf_value);
1894 //SETTING_TRACE(" system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, %s) TRY", vconf_value);
1895 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, vconf_value)) {
1896 //SETTING_TRACE(" system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, %s) FAIL", vconf_value);
1897 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1900 //SETTING_TRACE(" is_file_accessibile FAILED - system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, %s) FAIL", vconf_value);
1901 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1904 return SYSTEM_SETTINGS_ERROR_NONE;
1906 /* LCOV_EXCL_STOP */
1908 int system_setting_set_changed_callback_sound_notification(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1910 SETTING_TRACE_BEGIN;
1911 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, SYSTEM_SETTINGS_KEY_SOUND_NOTIFICATION, 0, user_data);
1914 int system_setting_unset_changed_callback_sound_notification(system_settings_key_e key)
1916 SETTING_TRACE_BEGIN;
1917 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, 0);
1920 int system_setting_get_notification_repetition_period(system_settings_key_e key, void **value)
1922 SETTING_TRACE_BEGIN;
1923 int ** val = (int**)value;
1926 if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_NOTI_MSG_ALERT_REP_TYPE_INT, &vconf_value)) {
1927 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1929 **val = vconf_value;
1931 return SYSTEM_SETTINGS_ERROR_NONE;
1934 /* LCOV_EXCL_START */
1935 int system_setting_set_notification_repetition_period(system_settings_key_e key, void *value)
1937 SETTING_TRACE_BEGIN;
1939 vconf_value = *(int **)value;
1941 if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_NOTI_MSG_ALERT_REP_TYPE_INT, *vconf_value)) {
1942 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1945 return SYSTEM_SETTINGS_ERROR_NONE;
1947 /* LCOV_EXCL_STOP */
1949 int system_setting_set_changed_callback_notification_repetition_period(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1951 SETTING_TRACE_BEGIN;
1952 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);
1955 int system_setting_unset_changed_callback_notification_repetition_period(system_settings_key_e key)
1957 SETTING_TRACE_BEGIN;
1958 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_ALERT_REP_TYPE_INT, 1);
1961 int system_setting_get_device_name(system_settings_key_e key, void **value)
1963 SETTING_TRACE_BEGIN;
1964 char *vconf_value = NULL;
1965 if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_DEVICE_NAME_STR, &vconf_value)) {
1966 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1969 *value = vconf_value;
1970 return SYSTEM_SETTINGS_ERROR_NONE;
1973 /* LCOV_EXCL_START */
1974 int system_setting_set_device_name(system_settings_key_e key, void *value)
1976 SETTING_TRACE_BEGIN;
1977 char *vconf_value = NULL;
1978 vconf_value = (char *)value;
1980 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_DEVICE_NAME_STR, vconf_value)) {
1981 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1984 return SYSTEM_SETTINGS_ERROR_NONE;
1986 /* LCOV_EXCL_STOP */
1988 int system_setting_set_changed_callback_device_name(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1990 SETTING_TRACE_BEGIN;
1991 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_DEVICE_NAME_STR, SYSTEM_SETTINGS_KEY_DEVICE_NAME, 0, user_data);
1994 int system_setting_unset_changed_callback_device_name(system_settings_key_e key)
1996 SETTING_TRACE_BEGIN;
1997 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_DEVICE_NAME_STR, 0);
2000 /*---------------------------------------------- */
2001 int system_setting_get_network_flight_mode(system_settings_key_e key, void **value)
2003 SETTING_TRACE_BEGIN;
2005 if (system_setting_vconf_get_value_bool(VCONFKEY_TELEPHONY_FLIGHT_MODE, &vconf_value)) {
2006 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2008 *value = (void *)vconf_value;
2010 return SYSTEM_SETTINGS_ERROR_NONE;
2013 int system_setting_set_changed_callback_network_flight_mode(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
2015 SETTING_TRACE_BEGIN;
2016 return system_setting_vconf_set_changed_cb(VCONFKEY_TELEPHONY_FLIGHT_MODE, SYSTEM_SETTINGS_KEY_NETWORK_FLIGHT_MODE, 3, user_data);
2019 int system_setting_unset_changed_callback_network_flight_mode(system_settings_key_e key)
2021 SETTING_TRACE_BEGIN;
2022 return system_setting_vconf_unset_changed_cb(VCONFKEY_TELEPHONY_FLIGHT_MODE, 3);
2025 int system_setting_get_network_wifi_notification(system_settings_key_e key, void **value)
2027 SETTING_TRACE_BEGIN;
2029 if (system_setting_vconf_get_value_int(VCONFKEY_WIFI_ENABLE_QS, &vconf_value)) {
2030 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2033 bret = (vconf_value == VCONFKEY_WIFI_QS_ENABLE) ? true : false;
2035 *value = (void *)bret;
2036 return SYSTEM_SETTINGS_ERROR_NONE;
2039 int system_setting_set_changed_callback_network_wifi_notification(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
2041 SETTING_TRACE_BEGIN;
2042 return system_setting_vconf_set_changed_cb(VCONFKEY_WIFI_ENABLE_QS, SYSTEM_SETTINGS_KEY_NETWORK_WIFI_NOTIFICATION, 4, user_data);
2045 int system_setting_unset_changed_callback_network_wifi_notification(system_settings_key_e key)
2047 SETTING_TRACE_BEGIN;
2048 return system_setting_vconf_unset_changed_cb(VCONFKEY_WIFI_ENABLE_QS, 4);
2051 /* LCOV_EXCL_START */
2052 int system_setting_get_lock_state(system_settings_key_e key, void **value)
2055 int ** val = (int**)value;
2057 if (system_setting_vconf_get_value_int(VCONFKEY_IDLE_LOCK_STATE_READ_ONLY, &vconf_value)) {
2058 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2060 **val = vconf_value;
2062 return SYSTEM_SETTINGS_ERROR_NONE;
2064 /* LCOV_EXCL_STOP */
2066 /* LCOV_EXCL_START */
2067 int system_setting_set_lock_state(system_settings_key_e key, void *value)
2069 SETTING_TRACE_BEGIN;
2071 vconf_value = *(int **)value;
2073 if (system_setting_vconf_set_value_int(VCONFKEY_IDLE_LOCK_STATE_READ_ONLY, *vconf_value)) {
2074 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2077 return SYSTEM_SETTINGS_ERROR_NONE;
2079 /* LCOV_EXCL_STOP */
2081 /* LCOV_EXCL_START */
2082 int system_setting_set_changed_callback_lock_state(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
2084 return system_setting_vconf_set_changed_cb(VCONFKEY_IDLE_LOCK_STATE_READ_ONLY, SYSTEM_SETTINGS_KEY_LOCK_STATE, 4, user_data);
2086 /* LCOV_EXCL_STOP */
2088 /* LCOV_EXCL_START */
2089 int system_setting_unset_changed_callback_lock_state(system_settings_key_e key)
2091 return system_setting_vconf_unset_changed_cb(VCONFKEY_IDLE_LOCK_STATE_READ_ONLY, 4);
2093 /* LCOV_EXCL_STOP */
2095 //----------------------------------------------------------------------------------------------------------------------------
2097 #define DEFAULT_ADS_ID "00000000-0000-0000-0000-000000000000"
2099 int system_setting_get_ads_id(system_settings_key_e key, void **value)
2101 SETTING_TRACE_BEGIN;
2102 int optout_value = 0;
2103 if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_AD_ID_OPT_OUT, &optout_value)) {
2104 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2107 if (optout_value == 1) {
2108 *value = strdup(DEFAULT_ADS_ID);
2109 return SYSTEM_SETTINGS_ERROR_NONE;
2112 char *vconf_value = NULL;
2113 if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_AD_ID, &vconf_value)) {
2114 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2117 *value = vconf_value;
2118 return SYSTEM_SETTINGS_ERROR_NONE;
2123 void make_ad_id(void)
2126 char uuid_unparsed[50] = {0};
2127 uuid_generate(uuid_value);
2128 uuid_unparse(uuid_value, uuid_unparsed);
2129 system_setting_set_ad_id(key, uuid_unparsed); //example of setting the value
2132 int system_setting_set_ads_id(system_settings_key_e key, void *value)
2134 SETTING_TRACE_BEGIN;
2135 char *vconf_value = NULL;
2136 vconf_value = (char *)value;
2138 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_AD_ID, vconf_value)) {
2139 SETTING_TRACE("Setting VCONFKEY_SETAPPL_AD_ID failed");
2140 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2143 return SYSTEM_SETTINGS_ERROR_NONE;
2146 int system_setting_set_changed_callback_ads_id(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
2148 SETTING_TRACE_BEGIN;
2149 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_AD_ID, SYSTEM_SETTINGS_KEY_ADS_ID, 0, user_data);
2152 int system_setting_unset_changed_callback_ads_id(system_settings_key_e key)
2154 SETTING_TRACE_BEGIN;
2155 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_AD_ID, 0);
2158 int system_settings_feature_check_bool(char *path)
2160 bool feature_data = false;
2161 int ret = system_info_get_platform_bool(path, &feature_data);
2162 if (ret != SYSTEM_INFO_ERROR_NONE) {
2163 SETTING_TRACE("Setting - reading feature data failed, %d", ret);
2164 return SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED;
2167 ret = (feature_data == true) ? SYSTEM_SETTINGS_ERROR_NONE : SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED;
2173 int system_setting_feature_check_incoming_call(void *value)
2175 static bool first_query = true;
2176 static int ret = SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED;
2178 if (first_query == true) {
2179 ret = system_settings_feature_check_bool(SETTING_INCOMING_CALL_PATH);
2180 first_query = false;
2186 int system_setting_feature_check_home_screen(void *value)
2188 static bool first_query = true;
2189 static int ret = SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED;
2191 if (first_query == true) {
2192 ret = system_settings_feature_check_bool(SETTING_HOME_SCREEN_PATH);
2193 first_query = false;
2199 int system_setting_feature_check_lock_screen(void *value)
2201 static bool first_query = true;
2202 static int ret = SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED;
2204 if (first_query == true) {
2205 ret = system_settings_feature_check_bool(SETTING_LOCK_SCREEN_PATH);
2206 first_query = false;
2212 int system_setting_feature_check_notification_email(void *value)
2214 static bool first_query = true;
2215 static int ret = SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED;
2217 if (first_query == true) {
2218 ret = system_settings_feature_check_bool(SETTING_NOTIFICATION_EMAIL_PATH);
2219 first_query = false;
2225 int system_setting_feature_check_wifi(void *value)
2227 static bool first_query = true;
2228 static int ret = SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED;
2230 if (first_query == true) {
2231 ret = system_settings_feature_check_bool(SETTING_WIFI_PATH);
2232 first_query = false;
2238 int system_setting_feature_check_telephony(void *value)
2240 static bool first_query = true;
2241 static int ret = SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED;
2243 if (first_query == true) {
2244 ret = system_settings_feature_check_bool(SETTING_TELEPHONY_PATH);
2245 first_query = false;
2252 int system_setting_feature_check_font(void *value)
2254 static bool first_query = true;
2255 static int ret = SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED;
2257 if (first_query == true) {
2258 ret = system_settings_feature_check_bool(SETTING_FONT_PATH);
2259 first_query = false;
2265 int system_setting_feature_check_accessibility_grayscale(void *value)
2267 static bool first_query = true;
2268 static int ret = SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED;
2270 if (first_query == true) {
2271 ret = system_settings_feature_check_bool(SETTING_ACCESSIBILITY_GRAYSCALE_PATH);
2272 first_query = false;
2278 int system_setting_feature_check_accessibility_negative(void *value)
2280 static bool first_query = true;
2281 static int ret = SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED;
2283 if (first_query == true) {
2284 ret = system_settings_feature_check_bool(SETTING_ACCESSIBILITY_NEGATIVE_PATH);
2285 first_query = false;
2291 int system_setting_feature_check_wearable_profile(void *value)
2293 static bool first_query = true;
2294 static int ret = SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED;
2296 if (first_query == true) {
2297 char *profile_data = NULL;
2298 int rotary_feature = SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED;
2299 ret = system_info_get_platform_string(SETTING_PROFILE_PATH, &profile_data);
2300 if (ret != SYSTEM_INFO_ERROR_NONE) {
2301 SETTING_TRACE("Setting - reading profile string failed, %d", ret);
2302 return SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED;
2305 rotary_feature = system_settings_feature_check_bool(SETTING_INPUT_ROTATING_BEZEL_PATH);
2307 if ((rotary_feature == SYSTEM_SETTINGS_ERROR_NONE) && profile_data && !strcmp(profile_data, "wearable"))
2308 ret = SYSTEM_SETTINGS_ERROR_NONE;
2310 ret = SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED;
2315 first_query = false;
2321 /* LCOV_EXCL_START */
2322 int system_setting_get_uds_state(system_settings_key_e key, void **value)
2324 int ** p_value = (int**)value;
2326 char *vconf_string_value = NULL;
2328 if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_UDSM, &vconf_value)) {
2329 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2332 SETTING_TRACE("[%s] udsm: %d", __FUNCTION__, vconf_value);
2334 if (vconf_value == SYSTEM_SETTINGS_UDS_ON) {
2335 if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_UDSM_PKGID_LIST, &vconf_string_value))
2336 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2338 if (vconf_string_value) {
2339 if (!strcmp(vconf_string_value, "NONE")) {
2340 vconf_value = SYSTEM_SETTINGS_UDS_ON;
2342 char *app_id = NULL;
2343 char *package_id = NULL;
2344 pid_t pid = getpid();
2346 int ret = app_manager_get_app_id(pid, &app_id);
2347 if (ret != APP_MANAGER_ERROR_NONE) {
2348 free(vconf_string_value);
2349 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2354 result = package_manager_get_package_id_by_app_id(app_id, &package_id);
2355 if (result != PACKAGE_MANAGER_ERROR_NONE) {
2356 SETTING_TRACE("package_manager_get_package_id_by_app_id returned error! %d", result);
2357 free(vconf_string_value);
2358 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2361 SETTING_TRACE("[%s] udsm_pkg_list : %s", __FUNCTION__, vconf_string_value);
2364 if (package_id && strstr(vconf_string_value, package_id)) {
2365 vconf_value = SYSTEM_SETTINGS_UDS_ON_WHITELISTED;
2366 SETTING_TRACE("[%s] pkg id : %s", __FUNCTION__, package_id);
2368 vconf_value = SYSTEM_SETTINGS_UDS_ON;
2372 free(vconf_string_value);
2376 **p_value = vconf_value;
2379 return SYSTEM_SETTINGS_ERROR_NONE;
2381 /* LCOV_EXCL_STOP */
2383 /* LCOV_EXCL_START */
2384 int system_setting_set_changed_callback_uds_state(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
2386 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_UDSM, SYSTEM_SETTINGS_KEY_ULTRA_DATA_SAVE, 4, user_data);
2388 /* LCOV_EXCL_STOP */
2390 /* LCOV_EXCL_START */
2391 int system_setting_unset_changed_callback_uds_state(system_settings_key_e key)
2393 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_UDSM, 4);
2395 /* LCOV_EXCL_STOP */
2397 /* LCOV_EXCL_START */
2398 int system_setting_set_changed_callback_uds_pkg_list(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
2400 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_UDSM_PKGID_LIST, SYSTEM_SETTINGS_KEY_ULTRA_DATA_SAVE_PKG_LIST, 4, user_data);
2402 /* LCOV_EXCL_STOP */
2404 /* LCOV_EXCL_START */
2405 int system_setting_unset_changed_callback_uds_pkg_list(system_settings_key_e key)
2407 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_UDSM_PKGID_LIST, 4);
2409 /* LCOV_EXCL_STOP */
2411 /* SYSTEM_SETTINGS_KEY_ACCESSIBILITY_TTS */
2412 int system_setting_get_accessibility_tts(system_settings_key_e key, void **value)
2414 SETTING_TRACE_BEGIN;
2417 int ret = system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_ACCESSIBILITY_TTS, &vconf_value);
2418 if (ret != SYSTEM_SETTINGS_ERROR_NONE) {
2421 *value = (void *)vconf_value;
2425 /* LCOV_EXCL_START */
2426 int system_setting_set_accessibility_tts(system_settings_key_e key, void *value)
2428 SETTING_TRACE_BEGIN;
2430 vconf_value = (bool *)value;
2431 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_ACCESSIBILITY_TTS, *vconf_value)) {
2432 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2435 return SYSTEM_SETTINGS_ERROR_NONE;
2437 /* LCOV_EXCL_STOP */
2439 int system_setting_set_changed_callback_accessibility_tts(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
2441 SETTING_TRACE_BEGIN;
2442 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_TTS, SYSTEM_SETTINGS_KEY_ACCESSIBILITY_TTS, 2, user_data);
2445 int system_setting_unset_changed_callback_accessibility_tts(system_settings_key_e key)
2447 SETTING_TRACE_BEGIN;
2448 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_TTS, 2);
2451 /* SYSTEM_SETTINGS_KEY_VIBRATION */
2452 int system_setting_get_vibration(system_settings_key_e key, void **value)
2454 SETTING_TRACE_BEGIN;
2457 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, &vconf_value)) {
2458 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2460 *value = (void *)vconf_value;
2462 return SYSTEM_SETTINGS_ERROR_NONE;
2465 /* LCOV_EXCL_START */
2466 int system_setting_set_vibration(system_settings_key_e key, void *value)
2468 SETTING_TRACE_BEGIN;
2470 vconf_value = (bool *)value;
2471 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, *vconf_value)) {
2472 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2475 return SYSTEM_SETTINGS_ERROR_NONE;
2477 /* LCOV_EXCL_STOP */
2479 int system_setting_set_changed_callback_vibration(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
2481 SETTING_TRACE_BEGIN;
2482 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, SYSTEM_SETTINGS_KEY_VIBRATION, 2, user_data);
2485 int system_setting_unset_changed_callback_vibration(system_settings_key_e key)
2487 SETTING_TRACE_BEGIN;
2488 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, 2);
2491 /* SYSTEM_SETTINGS_KEY_AUTOMATIC_TIME_UPDATE */
2492 int system_setting_get_automatic_time_update(system_settings_key_e key, void **value)
2494 SETTING_TRACE_BEGIN;
2497 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_STATE_AUTOMATIC_TIME_UPDATE_BOOL, &vconf_value)) {
2498 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2500 *value = (void *)vconf_value;
2502 return SYSTEM_SETTINGS_ERROR_NONE;
2505 /* LCOV_EXCL_START */
2506 int system_setting_set_automatic_time_update(system_settings_key_e key, void *value)
2508 SETTING_TRACE_BEGIN;
2510 vconf_value = (bool *)value;
2511 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_STATE_AUTOMATIC_TIME_UPDATE_BOOL, *vconf_value)) {
2512 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2515 return SYSTEM_SETTINGS_ERROR_NONE;
2517 /* LCOV_EXCL_STOP */
2519 int system_setting_set_changed_callback_automatic_time_update(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
2521 SETTING_TRACE_BEGIN;
2522 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_STATE_AUTOMATIC_TIME_UPDATE_BOOL, SYSTEM_SETTINGS_KEY_AUTOMATIC_TIME_UPDATE, 2, user_data);
2525 int system_setting_unset_changed_callback_automatic_time_update(system_settings_key_e key)
2527 SETTING_TRACE_BEGIN;
2528 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_STATE_AUTOMATIC_TIME_UPDATE_BOOL, 2);
2531 /* SYSTEM_SETTINGS_KEY_DEVELOPER_OPTION_STATE */
2532 int system_setting_get_developer_option_state(system_settings_key_e key, void **value)
2534 SETTING_TRACE_BEGIN;
2537 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_DEVELOPER_OPTION_STATE, &vconf_value)) {
2538 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2540 *value = (void *)vconf_value;
2542 return SYSTEM_SETTINGS_ERROR_NONE;
2545 /* LCOV_EXCL_START */
2546 int system_setting_set_developer_option_state(system_settings_key_e key, void *value)
2548 SETTING_TRACE_BEGIN;
2550 vconf_value = (bool *)value;
2551 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_DEVELOPER_OPTION_STATE, *vconf_value)) {
2552 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2555 return SYSTEM_SETTINGS_ERROR_NONE;
2557 /* LCOV_EXCL_STOP */
2559 int system_setting_set_changed_callback_developer_option_state(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
2561 SETTING_TRACE_BEGIN;
2562 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_DEVELOPER_OPTION_STATE, SYSTEM_SETTINGS_KEY_DEVELOPER_OPTION_STATE, 2, user_data);
2565 int system_setting_unset_changed_callback_developer_option_state(system_settings_key_e key)
2567 SETTING_TRACE_BEGIN;
2568 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_DEVELOPER_OPTION_STATE, 2);
2571 /* SYSTEM_SETTINGS_KEY_ACCESSIBILITY_GRAYSCALE */
2572 int system_setting_get_accessibility_grayscale(system_settings_key_e key, void **value)
2574 SETTING_TRACE_BEGIN;
2577 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_ACCESSIBILITY_GREYSCALE, &vconf_value)) {
2578 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2580 *value = (void *)vconf_value;
2582 return SYSTEM_SETTINGS_ERROR_NONE;
2585 /* LCOV_EXCL_START */
2586 int system_setting_set_accessibility_grayscale(system_settings_key_e key, void *value)
2588 SETTING_TRACE_BEGIN;
2590 vconf_value = (bool *)value;
2591 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_ACCESSIBILITY_GREYSCALE, *vconf_value)) {
2592 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2595 return SYSTEM_SETTINGS_ERROR_NONE;
2597 /* LCOV_EXCL_STOP */
2599 int system_setting_set_changed_callback_accessibility_grayscale(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
2601 SETTING_TRACE_BEGIN;
2602 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_GREYSCALE, SYSTEM_SETTINGS_KEY_ACCESSIBILITY_GRAYSCALE, 2, user_data);
2605 int system_setting_unset_changed_callback_accessibility_grayscale(system_settings_key_e key)
2607 SETTING_TRACE_BEGIN;
2608 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_GREYSCALE, 2);
2611 /* SYSTEM_SETTINGS_KEY_ACCESSIBILITY_NEGATIVE_COLOR */
2612 int system_setting_get_accessibility_negative_color(system_settings_key_e key, void **value)
2614 SETTING_TRACE_BEGIN;
2617 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_ACCESSIBILITY_HIGH_CONTRAST, &vconf_value)) {
2618 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2620 *value = (void *)vconf_value;
2622 return SYSTEM_SETTINGS_ERROR_NONE;
2625 /* LCOV_EXCL_START */
2626 int system_setting_set_accessibility_negative_color(system_settings_key_e key, void *value)
2628 SETTING_TRACE_BEGIN;
2630 vconf_value = (bool *)value;
2631 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_ACCESSIBILITY_HIGH_CONTRAST, *vconf_value)) {
2632 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2635 return SYSTEM_SETTINGS_ERROR_NONE;
2637 /* LCOV_EXCL_STOP */
2639 int system_setting_set_changed_callback_accessibility_negative_color(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
2641 SETTING_TRACE_BEGIN;
2642 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_HIGH_CONTRAST, SYSTEM_SETTINGS_KEY_ACCESSIBILITY_NEGATIVE_COLOR, 2, user_data);
2645 int system_setting_unset_changed_callback_accessibility_negative_color(system_settings_key_e key)
2647 SETTING_TRACE_BEGIN;
2648 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_HIGH_CONTRAST, 2);
2651 /* SYSTEM_SETTINGS_KEY_ROTARY_EVENT_ENABLED */
2652 /* LCOV_EXCL_START */
2653 int system_setting_get_rotary_event_enabled(system_settings_key_e key, void **value)
2655 SETTING_TRACE_BEGIN;
2658 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_ROTARY_EVENT_ENABLED_BOOL, &vconf_value)) {
2659 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2661 *value = (void *)vconf_value;
2663 return SYSTEM_SETTINGS_ERROR_NONE;
2665 /* LCOV_EXCL_STOP */
2667 /* LCOV_EXCL_START */
2668 int system_setting_set_rotary_event_enabled(system_settings_key_e key, void *value)
2670 SETTING_TRACE_BEGIN;
2672 vconf_value = (bool *)value;
2673 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_ROTARY_EVENT_ENABLED_BOOL, *vconf_value)) {
2674 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2677 return SYSTEM_SETTINGS_ERROR_NONE;
2679 /* LCOV_EXCL_STOP */
2681 /* LCOV_EXCL_START */
2682 int system_setting_set_changed_callback_rotary_event_enabled(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
2684 SETTING_TRACE_BEGIN;
2685 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_ROTARY_EVENT_ENABLED_BOOL, SYSTEM_SETTINGS_KEY_ROTARY_EVENT_ENABLED, 3, user_data);
2687 /* LCOV_EXCL_STOP */
2689 /* LCOV_EXCL_START */
2690 int system_setting_unset_changed_callback_rotary_event_enabled(system_settings_key_e key)
2692 SETTING_TRACE_BEGIN;
2693 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_ROTARY_EVENT_ENABLED_BOOL, 3);
2695 /* LCOV_EXCL_STOP */