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 * VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR has a path of the ringtone file which user choose
90 * @return the ringtone file path specified by user in normal case
91 * if it's not accessable, return the default ringtone path
93 int system_setting_get_incoming_call_ringtone(system_settings_key_e key, void **value)
97 if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR, &vconf_value)) {
98 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
101 /* check to see if it's accessable -> OK */
102 /* no --> default ringtone path VCONFKEY_SETAPPL_CALL_RINGTONE_DEFAULT_PATH_STR */
103 int is_load = _is_file_accessible(vconf_value);
105 *value = vconf_value;
106 } else { /* not zero on errro */
107 *value = vconf_get_str(VCONFKEY_SETAPPL_CALL_RINGTONE_DEFAULT_PATH_STR);
110 /**value = vconf_value; */
111 return SYSTEM_SETTINGS_ERROR_NONE;
115 int system_setting_get_email_alert_ringtone(system_settings_key_e key, void **value)
119 if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, &vconf_value)) {
120 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
123 /* check to see if it's accessable -> OK */
124 /* no --> default ringtone path VCONFKEY_SETAPPL_NOTI_RINGTONE_DEFAULT_PATH_STR */
125 int is_load = _is_file_accessible(vconf_value);
127 *value = vconf_value;
128 } else { /* not zero on errro */
129 *value = vconf_get_str(VCONFKEY_SETAPPL_NOTI_RINGTONE_DEFAULT_PATH_STR);
132 return SYSTEM_SETTINGS_ERROR_NONE;
136 int system_setting_get_wallpaper_home_screen(system_settings_key_e key, void **value)
140 if (system_setting_vconf_get_value_string(VCONFKEY_BGSET, &vconf_value)) {
141 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
143 *value = vconf_value;
144 return SYSTEM_SETTINGS_ERROR_NONE;
148 int system_setting_get_wallpaper_lock_screen(system_settings_key_e key, void **value)
153 if (system_setting_vconf_get_value_string(VCONFKEY_IDLE_LOCK_BGSET, &vconf_value)) {
154 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
156 *value = vconf_value;
158 return SYSTEM_SETTINGS_ERROR_NONE;
162 /* [int] vconf GET */
163 int system_setting_get_font_size(system_settings_key_e key, void **value)
167 int ** val = (int**)value;
169 if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, &vconf_value)) {
170 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
174 return SYSTEM_SETTINGS_ERROR_NONE;
178 int system_setting_get_default_font_type(system_settings_key_e key, void **value)
181 char *font_name = dl_get_default_font_info();
183 *value = (void *)font_name;
184 return SYSTEM_SETTINGS_ERROR_NONE;
186 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
190 /* [int] vconf GET */
191 int system_setting_get_font_type(system_settings_key_e key, void **value)
194 char *font_name = NULL;
196 if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, &font_name)) {
197 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
201 return SYSTEM_SETTINGS_ERROR_NONE;
205 int system_setting_get_motion_activation(system_settings_key_e key, void **value)
210 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_MOTION_ACTIVATION, &vconf_value)) {
211 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
213 *value = (void *)vconf_value;
215 return SYSTEM_SETTINGS_ERROR_NONE;
218 int system_setting_get_usb_debugging_option(system_settings_key_e key, void **value)
223 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_USB_DEBUG_MODE_BOOL, &vconf_value)) {
224 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
226 *value = (void *)vconf_value;
228 return SYSTEM_SETTINGS_ERROR_NONE;
231 int system_setting_get_3g_data_network(system_settings_key_e key, void **value)
236 if (system_setting_vconf_get_value_bool(VCONFKEY_3G_ENABLE, &vconf_value)) {
237 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
239 *value = (void *)vconf_value;
241 return SYSTEM_SETTINGS_ERROR_NONE;
243 /*////////////////////////////////////////////////////////////////////////////////////////////////// */
247 * get current lock scren app package name (string)
249 * @return SYSTEM_SETTINGS_ERROR_LOCKSCREEN_APP_PASSWORD_MODE raise exception if current lock type is 'password'
251 int system_setting_get_lockscreen_app(system_settings_key_e key, void **value)
254 char *pkg_name = NULL;
256 if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_SCREEN_LOCK_TYPE_INT, &locktype)) {
257 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
260 if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_3RD_LOCK_PKG_NAME_STR, &pkg_name)) {
261 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
264 if (pkg_name && strcmp(pkg_name, "com.samsung.lockscreen") == 0 && locktype == SETTING_SCREEN_LOCK_TYPE_PASSWORD) {
265 return SYSTEM_SETTINGS_ERROR_LOCKSCREEN_APP_PASSWORD_MODE;
269 return SYSTEM_SETTINGS_ERROR_NONE;
273 /*////////////////////////////////////////////////////////////////////////////////////////////////// */
275 int _is_file_accessible(const char *path)
278 int ret = access(path , R_OK);
280 SETTING_TRACE("found the file %s", path);
283 /* error code : 13 */
284 SETTING_TRACE("found the file %s --- error code : %d ", path, errno);
291 /*////////////////////////////////////////////////////////////////////////////////////////////////// */
292 // @todo move to CMake
293 #define DEF_RINGTONE_FILE_PATH SETTING_DEF_RES"/Ringtones"
295 #define USR_RINGTONE_FILE_PATH "/home/owner/content/Sounds/Ringtones"
296 #define JSONFILE "/opt/home/owner/apps_rw/org.tizen.setting/data/.user-ringtones.json"
299 static char* _get_json_file_path()
306 int system_setting_add_incoming_call_ringtone(system_settings_key_e key, void *value)
309 char* pathval = (char*)value;
310 char* dnameval = NULL;
311 char* baseval = NULL;
315 JsonParser *parser = ss_json_ringtone_open_file(JSONFILE);
317 JsonParser *parser = ss_json_ringtone_load_from_data();
320 JsonNode *root = json_parser_get_root(parser);
324 int ret = SYSTEM_SETTINGS_ERROR_NONE;
325 if (false == ss_json_ringtone_contain(root, pathval)) {
326 // @todo : MAKE SURE THE ACTUAL FILE IS THERE ON PATHVAL(SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER)
327 ss_json_ringtone_add(root, JSONFILE, pathval, pathval);
328 SETTING_TRACE("pathval is : %s -- OK", pathval);
330 SETTING_TRACE("pathval is duplicated : %s", pathval);
331 ret = SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
334 dnameval = strdup(pathval);
335 baseval = strdup(pathval);
336 if (dnameval && baseval) {
337 SETTING_TRACE("---> dirname is : %s ", dirname(dnameval));
338 SETTING_TRACE("---> basename is : %s ", basename(baseval));
344 g_object_unref(parser);
351 int system_setting_del_incoming_call_ringtone(system_settings_key_e key, void *value)
354 char* pathval = (char*)value;
357 JsonParser* parser = ss_json_ringtone_open_file(JSONFILE);
359 JsonParser* parser = ss_json_ringtone_load_from_data();
361 JsonNode *root = json_parser_get_root(parser);
363 ss_json_ringtone_remove(root, JSONFILE, pathval);
364 //void ss_json_ringtone_remove(JsonNode *root, char* filename, char* path_to_del)
366 ss_json_ringtone_print(root);
368 g_object_unref(parser);
372 return SYSTEM_SETTINGS_ERROR_NONE;
376 static int _compare_cb(const void *d1, const void *d2)
378 fileNodeInfo *pNode1 = (fileNodeInfo *)d1;
379 fileNodeInfo *pNode2 = (fileNodeInfo *)d2;
381 return strcmp(pNode1->media_name, pNode2->media_name);
385 * get the RINGTONE list
387 static void _get_default_ringtones(system_settings_key_e key, system_settings_iter_cb callback, void *data)
391 Eina_List *filelist = NULL;
393 fileNodeInfo *node = NULL;
396 //-----------------------------------------------------------------------------------------------------------------
397 // 1. get the default ringtone list
398 //-----------------------------------------------------------------------------------------------------------------
399 int ret = get_filelist_from_dir_path(DEF_RINGTONE_FILE_PATH, &filelist);
401 SETTING_TRACE("Failed to get filelist, ret = %d %s", ret, DEF_RINGTONE_FILE_PATH);
403 filelist = eina_list_sort(filelist, eina_list_count(filelist), _compare_cb);
405 EINA_LIST_FOREACH(filelist, l, node)
407 SETTING_TRACE("file path = (%d) : name:%s path:%s [%s]", ret, node->name, node->path, node->media_name);
408 // @todo assert NULL check
411 snprintf(temp, 1024, "%s/%s", node->path, node->name);
412 char* path = strdup(temp);
413 bool ret = callback(idx, (void *)(path), data);
419 SETTING_TRACE("quit the iteration by return value == false : %d", ret);
424 SETTING_TRACE("--> system_setting_data_iterator is NULL");
430 EINA_LIST_FOREACH(filelist, l, node)
434 FREE(node->media_name);
437 eina_list_free(filelist);
442 static void _get_user_ringtones(system_settings_key_e key, system_settings_iter_cb callback, void *data)
448 JsonParser* parser = ss_json_ringtone_open_file(JSONFILE);
450 JsonParser* parser = ss_json_ringtone_load_from_data();
453 JsonNode *root = json_parser_get_root(parser);
454 int size = json_array_get_length(json_node_get_array(root));
457 for (i = 0; i < size ; i++) {
458 JsonObject *ringtone = json_array_get_object_element(json_node_get_array(root), i);
459 char *nameval = (char *)json_object_get_string_member(ringtone, "name");
460 char *pathval = (char *)json_object_get_string_member(ringtone, "path");
461 SETTING_TRACE("(%s) --- (%s) \n", nameval, pathval);
463 char* path = strdup(pathval);
464 bool ret = callback(i, (void *)(path), data);
466 SETTING_TRACE("quit the iteration by return value == false : %d", ret);
470 SETTING_TRACE("--> callback is NULL");
475 int system_setting_list_incoming_call_ringtone(system_settings_key_e key, system_settings_iter_cb callback, void *data)
479 _get_default_ringtones(key, callback, data);
480 //-----------------------------------------------------------------------------------------------------------------
481 // 2. get the USER ringtone list
482 //-----------------------------------------------------------------------------------------------------------------
483 _get_user_ringtones(key, callback, data);
485 return SYSTEM_SETTINGS_ERROR_NONE;
489 /* LCOV_EXCL_START */
490 int system_setting_set_incoming_call_ringtone(system_settings_key_e key, void *value)
494 vconf_value = (char *)value;
496 int ret = _is_file_accessible(vconf_value);
498 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR, vconf_value)) {
499 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
502 /* @todo add a common ret_handler */
506 return SYSTEM_SETTINGS_ERROR_NONE;
511 /* LCOV_EXCL_START */
512 int system_setting_set_email_alert_ringtone(system_settings_key_e key, void *value)
516 vconf_value = (char *)value;
518 int ret = _is_file_accessible(vconf_value);
520 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, vconf_value)) {
521 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
524 /*return SYSTEM_SETTINGS_ERROR_IO_ERROR;*/
525 /* @todo add a common ret_handler */
529 return SYSTEM_SETTINGS_ERROR_NONE;
533 /* LCOV_EXCL_START */
534 static bool dl_is_supported_image_type_load(char *path)
539 bool (*image_type_check)(char *path);
541 handle = dlopen(SETTING_UTILS_SO_FILE_PATH, RTLD_LAZY);
543 SETTING_TRACE("ERROR!! canNOT find libsystem-settings-util.so.0.1.0");
547 image_type_check = dlsym(handle, "__is_supported_image_type_load");
548 if ((error = dlerror()) != NULL) {
549 SETTING_TRACE("ERROR!! canNOT find __is_supported_image_type_load function at libsystem-settings-util.so.0.1.0");
554 ret = image_type_check(path);
561 /* LCOV_EXCL_START */
562 static int dl_is_available_font(char *str)
567 int (*check_available_font)(char *font_name);
569 handle = dlopen(SETTING_UTILS_SO_FILE_PATH, RTLD_LAZY);
571 SETTING_TRACE("ERROR!! canNOT find libsystem-settings-util.so.0.1.0");
575 check_available_font = dlsym(handle, "__is_available_font");
576 if ((error = dlerror()) != NULL) {
577 SETTING_TRACE("ERROR!! canNOT find __is_available_font function at libsystem-settings-util.so.0.1.0");
582 ret = check_available_font(str);
589 /* LCOV_EXCL_START */
590 static void dl_font_size_set()
594 void (*set_font_size)();
596 handle = dlopen(SETTING_UTILS_SO_FILE_PATH, RTLD_LAZY);
598 SETTING_TRACE("ERROR!! canNOT find libsystem-settings-util.so.0.1.0");
602 set_font_size = dlsym(handle, "__font_size_set");
603 if ((error = dlerror()) != NULL) {
604 SETTING_TRACE("ERROR!! canNOT find __font_size_set function at libsystem-settings-util.so.0.1.0");
616 /* LCOV_EXCL_START */
617 static void dl_font_config_set_notification()
621 void (*set_font_nodification)();
623 handle = dlopen(SETTING_UTILS_SO_FILE_PATH, RTLD_LAZY);
625 SETTING_TRACE("ERROR!! canNOT find libsystem-settings-util.so.0.1.0");
629 set_font_nodification = dlsym(handle, "font_config_set_notification");
630 if ((error = dlerror()) != NULL) {
631 SETTING_TRACE("ERROR!! canNOT find font_config_set_notification function at libsystem-settings-util.so.0.1.0");
636 set_font_nodification();
643 /* LCOV_EXCL_START */
644 static bool dl_font_config_set(char *font_name)
649 bool (*check_font_type)(char *font_name);
651 handle = dlopen(SETTING_UTILS_SO_FILE_PATH, RTLD_LAZY);
653 SETTING_TRACE("ERROR!! canNOT find libsystem-settings-util.so.0.1.0");
657 check_font_type = dlsym(handle, "font_config_set");
658 if ((error = dlerror()) != NULL) {
659 SETTING_TRACE("ERROR!! canNOT find font_config_set function at libsystem-settings-util.so.0.1.0");
664 ret = check_font_type(font_name);
671 /* LCOV_EXCL_START */
672 static char *dl_get_default_font_info()
677 char *(*get_font_info)();
679 handle = dlopen(SETTING_UTILS_SO_FILE_PATH, RTLD_LAZY);
681 SETTING_TRACE("ERROR!! canNOT find libsystem-settings-util.so.0.1.0");
685 get_font_info = dlsym(handle, "_get_default_font");
687 if ((error = dlerror()) != NULL) {
688 SETTING_TRACE("ERROR!! canNOT find _get_default_font function at libsystem-settings-util.so.0.1.0");
693 ret = get_font_info();
700 #ifdef TIZEN_WEARABLE
701 /* LCOV_EXCL_START */
702 static int system_setting_get_extended_wallpaper_num(const char *file_path, unsigned int *num)
706 const char *find_str = "extended_wallpaper_";
709 if (!(ch = strstr(file_path, find_str))) {
710 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
712 strncpy(buffer, file_path, ch - file_path);
713 buffer[ch - file_path] = 0;
714 sprintf(buffer + (ch - file_path), "%s%s", "", ch + strlen(find_str));
716 if (!isdigit(buffer[0])) {
717 SETTING_TRACE("%s is not number", buffer);
718 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
723 return SYSTEM_SETTINGS_ERROR_NONE;
727 /* LCOV_EXCL_START */
728 static int system_setting_copy_extended_wallpaper(const char *dest_file_path, const char *source_file_path)
731 if (!source_file_path || !dest_file_path) {
732 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
738 fd = open(source_file_path, O_RDONLY);
740 SETTING_TRACE("file open failed: %s", source_file_path);
741 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
745 fd2 = open(dest_file_path, O_WRONLY | O_CREAT, S_IRWXU | S_IRWXG | S_IRWXO);
747 SETTING_TRACE("file creation failed: %s", dest_file_path);
749 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
752 while (read(fd, buf, sizeof(buf) - 1) > 0) {
753 write(fd2, buf, sizeof(buf) - 1);
759 if (chmod(dest_file_path, S_IRWXU | S_IRWXG | S_IRWXO) < 0) {
760 SETTING_TRACE("chmod failed: %s", dest_file_path);
763 return SYSTEM_SETTINGS_ERROR_NONE;
767 /* LCOV_EXCL_START */
768 static int system_setting_remove_oldest_extended_wallpaper()
773 char *min_image_name = NULL;
774 unsigned int min_image_num = 0;
775 unsigned int temp_image_num = 0;
778 if ((dp = opendir(_TZ_SYS_DATA"/setting/wallpaper")) == NULL) {
779 SETTING_TRACE("opendir error");
780 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
783 while ((dirp = readdir(dp))) {
784 if (!strcmp(dirp->d_name, ".") || !strcmp(dirp->d_name, ".."))
787 if (system_setting_get_extended_wallpaper_num(dirp->d_name, &temp_image_num)
788 != SYSTEM_SETTINGS_ERROR_NONE) {
789 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
792 if ((image_count == 0) || (min_image_num > temp_image_num)) {
793 min_image_num = temp_image_num;
794 min_image_name = dirp->d_name;
801 if (min_image_name) {
802 snprintf(buf, sizeof(buf) - 1, _TZ_SYS_DATA"/setting/wallpaper/%s", min_image_name);
803 if (remove(buf) < 0) { /* remove oldest image */
804 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
808 return SYSTEM_SETTINGS_ERROR_NONE;
812 /* LCOV_EXCL_START */
813 static int system_setting_check_extended_wallpaper(const char *file_path)
817 if (!file_path || !strlen(file_path))
819 snprintf(buffer, 512, "%s/.bgwallpaper", tzplatform_getenv(TZ_USER_CONTENT));
820 return (strstr(file_path, buffer) != NULL);
824 #define WALLPAPER_MAX_COUNT 10
826 /* LCOV_EXCL_START */
827 int system_setting_set_wallpaper_home_screen(system_settings_key_e key, void *value)
831 vconf_value = (char *)value;
833 bool isok = dl_is_supported_image_type_load(vconf_value);
836 SETTING_TRACE("path : %s is not supported file format", vconf_value);
837 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
839 SETTING_TRACE("path : %s is SUPPORT file format", vconf_value);
842 /* error handling here */
843 if (_is_file_accessible(vconf_value) != 0)
844 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
846 if (system_setting_vconf_set_value_string(VCONFKEY_BGSET, vconf_value)) {
847 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
851 #ifdef TIZEN_WEARABLE
852 if (system_setting_check_extended_wallpaper(vconf_value)) { /* New extended wallpaper */
855 unsigned int max_image_num = 0;
856 unsigned int temp_image_num = 0;
859 if ((dp = opendir(_TZ_SYS_DATA"/setting/wallpaper")) == NULL) {
860 SETTING_TRACE("Setting - dir open error!");
861 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
864 /* Check a max number of wallpapers */
865 while ((dirp = readdir(dp))) {
866 if (!strcmp(dirp->d_name, ".") || !strcmp(dirp->d_name, ".."))
869 if (system_setting_get_extended_wallpaper_num(dirp->d_name, &temp_image_num)
870 != SYSTEM_SETTINGS_ERROR_NONE) {
873 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
876 if ((image_count == 0) || (max_image_num < temp_image_num)) {
877 max_image_num = temp_image_num;
885 /* Numbering rule: Gear is odd number */
886 max_image_num = (max_image_num % 2 == 0) ? max_image_num + 1
889 char file_name_buffer[512];
890 snprintf(file_name_buffer, sizeof(file_name_buffer) - 1,
891 _TZ_SYS_DATA"/setting/wallpaper/extended_wallpaper_%d.jpg", max_image_num);
893 /* Copy image to _TZ_SYS_DATA/setting/wallpaper/ */
894 if (system_setting_copy_extended_wallpaper(file_name_buffer, vconf_value)
895 != SYSTEM_SETTINGS_ERROR_NONE) {
896 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
899 /* remove oldest wallpaper */
900 if (image_count >= WALLPAPER_MAX_COUNT) {
901 if (system_setting_remove_oldest_extended_wallpaper()
902 != SYSTEM_SETTINGS_ERROR_NONE) {
903 remove(file_name_buffer);
904 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
908 if (system_setting_vconf_set_value_string(VCONFKEY_BGSET, file_name_buffer)) {
909 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
912 if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_WALLPAPER_CHANGED_NOTI_INT,
913 VCONFKEY_WALLPAPER_CHANGED_NOTI_GEAR)) {
914 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
917 if (system_setting_vconf_set_value_string(VCONFKEY_BGSET, vconf_value)) {
918 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
923 return SYSTEM_SETTINGS_ERROR_NONE;
927 /* LCOV_EXCL_START */
928 int system_setting_set_wallpaper_lock_screen(system_settings_key_e key, void *value)
932 vconf_value = (char *)value;
934 bool isok = dl_is_supported_image_type_load(vconf_value);
937 SETTING_TRACE("path : %s is not supported file format", vconf_value);
938 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
940 SETTING_TRACE("path : %s is SUPPORT file format", vconf_value);
943 /* error handling here */
944 if (_is_file_accessible(vconf_value) != 0)
945 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
947 if (system_setting_vconf_set_value_string(VCONFKEY_IDLE_LOCK_BGSET, vconf_value)) {
948 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
951 return SYSTEM_SETTINGS_ERROR_NONE;
955 /* LCOV_EXCL_START */
956 int system_setting_set_font_size(system_settings_key_e key, void *value)
960 vconf_value = *(int **)value;
962 if (*vconf_value < 0 || *vconf_value > SYSTEM_SETTINGS_FONT_SIZE_GIANT) {
963 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
966 if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, *vconf_value)) {
967 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
971 return SYSTEM_SETTINGS_ERROR_NONE;
977 /* LCOV_EXCL_START */
978 void *font_conf_doc_parse(char *doc_name, char *font_name)
981 xmlDocPtr doc = NULL;
982 xmlNodePtr cur = NULL;
983 xmlNodePtr cur2 = NULL;
984 xmlNodePtr cur3 = NULL;
987 doc = xmlParseFile(doc_name);
989 cur = xmlDocGetRootElement(doc);
997 if (xmlStrcmp(cur->name, (const xmlChar *)"fontconfig")) {
1003 cur = cur->xmlChildrenNode;
1005 bool is_changed = false;
1006 while (cur != NULL) {
1007 if ((!xmlStrcmp(cur->name, (const xmlChar *)"match"))) {
1008 cur2 = cur->xmlChildrenNode;
1009 while (cur2 != NULL) {
1010 if ((!xmlStrcmp(cur2->name, (const xmlChar *)"edit"))) {
1011 xmlChar *name = xmlGetProp(cur2, (const xmlChar *)"name");
1012 /* if name is not 'family', break */
1013 if (xmlStrcmp(name, (const xmlChar *)"family")) {
1021 cur3 = cur2->xmlChildrenNode;
1022 while (cur3 != NULL) {
1023 if ((!xmlStrcmp(cur3->name, (const xmlChar *)"string"))) {
1024 xmlNodeSetContent(cur3->xmlChildrenNode, (const xmlChar *)font_name);
1025 key = xmlNodeListGetString(doc, cur3->xmlChildrenNode, 1);
1035 } else if ((!xmlStrcmp(cur->name, (const xmlChar *)"alias"))) {
1036 cur2 = cur->xmlChildrenNode;
1037 while (cur2 != NULL) {
1038 if ((!xmlStrcmp(cur2->name, (const xmlChar *)"family"))) {
1039 xmlNodeSetContent(cur2->xmlChildrenNode, (const xmlChar *)font_name);
1040 key = xmlNodeListGetString(doc, cur2->xmlChildrenNode, 1);
1044 } else if ((!xmlStrcmp(cur2->name, (const xmlChar *)"prefer"))) {
1045 cur3 = cur2->xmlChildrenNode;
1046 while (cur3 != NULL) {
1047 if ((!xmlStrcmp(cur3->name, (const xmlChar *)"family"))) {
1048 xmlNodeSetContent(cur3->xmlChildrenNode, (const xmlChar *)font_name);
1049 key = xmlNodeListGetString(doc, cur3->xmlChildrenNode, 1);
1073 /* LCOV_EXCL_STOP */
1075 /* LCOV_EXCL_START */
1076 int system_setting_set_font_type(system_settings_key_e key, void *value)
1078 SETTING_TRACE_BEGIN;
1079 char *font_name = NULL;
1080 font_name = (char *)value;
1082 /* get current font list */
1083 int is_found = dl_is_available_font(font_name);
1085 if (is_found == 1) {
1086 SETTING_TRACE("found font : %s ", font_name);
1088 SETTING_TRACE(" NOT found font : %s ", font_name);
1089 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1092 bool bsave = dl_font_config_set(font_name);
1095 SETTING_TRACE(" font type save error by font_config_set() ");
1096 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1098 SETTING_TRACE(" save OK - font_config_set() ");
1101 xmlDocPtr doc = (xmlDocPtr)font_conf_doc_parse(SETTING_FONT_CONF_FILE, font_name);
1103 xmlSaveFormatFile(SETTING_FONT_CONF_FILE, doc, 0);
1108 dl_font_config_set_notification();
1111 vconf_value = (char *)value;
1113 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, vconf_value)) {
1114 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1116 return SYSTEM_SETTINGS_ERROR_NONE;
1118 /* LCOV_EXCL_STOP */
1120 /* LCOV_EXCL_START */
1121 int system_setting_set_motion_activation(system_settings_key_e key, void *value)
1123 SETTING_TRACE_BEGIN;
1125 vconf_value = (bool *)value;
1126 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_MOTION_ACTIVATION, *vconf_value)) {
1127 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1129 return SYSTEM_SETTINGS_ERROR_NONE;
1131 /* LCOV_EXCL_STOP */
1133 /* LCOV_EXCL_START */
1134 int system_setting_set_usb_debugging_option(system_settings_key_e key, void *value)
1136 SETTING_TRACE_BEGIN;
1138 vconf_value = (bool *)value;
1139 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_USB_DEBUG_MODE_BOOL, *vconf_value)) {
1140 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1142 return SYSTEM_SETTINGS_ERROR_NONE;
1145 /* LCOV_EXCL_STOP */
1147 /* LCOV_EXCL_START */
1148 int system_setting_set_3g_data_network(system_settings_key_e key, void *value)
1150 SETTING_TRACE_BEGIN;
1152 vconf_value = (bool *)value;
1153 if (system_setting_vconf_set_value_bool(VCONFKEY_3G_ENABLE, *vconf_value)) {
1154 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1157 return SYSTEM_SETTINGS_ERROR_NONE;
1159 /* LCOV_EXCL_STOP */
1161 /* LCOV_EXCL_START */
1162 static int category_func(const char *name, void *user_data)
1164 SETTING_TRACE_BEGIN;
1165 static char *category = "lock-screen";
1166 if (name && !strcmp(name, category)) {
1167 SETTING_TRACE(" SAME ");
1170 SETTING_TRACE(" DIFFERENT -- %s, category -- %s ", name, category);
1176 /* LCOV_EXCL_STOP */
1180 * set 'swipe type' if current lockscreen app is 'com.samsung.lockscreen'
1184 /* LCOV_EXCL_START */
1185 int system_setting_set_lockscreen_app(system_settings_key_e key, void *value)
1187 SETTING_TRACE_BEGIN;
1189 vconf_value = (char *)value; /* ex) com.samsung.lockscreen */
1192 pkgmgrinfo_appinfo_h handle;
1193 r = pkgmgrinfo_appinfo_get_appinfo(vconf_value, &handle);
1194 if (r != PMINFO_R_OK) {
1195 SETTING_TRACE("*** pkginfo failed ");
1196 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
1198 SETTING_TRACE("%x", handle);
1201 int ret = pkgmgrinfo_appinfo_foreach_category(handle, category_func, (void *)"lock-screen");
1202 if (ret != PMINFO_R_OK) {
1203 pkgmgrinfo_appinfo_destroy_appinfo(handle);
1204 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
1207 pkgmgrinfo_appinfo_destroy_appinfo(handle);
1208 /*----------------------------------------------------------------------------------- */
1210 if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_SCREEN_LOCK_TYPE_INT, &locktype)) {
1211 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1214 if (locktype == SETTING_SCREEN_LOCK_TYPE_PASSWORD)
1215 return SYSTEM_SETTINGS_ERROR_LOCKSCREEN_APP_PASSWORD_MODE;
1217 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_3RD_LOCK_PKG_NAME_STR, vconf_value)) {
1218 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1221 if (vconf_value && strcmp(vconf_value, "com.samsung.lockscreen") == 0) {
1222 if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_SCREEN_LOCK_TYPE_INT, SETTING_SCREEN_LOCK_TYPE_SWIPE)) {
1223 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1226 return SYSTEM_SETTINGS_ERROR_NONE;
1228 /* LCOV_EXCL_STOP */
1230 /*/////////////////////////////////////////////////////////////////////////////////////////////// */
1233 int system_setting_set_changed_callback_incoming_call_ringtone(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1235 SETTING_TRACE_BEGIN;
1236 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR, SYSTEM_SETTINGS_KEY_INCOMING_CALL_RINGTONE, 0, user_data);
1239 int system_setting_unset_changed_callback_incoming_call_ringtone(system_settings_key_e key)
1241 SETTING_TRACE_BEGIN;
1242 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR, 0);
1245 int system_setting_set_changed_callback_email_alert_ringtone(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1247 SETTING_TRACE_BEGIN;
1248 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, SYSTEM_SETTINGS_KEY_EMAIL_ALERT_RINGTONE, 0, user_data);
1251 int system_setting_unset_changed_callback_email_alert_ringtone(system_settings_key_e key)
1253 SETTING_TRACE_BEGIN;
1254 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, 0);
1257 int system_setting_set_changed_callback_wallpaper_home_screen(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1259 SETTING_TRACE_BEGIN;
1260 return system_setting_vconf_set_changed_cb(VCONFKEY_BGSET, SYSTEM_SETTINGS_KEY_WALLPAPER_HOME_SCREEN, 0, user_data);
1263 int system_setting_unset_changed_callback_wallpaper_home_screen(system_settings_key_e key)
1265 SETTING_TRACE_BEGIN;
1266 return system_setting_vconf_unset_changed_cb(VCONFKEY_BGSET, 0);
1269 int system_setting_set_changed_callback_wallpaper_lock_screen(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1271 SETTING_TRACE_BEGIN;
1272 return system_setting_vconf_set_changed_cb(VCONFKEY_IDLE_LOCK_BGSET, SYSTEM_SETTINGS_KEY_WALLPAPER_LOCK_SCREEN, 0, user_data);
1275 int system_setting_unset_changed_callback_wallpaper_lock_screen(system_settings_key_e key)
1277 SETTING_TRACE_BEGIN;
1278 return system_setting_vconf_unset_changed_cb(VCONFKEY_IDLE_LOCK_BGSET, 0);
1281 int system_setting_set_changed_callback_font_size(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1283 SETTING_TRACE_BEGIN;
1284 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, SYSTEM_SETTINGS_KEY_FONT_SIZE, 1, user_data);
1287 int system_setting_unset_changed_callback_font_size(system_settings_key_e key)
1289 SETTING_TRACE_BEGIN;
1290 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, 1);
1293 int system_setting_set_changed_callback_usb_debugging_option(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1295 SETTING_TRACE_BEGIN;
1296 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_USB_DEBUG_MODE_BOOL, SYSTEM_SETTINGS_KEY_USB_DEBUGGING_ENABLED, 1, user_data);
1299 int system_setting_unset_changed_callback_usb_debugging_option(system_settings_key_e key)
1301 SETTING_TRACE_BEGIN;
1302 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_USB_DEBUG_MODE_BOOL, 1);
1305 int system_setting_set_changed_callback_3g_data_network(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1307 SETTING_TRACE_BEGIN;
1308 return system_setting_vconf_set_changed_cb(VCONFKEY_3G_ENABLE, SYSTEM_SETTINGS_KEY_3G_DATA_NETWORK_ENABLED, 1, user_data);
1311 int system_setting_unset_changed_callback_3g_data_network(system_settings_key_e key)
1313 SETTING_TRACE_BEGIN;
1314 return system_setting_vconf_unset_changed_cb(VCONFKEY_3G_ENABLE, 1);
1317 int system_setting_set_changed_callback_lockscreen_app(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1319 SETTING_TRACE_BEGIN;
1320 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_3RD_LOCK_PKG_NAME_STR, SYSTEM_SETTINGS_KEY_LOCKSCREEN_APP, 1, user_data);
1323 int system_setting_unset_changed_callback_lockscreen_app(system_settings_key_e key)
1325 SETTING_TRACE_BEGIN;
1326 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_3RD_LOCK_PKG_NAME_STR, 1);
1331 * @todo need to add custom event notification method
1333 int system_setting_set_changed_callback_font_type(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_SETAPPL_ACCESSIBILITY_FONT_NAME, SYSTEM_SETTINGS_KEY_FONT_TYPE, 2, user_data);
1339 int system_setting_unset_changed_callback_font_type(system_settings_key_e key)
1341 SETTING_TRACE_BEGIN;
1342 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, 2);
1345 /* TODO : 2th argument, callback, is not in use. */
1346 int system_setting_set_changed_callback_motion_activation(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1348 SETTING_TRACE_BEGIN;
1349 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_MOTION_ACTIVATION, SYSTEM_SETTINGS_KEY_MOTION_ACTIVATION, 3, user_data);
1352 int system_setting_unset_changed_callback_motion_activation(system_settings_key_e key)
1354 SETTING_TRACE_BEGIN;
1355 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_MOTION_ACTIVATION, 3);
1358 /*//////////////////////////////////////////////////////////////////////////////////////// */
1359 /*--------------------------------------- */
1360 int system_setting_get_locale_country(system_settings_key_e key, void **value)
1362 SETTING_TRACE_BEGIN;
1363 char *vconf_value = NULL;
1364 if (system_setting_vconf_get_value_string(VCONFKEY_REGIONFORMAT, &vconf_value)) {
1365 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1368 /* parsing validation */
1371 snprintf(arr, 20, "%s", vconf_value);
1373 *value = strdup(arr);
1377 return SYSTEM_SETTINGS_ERROR_NONE;
1380 /* LCOV_EXCL_START */
1381 int system_setting_set_locale_country(system_settings_key_e key, void *value)
1383 SETTING_TRACE_BEGIN;
1384 char *vconf_value = NULL;
1385 vconf_value = (char *)value;
1387 char *ext = "UTF-8";
1390 snprintf(arr, 20, "%s.%s", vconf_value, ext);
1392 if (system_setting_vconf_set_value_string(VCONFKEY_REGIONFORMAT, arr)) {
1393 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1395 return SYSTEM_SETTINGS_ERROR_NONE;
1397 /* LCOV_EXCL_STOP */
1399 int system_setting_set_changed_callback_locale_country(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1401 SETTING_TRACE_BEGIN;
1402 return system_setting_vconf_set_changed_cb(VCONFKEY_REGIONFORMAT, SYSTEM_SETTINGS_KEY_LOCALE_COUNTRY, 3, user_data);
1405 int system_setting_unset_changed_callback_locale_country(system_settings_key_e key)
1407 SETTING_TRACE_BEGIN;
1408 return system_setting_vconf_unset_changed_cb(VCONFKEY_REGIONFORMAT, 3);
1412 /*--------------------------------------- */
1413 int system_setting_get_locale_language(system_settings_key_e key, void **value)
1415 SETTING_TRACE_BEGIN;
1416 char *vconf_value = NULL;
1417 if (system_setting_vconf_get_value_string(VCONFKEY_LANGSET, &vconf_value)) {
1418 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1421 /* parsing validation */
1424 snprintf(arr, 20, "%s", vconf_value);
1426 *value = strdup(arr);
1429 return SYSTEM_SETTINGS_ERROR_NONE;
1432 /* LCOV_EXCL_START */
1433 int system_setting_set_locale_language(system_settings_key_e key, void *value)
1435 SETTING_TRACE_BEGIN;
1436 char *vconf_value = NULL;
1437 vconf_value = (char *)value;
1439 char *ext = "UTF-8";
1442 snprintf(arr, 20, "%s.%s", vconf_value, ext);
1444 if (system_setting_vconf_set_value_string(VCONFKEY_LANGSET, arr)) {
1445 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1447 return SYSTEM_SETTINGS_ERROR_NONE;
1449 /* LCOV_EXCL_STOP */
1451 int system_setting_set_changed_callback_locale_language(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1453 SETTING_TRACE_BEGIN;
1454 /*return system_setting_vconf_set_changed_cb(VCONFKEY_LANGSET, SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, 3, user_data ); */
1455 return system_setting_vconf_set_changed_cb(VCONFKEY_LANGSET, SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, 100, user_data);
1458 int system_setting_unset_changed_callback_locale_language(system_settings_key_e key)
1460 SETTING_TRACE_BEGIN;
1461 return system_setting_vconf_unset_changed_cb(VCONFKEY_LANGSET, 100);
1464 /*--------------------------------------- */
1465 /* LCOV_EXCL_START */
1466 int system_setting_get_locale_timeformat_24hour(system_settings_key_e key, void **value)
1468 SETTING_TRACE_BEGIN;
1471 if (system_setting_vconf_get_value_int(VCONFKEY_REGIONFORMAT_TIME1224, &vconf_value)) {
1472 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1475 bool ret_value = true;
1476 if (vconf_value == VCONFKEY_TIME_FORMAT_12)
1478 else if (vconf_value == VCONFKEY_TIME_FORMAT_24)
1481 *value = (void *)ret_value;
1483 return SYSTEM_SETTINGS_ERROR_NONE;
1485 /* LCOV_EXCL_STOP */
1487 int system_setting_set_locale_timeformat_24hour(system_settings_key_e key, void *value)
1489 SETTING_TRACE_BEGIN;
1492 vconf_value = (bool *)value;
1495 if (system_setting_vconf_set_value_int(VCONFKEY_REGIONFORMAT_TIME1224, VCONFKEY_TIME_FORMAT_24)) {
1496 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1500 if (system_setting_vconf_set_value_int(VCONFKEY_REGIONFORMAT_TIME1224, VCONFKEY_TIME_FORMAT_12)) {
1501 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1506 return SYSTEM_SETTINGS_ERROR_NONE;
1509 int system_setting_set_changed_callback_locale_timeformat_24hour(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1511 SETTING_TRACE_BEGIN;
1512 return system_setting_vconf_set_changed_cb(VCONFKEY_REGIONFORMAT_TIME1224, SYSTEM_SETTINGS_KEY_LOCALE_TIMEFORMAT_24HOUR, 3, user_data);
1515 int system_setting_unset_changed_callback_locale_timeformat_24hour(system_settings_key_e key)
1517 SETTING_TRACE_BEGIN;
1518 return system_setting_vconf_unset_changed_cb(VCONFKEY_REGIONFORMAT_TIME1224, 3);
1521 int system_setting_get_locale_timezone(system_settings_key_e key, void **value)
1524 ssize_t len = readlink(SETTING_TZONE_SYMLINK_PATH, tzpath, sizeof(tzpath)-1);
1528 SETTING_TRACE("parse error for SETTING_TZONE_SYMLINK_PATH");
1529 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1532 SETTING_TRACE("tzpath : %s ", &tzpath[20]);
1533 *value = strdup(&tzpath[20]);
1534 return SYSTEM_SETTINGS_ERROR_NONE;
1537 /* LCOV_EXCL_START */
1538 int system_setting_set_locale_timezone(system_settings_key_e key, void *value)
1540 SETTING_TRACE_BEGIN;
1541 char *timezone_value = NULL;
1542 timezone_value = (char *)value;
1545 snprintf(tz_path, 1024, "/usr/share/zoneinfo/%s", timezone_value);
1547 int is_load = _is_file_accessible(tz_path);
1549 alarmmgr_set_timezone(tz_path);
1551 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_TIMEZONE_ID, timezone_value)) {
1552 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1554 return SYSTEM_SETTINGS_ERROR_NONE;
1556 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
1558 /* LCOV_EXCL_STOP */
1562 /* LCOV_EXCL_START */
1563 int system_setting_set_changed_callback_locale_timezone(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1565 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_TIMEZONE_ID, SYSTEM_SETTINGS_KEY_LOCALE_TIMEZONE, 4, user_data);
1567 /* LCOV_EXCL_STOP */
1569 /* LCOV_EXCL_START */
1570 int system_setting_unset_changed_callback_locale_timezone(system_settings_key_e key)
1572 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_TIMEZONE_ID, 4);
1574 /* LCOV_EXCL_STOP */
1576 /* LCOV_EXCL_START */
1577 int system_setting_set_changed_callback_locale_timezone_changed(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1579 SETTING_TRACE_BEGIN;
1580 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
1582 /* LCOV_EXCL_STOP */
1584 /* LCOV_EXCL_START */
1585 int system_setting_unset_changed_callback_locale_timezone_changed(system_settings_key_e key)
1587 SETTING_TRACE_BEGIN;
1588 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
1590 /* LCOV_EXCL_STOP */
1593 /* LCOV_EXCL_START */
1594 int system_setting_get_time_changed(system_settings_key_e key, void **value)
1596 SETTING_TRACE_BEGIN;
1598 int ** val = (int**)value;
1599 cur_tick = time(NULL);
1601 /* struct tm * localtime = time (cur_tick); */
1602 /* printf("%s\n", ctime(&cur_tick); */
1603 return SYSTEM_SETTINGS_ERROR_NONE;
1606 /* LCOV_EXCL_STOP */
1608 int system_setting_set_changed_callback_time_changed(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1610 SETTING_TRACE_BEGIN;
1611 return system_setting_vconf_set_changed_cb(VCONFKEY_SYSTEM_TIME_CHANGED, SYSTEM_SETTINGS_KEY_TIME_CHANGED, 3, user_data);
1614 int system_setting_unset_changed_callback_time_changed(system_settings_key_e key)
1616 SETTING_TRACE_BEGIN;
1617 return system_setting_vconf_unset_changed_cb(VCONFKEY_SYSTEM_TIME_CHANGED, 3);
1622 /* SYSTEM_SETTINGS_KEY_SOUND_LOCK */
1623 int system_setting_get_sound_lock(system_settings_key_e key, void **value)
1625 SETTING_TRACE_BEGIN;
1628 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_SOUND_LOCK_BOOL, &vconf_value)) {
1629 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1631 *value = (void *)vconf_value;
1633 return SYSTEM_SETTINGS_ERROR_NONE;
1636 int system_setting_set_changed_callback_sound_lock(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_SETAPPL_SOUND_LOCK_BOOL, SYSTEM_SETTINGS_KEY_SOUND_LOCK, 3, user_data);
1642 int system_setting_unset_changed_callback_sound_lock(system_settings_key_e key)
1644 SETTING_TRACE_BEGIN;
1645 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_SOUND_LOCK_BOOL, 3);
1649 * a = VCONFKEY_SETAPPL_SOUND_STATUS_BOOL b = VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL
1651 * a == false, b == false --> silent mode
1652 * a == true, b == false --> sound mode
1653 * a == false, b == true --> vibration mode
1655 /* LCOV_EXCL_START */
1656 int system_setting_get_sound_silent_mode(system_settings_key_e key, void **value)
1658 SETTING_TRACE_BEGIN;
1663 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, &sound_cond)) {
1664 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1667 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, &vib_cond)) {
1668 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1671 if (sound_cond == false && vib_cond == false) {
1673 *value = (void *)vconf_value;
1675 vconf_value = false;
1676 *value = (void *)vconf_value;
1678 return SYSTEM_SETTINGS_ERROR_NONE;
1680 /* LCOV_EXCL_STOP */
1683 * a = VCONFKEY_SETAPPL_SOUND_STATUS_BOOL b = VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL
1685 * a == false, b == false --> silent mode
1686 * a == true, b == false --> sound mode
1688 int system_setting_set_sound_silent_mode(system_settings_key_e key, void *value)
1690 SETTING_TRACE_BEGIN;
1693 vconf_value = (bool *)value;
1695 bool vconf_sound = false;
1696 bool vconf_vib = false;
1699 vconf_sound = false;
1706 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, vconf_sound)) {
1707 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1709 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, vconf_vib)) {
1710 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1713 return SYSTEM_SETTINGS_ERROR_NONE;
1719 int system_setting_set_changed_callback_sound_silent_mode(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1721 SETTING_TRACE_BEGIN;
1722 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, SYSTEM_SETTINGS_KEY_SOUND_SILENT_MODE, 3, user_data);
1726 int system_setting_unset_changed_callback_sound_silent_mode(system_settings_key_e key)
1728 SETTING_TRACE_BEGIN;
1729 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, 3);
1732 /* SYSTEM_SETTINGS_KEY_SOUND_TOUCH */
1733 int system_setting_get_sound_touch(system_settings_key_e key, void **value)
1735 SETTING_TRACE_BEGIN;
1738 int ret = system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL, &vconf_value);
1739 if (ret != SYSTEM_SETTINGS_ERROR_NONE) {
1742 *value = (void *)vconf_value;
1746 int system_setting_set_changed_callback_sound_touch(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_TOUCH_SOUNDS_BOOL, SYSTEM_SETTINGS_KEY_SOUND_TOUCH, 2, user_data);
1752 int system_setting_unset_changed_callback_sound_touch(system_settings_key_e key)
1754 SETTING_TRACE_BEGIN;
1755 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL, 2);
1759 /* SYSTEM_SETTINGS_KEY_SOUND_LOCK */
1760 int system_setting_get_sound_lock(system_settings_key_e key, void **value)
1764 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_SOUND_LOCK_BOOL, &vconf_value)) {
1765 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1767 *value = (void *)vconf_value;
1769 return SYSTEM_SETTINGS_ERROR_NONE;
1773 int system_setting_get_auto_rotation_mode(system_settings_key_e key, void **value)
1775 SETTING_TRACE_BEGIN;
1778 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, &vconf_value)) {
1779 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1781 *value = (void *)vconf_value;
1783 return SYSTEM_SETTINGS_ERROR_NONE;
1786 /* LCOV_EXCL_START */
1787 int system_setting_set_auto_rotation_mode(system_settings_key_e key, void *value)
1789 SETTING_TRACE_BEGIN;
1791 vconf_value = (bool *)value;
1792 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, *vconf_value)) {
1793 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1796 return SYSTEM_SETTINGS_ERROR_NONE;
1798 /* LCOV_EXCL_STOP */
1800 int system_setting_set_changed_callback_auto_rotation_mode(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1802 SETTING_TRACE_BEGIN;
1803 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, SYSTEM_SETTINGS_KEY_DISPLAY_SCREEN_ROTATION_AUTO, 2, user_data);
1806 int system_setting_unset_changed_callback_auto_rotation_mode(system_settings_key_e key)
1808 SETTING_TRACE_BEGIN;
1809 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, 2);
1812 int system_setting_get_screen_backlight_time(system_settings_key_e key, void **value)
1814 SETTING_TRACE_BEGIN;
1816 int ** val = (int**)value;
1818 if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, &vconf_value)) {
1819 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1821 **val = vconf_value;
1823 return SYSTEM_SETTINGS_ERROR_NONE;
1827 /* LCOV_EXCL_START */
1828 int system_setting_set_screen_backlight_time(system_settings_key_e key, void *value)
1830 SETTING_TRACE_BEGIN;
1832 vconf_value = *(int **)value;
1834 if (!(*vconf_value > 0 && *vconf_value <= 600)) {
1835 SETTING_TRACE(" ERR Betweeny here 0 ~ 600");
1836 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
1839 if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, *vconf_value)) {
1840 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1843 return SYSTEM_SETTINGS_ERROR_NONE;
1845 /* LCOV_EXCL_STOP */
1847 int system_setting_set_changed_callback_screen_backlight_time(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1849 SETTING_TRACE_BEGIN;
1850 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, SYSTEM_SETTINGS_KEY_SCREEN_BACKLIGHT_TIME, 2, user_data);
1853 int system_setting_unset_changed_callback_screen_backlight_time(system_settings_key_e key)
1855 SETTING_TRACE_BEGIN;
1856 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, 2);
1859 int system_setting_get_sound_notification(system_settings_key_e key, void **value)
1861 SETTING_TRACE_BEGIN;
1862 char *vconf_value = NULL;
1863 if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, &vconf_value)) {
1864 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1867 *value = vconf_value;
1868 return SYSTEM_SETTINGS_ERROR_NONE;
1871 /* LCOV_EXCL_START */
1872 int system_setting_set_sound_notification(system_settings_key_e key, void *value)
1874 SETTING_TRACE_BEGIN;
1875 char *vconf_value = NULL;
1876 vconf_value = (char *)value;
1878 int is_load = _is_file_accessible(vconf_value);
1880 //SETTING_TRACE(" system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, %s) TRY", vconf_value);
1881 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, vconf_value)) {
1882 //SETTING_TRACE(" system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, %s) FAIL", vconf_value);
1883 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1886 //SETTING_TRACE(" is_file_accessibile FAILED - system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, %s) FAIL", vconf_value);
1887 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1890 return SYSTEM_SETTINGS_ERROR_NONE;
1892 /* LCOV_EXCL_STOP */
1894 int system_setting_set_changed_callback_sound_notification(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1896 SETTING_TRACE_BEGIN;
1897 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, SYSTEM_SETTINGS_KEY_SOUND_NOTIFICATION, 0, user_data);
1900 int system_setting_unset_changed_callback_sound_notification(system_settings_key_e key)
1902 SETTING_TRACE_BEGIN;
1903 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, 0);
1906 int system_setting_get_notification_repetition_period(system_settings_key_e key, void **value)
1908 SETTING_TRACE_BEGIN;
1909 int ** val = (int**)value;
1912 if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_NOTI_MSG_ALERT_REP_TYPE_INT, &vconf_value)) {
1913 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1915 **val = vconf_value;
1917 return SYSTEM_SETTINGS_ERROR_NONE;
1920 /* LCOV_EXCL_START */
1921 int system_setting_set_notification_repetition_period(system_settings_key_e key, void *value)
1923 SETTING_TRACE_BEGIN;
1925 vconf_value = *(int **)value;
1927 if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_NOTI_MSG_ALERT_REP_TYPE_INT, *vconf_value)) {
1928 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1931 return SYSTEM_SETTINGS_ERROR_NONE;
1933 /* LCOV_EXCL_STOP */
1935 int system_setting_set_changed_callback_notification_repetition_period(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1937 SETTING_TRACE_BEGIN;
1938 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);
1941 int system_setting_unset_changed_callback_notification_repetition_period(system_settings_key_e key)
1943 SETTING_TRACE_BEGIN;
1944 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_ALERT_REP_TYPE_INT, 1);
1947 int system_setting_get_device_name(system_settings_key_e key, void **value)
1949 SETTING_TRACE_BEGIN;
1950 char *vconf_value = NULL;
1951 if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_DEVICE_NAME_STR, &vconf_value)) {
1952 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1955 *value = vconf_value;
1956 return SYSTEM_SETTINGS_ERROR_NONE;
1959 /* LCOV_EXCL_START */
1960 int system_setting_set_device_name(system_settings_key_e key, void *value)
1962 SETTING_TRACE_BEGIN;
1963 char *vconf_value = NULL;
1964 vconf_value = (char *)value;
1966 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_DEVICE_NAME_STR, vconf_value)) {
1967 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1970 return SYSTEM_SETTINGS_ERROR_NONE;
1972 /* LCOV_EXCL_STOP */
1974 int system_setting_set_changed_callback_device_name(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1976 SETTING_TRACE_BEGIN;
1977 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_DEVICE_NAME_STR, SYSTEM_SETTINGS_KEY_DEVICE_NAME, 0, user_data);
1980 int system_setting_unset_changed_callback_device_name(system_settings_key_e key)
1982 SETTING_TRACE_BEGIN;
1983 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_DEVICE_NAME_STR, 0);
1986 /*---------------------------------------------- */
1987 int system_setting_get_network_flight_mode(system_settings_key_e key, void **value)
1989 SETTING_TRACE_BEGIN;
1991 if (system_setting_vconf_get_value_bool(VCONFKEY_TELEPHONY_FLIGHT_MODE, &vconf_value)) {
1992 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1994 *value = (void *)vconf_value;
1996 return SYSTEM_SETTINGS_ERROR_NONE;
1999 int system_setting_set_changed_callback_network_flight_mode(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
2001 SETTING_TRACE_BEGIN;
2002 return system_setting_vconf_set_changed_cb(VCONFKEY_TELEPHONY_FLIGHT_MODE, SYSTEM_SETTINGS_KEY_NETWORK_FLIGHT_MODE, 3, user_data);
2005 int system_setting_unset_changed_callback_network_flight_mode(system_settings_key_e key)
2007 SETTING_TRACE_BEGIN;
2008 return system_setting_vconf_unset_changed_cb(VCONFKEY_TELEPHONY_FLIGHT_MODE, 3);
2011 int system_setting_get_network_wifi_notification(system_settings_key_e key, void **value)
2013 SETTING_TRACE_BEGIN;
2015 if (system_setting_vconf_get_value_int(VCONFKEY_WIFI_ENABLE_QS, &vconf_value)) {
2016 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2019 bret = (vconf_value == VCONFKEY_WIFI_QS_ENABLE) ? true : false;
2021 *value = (void *)bret;
2022 return SYSTEM_SETTINGS_ERROR_NONE;
2025 int system_setting_set_changed_callback_network_wifi_notification(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
2027 SETTING_TRACE_BEGIN;
2028 return system_setting_vconf_set_changed_cb(VCONFKEY_WIFI_ENABLE_QS, SYSTEM_SETTINGS_KEY_NETWORK_WIFI_NOTIFICATION, 4, user_data);
2031 int system_setting_unset_changed_callback_network_wifi_notification(system_settings_key_e key)
2033 SETTING_TRACE_BEGIN;
2034 return system_setting_vconf_unset_changed_cb(VCONFKEY_WIFI_ENABLE_QS, 4);
2037 /* LCOV_EXCL_START */
2038 int system_setting_get_lock_state(system_settings_key_e key, void **value)
2041 int ** val = (int**)value;
2043 if (system_setting_vconf_get_value_int(VCONFKEY_IDLE_LOCK_STATE_READ_ONLY, &vconf_value)) {
2044 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2046 **val = vconf_value;
2048 return SYSTEM_SETTINGS_ERROR_NONE;
2050 /* LCOV_EXCL_STOP */
2052 /* LCOV_EXCL_START */
2053 int system_setting_set_lock_state(system_settings_key_e key, void *value)
2055 SETTING_TRACE_BEGIN;
2057 vconf_value = *(int **)value;
2059 if (system_setting_vconf_set_value_int(VCONFKEY_IDLE_LOCK_STATE_READ_ONLY, *vconf_value)) {
2060 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2063 return SYSTEM_SETTINGS_ERROR_NONE;
2065 /* LCOV_EXCL_STOP */
2067 /* LCOV_EXCL_START */
2068 int system_setting_set_changed_callback_lock_state(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
2070 return system_setting_vconf_set_changed_cb(VCONFKEY_IDLE_LOCK_STATE_READ_ONLY, SYSTEM_SETTINGS_KEY_LOCK_STATE, 4, user_data);
2072 /* LCOV_EXCL_STOP */
2074 /* LCOV_EXCL_START */
2075 int system_setting_unset_changed_callback_lock_state(system_settings_key_e key)
2077 return system_setting_vconf_unset_changed_cb(VCONFKEY_IDLE_LOCK_STATE_READ_ONLY, 4);
2079 /* LCOV_EXCL_STOP */
2081 //----------------------------------------------------------------------------------------------------------------------------
2083 #define DEFAULT_ADS_ID "00000000-0000-0000-0000-000000000000"
2085 int system_setting_get_ads_id(system_settings_key_e key, void **value)
2087 SETTING_TRACE_BEGIN;
2088 int optout_value = 0;
2089 if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_AD_ID_OPT_OUT, &optout_value)) {
2090 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2093 if (optout_value == 1) {
2094 *value = strdup(DEFAULT_ADS_ID);
2095 return SYSTEM_SETTINGS_ERROR_NONE;
2098 char *vconf_value = NULL;
2099 if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_AD_ID, &vconf_value)) {
2100 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2103 *value = vconf_value;
2104 return SYSTEM_SETTINGS_ERROR_NONE;
2109 void make_ad_id(void)
2112 char uuid_unparsed[50] = {0};
2113 uuid_generate(uuid_value);
2114 uuid_unparse(uuid_value, uuid_unparsed);
2115 system_setting_set_ad_id(key, uuid_unparsed); //example of setting the value
2118 /* LCOV_EXCL_START */
2119 int system_setting_set_ads_id(system_settings_key_e key, void *value)
2121 SETTING_TRACE_BEGIN;
2122 char *vconf_value = NULL;
2123 vconf_value = (char *)value;
2125 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_AD_ID, vconf_value)) {
2126 SETTING_TRACE("Setting VCONFKEY_SETAPPL_AD_ID failed");
2127 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2130 return SYSTEM_SETTINGS_ERROR_NONE;
2132 /* LCOV_EXCL_STOP */
2134 int system_setting_set_changed_callback_ads_id(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
2136 SETTING_TRACE_BEGIN;
2137 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_AD_ID, SYSTEM_SETTINGS_KEY_ADS_ID, 0, user_data);
2140 int system_setting_unset_changed_callback_ads_id(system_settings_key_e key)
2142 SETTING_TRACE_BEGIN;
2143 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_AD_ID, 0);
2146 int system_settings_feature_check_bool(char *path)
2148 bool profile_data = false;
2149 int ret = system_info_get_platform_bool(path, &profile_data);
2150 if (ret != SYSTEM_INFO_ERROR_NONE) {
2151 SETTING_TRACE("Setting - reading profile string failed, %d", ret);
2152 return SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED;
2155 ret = (profile_data == true) ? SYSTEM_SETTINGS_ERROR_NONE : SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED;
2161 int system_setting_feature_check_incoming_call(void * value)
2163 static bool first_query = true;
2164 static int ret = SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED;
2166 if (first_query == true) {
2167 ret = system_settings_feature_check_bool(SETTING_INCOMING_CALL_PATH);
2168 first_query = false;
2174 int system_setting_feature_check_home_screen(void * value)
2176 static bool first_query = true;
2177 static int ret = SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED;
2179 if (first_query == true) {
2180 ret = system_settings_feature_check_bool(SETTING_HOME_SCREEN_PATH);
2181 first_query = false;
2187 int system_setting_feature_check_lock_screen(void * value)
2189 static bool first_query = true;
2190 static int ret = SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED;
2192 if (first_query == true) {
2193 ret = system_settings_feature_check_bool(SETTING_LOCK_SCREEN_PATH);
2194 first_query = false;
2200 int system_setting_feature_check_notification_email(void * value)
2202 static bool first_query = true;
2203 static int ret = SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED;
2205 if (first_query == true) {
2206 ret = system_settings_feature_check_bool(SETTING_NOTIFICATION_EMAIL_PATH);
2207 first_query = false;
2213 int system_setting_feature_check_wifi(void * value)
2215 static bool first_query = true;
2216 static int ret = SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED;
2218 if (first_query == true) {
2219 ret = system_settings_feature_check_bool(SETTING_WIFI_PATH);
2220 first_query = false;
2226 int system_setting_feature_check_telephony(void * value)
2228 static bool first_query = true;
2229 static int ret = SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED;
2231 if (first_query == true) {
2232 ret = system_settings_feature_check_bool(SETTING_TELEPHONY_PATH);
2233 first_query = false;
2239 /* LCOV_EXCL_START */
2240 int system_setting_get_uds_state(system_settings_key_e key, void **value)
2242 int ** p_value = (int**)value;
2244 char *vconf_string_value = NULL;
2246 if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_UDSM, &vconf_value)) {
2247 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2250 SETTING_TRACE("[%s] udsm: %d", __FUNCTION__, vconf_value);
2252 if (vconf_value == SYSTEM_SETTINGS_UDS_ON) {
2253 if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_UDSM_PKGID_LIST, &vconf_string_value))
2254 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2256 if (vconf_string_value) {
2257 if (!strcmp(vconf_string_value, "NONE")) {
2258 vconf_value = SYSTEM_SETTINGS_UDS_ON;
2260 char *app_id = NULL;
2261 char *package_id = NULL;
2262 pid_t pid = getpid();
2263 app_manager_get_app_id(pid, &app_id);
2266 package_manager_get_package_id_by_app_id(app_id, &package_id);
2267 SETTING_TRACE("[%s] udsm_pkg_list : %s", __FUNCTION__, vconf_string_value);
2270 if (package_id && strstr(vconf_string_value, package_id)) {
2271 vconf_value = SYSTEM_SETTINGS_UDS_ON_WHITELISTED;
2272 SETTING_TRACE("[%s] pkg id : %s", __FUNCTION__, package_id);
2274 vconf_value = SYSTEM_SETTINGS_UDS_ON;
2278 if (vconf_string_value)
2279 free(vconf_string_value);
2283 **p_value = vconf_value;
2286 return SYSTEM_SETTINGS_ERROR_NONE;
2288 /* LCOV_EXCL_STOP */
2290 /* LCOV_EXCL_START */
2291 int system_setting_set_changed_callback_uds_state(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
2293 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_UDSM, SYSTEM_SETTINGS_KEY_ULTRA_DATA_SAVE, 4, user_data);
2295 /* LCOV_EXCL_STOP */
2297 /* LCOV_EXCL_START */
2298 int system_setting_unset_changed_callback_uds_state(system_settings_key_e key)
2300 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_UDSM, 4);
2302 /* LCOV_EXCL_STOP */
2304 /* LCOV_EXCL_START */
2305 int system_setting_set_changed_callback_uds_pkg_list(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
2307 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_UDSM_PKGID_LIST, SYSTEM_SETTINGS_KEY_ULTRA_DATA_SAVE_PKG_LIST, 4, user_data);
2309 /* LCOV_EXCL_STOP */
2311 /* LCOV_EXCL_START */
2312 int system_setting_unset_changed_callback_uds_pkg_list(system_settings_key_e key)
2314 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_UDSM_PKGID_LIST, 4);
2316 /* LCOV_EXCL_STOP */
2318 /* SYSTEM_SETTINGS_KEY_ACCESSIBILITY_TTS */
2319 int system_setting_get_accessibility_tts(system_settings_key_e key, void **value)
2321 SETTING_TRACE_BEGIN;
2324 int ret = system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_ACCESSIBILITY_TTS, &vconf_value);
2325 if (ret != SYSTEM_SETTINGS_ERROR_NONE) {
2328 *value = (void *)vconf_value;
2332 int system_setting_set_changed_callback_accessibility_tts(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
2334 SETTING_TRACE_BEGIN;
2335 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_TTS, SYSTEM_SETTINGS_KEY_ACCESSIBILITY_TTS, 2, user_data);
2338 int system_setting_unset_changed_callback_accessibility_tts(system_settings_key_e key)
2340 SETTING_TRACE_BEGIN;
2341 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_TTS, 2);
2344 /* SYSTEM_SETTINGS_KEY_VIBRATION */
2345 int system_setting_get_vibration(system_settings_key_e key, void **value)
2347 SETTING_TRACE_BEGIN;
2350 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, &vconf_value)) {
2351 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2353 *value = (void *)vconf_value;
2355 return SYSTEM_SETTINGS_ERROR_NONE;
2358 /* LCOV_EXCL_START */
2359 int system_setting_set_vibration(system_settings_key_e key, void *value)
2361 SETTING_TRACE_BEGIN;
2363 vconf_value = (bool *)value;
2364 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, *vconf_value)) {
2365 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2368 return SYSTEM_SETTINGS_ERROR_NONE;
2370 /* LCOV_EXCL_STOP */
2372 int system_setting_set_changed_callback_vibration(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
2374 SETTING_TRACE_BEGIN;
2375 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, SYSTEM_SETTINGS_KEY_VIBRATION, 2, user_data);
2378 int system_setting_unset_changed_callback_vibration(system_settings_key_e key)
2380 SETTING_TRACE_BEGIN;
2381 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, 2);
2385 static void simple_test_case(void)
2387 /* a suitable test */
2388 g_assert(g_bit_storage(1) == 1);
2390 /* a test with verbose error message */
2391 g_assert_cmpint(g_bit_storage(1), ==, 1);
2394 static void simple_test_case02(void)
2396 /* a suitable test */
2397 g_assert(g_bit_storage(1) == 1);
2399 /* a test with verbose error message */
2400 g_assert_cmpint(g_bit_storage(1), ==, 1);
2402 void unittest_platform()
2404 /* hook up your test functions */
2405 g_test_add_func("/Simple Test Case", simple_test_case);
2406 g_test_add_func("/Simple Test Case02", simple_test_case02);
2407 /* run tests from the suite */