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>
35 #include <libxml/xmlmemory.h>
36 #include <libxml/parser.h>
38 #include <fontconfig/fontconfig.h>
42 #include <pkgmgr-info.h>
44 #include <system_settings.h>
45 #include <system_settings_private.h>
47 #include <tzplatform_config.h>
50 #include <efl_assist.h>
53 #define SETTING_FONT_CONF_FILE _TZ_SYS_ETC"/fonts/conf.avail/99-tizen.conf"
54 #define SETTING_DEFAULT_FONT_CONF_FILE _TZ_SYS_ETC"/fonts/conf.avail/99-tizen.conf"
56 #define SETTING_TIME_ZONEINFO_PATH "/usr/share/zoneinfo/"
57 #define SETTING_TIME_SHARE_LOCAL_PATH "/usr/share/locale"
58 #define SETTING_TZONE_SYMLINK_PATH "/opt/etc/localtime"
60 #ifdef SETTING_ARCH_64
61 #define SETTING_UTILS_SO_FILE_PATH "/usr/lib64/libsystem-settings-util.so.0.1.0"
63 #define SETTING_UTILS_SO_FILE_PATH "/usr/lib/libsystem-settings-util.so.0.1.0"
66 int _is_file_accessible(const char *path);
68 static bool dl_is_supported_image_type_load(char *path);
69 static bool dl_font_config_set(char *font_name);
70 static char *dl_get_font_info(char *str);
71 static int dl_is_available_font(char *str);
72 static void dl_font_size_set();
73 static void dl_font_config_set_notification();
77 * VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR has a path of the ringtone file which user choose
78 * @return the ringtone file path specified by user in normal case
79 * if it's not accessable, return the default ringtone path
81 int system_setting_get_incoming_call_ringtone(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
85 if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR, &vconf_value)) {
86 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
89 /* check to see if it's accessable -> OK */
90 /* no --> default ringtone path VCONFKEY_SETAPPL_CALL_RINGTONE_DEFAULT_PATH_STR */
91 int is_load = _is_file_accessible(vconf_value);
94 } else { /* not zero on errro */
95 *value = vconf_get_str(VCONFKEY_SETAPPL_CALL_RINGTONE_DEFAULT_PATH_STR);
98 /**value = vconf_value; */
99 return SYSTEM_SETTINGS_ERROR_NONE;
103 int system_setting_get_email_alert_ringtone(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
107 if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_NOTI_MSG_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_NOTI_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_NOTI_RINGTONE_DEFAULT_PATH_STR);
120 return SYSTEM_SETTINGS_ERROR_NONE;
124 int system_setting_get_wallpaper_home_screen(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
128 if (system_setting_vconf_get_value_string(VCONFKEY_BGSET, &vconf_value)) {
129 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
131 *value = vconf_value;
132 return SYSTEM_SETTINGS_ERROR_NONE;
136 int system_setting_get_wallpaper_lock_screen(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
141 if (system_setting_vconf_get_value_string(VCONFKEY_IDLE_LOCK_BGSET, &vconf_value)) {
142 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
144 *value = vconf_value;
146 return SYSTEM_SETTINGS_ERROR_NONE;
150 /* [int] vconf GET */
151 int system_setting_get_font_size(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
155 int ** val = (int**)value;
157 if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, &vconf_value)) {
158 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
162 return SYSTEM_SETTINGS_ERROR_NONE;
166 int system_setting_get_default_font_type(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
169 char *font_name = dl_get_font_info("default");
171 *value = (void *)font_name;
172 return SYSTEM_SETTINGS_ERROR_NONE;
174 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
178 /* [int] vconf GET */
179 int system_setting_get_font_type(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
182 char *font_name = dl_get_font_info("cur");
183 *value = (void *)font_name;
185 return SYSTEM_SETTINGS_ERROR_NONE;
189 int system_setting_get_motion_activation(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
194 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_MOTION_ACTIVATION, &vconf_value)) {
195 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
197 *value = (void *)vconf_value;
199 return SYSTEM_SETTINGS_ERROR_NONE;
202 int system_setting_get_usb_debugging_option(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
207 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_USB_DEBUG_MODE_BOOL, &vconf_value)) {
208 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
210 *value = (void *)vconf_value;
212 return SYSTEM_SETTINGS_ERROR_NONE;
215 int system_setting_get_3g_data_network(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
220 if (system_setting_vconf_get_value_bool(VCONFKEY_3G_ENABLE, &vconf_value)) {
221 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
223 *value = (void *)vconf_value;
225 return SYSTEM_SETTINGS_ERROR_NONE;
227 /*////////////////////////////////////////////////////////////////////////////////////////////////// */
231 * get current lock scren app package name (string)
233 * @return SYSTEM_SETTINGS_ERROR_LOCKSCREEN_APP_PASSWORD_MODE raise exception if current lock type is 'password'
235 /* LCOV_EXCL_START */
236 int system_setting_get_lockscreen_app(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
239 char *pkg_name = NULL;
241 system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_SCREEN_LOCK_TYPE_INT, &locktype);
243 if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_3RD_LOCK_PKG_NAME_STR, &pkg_name)) {
244 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
247 if (pkg_name && strcmp(pkg_name, "com.samsung.lockscreen") == 0 && locktype == SETTING_SCREEN_LOCK_TYPE_PASSWORD) {
248 return SYSTEM_SETTINGS_ERROR_LOCKSCREEN_APP_PASSWORD_MODE;
252 return SYSTEM_SETTINGS_ERROR_NONE;
257 /*////////////////////////////////////////////////////////////////////////////////////////////////// */
259 int _is_file_accessible(const char *path)
262 int ret = access(path , R_OK);
264 SETTING_TRACE("found the file %s", path);
267 /* error code : 13 */
268 SETTING_TRACE("found the file %s --- error code : %d ", path, errno);
273 /* LCOV_EXCL_START */
274 int system_setting_set_incoming_call_ringtone(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
278 vconf_value = (char *)value;
280 int ret = _is_file_accessible(vconf_value);
282 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR, vconf_value)) {
283 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
286 /* @todo add a common ret_handler */
290 return SYSTEM_SETTINGS_ERROR_NONE;
295 /* LCOV_EXCL_START */
296 int system_setting_set_email_alert_ringtone(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
300 vconf_value = (char *)value;
302 int ret = _is_file_accessible(vconf_value);
304 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, vconf_value)) {
305 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
308 /*return SYSTEM_SETTINGS_ERROR_IO_ERROR;*/
309 /* @todo add a common ret_handler */
313 return SYSTEM_SETTINGS_ERROR_NONE;
317 /* LCOV_EXCL_START */
318 static bool dl_is_supported_image_type_load(char *path)
323 bool (*image_type_check)(char *path);
325 handle = dlopen(SETTING_UTILS_SO_FILE_PATH, RTLD_LAZY);
327 SETTING_TRACE("ERROR!! canNOT find libsystem-settings-util.so.0.1.0");
331 image_type_check = dlsym(handle, "__is_supported_image_type_load");
332 if ((error = dlerror()) != NULL) {
333 SETTING_TRACE("ERROR!! canNOT find __is_supported_image_type_load function at libsystem-settings-util.so.0.1.0");
338 ret = image_type_check(path);
345 /* LCOV_EXCL_START */
346 static int dl_is_available_font(char *str)
351 int (*check_available_font)(char *font_name);
353 handle = dlopen(SETTING_UTILS_SO_FILE_PATH, RTLD_LAZY);
355 SETTING_TRACE("ERROR!! canNOT find libsystem-settings-util.so.0.1.0");
359 check_available_font = dlsym(handle, "__is_available_font");
360 if ((error = dlerror()) != NULL) {
361 SETTING_TRACE("ERROR!! canNOT find __is_available_font function at libsystem-settings-util.so.0.1.0");
366 ret = check_available_font(str);
373 /* LCOV_EXCL_START */
374 static void dl_font_size_set()
378 void (*set_font_size)();
380 handle = dlopen(SETTING_UTILS_SO_FILE_PATH, RTLD_LAZY);
382 SETTING_TRACE("ERROR!! canNOT find libsystem-settings-util.so.0.1.0");
386 set_font_size = dlsym(handle, "__font_size_set");
387 if ((error = dlerror()) != NULL) {
388 SETTING_TRACE("ERROR!! canNOT find __font_size_set function at libsystem-settings-util.so.0.1.0");
400 /* LCOV_EXCL_START */
401 static void dl_font_config_set_notification()
405 void (*set_font_nodification)();
407 handle = dlopen(SETTING_UTILS_SO_FILE_PATH, RTLD_LAZY);
409 SETTING_TRACE("ERROR!! canNOT find libsystem-settings-util.so.0.1.0");
413 set_font_nodification = dlsym(handle, "font_config_set_notification");
414 if ((error = dlerror()) != NULL) {
415 SETTING_TRACE("ERROR!! canNOT find font_config_set_notification function at libsystem-settings-util.so.0.1.0");
420 set_font_nodification();
427 /* LCOV_EXCL_START */
428 static bool dl_font_config_set(char *font_name)
433 bool (*check_font_type)(char *font_name);
435 handle = dlopen(SETTING_UTILS_SO_FILE_PATH, RTLD_LAZY);
437 SETTING_TRACE("ERROR!! canNOT find libsystem-settings-util.so.0.1.0");
441 check_font_type = dlsym(handle, "font_config_set");
442 if ((error = dlerror()) != NULL) {
443 SETTING_TRACE("ERROR!! canNOT find font_config_set function at libsystem-settings-util.so.0.1.0");
448 ret = check_font_type(font_name);
455 /* LCOV_EXCL_START */
456 static char *dl_get_font_info(char *str)
461 char *(*get_font_info)();
463 handle = dlopen(SETTING_UTILS_SO_FILE_PATH, RTLD_LAZY);
465 SETTING_TRACE("ERROR!! canNOT find libsystem-settings-util.so.0.1.0");
469 if (strcmp(str, "cur") == 0)
470 get_font_info = dlsym(handle, "_get_cur_font");
472 get_font_info = dlsym(handle, "_get_default_font");
474 if ((error = dlerror()) != NULL) {
475 SETTING_TRACE("ERROR!! canNOT find %s function at libsystem-settings-util.so.0.1.0", str);
480 ret = get_font_info();
487 /* LCOV_EXCL_START */
488 #define PATH_EXT_CHECK_REG ".(jpe?g|jpg|png|gif)$"
489 bool __is_supported_image_type_by_ext(char *file_path)
493 regmatch_t str[2048 + 1];
495 if (!file_path) return false;
498 if ((ret = regcomp(&fsm, PATH_EXT_CHECK_REG, REG_ICASE | REG_EXTENDED))) {
499 SETTING_TRACE("regular expresstion fail");
504 if (regexec(&fsm, file_path, strlen(file_path) + 1, str, 0) == REG_NOMATCH) {
505 /*SETTING_TRACE("FAILED - %s", file_path[i]); */
508 /*SETTING_TRACE("MATCHED - %s", file_path[i]); */
514 #ifdef TIZEN_WEARABLE
515 /* LCOV_EXCL_START */
516 static int system_setting_get_extended_wallpaper_num(const char *file_path, unsigned int *num)
520 const char *find_str = "extended_wallpaper_";
523 if (!(ch = strstr(file_path, find_str))) {
524 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
526 strncpy(buffer, file_path, ch - file_path);
527 buffer[ch - file_path] = 0;
528 sprintf(buffer + (ch - file_path), "%s%s", "", ch + strlen(find_str));
530 if (!isdigit(buffer[0])) {
531 SETTING_TRACE("%s is not number", buffer);
532 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
537 return SYSTEM_SETTINGS_ERROR_NONE;
541 /* LCOV_EXCL_START */
542 static int system_setting_copy_extended_wallpaper(const char *dest_file_path, const char *source_file_path)
545 if (!source_file_path || !dest_file_path) {
546 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
552 fd = open(source_file_path, O_RDONLY);
554 SETTING_TRACE("file open failed: %s", source_file_path);
555 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
559 fd2 = open(dest_file_path, O_WRONLY | O_CREAT, S_IRWXU | S_IRWXG | S_IRWXO);
561 SETTING_TRACE("file creation failed: %s", dest_file_path);
563 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
566 while (read(fd, buf, sizeof(buf) - 1) > 0) {
567 write(fd2, buf, sizeof(buf) - 1);
573 if (chmod(dest_file_path, S_IRWXU | S_IRWXG | S_IRWXO) < 0) {
574 SETTING_TRACE("chmod failed: %s", dest_file_path);
577 return SYSTEM_SETTINGS_ERROR_NONE;
581 /* LCOV_EXCL_START */
582 static int system_setting_remove_oldest_extended_wallpaper()
587 char *min_image_name = NULL;
588 unsigned int min_image_num = 0;
589 unsigned int temp_image_num = 0;
592 if ((dp = opendir(_TZ_SYS_DATA"/setting/wallpaper")) == NULL) {
593 SETTING_TRACE("opendir error");
594 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
597 while ((dirp = readdir(dp))) {
598 if (!strcmp(dirp->d_name, ".") || !strcmp(dirp->d_name, ".."))
601 if (system_setting_get_extended_wallpaper_num(dirp->d_name, &temp_image_num)
602 != SYSTEM_SETTINGS_ERROR_NONE) {
603 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
606 if ((image_count == 0) || (min_image_num > temp_image_num)) {
607 min_image_num = temp_image_num;
608 min_image_name = dirp->d_name;
615 if (min_image_name) {
616 snprintf(buf, sizeof(buf) - 1, _TZ_SYS_DATA"/setting/wallpaper/%s", min_image_name);
617 if (remove(buf) < 0) { /* remove oldest image */
618 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
622 return SYSTEM_SETTINGS_ERROR_NONE;
626 /* LCOV_EXCL_START */
627 static int system_setting_check_extended_wallpaper(const char *file_path)
631 if (!file_path || !strlen(file_path))
633 snprintf(buffer, 512, "%s/.bgwallpaper", tzplatform_getenv(TZ_USER_CONTENT));
634 return (strstr(file_path, buffer) != NULL);
638 #define WALLPAPER_MAX_COUNT 10
640 /* LCOV_EXCL_START */
641 int system_setting_set_wallpaper_home_screen(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
645 vconf_value = (char *)value;
647 bool isok = dl_is_supported_image_type_load(vconf_value);
650 SETTING_TRACE("path : %s is not supported file format", vconf_value);
651 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
653 SETTING_TRACE("path : %s is SUPPORT file format", vconf_value);
656 /* error handling here */
657 if (_is_file_accessible(vconf_value) != 0)
658 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
660 if (system_setting_vconf_set_value_string(VCONFKEY_BGSET, vconf_value)) {
661 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
665 #ifdef TIZEN_WEARABLE
666 if (system_setting_check_extended_wallpaper(vconf_value)) { /* New extended wallpaper */
669 unsigned int max_image_num = 0;
670 unsigned int temp_image_num = 0;
673 if ((dp = opendir(_TZ_SYS_DATA"/setting/wallpaper")) == NULL) {
674 SETTING_TRACE("Setting - dir open error!");
675 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
678 /* Check a max number of wallpapers */
679 while ((dirp = readdir(dp))) {
680 if (!strcmp(dirp->d_name, ".") || !strcmp(dirp->d_name, ".."))
683 if (system_setting_get_extended_wallpaper_num(dirp->d_name, &temp_image_num)
684 != SYSTEM_SETTINGS_ERROR_NONE) {
687 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
690 if ((image_count == 0) || (max_image_num < temp_image_num)) {
691 max_image_num = temp_image_num;
699 /* Numbering rule: Gear is odd number */
700 max_image_num = (max_image_num % 2 == 0) ? max_image_num + 1
703 char file_name_buffer[512];
704 snprintf(file_name_buffer, sizeof(file_name_buffer) - 1,
705 _TZ_SYS_DATA"/setting/wallpaper/extended_wallpaper_%d.jpg", max_image_num);
707 /* Copy image to _TZ_SYS_DATA/setting/wallpaper/ */
708 if (system_setting_copy_extended_wallpaper(file_name_buffer, vconf_value)
709 != SYSTEM_SETTINGS_ERROR_NONE) {
710 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
713 /* remove oldest wallpaper */
714 if (image_count >= WALLPAPER_MAX_COUNT) {
715 if (system_setting_remove_oldest_extended_wallpaper()
716 != SYSTEM_SETTINGS_ERROR_NONE) {
717 remove(file_name_buffer);
718 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
722 if (system_setting_vconf_set_value_string(VCONFKEY_BGSET, file_name_buffer)) {
723 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
726 if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_WALLPAPER_CHANGED_NOTI_INT,
727 VCONFKEY_WALLPAPER_CHANGED_NOTI_GEAR)) {
728 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
731 if (system_setting_vconf_set_value_string(VCONFKEY_BGSET, vconf_value)) {
732 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
737 return SYSTEM_SETTINGS_ERROR_NONE;
741 /* LCOV_EXCL_START */
742 int system_setting_set_wallpaper_lock_screen(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
746 vconf_value = (char *)value;
748 bool isok = dl_is_supported_image_type_load(vconf_value);
751 SETTING_TRACE("path : %s is not supported file format", vconf_value);
752 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
754 SETTING_TRACE("path : %s is SUPPORT file format", vconf_value);
757 /* error handling here */
758 if (_is_file_accessible(vconf_value) != 0)
759 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
761 if (system_setting_vconf_set_value_string(VCONFKEY_IDLE_LOCK_BGSET, vconf_value)) {
762 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
765 return SYSTEM_SETTINGS_ERROR_NONE;
769 /* LCOV_EXCL_START */
770 int system_setting_set_font_size(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
774 vconf_value = *(int **)value;
776 if (*vconf_value < 0 || *vconf_value > SYSTEM_SETTINGS_FONT_SIZE_GIANT) {
777 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
780 if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, *vconf_value)) {
781 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
785 return SYSTEM_SETTINGS_ERROR_NONE;
791 /* LCOV_EXCL_START */
792 void *font_conf_doc_parse(char *doc_name, char *font_name)
795 xmlDocPtr doc = NULL;
796 xmlNodePtr cur = NULL;
797 xmlNodePtr cur2 = NULL;
798 xmlNodePtr cur3 = NULL;
801 doc = xmlParseFile(doc_name);
803 cur = xmlDocGetRootElement(doc);
811 if (xmlStrcmp(cur->name, (const xmlChar *)"fontconfig")) {
817 cur = cur->xmlChildrenNode;
819 bool is_changed = false;
820 while (cur != NULL) {
821 if ((!xmlStrcmp(cur->name, (const xmlChar *)"match"))) {
822 cur2 = cur->xmlChildrenNode;
823 while (cur2 != NULL) {
824 if ((!xmlStrcmp(cur2->name, (const xmlChar *)"edit"))) {
825 xmlChar *name = xmlGetProp(cur2, (const xmlChar *)"name");
826 /* if name is not 'family', break */
827 if (xmlStrcmp(name, (const xmlChar *)"family")) {
835 cur3 = cur2->xmlChildrenNode;
836 while (cur3 != NULL) {
837 if ((!xmlStrcmp(cur3->name, (const xmlChar *)"string"))) {
838 xmlNodeSetContent(cur3->xmlChildrenNode, (const xmlChar *)font_name);
839 key = xmlNodeListGetString(doc, cur3->xmlChildrenNode, 1);
849 } else if ((!xmlStrcmp(cur->name, (const xmlChar *)"alias"))) {
850 cur2 = cur->xmlChildrenNode;
851 while (cur2 != NULL) {
852 if ((!xmlStrcmp(cur2->name, (const xmlChar *)"family"))) {
853 xmlNodeSetContent(cur2->xmlChildrenNode, (const xmlChar *)font_name);
854 key = xmlNodeListGetString(doc, cur2->xmlChildrenNode, 1);
858 } else if ((!xmlStrcmp(cur2->name, (const xmlChar *)"prefer"))) {
859 cur3 = cur2->xmlChildrenNode;
860 while (cur3 != NULL) {
861 if ((!xmlStrcmp(cur3->name, (const xmlChar *)"family"))) {
862 xmlNodeSetContent(cur3->xmlChildrenNode, (const xmlChar *)font_name);
863 key = xmlNodeListGetString(doc, cur3->xmlChildrenNode, 1);
889 /* LCOV_EXCL_START */
890 int system_setting_set_font_type(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
893 char *font_name = NULL;
894 font_name = (char *)value;
896 /* get current font list */
897 int is_found = dl_is_available_font(font_name);
900 SETTING_TRACE("found font : %s ", font_name);
902 SETTING_TRACE(" NOT found font : %s ", font_name);
903 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
906 bool bsave = dl_font_config_set(font_name);
909 SETTING_TRACE(" font type save error by font_config_set() ");
910 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
912 SETTING_TRACE(" save OK - font_config_set() ");
915 xmlDocPtr doc = (xmlDocPtr)font_conf_doc_parse(SETTING_FONT_CONF_FILE, font_name);
917 xmlSaveFormatFile(SETTING_FONT_CONF_FILE, doc, 0);
922 dl_font_config_set_notification();
925 vconf_value = (char *)value;
927 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, vconf_value)) {
928 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
930 return SYSTEM_SETTINGS_ERROR_NONE;
934 /* LCOV_EXCL_START */
935 int system_setting_set_motion_activation(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
939 vconf_value = (bool *)value;
940 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_MOTION_ACTIVATION, *vconf_value)) {
941 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
943 return SYSTEM_SETTINGS_ERROR_NONE;
947 /* LCOV_EXCL_START */
948 int system_setting_set_usb_debugging_option(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
952 vconf_value = (bool *)value;
953 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_USB_DEBUG_MODE_BOOL, *vconf_value)) {
954 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
956 return SYSTEM_SETTINGS_ERROR_NONE;
961 /* LCOV_EXCL_START */
962 int system_setting_set_3g_data_network(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
966 vconf_value = (bool *)value;
967 if (system_setting_vconf_set_value_bool(VCONFKEY_3G_ENABLE, *vconf_value)) {
968 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
971 return SYSTEM_SETTINGS_ERROR_NONE;
975 /* LCOV_EXCL_START */
976 static int category_func(const char *name, void *user_data)
979 static char *category = "lock-screen";
980 if (name && !strcmp(name, category)) {
981 SETTING_TRACE(" SAME ");
984 SETTING_TRACE(" DIFFERENT -- %s, category -- %s ", name, category);
994 * set 'swipe type' if current lockscreen app is 'com.samsung.lockscreen'
998 /* LCOV_EXCL_START */
999 int system_setting_set_lockscreen_app(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1001 SETTING_TRACE_BEGIN;
1003 vconf_value = (char *)value; /* ex) com.samsung.lockscreen */
1006 pkgmgrinfo_appinfo_h handle;
1007 r = pkgmgrinfo_appinfo_get_appinfo(vconf_value, &handle);
1008 if (r != PMINFO_R_OK) {
1009 SETTING_TRACE("*** pkginfo failed ");
1010 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
1012 SETTING_TRACE("%x", handle);
1015 int ret = pkgmgrinfo_appinfo_foreach_category(handle, category_func, (void *)"lock-screen");
1016 if (ret != PMINFO_R_OK) {
1017 pkgmgrinfo_appinfo_destroy_appinfo(handle);
1018 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
1021 pkgmgrinfo_appinfo_destroy_appinfo(handle);
1022 /*----------------------------------------------------------------------------------- */
1024 if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_SCREEN_LOCK_TYPE_INT, &locktype)) {
1025 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1028 if (locktype == SETTING_SCREEN_LOCK_TYPE_PASSWORD)
1029 return SYSTEM_SETTINGS_ERROR_LOCKSCREEN_APP_PASSWORD_MODE;
1031 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_3RD_LOCK_PKG_NAME_STR, vconf_value)) {
1032 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1035 if (vconf_value && strcmp(vconf_value, "com.samsung.lockscreen") == 0) {
1036 if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_SCREEN_LOCK_TYPE_INT, SETTING_SCREEN_LOCK_TYPE_SWIPE)) {
1037 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1040 return SYSTEM_SETTINGS_ERROR_NONE;
1042 /* LCOV_EXCL_STOP */
1044 /*/////////////////////////////////////////////////////////////////////////////////////////////// */
1047 int system_setting_set_changed_callback_incoming_call_ringtone(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1049 SETTING_TRACE_BEGIN;
1050 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR, SYSTEM_SETTINGS_KEY_INCOMING_CALL_RINGTONE, 0, user_data);
1053 int system_setting_unset_changed_callback_incoming_call_ringtone(system_settings_key_e key)
1055 SETTING_TRACE_BEGIN;
1056 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR, 0);
1059 int system_setting_set_changed_callback_email_alert_ringtone(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1061 SETTING_TRACE_BEGIN;
1062 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, SYSTEM_SETTINGS_KEY_EMAIL_ALERT_RINGTONE, 0, user_data);
1065 int system_setting_unset_changed_callback_email_alert_ringtone(system_settings_key_e key)
1067 SETTING_TRACE_BEGIN;
1068 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, 0);
1071 int system_setting_set_changed_callback_wallpaper_home_screen(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1073 SETTING_TRACE_BEGIN;
1074 return system_setting_vconf_set_changed_cb(VCONFKEY_BGSET, SYSTEM_SETTINGS_KEY_WALLPAPER_HOME_SCREEN, 0, user_data);
1077 int system_setting_unset_changed_callback_wallpaper_home_screen(system_settings_key_e key)
1079 SETTING_TRACE_BEGIN;
1080 return system_setting_vconf_unset_changed_cb(VCONFKEY_BGSET, 0);
1083 int system_setting_set_changed_callback_wallpaper_lock_screen(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1085 SETTING_TRACE_BEGIN;
1086 return system_setting_vconf_set_changed_cb(VCONFKEY_IDLE_LOCK_BGSET, SYSTEM_SETTINGS_KEY_WALLPAPER_LOCK_SCREEN, 0, user_data);
1089 int system_setting_unset_changed_callback_wallpaper_lock_screen(system_settings_key_e key)
1091 SETTING_TRACE_BEGIN;
1092 return system_setting_vconf_unset_changed_cb(VCONFKEY_IDLE_LOCK_BGSET, 0);
1095 int system_setting_set_changed_callback_font_size(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1097 SETTING_TRACE_BEGIN;
1098 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, SYSTEM_SETTINGS_KEY_FONT_SIZE, 1, user_data);
1101 int system_setting_unset_changed_callback_font_size(system_settings_key_e key)
1103 SETTING_TRACE_BEGIN;
1104 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, 1);
1107 int system_setting_set_changed_callback_usb_debugging_option(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1109 SETTING_TRACE_BEGIN;
1110 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_USB_DEBUG_MODE_BOOL, SYSTEM_SETTINGS_KEY_USB_DEBUGGING_ENABLED, 1, user_data);
1113 int system_setting_unset_changed_callback_usb_debugging_option(system_settings_key_e key)
1115 SETTING_TRACE_BEGIN;
1116 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_USB_DEBUG_MODE_BOOL, 1);
1119 int system_setting_set_changed_callback_3g_data_network(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1121 SETTING_TRACE_BEGIN;
1122 return system_setting_vconf_set_changed_cb(VCONFKEY_3G_ENABLE, SYSTEM_SETTINGS_KEY_3G_DATA_NETWORK_ENABLED, 1, user_data);
1125 int system_setting_unset_changed_callback_3g_data_network(system_settings_key_e key)
1127 SETTING_TRACE_BEGIN;
1128 return system_setting_vconf_unset_changed_cb(VCONFKEY_3G_ENABLE, 1);
1131 int system_setting_set_changed_callback_lockscreen_app(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1133 SETTING_TRACE_BEGIN;
1134 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_3RD_LOCK_PKG_NAME_STR, SYSTEM_SETTINGS_KEY_LOCKSCREEN_APP, 1, user_data);
1137 int system_setting_unset_changed_callback_lockscreen_app(system_settings_key_e key)
1139 SETTING_TRACE_BEGIN;
1140 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_3RD_LOCK_PKG_NAME_STR, 1);
1145 * @todo need to add custom event notification method
1147 int system_setting_set_changed_callback_font_type(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1149 SETTING_TRACE_BEGIN;
1150 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, SYSTEM_SETTINGS_KEY_FONT_TYPE, 2, user_data);
1153 int system_setting_unset_changed_callback_font_type(system_settings_key_e key)
1155 SETTING_TRACE_BEGIN;
1156 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, 2);
1159 /* TODO : 2th argument, callback, is not in use. */
1160 int system_setting_set_changed_callback_motion_activation(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1162 SETTING_TRACE_BEGIN;
1163 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_MOTION_ACTIVATION, SYSTEM_SETTINGS_KEY_MOTION_ACTIVATION, 3, user_data);
1166 int system_setting_unset_changed_callback_motion_activation(system_settings_key_e key)
1168 SETTING_TRACE_BEGIN;
1169 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_MOTION_ACTIVATION, 3);
1172 /*//////////////////////////////////////////////////////////////////////////////////////// */
1173 /*--------------------------------------- */
1174 int system_setting_get_locale_country(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1176 SETTING_TRACE_BEGIN;
1177 char *vconf_value = NULL;
1178 if (system_setting_vconf_get_value_string(VCONFKEY_REGIONFORMAT, &vconf_value)) {
1179 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1182 /* parsing validation */
1185 snprintf(arr, 20, "%s", vconf_value);
1187 *value = strdup(arr);
1191 return SYSTEM_SETTINGS_ERROR_NONE;
1194 /* LCOV_EXCL_START */
1195 int system_setting_set_locale_country(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1197 SETTING_TRACE_BEGIN;
1198 char *vconf_value = NULL;
1199 vconf_value = (char *)value;
1201 char *ext = "UTF-8";
1204 snprintf(arr, 20, "%s.%s", vconf_value, ext);
1206 if (system_setting_vconf_set_value_string(VCONFKEY_REGIONFORMAT, arr)) {
1207 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1209 return SYSTEM_SETTINGS_ERROR_NONE;
1211 /* LCOV_EXCL_STOP */
1213 int system_setting_set_changed_callback_locale_country(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1215 SETTING_TRACE_BEGIN;
1216 return system_setting_vconf_set_changed_cb(VCONFKEY_REGIONFORMAT, SYSTEM_SETTINGS_KEY_LOCALE_COUNTRY, 3, user_data);
1219 int system_setting_unset_changed_callback_locale_country(system_settings_key_e key)
1221 SETTING_TRACE_BEGIN;
1222 return system_setting_vconf_unset_changed_cb(VCONFKEY_REGIONFORMAT, 3);
1226 /*--------------------------------------- */
1227 int system_setting_get_locale_language(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1229 SETTING_TRACE_BEGIN;
1230 char *vconf_value = NULL;
1231 if (system_setting_vconf_get_value_string(VCONFKEY_LANGSET, &vconf_value)) {
1232 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1235 /* parsing validation */
1238 snprintf(arr, 20, "%s", vconf_value);
1240 *value = strdup(arr);
1243 return SYSTEM_SETTINGS_ERROR_NONE;
1246 /* LCOV_EXCL_START */
1247 int system_setting_set_locale_language(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1249 SETTING_TRACE_BEGIN;
1250 char *vconf_value = NULL;
1251 vconf_value = (char *)value;
1253 char *ext = "UTF-8";
1256 snprintf(arr, 20, "%s.%s", vconf_value, ext);
1258 if (system_setting_vconf_set_value_string(VCONFKEY_LANGSET, arr)) {
1259 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1261 return SYSTEM_SETTINGS_ERROR_NONE;
1263 /* LCOV_EXCL_STOP */
1265 int system_setting_set_changed_callback_locale_language(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1267 SETTING_TRACE_BEGIN;
1268 /*return system_setting_vconf_set_changed_cb(VCONFKEY_LANGSET, SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, 3, user_data ); */
1269 return system_setting_vconf_set_changed_cb(VCONFKEY_LANGSET, SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, 100, user_data);
1272 int system_setting_unset_changed_callback_locale_language(system_settings_key_e key)
1274 SETTING_TRACE_BEGIN;
1275 return system_setting_vconf_unset_changed_cb(VCONFKEY_LANGSET, 100);
1278 /*--------------------------------------- */
1279 /* LCOV_EXCL_START */
1280 int system_setting_get_locale_timeformat_24hour(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1282 SETTING_TRACE_BEGIN;
1285 if (system_setting_vconf_get_value_int(VCONFKEY_REGIONFORMAT_TIME1224, &vconf_value)) {
1286 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1289 bool ret_value = true;
1290 if (vconf_value == VCONFKEY_TIME_FORMAT_12)
1292 else if (vconf_value == VCONFKEY_TIME_FORMAT_24)
1295 *value = (void *)ret_value;
1297 return SYSTEM_SETTINGS_ERROR_NONE;
1299 /* LCOV_EXCL_STOP */
1301 int system_setting_set_locale_timeformat_24hour(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1303 SETTING_TRACE_BEGIN;
1306 vconf_value = (bool *)value;
1309 if (system_setting_vconf_set_value_int(VCONFKEY_REGIONFORMAT_TIME1224, VCONFKEY_TIME_FORMAT_24)) {
1310 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1314 if (system_setting_vconf_set_value_int(VCONFKEY_REGIONFORMAT_TIME1224, VCONFKEY_TIME_FORMAT_12)) {
1315 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1320 return SYSTEM_SETTINGS_ERROR_NONE;
1323 int system_setting_set_changed_callback_locale_timeformat_24hour(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1325 SETTING_TRACE_BEGIN;
1326 return system_setting_vconf_set_changed_cb(VCONFKEY_REGIONFORMAT_TIME1224, SYSTEM_SETTINGS_KEY_LOCALE_TIMEFORMAT_24HOUR, 3, user_data);
1329 int system_setting_unset_changed_callback_locale_timeformat_24hour(system_settings_key_e key)
1331 SETTING_TRACE_BEGIN;
1332 return system_setting_vconf_unset_changed_cb(VCONFKEY_REGIONFORMAT_TIME1224, 3);
1335 int system_setting_get_locale_timezone(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1338 ssize_t len = readlink(SETTING_TZONE_SYMLINK_PATH, tzpath, sizeof(tzpath)-1);
1342 SETTING_TRACE("parse error for SETTING_TZONE_SYMLINK_PATH");
1343 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1346 SETTING_TRACE("tzpath : %s ", &tzpath[20]);
1347 *value = strdup(&tzpath[20]);
1348 return SYSTEM_SETTINGS_ERROR_NONE;
1351 /* LCOV_EXCL_START */
1352 int system_setting_set_locale_timezone(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1354 SETTING_TRACE_BEGIN;
1355 char *timezone_value = NULL;
1356 timezone_value = (char *)value;
1359 snprintf(tz_path, 1024, "/usr/share/zoneinfo/%s", timezone_value);
1361 int is_load = _is_file_accessible(tz_path);
1363 alarmmgr_set_timezone(tz_path);
1365 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_TIMEZONE_ID, timezone_value)) {
1366 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1368 return SYSTEM_SETTINGS_ERROR_NONE;
1370 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
1372 /* LCOV_EXCL_STOP */
1376 /* LCOV_EXCL_START */
1377 int system_setting_set_changed_callback_locale_timezone(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1379 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_TIMEZONE_ID, SYSTEM_SETTINGS_KEY_LOCALE_TIMEZONE, 4, user_data);
1381 /* LCOV_EXCL_STOP */
1383 /* LCOV_EXCL_START */
1384 int system_setting_unset_changed_callback_locale_timezone(system_settings_key_e key)
1386 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_TIMEZONE_ID, 4);
1388 /* LCOV_EXCL_STOP */
1390 /* LCOV_EXCL_START */
1391 int system_setting_set_changed_callback_locale_timezone_changed(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1393 SETTING_TRACE_BEGIN;
1394 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
1396 /* LCOV_EXCL_STOP */
1398 /* LCOV_EXCL_START */
1399 int system_setting_unset_changed_callback_locale_timezone_changed(system_settings_key_e key)
1401 SETTING_TRACE_BEGIN;
1402 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
1404 /* LCOV_EXCL_STOP */
1407 /* LCOV_EXCL_START */
1408 int system_setting_get_time_changed(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1410 SETTING_TRACE_BEGIN;
1412 int ** val = (int**)value;
1413 cur_tick = time(NULL);
1415 /* struct tm * localtime = time (cur_tick); */
1416 /* printf("%s\n", ctime(&cur_tick); */
1417 return SYSTEM_SETTINGS_ERROR_NONE;
1420 /* LCOV_EXCL_STOP */
1422 int system_setting_set_changed_callback_time_changed(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1424 SETTING_TRACE_BEGIN;
1425 return system_setting_vconf_set_changed_cb(VCONFKEY_SYSTEM_TIME_CHANGED, SYSTEM_SETTINGS_KEY_TIME_CHANGED, 3, user_data);
1428 int system_setting_unset_changed_callback_time_changed(system_settings_key_e key)
1430 SETTING_TRACE_BEGIN;
1431 return system_setting_vconf_unset_changed_cb(VCONFKEY_SYSTEM_TIME_CHANGED, 3);
1436 /* SYSTEM_SETTINGS_KEY_SOUND_LOCK */
1437 int system_setting_get_sound_lock(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1439 SETTING_TRACE_BEGIN;
1442 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_SOUND_LOCK_BOOL, &vconf_value)) {
1443 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1445 *value = (void *)vconf_value;
1447 return SYSTEM_SETTINGS_ERROR_NONE;
1450 int system_setting_set_changed_callback_sound_lock(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1452 SETTING_TRACE_BEGIN;
1453 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_SOUND_LOCK_BOOL, SYSTEM_SETTINGS_KEY_SOUND_LOCK, 3, user_data);
1456 int system_setting_unset_changed_callback_sound_lock(system_settings_key_e key)
1458 SETTING_TRACE_BEGIN;
1459 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_SOUND_LOCK_BOOL, 3);
1463 * a = VCONFKEY_SETAPPL_SOUND_STATUS_BOOL b = VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL
1465 * a == false, b == false --> silent mode
1466 * a == true, b == false --> sound mode
1467 * a == false, b == true --> vibration mode
1469 /* LCOV_EXCL_START */
1470 int system_setting_get_sound_silent_mode(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1472 SETTING_TRACE_BEGIN;
1477 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, &sound_cond)) {
1478 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1481 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, &vib_cond)) {
1482 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1485 if (sound_cond == false && vib_cond == false) {
1487 *value = (void *)vconf_value;
1489 vconf_value = false;
1490 *value = (void *)vconf_value;
1492 return SYSTEM_SETTINGS_ERROR_NONE;
1494 /* LCOV_EXCL_STOP */
1497 * a = VCONFKEY_SETAPPL_SOUND_STATUS_BOOL b = VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL
1499 * a == false, b == false --> silent mode
1500 * a == true, b == false --> sound mode
1502 int system_setting_set_sound_silent_mode(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1504 SETTING_TRACE_BEGIN;
1507 vconf_value = (bool *)value;
1509 bool vconf_sound = false;
1510 bool vconf_vib = false;
1513 vconf_sound = false;
1520 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, vconf_sound)) {
1521 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1523 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, vconf_vib)) {
1524 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1527 return SYSTEM_SETTINGS_ERROR_NONE;
1533 int system_setting_set_changed_callback_sound_silent_mode(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1535 SETTING_TRACE_BEGIN;
1536 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, SYSTEM_SETTINGS_KEY_SOUND_SILENT_MODE, 3, user_data);
1540 int system_setting_unset_changed_callback_sound_silent_mode(system_settings_key_e key)
1542 SETTING_TRACE_BEGIN;
1543 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, 3);
1546 /* SYSTEM_SETTINGS_KEY_SOUND_TOUCH */
1547 int system_setting_get_sound_touch(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1549 SETTING_TRACE_BEGIN;
1552 int ret = system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL, &vconf_value);
1553 if (ret != SYSTEM_SETTINGS_ERROR_NONE) {
1556 *value = (void *)vconf_value;
1560 int system_setting_set_changed_callback_sound_touch(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1562 SETTING_TRACE_BEGIN;
1563 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL, SYSTEM_SETTINGS_KEY_SOUND_TOUCH, 2, user_data);
1566 int system_setting_unset_changed_callback_sound_touch(system_settings_key_e key)
1568 SETTING_TRACE_BEGIN;
1569 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL, 2);
1573 /* SYSTEM_SETTINGS_KEY_SOUND_LOCK */
1574 int system_setting_get_sound_lock(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1578 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_SOUND_LOCK_BOOL, &vconf_value)) {
1579 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1581 *value = (void *)vconf_value;
1583 return SYSTEM_SETTINGS_ERROR_NONE;
1587 int system_setting_get_auto_rotation_mode(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1589 SETTING_TRACE_BEGIN;
1592 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, &vconf_value)) {
1593 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1595 *value = (void *)vconf_value;
1597 return SYSTEM_SETTINGS_ERROR_NONE;
1600 /* LCOV_EXCL_START */
1601 int system_setting_set_auto_rotation_mode(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1603 SETTING_TRACE_BEGIN;
1605 vconf_value = (bool *)value;
1606 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, *vconf_value)) {
1607 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1610 return SYSTEM_SETTINGS_ERROR_NONE;
1612 /* LCOV_EXCL_STOP */
1614 int system_setting_set_changed_callback_auto_rotation_mode(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1616 SETTING_TRACE_BEGIN;
1617 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, SYSTEM_SETTINGS_KEY_DISPLAY_SCREEN_ROTATION_AUTO, 2, user_data);
1620 int system_setting_unset_changed_callback_auto_rotation_mode(system_settings_key_e key)
1622 SETTING_TRACE_BEGIN;
1623 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, 2);
1626 int system_setting_get_screen_backlight_time(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1628 SETTING_TRACE_BEGIN;
1630 int ** val = (int**)value;
1632 if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, &vconf_value)) {
1633 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1635 **val = vconf_value;
1637 return SYSTEM_SETTINGS_ERROR_NONE;
1641 /* LCOV_EXCL_START */
1642 int system_setting_set_screen_backlight_time(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1644 SETTING_TRACE_BEGIN;
1646 vconf_value = *(int **)value;
1648 if (!(*vconf_value > 0 && *vconf_value < 600)) {
1649 SETTING_TRACE(" ERR Betweeny here 0 ~ 600");
1650 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
1653 if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, *vconf_value)) {
1654 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1657 return SYSTEM_SETTINGS_ERROR_NONE;
1659 /* LCOV_EXCL_STOP */
1661 int system_setting_set_changed_callback_screen_backlight_time(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1663 SETTING_TRACE_BEGIN;
1664 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, SYSTEM_SETTINGS_KEY_DISPLAY_SCREEN_ROTATION_AUTO, 2, user_data);
1667 int system_setting_unset_changed_callback_screen_backlight_time(system_settings_key_e key)
1669 SETTING_TRACE_BEGIN;
1670 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, 2);
1673 int system_setting_get_sound_notification(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1675 SETTING_TRACE_BEGIN;
1676 char *vconf_value = NULL;
1677 if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, &vconf_value)) {
1678 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1681 *value = vconf_value;
1682 return SYSTEM_SETTINGS_ERROR_NONE;
1685 /* LCOV_EXCL_START */
1686 int system_setting_set_sound_notification(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1688 SETTING_TRACE_BEGIN;
1689 char *vconf_value = NULL;
1690 vconf_value = (char *)value;
1692 int is_load = _is_file_accessible(vconf_value);
1694 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, vconf_value)) {
1695 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1698 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1701 return SYSTEM_SETTINGS_ERROR_NONE;
1703 /* LCOV_EXCL_STOP */
1705 int system_setting_set_changed_callback_sound_notification(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1707 SETTING_TRACE_BEGIN;
1708 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, SYSTEM_SETTINGS_KEY_INCOMING_CALL_RINGTONE, 0, user_data);
1711 int system_setting_unset_changed_callback_sound_notification(system_settings_key_e key)
1713 SETTING_TRACE_BEGIN;
1714 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, 0);
1717 int system_setting_get_notification_repetition_period(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1719 SETTING_TRACE_BEGIN;
1720 int ** val = (int**)value;
1723 if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_NOTI_MSG_ALERT_REP_TYPE_INT, &vconf_value)) {
1724 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1726 **val = vconf_value;
1728 return SYSTEM_SETTINGS_ERROR_NONE;
1731 /* LCOV_EXCL_START */
1732 int system_setting_set_notification_repetition_period(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1734 SETTING_TRACE_BEGIN;
1736 vconf_value = *(int **)value;
1738 if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_NOTI_MSG_ALERT_REP_TYPE_INT, *vconf_value)) {
1739 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1742 return SYSTEM_SETTINGS_ERROR_NONE;
1744 /* LCOV_EXCL_STOP */
1746 int system_setting_set_changed_callback_notification_repetition_period(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_NOTI_MSG_ALERT_REP_TYPE_INT, SYSTEM_SETTINGS_KEY_SOUND_NOTIFICATION_REPETITION_PERIOD, 1, user_data);
1752 int system_setting_unset_changed_callback_notification_repetition_period(system_settings_key_e key)
1754 SETTING_TRACE_BEGIN;
1755 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_ALERT_REP_TYPE_INT, 1);
1758 int system_setting_get_device_name(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1760 SETTING_TRACE_BEGIN;
1761 char *vconf_value = NULL;
1762 if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_DEVICE_NAME_STR, &vconf_value)) {
1763 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1766 *value = vconf_value;
1767 return SYSTEM_SETTINGS_ERROR_NONE;
1770 /* LCOV_EXCL_START */
1771 int system_setting_set_device_name(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1773 SETTING_TRACE_BEGIN;
1774 char *vconf_value = NULL;
1775 vconf_value = (char *)value;
1777 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_DEVICE_NAME_STR, vconf_value)) {
1778 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1781 return SYSTEM_SETTINGS_ERROR_NONE;
1783 /* LCOV_EXCL_STOP */
1785 int system_setting_set_changed_callback_device_name(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1787 SETTING_TRACE_BEGIN;
1788 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_DEVICE_NAME_STR, SYSTEM_SETTINGS_KEY_DEVICE_NAME, 0, user_data);
1791 int system_setting_unset_changed_callback_device_name(system_settings_key_e key)
1793 SETTING_TRACE_BEGIN;
1794 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_DEVICE_NAME_STR, 0);
1797 /*---------------------------------------------- */
1798 int system_setting_get_network_flight_mode(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1800 SETTING_TRACE_BEGIN;
1802 if (system_setting_vconf_get_value_bool(VCONFKEY_TELEPHONY_FLIGHT_MODE, &vconf_value)) {
1803 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1805 *value = (void *)vconf_value;
1807 return SYSTEM_SETTINGS_ERROR_NONE;
1810 int system_setting_set_changed_callback_network_flight_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_TELEPHONY_FLIGHT_MODE, SYSTEM_SETTINGS_KEY_NETWORK_FLIGHT_MODE, 3, user_data);
1816 int system_setting_unset_changed_callback_network_flight_mode(system_settings_key_e key)
1818 SETTING_TRACE_BEGIN;
1819 return system_setting_vconf_unset_changed_cb(VCONFKEY_TELEPHONY_FLIGHT_MODE, 3);
1822 int system_setting_get_network_wifi_notification(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1824 SETTING_TRACE_BEGIN;
1826 if (system_setting_vconf_get_value_int(VCONFKEY_WIFI_ENABLE_QS, &vconf_value)) {
1827 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1830 bret = (vconf_value == VCONFKEY_WIFI_QS_ENABLE) ? true : false;
1832 *value = (void *)bret;
1833 return SYSTEM_SETTINGS_ERROR_NONE;
1836 int system_setting_set_changed_callback_network_wifi_notification(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1838 SETTING_TRACE_BEGIN;
1839 return system_setting_vconf_set_changed_cb(VCONFKEY_WIFI_ENABLE_QS, SYSTEM_SETTINGS_KEY_NETWORK_WIFI_NOTIFICATION, 4, user_data);
1842 int system_setting_unset_changed_callback_network_wifi_notification(system_settings_key_e key)
1844 SETTING_TRACE_BEGIN;
1845 return system_setting_vconf_unset_changed_cb(VCONFKEY_WIFI_ENABLE_QS, 4);
1848 /* LCOV_EXCL_START */
1849 int system_setting_get_lock_state(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1852 int ** val = (int**)value;
1854 if (system_setting_vconf_get_value_int(VCONFKEY_IDLE_LOCK_STATE_READ_ONLY, &vconf_value)) {
1855 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1857 **val = vconf_value;
1859 return SYSTEM_SETTINGS_ERROR_NONE;
1861 /* LCOV_EXCL_STOP */
1863 /* LCOV_EXCL_START */
1864 int system_setting_set_lock_state(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1866 SETTING_TRACE_BEGIN;
1868 vconf_value = *(int **)value;
1870 if (system_setting_vconf_set_value_int(VCONFKEY_IDLE_LOCK_STATE_READ_ONLY, *vconf_value)) {
1871 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1874 return SYSTEM_SETTINGS_ERROR_NONE;
1876 /* LCOV_EXCL_STOP */
1878 /* LCOV_EXCL_START */
1879 int system_setting_set_changed_callback_lock_state(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1881 return system_setting_vconf_set_changed_cb(VCONFKEY_IDLE_LOCK_STATE_READ_ONLY, SYSTEM_SETTINGS_KEY_LOCK_STATE, 4, user_data);
1883 /* LCOV_EXCL_STOP */
1885 /* LCOV_EXCL_START */
1886 int system_setting_unset_changed_callback_lock_state(system_settings_key_e key)
1888 return system_setting_vconf_unset_changed_cb(VCONFKEY_IDLE_LOCK_STATE_READ_ONLY, 4);
1890 /* LCOV_EXCL_STOP */
1892 //----------------------------------------------------------------------------------------------------------------------------
1894 #define DEFAULT_ADS_ID "00000000-0000-0000-0000-000000000000"
1896 int system_setting_get_ads_id(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1898 SETTING_TRACE_BEGIN;
1899 int optout_value = 0;
1900 if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_AD_ID_OPT_OUT, &optout_value)) {
1901 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1904 if (optout_value == 1) {
1905 *value = strdup(DEFAULT_ADS_ID);
1906 return SYSTEM_SETTINGS_ERROR_NONE;
1909 char *vconf_value = NULL;
1910 if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_AD_ID, &vconf_value)) {
1911 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1914 *value = vconf_value;
1915 return SYSTEM_SETTINGS_ERROR_NONE;
1920 void make_ad_id(void)
1923 char uuid_unparsed[50] = {0};
1924 uuid_generate(uuid_value);
1925 uuid_unparse(uuid_value, uuid_unparsed);
1926 system_setting_set_ad_id(key, uuid_unparsed); //example of setting the value
1929 /* LCOV_EXCL_START */
1930 int system_setting_set_ads_id(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1932 SETTING_TRACE_BEGIN;
1933 char *vconf_value = NULL;
1934 vconf_value = (char *)value;
1936 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_AD_ID, vconf_value)) {
1937 SETTING_TRACE("Setting VCONFKEY_SETAPPL_AD_ID failed");
1938 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1941 return SYSTEM_SETTINGS_ERROR_NONE;
1943 /* LCOV_EXCL_STOP */
1945 int system_setting_set_changed_callback_ads_id(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_AD_ID, SYSTEM_SETTINGS_KEY_ADS_ID, 0, user_data);
1951 int system_setting_unset_changed_callback_ads_id(system_settings_key_e key)
1953 SETTING_TRACE_BEGIN;
1954 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_AD_ID, 0);