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_font_info(char *str);
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_font_info("default");
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 = dl_get_font_info("cur");
205 *value = (void *)font_name;
207 return SYSTEM_SETTINGS_ERROR_NONE;
211 int system_setting_get_motion_activation(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
216 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_MOTION_ACTIVATION, &vconf_value)) {
217 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
219 *value = (void *)vconf_value;
221 return SYSTEM_SETTINGS_ERROR_NONE;
224 int system_setting_get_usb_debugging_option(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
229 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_USB_DEBUG_MODE_BOOL, &vconf_value)) {
230 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
232 *value = (void *)vconf_value;
234 return SYSTEM_SETTINGS_ERROR_NONE;
237 int system_setting_get_3g_data_network(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
242 if (system_setting_vconf_get_value_bool(VCONFKEY_3G_ENABLE, &vconf_value)) {
243 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
245 *value = (void *)vconf_value;
247 return SYSTEM_SETTINGS_ERROR_NONE;
249 /*////////////////////////////////////////////////////////////////////////////////////////////////// */
253 * get current lock scren app package name (string)
255 * @return SYSTEM_SETTINGS_ERROR_LOCKSCREEN_APP_PASSWORD_MODE raise exception if current lock type is 'password'
257 int system_setting_get_lockscreen_app(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
260 char *pkg_name = NULL;
262 system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_SCREEN_LOCK_TYPE_INT, &locktype);
264 if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_3RD_LOCK_PKG_NAME_STR, &pkg_name)) {
265 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
268 if (pkg_name && strcmp(pkg_name, "com.samsung.lockscreen") == 0 && locktype == SETTING_SCREEN_LOCK_TYPE_PASSWORD) {
269 return SYSTEM_SETTINGS_ERROR_LOCKSCREEN_APP_PASSWORD_MODE;
273 return SYSTEM_SETTINGS_ERROR_NONE;
277 /*////////////////////////////////////////////////////////////////////////////////////////////////// */
279 int _is_file_accessible(const char *path)
282 int ret = access(path , R_OK);
284 SETTING_TRACE("found the file %s", path);
287 /* error code : 13 */
288 SETTING_TRACE("found the file %s --- error code : %d ", path, errno);
295 /*////////////////////////////////////////////////////////////////////////////////////////////////// */
296 // @todo move to CMake
297 #define DEF_RINGTONE_FILE_PATH SETTING_DEF_RES"/Ringtones"
299 #define USR_RINGTONE_FILE_PATH "/home/owner/content/Sounds/Ringtones"
300 #define JSONFILE "/opt/home/owner/apps_rw/org.tizen.setting/data/.user-ringtones.json"
303 static char* _get_json_file_path()
310 int system_setting_add_incoming_call_ringtone(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
313 char* pathval = (char*)value;
317 JsonParser *parser = ss_json_ringtone_open_file(JSONFILE);
319 JsonParser *parser = ss_json_ringtone_load_from_data();
322 JsonNode *root = json_parser_get_root(parser);
326 int ret = SYSTEM_SETTINGS_ERROR_NONE;
327 if (false == ss_json_ringtone_contain(root, pathval)) {
328 SETTING_TRACE("---> dirname is : %s ", dirname(strdup(pathval)));
329 SETTING_TRACE("---> basename is : %s ", basename(strdup(pathval)));
330 // @todo : MAKE SURE THE ACTUAL FILE IS THERE ON PATHVAL(SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER)
331 ss_json_ringtone_add(root, JSONFILE, pathval, pathval);
332 SETTING_TRACE("pathval is : %s -- OK", pathval);
334 SETTING_TRACE("pathval is duplicated : %s", pathval);
335 SETTING_TRACE("---> dirname is : %s ", dirname(strdup(pathval)));
336 SETTING_TRACE("---> basename is : %s ", basename(strdup(pathval)));
337 ret = SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
341 g_object_unref(parser);
348 int system_setting_del_incoming_call_ringtone(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
351 char* pathval = (char*)value;
354 JsonParser* parser = ss_json_ringtone_open_file(JSONFILE);
356 JsonParser* parser = ss_json_ringtone_load_from_data();
358 JsonNode *root = json_parser_get_root(parser);
360 ss_json_ringtone_remove(root, JSONFILE, pathval);
361 //void ss_json_ringtone_remove(JsonNode *root, char* filename, char* path_to_del)
363 ss_json_ringtone_print(root);
365 g_object_unref(parser);
369 return SYSTEM_SETTINGS_ERROR_NONE;
373 static int _compare_cb(const void *d1, const void *d2)
375 fileNodeInfo *pNode1 = (fileNodeInfo *)d1;
376 fileNodeInfo *pNode2 = (fileNodeInfo *)d2;
378 return strcmp(pNode1->media_name, pNode2->media_name);
382 * get the RINGTONE list
384 static void _get_default_ringtones(system_settings_key_e key, system_setting_data_type_e data_type, system_settings_iter_cb callback, void *data)
388 Eina_List *filelist = NULL;
390 fileNodeInfo *node = NULL;
393 //-----------------------------------------------------------------------------------------------------------------
394 // 1. get the default ringtone list
395 //-----------------------------------------------------------------------------------------------------------------
396 int ret = get_filelist_from_dir_path(DEF_RINGTONE_FILE_PATH, &filelist);
398 SETTING_TRACE("Failed to get filelist, ret = %d %s", ret, DEF_RINGTONE_FILE_PATH);
400 filelist = eina_list_sort(filelist, eina_list_count(filelist), _compare_cb);
402 EINA_LIST_FOREACH(filelist, l, node)
404 SETTING_TRACE("file path = (%d) : name:%s path:%s [%s]", ret, node->name, node->path, node->media_name);
405 // @todo assert NULL check
408 snprintf(temp, 1024, "%s/%s", node->path, node->name);
409 char* path = strdup(temp);
410 bool ret = callback(idx, (void *)(path), data);
416 SETTING_TRACE("quit the iteration by return value == false : %d", ret);
421 SETTING_TRACE("--> system_setting_data_iterator is NULL");
427 EINA_LIST_FOREACH(filelist, l, node)
431 FREE(node->media_name);
434 eina_list_free(filelist);
439 static void _get_user_ringtones(system_settings_key_e key, system_setting_data_type_e data_type, system_settings_iter_cb callback, void *data)
445 JsonParser* parser = ss_json_ringtone_open_file(JSONFILE);
447 JsonParser* parser = ss_json_ringtone_load_from_data();
450 JsonNode *root = json_parser_get_root(parser);
451 int size = json_array_get_length(json_node_get_array(root));
454 for (i = 0; i < size ; i++) {
455 JsonObject *ringtone = json_array_get_object_element(json_node_get_array(root), i);
456 char *nameval = (char *)json_object_get_string_member(ringtone, "name");
457 char *pathval = (char *)json_object_get_string_member(ringtone, "path");
458 SETTING_TRACE("(%s) --- (%s) \n", nameval, pathval);
460 char* path = strdup(pathval);
461 bool ret = callback(i, (void *)(path), data);
463 SETTING_TRACE("quit the iteration by return value == false : %d", ret);
467 SETTING_TRACE("--> callback is NULL");
472 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)
476 _get_default_ringtones(key, data_type, callback, data);
477 //-----------------------------------------------------------------------------------------------------------------
478 // 2. get the USER ringtone list
479 //-----------------------------------------------------------------------------------------------------------------
480 _get_user_ringtones(key, data_type, callback, data);
482 return SYSTEM_SETTINGS_ERROR_NONE;
486 /* LCOV_EXCL_START */
487 int system_setting_set_incoming_call_ringtone(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
491 vconf_value = (char *)value;
493 int ret = _is_file_accessible(vconf_value);
495 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR, vconf_value)) {
496 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
499 /* @todo add a common ret_handler */
503 return SYSTEM_SETTINGS_ERROR_NONE;
508 /* LCOV_EXCL_START */
509 int system_setting_set_email_alert_ringtone(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
513 vconf_value = (char *)value;
515 int ret = _is_file_accessible(vconf_value);
517 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, vconf_value)) {
518 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
521 /*return SYSTEM_SETTINGS_ERROR_IO_ERROR;*/
522 /* @todo add a common ret_handler */
526 return SYSTEM_SETTINGS_ERROR_NONE;
530 /* LCOV_EXCL_START */
531 static bool dl_is_supported_image_type_load(char *path)
536 bool (*image_type_check)(char *path);
538 handle = dlopen(SETTING_UTILS_SO_FILE_PATH, RTLD_LAZY);
540 SETTING_TRACE("ERROR!! canNOT find libsystem-settings-util.so.0.1.0");
544 image_type_check = dlsym(handle, "__is_supported_image_type_load");
545 if ((error = dlerror()) != NULL) {
546 SETTING_TRACE("ERROR!! canNOT find __is_supported_image_type_load function at libsystem-settings-util.so.0.1.0");
551 ret = image_type_check(path);
558 /* LCOV_EXCL_START */
559 static int dl_is_available_font(char *str)
564 int (*check_available_font)(char *font_name);
566 handle = dlopen(SETTING_UTILS_SO_FILE_PATH, RTLD_LAZY);
568 SETTING_TRACE("ERROR!! canNOT find libsystem-settings-util.so.0.1.0");
572 check_available_font = dlsym(handle, "__is_available_font");
573 if ((error = dlerror()) != NULL) {
574 SETTING_TRACE("ERROR!! canNOT find __is_available_font function at libsystem-settings-util.so.0.1.0");
579 ret = check_available_font(str);
586 /* LCOV_EXCL_START */
587 static void dl_font_size_set()
591 void (*set_font_size)();
593 handle = dlopen(SETTING_UTILS_SO_FILE_PATH, RTLD_LAZY);
595 SETTING_TRACE("ERROR!! canNOT find libsystem-settings-util.so.0.1.0");
599 set_font_size = dlsym(handle, "__font_size_set");
600 if ((error = dlerror()) != NULL) {
601 SETTING_TRACE("ERROR!! canNOT find __font_size_set function at libsystem-settings-util.so.0.1.0");
613 /* LCOV_EXCL_START */
614 static void dl_font_config_set_notification()
618 void (*set_font_nodification)();
620 handle = dlopen(SETTING_UTILS_SO_FILE_PATH, RTLD_LAZY);
622 SETTING_TRACE("ERROR!! canNOT find libsystem-settings-util.so.0.1.0");
626 set_font_nodification = dlsym(handle, "font_config_set_notification");
627 if ((error = dlerror()) != NULL) {
628 SETTING_TRACE("ERROR!! canNOT find font_config_set_notification function at libsystem-settings-util.so.0.1.0");
633 set_font_nodification();
640 /* LCOV_EXCL_START */
641 static bool dl_font_config_set(char *font_name)
646 bool (*check_font_type)(char *font_name);
648 handle = dlopen(SETTING_UTILS_SO_FILE_PATH, RTLD_LAZY);
650 SETTING_TRACE("ERROR!! canNOT find libsystem-settings-util.so.0.1.0");
654 check_font_type = dlsym(handle, "font_config_set");
655 if ((error = dlerror()) != NULL) {
656 SETTING_TRACE("ERROR!! canNOT find font_config_set function at libsystem-settings-util.so.0.1.0");
661 ret = check_font_type(font_name);
668 /* LCOV_EXCL_START */
669 static char *dl_get_font_info(char *str)
674 char *(*get_font_info)();
676 handle = dlopen(SETTING_UTILS_SO_FILE_PATH, RTLD_LAZY);
678 SETTING_TRACE("ERROR!! canNOT find libsystem-settings-util.so.0.1.0");
682 if (strcmp(str, "cur") == 0)
683 get_font_info = dlsym(handle, "_get_cur_font");
685 get_font_info = dlsym(handle, "_get_default_font");
687 if ((error = dlerror()) != NULL) {
688 SETTING_TRACE("ERROR!! canNOT find %s function at libsystem-settings-util.so.0.1.0", str);
693 ret = get_font_info();
700 /* LCOV_EXCL_START */
701 #define PATH_EXT_CHECK_REG ".(jpe?g|jpg|png|gif)$"
702 bool __is_supported_image_type_by_ext(char *file_path)
706 regmatch_t str[2048 + 1];
708 if (!file_path) return false;
711 if ((ret = regcomp(&fsm, PATH_EXT_CHECK_REG, REG_ICASE | REG_EXTENDED))) {
712 SETTING_TRACE("regular expresstion fail");
717 if (regexec(&fsm, file_path, strlen(file_path) + 1, str, 0) == REG_NOMATCH) {
718 /*SETTING_TRACE("FAILED - %s", file_path[i]); */
721 /*SETTING_TRACE("MATCHED - %s", file_path[i]); */
727 #ifdef TIZEN_WEARABLE
728 /* LCOV_EXCL_START */
729 static int system_setting_get_extended_wallpaper_num(const char *file_path, unsigned int *num)
733 const char *find_str = "extended_wallpaper_";
736 if (!(ch = strstr(file_path, find_str))) {
737 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
739 strncpy(buffer, file_path, ch - file_path);
740 buffer[ch - file_path] = 0;
741 sprintf(buffer + (ch - file_path), "%s%s", "", ch + strlen(find_str));
743 if (!isdigit(buffer[0])) {
744 SETTING_TRACE("%s is not number", buffer);
745 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
750 return SYSTEM_SETTINGS_ERROR_NONE;
754 /* LCOV_EXCL_START */
755 static int system_setting_copy_extended_wallpaper(const char *dest_file_path, const char *source_file_path)
758 if (!source_file_path || !dest_file_path) {
759 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
765 fd = open(source_file_path, O_RDONLY);
767 SETTING_TRACE("file open failed: %s", source_file_path);
768 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
772 fd2 = open(dest_file_path, O_WRONLY | O_CREAT, S_IRWXU | S_IRWXG | S_IRWXO);
774 SETTING_TRACE("file creation failed: %s", dest_file_path);
776 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
779 while (read(fd, buf, sizeof(buf) - 1) > 0) {
780 write(fd2, buf, sizeof(buf) - 1);
786 if (chmod(dest_file_path, S_IRWXU | S_IRWXG | S_IRWXO) < 0) {
787 SETTING_TRACE("chmod failed: %s", dest_file_path);
790 return SYSTEM_SETTINGS_ERROR_NONE;
794 /* LCOV_EXCL_START */
795 static int system_setting_remove_oldest_extended_wallpaper()
800 char *min_image_name = NULL;
801 unsigned int min_image_num = 0;
802 unsigned int temp_image_num = 0;
805 if ((dp = opendir(_TZ_SYS_DATA"/setting/wallpaper")) == NULL) {
806 SETTING_TRACE("opendir error");
807 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
810 while ((dirp = readdir(dp))) {
811 if (!strcmp(dirp->d_name, ".") || !strcmp(dirp->d_name, ".."))
814 if (system_setting_get_extended_wallpaper_num(dirp->d_name, &temp_image_num)
815 != SYSTEM_SETTINGS_ERROR_NONE) {
816 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
819 if ((image_count == 0) || (min_image_num > temp_image_num)) {
820 min_image_num = temp_image_num;
821 min_image_name = dirp->d_name;
828 if (min_image_name) {
829 snprintf(buf, sizeof(buf) - 1, _TZ_SYS_DATA"/setting/wallpaper/%s", min_image_name);
830 if (remove(buf) < 0) { /* remove oldest image */
831 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
835 return SYSTEM_SETTINGS_ERROR_NONE;
839 /* LCOV_EXCL_START */
840 static int system_setting_check_extended_wallpaper(const char *file_path)
844 if (!file_path || !strlen(file_path))
846 snprintf(buffer, 512, "%s/.bgwallpaper", tzplatform_getenv(TZ_USER_CONTENT));
847 return (strstr(file_path, buffer) != NULL);
851 #define WALLPAPER_MAX_COUNT 10
853 /* LCOV_EXCL_START */
854 int system_setting_set_wallpaper_home_screen(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
858 vconf_value = (char *)value;
860 bool isok = dl_is_supported_image_type_load(vconf_value);
863 SETTING_TRACE("path : %s is not supported file format", vconf_value);
864 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
866 SETTING_TRACE("path : %s is SUPPORT file format", vconf_value);
869 /* error handling here */
870 if (_is_file_accessible(vconf_value) != 0)
871 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
873 if (system_setting_vconf_set_value_string(VCONFKEY_BGSET, vconf_value)) {
874 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
878 #ifdef TIZEN_WEARABLE
879 if (system_setting_check_extended_wallpaper(vconf_value)) { /* New extended wallpaper */
882 unsigned int max_image_num = 0;
883 unsigned int temp_image_num = 0;
886 if ((dp = opendir(_TZ_SYS_DATA"/setting/wallpaper")) == NULL) {
887 SETTING_TRACE("Setting - dir open error!");
888 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
891 /* Check a max number of wallpapers */
892 while ((dirp = readdir(dp))) {
893 if (!strcmp(dirp->d_name, ".") || !strcmp(dirp->d_name, ".."))
896 if (system_setting_get_extended_wallpaper_num(dirp->d_name, &temp_image_num)
897 != SYSTEM_SETTINGS_ERROR_NONE) {
900 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
903 if ((image_count == 0) || (max_image_num < temp_image_num)) {
904 max_image_num = temp_image_num;
912 /* Numbering rule: Gear is odd number */
913 max_image_num = (max_image_num % 2 == 0) ? max_image_num + 1
916 char file_name_buffer[512];
917 snprintf(file_name_buffer, sizeof(file_name_buffer) - 1,
918 _TZ_SYS_DATA"/setting/wallpaper/extended_wallpaper_%d.jpg", max_image_num);
920 /* Copy image to _TZ_SYS_DATA/setting/wallpaper/ */
921 if (system_setting_copy_extended_wallpaper(file_name_buffer, vconf_value)
922 != SYSTEM_SETTINGS_ERROR_NONE) {
923 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
926 /* remove oldest wallpaper */
927 if (image_count >= WALLPAPER_MAX_COUNT) {
928 if (system_setting_remove_oldest_extended_wallpaper()
929 != SYSTEM_SETTINGS_ERROR_NONE) {
930 remove(file_name_buffer);
931 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
935 if (system_setting_vconf_set_value_string(VCONFKEY_BGSET, file_name_buffer)) {
936 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
939 if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_WALLPAPER_CHANGED_NOTI_INT,
940 VCONFKEY_WALLPAPER_CHANGED_NOTI_GEAR)) {
941 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
944 if (system_setting_vconf_set_value_string(VCONFKEY_BGSET, vconf_value)) {
945 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
950 return SYSTEM_SETTINGS_ERROR_NONE;
954 /* LCOV_EXCL_START */
955 int system_setting_set_wallpaper_lock_screen(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
959 vconf_value = (char *)value;
961 bool isok = dl_is_supported_image_type_load(vconf_value);
964 SETTING_TRACE("path : %s is not supported file format", vconf_value);
965 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
967 SETTING_TRACE("path : %s is SUPPORT file format", vconf_value);
970 /* error handling here */
971 if (_is_file_accessible(vconf_value) != 0)
972 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
974 if (system_setting_vconf_set_value_string(VCONFKEY_IDLE_LOCK_BGSET, vconf_value)) {
975 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
978 return SYSTEM_SETTINGS_ERROR_NONE;
982 /* LCOV_EXCL_START */
983 int system_setting_set_font_size(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
987 vconf_value = *(int **)value;
989 if (*vconf_value < 0 || *vconf_value > SYSTEM_SETTINGS_FONT_SIZE_GIANT) {
990 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
993 if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, *vconf_value)) {
994 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
998 return SYSTEM_SETTINGS_ERROR_NONE;
1000 /* LCOV_EXCL_STOP */
1004 /* LCOV_EXCL_START */
1005 void *font_conf_doc_parse(char *doc_name, char *font_name)
1007 SETTING_TRACE_BEGIN;
1008 xmlDocPtr doc = NULL;
1009 xmlNodePtr cur = NULL;
1010 xmlNodePtr cur2 = NULL;
1011 xmlNodePtr cur3 = NULL;
1012 xmlChar *key = NULL;
1014 doc = xmlParseFile(doc_name);
1016 cur = xmlDocGetRootElement(doc);
1024 if (xmlStrcmp(cur->name, (const xmlChar *)"fontconfig")) {
1030 cur = cur->xmlChildrenNode;
1032 bool is_changed = false;
1033 while (cur != NULL) {
1034 if ((!xmlStrcmp(cur->name, (const xmlChar *)"match"))) {
1035 cur2 = cur->xmlChildrenNode;
1036 while (cur2 != NULL) {
1037 if ((!xmlStrcmp(cur2->name, (const xmlChar *)"edit"))) {
1038 xmlChar *name = xmlGetProp(cur2, (const xmlChar *)"name");
1039 /* if name is not 'family', break */
1040 if (xmlStrcmp(name, (const xmlChar *)"family")) {
1048 cur3 = cur2->xmlChildrenNode;
1049 while (cur3 != NULL) {
1050 if ((!xmlStrcmp(cur3->name, (const xmlChar *)"string"))) {
1051 xmlNodeSetContent(cur3->xmlChildrenNode, (const xmlChar *)font_name);
1052 key = xmlNodeListGetString(doc, cur3->xmlChildrenNode, 1);
1062 } else if ((!xmlStrcmp(cur->name, (const xmlChar *)"alias"))) {
1063 cur2 = cur->xmlChildrenNode;
1064 while (cur2 != NULL) {
1065 if ((!xmlStrcmp(cur2->name, (const xmlChar *)"family"))) {
1066 xmlNodeSetContent(cur2->xmlChildrenNode, (const xmlChar *)font_name);
1067 key = xmlNodeListGetString(doc, cur2->xmlChildrenNode, 1);
1071 } else if ((!xmlStrcmp(cur2->name, (const xmlChar *)"prefer"))) {
1072 cur3 = cur2->xmlChildrenNode;
1073 while (cur3 != NULL) {
1074 if ((!xmlStrcmp(cur3->name, (const xmlChar *)"family"))) {
1075 xmlNodeSetContent(cur3->xmlChildrenNode, (const xmlChar *)font_name);
1076 key = xmlNodeListGetString(doc, cur3->xmlChildrenNode, 1);
1100 /* LCOV_EXCL_STOP */
1102 /* LCOV_EXCL_START */
1103 int system_setting_set_font_type(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1105 SETTING_TRACE_BEGIN;
1106 char *font_name = NULL;
1107 font_name = (char *)value;
1109 /* get current font list */
1110 int is_found = dl_is_available_font(font_name);
1113 SETTING_TRACE("found font : %s ", font_name);
1115 SETTING_TRACE(" NOT found font : %s ", font_name);
1116 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1119 bool bsave = dl_font_config_set(font_name);
1122 SETTING_TRACE(" font type save error by font_config_set() ");
1123 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1125 SETTING_TRACE(" save OK - font_config_set() ");
1128 xmlDocPtr doc = (xmlDocPtr)font_conf_doc_parse(SETTING_FONT_CONF_FILE, font_name);
1130 xmlSaveFormatFile(SETTING_FONT_CONF_FILE, doc, 0);
1135 dl_font_config_set_notification();
1138 vconf_value = (char *)value;
1140 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, vconf_value)) {
1141 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1143 return SYSTEM_SETTINGS_ERROR_NONE;
1145 /* LCOV_EXCL_STOP */
1147 /* LCOV_EXCL_START */
1148 int system_setting_set_motion_activation(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1150 SETTING_TRACE_BEGIN;
1152 vconf_value = (bool *)value;
1153 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_MOTION_ACTIVATION, *vconf_value)) {
1154 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1156 return SYSTEM_SETTINGS_ERROR_NONE;
1158 /* LCOV_EXCL_STOP */
1160 /* LCOV_EXCL_START */
1161 int system_setting_set_usb_debugging_option(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1163 SETTING_TRACE_BEGIN;
1165 vconf_value = (bool *)value;
1166 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_USB_DEBUG_MODE_BOOL, *vconf_value)) {
1167 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1169 return SYSTEM_SETTINGS_ERROR_NONE;
1172 /* LCOV_EXCL_STOP */
1174 /* LCOV_EXCL_START */
1175 int system_setting_set_3g_data_network(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1177 SETTING_TRACE_BEGIN;
1179 vconf_value = (bool *)value;
1180 if (system_setting_vconf_set_value_bool(VCONFKEY_3G_ENABLE, *vconf_value)) {
1181 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1184 return SYSTEM_SETTINGS_ERROR_NONE;
1186 /* LCOV_EXCL_STOP */
1188 /* LCOV_EXCL_START */
1189 static int category_func(const char *name, void *user_data)
1191 SETTING_TRACE_BEGIN;
1192 static char *category = "lock-screen";
1193 if (name && !strcmp(name, category)) {
1194 SETTING_TRACE(" SAME ");
1197 SETTING_TRACE(" DIFFERENT -- %s, category -- %s ", name, category);
1203 /* LCOV_EXCL_STOP */
1207 * set 'swipe type' if current lockscreen app is 'com.samsung.lockscreen'
1211 /* LCOV_EXCL_START */
1212 int system_setting_set_lockscreen_app(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1214 SETTING_TRACE_BEGIN;
1216 vconf_value = (char *)value; /* ex) com.samsung.lockscreen */
1219 pkgmgrinfo_appinfo_h handle;
1220 r = pkgmgrinfo_appinfo_get_appinfo(vconf_value, &handle);
1221 if (r != PMINFO_R_OK) {
1222 SETTING_TRACE("*** pkginfo failed ");
1223 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
1225 SETTING_TRACE("%x", handle);
1228 int ret = pkgmgrinfo_appinfo_foreach_category(handle, category_func, (void *)"lock-screen");
1229 if (ret != PMINFO_R_OK) {
1230 pkgmgrinfo_appinfo_destroy_appinfo(handle);
1231 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
1234 pkgmgrinfo_appinfo_destroy_appinfo(handle);
1235 /*----------------------------------------------------------------------------------- */
1237 if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_SCREEN_LOCK_TYPE_INT, &locktype)) {
1238 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1241 if (locktype == SETTING_SCREEN_LOCK_TYPE_PASSWORD)
1242 return SYSTEM_SETTINGS_ERROR_LOCKSCREEN_APP_PASSWORD_MODE;
1244 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_3RD_LOCK_PKG_NAME_STR, vconf_value)) {
1245 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1248 if (vconf_value && strcmp(vconf_value, "com.samsung.lockscreen") == 0) {
1249 if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_SCREEN_LOCK_TYPE_INT, SETTING_SCREEN_LOCK_TYPE_SWIPE)) {
1250 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1253 return SYSTEM_SETTINGS_ERROR_NONE;
1255 /* LCOV_EXCL_STOP */
1257 /*/////////////////////////////////////////////////////////////////////////////////////////////// */
1260 int system_setting_set_changed_callback_incoming_call_ringtone(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1262 SETTING_TRACE_BEGIN;
1263 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR, SYSTEM_SETTINGS_KEY_INCOMING_CALL_RINGTONE, 0, user_data);
1266 int system_setting_unset_changed_callback_incoming_call_ringtone(system_settings_key_e key)
1268 SETTING_TRACE_BEGIN;
1269 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR, 0);
1272 int system_setting_set_changed_callback_email_alert_ringtone(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1274 SETTING_TRACE_BEGIN;
1275 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, SYSTEM_SETTINGS_KEY_EMAIL_ALERT_RINGTONE, 0, user_data);
1278 int system_setting_unset_changed_callback_email_alert_ringtone(system_settings_key_e key)
1280 SETTING_TRACE_BEGIN;
1281 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, 0);
1284 int system_setting_set_changed_callback_wallpaper_home_screen(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1286 SETTING_TRACE_BEGIN;
1287 return system_setting_vconf_set_changed_cb(VCONFKEY_BGSET, SYSTEM_SETTINGS_KEY_WALLPAPER_HOME_SCREEN, 0, user_data);
1290 int system_setting_unset_changed_callback_wallpaper_home_screen(system_settings_key_e key)
1292 SETTING_TRACE_BEGIN;
1293 return system_setting_vconf_unset_changed_cb(VCONFKEY_BGSET, 0);
1296 int system_setting_set_changed_callback_wallpaper_lock_screen(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1298 SETTING_TRACE_BEGIN;
1299 return system_setting_vconf_set_changed_cb(VCONFKEY_IDLE_LOCK_BGSET, SYSTEM_SETTINGS_KEY_WALLPAPER_LOCK_SCREEN, 0, user_data);
1302 int system_setting_unset_changed_callback_wallpaper_lock_screen(system_settings_key_e key)
1304 SETTING_TRACE_BEGIN;
1305 return system_setting_vconf_unset_changed_cb(VCONFKEY_IDLE_LOCK_BGSET, 0);
1308 int system_setting_set_changed_callback_font_size(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1310 SETTING_TRACE_BEGIN;
1311 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, SYSTEM_SETTINGS_KEY_FONT_SIZE, 1, user_data);
1314 int system_setting_unset_changed_callback_font_size(system_settings_key_e key)
1316 SETTING_TRACE_BEGIN;
1317 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, 1);
1320 int system_setting_set_changed_callback_usb_debugging_option(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1322 SETTING_TRACE_BEGIN;
1323 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_USB_DEBUG_MODE_BOOL, SYSTEM_SETTINGS_KEY_USB_DEBUGGING_ENABLED, 1, user_data);
1326 int system_setting_unset_changed_callback_usb_debugging_option(system_settings_key_e key)
1328 SETTING_TRACE_BEGIN;
1329 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_USB_DEBUG_MODE_BOOL, 1);
1332 int system_setting_set_changed_callback_3g_data_network(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1334 SETTING_TRACE_BEGIN;
1335 return system_setting_vconf_set_changed_cb(VCONFKEY_3G_ENABLE, SYSTEM_SETTINGS_KEY_3G_DATA_NETWORK_ENABLED, 1, user_data);
1338 int system_setting_unset_changed_callback_3g_data_network(system_settings_key_e key)
1340 SETTING_TRACE_BEGIN;
1341 return system_setting_vconf_unset_changed_cb(VCONFKEY_3G_ENABLE, 1);
1344 int system_setting_set_changed_callback_lockscreen_app(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1346 SETTING_TRACE_BEGIN;
1347 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_3RD_LOCK_PKG_NAME_STR, SYSTEM_SETTINGS_KEY_LOCKSCREEN_APP, 1, user_data);
1350 int system_setting_unset_changed_callback_lockscreen_app(system_settings_key_e key)
1352 SETTING_TRACE_BEGIN;
1353 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_3RD_LOCK_PKG_NAME_STR, 1);
1358 * @todo need to add custom event notification method
1360 int system_setting_set_changed_callback_font_type(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1362 SETTING_TRACE_BEGIN;
1363 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, SYSTEM_SETTINGS_KEY_FONT_TYPE, 2, user_data);
1366 int system_setting_unset_changed_callback_font_type(system_settings_key_e key)
1368 SETTING_TRACE_BEGIN;
1369 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, 2);
1372 /* TODO : 2th argument, callback, is not in use. */
1373 int system_setting_set_changed_callback_motion_activation(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1375 SETTING_TRACE_BEGIN;
1376 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_MOTION_ACTIVATION, SYSTEM_SETTINGS_KEY_MOTION_ACTIVATION, 3, user_data);
1379 int system_setting_unset_changed_callback_motion_activation(system_settings_key_e key)
1381 SETTING_TRACE_BEGIN;
1382 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_MOTION_ACTIVATION, 3);
1385 /*//////////////////////////////////////////////////////////////////////////////////////// */
1386 /*--------------------------------------- */
1387 int system_setting_get_locale_country(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1389 SETTING_TRACE_BEGIN;
1390 char *vconf_value = NULL;
1391 if (system_setting_vconf_get_value_string(VCONFKEY_REGIONFORMAT, &vconf_value)) {
1392 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1395 /* parsing validation */
1398 snprintf(arr, 20, "%s", vconf_value);
1400 *value = strdup(arr);
1404 return SYSTEM_SETTINGS_ERROR_NONE;
1407 /* LCOV_EXCL_START */
1408 int system_setting_set_locale_country(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1410 SETTING_TRACE_BEGIN;
1411 char *vconf_value = NULL;
1412 vconf_value = (char *)value;
1414 char *ext = "UTF-8";
1417 snprintf(arr, 20, "%s.%s", vconf_value, ext);
1419 if (system_setting_vconf_set_value_string(VCONFKEY_REGIONFORMAT, arr)) {
1420 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1422 return SYSTEM_SETTINGS_ERROR_NONE;
1424 /* LCOV_EXCL_STOP */
1426 int system_setting_set_changed_callback_locale_country(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1428 SETTING_TRACE_BEGIN;
1429 return system_setting_vconf_set_changed_cb(VCONFKEY_REGIONFORMAT, SYSTEM_SETTINGS_KEY_LOCALE_COUNTRY, 3, user_data);
1432 int system_setting_unset_changed_callback_locale_country(system_settings_key_e key)
1434 SETTING_TRACE_BEGIN;
1435 return system_setting_vconf_unset_changed_cb(VCONFKEY_REGIONFORMAT, 3);
1439 /*--------------------------------------- */
1440 int system_setting_get_locale_language(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1442 SETTING_TRACE_BEGIN;
1443 char *vconf_value = NULL;
1444 if (system_setting_vconf_get_value_string(VCONFKEY_LANGSET, &vconf_value)) {
1445 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1448 /* parsing validation */
1451 snprintf(arr, 20, "%s", vconf_value);
1453 *value = strdup(arr);
1456 return SYSTEM_SETTINGS_ERROR_NONE;
1459 /* LCOV_EXCL_START */
1460 int system_setting_set_locale_language(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1462 SETTING_TRACE_BEGIN;
1463 char *vconf_value = NULL;
1464 vconf_value = (char *)value;
1466 char *ext = "UTF-8";
1469 snprintf(arr, 20, "%s.%s", vconf_value, ext);
1471 if (system_setting_vconf_set_value_string(VCONFKEY_LANGSET, arr)) {
1472 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1474 return SYSTEM_SETTINGS_ERROR_NONE;
1476 /* LCOV_EXCL_STOP */
1478 int system_setting_set_changed_callback_locale_language(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1480 SETTING_TRACE_BEGIN;
1481 /*return system_setting_vconf_set_changed_cb(VCONFKEY_LANGSET, SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, 3, user_data ); */
1482 return system_setting_vconf_set_changed_cb(VCONFKEY_LANGSET, SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, 100, user_data);
1485 int system_setting_unset_changed_callback_locale_language(system_settings_key_e key)
1487 SETTING_TRACE_BEGIN;
1488 return system_setting_vconf_unset_changed_cb(VCONFKEY_LANGSET, 100);
1491 /*--------------------------------------- */
1492 /* LCOV_EXCL_START */
1493 int system_setting_get_locale_timeformat_24hour(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1495 SETTING_TRACE_BEGIN;
1498 if (system_setting_vconf_get_value_int(VCONFKEY_REGIONFORMAT_TIME1224, &vconf_value)) {
1499 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1502 bool ret_value = true;
1503 if (vconf_value == VCONFKEY_TIME_FORMAT_12)
1505 else if (vconf_value == VCONFKEY_TIME_FORMAT_24)
1508 *value = (void *)ret_value;
1510 return SYSTEM_SETTINGS_ERROR_NONE;
1512 /* LCOV_EXCL_STOP */
1514 int system_setting_set_locale_timeformat_24hour(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1516 SETTING_TRACE_BEGIN;
1519 vconf_value = (bool *)value;
1522 if (system_setting_vconf_set_value_int(VCONFKEY_REGIONFORMAT_TIME1224, VCONFKEY_TIME_FORMAT_24)) {
1523 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1527 if (system_setting_vconf_set_value_int(VCONFKEY_REGIONFORMAT_TIME1224, VCONFKEY_TIME_FORMAT_12)) {
1528 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1533 return SYSTEM_SETTINGS_ERROR_NONE;
1536 int system_setting_set_changed_callback_locale_timeformat_24hour(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1538 SETTING_TRACE_BEGIN;
1539 return system_setting_vconf_set_changed_cb(VCONFKEY_REGIONFORMAT_TIME1224, SYSTEM_SETTINGS_KEY_LOCALE_TIMEFORMAT_24HOUR, 3, user_data);
1542 int system_setting_unset_changed_callback_locale_timeformat_24hour(system_settings_key_e key)
1544 SETTING_TRACE_BEGIN;
1545 return system_setting_vconf_unset_changed_cb(VCONFKEY_REGIONFORMAT_TIME1224, 3);
1548 int system_setting_get_locale_timezone(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1551 ssize_t len = readlink(SETTING_TZONE_SYMLINK_PATH, tzpath, sizeof(tzpath)-1);
1555 SETTING_TRACE("parse error for SETTING_TZONE_SYMLINK_PATH");
1556 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1559 SETTING_TRACE("tzpath : %s ", &tzpath[20]);
1560 *value = strdup(&tzpath[20]);
1561 return SYSTEM_SETTINGS_ERROR_NONE;
1564 /* LCOV_EXCL_START */
1565 int system_setting_set_locale_timezone(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1567 SETTING_TRACE_BEGIN;
1568 char *timezone_value = NULL;
1569 timezone_value = (char *)value;
1572 snprintf(tz_path, 1024, "/usr/share/zoneinfo/%s", timezone_value);
1574 int is_load = _is_file_accessible(tz_path);
1576 alarmmgr_set_timezone(tz_path);
1578 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_TIMEZONE_ID, timezone_value)) {
1579 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1581 return SYSTEM_SETTINGS_ERROR_NONE;
1583 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
1585 /* LCOV_EXCL_STOP */
1589 /* LCOV_EXCL_START */
1590 int system_setting_set_changed_callback_locale_timezone(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1592 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_TIMEZONE_ID, SYSTEM_SETTINGS_KEY_LOCALE_TIMEZONE, 4, user_data);
1594 /* LCOV_EXCL_STOP */
1596 /* LCOV_EXCL_START */
1597 int system_setting_unset_changed_callback_locale_timezone(system_settings_key_e key)
1599 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_TIMEZONE_ID, 4);
1601 /* LCOV_EXCL_STOP */
1603 /* LCOV_EXCL_START */
1604 int system_setting_set_changed_callback_locale_timezone_changed(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1606 SETTING_TRACE_BEGIN;
1607 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
1609 /* LCOV_EXCL_STOP */
1611 /* LCOV_EXCL_START */
1612 int system_setting_unset_changed_callback_locale_timezone_changed(system_settings_key_e key)
1614 SETTING_TRACE_BEGIN;
1615 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
1617 /* LCOV_EXCL_STOP */
1620 /* LCOV_EXCL_START */
1621 int system_setting_get_time_changed(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1623 SETTING_TRACE_BEGIN;
1625 int ** val = (int**)value;
1626 cur_tick = time(NULL);
1628 /* struct tm * localtime = time (cur_tick); */
1629 /* printf("%s\n", ctime(&cur_tick); */
1630 return SYSTEM_SETTINGS_ERROR_NONE;
1633 /* LCOV_EXCL_STOP */
1635 int system_setting_set_changed_callback_time_changed(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1637 SETTING_TRACE_BEGIN;
1638 return system_setting_vconf_set_changed_cb(VCONFKEY_SYSTEM_TIME_CHANGED, SYSTEM_SETTINGS_KEY_TIME_CHANGED, 3, user_data);
1641 int system_setting_unset_changed_callback_time_changed(system_settings_key_e key)
1643 SETTING_TRACE_BEGIN;
1644 return system_setting_vconf_unset_changed_cb(VCONFKEY_SYSTEM_TIME_CHANGED, 3);
1649 /* SYSTEM_SETTINGS_KEY_SOUND_LOCK */
1650 int system_setting_get_sound_lock(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1652 SETTING_TRACE_BEGIN;
1655 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_SOUND_LOCK_BOOL, &vconf_value)) {
1656 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1658 *value = (void *)vconf_value;
1660 return SYSTEM_SETTINGS_ERROR_NONE;
1663 int system_setting_set_changed_callback_sound_lock(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1665 SETTING_TRACE_BEGIN;
1666 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_SOUND_LOCK_BOOL, SYSTEM_SETTINGS_KEY_SOUND_LOCK, 3, user_data);
1669 int system_setting_unset_changed_callback_sound_lock(system_settings_key_e key)
1671 SETTING_TRACE_BEGIN;
1672 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_SOUND_LOCK_BOOL, 3);
1676 * a = VCONFKEY_SETAPPL_SOUND_STATUS_BOOL b = VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL
1678 * a == false, b == false --> silent mode
1679 * a == true, b == false --> sound mode
1680 * a == false, b == true --> vibration mode
1682 /* LCOV_EXCL_START */
1683 int system_setting_get_sound_silent_mode(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1685 SETTING_TRACE_BEGIN;
1690 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, &sound_cond)) {
1691 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1694 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, &vib_cond)) {
1695 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1698 if (sound_cond == false && vib_cond == false) {
1700 *value = (void *)vconf_value;
1702 vconf_value = false;
1703 *value = (void *)vconf_value;
1705 return SYSTEM_SETTINGS_ERROR_NONE;
1707 /* LCOV_EXCL_STOP */
1710 * a = VCONFKEY_SETAPPL_SOUND_STATUS_BOOL b = VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL
1712 * a == false, b == false --> silent mode
1713 * a == true, b == false --> sound mode
1715 int system_setting_set_sound_silent_mode(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1717 SETTING_TRACE_BEGIN;
1720 vconf_value = (bool *)value;
1722 bool vconf_sound = false;
1723 bool vconf_vib = false;
1726 vconf_sound = false;
1733 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, vconf_sound)) {
1734 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1736 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, vconf_vib)) {
1737 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1740 return SYSTEM_SETTINGS_ERROR_NONE;
1746 int system_setting_set_changed_callback_sound_silent_mode(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1748 SETTING_TRACE_BEGIN;
1749 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, SYSTEM_SETTINGS_KEY_SOUND_SILENT_MODE, 3, user_data);
1753 int system_setting_unset_changed_callback_sound_silent_mode(system_settings_key_e key)
1755 SETTING_TRACE_BEGIN;
1756 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, 3);
1759 /* SYSTEM_SETTINGS_KEY_SOUND_TOUCH */
1760 int system_setting_get_sound_touch(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1762 SETTING_TRACE_BEGIN;
1765 int ret = system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL, &vconf_value);
1766 if (ret != SYSTEM_SETTINGS_ERROR_NONE) {
1769 *value = (void *)vconf_value;
1773 int system_setting_set_changed_callback_sound_touch(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1775 SETTING_TRACE_BEGIN;
1776 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL, SYSTEM_SETTINGS_KEY_SOUND_TOUCH, 2, user_data);
1779 int system_setting_unset_changed_callback_sound_touch(system_settings_key_e key)
1781 SETTING_TRACE_BEGIN;
1782 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL, 2);
1786 /* SYSTEM_SETTINGS_KEY_SOUND_LOCK */
1787 int system_setting_get_sound_lock(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1791 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_SOUND_LOCK_BOOL, &vconf_value)) {
1792 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1794 *value = (void *)vconf_value;
1796 return SYSTEM_SETTINGS_ERROR_NONE;
1800 int system_setting_get_auto_rotation_mode(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1802 SETTING_TRACE_BEGIN;
1805 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, &vconf_value)) {
1806 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1808 *value = (void *)vconf_value;
1810 return SYSTEM_SETTINGS_ERROR_NONE;
1813 /* LCOV_EXCL_START */
1814 int system_setting_set_auto_rotation_mode(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1816 SETTING_TRACE_BEGIN;
1818 vconf_value = (bool *)value;
1819 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, *vconf_value)) {
1820 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1823 return SYSTEM_SETTINGS_ERROR_NONE;
1825 /* LCOV_EXCL_STOP */
1827 int system_setting_set_changed_callback_auto_rotation_mode(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1829 SETTING_TRACE_BEGIN;
1830 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, SYSTEM_SETTINGS_KEY_DISPLAY_SCREEN_ROTATION_AUTO, 2, user_data);
1833 int system_setting_unset_changed_callback_auto_rotation_mode(system_settings_key_e key)
1835 SETTING_TRACE_BEGIN;
1836 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, 2);
1839 int system_setting_get_screen_backlight_time(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1841 SETTING_TRACE_BEGIN;
1843 int ** val = (int**)value;
1845 if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, &vconf_value)) {
1846 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1848 **val = vconf_value;
1850 return SYSTEM_SETTINGS_ERROR_NONE;
1854 /* LCOV_EXCL_START */
1855 int system_setting_set_screen_backlight_time(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1857 SETTING_TRACE_BEGIN;
1859 vconf_value = *(int **)value;
1861 if (!(*vconf_value > 0 && *vconf_value <= 600)) {
1862 SETTING_TRACE(" ERR Betweeny here 0 ~ 600");
1863 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
1866 if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, *vconf_value)) {
1867 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1870 return SYSTEM_SETTINGS_ERROR_NONE;
1872 /* LCOV_EXCL_STOP */
1874 int system_setting_set_changed_callback_screen_backlight_time(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1876 SETTING_TRACE_BEGIN;
1877 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, SYSTEM_SETTINGS_KEY_SCREEN_BACKLIGHT_TIME, 2, user_data);
1880 int system_setting_unset_changed_callback_screen_backlight_time(system_settings_key_e key)
1882 SETTING_TRACE_BEGIN;
1883 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, 2);
1886 int system_setting_get_sound_notification(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1888 SETTING_TRACE_BEGIN;
1889 char *vconf_value = NULL;
1890 if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, &vconf_value)) {
1891 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1894 *value = vconf_value;
1895 return SYSTEM_SETTINGS_ERROR_NONE;
1898 /* LCOV_EXCL_START */
1899 int system_setting_set_sound_notification(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1901 SETTING_TRACE_BEGIN;
1902 char *vconf_value = NULL;
1903 vconf_value = (char *)value;
1905 int is_load = _is_file_accessible(vconf_value);
1907 //SETTING_TRACE(" system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, %s) TRY", vconf_value);
1908 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, vconf_value)) {
1909 //SETTING_TRACE(" system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, %s) FAIL", vconf_value);
1910 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1913 //SETTING_TRACE(" is_file_accessibile FAILED - system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, %s) FAIL", vconf_value);
1914 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1917 return SYSTEM_SETTINGS_ERROR_NONE;
1919 /* LCOV_EXCL_STOP */
1921 int system_setting_set_changed_callback_sound_notification(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1923 SETTING_TRACE_BEGIN;
1924 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, SYSTEM_SETTINGS_KEY_SOUND_NOTIFICATION, 0, user_data);
1927 int system_setting_unset_changed_callback_sound_notification(system_settings_key_e key)
1929 SETTING_TRACE_BEGIN;
1930 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, 0);
1933 int system_setting_get_notification_repetition_period(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1935 SETTING_TRACE_BEGIN;
1936 int ** val = (int**)value;
1939 if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_NOTI_MSG_ALERT_REP_TYPE_INT, &vconf_value)) {
1940 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1942 **val = vconf_value;
1944 return SYSTEM_SETTINGS_ERROR_NONE;
1947 /* LCOV_EXCL_START */
1948 int system_setting_set_notification_repetition_period(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1950 SETTING_TRACE_BEGIN;
1952 vconf_value = *(int **)value;
1954 if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_NOTI_MSG_ALERT_REP_TYPE_INT, *vconf_value)) {
1955 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1958 return SYSTEM_SETTINGS_ERROR_NONE;
1960 /* LCOV_EXCL_STOP */
1962 int system_setting_set_changed_callback_notification_repetition_period(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1964 SETTING_TRACE_BEGIN;
1965 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);
1968 int system_setting_unset_changed_callback_notification_repetition_period(system_settings_key_e key)
1970 SETTING_TRACE_BEGIN;
1971 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_ALERT_REP_TYPE_INT, 1);
1974 int system_setting_get_device_name(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1976 SETTING_TRACE_BEGIN;
1977 char *vconf_value = NULL;
1978 if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_DEVICE_NAME_STR, &vconf_value)) {
1979 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1982 *value = vconf_value;
1983 return SYSTEM_SETTINGS_ERROR_NONE;
1986 /* LCOV_EXCL_START */
1987 int system_setting_set_device_name(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1989 SETTING_TRACE_BEGIN;
1990 char *vconf_value = NULL;
1991 vconf_value = (char *)value;
1993 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_DEVICE_NAME_STR, vconf_value)) {
1994 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1997 return SYSTEM_SETTINGS_ERROR_NONE;
1999 /* LCOV_EXCL_STOP */
2001 int system_setting_set_changed_callback_device_name(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
2003 SETTING_TRACE_BEGIN;
2004 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_DEVICE_NAME_STR, SYSTEM_SETTINGS_KEY_DEVICE_NAME, 0, user_data);
2007 int system_setting_unset_changed_callback_device_name(system_settings_key_e key)
2009 SETTING_TRACE_BEGIN;
2010 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_DEVICE_NAME_STR, 0);
2013 /*---------------------------------------------- */
2014 int system_setting_get_network_flight_mode(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
2016 SETTING_TRACE_BEGIN;
2018 if (system_setting_vconf_get_value_bool(VCONFKEY_TELEPHONY_FLIGHT_MODE, &vconf_value)) {
2019 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2021 *value = (void *)vconf_value;
2023 return SYSTEM_SETTINGS_ERROR_NONE;
2026 int system_setting_set_changed_callback_network_flight_mode(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
2028 SETTING_TRACE_BEGIN;
2029 return system_setting_vconf_set_changed_cb(VCONFKEY_TELEPHONY_FLIGHT_MODE, SYSTEM_SETTINGS_KEY_NETWORK_FLIGHT_MODE, 3, user_data);
2032 int system_setting_unset_changed_callback_network_flight_mode(system_settings_key_e key)
2034 SETTING_TRACE_BEGIN;
2035 return system_setting_vconf_unset_changed_cb(VCONFKEY_TELEPHONY_FLIGHT_MODE, 3);
2038 int system_setting_get_network_wifi_notification(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
2040 SETTING_TRACE_BEGIN;
2042 if (system_setting_vconf_get_value_int(VCONFKEY_WIFI_ENABLE_QS, &vconf_value)) {
2043 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2046 bret = (vconf_value == VCONFKEY_WIFI_QS_ENABLE) ? true : false;
2048 *value = (void *)bret;
2049 return SYSTEM_SETTINGS_ERROR_NONE;
2052 int system_setting_set_changed_callback_network_wifi_notification(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
2054 SETTING_TRACE_BEGIN;
2055 return system_setting_vconf_set_changed_cb(VCONFKEY_WIFI_ENABLE_QS, SYSTEM_SETTINGS_KEY_NETWORK_WIFI_NOTIFICATION, 4, user_data);
2058 int system_setting_unset_changed_callback_network_wifi_notification(system_settings_key_e key)
2060 SETTING_TRACE_BEGIN;
2061 return system_setting_vconf_unset_changed_cb(VCONFKEY_WIFI_ENABLE_QS, 4);
2064 /* LCOV_EXCL_START */
2065 int system_setting_get_lock_state(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
2068 int ** val = (int**)value;
2070 if (system_setting_vconf_get_value_int(VCONFKEY_IDLE_LOCK_STATE_READ_ONLY, &vconf_value)) {
2071 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2073 **val = vconf_value;
2075 return SYSTEM_SETTINGS_ERROR_NONE;
2077 /* LCOV_EXCL_STOP */
2079 /* LCOV_EXCL_START */
2080 int system_setting_set_lock_state(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
2082 SETTING_TRACE_BEGIN;
2084 vconf_value = *(int **)value;
2086 if (system_setting_vconf_set_value_int(VCONFKEY_IDLE_LOCK_STATE_READ_ONLY, *vconf_value)) {
2087 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2090 return SYSTEM_SETTINGS_ERROR_NONE;
2092 /* LCOV_EXCL_STOP */
2094 /* LCOV_EXCL_START */
2095 int system_setting_set_changed_callback_lock_state(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
2097 return system_setting_vconf_set_changed_cb(VCONFKEY_IDLE_LOCK_STATE_READ_ONLY, SYSTEM_SETTINGS_KEY_LOCK_STATE, 4, user_data);
2099 /* LCOV_EXCL_STOP */
2101 /* LCOV_EXCL_START */
2102 int system_setting_unset_changed_callback_lock_state(system_settings_key_e key)
2104 return system_setting_vconf_unset_changed_cb(VCONFKEY_IDLE_LOCK_STATE_READ_ONLY, 4);
2106 /* LCOV_EXCL_STOP */
2108 //----------------------------------------------------------------------------------------------------------------------------
2110 #define DEFAULT_ADS_ID "00000000-0000-0000-0000-000000000000"
2112 int system_setting_get_ads_id(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
2114 SETTING_TRACE_BEGIN;
2115 int optout_value = 0;
2116 if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_AD_ID_OPT_OUT, &optout_value)) {
2117 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2120 if (optout_value == 1) {
2121 *value = strdup(DEFAULT_ADS_ID);
2122 return SYSTEM_SETTINGS_ERROR_NONE;
2125 char *vconf_value = NULL;
2126 if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_AD_ID, &vconf_value)) {
2127 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2130 *value = vconf_value;
2131 return SYSTEM_SETTINGS_ERROR_NONE;
2136 void make_ad_id(void)
2139 char uuid_unparsed[50] = {0};
2140 uuid_generate(uuid_value);
2141 uuid_unparse(uuid_value, uuid_unparsed);
2142 system_setting_set_ad_id(key, uuid_unparsed); //example of setting the value
2145 /* LCOV_EXCL_START */
2146 int system_setting_set_ads_id(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
2148 SETTING_TRACE_BEGIN;
2149 char *vconf_value = NULL;
2150 vconf_value = (char *)value;
2152 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_AD_ID, vconf_value)) {
2153 SETTING_TRACE("Setting VCONFKEY_SETAPPL_AD_ID failed");
2154 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2157 return SYSTEM_SETTINGS_ERROR_NONE;
2159 /* LCOV_EXCL_STOP */
2161 int system_setting_set_changed_callback_ads_id(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
2163 SETTING_TRACE_BEGIN;
2164 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_AD_ID, SYSTEM_SETTINGS_KEY_ADS_ID, 0, user_data);
2167 int system_setting_unset_changed_callback_ads_id(system_settings_key_e key)
2169 SETTING_TRACE_BEGIN;
2170 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_AD_ID, 0);
2173 int system_settings_feature_check_bool(char *path)
2175 bool profile_data = false;
2176 int ret = system_info_get_platform_bool(path, &profile_data);
2177 if (ret != SYSTEM_INFO_ERROR_NONE) {
2178 SETTING_TRACE("Setting - reading profile string failed, %d", ret);
2179 return SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED;
2182 ret = (profile_data == true) ? SYSTEM_SETTINGS_ERROR_NONE : SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED;
2188 int system_setting_feature_check_incoming_call(void * value)
2190 static bool first_query = true;
2191 static int ret = SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED;
2193 if (first_query == true) {
2194 ret = system_settings_feature_check_bool(SETTING_INCOMING_CALL_PATH);
2195 first_query = false;
2201 int system_setting_feature_check_home_screen(void * value)
2203 static bool first_query = true;
2204 static int ret = SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED;
2206 if (first_query == true) {
2207 ret = system_settings_feature_check_bool(SETTING_HOME_SCREEN_PATH);
2208 first_query = false;
2214 int system_setting_feature_check_lock_screen(void * value)
2216 static bool first_query = true;
2217 static int ret = SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED;
2219 if (first_query == true) {
2220 ret = system_settings_feature_check_bool(SETTING_LOCK_SCREEN_PATH);
2221 first_query = false;
2227 int system_setting_feature_check_notification_email(void * value)
2229 static bool first_query = true;
2230 static int ret = SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED;
2232 if (first_query == true) {
2233 ret = system_settings_feature_check_bool(SETTING_NOTIFICATION_EMAIL_PATH);
2234 first_query = false;
2240 int system_setting_feature_check_wifi(void * value)
2242 static bool first_query = true;
2243 static int ret = SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED;
2245 if (first_query == true) {
2246 ret = system_settings_feature_check_bool(SETTING_WIFI_PATH);
2247 first_query = false;
2253 int system_setting_feature_check_telephony(void * value)
2255 static bool first_query = true;
2256 static int ret = SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED;
2258 if (first_query == true) {
2259 ret = system_settings_feature_check_bool(SETTING_TELEPHONY_PATH);
2260 first_query = false;
2266 /* LCOV_EXCL_START */
2267 int system_setting_get_uds_state(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
2269 int ** p_value = (int**)value;
2271 char *vconf_string_value = NULL;
2273 if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_UDSM, &vconf_value)) {
2274 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2277 SETTING_TRACE("[%s] udsm: %d", __FUNCTION__, vconf_value);
2279 if (vconf_value == SYSTEM_SETTINGS_UDS_ON) {
2280 if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_UDSM_PKGID_LIST, &vconf_string_value))
2281 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2283 if (vconf_string_value) {
2284 if (!strcmp(vconf_string_value, "NONE")) {
2285 vconf_value = SYSTEM_SETTINGS_UDS_ON;
2287 char *app_id = NULL;
2288 char *package_id = NULL;
2289 pid_t pid = getpid();
2290 app_manager_get_app_id(pid, &app_id);
2293 package_manager_get_package_id_by_app_id(app_id, &package_id);
2294 SETTING_TRACE("[%s] udsm_pkg_list : %s", __FUNCTION__, vconf_string_value);
2297 if (package_id && strstr(vconf_string_value, package_id)) {
2298 vconf_value = SYSTEM_SETTINGS_UDS_ON_WHITELISTED;
2299 SETTING_TRACE("[%s] pkg id : %s", __FUNCTION__, package_id);
2301 vconf_value = SYSTEM_SETTINGS_UDS_ON;
2305 if (vconf_string_value)
2306 free(vconf_string_value);
2310 **p_value = vconf_value;
2313 return SYSTEM_SETTINGS_ERROR_NONE;
2315 /* LCOV_EXCL_STOP */
2317 /* LCOV_EXCL_START */
2318 int system_setting_set_changed_callback_uds_state(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
2320 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_UDSM, SYSTEM_SETTINGS_KEY_ULTRA_DATA_SAVE, 4, user_data);
2322 /* LCOV_EXCL_STOP */
2324 /* LCOV_EXCL_START */
2325 int system_setting_unset_changed_callback_uds_state(system_settings_key_e key)
2327 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_UDSM, 4);
2329 /* LCOV_EXCL_STOP */
2331 /* LCOV_EXCL_START */
2332 int system_setting_set_changed_callback_uds_pkg_list(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
2334 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_UDSM_PKGID_LIST, SYSTEM_SETTINGS_KEY_ULTRA_DATA_SAVE_PKG_LIST, 4, user_data);
2336 /* LCOV_EXCL_STOP */
2338 /* LCOV_EXCL_START */
2339 int system_setting_unset_changed_callback_uds_pkg_list(system_settings_key_e key)
2341 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_UDSM_PKGID_LIST, 4);
2343 /* LCOV_EXCL_STOP */
2345 /* SYSTEM_SETTINGS_KEY_ACCESSIBILITY_TTS */
2346 int system_setting_get_accessibility_tts(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
2348 SETTING_TRACE_BEGIN;
2351 int ret = system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_ACCESSIBILITY_TTS, &vconf_value);
2352 if (ret != SYSTEM_SETTINGS_ERROR_NONE) {
2355 *value = (void *)vconf_value;
2359 int system_setting_set_changed_callback_accessibility_tts(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
2361 SETTING_TRACE_BEGIN;
2362 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_TTS, SYSTEM_SETTINGS_KEY_ACCESSIBILITY_TTS, 2, user_data);
2365 int system_setting_unset_changed_callback_accessibility_tts(system_settings_key_e key)
2367 SETTING_TRACE_BEGIN;
2368 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_TTS, 2);