2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
25 #include <sys/types.h>
36 #include <libxml/xmlmemory.h>
37 #include <libxml/parser.h>
39 #include <fontconfig/fontconfig.h>
41 #include <pkgmgr-info.h>
42 #include <package_manager.h>
43 #include <app_manager.h>
45 #include <system_settings.h>
46 #include <system_settings_private.h>
47 #include <system_settings_ringtones.h>
48 #include <system_settings_json.h>
50 #include <system-setting-config.h>
52 #include <tzplatform_config.h>
55 #include <system_info.h>
57 #define SETTING_FONT_CONF_FILE _TZ_SYS_ETC"/fonts/conf.avail/99-tizen.conf"
58 #define SETTING_DEFAULT_FONT_CONF_FILE _TZ_SYS_ETC"/fonts/conf.avail/99-tizen.conf"
60 #define SETTING_TIME_ZONEINFO_PATH "/usr/share/zoneinfo/"
61 #define SETTING_TIME_SHARE_LOCAL_PATH "/usr/share/locale"
62 #define SETTING_TZONE_SYMLINK_PATH "/opt/etc/localtime"
65 #define __FREE(del, arg) do { \
67 del((void *)(arg)); /*cast any argument to (void*) to avoid build warring*/\
71 #define FREE(arg) __FREE(free, arg)
73 #ifdef SETTING_ARCH_64
74 #define SETTING_UTILS_SO_FILE_PATH "/usr/lib64/libsystem-settings-util.so.0.1.0"
76 #define SETTING_UTILS_SO_FILE_PATH "/usr/lib/libsystem-settings-util.so.0.1.0"
79 int _is_file_accessible(const char *path);
81 static bool dl_is_supported_image_type_load(char *path);
82 static bool dl_font_config_set(char *font_name);
83 static char *dl_get_default_font_info();
84 static int dl_is_available_font(char *str);
85 static void dl_font_size_set();
86 static void dl_font_config_set_notification();
89 #ifndef VCONFKEY_SETAPPL_UDSM
90 #define VCONFKEY_SETAPPL_UDSM "db/setting/udsm"
93 #ifndef VCONFKEY_SETAPPL_UDSM_PKGID_LIST
94 #define VCONFKEY_SETAPPL_UDSM_PKGID_LIST "db/setting/udsm/pkgid_list"
99 * VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR has a path of the ringtone file which user choose
100 * @return the ringtone file path specified by user in normal case
101 * if it's not accessable, return the default ringtone path
103 int system_setting_get_incoming_call_ringtone(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
107 if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR, &vconf_value)) {
108 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
111 /* check to see if it's accessable -> OK */
112 /* no --> default ringtone path VCONFKEY_SETAPPL_CALL_RINGTONE_DEFAULT_PATH_STR */
113 int is_load = _is_file_accessible(vconf_value);
115 *value = vconf_value;
116 } else { /* not zero on errro */
117 *value = vconf_get_str(VCONFKEY_SETAPPL_CALL_RINGTONE_DEFAULT_PATH_STR);
120 /**value = vconf_value; */
121 return SYSTEM_SETTINGS_ERROR_NONE;
125 int system_setting_get_email_alert_ringtone(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
129 if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, &vconf_value)) {
130 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
133 /* check to see if it's accessable -> OK */
134 /* no --> default ringtone path VCONFKEY_SETAPPL_NOTI_RINGTONE_DEFAULT_PATH_STR */
135 int is_load = _is_file_accessible(vconf_value);
137 *value = vconf_value;
138 } else { /* not zero on errro */
139 *value = vconf_get_str(VCONFKEY_SETAPPL_NOTI_RINGTONE_DEFAULT_PATH_STR);
142 return SYSTEM_SETTINGS_ERROR_NONE;
146 int system_setting_get_wallpaper_home_screen(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
150 if (system_setting_vconf_get_value_string(VCONFKEY_BGSET, &vconf_value)) {
151 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
153 *value = vconf_value;
154 return SYSTEM_SETTINGS_ERROR_NONE;
158 int system_setting_get_wallpaper_lock_screen(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
163 if (system_setting_vconf_get_value_string(VCONFKEY_IDLE_LOCK_BGSET, &vconf_value)) {
164 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
166 *value = vconf_value;
168 return SYSTEM_SETTINGS_ERROR_NONE;
172 /* [int] vconf GET */
173 int system_setting_get_font_size(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
177 int ** val = (int**)value;
179 if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, &vconf_value)) {
180 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
184 return SYSTEM_SETTINGS_ERROR_NONE;
188 int system_setting_get_default_font_type(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
191 char *font_name = dl_get_default_font_info();
193 *value = (void *)font_name;
194 return SYSTEM_SETTINGS_ERROR_NONE;
196 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
200 /* [int] vconf GET */
201 int system_setting_get_font_type(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
204 char *font_name = NULL;
206 if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, &font_name)) {
207 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
211 return SYSTEM_SETTINGS_ERROR_NONE;
215 int system_setting_get_motion_activation(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
220 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_MOTION_ACTIVATION, &vconf_value)) {
221 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
223 *value = (void *)vconf_value;
225 return SYSTEM_SETTINGS_ERROR_NONE;
228 int system_setting_get_usb_debugging_option(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
233 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_USB_DEBUG_MODE_BOOL, &vconf_value)) {
234 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
236 *value = (void *)vconf_value;
238 return SYSTEM_SETTINGS_ERROR_NONE;
241 int system_setting_get_3g_data_network(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
246 if (system_setting_vconf_get_value_bool(VCONFKEY_3G_ENABLE, &vconf_value)) {
247 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
249 *value = (void *)vconf_value;
251 return SYSTEM_SETTINGS_ERROR_NONE;
253 /*////////////////////////////////////////////////////////////////////////////////////////////////// */
257 * get current lock scren app package name (string)
259 * @return SYSTEM_SETTINGS_ERROR_LOCKSCREEN_APP_PASSWORD_MODE raise exception if current lock type is 'password'
261 int system_setting_get_lockscreen_app(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
264 char *pkg_name = NULL;
266 system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_SCREEN_LOCK_TYPE_INT, &locktype);
268 if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_3RD_LOCK_PKG_NAME_STR, &pkg_name)) {
269 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
272 if (pkg_name && strcmp(pkg_name, "com.samsung.lockscreen") == 0 && locktype == SETTING_SCREEN_LOCK_TYPE_PASSWORD) {
273 return SYSTEM_SETTINGS_ERROR_LOCKSCREEN_APP_PASSWORD_MODE;
277 return SYSTEM_SETTINGS_ERROR_NONE;
281 /*////////////////////////////////////////////////////////////////////////////////////////////////// */
283 int _is_file_accessible(const char *path)
286 int ret = access(path , R_OK);
288 SETTING_TRACE("found the file %s", path);
291 /* error code : 13 */
292 SETTING_TRACE("found the file %s --- error code : %d ", path, errno);
299 /*////////////////////////////////////////////////////////////////////////////////////////////////// */
300 // @todo move to CMake
301 #define DEF_RINGTONE_FILE_PATH SETTING_DEF_RES"/Ringtones"
303 #define USR_RINGTONE_FILE_PATH "/home/owner/content/Sounds/Ringtones"
304 #define JSONFILE "/opt/home/owner/apps_rw/org.tizen.setting/data/.user-ringtones.json"
307 static char* _get_json_file_path()
314 int system_setting_add_incoming_call_ringtone(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
317 char* pathval = (char*)value;
321 JsonParser *parser = ss_json_ringtone_open_file(JSONFILE);
323 JsonParser *parser = ss_json_ringtone_load_from_data();
326 JsonNode *root = json_parser_get_root(parser);
330 int ret = SYSTEM_SETTINGS_ERROR_NONE;
331 if (false == ss_json_ringtone_contain(root, pathval)) {
332 SETTING_TRACE("---> dirname is : %s ", dirname(strdup(pathval)));
333 SETTING_TRACE("---> basename is : %s ", basename(strdup(pathval)));
334 // @todo : MAKE SURE THE ACTUAL FILE IS THERE ON PATHVAL(SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER)
335 ss_json_ringtone_add(root, JSONFILE, pathval, pathval);
336 SETTING_TRACE("pathval is : %s -- OK", pathval);
338 SETTING_TRACE("pathval is duplicated : %s", pathval);
339 SETTING_TRACE("---> dirname is : %s ", dirname(strdup(pathval)));
340 SETTING_TRACE("---> basename is : %s ", basename(strdup(pathval)));
341 ret = SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
345 g_object_unref(parser);
352 int system_setting_del_incoming_call_ringtone(system_settings_key_e key, system_setting_data_type_e data_type, 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 static int _compare_cb(const void *d1, const void *d2)
379 fileNodeInfo *pNode1 = (fileNodeInfo *)d1;
380 fileNodeInfo *pNode2 = (fileNodeInfo *)d2;
382 return strcmp(pNode1->media_name, pNode2->media_name);
386 * get the RINGTONE list
388 static void _get_default_ringtones(system_settings_key_e key, system_setting_data_type_e data_type, system_settings_iter_cb callback, void *data)
392 Eina_List *filelist = NULL;
394 fileNodeInfo *node = NULL;
397 //-----------------------------------------------------------------------------------------------------------------
398 // 1. get the default ringtone list
399 //-----------------------------------------------------------------------------------------------------------------
400 int ret = get_filelist_from_dir_path(DEF_RINGTONE_FILE_PATH, &filelist);
402 SETTING_TRACE("Failed to get filelist, ret = %d %s", ret, DEF_RINGTONE_FILE_PATH);
404 filelist = eina_list_sort(filelist, eina_list_count(filelist), _compare_cb);
406 EINA_LIST_FOREACH(filelist, l, node)
408 SETTING_TRACE("file path = (%d) : name:%s path:%s [%s]", ret, node->name, node->path, node->media_name);
409 // @todo assert NULL check
412 snprintf(temp, 1024, "%s/%s", node->path, node->name);
413 char* path = strdup(temp);
414 bool ret = callback(idx, (void *)(path), data);
420 SETTING_TRACE("quit the iteration by return value == false : %d", ret);
425 SETTING_TRACE("--> system_setting_data_iterator is NULL");
431 EINA_LIST_FOREACH(filelist, l, node)
435 FREE(node->media_name);
438 eina_list_free(filelist);
443 static void _get_user_ringtones(system_settings_key_e key, system_setting_data_type_e data_type, system_settings_iter_cb callback, void *data)
449 JsonParser* parser = ss_json_ringtone_open_file(JSONFILE);
451 JsonParser* parser = ss_json_ringtone_load_from_data();
454 JsonNode *root = json_parser_get_root(parser);
455 int size = json_array_get_length(json_node_get_array(root));
458 for (i = 0; i < size ; i++) {
459 JsonObject *ringtone = json_array_get_object_element(json_node_get_array(root), i);
460 char *nameval = (char *)json_object_get_string_member(ringtone, "name");
461 char *pathval = (char *)json_object_get_string_member(ringtone, "path");
462 SETTING_TRACE("(%s) --- (%s) \n", nameval, pathval);
464 char* path = strdup(pathval);
465 bool ret = callback(i, (void *)(path), data);
467 SETTING_TRACE("quit the iteration by return value == false : %d", ret);
471 SETTING_TRACE("--> callback is NULL");
476 int system_setting_list_incoming_call_ringtone(system_settings_key_e key, system_setting_data_type_e data_type, system_settings_iter_cb callback, void *data)
480 _get_default_ringtones(key, data_type, callback, data);
481 //-----------------------------------------------------------------------------------------------------------------
482 // 2. get the USER ringtone list
483 //-----------------------------------------------------------------------------------------------------------------
484 _get_user_ringtones(key, data_type, callback, data);
486 return SYSTEM_SETTINGS_ERROR_NONE;
490 /* LCOV_EXCL_START */
491 int system_setting_set_incoming_call_ringtone(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
495 vconf_value = (char *)value;
497 int ret = _is_file_accessible(vconf_value);
499 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR, vconf_value)) {
500 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
503 /* @todo add a common ret_handler */
507 return SYSTEM_SETTINGS_ERROR_NONE;
512 /* LCOV_EXCL_START */
513 int system_setting_set_email_alert_ringtone(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
517 vconf_value = (char *)value;
519 int ret = _is_file_accessible(vconf_value);
521 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, vconf_value)) {
522 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
525 /*return SYSTEM_SETTINGS_ERROR_IO_ERROR;*/
526 /* @todo add a common ret_handler */
530 return SYSTEM_SETTINGS_ERROR_NONE;
534 /* LCOV_EXCL_START */
535 static bool dl_is_supported_image_type_load(char *path)
540 bool (*image_type_check)(char *path);
542 handle = dlopen(SETTING_UTILS_SO_FILE_PATH, RTLD_LAZY);
544 SETTING_TRACE("ERROR!! canNOT find libsystem-settings-util.so.0.1.0");
548 image_type_check = dlsym(handle, "__is_supported_image_type_load");
549 if ((error = dlerror()) != NULL) {
550 SETTING_TRACE("ERROR!! canNOT find __is_supported_image_type_load function at libsystem-settings-util.so.0.1.0");
555 ret = image_type_check(path);
562 /* LCOV_EXCL_START */
563 static int dl_is_available_font(char *str)
568 int (*check_available_font)(char *font_name);
570 handle = dlopen(SETTING_UTILS_SO_FILE_PATH, RTLD_LAZY);
572 SETTING_TRACE("ERROR!! canNOT find libsystem-settings-util.so.0.1.0");
576 check_available_font = dlsym(handle, "__is_available_font");
577 if ((error = dlerror()) != NULL) {
578 SETTING_TRACE("ERROR!! canNOT find __is_available_font function at libsystem-settings-util.so.0.1.0");
583 ret = check_available_font(str);
590 /* LCOV_EXCL_START */
591 static void dl_font_size_set()
595 void (*set_font_size)();
597 handle = dlopen(SETTING_UTILS_SO_FILE_PATH, RTLD_LAZY);
599 SETTING_TRACE("ERROR!! canNOT find libsystem-settings-util.so.0.1.0");
603 set_font_size = dlsym(handle, "__font_size_set");
604 if ((error = dlerror()) != NULL) {
605 SETTING_TRACE("ERROR!! canNOT find __font_size_set function at libsystem-settings-util.so.0.1.0");
617 /* LCOV_EXCL_START */
618 static void dl_font_config_set_notification()
622 void (*set_font_nodification)();
624 handle = dlopen(SETTING_UTILS_SO_FILE_PATH, RTLD_LAZY);
626 SETTING_TRACE("ERROR!! canNOT find libsystem-settings-util.so.0.1.0");
630 set_font_nodification = dlsym(handle, "font_config_set_notification");
631 if ((error = dlerror()) != NULL) {
632 SETTING_TRACE("ERROR!! canNOT find font_config_set_notification function at libsystem-settings-util.so.0.1.0");
637 set_font_nodification();
644 /* LCOV_EXCL_START */
645 static bool dl_font_config_set(char *font_name)
650 bool (*check_font_type)(char *font_name);
652 handle = dlopen(SETTING_UTILS_SO_FILE_PATH, RTLD_LAZY);
654 SETTING_TRACE("ERROR!! canNOT find libsystem-settings-util.so.0.1.0");
658 check_font_type = dlsym(handle, "font_config_set");
659 if ((error = dlerror()) != NULL) {
660 SETTING_TRACE("ERROR!! canNOT find font_config_set function at libsystem-settings-util.so.0.1.0");
665 ret = check_font_type(font_name);
672 /* LCOV_EXCL_START */
673 static char *dl_get_default_font_info()
678 char *(*get_font_info)();
680 handle = dlopen(SETTING_UTILS_SO_FILE_PATH, RTLD_LAZY);
682 SETTING_TRACE("ERROR!! canNOT find libsystem-settings-util.so.0.1.0");
686 get_font_info = dlsym(handle, "_get_default_font");
688 if ((error = dlerror()) != NULL) {
689 SETTING_TRACE("ERROR!! canNOT find _get_default_font function at libsystem-settings-util.so.0.1.0");
694 ret = get_font_info();
701 /* LCOV_EXCL_START */
702 #define PATH_EXT_CHECK_REG ".(jpe?g|jpg|png|gif)$"
703 bool __is_supported_image_type_by_ext(char *file_path)
707 regmatch_t str[2048 + 1];
709 if (!file_path) return false;
712 if ((ret = regcomp(&fsm, PATH_EXT_CHECK_REG, REG_ICASE | REG_EXTENDED))) {
713 SETTING_TRACE("regular expresstion fail");
718 if (regexec(&fsm, file_path, strlen(file_path) + 1, str, 0) == REG_NOMATCH) {
719 /*SETTING_TRACE("FAILED - %s", file_path[i]); */
722 /*SETTING_TRACE("MATCHED - %s", file_path[i]); */
728 #ifdef TIZEN_WEARABLE
729 /* LCOV_EXCL_START */
730 static int system_setting_get_extended_wallpaper_num(const char *file_path, unsigned int *num)
734 const char *find_str = "extended_wallpaper_";
737 if (!(ch = strstr(file_path, find_str))) {
738 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
740 strncpy(buffer, file_path, ch - file_path);
741 buffer[ch - file_path] = 0;
742 sprintf(buffer + (ch - file_path), "%s%s", "", ch + strlen(find_str));
744 if (!isdigit(buffer[0])) {
745 SETTING_TRACE("%s is not number", buffer);
746 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
751 return SYSTEM_SETTINGS_ERROR_NONE;
755 /* LCOV_EXCL_START */
756 static int system_setting_copy_extended_wallpaper(const char *dest_file_path, const char *source_file_path)
759 if (!source_file_path || !dest_file_path) {
760 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
766 fd = open(source_file_path, O_RDONLY);
768 SETTING_TRACE("file open failed: %s", source_file_path);
769 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
773 fd2 = open(dest_file_path, O_WRONLY | O_CREAT, S_IRWXU | S_IRWXG | S_IRWXO);
775 SETTING_TRACE("file creation failed: %s", dest_file_path);
777 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
780 while (read(fd, buf, sizeof(buf) - 1) > 0) {
781 write(fd2, buf, sizeof(buf) - 1);
787 if (chmod(dest_file_path, S_IRWXU | S_IRWXG | S_IRWXO) < 0) {
788 SETTING_TRACE("chmod failed: %s", dest_file_path);
791 return SYSTEM_SETTINGS_ERROR_NONE;
795 /* LCOV_EXCL_START */
796 static int system_setting_remove_oldest_extended_wallpaper()
801 char *min_image_name = NULL;
802 unsigned int min_image_num = 0;
803 unsigned int temp_image_num = 0;
806 if ((dp = opendir(_TZ_SYS_DATA"/setting/wallpaper")) == NULL) {
807 SETTING_TRACE("opendir error");
808 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
811 while ((dirp = readdir(dp))) {
812 if (!strcmp(dirp->d_name, ".") || !strcmp(dirp->d_name, ".."))
815 if (system_setting_get_extended_wallpaper_num(dirp->d_name, &temp_image_num)
816 != SYSTEM_SETTINGS_ERROR_NONE) {
817 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
820 if ((image_count == 0) || (min_image_num > temp_image_num)) {
821 min_image_num = temp_image_num;
822 min_image_name = dirp->d_name;
829 if (min_image_name) {
830 snprintf(buf, sizeof(buf) - 1, _TZ_SYS_DATA"/setting/wallpaper/%s", min_image_name);
831 if (remove(buf) < 0) { /* remove oldest image */
832 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
836 return SYSTEM_SETTINGS_ERROR_NONE;
840 /* LCOV_EXCL_START */
841 static int system_setting_check_extended_wallpaper(const char *file_path)
845 if (!file_path || !strlen(file_path))
847 snprintf(buffer, 512, "%s/.bgwallpaper", tzplatform_getenv(TZ_USER_CONTENT));
848 return (strstr(file_path, buffer) != NULL);
852 #define WALLPAPER_MAX_COUNT 10
854 /* LCOV_EXCL_START */
855 int system_setting_set_wallpaper_home_screen(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
859 vconf_value = (char *)value;
861 bool isok = dl_is_supported_image_type_load(vconf_value);
864 SETTING_TRACE("path : %s is not supported file format", vconf_value);
865 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
867 SETTING_TRACE("path : %s is SUPPORT file format", vconf_value);
870 /* error handling here */
871 if (_is_file_accessible(vconf_value) != 0)
872 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
874 if (system_setting_vconf_set_value_string(VCONFKEY_BGSET, vconf_value)) {
875 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
879 #ifdef TIZEN_WEARABLE
880 if (system_setting_check_extended_wallpaper(vconf_value)) { /* New extended wallpaper */
883 unsigned int max_image_num = 0;
884 unsigned int temp_image_num = 0;
887 if ((dp = opendir(_TZ_SYS_DATA"/setting/wallpaper")) == NULL) {
888 SETTING_TRACE("Setting - dir open error!");
889 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
892 /* Check a max number of wallpapers */
893 while ((dirp = readdir(dp))) {
894 if (!strcmp(dirp->d_name, ".") || !strcmp(dirp->d_name, ".."))
897 if (system_setting_get_extended_wallpaper_num(dirp->d_name, &temp_image_num)
898 != SYSTEM_SETTINGS_ERROR_NONE) {
901 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
904 if ((image_count == 0) || (max_image_num < temp_image_num)) {
905 max_image_num = temp_image_num;
913 /* Numbering rule: Gear is odd number */
914 max_image_num = (max_image_num % 2 == 0) ? max_image_num + 1
917 char file_name_buffer[512];
918 snprintf(file_name_buffer, sizeof(file_name_buffer) - 1,
919 _TZ_SYS_DATA"/setting/wallpaper/extended_wallpaper_%d.jpg", max_image_num);
921 /* Copy image to _TZ_SYS_DATA/setting/wallpaper/ */
922 if (system_setting_copy_extended_wallpaper(file_name_buffer, vconf_value)
923 != SYSTEM_SETTINGS_ERROR_NONE) {
924 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
927 /* remove oldest wallpaper */
928 if (image_count >= WALLPAPER_MAX_COUNT) {
929 if (system_setting_remove_oldest_extended_wallpaper()
930 != SYSTEM_SETTINGS_ERROR_NONE) {
931 remove(file_name_buffer);
932 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
936 if (system_setting_vconf_set_value_string(VCONFKEY_BGSET, file_name_buffer)) {
937 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
940 if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_WALLPAPER_CHANGED_NOTI_INT,
941 VCONFKEY_WALLPAPER_CHANGED_NOTI_GEAR)) {
942 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
945 if (system_setting_vconf_set_value_string(VCONFKEY_BGSET, vconf_value)) {
946 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
951 return SYSTEM_SETTINGS_ERROR_NONE;
955 /* LCOV_EXCL_START */
956 int system_setting_set_wallpaper_lock_screen(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
960 vconf_value = (char *)value;
962 bool isok = dl_is_supported_image_type_load(vconf_value);
965 SETTING_TRACE("path : %s is not supported file format", vconf_value);
966 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
968 SETTING_TRACE("path : %s is SUPPORT file format", vconf_value);
971 /* error handling here */
972 if (_is_file_accessible(vconf_value) != 0)
973 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
975 if (system_setting_vconf_set_value_string(VCONFKEY_IDLE_LOCK_BGSET, vconf_value)) {
976 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
979 return SYSTEM_SETTINGS_ERROR_NONE;
983 /* LCOV_EXCL_START */
984 int system_setting_set_font_size(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
988 vconf_value = *(int **)value;
990 if (*vconf_value < 0 || *vconf_value > SYSTEM_SETTINGS_FONT_SIZE_GIANT) {
991 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
994 if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, *vconf_value)) {
995 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
999 return SYSTEM_SETTINGS_ERROR_NONE;
1001 /* LCOV_EXCL_STOP */
1005 /* LCOV_EXCL_START */
1006 void *font_conf_doc_parse(char *doc_name, char *font_name)
1008 SETTING_TRACE_BEGIN;
1009 xmlDocPtr doc = NULL;
1010 xmlNodePtr cur = NULL;
1011 xmlNodePtr cur2 = NULL;
1012 xmlNodePtr cur3 = NULL;
1013 xmlChar *key = NULL;
1015 doc = xmlParseFile(doc_name);
1017 cur = xmlDocGetRootElement(doc);
1025 if (xmlStrcmp(cur->name, (const xmlChar *)"fontconfig")) {
1031 cur = cur->xmlChildrenNode;
1033 bool is_changed = false;
1034 while (cur != NULL) {
1035 if ((!xmlStrcmp(cur->name, (const xmlChar *)"match"))) {
1036 cur2 = cur->xmlChildrenNode;
1037 while (cur2 != NULL) {
1038 if ((!xmlStrcmp(cur2->name, (const xmlChar *)"edit"))) {
1039 xmlChar *name = xmlGetProp(cur2, (const xmlChar *)"name");
1040 /* if name is not 'family', break */
1041 if (xmlStrcmp(name, (const xmlChar *)"family")) {
1049 cur3 = cur2->xmlChildrenNode;
1050 while (cur3 != NULL) {
1051 if ((!xmlStrcmp(cur3->name, (const xmlChar *)"string"))) {
1052 xmlNodeSetContent(cur3->xmlChildrenNode, (const xmlChar *)font_name);
1053 key = xmlNodeListGetString(doc, cur3->xmlChildrenNode, 1);
1063 } else if ((!xmlStrcmp(cur->name, (const xmlChar *)"alias"))) {
1064 cur2 = cur->xmlChildrenNode;
1065 while (cur2 != NULL) {
1066 if ((!xmlStrcmp(cur2->name, (const xmlChar *)"family"))) {
1067 xmlNodeSetContent(cur2->xmlChildrenNode, (const xmlChar *)font_name);
1068 key = xmlNodeListGetString(doc, cur2->xmlChildrenNode, 1);
1072 } else if ((!xmlStrcmp(cur2->name, (const xmlChar *)"prefer"))) {
1073 cur3 = cur2->xmlChildrenNode;
1074 while (cur3 != NULL) {
1075 if ((!xmlStrcmp(cur3->name, (const xmlChar *)"family"))) {
1076 xmlNodeSetContent(cur3->xmlChildrenNode, (const xmlChar *)font_name);
1077 key = xmlNodeListGetString(doc, cur3->xmlChildrenNode, 1);
1101 /* LCOV_EXCL_STOP */
1103 /* LCOV_EXCL_START */
1104 int system_setting_set_font_type(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1106 SETTING_TRACE_BEGIN;
1107 char *font_name = NULL;
1108 font_name = (char *)value;
1110 /* get current font list */
1111 int is_found = dl_is_available_font(font_name);
1114 SETTING_TRACE("found font : %s ", font_name);
1116 SETTING_TRACE(" NOT found font : %s ", font_name);
1117 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1120 bool bsave = dl_font_config_set(font_name);
1123 SETTING_TRACE(" font type save error by font_config_set() ");
1124 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1126 SETTING_TRACE(" save OK - font_config_set() ");
1129 xmlDocPtr doc = (xmlDocPtr)font_conf_doc_parse(SETTING_FONT_CONF_FILE, font_name);
1131 xmlSaveFormatFile(SETTING_FONT_CONF_FILE, doc, 0);
1136 dl_font_config_set_notification();
1139 vconf_value = (char *)value;
1141 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, vconf_value)) {
1142 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1144 return SYSTEM_SETTINGS_ERROR_NONE;
1146 /* LCOV_EXCL_STOP */
1148 /* LCOV_EXCL_START */
1149 int system_setting_set_motion_activation(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1151 SETTING_TRACE_BEGIN;
1153 vconf_value = (bool *)value;
1154 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_MOTION_ACTIVATION, *vconf_value)) {
1155 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1157 return SYSTEM_SETTINGS_ERROR_NONE;
1159 /* LCOV_EXCL_STOP */
1161 /* LCOV_EXCL_START */
1162 int system_setting_set_usb_debugging_option(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1164 SETTING_TRACE_BEGIN;
1166 vconf_value = (bool *)value;
1167 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_USB_DEBUG_MODE_BOOL, *vconf_value)) {
1168 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1170 return SYSTEM_SETTINGS_ERROR_NONE;
1173 /* LCOV_EXCL_STOP */
1175 /* LCOV_EXCL_START */
1176 int system_setting_set_3g_data_network(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1178 SETTING_TRACE_BEGIN;
1180 vconf_value = (bool *)value;
1181 if (system_setting_vconf_set_value_bool(VCONFKEY_3G_ENABLE, *vconf_value)) {
1182 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1185 return SYSTEM_SETTINGS_ERROR_NONE;
1187 /* LCOV_EXCL_STOP */
1189 /* LCOV_EXCL_START */
1190 static int category_func(const char *name, void *user_data)
1192 SETTING_TRACE_BEGIN;
1193 static char *category = "lock-screen";
1194 if (name && !strcmp(name, category)) {
1195 SETTING_TRACE(" SAME ");
1198 SETTING_TRACE(" DIFFERENT -- %s, category -- %s ", name, category);
1204 /* LCOV_EXCL_STOP */
1208 * set 'swipe type' if current lockscreen app is 'com.samsung.lockscreen'
1212 /* LCOV_EXCL_START */
1213 int system_setting_set_lockscreen_app(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1215 SETTING_TRACE_BEGIN;
1217 vconf_value = (char *)value; /* ex) com.samsung.lockscreen */
1220 pkgmgrinfo_appinfo_h handle;
1221 r = pkgmgrinfo_appinfo_get_appinfo(vconf_value, &handle);
1222 if (r != PMINFO_R_OK) {
1223 SETTING_TRACE("*** pkginfo failed ");
1224 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
1226 SETTING_TRACE("%x", handle);
1229 int ret = pkgmgrinfo_appinfo_foreach_category(handle, category_func, (void *)"lock-screen");
1230 if (ret != PMINFO_R_OK) {
1231 pkgmgrinfo_appinfo_destroy_appinfo(handle);
1232 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
1235 pkgmgrinfo_appinfo_destroy_appinfo(handle);
1236 /*----------------------------------------------------------------------------------- */
1238 if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_SCREEN_LOCK_TYPE_INT, &locktype)) {
1239 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1242 if (locktype == SETTING_SCREEN_LOCK_TYPE_PASSWORD)
1243 return SYSTEM_SETTINGS_ERROR_LOCKSCREEN_APP_PASSWORD_MODE;
1245 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_3RD_LOCK_PKG_NAME_STR, vconf_value)) {
1246 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1249 if (vconf_value && strcmp(vconf_value, "com.samsung.lockscreen") == 0) {
1250 if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_SCREEN_LOCK_TYPE_INT, SETTING_SCREEN_LOCK_TYPE_SWIPE)) {
1251 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1254 return SYSTEM_SETTINGS_ERROR_NONE;
1256 /* LCOV_EXCL_STOP */
1258 /*/////////////////////////////////////////////////////////////////////////////////////////////// */
1261 int system_setting_set_changed_callback_incoming_call_ringtone(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1263 SETTING_TRACE_BEGIN;
1264 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR, SYSTEM_SETTINGS_KEY_INCOMING_CALL_RINGTONE, 0, user_data);
1267 int system_setting_unset_changed_callback_incoming_call_ringtone(system_settings_key_e key)
1269 SETTING_TRACE_BEGIN;
1270 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR, 0);
1273 int system_setting_set_changed_callback_email_alert_ringtone(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1275 SETTING_TRACE_BEGIN;
1276 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, SYSTEM_SETTINGS_KEY_EMAIL_ALERT_RINGTONE, 0, user_data);
1279 int system_setting_unset_changed_callback_email_alert_ringtone(system_settings_key_e key)
1281 SETTING_TRACE_BEGIN;
1282 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, 0);
1285 int system_setting_set_changed_callback_wallpaper_home_screen(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1287 SETTING_TRACE_BEGIN;
1288 return system_setting_vconf_set_changed_cb(VCONFKEY_BGSET, SYSTEM_SETTINGS_KEY_WALLPAPER_HOME_SCREEN, 0, user_data);
1291 int system_setting_unset_changed_callback_wallpaper_home_screen(system_settings_key_e key)
1293 SETTING_TRACE_BEGIN;
1294 return system_setting_vconf_unset_changed_cb(VCONFKEY_BGSET, 0);
1297 int system_setting_set_changed_callback_wallpaper_lock_screen(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1299 SETTING_TRACE_BEGIN;
1300 return system_setting_vconf_set_changed_cb(VCONFKEY_IDLE_LOCK_BGSET, SYSTEM_SETTINGS_KEY_WALLPAPER_LOCK_SCREEN, 0, user_data);
1303 int system_setting_unset_changed_callback_wallpaper_lock_screen(system_settings_key_e key)
1305 SETTING_TRACE_BEGIN;
1306 return system_setting_vconf_unset_changed_cb(VCONFKEY_IDLE_LOCK_BGSET, 0);
1309 int system_setting_set_changed_callback_font_size(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1311 SETTING_TRACE_BEGIN;
1312 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, SYSTEM_SETTINGS_KEY_FONT_SIZE, 1, user_data);
1315 int system_setting_unset_changed_callback_font_size(system_settings_key_e key)
1317 SETTING_TRACE_BEGIN;
1318 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, 1);
1321 int system_setting_set_changed_callback_usb_debugging_option(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1323 SETTING_TRACE_BEGIN;
1324 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_USB_DEBUG_MODE_BOOL, SYSTEM_SETTINGS_KEY_USB_DEBUGGING_ENABLED, 1, user_data);
1327 int system_setting_unset_changed_callback_usb_debugging_option(system_settings_key_e key)
1329 SETTING_TRACE_BEGIN;
1330 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_USB_DEBUG_MODE_BOOL, 1);
1333 int system_setting_set_changed_callback_3g_data_network(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1335 SETTING_TRACE_BEGIN;
1336 return system_setting_vconf_set_changed_cb(VCONFKEY_3G_ENABLE, SYSTEM_SETTINGS_KEY_3G_DATA_NETWORK_ENABLED, 1, user_data);
1339 int system_setting_unset_changed_callback_3g_data_network(system_settings_key_e key)
1341 SETTING_TRACE_BEGIN;
1342 return system_setting_vconf_unset_changed_cb(VCONFKEY_3G_ENABLE, 1);
1345 int system_setting_set_changed_callback_lockscreen_app(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1347 SETTING_TRACE_BEGIN;
1348 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_3RD_LOCK_PKG_NAME_STR, SYSTEM_SETTINGS_KEY_LOCKSCREEN_APP, 1, user_data);
1351 int system_setting_unset_changed_callback_lockscreen_app(system_settings_key_e key)
1353 SETTING_TRACE_BEGIN;
1354 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_3RD_LOCK_PKG_NAME_STR, 1);
1359 * @todo need to add custom event notification method
1361 int system_setting_set_changed_callback_font_type(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1363 SETTING_TRACE_BEGIN;
1364 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, SYSTEM_SETTINGS_KEY_FONT_TYPE, 2, user_data);
1367 int system_setting_unset_changed_callback_font_type(system_settings_key_e key)
1369 SETTING_TRACE_BEGIN;
1370 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, 2);
1373 /* TODO : 2th argument, callback, is not in use. */
1374 int system_setting_set_changed_callback_motion_activation(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1376 SETTING_TRACE_BEGIN;
1377 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_MOTION_ACTIVATION, SYSTEM_SETTINGS_KEY_MOTION_ACTIVATION, 3, user_data);
1380 int system_setting_unset_changed_callback_motion_activation(system_settings_key_e key)
1382 SETTING_TRACE_BEGIN;
1383 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_MOTION_ACTIVATION, 3);
1386 /*//////////////////////////////////////////////////////////////////////////////////////// */
1387 /*--------------------------------------- */
1388 int system_setting_get_locale_country(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1390 SETTING_TRACE_BEGIN;
1391 char *vconf_value = NULL;
1392 if (system_setting_vconf_get_value_string(VCONFKEY_REGIONFORMAT, &vconf_value)) {
1393 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1396 /* parsing validation */
1399 snprintf(arr, 20, "%s", vconf_value);
1401 *value = strdup(arr);
1405 return SYSTEM_SETTINGS_ERROR_NONE;
1408 /* LCOV_EXCL_START */
1409 int system_setting_set_locale_country(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1411 SETTING_TRACE_BEGIN;
1412 char *vconf_value = NULL;
1413 vconf_value = (char *)value;
1415 char *ext = "UTF-8";
1418 snprintf(arr, 20, "%s.%s", vconf_value, ext);
1420 if (system_setting_vconf_set_value_string(VCONFKEY_REGIONFORMAT, arr)) {
1421 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1423 return SYSTEM_SETTINGS_ERROR_NONE;
1425 /* LCOV_EXCL_STOP */
1427 int system_setting_set_changed_callback_locale_country(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1429 SETTING_TRACE_BEGIN;
1430 return system_setting_vconf_set_changed_cb(VCONFKEY_REGIONFORMAT, SYSTEM_SETTINGS_KEY_LOCALE_COUNTRY, 3, user_data);
1433 int system_setting_unset_changed_callback_locale_country(system_settings_key_e key)
1435 SETTING_TRACE_BEGIN;
1436 return system_setting_vconf_unset_changed_cb(VCONFKEY_REGIONFORMAT, 3);
1440 /*--------------------------------------- */
1441 int system_setting_get_locale_language(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1443 SETTING_TRACE_BEGIN;
1444 char *vconf_value = NULL;
1445 if (system_setting_vconf_get_value_string(VCONFKEY_LANGSET, &vconf_value)) {
1446 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1449 /* parsing validation */
1452 snprintf(arr, 20, "%s", vconf_value);
1454 *value = strdup(arr);
1457 return SYSTEM_SETTINGS_ERROR_NONE;
1460 /* LCOV_EXCL_START */
1461 int system_setting_set_locale_language(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1463 SETTING_TRACE_BEGIN;
1464 char *vconf_value = NULL;
1465 vconf_value = (char *)value;
1467 char *ext = "UTF-8";
1470 snprintf(arr, 20, "%s.%s", vconf_value, ext);
1472 if (system_setting_vconf_set_value_string(VCONFKEY_LANGSET, arr)) {
1473 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1475 return SYSTEM_SETTINGS_ERROR_NONE;
1477 /* LCOV_EXCL_STOP */
1479 int system_setting_set_changed_callback_locale_language(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1481 SETTING_TRACE_BEGIN;
1482 /*return system_setting_vconf_set_changed_cb(VCONFKEY_LANGSET, SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, 3, user_data ); */
1483 return system_setting_vconf_set_changed_cb(VCONFKEY_LANGSET, SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, 100, user_data);
1486 int system_setting_unset_changed_callback_locale_language(system_settings_key_e key)
1488 SETTING_TRACE_BEGIN;
1489 return system_setting_vconf_unset_changed_cb(VCONFKEY_LANGSET, 100);
1492 /*--------------------------------------- */
1493 /* LCOV_EXCL_START */
1494 int system_setting_get_locale_timeformat_24hour(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1496 SETTING_TRACE_BEGIN;
1499 if (system_setting_vconf_get_value_int(VCONFKEY_REGIONFORMAT_TIME1224, &vconf_value)) {
1500 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1503 bool ret_value = true;
1504 if (vconf_value == VCONFKEY_TIME_FORMAT_12)
1506 else if (vconf_value == VCONFKEY_TIME_FORMAT_24)
1509 *value = (void *)ret_value;
1511 return SYSTEM_SETTINGS_ERROR_NONE;
1513 /* LCOV_EXCL_STOP */
1515 int system_setting_set_locale_timeformat_24hour(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1517 SETTING_TRACE_BEGIN;
1520 vconf_value = (bool *)value;
1523 if (system_setting_vconf_set_value_int(VCONFKEY_REGIONFORMAT_TIME1224, VCONFKEY_TIME_FORMAT_24)) {
1524 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1528 if (system_setting_vconf_set_value_int(VCONFKEY_REGIONFORMAT_TIME1224, VCONFKEY_TIME_FORMAT_12)) {
1529 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1534 return SYSTEM_SETTINGS_ERROR_NONE;
1537 int system_setting_set_changed_callback_locale_timeformat_24hour(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1539 SETTING_TRACE_BEGIN;
1540 return system_setting_vconf_set_changed_cb(VCONFKEY_REGIONFORMAT_TIME1224, SYSTEM_SETTINGS_KEY_LOCALE_TIMEFORMAT_24HOUR, 3, user_data);
1543 int system_setting_unset_changed_callback_locale_timeformat_24hour(system_settings_key_e key)
1545 SETTING_TRACE_BEGIN;
1546 return system_setting_vconf_unset_changed_cb(VCONFKEY_REGIONFORMAT_TIME1224, 3);
1549 int system_setting_get_locale_timezone(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1552 ssize_t len = readlink(SETTING_TZONE_SYMLINK_PATH, tzpath, sizeof(tzpath)-1);
1556 SETTING_TRACE("parse error for SETTING_TZONE_SYMLINK_PATH");
1557 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1560 SETTING_TRACE("tzpath : %s ", &tzpath[20]);
1561 *value = strdup(&tzpath[20]);
1562 return SYSTEM_SETTINGS_ERROR_NONE;
1565 /* LCOV_EXCL_START */
1566 int system_setting_set_locale_timezone(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1568 SETTING_TRACE_BEGIN;
1569 char *timezone_value = NULL;
1570 timezone_value = (char *)value;
1573 snprintf(tz_path, 1024, "/usr/share/zoneinfo/%s", timezone_value);
1575 int is_load = _is_file_accessible(tz_path);
1577 alarmmgr_set_timezone(tz_path);
1579 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_TIMEZONE_ID, timezone_value)) {
1580 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1582 return SYSTEM_SETTINGS_ERROR_NONE;
1584 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
1586 /* LCOV_EXCL_STOP */
1590 /* LCOV_EXCL_START */
1591 int system_setting_set_changed_callback_locale_timezone(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1593 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_TIMEZONE_ID, SYSTEM_SETTINGS_KEY_LOCALE_TIMEZONE, 4, user_data);
1595 /* LCOV_EXCL_STOP */
1597 /* LCOV_EXCL_START */
1598 int system_setting_unset_changed_callback_locale_timezone(system_settings_key_e key)
1600 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_TIMEZONE_ID, 4);
1602 /* LCOV_EXCL_STOP */
1604 /* LCOV_EXCL_START */
1605 int system_setting_set_changed_callback_locale_timezone_changed(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1607 SETTING_TRACE_BEGIN;
1608 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
1610 /* LCOV_EXCL_STOP */
1612 /* LCOV_EXCL_START */
1613 int system_setting_unset_changed_callback_locale_timezone_changed(system_settings_key_e key)
1615 SETTING_TRACE_BEGIN;
1616 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
1618 /* LCOV_EXCL_STOP */
1621 /* LCOV_EXCL_START */
1622 int system_setting_get_time_changed(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1624 SETTING_TRACE_BEGIN;
1626 int ** val = (int**)value;
1627 cur_tick = time(NULL);
1629 /* struct tm * localtime = time (cur_tick); */
1630 /* printf("%s\n", ctime(&cur_tick); */
1631 return SYSTEM_SETTINGS_ERROR_NONE;
1634 /* LCOV_EXCL_STOP */
1636 int system_setting_set_changed_callback_time_changed(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1638 SETTING_TRACE_BEGIN;
1639 return system_setting_vconf_set_changed_cb(VCONFKEY_SYSTEM_TIME_CHANGED, SYSTEM_SETTINGS_KEY_TIME_CHANGED, 3, user_data);
1642 int system_setting_unset_changed_callback_time_changed(system_settings_key_e key)
1644 SETTING_TRACE_BEGIN;
1645 return system_setting_vconf_unset_changed_cb(VCONFKEY_SYSTEM_TIME_CHANGED, 3);
1650 /* SYSTEM_SETTINGS_KEY_SOUND_LOCK */
1651 int system_setting_get_sound_lock(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1653 SETTING_TRACE_BEGIN;
1656 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_SOUND_LOCK_BOOL, &vconf_value)) {
1657 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1659 *value = (void *)vconf_value;
1661 return SYSTEM_SETTINGS_ERROR_NONE;
1664 int system_setting_set_changed_callback_sound_lock(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1666 SETTING_TRACE_BEGIN;
1667 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_SOUND_LOCK_BOOL, SYSTEM_SETTINGS_KEY_SOUND_LOCK, 3, user_data);
1670 int system_setting_unset_changed_callback_sound_lock(system_settings_key_e key)
1672 SETTING_TRACE_BEGIN;
1673 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_SOUND_LOCK_BOOL, 3);
1677 * a = VCONFKEY_SETAPPL_SOUND_STATUS_BOOL b = VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL
1679 * a == false, b == false --> silent mode
1680 * a == true, b == false --> sound mode
1681 * a == false, b == true --> vibration mode
1683 /* LCOV_EXCL_START */
1684 int system_setting_get_sound_silent_mode(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1686 SETTING_TRACE_BEGIN;
1691 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, &sound_cond)) {
1692 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1695 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, &vib_cond)) {
1696 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1699 if (sound_cond == false && vib_cond == false) {
1701 *value = (void *)vconf_value;
1703 vconf_value = false;
1704 *value = (void *)vconf_value;
1706 return SYSTEM_SETTINGS_ERROR_NONE;
1708 /* LCOV_EXCL_STOP */
1711 * a = VCONFKEY_SETAPPL_SOUND_STATUS_BOOL b = VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL
1713 * a == false, b == false --> silent mode
1714 * a == true, b == false --> sound mode
1716 int system_setting_set_sound_silent_mode(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1718 SETTING_TRACE_BEGIN;
1721 vconf_value = (bool *)value;
1723 bool vconf_sound = false;
1724 bool vconf_vib = false;
1727 vconf_sound = false;
1734 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, vconf_sound)) {
1735 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1737 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, vconf_vib)) {
1738 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1741 return SYSTEM_SETTINGS_ERROR_NONE;
1747 int system_setting_set_changed_callback_sound_silent_mode(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1749 SETTING_TRACE_BEGIN;
1750 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, SYSTEM_SETTINGS_KEY_SOUND_SILENT_MODE, 3, user_data);
1754 int system_setting_unset_changed_callback_sound_silent_mode(system_settings_key_e key)
1756 SETTING_TRACE_BEGIN;
1757 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, 3);
1760 /* SYSTEM_SETTINGS_KEY_SOUND_TOUCH */
1761 int system_setting_get_sound_touch(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1763 SETTING_TRACE_BEGIN;
1766 int ret = system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL, &vconf_value);
1767 if (ret != SYSTEM_SETTINGS_ERROR_NONE) {
1770 *value = (void *)vconf_value;
1774 int system_setting_set_changed_callback_sound_touch(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1776 SETTING_TRACE_BEGIN;
1777 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL, SYSTEM_SETTINGS_KEY_SOUND_TOUCH, 2, user_data);
1780 int system_setting_unset_changed_callback_sound_touch(system_settings_key_e key)
1782 SETTING_TRACE_BEGIN;
1783 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL, 2);
1787 /* SYSTEM_SETTINGS_KEY_SOUND_LOCK */
1788 int system_setting_get_sound_lock(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1792 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_SOUND_LOCK_BOOL, &vconf_value)) {
1793 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1795 *value = (void *)vconf_value;
1797 return SYSTEM_SETTINGS_ERROR_NONE;
1801 int system_setting_get_auto_rotation_mode(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1803 SETTING_TRACE_BEGIN;
1806 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, &vconf_value)) {
1807 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1809 *value = (void *)vconf_value;
1811 return SYSTEM_SETTINGS_ERROR_NONE;
1814 /* LCOV_EXCL_START */
1815 int system_setting_set_auto_rotation_mode(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1817 SETTING_TRACE_BEGIN;
1819 vconf_value = (bool *)value;
1820 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, *vconf_value)) {
1821 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1824 return SYSTEM_SETTINGS_ERROR_NONE;
1826 /* LCOV_EXCL_STOP */
1828 int system_setting_set_changed_callback_auto_rotation_mode(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1830 SETTING_TRACE_BEGIN;
1831 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, SYSTEM_SETTINGS_KEY_DISPLAY_SCREEN_ROTATION_AUTO, 2, user_data);
1834 int system_setting_unset_changed_callback_auto_rotation_mode(system_settings_key_e key)
1836 SETTING_TRACE_BEGIN;
1837 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, 2);
1840 int system_setting_get_screen_backlight_time(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1842 SETTING_TRACE_BEGIN;
1844 int ** val = (int**)value;
1846 if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, &vconf_value)) {
1847 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1849 **val = vconf_value;
1851 return SYSTEM_SETTINGS_ERROR_NONE;
1855 /* LCOV_EXCL_START */
1856 int system_setting_set_screen_backlight_time(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1858 SETTING_TRACE_BEGIN;
1860 vconf_value = *(int **)value;
1862 if (!(*vconf_value > 0 && *vconf_value <= 600)) {
1863 SETTING_TRACE(" ERR Betweeny here 0 ~ 600");
1864 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
1867 if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, *vconf_value)) {
1868 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1871 return SYSTEM_SETTINGS_ERROR_NONE;
1873 /* LCOV_EXCL_STOP */
1875 int system_setting_set_changed_callback_screen_backlight_time(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1877 SETTING_TRACE_BEGIN;
1878 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, SYSTEM_SETTINGS_KEY_SCREEN_BACKLIGHT_TIME, 2, user_data);
1881 int system_setting_unset_changed_callback_screen_backlight_time(system_settings_key_e key)
1883 SETTING_TRACE_BEGIN;
1884 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, 2);
1887 int system_setting_get_sound_notification(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1889 SETTING_TRACE_BEGIN;
1890 char *vconf_value = NULL;
1891 if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, &vconf_value)) {
1892 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1895 *value = vconf_value;
1896 return SYSTEM_SETTINGS_ERROR_NONE;
1899 /* LCOV_EXCL_START */
1900 int system_setting_set_sound_notification(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1902 SETTING_TRACE_BEGIN;
1903 char *vconf_value = NULL;
1904 vconf_value = (char *)value;
1906 int is_load = _is_file_accessible(vconf_value);
1908 //SETTING_TRACE(" system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, %s) TRY", vconf_value);
1909 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, vconf_value)) {
1910 //SETTING_TRACE(" system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, %s) FAIL", vconf_value);
1911 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1914 //SETTING_TRACE(" is_file_accessibile FAILED - system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, %s) FAIL", vconf_value);
1915 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1918 return SYSTEM_SETTINGS_ERROR_NONE;
1920 /* LCOV_EXCL_STOP */
1922 int system_setting_set_changed_callback_sound_notification(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1924 SETTING_TRACE_BEGIN;
1925 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, SYSTEM_SETTINGS_KEY_SOUND_NOTIFICATION, 0, user_data);
1928 int system_setting_unset_changed_callback_sound_notification(system_settings_key_e key)
1930 SETTING_TRACE_BEGIN;
1931 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, 0);
1934 int system_setting_get_notification_repetition_period(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1936 SETTING_TRACE_BEGIN;
1937 int ** val = (int**)value;
1940 if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_NOTI_MSG_ALERT_REP_TYPE_INT, &vconf_value)) {
1941 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1943 **val = vconf_value;
1945 return SYSTEM_SETTINGS_ERROR_NONE;
1948 /* LCOV_EXCL_START */
1949 int system_setting_set_notification_repetition_period(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1951 SETTING_TRACE_BEGIN;
1953 vconf_value = *(int **)value;
1955 if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_NOTI_MSG_ALERT_REP_TYPE_INT, *vconf_value)) {
1956 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1959 return SYSTEM_SETTINGS_ERROR_NONE;
1961 /* LCOV_EXCL_STOP */
1963 int system_setting_set_changed_callback_notification_repetition_period(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1965 SETTING_TRACE_BEGIN;
1966 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);
1969 int system_setting_unset_changed_callback_notification_repetition_period(system_settings_key_e key)
1971 SETTING_TRACE_BEGIN;
1972 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_ALERT_REP_TYPE_INT, 1);
1975 int system_setting_get_device_name(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1977 SETTING_TRACE_BEGIN;
1978 char *vconf_value = NULL;
1979 if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_DEVICE_NAME_STR, &vconf_value)) {
1980 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1983 *value = vconf_value;
1984 return SYSTEM_SETTINGS_ERROR_NONE;
1987 /* LCOV_EXCL_START */
1988 int system_setting_set_device_name(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1990 SETTING_TRACE_BEGIN;
1991 char *vconf_value = NULL;
1992 vconf_value = (char *)value;
1994 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_DEVICE_NAME_STR, vconf_value)) {
1995 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1998 return SYSTEM_SETTINGS_ERROR_NONE;
2000 /* LCOV_EXCL_STOP */
2002 int system_setting_set_changed_callback_device_name(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
2004 SETTING_TRACE_BEGIN;
2005 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_DEVICE_NAME_STR, SYSTEM_SETTINGS_KEY_DEVICE_NAME, 0, user_data);
2008 int system_setting_unset_changed_callback_device_name(system_settings_key_e key)
2010 SETTING_TRACE_BEGIN;
2011 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_DEVICE_NAME_STR, 0);
2014 /*---------------------------------------------- */
2015 int system_setting_get_network_flight_mode(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
2017 SETTING_TRACE_BEGIN;
2019 if (system_setting_vconf_get_value_bool(VCONFKEY_TELEPHONY_FLIGHT_MODE, &vconf_value)) {
2020 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2022 *value = (void *)vconf_value;
2024 return SYSTEM_SETTINGS_ERROR_NONE;
2027 int system_setting_set_changed_callback_network_flight_mode(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
2029 SETTING_TRACE_BEGIN;
2030 return system_setting_vconf_set_changed_cb(VCONFKEY_TELEPHONY_FLIGHT_MODE, SYSTEM_SETTINGS_KEY_NETWORK_FLIGHT_MODE, 3, user_data);
2033 int system_setting_unset_changed_callback_network_flight_mode(system_settings_key_e key)
2035 SETTING_TRACE_BEGIN;
2036 return system_setting_vconf_unset_changed_cb(VCONFKEY_TELEPHONY_FLIGHT_MODE, 3);
2039 int system_setting_get_network_wifi_notification(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
2041 SETTING_TRACE_BEGIN;
2043 if (system_setting_vconf_get_value_int(VCONFKEY_WIFI_ENABLE_QS, &vconf_value)) {
2044 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2047 bret = (vconf_value == VCONFKEY_WIFI_QS_ENABLE) ? true : false;
2049 *value = (void *)bret;
2050 return SYSTEM_SETTINGS_ERROR_NONE;
2053 int system_setting_set_changed_callback_network_wifi_notification(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
2055 SETTING_TRACE_BEGIN;
2056 return system_setting_vconf_set_changed_cb(VCONFKEY_WIFI_ENABLE_QS, SYSTEM_SETTINGS_KEY_NETWORK_WIFI_NOTIFICATION, 4, user_data);
2059 int system_setting_unset_changed_callback_network_wifi_notification(system_settings_key_e key)
2061 SETTING_TRACE_BEGIN;
2062 return system_setting_vconf_unset_changed_cb(VCONFKEY_WIFI_ENABLE_QS, 4);
2065 /* LCOV_EXCL_START */
2066 int system_setting_get_lock_state(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
2069 int ** val = (int**)value;
2071 if (system_setting_vconf_get_value_int(VCONFKEY_IDLE_LOCK_STATE_READ_ONLY, &vconf_value)) {
2072 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2074 **val = vconf_value;
2076 return SYSTEM_SETTINGS_ERROR_NONE;
2078 /* LCOV_EXCL_STOP */
2080 /* LCOV_EXCL_START */
2081 int system_setting_set_lock_state(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
2083 SETTING_TRACE_BEGIN;
2085 vconf_value = *(int **)value;
2087 if (system_setting_vconf_set_value_int(VCONFKEY_IDLE_LOCK_STATE_READ_ONLY, *vconf_value)) {
2088 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2091 return SYSTEM_SETTINGS_ERROR_NONE;
2093 /* LCOV_EXCL_STOP */
2095 /* LCOV_EXCL_START */
2096 int system_setting_set_changed_callback_lock_state(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
2098 return system_setting_vconf_set_changed_cb(VCONFKEY_IDLE_LOCK_STATE_READ_ONLY, SYSTEM_SETTINGS_KEY_LOCK_STATE, 4, user_data);
2100 /* LCOV_EXCL_STOP */
2102 /* LCOV_EXCL_START */
2103 int system_setting_unset_changed_callback_lock_state(system_settings_key_e key)
2105 return system_setting_vconf_unset_changed_cb(VCONFKEY_IDLE_LOCK_STATE_READ_ONLY, 4);
2107 /* LCOV_EXCL_STOP */
2109 //----------------------------------------------------------------------------------------------------------------------------
2111 #define DEFAULT_ADS_ID "00000000-0000-0000-0000-000000000000"
2113 int system_setting_get_ads_id(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
2115 SETTING_TRACE_BEGIN;
2116 int optout_value = 0;
2117 if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_AD_ID_OPT_OUT, &optout_value)) {
2118 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2121 if (optout_value == 1) {
2122 *value = strdup(DEFAULT_ADS_ID);
2123 return SYSTEM_SETTINGS_ERROR_NONE;
2126 char *vconf_value = NULL;
2127 if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_AD_ID, &vconf_value)) {
2128 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2131 *value = vconf_value;
2132 return SYSTEM_SETTINGS_ERROR_NONE;
2137 void make_ad_id(void)
2140 char uuid_unparsed[50] = {0};
2141 uuid_generate(uuid_value);
2142 uuid_unparse(uuid_value, uuid_unparsed);
2143 system_setting_set_ad_id(key, uuid_unparsed); //example of setting the value
2146 /* LCOV_EXCL_START */
2147 int system_setting_set_ads_id(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
2149 SETTING_TRACE_BEGIN;
2150 char *vconf_value = NULL;
2151 vconf_value = (char *)value;
2153 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_AD_ID, vconf_value)) {
2154 SETTING_TRACE("Setting VCONFKEY_SETAPPL_AD_ID failed");
2155 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2158 return SYSTEM_SETTINGS_ERROR_NONE;
2160 /* LCOV_EXCL_STOP */
2162 int system_setting_set_changed_callback_ads_id(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
2164 SETTING_TRACE_BEGIN;
2165 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_AD_ID, SYSTEM_SETTINGS_KEY_ADS_ID, 0, user_data);
2168 int system_setting_unset_changed_callback_ads_id(system_settings_key_e key)
2170 SETTING_TRACE_BEGIN;
2171 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_AD_ID, 0);
2174 int system_settings_feature_check_bool(char *path)
2176 bool profile_data = false;
2177 int ret = system_info_get_platform_bool(path, &profile_data);
2178 if (ret != SYSTEM_INFO_ERROR_NONE) {
2179 SETTING_TRACE("Setting - reading profile string failed, %d", ret);
2180 return SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED;
2183 ret = (profile_data == true) ? SYSTEM_SETTINGS_ERROR_NONE : SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED;
2189 int system_setting_feature_check_incoming_call(void * value)
2191 static bool first_query = true;
2192 static int ret = SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED;
2194 if (first_query == true) {
2195 ret = system_settings_feature_check_bool(SETTING_INCOMING_CALL_PATH);
2196 first_query = false;
2202 int system_setting_feature_check_home_screen(void * value)
2204 static bool first_query = true;
2205 static int ret = SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED;
2207 if (first_query == true) {
2208 ret = system_settings_feature_check_bool(SETTING_HOME_SCREEN_PATH);
2209 first_query = false;
2215 int system_setting_feature_check_lock_screen(void * value)
2217 static bool first_query = true;
2218 static int ret = SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED;
2220 if (first_query == true) {
2221 ret = system_settings_feature_check_bool(SETTING_LOCK_SCREEN_PATH);
2222 first_query = false;
2228 int system_setting_feature_check_notification_email(void * value)
2230 static bool first_query = true;
2231 static int ret = SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED;
2233 if (first_query == true) {
2234 ret = system_settings_feature_check_bool(SETTING_NOTIFICATION_EMAIL_PATH);
2235 first_query = false;
2241 int system_setting_feature_check_wifi(void * value)
2243 static bool first_query = true;
2244 static int ret = SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED;
2246 if (first_query == true) {
2247 ret = system_settings_feature_check_bool(SETTING_WIFI_PATH);
2248 first_query = false;
2254 int system_setting_feature_check_telephony(void * value)
2256 static bool first_query = true;
2257 static int ret = SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED;
2259 if (first_query == true) {
2260 ret = system_settings_feature_check_bool(SETTING_TELEPHONY_PATH);
2261 first_query = false;
2267 /* LCOV_EXCL_START */
2268 int system_setting_get_uds_state(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
2270 int ** p_value = (int**)value;
2272 char *vconf_string_value = NULL;
2274 if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_UDSM, &vconf_value)) {
2275 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2278 SETTING_TRACE("[%s] udsm: %d", __FUNCTION__, vconf_value);
2280 if (vconf_value == SYSTEM_SETTINGS_UDS_ON) {
2281 if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_UDSM_PKGID_LIST, &vconf_string_value))
2282 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2284 if (vconf_string_value) {
2285 if (!strcmp(vconf_string_value, "NONE")) {
2286 vconf_value = SYSTEM_SETTINGS_UDS_ON;
2288 char *app_id = NULL;
2289 char *package_id = NULL;
2290 pid_t pid = getpid();
2291 app_manager_get_app_id(pid, &app_id);
2294 package_manager_get_package_id_by_app_id(app_id, &package_id);
2295 SETTING_TRACE("[%s] udsm_pkg_list : %s", __FUNCTION__, vconf_string_value);
2298 if (package_id && strstr(vconf_string_value, package_id)) {
2299 vconf_value = SYSTEM_SETTINGS_UDS_ON_WHITELISTED;
2300 SETTING_TRACE("[%s] pkg id : %s", __FUNCTION__, package_id);
2302 vconf_value = SYSTEM_SETTINGS_UDS_ON;
2306 if (vconf_string_value)
2307 free(vconf_string_value);
2311 **p_value = vconf_value;
2314 return SYSTEM_SETTINGS_ERROR_NONE;
2316 /* LCOV_EXCL_STOP */
2318 /* LCOV_EXCL_START */
2319 int system_setting_set_changed_callback_uds_state(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
2321 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_UDSM, SYSTEM_SETTINGS_KEY_ULTRA_DATA_SAVE, 4, user_data);
2323 /* LCOV_EXCL_STOP */
2325 /* LCOV_EXCL_START */
2326 int system_setting_unset_changed_callback_uds_state(system_settings_key_e key)
2328 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_UDSM, 4);
2330 /* LCOV_EXCL_STOP */
2332 /* LCOV_EXCL_START */
2333 int system_setting_set_changed_callback_uds_pkg_list(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
2335 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_UDSM_PKGID_LIST, SYSTEM_SETTINGS_KEY_ULTRA_DATA_SAVE_PKG_LIST, 4, user_data);
2337 /* LCOV_EXCL_STOP */
2339 /* LCOV_EXCL_START */
2340 int system_setting_unset_changed_callback_uds_pkg_list(system_settings_key_e key)
2342 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_UDSM_PKGID_LIST, 4);
2344 /* LCOV_EXCL_STOP */
2346 /* SYSTEM_SETTINGS_KEY_ACCESSIBILITY_TTS */
2347 int system_setting_get_accessibility_tts(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
2349 SETTING_TRACE_BEGIN;
2352 int ret = system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_ACCESSIBILITY_TTS, &vconf_value);
2353 if (ret != SYSTEM_SETTINGS_ERROR_NONE) {
2356 *value = (void *)vconf_value;
2360 int system_setting_set_changed_callback_accessibility_tts(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
2362 SETTING_TRACE_BEGIN;
2363 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_TTS, SYSTEM_SETTINGS_KEY_ACCESSIBILITY_TTS, 2, user_data);
2366 int system_setting_unset_changed_callback_accessibility_tts(system_settings_key_e key)
2368 SETTING_TRACE_BEGIN;
2369 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_TTS, 2);
2372 /* SYSTEM_SETTINGS_KEY_VIBRATION */
2373 int system_setting_get_vibration(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
2375 SETTING_TRACE_BEGIN;
2378 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, &vconf_value)) {
2379 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2381 *value = (void *)vconf_value;
2383 return SYSTEM_SETTINGS_ERROR_NONE;
2386 /* LCOV_EXCL_START */
2387 int system_setting_set_vibration(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
2389 SETTING_TRACE_BEGIN;
2391 vconf_value = (bool *)value;
2392 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, *vconf_value)) {
2393 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2396 return SYSTEM_SETTINGS_ERROR_NONE;
2398 /* LCOV_EXCL_STOP */
2400 int system_setting_set_changed_callback_vibration(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
2402 SETTING_TRACE_BEGIN;
2403 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, SYSTEM_SETTINGS_KEY_VIBRATION, 2, user_data);
2406 int system_setting_unset_changed_callback_vibration(system_settings_key_e key)
2408 SETTING_TRACE_BEGIN;
2409 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, 2);