2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
25 #include <sys/types.h>
36 #include <libxml/xmlmemory.h>
37 #include <libxml/parser.h>
39 #include <fontconfig/fontconfig.h>
41 #include <pkgmgr-info.h>
42 #include <package_manager.h>
43 #include <app_manager.h>
45 #include <system_settings.h>
46 #include <system_settings_private.h>
47 #include <system_settings_ringtones.h>
48 #include <system_settings_json.h>
50 #include <system-setting-config.h>
52 #include <tzplatform_config.h>
55 #include <system_info.h>
57 #define SETTING_FONT_CONF_FILE _TZ_SYS_ETC"/fonts/conf.avail/99-tizen.conf"
58 #define SETTING_DEFAULT_FONT_CONF_FILE _TZ_SYS_ETC"/fonts/conf.avail/99-tizen.conf"
60 #define SETTING_TIME_ZONEINFO_PATH "/usr/share/zoneinfo/"
61 #define SETTING_TIME_SHARE_LOCAL_PATH "/usr/share/locale"
62 #define SETTING_TZONE_SYMLINK_PATH "/opt/etc/localtime"
65 #define __FREE(del, arg) do { \
67 del((void *)(arg)); /*cast any argument to (void*) to avoid build warring*/\
71 #define FREE(arg) __FREE(free, arg)
73 #ifdef SETTING_ARCH_64
74 #define SETTING_UTILS_SO_FILE_PATH "/usr/lib64/libsystem-settings-util.so.0.1.0"
76 #define SETTING_UTILS_SO_FILE_PATH "/usr/lib/libsystem-settings-util.so.0.1.0"
79 int _is_file_accessible(const char *path);
81 static bool dl_is_supported_image_type_load(char *path);
82 static bool dl_font_config_set(char *font_name);
83 static char *dl_get_default_font_info();
84 static int dl_is_available_font(char *str);
85 static void dl_font_size_set();
86 static void dl_font_config_set_notification();
89 #ifndef VCONFKEY_SETAPPL_UDSM
90 #define VCONFKEY_SETAPPL_UDSM "db/setting/udsm"
93 #ifndef VCONFKEY_SETAPPL_UDSM_PKGID_LIST
94 #define VCONFKEY_SETAPPL_UDSM_PKGID_LIST "db/setting/udsm/pkgid_list"
99 * VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR has a path of the ringtone file which user choose
100 * @return the ringtone file path specified by user in normal case
101 * if it's not accessable, return the default ringtone path
103 int system_setting_get_incoming_call_ringtone(system_settings_key_e key, 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, 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, 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, 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, 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, void **value)
191 char *font_name = dl_get_default_font_info();
193 *value = (void *)font_name;
194 return SYSTEM_SETTINGS_ERROR_NONE;
196 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
200 /* [int] vconf GET */
201 int system_setting_get_font_type(system_settings_key_e key, void **value)
204 char *font_name = NULL;
206 if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, &font_name)) {
207 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
211 return SYSTEM_SETTINGS_ERROR_NONE;
215 int system_setting_get_motion_activation(system_settings_key_e key, void **value)
220 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_MOTION_ACTIVATION, &vconf_value)) {
221 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
223 *value = (void *)vconf_value;
225 return SYSTEM_SETTINGS_ERROR_NONE;
228 int system_setting_get_usb_debugging_option(system_settings_key_e key, void **value)
233 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_USB_DEBUG_MODE_BOOL, &vconf_value)) {
234 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
236 *value = (void *)vconf_value;
238 return SYSTEM_SETTINGS_ERROR_NONE;
241 int system_setting_get_3g_data_network(system_settings_key_e key, void **value)
246 if (system_setting_vconf_get_value_bool(VCONFKEY_3G_ENABLE, &vconf_value)) {
247 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
249 *value = (void *)vconf_value;
251 return SYSTEM_SETTINGS_ERROR_NONE;
253 /*////////////////////////////////////////////////////////////////////////////////////////////////// */
257 * get current lock scren app package name (string)
259 * @return SYSTEM_SETTINGS_ERROR_LOCKSCREEN_APP_PASSWORD_MODE raise exception if current lock type is 'password'
261 int system_setting_get_lockscreen_app(system_settings_key_e key, void **value)
264 char *pkg_name = NULL;
266 if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_SCREEN_LOCK_TYPE_INT, &locktype)) {
267 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
270 if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_3RD_LOCK_PKG_NAME_STR, &pkg_name)) {
271 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
274 if (pkg_name && strcmp(pkg_name, "com.samsung.lockscreen") == 0 && locktype == SETTING_SCREEN_LOCK_TYPE_PASSWORD) {
275 return SYSTEM_SETTINGS_ERROR_LOCKSCREEN_APP_PASSWORD_MODE;
279 return SYSTEM_SETTINGS_ERROR_NONE;
283 /*////////////////////////////////////////////////////////////////////////////////////////////////// */
285 int _is_file_accessible(const char *path)
288 int ret = access(path , R_OK);
290 SETTING_TRACE("found the file %s", path);
293 /* error code : 13 */
294 SETTING_TRACE("found the file %s --- error code : %d ", path, errno);
301 /*////////////////////////////////////////////////////////////////////////////////////////////////// */
302 // @todo move to CMake
303 #define DEF_RINGTONE_FILE_PATH SETTING_DEF_RES"/Ringtones"
305 #define USR_RINGTONE_FILE_PATH "/home/owner/content/Sounds/Ringtones"
306 #define JSONFILE "/opt/home/owner/apps_rw/org.tizen.setting/data/.user-ringtones.json"
309 static char* _get_json_file_path()
316 int system_setting_add_incoming_call_ringtone(system_settings_key_e key, void *value)
319 char* pathval = (char*)value;
320 char* dnameval = NULL;
321 char* baseval = NULL;
325 JsonParser *parser = ss_json_ringtone_open_file(JSONFILE);
327 JsonParser *parser = ss_json_ringtone_load_from_data();
330 JsonNode *root = json_parser_get_root(parser);
334 int ret = SYSTEM_SETTINGS_ERROR_NONE;
335 if (false == ss_json_ringtone_contain(root, pathval)) {
336 // @todo : MAKE SURE THE ACTUAL FILE IS THERE ON PATHVAL(SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER)
337 ss_json_ringtone_add(root, JSONFILE, pathval, pathval);
338 SETTING_TRACE("pathval is : %s -- OK", pathval);
340 SETTING_TRACE("pathval is duplicated : %s", pathval);
341 ret = SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
344 dnameval = strdup(pathval);
345 baseval = strdup(pathval);
346 if (dnameval && baseval) {
347 SETTING_TRACE("---> dirname is : %s ", dirname(dnameval));
348 SETTING_TRACE("---> basename is : %s ", basename(baseval));
354 g_object_unref(parser);
361 int system_setting_del_incoming_call_ringtone(system_settings_key_e key, void *value)
364 char* pathval = (char*)value;
367 JsonParser* parser = ss_json_ringtone_open_file(JSONFILE);
369 JsonParser* parser = ss_json_ringtone_load_from_data();
371 JsonNode *root = json_parser_get_root(parser);
373 ss_json_ringtone_remove(root, JSONFILE, pathval);
374 //void ss_json_ringtone_remove(JsonNode *root, char* filename, char* path_to_del)
376 ss_json_ringtone_print(root);
378 g_object_unref(parser);
382 return SYSTEM_SETTINGS_ERROR_NONE;
386 static int _compare_cb(const void *d1, const void *d2)
388 fileNodeInfo *pNode1 = (fileNodeInfo *)d1;
389 fileNodeInfo *pNode2 = (fileNodeInfo *)d2;
391 return strcmp(pNode1->media_name, pNode2->media_name);
395 * get the RINGTONE list
397 static void _get_default_ringtones(system_settings_key_e key, system_settings_iter_cb callback, void *data)
401 Eina_List *filelist = NULL;
403 fileNodeInfo *node = NULL;
406 //-----------------------------------------------------------------------------------------------------------------
407 // 1. get the default ringtone list
408 //-----------------------------------------------------------------------------------------------------------------
409 int ret = get_filelist_from_dir_path(DEF_RINGTONE_FILE_PATH, &filelist);
411 SETTING_TRACE("Failed to get filelist, ret = %d %s", ret, DEF_RINGTONE_FILE_PATH);
413 filelist = eina_list_sort(filelist, eina_list_count(filelist), _compare_cb);
415 EINA_LIST_FOREACH(filelist, l, node)
417 SETTING_TRACE("file path = (%d) : name:%s path:%s [%s]", ret, node->name, node->path, node->media_name);
418 // @todo assert NULL check
421 snprintf(temp, 1024, "%s/%s", node->path, node->name);
422 char* path = strdup(temp);
423 bool ret = callback(idx, (void *)(path), data);
429 SETTING_TRACE("quit the iteration by return value == false : %d", ret);
434 SETTING_TRACE("--> system_setting_data_iterator is NULL");
440 EINA_LIST_FOREACH(filelist, l, node)
444 FREE(node->media_name);
447 eina_list_free(filelist);
452 static void _get_user_ringtones(system_settings_key_e key, system_settings_iter_cb callback, void *data)
458 JsonParser* parser = ss_json_ringtone_open_file(JSONFILE);
460 JsonParser* parser = ss_json_ringtone_load_from_data();
463 JsonNode *root = json_parser_get_root(parser);
464 int size = json_array_get_length(json_node_get_array(root));
467 for (i = 0; i < size ; i++) {
468 JsonObject *ringtone = json_array_get_object_element(json_node_get_array(root), i);
469 char *nameval = (char *)json_object_get_string_member(ringtone, "name");
470 char *pathval = (char *)json_object_get_string_member(ringtone, "path");
471 SETTING_TRACE("(%s) --- (%s) \n", nameval, pathval);
473 char* path = strdup(pathval);
474 bool ret = callback(i, (void *)(path), data);
476 SETTING_TRACE("quit the iteration by return value == false : %d", ret);
480 SETTING_TRACE("--> callback is NULL");
485 int system_setting_list_incoming_call_ringtone(system_settings_key_e key, system_settings_iter_cb callback, void *data)
489 _get_default_ringtones(key, callback, data);
490 //-----------------------------------------------------------------------------------------------------------------
491 // 2. get the USER ringtone list
492 //-----------------------------------------------------------------------------------------------------------------
493 _get_user_ringtones(key, callback, data);
495 return SYSTEM_SETTINGS_ERROR_NONE;
499 /* LCOV_EXCL_START */
500 int system_setting_set_incoming_call_ringtone(system_settings_key_e key, void *value)
504 vconf_value = (char *)value;
506 int ret = _is_file_accessible(vconf_value);
508 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR, vconf_value)) {
509 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
512 /* @todo add a common ret_handler */
516 return SYSTEM_SETTINGS_ERROR_NONE;
521 /* LCOV_EXCL_START */
522 int system_setting_set_email_alert_ringtone(system_settings_key_e key, void *value)
526 vconf_value = (char *)value;
528 int ret = _is_file_accessible(vconf_value);
530 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, vconf_value)) {
531 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
534 /*return SYSTEM_SETTINGS_ERROR_IO_ERROR;*/
535 /* @todo add a common ret_handler */
539 return SYSTEM_SETTINGS_ERROR_NONE;
543 /* LCOV_EXCL_START */
544 static bool dl_is_supported_image_type_load(char *path)
549 bool (*image_type_check)(char *path);
551 handle = dlopen(SETTING_UTILS_SO_FILE_PATH, RTLD_LAZY);
553 SETTING_TRACE("ERROR!! canNOT find libsystem-settings-util.so.0.1.0");
557 image_type_check = dlsym(handle, "__is_supported_image_type_load");
558 if ((error = dlerror()) != NULL) {
559 SETTING_TRACE("ERROR!! canNOT find __is_supported_image_type_load function at libsystem-settings-util.so.0.1.0");
564 ret = image_type_check(path);
571 /* LCOV_EXCL_START */
572 static int dl_is_available_font(char *str)
577 int (*check_available_font)(char *font_name);
579 handle = dlopen(SETTING_UTILS_SO_FILE_PATH, RTLD_LAZY);
581 SETTING_TRACE("ERROR!! canNOT find libsystem-settings-util.so.0.1.0");
585 check_available_font = dlsym(handle, "__is_available_font");
586 if ((error = dlerror()) != NULL) {
587 SETTING_TRACE("ERROR!! canNOT find __is_available_font function at libsystem-settings-util.so.0.1.0");
592 ret = check_available_font(str);
599 /* LCOV_EXCL_START */
600 static void dl_font_size_set()
604 void (*set_font_size)();
606 handle = dlopen(SETTING_UTILS_SO_FILE_PATH, RTLD_LAZY);
608 SETTING_TRACE("ERROR!! canNOT find libsystem-settings-util.so.0.1.0");
612 set_font_size = dlsym(handle, "__font_size_set");
613 if ((error = dlerror()) != NULL) {
614 SETTING_TRACE("ERROR!! canNOT find __font_size_set function at libsystem-settings-util.so.0.1.0");
626 /* LCOV_EXCL_START */
627 static void dl_font_config_set_notification()
631 void (*set_font_nodification)();
633 handle = dlopen(SETTING_UTILS_SO_FILE_PATH, RTLD_LAZY);
635 SETTING_TRACE("ERROR!! canNOT find libsystem-settings-util.so.0.1.0");
639 set_font_nodification = dlsym(handle, "font_config_set_notification");
640 if ((error = dlerror()) != NULL) {
641 SETTING_TRACE("ERROR!! canNOT find font_config_set_notification function at libsystem-settings-util.so.0.1.0");
646 set_font_nodification();
653 /* LCOV_EXCL_START */
654 static bool dl_font_config_set(char *font_name)
659 bool (*check_font_type)(char *font_name);
661 handle = dlopen(SETTING_UTILS_SO_FILE_PATH, RTLD_LAZY);
663 SETTING_TRACE("ERROR!! canNOT find libsystem-settings-util.so.0.1.0");
667 check_font_type = dlsym(handle, "font_config_set");
668 if ((error = dlerror()) != NULL) {
669 SETTING_TRACE("ERROR!! canNOT find font_config_set function at libsystem-settings-util.so.0.1.0");
674 ret = check_font_type(font_name);
681 /* LCOV_EXCL_START */
682 static char *dl_get_default_font_info()
687 char *(*get_font_info)();
689 handle = dlopen(SETTING_UTILS_SO_FILE_PATH, RTLD_LAZY);
691 SETTING_TRACE("ERROR!! canNOT find libsystem-settings-util.so.0.1.0");
695 get_font_info = dlsym(handle, "_get_default_font");
697 if ((error = dlerror()) != NULL) {
698 SETTING_TRACE("ERROR!! canNOT find _get_default_font function at libsystem-settings-util.so.0.1.0");
703 ret = get_font_info();
710 #ifdef TIZEN_WEARABLE
711 /* LCOV_EXCL_START */
712 static int system_setting_get_extended_wallpaper_num(const char *file_path, unsigned int *num)
716 const char *find_str = "extended_wallpaper_";
719 if (!(ch = strstr(file_path, find_str))) {
720 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
722 strncpy(buffer, file_path, ch - file_path);
723 buffer[ch - file_path] = 0;
724 sprintf(buffer + (ch - file_path), "%s%s", "", ch + strlen(find_str));
726 if (!isdigit(buffer[0])) {
727 SETTING_TRACE("%s is not number", buffer);
728 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
733 return SYSTEM_SETTINGS_ERROR_NONE;
737 /* LCOV_EXCL_START */
738 static int system_setting_copy_extended_wallpaper(const char *dest_file_path, const char *source_file_path)
741 if (!source_file_path || !dest_file_path) {
742 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
748 fd = open(source_file_path, O_RDONLY);
750 SETTING_TRACE("file open failed: %s", source_file_path);
751 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
755 fd2 = open(dest_file_path, O_WRONLY | O_CREAT, S_IRWXU | S_IRWXG | S_IRWXO);
757 SETTING_TRACE("file creation failed: %s", dest_file_path);
759 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
762 while (read(fd, buf, sizeof(buf) - 1) > 0) {
763 write(fd2, buf, sizeof(buf) - 1);
769 if (chmod(dest_file_path, S_IRWXU | S_IRWXG | S_IRWXO) < 0) {
770 SETTING_TRACE("chmod failed: %s", dest_file_path);
773 return SYSTEM_SETTINGS_ERROR_NONE;
777 /* LCOV_EXCL_START */
778 static int system_setting_remove_oldest_extended_wallpaper()
783 char *min_image_name = NULL;
784 unsigned int min_image_num = 0;
785 unsigned int temp_image_num = 0;
788 if ((dp = opendir(_TZ_SYS_DATA"/setting/wallpaper")) == NULL) {
789 SETTING_TRACE("opendir error");
790 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
793 while ((dirp = readdir(dp))) {
794 if (!strcmp(dirp->d_name, ".") || !strcmp(dirp->d_name, ".."))
797 if (system_setting_get_extended_wallpaper_num(dirp->d_name, &temp_image_num)
798 != SYSTEM_SETTINGS_ERROR_NONE) {
799 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
802 if ((image_count == 0) || (min_image_num > temp_image_num)) {
803 min_image_num = temp_image_num;
804 min_image_name = dirp->d_name;
811 if (min_image_name) {
812 snprintf(buf, sizeof(buf) - 1, _TZ_SYS_DATA"/setting/wallpaper/%s", min_image_name);
813 if (remove(buf) < 0) { /* remove oldest image */
814 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
818 return SYSTEM_SETTINGS_ERROR_NONE;
822 /* LCOV_EXCL_START */
823 static int system_setting_check_extended_wallpaper(const char *file_path)
827 if (!file_path || !strlen(file_path))
829 snprintf(buffer, 512, "%s/.bgwallpaper", tzplatform_getenv(TZ_USER_CONTENT));
830 return (strstr(file_path, buffer) != NULL);
834 #define WALLPAPER_MAX_COUNT 10
836 /* LCOV_EXCL_START */
837 int system_setting_set_wallpaper_home_screen(system_settings_key_e key, void *value)
841 vconf_value = (char *)value;
843 bool isok = dl_is_supported_image_type_load(vconf_value);
846 SETTING_TRACE("path : %s is not supported file format", vconf_value);
847 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
849 SETTING_TRACE("path : %s is SUPPORT file format", vconf_value);
852 /* error handling here */
853 if (_is_file_accessible(vconf_value) != 0)
854 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
856 if (system_setting_vconf_set_value_string(VCONFKEY_BGSET, vconf_value)) {
857 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
861 #ifdef TIZEN_WEARABLE
862 if (system_setting_check_extended_wallpaper(vconf_value)) { /* New extended wallpaper */
865 unsigned int max_image_num = 0;
866 unsigned int temp_image_num = 0;
869 if ((dp = opendir(_TZ_SYS_DATA"/setting/wallpaper")) == NULL) {
870 SETTING_TRACE("Setting - dir open error!");
871 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
874 /* Check a max number of wallpapers */
875 while ((dirp = readdir(dp))) {
876 if (!strcmp(dirp->d_name, ".") || !strcmp(dirp->d_name, ".."))
879 if (system_setting_get_extended_wallpaper_num(dirp->d_name, &temp_image_num)
880 != SYSTEM_SETTINGS_ERROR_NONE) {
883 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
886 if ((image_count == 0) || (max_image_num < temp_image_num)) {
887 max_image_num = temp_image_num;
895 /* Numbering rule: Gear is odd number */
896 max_image_num = (max_image_num % 2 == 0) ? max_image_num + 1
899 char file_name_buffer[512];
900 snprintf(file_name_buffer, sizeof(file_name_buffer) - 1,
901 _TZ_SYS_DATA"/setting/wallpaper/extended_wallpaper_%d.jpg", max_image_num);
903 /* Copy image to _TZ_SYS_DATA/setting/wallpaper/ */
904 if (system_setting_copy_extended_wallpaper(file_name_buffer, vconf_value)
905 != SYSTEM_SETTINGS_ERROR_NONE) {
906 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
909 /* remove oldest wallpaper */
910 if (image_count >= WALLPAPER_MAX_COUNT) {
911 if (system_setting_remove_oldest_extended_wallpaper()
912 != SYSTEM_SETTINGS_ERROR_NONE) {
913 remove(file_name_buffer);
914 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
918 if (system_setting_vconf_set_value_string(VCONFKEY_BGSET, file_name_buffer)) {
919 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
922 if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_WALLPAPER_CHANGED_NOTI_INT,
923 VCONFKEY_WALLPAPER_CHANGED_NOTI_GEAR)) {
924 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
927 if (system_setting_vconf_set_value_string(VCONFKEY_BGSET, vconf_value)) {
928 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
933 return SYSTEM_SETTINGS_ERROR_NONE;
937 /* LCOV_EXCL_START */
938 int system_setting_set_wallpaper_lock_screen(system_settings_key_e key, void *value)
942 vconf_value = (char *)value;
944 bool isok = dl_is_supported_image_type_load(vconf_value);
947 SETTING_TRACE("path : %s is not supported file format", vconf_value);
948 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
950 SETTING_TRACE("path : %s is SUPPORT file format", vconf_value);
953 /* error handling here */
954 if (_is_file_accessible(vconf_value) != 0)
955 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
957 if (system_setting_vconf_set_value_string(VCONFKEY_IDLE_LOCK_BGSET, vconf_value)) {
958 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
961 return SYSTEM_SETTINGS_ERROR_NONE;
965 /* LCOV_EXCL_START */
966 int system_setting_set_font_size(system_settings_key_e key, void *value)
970 vconf_value = *(int **)value;
972 if (*vconf_value < 0 || *vconf_value > SYSTEM_SETTINGS_FONT_SIZE_GIANT) {
973 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
976 if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, *vconf_value)) {
977 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
981 return SYSTEM_SETTINGS_ERROR_NONE;
987 /* LCOV_EXCL_START */
988 void *font_conf_doc_parse(char *doc_name, char *font_name)
991 xmlDocPtr doc = NULL;
992 xmlNodePtr cur = NULL;
993 xmlNodePtr cur2 = NULL;
994 xmlNodePtr cur3 = NULL;
997 doc = xmlParseFile(doc_name);
999 cur = xmlDocGetRootElement(doc);
1007 if (xmlStrcmp(cur->name, (const xmlChar *)"fontconfig")) {
1013 cur = cur->xmlChildrenNode;
1015 bool is_changed = false;
1016 while (cur != NULL) {
1017 if ((!xmlStrcmp(cur->name, (const xmlChar *)"match"))) {
1018 cur2 = cur->xmlChildrenNode;
1019 while (cur2 != NULL) {
1020 if ((!xmlStrcmp(cur2->name, (const xmlChar *)"edit"))) {
1021 xmlChar *name = xmlGetProp(cur2, (const xmlChar *)"name");
1022 /* if name is not 'family', break */
1023 if (xmlStrcmp(name, (const xmlChar *)"family")) {
1031 cur3 = cur2->xmlChildrenNode;
1032 while (cur3 != NULL) {
1033 if ((!xmlStrcmp(cur3->name, (const xmlChar *)"string"))) {
1034 xmlNodeSetContent(cur3->xmlChildrenNode, (const xmlChar *)font_name);
1035 key = xmlNodeListGetString(doc, cur3->xmlChildrenNode, 1);
1045 } else if ((!xmlStrcmp(cur->name, (const xmlChar *)"alias"))) {
1046 cur2 = cur->xmlChildrenNode;
1047 while (cur2 != NULL) {
1048 if ((!xmlStrcmp(cur2->name, (const xmlChar *)"family"))) {
1049 xmlNodeSetContent(cur2->xmlChildrenNode, (const xmlChar *)font_name);
1050 key = xmlNodeListGetString(doc, cur2->xmlChildrenNode, 1);
1054 } else if ((!xmlStrcmp(cur2->name, (const xmlChar *)"prefer"))) {
1055 cur3 = cur2->xmlChildrenNode;
1056 while (cur3 != NULL) {
1057 if ((!xmlStrcmp(cur3->name, (const xmlChar *)"family"))) {
1058 xmlNodeSetContent(cur3->xmlChildrenNode, (const xmlChar *)font_name);
1059 key = xmlNodeListGetString(doc, cur3->xmlChildrenNode, 1);
1083 /* LCOV_EXCL_STOP */
1085 /* LCOV_EXCL_START */
1086 int system_setting_set_font_type(system_settings_key_e key, void *value)
1088 SETTING_TRACE_BEGIN;
1089 char *font_name = NULL;
1090 font_name = (char *)value;
1092 /* get current font list */
1093 int is_found = dl_is_available_font(font_name);
1096 SETTING_TRACE("found font : %s ", font_name);
1098 SETTING_TRACE(" NOT found font : %s ", font_name);
1099 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1102 bool bsave = dl_font_config_set(font_name);
1105 SETTING_TRACE(" font type save error by font_config_set() ");
1106 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1108 SETTING_TRACE(" save OK - font_config_set() ");
1111 xmlDocPtr doc = (xmlDocPtr)font_conf_doc_parse(SETTING_FONT_CONF_FILE, font_name);
1113 xmlSaveFormatFile(SETTING_FONT_CONF_FILE, doc, 0);
1118 dl_font_config_set_notification();
1121 vconf_value = (char *)value;
1123 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, vconf_value)) {
1124 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1126 return SYSTEM_SETTINGS_ERROR_NONE;
1128 /* LCOV_EXCL_STOP */
1130 /* LCOV_EXCL_START */
1131 int system_setting_set_motion_activation(system_settings_key_e key, void *value)
1133 SETTING_TRACE_BEGIN;
1135 vconf_value = (bool *)value;
1136 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_MOTION_ACTIVATION, *vconf_value)) {
1137 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1139 return SYSTEM_SETTINGS_ERROR_NONE;
1141 /* LCOV_EXCL_STOP */
1143 /* LCOV_EXCL_START */
1144 int system_setting_set_usb_debugging_option(system_settings_key_e key, void *value)
1146 SETTING_TRACE_BEGIN;
1148 vconf_value = (bool *)value;
1149 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_USB_DEBUG_MODE_BOOL, *vconf_value)) {
1150 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1152 return SYSTEM_SETTINGS_ERROR_NONE;
1155 /* LCOV_EXCL_STOP */
1157 /* LCOV_EXCL_START */
1158 int system_setting_set_3g_data_network(system_settings_key_e key, void *value)
1160 SETTING_TRACE_BEGIN;
1162 vconf_value = (bool *)value;
1163 if (system_setting_vconf_set_value_bool(VCONFKEY_3G_ENABLE, *vconf_value)) {
1164 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1167 return SYSTEM_SETTINGS_ERROR_NONE;
1169 /* LCOV_EXCL_STOP */
1171 /* LCOV_EXCL_START */
1172 static int category_func(const char *name, void *user_data)
1174 SETTING_TRACE_BEGIN;
1175 static char *category = "lock-screen";
1176 if (name && !strcmp(name, category)) {
1177 SETTING_TRACE(" SAME ");
1180 SETTING_TRACE(" DIFFERENT -- %s, category -- %s ", name, category);
1186 /* LCOV_EXCL_STOP */
1190 * set 'swipe type' if current lockscreen app is 'com.samsung.lockscreen'
1194 /* LCOV_EXCL_START */
1195 int system_setting_set_lockscreen_app(system_settings_key_e key, void *value)
1197 SETTING_TRACE_BEGIN;
1199 vconf_value = (char *)value; /* ex) com.samsung.lockscreen */
1202 pkgmgrinfo_appinfo_h handle;
1203 r = pkgmgrinfo_appinfo_get_appinfo(vconf_value, &handle);
1204 if (r != PMINFO_R_OK) {
1205 SETTING_TRACE("*** pkginfo failed ");
1206 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
1208 SETTING_TRACE("%x", handle);
1211 int ret = pkgmgrinfo_appinfo_foreach_category(handle, category_func, (void *)"lock-screen");
1212 if (ret != PMINFO_R_OK) {
1213 pkgmgrinfo_appinfo_destroy_appinfo(handle);
1214 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
1217 pkgmgrinfo_appinfo_destroy_appinfo(handle);
1218 /*----------------------------------------------------------------------------------- */
1220 if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_SCREEN_LOCK_TYPE_INT, &locktype)) {
1221 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1224 if (locktype == SETTING_SCREEN_LOCK_TYPE_PASSWORD)
1225 return SYSTEM_SETTINGS_ERROR_LOCKSCREEN_APP_PASSWORD_MODE;
1227 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_3RD_LOCK_PKG_NAME_STR, vconf_value)) {
1228 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1231 if (vconf_value && strcmp(vconf_value, "com.samsung.lockscreen") == 0) {
1232 if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_SCREEN_LOCK_TYPE_INT, SETTING_SCREEN_LOCK_TYPE_SWIPE)) {
1233 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1236 return SYSTEM_SETTINGS_ERROR_NONE;
1238 /* LCOV_EXCL_STOP */
1240 /*/////////////////////////////////////////////////////////////////////////////////////////////// */
1243 int system_setting_set_changed_callback_incoming_call_ringtone(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1245 SETTING_TRACE_BEGIN;
1246 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR, SYSTEM_SETTINGS_KEY_INCOMING_CALL_RINGTONE, 0, user_data);
1249 int system_setting_unset_changed_callback_incoming_call_ringtone(system_settings_key_e key)
1251 SETTING_TRACE_BEGIN;
1252 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR, 0);
1255 int system_setting_set_changed_callback_email_alert_ringtone(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1257 SETTING_TRACE_BEGIN;
1258 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, SYSTEM_SETTINGS_KEY_EMAIL_ALERT_RINGTONE, 0, user_data);
1261 int system_setting_unset_changed_callback_email_alert_ringtone(system_settings_key_e key)
1263 SETTING_TRACE_BEGIN;
1264 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, 0);
1267 int system_setting_set_changed_callback_wallpaper_home_screen(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1269 SETTING_TRACE_BEGIN;
1270 return system_setting_vconf_set_changed_cb(VCONFKEY_BGSET, SYSTEM_SETTINGS_KEY_WALLPAPER_HOME_SCREEN, 0, user_data);
1273 int system_setting_unset_changed_callback_wallpaper_home_screen(system_settings_key_e key)
1275 SETTING_TRACE_BEGIN;
1276 return system_setting_vconf_unset_changed_cb(VCONFKEY_BGSET, 0);
1279 int system_setting_set_changed_callback_wallpaper_lock_screen(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1281 SETTING_TRACE_BEGIN;
1282 return system_setting_vconf_set_changed_cb(VCONFKEY_IDLE_LOCK_BGSET, SYSTEM_SETTINGS_KEY_WALLPAPER_LOCK_SCREEN, 0, user_data);
1285 int system_setting_unset_changed_callback_wallpaper_lock_screen(system_settings_key_e key)
1287 SETTING_TRACE_BEGIN;
1288 return system_setting_vconf_unset_changed_cb(VCONFKEY_IDLE_LOCK_BGSET, 0);
1291 int system_setting_set_changed_callback_font_size(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1293 SETTING_TRACE_BEGIN;
1294 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, SYSTEM_SETTINGS_KEY_FONT_SIZE, 1, user_data);
1297 int system_setting_unset_changed_callback_font_size(system_settings_key_e key)
1299 SETTING_TRACE_BEGIN;
1300 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, 1);
1303 int system_setting_set_changed_callback_usb_debugging_option(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1305 SETTING_TRACE_BEGIN;
1306 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_USB_DEBUG_MODE_BOOL, SYSTEM_SETTINGS_KEY_USB_DEBUGGING_ENABLED, 1, user_data);
1309 int system_setting_unset_changed_callback_usb_debugging_option(system_settings_key_e key)
1311 SETTING_TRACE_BEGIN;
1312 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_USB_DEBUG_MODE_BOOL, 1);
1315 int system_setting_set_changed_callback_3g_data_network(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1317 SETTING_TRACE_BEGIN;
1318 return system_setting_vconf_set_changed_cb(VCONFKEY_3G_ENABLE, SYSTEM_SETTINGS_KEY_3G_DATA_NETWORK_ENABLED, 1, user_data);
1321 int system_setting_unset_changed_callback_3g_data_network(system_settings_key_e key)
1323 SETTING_TRACE_BEGIN;
1324 return system_setting_vconf_unset_changed_cb(VCONFKEY_3G_ENABLE, 1);
1327 int system_setting_set_changed_callback_lockscreen_app(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1329 SETTING_TRACE_BEGIN;
1330 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_3RD_LOCK_PKG_NAME_STR, SYSTEM_SETTINGS_KEY_LOCKSCREEN_APP, 1, user_data);
1333 int system_setting_unset_changed_callback_lockscreen_app(system_settings_key_e key)
1335 SETTING_TRACE_BEGIN;
1336 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_3RD_LOCK_PKG_NAME_STR, 1);
1341 * @todo need to add custom event notification method
1343 int system_setting_set_changed_callback_font_type(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1345 SETTING_TRACE_BEGIN;
1346 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, SYSTEM_SETTINGS_KEY_FONT_TYPE, 2, user_data);
1349 int system_setting_unset_changed_callback_font_type(system_settings_key_e key)
1351 SETTING_TRACE_BEGIN;
1352 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, 2);
1355 /* TODO : 2th argument, callback, is not in use. */
1356 int system_setting_set_changed_callback_motion_activation(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1358 SETTING_TRACE_BEGIN;
1359 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_MOTION_ACTIVATION, SYSTEM_SETTINGS_KEY_MOTION_ACTIVATION, 3, user_data);
1362 int system_setting_unset_changed_callback_motion_activation(system_settings_key_e key)
1364 SETTING_TRACE_BEGIN;
1365 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_MOTION_ACTIVATION, 3);
1368 /*//////////////////////////////////////////////////////////////////////////////////////// */
1369 /*--------------------------------------- */
1370 int system_setting_get_locale_country(system_settings_key_e key, void **value)
1372 SETTING_TRACE_BEGIN;
1373 char *vconf_value = NULL;
1374 if (system_setting_vconf_get_value_string(VCONFKEY_REGIONFORMAT, &vconf_value)) {
1375 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1378 /* parsing validation */
1381 snprintf(arr, 20, "%s", vconf_value);
1383 *value = strdup(arr);
1387 return SYSTEM_SETTINGS_ERROR_NONE;
1390 /* LCOV_EXCL_START */
1391 int system_setting_set_locale_country(system_settings_key_e key, void *value)
1393 SETTING_TRACE_BEGIN;
1394 char *vconf_value = NULL;
1395 vconf_value = (char *)value;
1397 char *ext = "UTF-8";
1400 snprintf(arr, 20, "%s.%s", vconf_value, ext);
1402 if (system_setting_vconf_set_value_string(VCONFKEY_REGIONFORMAT, arr)) {
1403 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1405 return SYSTEM_SETTINGS_ERROR_NONE;
1407 /* LCOV_EXCL_STOP */
1409 int system_setting_set_changed_callback_locale_country(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1411 SETTING_TRACE_BEGIN;
1412 return system_setting_vconf_set_changed_cb(VCONFKEY_REGIONFORMAT, SYSTEM_SETTINGS_KEY_LOCALE_COUNTRY, 3, user_data);
1415 int system_setting_unset_changed_callback_locale_country(system_settings_key_e key)
1417 SETTING_TRACE_BEGIN;
1418 return system_setting_vconf_unset_changed_cb(VCONFKEY_REGIONFORMAT, 3);
1422 /*--------------------------------------- */
1423 int system_setting_get_locale_language(system_settings_key_e key, void **value)
1425 SETTING_TRACE_BEGIN;
1426 char *vconf_value = NULL;
1427 if (system_setting_vconf_get_value_string(VCONFKEY_LANGSET, &vconf_value)) {
1428 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1431 /* parsing validation */
1434 snprintf(arr, 20, "%s", vconf_value);
1436 *value = strdup(arr);
1439 return SYSTEM_SETTINGS_ERROR_NONE;
1442 /* LCOV_EXCL_START */
1443 int system_setting_set_locale_language(system_settings_key_e key, void *value)
1445 SETTING_TRACE_BEGIN;
1446 char *vconf_value = NULL;
1447 vconf_value = (char *)value;
1449 char *ext = "UTF-8";
1452 snprintf(arr, 20, "%s.%s", vconf_value, ext);
1454 if (system_setting_vconf_set_value_string(VCONFKEY_LANGSET, arr)) {
1455 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1457 return SYSTEM_SETTINGS_ERROR_NONE;
1459 /* LCOV_EXCL_STOP */
1461 int system_setting_set_changed_callback_locale_language(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1463 SETTING_TRACE_BEGIN;
1464 /*return system_setting_vconf_set_changed_cb(VCONFKEY_LANGSET, SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, 3, user_data ); */
1465 return system_setting_vconf_set_changed_cb(VCONFKEY_LANGSET, SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, 100, user_data);
1468 int system_setting_unset_changed_callback_locale_language(system_settings_key_e key)
1470 SETTING_TRACE_BEGIN;
1471 return system_setting_vconf_unset_changed_cb(VCONFKEY_LANGSET, 100);
1474 /*--------------------------------------- */
1475 /* LCOV_EXCL_START */
1476 int system_setting_get_locale_timeformat_24hour(system_settings_key_e key, void **value)
1478 SETTING_TRACE_BEGIN;
1481 if (system_setting_vconf_get_value_int(VCONFKEY_REGIONFORMAT_TIME1224, &vconf_value)) {
1482 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1485 bool ret_value = true;
1486 if (vconf_value == VCONFKEY_TIME_FORMAT_12)
1488 else if (vconf_value == VCONFKEY_TIME_FORMAT_24)
1491 *value = (void *)ret_value;
1493 return SYSTEM_SETTINGS_ERROR_NONE;
1495 /* LCOV_EXCL_STOP */
1497 int system_setting_set_locale_timeformat_24hour(system_settings_key_e key, void *value)
1499 SETTING_TRACE_BEGIN;
1502 vconf_value = (bool *)value;
1505 if (system_setting_vconf_set_value_int(VCONFKEY_REGIONFORMAT_TIME1224, VCONFKEY_TIME_FORMAT_24)) {
1506 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1510 if (system_setting_vconf_set_value_int(VCONFKEY_REGIONFORMAT_TIME1224, VCONFKEY_TIME_FORMAT_12)) {
1511 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1516 return SYSTEM_SETTINGS_ERROR_NONE;
1519 int system_setting_set_changed_callback_locale_timeformat_24hour(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1521 SETTING_TRACE_BEGIN;
1522 return system_setting_vconf_set_changed_cb(VCONFKEY_REGIONFORMAT_TIME1224, SYSTEM_SETTINGS_KEY_LOCALE_TIMEFORMAT_24HOUR, 3, user_data);
1525 int system_setting_unset_changed_callback_locale_timeformat_24hour(system_settings_key_e key)
1527 SETTING_TRACE_BEGIN;
1528 return system_setting_vconf_unset_changed_cb(VCONFKEY_REGIONFORMAT_TIME1224, 3);
1531 int system_setting_get_locale_timezone(system_settings_key_e key, void **value)
1534 ssize_t len = readlink(SETTING_TZONE_SYMLINK_PATH, tzpath, sizeof(tzpath)-1);
1538 SETTING_TRACE("parse error for SETTING_TZONE_SYMLINK_PATH");
1539 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1542 SETTING_TRACE("tzpath : %s ", &tzpath[20]);
1543 *value = strdup(&tzpath[20]);
1544 return SYSTEM_SETTINGS_ERROR_NONE;
1547 /* LCOV_EXCL_START */
1548 int system_setting_set_locale_timezone(system_settings_key_e key, void *value)
1550 SETTING_TRACE_BEGIN;
1551 char *timezone_value = NULL;
1552 timezone_value = (char *)value;
1555 snprintf(tz_path, 1024, "/usr/share/zoneinfo/%s", timezone_value);
1557 int is_load = _is_file_accessible(tz_path);
1559 alarmmgr_set_timezone(tz_path);
1561 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_TIMEZONE_ID, timezone_value)) {
1562 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1564 return SYSTEM_SETTINGS_ERROR_NONE;
1566 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
1568 /* LCOV_EXCL_STOP */
1572 /* LCOV_EXCL_START */
1573 int system_setting_set_changed_callback_locale_timezone(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1575 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_TIMEZONE_ID, SYSTEM_SETTINGS_KEY_LOCALE_TIMEZONE, 4, user_data);
1577 /* LCOV_EXCL_STOP */
1579 /* LCOV_EXCL_START */
1580 int system_setting_unset_changed_callback_locale_timezone(system_settings_key_e key)
1582 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_TIMEZONE_ID, 4);
1584 /* LCOV_EXCL_STOP */
1586 /* LCOV_EXCL_START */
1587 int system_setting_set_changed_callback_locale_timezone_changed(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1589 SETTING_TRACE_BEGIN;
1590 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
1592 /* LCOV_EXCL_STOP */
1594 /* LCOV_EXCL_START */
1595 int system_setting_unset_changed_callback_locale_timezone_changed(system_settings_key_e key)
1597 SETTING_TRACE_BEGIN;
1598 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
1600 /* LCOV_EXCL_STOP */
1603 /* LCOV_EXCL_START */
1604 int system_setting_get_time_changed(system_settings_key_e key, void **value)
1606 SETTING_TRACE_BEGIN;
1608 int ** val = (int**)value;
1609 cur_tick = time(NULL);
1611 /* struct tm * localtime = time (cur_tick); */
1612 /* printf("%s\n", ctime(&cur_tick); */
1613 return SYSTEM_SETTINGS_ERROR_NONE;
1616 /* LCOV_EXCL_STOP */
1618 int system_setting_set_changed_callback_time_changed(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1620 SETTING_TRACE_BEGIN;
1621 return system_setting_vconf_set_changed_cb(VCONFKEY_SYSTEM_TIME_CHANGED, SYSTEM_SETTINGS_KEY_TIME_CHANGED, 3, user_data);
1624 int system_setting_unset_changed_callback_time_changed(system_settings_key_e key)
1626 SETTING_TRACE_BEGIN;
1627 return system_setting_vconf_unset_changed_cb(VCONFKEY_SYSTEM_TIME_CHANGED, 3);
1632 /* SYSTEM_SETTINGS_KEY_SOUND_LOCK */
1633 int system_setting_get_sound_lock(system_settings_key_e key, void **value)
1635 SETTING_TRACE_BEGIN;
1638 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_SOUND_LOCK_BOOL, &vconf_value)) {
1639 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1641 *value = (void *)vconf_value;
1643 return SYSTEM_SETTINGS_ERROR_NONE;
1646 int system_setting_set_changed_callback_sound_lock(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1648 SETTING_TRACE_BEGIN;
1649 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_SOUND_LOCK_BOOL, SYSTEM_SETTINGS_KEY_SOUND_LOCK, 3, user_data);
1652 int system_setting_unset_changed_callback_sound_lock(system_settings_key_e key)
1654 SETTING_TRACE_BEGIN;
1655 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_SOUND_LOCK_BOOL, 3);
1659 * a = VCONFKEY_SETAPPL_SOUND_STATUS_BOOL b = VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL
1661 * a == false, b == false --> silent mode
1662 * a == true, b == false --> sound mode
1663 * a == false, b == true --> vibration mode
1665 /* LCOV_EXCL_START */
1666 int system_setting_get_sound_silent_mode(system_settings_key_e key, void **value)
1668 SETTING_TRACE_BEGIN;
1673 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, &sound_cond)) {
1674 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1677 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, &vib_cond)) {
1678 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1681 if (sound_cond == false && vib_cond == false) {
1683 *value = (void *)vconf_value;
1685 vconf_value = false;
1686 *value = (void *)vconf_value;
1688 return SYSTEM_SETTINGS_ERROR_NONE;
1690 /* LCOV_EXCL_STOP */
1693 * a = VCONFKEY_SETAPPL_SOUND_STATUS_BOOL b = VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL
1695 * a == false, b == false --> silent mode
1696 * a == true, b == false --> sound mode
1698 int system_setting_set_sound_silent_mode(system_settings_key_e key, void *value)
1700 SETTING_TRACE_BEGIN;
1703 vconf_value = (bool *)value;
1705 bool vconf_sound = false;
1706 bool vconf_vib = false;
1709 vconf_sound = false;
1716 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, vconf_sound)) {
1717 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1719 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, vconf_vib)) {
1720 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1723 return SYSTEM_SETTINGS_ERROR_NONE;
1729 int system_setting_set_changed_callback_sound_silent_mode(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1731 SETTING_TRACE_BEGIN;
1732 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, SYSTEM_SETTINGS_KEY_SOUND_SILENT_MODE, 3, user_data);
1736 int system_setting_unset_changed_callback_sound_silent_mode(system_settings_key_e key)
1738 SETTING_TRACE_BEGIN;
1739 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, 3);
1742 /* SYSTEM_SETTINGS_KEY_SOUND_TOUCH */
1743 int system_setting_get_sound_touch(system_settings_key_e key, void **value)
1745 SETTING_TRACE_BEGIN;
1748 int ret = system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL, &vconf_value);
1749 if (ret != SYSTEM_SETTINGS_ERROR_NONE) {
1752 *value = (void *)vconf_value;
1756 int system_setting_set_changed_callback_sound_touch(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1758 SETTING_TRACE_BEGIN;
1759 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL, SYSTEM_SETTINGS_KEY_SOUND_TOUCH, 2, user_data);
1762 int system_setting_unset_changed_callback_sound_touch(system_settings_key_e key)
1764 SETTING_TRACE_BEGIN;
1765 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL, 2);
1769 /* SYSTEM_SETTINGS_KEY_SOUND_LOCK */
1770 int system_setting_get_sound_lock(system_settings_key_e key, void **value)
1774 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_SOUND_LOCK_BOOL, &vconf_value)) {
1775 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1777 *value = (void *)vconf_value;
1779 return SYSTEM_SETTINGS_ERROR_NONE;
1783 int system_setting_get_auto_rotation_mode(system_settings_key_e key, void **value)
1785 SETTING_TRACE_BEGIN;
1788 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, &vconf_value)) {
1789 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1791 *value = (void *)vconf_value;
1793 return SYSTEM_SETTINGS_ERROR_NONE;
1796 /* LCOV_EXCL_START */
1797 int system_setting_set_auto_rotation_mode(system_settings_key_e key, void *value)
1799 SETTING_TRACE_BEGIN;
1801 vconf_value = (bool *)value;
1802 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, *vconf_value)) {
1803 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1806 return SYSTEM_SETTINGS_ERROR_NONE;
1808 /* LCOV_EXCL_STOP */
1810 int system_setting_set_changed_callback_auto_rotation_mode(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1812 SETTING_TRACE_BEGIN;
1813 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, SYSTEM_SETTINGS_KEY_DISPLAY_SCREEN_ROTATION_AUTO, 2, user_data);
1816 int system_setting_unset_changed_callback_auto_rotation_mode(system_settings_key_e key)
1818 SETTING_TRACE_BEGIN;
1819 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, 2);
1822 int system_setting_get_screen_backlight_time(system_settings_key_e key, void **value)
1824 SETTING_TRACE_BEGIN;
1826 int ** val = (int**)value;
1828 if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, &vconf_value)) {
1829 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1831 **val = vconf_value;
1833 return SYSTEM_SETTINGS_ERROR_NONE;
1837 /* LCOV_EXCL_START */
1838 int system_setting_set_screen_backlight_time(system_settings_key_e key, void *value)
1840 SETTING_TRACE_BEGIN;
1842 vconf_value = *(int **)value;
1844 if (!(*vconf_value > 0 && *vconf_value <= 600)) {
1845 SETTING_TRACE(" ERR Betweeny here 0 ~ 600");
1846 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
1849 if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, *vconf_value)) {
1850 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1853 return SYSTEM_SETTINGS_ERROR_NONE;
1855 /* LCOV_EXCL_STOP */
1857 int system_setting_set_changed_callback_screen_backlight_time(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1859 SETTING_TRACE_BEGIN;
1860 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, SYSTEM_SETTINGS_KEY_SCREEN_BACKLIGHT_TIME, 2, user_data);
1863 int system_setting_unset_changed_callback_screen_backlight_time(system_settings_key_e key)
1865 SETTING_TRACE_BEGIN;
1866 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, 2);
1869 int system_setting_get_sound_notification(system_settings_key_e key, void **value)
1871 SETTING_TRACE_BEGIN;
1872 char *vconf_value = NULL;
1873 if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, &vconf_value)) {
1874 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1877 *value = vconf_value;
1878 return SYSTEM_SETTINGS_ERROR_NONE;
1881 /* LCOV_EXCL_START */
1882 int system_setting_set_sound_notification(system_settings_key_e key, void *value)
1884 SETTING_TRACE_BEGIN;
1885 char *vconf_value = NULL;
1886 vconf_value = (char *)value;
1888 int is_load = _is_file_accessible(vconf_value);
1890 //SETTING_TRACE(" system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, %s) TRY", vconf_value);
1891 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, vconf_value)) {
1892 //SETTING_TRACE(" system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, %s) FAIL", vconf_value);
1893 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1896 //SETTING_TRACE(" is_file_accessibile FAILED - system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, %s) FAIL", vconf_value);
1897 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1900 return SYSTEM_SETTINGS_ERROR_NONE;
1902 /* LCOV_EXCL_STOP */
1904 int system_setting_set_changed_callback_sound_notification(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1906 SETTING_TRACE_BEGIN;
1907 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, SYSTEM_SETTINGS_KEY_SOUND_NOTIFICATION, 0, user_data);
1910 int system_setting_unset_changed_callback_sound_notification(system_settings_key_e key)
1912 SETTING_TRACE_BEGIN;
1913 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, 0);
1916 int system_setting_get_notification_repetition_period(system_settings_key_e key, void **value)
1918 SETTING_TRACE_BEGIN;
1919 int ** val = (int**)value;
1922 if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_NOTI_MSG_ALERT_REP_TYPE_INT, &vconf_value)) {
1923 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1925 **val = vconf_value;
1927 return SYSTEM_SETTINGS_ERROR_NONE;
1930 /* LCOV_EXCL_START */
1931 int system_setting_set_notification_repetition_period(system_settings_key_e key, void *value)
1933 SETTING_TRACE_BEGIN;
1935 vconf_value = *(int **)value;
1937 if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_NOTI_MSG_ALERT_REP_TYPE_INT, *vconf_value)) {
1938 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1941 return SYSTEM_SETTINGS_ERROR_NONE;
1943 /* LCOV_EXCL_STOP */
1945 int system_setting_set_changed_callback_notification_repetition_period(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1947 SETTING_TRACE_BEGIN;
1948 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);
1951 int system_setting_unset_changed_callback_notification_repetition_period(system_settings_key_e key)
1953 SETTING_TRACE_BEGIN;
1954 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_ALERT_REP_TYPE_INT, 1);
1957 int system_setting_get_device_name(system_settings_key_e key, void **value)
1959 SETTING_TRACE_BEGIN;
1960 char *vconf_value = NULL;
1961 if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_DEVICE_NAME_STR, &vconf_value)) {
1962 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1965 *value = vconf_value;
1966 return SYSTEM_SETTINGS_ERROR_NONE;
1969 /* LCOV_EXCL_START */
1970 int system_setting_set_device_name(system_settings_key_e key, void *value)
1972 SETTING_TRACE_BEGIN;
1973 char *vconf_value = NULL;
1974 vconf_value = (char *)value;
1976 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_DEVICE_NAME_STR, vconf_value)) {
1977 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1980 return SYSTEM_SETTINGS_ERROR_NONE;
1982 /* LCOV_EXCL_STOP */
1984 int system_setting_set_changed_callback_device_name(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1986 SETTING_TRACE_BEGIN;
1987 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_DEVICE_NAME_STR, SYSTEM_SETTINGS_KEY_DEVICE_NAME, 0, user_data);
1990 int system_setting_unset_changed_callback_device_name(system_settings_key_e key)
1992 SETTING_TRACE_BEGIN;
1993 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_DEVICE_NAME_STR, 0);
1996 /*---------------------------------------------- */
1997 int system_setting_get_network_flight_mode(system_settings_key_e key, void **value)
1999 SETTING_TRACE_BEGIN;
2001 if (system_setting_vconf_get_value_bool(VCONFKEY_TELEPHONY_FLIGHT_MODE, &vconf_value)) {
2002 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2004 *value = (void *)vconf_value;
2006 return SYSTEM_SETTINGS_ERROR_NONE;
2009 int system_setting_set_changed_callback_network_flight_mode(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
2011 SETTING_TRACE_BEGIN;
2012 return system_setting_vconf_set_changed_cb(VCONFKEY_TELEPHONY_FLIGHT_MODE, SYSTEM_SETTINGS_KEY_NETWORK_FLIGHT_MODE, 3, user_data);
2015 int system_setting_unset_changed_callback_network_flight_mode(system_settings_key_e key)
2017 SETTING_TRACE_BEGIN;
2018 return system_setting_vconf_unset_changed_cb(VCONFKEY_TELEPHONY_FLIGHT_MODE, 3);
2021 int system_setting_get_network_wifi_notification(system_settings_key_e key, void **value)
2023 SETTING_TRACE_BEGIN;
2025 if (system_setting_vconf_get_value_int(VCONFKEY_WIFI_ENABLE_QS, &vconf_value)) {
2026 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2029 bret = (vconf_value == VCONFKEY_WIFI_QS_ENABLE) ? true : false;
2031 *value = (void *)bret;
2032 return SYSTEM_SETTINGS_ERROR_NONE;
2035 int system_setting_set_changed_callback_network_wifi_notification(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
2037 SETTING_TRACE_BEGIN;
2038 return system_setting_vconf_set_changed_cb(VCONFKEY_WIFI_ENABLE_QS, SYSTEM_SETTINGS_KEY_NETWORK_WIFI_NOTIFICATION, 4, user_data);
2041 int system_setting_unset_changed_callback_network_wifi_notification(system_settings_key_e key)
2043 SETTING_TRACE_BEGIN;
2044 return system_setting_vconf_unset_changed_cb(VCONFKEY_WIFI_ENABLE_QS, 4);
2047 /* LCOV_EXCL_START */
2048 int system_setting_get_lock_state(system_settings_key_e key, void **value)
2051 int ** val = (int**)value;
2053 if (system_setting_vconf_get_value_int(VCONFKEY_IDLE_LOCK_STATE_READ_ONLY, &vconf_value)) {
2054 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2056 **val = vconf_value;
2058 return SYSTEM_SETTINGS_ERROR_NONE;
2060 /* LCOV_EXCL_STOP */
2062 /* LCOV_EXCL_START */
2063 int system_setting_set_lock_state(system_settings_key_e key, void *value)
2065 SETTING_TRACE_BEGIN;
2067 vconf_value = *(int **)value;
2069 if (system_setting_vconf_set_value_int(VCONFKEY_IDLE_LOCK_STATE_READ_ONLY, *vconf_value)) {
2070 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2073 return SYSTEM_SETTINGS_ERROR_NONE;
2075 /* LCOV_EXCL_STOP */
2077 /* LCOV_EXCL_START */
2078 int system_setting_set_changed_callback_lock_state(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
2080 return system_setting_vconf_set_changed_cb(VCONFKEY_IDLE_LOCK_STATE_READ_ONLY, SYSTEM_SETTINGS_KEY_LOCK_STATE, 4, user_data);
2082 /* LCOV_EXCL_STOP */
2084 /* LCOV_EXCL_START */
2085 int system_setting_unset_changed_callback_lock_state(system_settings_key_e key)
2087 return system_setting_vconf_unset_changed_cb(VCONFKEY_IDLE_LOCK_STATE_READ_ONLY, 4);
2089 /* LCOV_EXCL_STOP */
2091 //----------------------------------------------------------------------------------------------------------------------------
2093 #define DEFAULT_ADS_ID "00000000-0000-0000-0000-000000000000"
2095 int system_setting_get_ads_id(system_settings_key_e key, void **value)
2097 SETTING_TRACE_BEGIN;
2098 int optout_value = 0;
2099 if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_AD_ID_OPT_OUT, &optout_value)) {
2100 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2103 if (optout_value == 1) {
2104 *value = strdup(DEFAULT_ADS_ID);
2105 return SYSTEM_SETTINGS_ERROR_NONE;
2108 char *vconf_value = NULL;
2109 if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_AD_ID, &vconf_value)) {
2110 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2113 *value = vconf_value;
2114 return SYSTEM_SETTINGS_ERROR_NONE;
2119 void make_ad_id(void)
2122 char uuid_unparsed[50] = {0};
2123 uuid_generate(uuid_value);
2124 uuid_unparse(uuid_value, uuid_unparsed);
2125 system_setting_set_ad_id(key, uuid_unparsed); //example of setting the value
2128 /* LCOV_EXCL_START */
2129 int system_setting_set_ads_id(system_settings_key_e key, void *value)
2131 SETTING_TRACE_BEGIN;
2132 char *vconf_value = NULL;
2133 vconf_value = (char *)value;
2135 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_AD_ID, vconf_value)) {
2136 SETTING_TRACE("Setting VCONFKEY_SETAPPL_AD_ID failed");
2137 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2140 return SYSTEM_SETTINGS_ERROR_NONE;
2142 /* LCOV_EXCL_STOP */
2144 int system_setting_set_changed_callback_ads_id(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
2146 SETTING_TRACE_BEGIN;
2147 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_AD_ID, SYSTEM_SETTINGS_KEY_ADS_ID, 0, user_data);
2150 int system_setting_unset_changed_callback_ads_id(system_settings_key_e key)
2152 SETTING_TRACE_BEGIN;
2153 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_AD_ID, 0);
2156 int system_settings_feature_check_bool(char *path)
2158 bool profile_data = false;
2159 int ret = system_info_get_platform_bool(path, &profile_data);
2160 if (ret != SYSTEM_INFO_ERROR_NONE) {
2161 SETTING_TRACE("Setting - reading profile string failed, %d", ret);
2162 return SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED;
2165 ret = (profile_data == true) ? SYSTEM_SETTINGS_ERROR_NONE : SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED;
2171 int system_setting_feature_check_incoming_call(void * value)
2173 static bool first_query = true;
2174 static int ret = SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED;
2176 if (first_query == true) {
2177 ret = system_settings_feature_check_bool(SETTING_INCOMING_CALL_PATH);
2178 first_query = false;
2184 int system_setting_feature_check_home_screen(void * value)
2186 static bool first_query = true;
2187 static int ret = SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED;
2189 if (first_query == true) {
2190 ret = system_settings_feature_check_bool(SETTING_HOME_SCREEN_PATH);
2191 first_query = false;
2197 int system_setting_feature_check_lock_screen(void * value)
2199 static bool first_query = true;
2200 static int ret = SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED;
2202 if (first_query == true) {
2203 ret = system_settings_feature_check_bool(SETTING_LOCK_SCREEN_PATH);
2204 first_query = false;
2210 int system_setting_feature_check_notification_email(void * value)
2212 static bool first_query = true;
2213 static int ret = SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED;
2215 if (first_query == true) {
2216 ret = system_settings_feature_check_bool(SETTING_NOTIFICATION_EMAIL_PATH);
2217 first_query = false;
2223 int system_setting_feature_check_wifi(void * value)
2225 static bool first_query = true;
2226 static int ret = SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED;
2228 if (first_query == true) {
2229 ret = system_settings_feature_check_bool(SETTING_WIFI_PATH);
2230 first_query = false;
2236 int system_setting_feature_check_telephony(void * value)
2238 static bool first_query = true;
2239 static int ret = SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED;
2241 if (first_query == true) {
2242 ret = system_settings_feature_check_bool(SETTING_TELEPHONY_PATH);
2243 first_query = false;
2249 /* LCOV_EXCL_START */
2250 int system_setting_get_uds_state(system_settings_key_e key, void **value)
2252 int ** p_value = (int**)value;
2254 char *vconf_string_value = NULL;
2256 if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_UDSM, &vconf_value)) {
2257 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2260 SETTING_TRACE("[%s] udsm: %d", __FUNCTION__, vconf_value);
2262 if (vconf_value == SYSTEM_SETTINGS_UDS_ON) {
2263 if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_UDSM_PKGID_LIST, &vconf_string_value))
2264 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2266 if (vconf_string_value) {
2267 if (!strcmp(vconf_string_value, "NONE")) {
2268 vconf_value = SYSTEM_SETTINGS_UDS_ON;
2270 char *app_id = NULL;
2271 char *package_id = NULL;
2272 pid_t pid = getpid();
2273 app_manager_get_app_id(pid, &app_id);
2276 package_manager_get_package_id_by_app_id(app_id, &package_id);
2277 SETTING_TRACE("[%s] udsm_pkg_list : %s", __FUNCTION__, vconf_string_value);
2280 if (package_id && strstr(vconf_string_value, package_id)) {
2281 vconf_value = SYSTEM_SETTINGS_UDS_ON_WHITELISTED;
2282 SETTING_TRACE("[%s] pkg id : %s", __FUNCTION__, package_id);
2284 vconf_value = SYSTEM_SETTINGS_UDS_ON;
2288 if (vconf_string_value)
2289 free(vconf_string_value);
2293 **p_value = vconf_value;
2296 return SYSTEM_SETTINGS_ERROR_NONE;
2298 /* LCOV_EXCL_STOP */
2300 /* LCOV_EXCL_START */
2301 int system_setting_set_changed_callback_uds_state(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
2303 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_UDSM, SYSTEM_SETTINGS_KEY_ULTRA_DATA_SAVE, 4, user_data);
2305 /* LCOV_EXCL_STOP */
2307 /* LCOV_EXCL_START */
2308 int system_setting_unset_changed_callback_uds_state(system_settings_key_e key)
2310 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_UDSM, 4);
2312 /* LCOV_EXCL_STOP */
2314 /* LCOV_EXCL_START */
2315 int system_setting_set_changed_callback_uds_pkg_list(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
2317 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_UDSM_PKGID_LIST, SYSTEM_SETTINGS_KEY_ULTRA_DATA_SAVE_PKG_LIST, 4, user_data);
2319 /* LCOV_EXCL_STOP */
2321 /* LCOV_EXCL_START */
2322 int system_setting_unset_changed_callback_uds_pkg_list(system_settings_key_e key)
2324 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_UDSM_PKGID_LIST, 4);
2326 /* LCOV_EXCL_STOP */
2328 /* SYSTEM_SETTINGS_KEY_ACCESSIBILITY_TTS */
2329 int system_setting_get_accessibility_tts(system_settings_key_e key, void **value)
2331 SETTING_TRACE_BEGIN;
2334 int ret = system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_ACCESSIBILITY_TTS, &vconf_value);
2335 if (ret != SYSTEM_SETTINGS_ERROR_NONE) {
2338 *value = (void *)vconf_value;
2342 int system_setting_set_changed_callback_accessibility_tts(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
2344 SETTING_TRACE_BEGIN;
2345 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_TTS, SYSTEM_SETTINGS_KEY_ACCESSIBILITY_TTS, 2, user_data);
2348 int system_setting_unset_changed_callback_accessibility_tts(system_settings_key_e key)
2350 SETTING_TRACE_BEGIN;
2351 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_TTS, 2);
2354 /* SYSTEM_SETTINGS_KEY_VIBRATION */
2355 int system_setting_get_vibration(system_settings_key_e key, void **value)
2357 SETTING_TRACE_BEGIN;
2360 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, &vconf_value)) {
2361 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2363 *value = (void *)vconf_value;
2365 return SYSTEM_SETTINGS_ERROR_NONE;
2368 /* LCOV_EXCL_START */
2369 int system_setting_set_vibration(system_settings_key_e key, void *value)
2371 SETTING_TRACE_BEGIN;
2373 vconf_value = (bool *)value;
2374 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, *vconf_value)) {
2375 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2378 return SYSTEM_SETTINGS_ERROR_NONE;
2380 /* LCOV_EXCL_STOP */
2382 int system_setting_set_changed_callback_vibration(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
2384 SETTING_TRACE_BEGIN;
2385 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, SYSTEM_SETTINGS_KEY_VIBRATION, 2, user_data);
2388 int system_setting_unset_changed_callback_vibration(system_settings_key_e key)
2390 SETTING_TRACE_BEGIN;
2391 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, 2);
2395 static void simple_test_case(void)
2397 /* a suitable test */
2398 g_assert(g_bit_storage(1) == 1);
2400 /* a test with verbose error message */
2401 g_assert_cmpint(g_bit_storage(1), ==, 1);
2404 static void simple_test_case02(void)
2406 /* a suitable test */
2407 g_assert(g_bit_storage(1) == 1);
2409 /* a test with verbose error message */
2410 g_assert_cmpint(g_bit_storage(1), ==, 1);
2412 void unittest_platform()
2414 /* hook up your test functions */
2415 g_test_add_func("/Simple Test Case", simple_test_case);
2416 g_test_add_func("/Simple Test Case02", simple_test_case02);
2417 /* run tests from the suite */