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)
156 if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, &vconf_value)) {
157 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
159 *value = (void *)vconf_value;
161 return SYSTEM_SETTINGS_ERROR_NONE;
165 int system_setting_get_default_font_type(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
168 char *font_name = dl_get_font_info("default");
170 *value = (void *)font_name;
171 return SYSTEM_SETTINGS_ERROR_NONE;
173 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
177 /* [int] vconf GET */
178 int system_setting_get_font_type(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
181 char *font_name = dl_get_font_info("cur");
182 *value = (void *)font_name;
184 return SYSTEM_SETTINGS_ERROR_NONE;
188 int system_setting_get_motion_activation(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
193 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_MOTION_ACTIVATION, &vconf_value)) {
194 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
196 *value = (void *)vconf_value;
198 return SYSTEM_SETTINGS_ERROR_NONE;
201 int system_setting_get_usb_debugging_option(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
206 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_USB_DEBUG_MODE_BOOL, &vconf_value)) {
207 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
209 *value = (void *)vconf_value;
211 return SYSTEM_SETTINGS_ERROR_NONE;
214 int system_setting_get_3g_data_network(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
219 if (system_setting_vconf_get_value_bool(VCONFKEY_3G_ENABLE, &vconf_value)) {
220 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
222 *value = (void *)vconf_value;
224 return SYSTEM_SETTINGS_ERROR_NONE;
226 /*////////////////////////////////////////////////////////////////////////////////////////////////// */
230 * get current lock scren app package name (string)
232 * @return SYSTEM_SETTINGS_ERROR_LOCKSCREEN_APP_PASSWORD_MODE raise exception if current lock type is 'password'
234 /* LCOV_EXCL_START */
235 int system_setting_get_lockscreen_app(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
238 char *pkg_name = NULL;
240 system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_SCREEN_LOCK_TYPE_INT, &locktype);
242 if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_3RD_LOCK_PKG_NAME_STR, &pkg_name)) {
243 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
246 if (pkg_name && strcmp(pkg_name, "com.samsung.lockscreen") == 0 && locktype == SETTING_SCREEN_LOCK_TYPE_PASSWORD) {
247 return SYSTEM_SETTINGS_ERROR_LOCKSCREEN_APP_PASSWORD_MODE;
251 return SYSTEM_SETTINGS_ERROR_NONE;
256 /*////////////////////////////////////////////////////////////////////////////////////////////////// */
258 int _is_file_accessible(const char *path)
261 int ret = access(path , R_OK);
263 SETTING_TRACE("found the file %s", path);
266 /* error code : 13 */
267 SETTING_TRACE("found the file %s --- error code : %d ", path, errno);
272 /* LCOV_EXCL_START */
273 int system_setting_set_incoming_call_ringtone(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
277 vconf_value = (char *)value;
279 int ret = _is_file_accessible(vconf_value);
281 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR, vconf_value)) {
282 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
285 /* @todo add a common ret_handler */
289 return SYSTEM_SETTINGS_ERROR_NONE;
294 /* LCOV_EXCL_START */
295 int system_setting_set_email_alert_ringtone(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
299 vconf_value = (char *)value;
301 int ret = _is_file_accessible(vconf_value);
303 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, vconf_value)) {
304 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
307 /*return SYSTEM_SETTINGS_ERROR_IO_ERROR;*/
308 /* @todo add a common ret_handler */
312 return SYSTEM_SETTINGS_ERROR_NONE;
316 /* LCOV_EXCL_START */
317 static bool dl_is_supported_image_type_load(char *path)
322 bool (*image_type_check)(char *path);
324 handle = dlopen(SETTING_UTILS_SO_FILE_PATH, RTLD_LAZY);
326 SETTING_TRACE("ERROR!! canNOT find libsystem-settings-util.so.0.1.0");
330 image_type_check = dlsym(handle, "__is_supported_image_type_load");
331 if ((error = dlerror()) != NULL) {
332 SETTING_TRACE("ERROR!! canNOT find __is_supported_image_type_load function at libsystem-settings-util.so.0.1.0");
337 ret = image_type_check(path);
344 /* LCOV_EXCL_START */
345 static int dl_is_available_font(char *str)
350 int (*check_available_font)(char *font_name);
352 handle = dlopen(SETTING_UTILS_SO_FILE_PATH, RTLD_LAZY);
354 SETTING_TRACE("ERROR!! canNOT find libsystem-settings-util.so.0.1.0");
358 check_available_font = dlsym(handle, "__is_available_font");
359 if ((error = dlerror()) != NULL) {
360 SETTING_TRACE("ERROR!! canNOT find __is_available_font function at libsystem-settings-util.so.0.1.0");
365 ret = check_available_font(str);
372 /* LCOV_EXCL_START */
373 static void dl_font_size_set()
377 void (*set_font_size)();
379 handle = dlopen(SETTING_UTILS_SO_FILE_PATH, RTLD_LAZY);
381 SETTING_TRACE("ERROR!! canNOT find libsystem-settings-util.so.0.1.0");
385 set_font_size = dlsym(handle, "__font_size_set");
386 if ((error = dlerror()) != NULL) {
387 SETTING_TRACE("ERROR!! canNOT find __font_size_set function at libsystem-settings-util.so.0.1.0");
399 /* LCOV_EXCL_START */
400 static void dl_font_config_set_notification()
404 void (*set_font_nodification)();
406 handle = dlopen(SETTING_UTILS_SO_FILE_PATH, RTLD_LAZY);
408 SETTING_TRACE("ERROR!! canNOT find libsystem-settings-util.so.0.1.0");
412 set_font_nodification = dlsym(handle, "font_config_set_notification");
413 if ((error = dlerror()) != NULL) {
414 SETTING_TRACE("ERROR!! canNOT find font_config_set_notification function at libsystem-settings-util.so.0.1.0");
419 set_font_nodification();
426 /* LCOV_EXCL_START */
427 static bool dl_font_config_set(char *font_name)
432 bool (*check_font_type)(char *font_name);
434 handle = dlopen(SETTING_UTILS_SO_FILE_PATH, RTLD_LAZY);
436 SETTING_TRACE("ERROR!! canNOT find libsystem-settings-util.so.0.1.0");
440 check_font_type = dlsym(handle, "font_config_set");
441 if ((error = dlerror()) != NULL) {
442 SETTING_TRACE("ERROR!! canNOT find font_config_set function at libsystem-settings-util.so.0.1.0");
447 ret = check_font_type(font_name);
454 /* LCOV_EXCL_START */
455 static char *dl_get_font_info(char *str)
460 char *(*get_font_info)();
462 handle = dlopen(SETTING_UTILS_SO_FILE_PATH, RTLD_LAZY);
464 SETTING_TRACE("ERROR!! canNOT find libsystem-settings-util.so.0.1.0");
468 if (strcmp(str, "cur") == 0)
469 get_font_info = dlsym(handle, "_get_cur_font");
471 get_font_info = dlsym(handle, "_get_default_font");
473 if ((error = dlerror()) != NULL) {
474 SETTING_TRACE("ERROR!! canNOT find %s function at libsystem-settings-util.so.0.1.0", str);
479 ret = get_font_info();
486 /* LCOV_EXCL_START */
487 #define PATH_EXT_CHECK_REG ".(jpe?g|jpg|png|gif)$"
488 bool __is_supported_image_type_by_ext(char *file_path)
492 regmatch_t str[2048 + 1];
494 if (!file_path) return false;
497 if ((ret = regcomp(&fsm, PATH_EXT_CHECK_REG, REG_ICASE | REG_EXTENDED))) {
498 SETTING_TRACE("regular expresstion fail");
503 if (regexec(&fsm, file_path, strlen(file_path) + 1, str, 0) == REG_NOMATCH) {
504 /*SETTING_TRACE("FAILED - %s", file_path[i]); */
507 /*SETTING_TRACE("MATCHED - %s", file_path[i]); */
513 #ifdef TIZEN_WEARABLE
514 /* LCOV_EXCL_START */
515 static int system_setting_get_extended_wallpaper_num(const char *file_path, unsigned int *num)
519 const char *find_str = "extended_wallpaper_";
522 if (!(ch = strstr(file_path, find_str))) {
523 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
525 strncpy(buffer, file_path, ch - file_path);
526 buffer[ch - file_path] = 0;
527 sprintf(buffer + (ch - file_path), "%s%s", "", ch + strlen(find_str));
529 if (!isdigit(buffer[0])) {
530 SETTING_TRACE("%s is not number", buffer);
531 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
536 return SYSTEM_SETTINGS_ERROR_NONE;
540 /* LCOV_EXCL_START */
541 static int system_setting_copy_extended_wallpaper(const char *dest_file_path, const char *source_file_path)
544 if (!source_file_path || !dest_file_path) {
545 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
551 fd = open(source_file_path, O_RDONLY);
553 SETTING_TRACE("file open failed: %s", source_file_path);
554 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
558 fd2 = open(dest_file_path, O_WRONLY | O_CREAT, S_IRWXU | S_IRWXG | S_IRWXO);
560 SETTING_TRACE("file creation failed: %s", dest_file_path);
562 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
565 while (read(fd, buf, sizeof(buf) - 1) > 0) {
566 write(fd2, buf, sizeof(buf) - 1);
572 if (chmod(dest_file_path, S_IRWXU | S_IRWXG | S_IRWXO) < 0) {
573 SETTING_TRACE("chmod failed: %s", dest_file_path);
576 return SYSTEM_SETTINGS_ERROR_NONE;
580 /* LCOV_EXCL_START */
581 static int system_setting_remove_oldest_extended_wallpaper()
586 char *min_image_name = NULL;
587 unsigned int min_image_num = 0;
588 unsigned int temp_image_num = 0;
591 if ((dp = opendir(_TZ_SYS_DATA"/setting/wallpaper")) == NULL) {
592 SETTING_TRACE("opendir error");
593 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
596 while ((dirp = readdir(dp))) {
597 if (!strcmp(dirp->d_name, ".") || !strcmp(dirp->d_name, ".."))
600 if (system_setting_get_extended_wallpaper_num(dirp->d_name, &temp_image_num)
601 != SYSTEM_SETTINGS_ERROR_NONE) {
602 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
605 if ((image_count == 0) || (min_image_num > temp_image_num)) {
606 min_image_num = temp_image_num;
607 min_image_name = dirp->d_name;
614 if (min_image_name) {
615 snprintf(buf, sizeof(buf) - 1, _TZ_SYS_DATA"/setting/wallpaper/%s", min_image_name);
616 if (remove(buf) < 0) { /* remove oldest image */
617 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
621 return SYSTEM_SETTINGS_ERROR_NONE;
625 /* LCOV_EXCL_START */
626 static int system_setting_check_extended_wallpaper(const char *file_path)
630 if (!file_path || !strlen(file_path))
632 snprintf(buffer, 512, "%s/.bgwallpaper", tzplatform_getenv(TZ_USER_CONTENT));
633 return (strstr(file_path, buffer) != NULL);
637 #define WALLPAPER_MAX_COUNT 10
639 /* LCOV_EXCL_START */
640 int system_setting_set_wallpaper_home_screen(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
644 vconf_value = (char *)value;
646 bool isok = dl_is_supported_image_type_load(vconf_value);
649 SETTING_TRACE("path : %s is not supported file format", vconf_value);
650 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
652 SETTING_TRACE("path : %s is SUPPORT file format", vconf_value);
655 /* error handling here */
656 if (_is_file_accessible(vconf_value) != 0)
657 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
659 if (system_setting_vconf_set_value_string(VCONFKEY_BGSET, vconf_value)) {
660 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
664 #ifdef TIZEN_WEARABLE
665 if (system_setting_check_extended_wallpaper(vconf_value)) { /* New extended wallpaper */
668 unsigned int max_image_num = 0;
669 unsigned int temp_image_num = 0;
672 if ((dp = opendir(_TZ_SYS_DATA"/setting/wallpaper")) == NULL) {
673 SETTING_TRACE("Setting - dir open error!");
674 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
677 /* Check a max number of wallpapers */
678 while ((dirp = readdir(dp))) {
679 if (!strcmp(dirp->d_name, ".") || !strcmp(dirp->d_name, ".."))
682 if (system_setting_get_extended_wallpaper_num(dirp->d_name, &temp_image_num)
683 != SYSTEM_SETTINGS_ERROR_NONE) {
686 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
689 if ((image_count == 0) || (max_image_num < temp_image_num)) {
690 max_image_num = temp_image_num;
698 /* Numbering rule: Gear is odd number */
699 max_image_num = (max_image_num % 2 == 0) ? max_image_num + 1
702 char file_name_buffer[512];
703 snprintf(file_name_buffer, sizeof(file_name_buffer) - 1,
704 _TZ_SYS_DATA"/setting/wallpaper/extended_wallpaper_%d.jpg", max_image_num);
706 /* Copy image to _TZ_SYS_DATA/setting/wallpaper/ */
707 if (system_setting_copy_extended_wallpaper(file_name_buffer, vconf_value)
708 != SYSTEM_SETTINGS_ERROR_NONE) {
709 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
712 /* remove oldest wallpaper */
713 if (image_count >= WALLPAPER_MAX_COUNT) {
714 if (system_setting_remove_oldest_extended_wallpaper()
715 != SYSTEM_SETTINGS_ERROR_NONE) {
716 remove(file_name_buffer);
717 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
721 if (system_setting_vconf_set_value_string(VCONFKEY_BGSET, file_name_buffer)) {
722 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
725 if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_WALLPAPER_CHANGED_NOTI_INT,
726 VCONFKEY_WALLPAPER_CHANGED_NOTI_GEAR)) {
727 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
730 if (system_setting_vconf_set_value_string(VCONFKEY_BGSET, vconf_value)) {
731 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
736 return SYSTEM_SETTINGS_ERROR_NONE;
740 /* LCOV_EXCL_START */
741 int system_setting_set_wallpaper_lock_screen(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
745 vconf_value = (char *)value;
747 bool isok = dl_is_supported_image_type_load(vconf_value);
750 SETTING_TRACE("path : %s is not supported file format", vconf_value);
751 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
753 SETTING_TRACE("path : %s is SUPPORT file format", vconf_value);
756 /* error handling here */
757 if (_is_file_accessible(vconf_value) != 0)
758 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
760 if (system_setting_vconf_set_value_string(VCONFKEY_IDLE_LOCK_BGSET, vconf_value)) {
761 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
764 return SYSTEM_SETTINGS_ERROR_NONE;
768 /* LCOV_EXCL_START */
769 int system_setting_set_font_size(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
773 vconf_value = (int *)value;
775 if (*vconf_value < 0 || *vconf_value > SYSTEM_SETTINGS_FONT_SIZE_GIANT) {
776 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
779 if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, *vconf_value)) {
780 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
784 return SYSTEM_SETTINGS_ERROR_NONE;
790 /* LCOV_EXCL_START */
791 void *font_conf_doc_parse(char *doc_name, char *font_name)
794 xmlDocPtr doc = NULL;
795 xmlNodePtr cur = NULL;
796 xmlNodePtr cur2 = NULL;
797 xmlNodePtr cur3 = NULL;
800 doc = xmlParseFile(doc_name);
802 cur = xmlDocGetRootElement(doc);
810 if (xmlStrcmp(cur->name, (const xmlChar *)"fontconfig")) {
816 cur = cur->xmlChildrenNode;
818 bool is_changed = false;
819 while (cur != NULL) {
820 if ((!xmlStrcmp(cur->name, (const xmlChar *)"match"))) {
821 cur2 = cur->xmlChildrenNode;
822 while (cur2 != NULL) {
823 if ((!xmlStrcmp(cur2->name, (const xmlChar *)"edit"))) {
824 xmlChar *name = xmlGetProp(cur2, (const xmlChar *)"name");
825 /* if name is not 'family', break */
826 if (xmlStrcmp(name, (const xmlChar *)"family")) {
834 cur3 = cur2->xmlChildrenNode;
835 while (cur3 != NULL) {
836 if ((!xmlStrcmp(cur3->name, (const xmlChar *)"string"))) {
837 xmlNodeSetContent(cur3->xmlChildrenNode, (const xmlChar *)font_name);
838 key = xmlNodeListGetString(doc, cur3->xmlChildrenNode, 1);
848 } else if ((!xmlStrcmp(cur->name, (const xmlChar *)"alias"))) {
849 cur2 = cur->xmlChildrenNode;
850 while (cur2 != NULL) {
851 if ((!xmlStrcmp(cur2->name, (const xmlChar *)"family"))) {
852 xmlNodeSetContent(cur2->xmlChildrenNode, (const xmlChar *)font_name);
853 key = xmlNodeListGetString(doc, cur2->xmlChildrenNode, 1);
857 } else if ((!xmlStrcmp(cur2->name, (const xmlChar *)"prefer"))) {
858 cur3 = cur2->xmlChildrenNode;
859 while (cur3 != NULL) {
860 if ((!xmlStrcmp(cur3->name, (const xmlChar *)"family"))) {
861 xmlNodeSetContent(cur3->xmlChildrenNode, (const xmlChar *)font_name);
862 key = xmlNodeListGetString(doc, cur3->xmlChildrenNode, 1);
888 /* LCOV_EXCL_START */
889 int system_setting_set_font_type(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
892 char *font_name = NULL;
893 font_name = (char *)value;
895 /* get current font list */
896 int is_found = dl_is_available_font(font_name);
899 SETTING_TRACE("found font : %s ", font_name);
901 SETTING_TRACE(" NOT found font : %s ", font_name);
902 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
905 bool bsave = dl_font_config_set(font_name);
908 SETTING_TRACE(" font type save error by font_config_set() ");
909 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
911 SETTING_TRACE(" save OK - font_config_set() ");
914 xmlDocPtr doc = (xmlDocPtr)font_conf_doc_parse(SETTING_FONT_CONF_FILE, font_name);
916 xmlSaveFormatFile(SETTING_FONT_CONF_FILE, doc, 0);
921 dl_font_config_set_notification();
924 vconf_value = (char *)value;
926 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, vconf_value)) {
927 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
929 return SYSTEM_SETTINGS_ERROR_NONE;
933 /* LCOV_EXCL_START */
934 int system_setting_set_motion_activation(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
938 vconf_value = (bool *)value;
939 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_MOTION_ACTIVATION, *vconf_value)) {
940 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
942 return SYSTEM_SETTINGS_ERROR_NONE;
946 /* LCOV_EXCL_START */
947 int system_setting_set_usb_debugging_option(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
951 vconf_value = (bool *)value;
952 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_USB_DEBUG_MODE_BOOL, *vconf_value)) {
953 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
955 return SYSTEM_SETTINGS_ERROR_NONE;
960 /* LCOV_EXCL_START */
961 int system_setting_set_3g_data_network(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
965 vconf_value = (bool *)value;
966 if (system_setting_vconf_set_value_bool(VCONFKEY_3G_ENABLE, *vconf_value)) {
967 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
970 return SYSTEM_SETTINGS_ERROR_NONE;
974 /* LCOV_EXCL_START */
975 static int category_func(const char *name, void *user_data)
978 static char *category = "lock-screen";
979 if (name && !strcmp(name, category)) {
980 SETTING_TRACE(" SAME ");
983 SETTING_TRACE(" DIFFERENT -- %s, category -- %s ", name, category);
993 * set 'swipe type' if current lockscreen app is 'com.samsung.lockscreen'
997 /* LCOV_EXCL_START */
998 int system_setting_set_lockscreen_app(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1000 SETTING_TRACE_BEGIN;
1002 vconf_value = (char *)value; /* ex) com.samsung.lockscreen */
1005 pkgmgrinfo_appinfo_h handle;
1006 r = pkgmgrinfo_appinfo_get_appinfo(vconf_value, &handle);
1007 if (r != PMINFO_R_OK) {
1008 SETTING_TRACE("*** pkginfo failed ");
1009 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
1011 SETTING_TRACE("%x", handle);
1014 int ret = pkgmgrinfo_appinfo_foreach_category(handle, category_func, (void *)"lock-screen");
1015 if (ret != PMINFO_R_OK) {
1016 pkgmgrinfo_appinfo_destroy_appinfo(handle);
1017 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
1020 pkgmgrinfo_appinfo_destroy_appinfo(handle);
1021 /*----------------------------------------------------------------------------------- */
1023 if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_SCREEN_LOCK_TYPE_INT, &locktype)) {
1024 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1027 if (locktype == SETTING_SCREEN_LOCK_TYPE_PASSWORD)
1028 return SYSTEM_SETTINGS_ERROR_LOCKSCREEN_APP_PASSWORD_MODE;
1030 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_3RD_LOCK_PKG_NAME_STR, vconf_value)) {
1031 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1034 if (vconf_value && strcmp(vconf_value, "com.samsung.lockscreen") == 0) {
1035 if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_SCREEN_LOCK_TYPE_INT, SETTING_SCREEN_LOCK_TYPE_SWIPE)) {
1036 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1039 return SYSTEM_SETTINGS_ERROR_NONE;
1041 /* LCOV_EXCL_STOP */
1043 /*/////////////////////////////////////////////////////////////////////////////////////////////// */
1046 int system_setting_set_changed_callback_incoming_call_ringtone(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1048 SETTING_TRACE_BEGIN;
1049 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR, SYSTEM_SETTINGS_KEY_INCOMING_CALL_RINGTONE, 0, user_data);
1052 int system_setting_unset_changed_callback_incoming_call_ringtone(system_settings_key_e key)
1054 SETTING_TRACE_BEGIN;
1055 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR, 0);
1058 int system_setting_set_changed_callback_email_alert_ringtone(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1060 SETTING_TRACE_BEGIN;
1061 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, SYSTEM_SETTINGS_KEY_EMAIL_ALERT_RINGTONE, 0, user_data);
1064 int system_setting_unset_changed_callback_email_alert_ringtone(system_settings_key_e key)
1066 SETTING_TRACE_BEGIN;
1067 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, 0);
1070 int system_setting_set_changed_callback_wallpaper_home_screen(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1072 SETTING_TRACE_BEGIN;
1073 return system_setting_vconf_set_changed_cb(VCONFKEY_BGSET, SYSTEM_SETTINGS_KEY_WALLPAPER_HOME_SCREEN, 0, user_data);
1076 int system_setting_unset_changed_callback_wallpaper_home_screen(system_settings_key_e key)
1078 SETTING_TRACE_BEGIN;
1079 return system_setting_vconf_unset_changed_cb(VCONFKEY_BGSET, 0);
1082 int system_setting_set_changed_callback_wallpaper_lock_screen(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1084 SETTING_TRACE_BEGIN;
1085 return system_setting_vconf_set_changed_cb(VCONFKEY_IDLE_LOCK_BGSET, SYSTEM_SETTINGS_KEY_WALLPAPER_LOCK_SCREEN, 0, user_data);
1088 int system_setting_unset_changed_callback_wallpaper_lock_screen(system_settings_key_e key)
1090 SETTING_TRACE_BEGIN;
1091 return system_setting_vconf_unset_changed_cb(VCONFKEY_IDLE_LOCK_BGSET, 0);
1094 int system_setting_set_changed_callback_font_size(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1096 SETTING_TRACE_BEGIN;
1097 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, SYSTEM_SETTINGS_KEY_FONT_SIZE, 1, user_data);
1100 int system_setting_unset_changed_callback_font_size(system_settings_key_e key)
1102 SETTING_TRACE_BEGIN;
1103 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, 1);
1106 int system_setting_set_changed_callback_usb_debugging_option(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1108 SETTING_TRACE_BEGIN;
1109 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_USB_DEBUG_MODE_BOOL, SYSTEM_SETTINGS_KEY_USB_DEBUGGING_ENABLED, 1, user_data);
1112 int system_setting_unset_changed_callback_usb_debugging_option(system_settings_key_e key)
1114 SETTING_TRACE_BEGIN;
1115 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_USB_DEBUG_MODE_BOOL, 1);
1118 int system_setting_set_changed_callback_3g_data_network(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1120 SETTING_TRACE_BEGIN;
1121 return system_setting_vconf_set_changed_cb(VCONFKEY_3G_ENABLE, SYSTEM_SETTINGS_KEY_3G_DATA_NETWORK_ENABLED, 1, user_data);
1124 int system_setting_unset_changed_callback_3g_data_network(system_settings_key_e key)
1126 SETTING_TRACE_BEGIN;
1127 return system_setting_vconf_unset_changed_cb(VCONFKEY_3G_ENABLE, 1);
1130 int system_setting_set_changed_callback_lockscreen_app(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1132 SETTING_TRACE_BEGIN;
1133 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_3RD_LOCK_PKG_NAME_STR, SYSTEM_SETTINGS_KEY_LOCKSCREEN_APP, 1, user_data);
1136 int system_setting_unset_changed_callback_lockscreen_app(system_settings_key_e key)
1138 SETTING_TRACE_BEGIN;
1139 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_3RD_LOCK_PKG_NAME_STR, 1);
1144 * @todo need to add custom event notification method
1146 int system_setting_set_changed_callback_font_type(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1148 SETTING_TRACE_BEGIN;
1149 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, SYSTEM_SETTINGS_KEY_FONT_TYPE, 2, user_data);
1152 int system_setting_unset_changed_callback_font_type(system_settings_key_e key)
1154 SETTING_TRACE_BEGIN;
1155 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, 2);
1158 /* TODO : 2th argument, callback, is not in use. */
1159 int system_setting_set_changed_callback_motion_activation(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1161 SETTING_TRACE_BEGIN;
1162 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_MOTION_ACTIVATION, SYSTEM_SETTINGS_KEY_MOTION_ACTIVATION, 3, user_data);
1165 int system_setting_unset_changed_callback_motion_activation(system_settings_key_e key)
1167 SETTING_TRACE_BEGIN;
1168 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_MOTION_ACTIVATION, 3);
1171 /*//////////////////////////////////////////////////////////////////////////////////////// */
1172 /*--------------------------------------- */
1173 int system_setting_get_locale_country(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1175 SETTING_TRACE_BEGIN;
1176 char *vconf_value = NULL;
1177 if (system_setting_vconf_get_value_string(VCONFKEY_REGIONFORMAT, &vconf_value)) {
1178 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1181 /* parsing validation */
1184 snprintf(arr, 20, "%s", vconf_value);
1186 *value = strdup(arr);
1190 return SYSTEM_SETTINGS_ERROR_NONE;
1193 /* LCOV_EXCL_START */
1194 int system_setting_set_locale_country(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1196 SETTING_TRACE_BEGIN;
1197 char *vconf_value = NULL;
1198 vconf_value = (char *)value;
1200 char *ext = "UTF-8";
1203 snprintf(arr, 20, "%s.%s", vconf_value, ext);
1205 if (system_setting_vconf_set_value_string(VCONFKEY_REGIONFORMAT, arr)) {
1206 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1208 return SYSTEM_SETTINGS_ERROR_NONE;
1210 /* LCOV_EXCL_STOP */
1212 int system_setting_set_changed_callback_locale_country(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1214 SETTING_TRACE_BEGIN;
1215 return system_setting_vconf_set_changed_cb(VCONFKEY_REGIONFORMAT, SYSTEM_SETTINGS_KEY_LOCALE_COUNTRY, 3, user_data);
1218 int system_setting_unset_changed_callback_locale_country(system_settings_key_e key)
1220 SETTING_TRACE_BEGIN;
1221 return system_setting_vconf_unset_changed_cb(VCONFKEY_REGIONFORMAT, 3);
1225 /*--------------------------------------- */
1226 int system_setting_get_locale_language(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1228 SETTING_TRACE_BEGIN;
1229 char *vconf_value = NULL;
1230 if (system_setting_vconf_get_value_string(VCONFKEY_LANGSET, &vconf_value)) {
1231 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1234 /* parsing validation */
1237 snprintf(arr, 20, "%s", vconf_value);
1239 *value = strdup(arr);
1242 return SYSTEM_SETTINGS_ERROR_NONE;
1245 /* LCOV_EXCL_START */
1246 int system_setting_set_locale_language(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1248 SETTING_TRACE_BEGIN;
1249 char *vconf_value = NULL;
1250 vconf_value = (char *)value;
1252 char *ext = "UTF-8";
1255 snprintf(arr, 20, "%s.%s", vconf_value, ext);
1257 if (system_setting_vconf_set_value_string(VCONFKEY_LANGSET, arr)) {
1258 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1260 return SYSTEM_SETTINGS_ERROR_NONE;
1262 /* LCOV_EXCL_STOP */
1264 int system_setting_set_changed_callback_locale_language(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1266 SETTING_TRACE_BEGIN;
1267 /*return system_setting_vconf_set_changed_cb(VCONFKEY_LANGSET, SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, 3, user_data ); */
1268 return system_setting_vconf_set_changed_cb(VCONFKEY_LANGSET, SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, 100, user_data);
1271 int system_setting_unset_changed_callback_locale_language(system_settings_key_e key)
1273 SETTING_TRACE_BEGIN;
1274 return system_setting_vconf_unset_changed_cb(VCONFKEY_LANGSET, 100);
1277 /*--------------------------------------- */
1278 /* LCOV_EXCL_START */
1279 int system_setting_get_locale_timeformat_24hour(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1281 SETTING_TRACE_BEGIN;
1284 if (system_setting_vconf_get_value_int(VCONFKEY_REGIONFORMAT_TIME1224, &vconf_value)) {
1285 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1288 bool ret_value = true;
1289 if (vconf_value == VCONFKEY_TIME_FORMAT_12)
1291 else if (vconf_value == VCONFKEY_TIME_FORMAT_24)
1294 *value = (void *)ret_value;
1296 return SYSTEM_SETTINGS_ERROR_NONE;
1298 /* LCOV_EXCL_STOP */
1300 int system_setting_set_locale_timeformat_24hour(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1302 SETTING_TRACE_BEGIN;
1305 vconf_value = (bool *)value;
1308 if (system_setting_vconf_set_value_int(VCONFKEY_REGIONFORMAT_TIME1224, VCONFKEY_TIME_FORMAT_24)) {
1309 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1313 if (system_setting_vconf_set_value_int(VCONFKEY_REGIONFORMAT_TIME1224, VCONFKEY_TIME_FORMAT_12)) {
1314 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1319 return SYSTEM_SETTINGS_ERROR_NONE;
1322 int system_setting_set_changed_callback_locale_timeformat_24hour(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1324 SETTING_TRACE_BEGIN;
1325 return system_setting_vconf_set_changed_cb(VCONFKEY_REGIONFORMAT_TIME1224, SYSTEM_SETTINGS_KEY_LOCALE_TIMEFORMAT_24HOUR, 3, user_data);
1328 int system_setting_unset_changed_callback_locale_timeformat_24hour(system_settings_key_e key)
1330 SETTING_TRACE_BEGIN;
1331 return system_setting_vconf_unset_changed_cb(VCONFKEY_REGIONFORMAT_TIME1224, 3);
1334 int system_setting_get_locale_timezone(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1337 ssize_t len = readlink(SETTING_TZONE_SYMLINK_PATH, tzpath, sizeof(tzpath)-1);
1341 SETTING_TRACE("parse error for SETTING_TZONE_SYMLINK_PATH");
1342 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1345 SETTING_TRACE("tzpath : %s ", &tzpath[20]);
1346 *value = strdup(&tzpath[20]);
1347 return SYSTEM_SETTINGS_ERROR_NONE;
1350 /* LCOV_EXCL_START */
1351 int system_setting_set_locale_timezone(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1353 SETTING_TRACE_BEGIN;
1354 char *timezone_value = NULL;
1355 timezone_value = (char *)value;
1358 snprintf(tz_path, 1024, "/usr/share/zoneinfo/%s", timezone_value);
1360 int is_load = _is_file_accessible(tz_path);
1362 alarmmgr_set_timezone(tz_path);
1364 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_TIMEZONE_ID, timezone_value)) {
1365 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1367 return SYSTEM_SETTINGS_ERROR_NONE;
1369 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
1371 /* LCOV_EXCL_STOP */
1375 /* LCOV_EXCL_START */
1376 int system_setting_set_changed_callback_locale_timezone(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1378 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_TIMEZONE_ID, SYSTEM_SETTINGS_KEY_LOCALE_TIMEZONE, 4, user_data);
1380 /* LCOV_EXCL_STOP */
1382 /* LCOV_EXCL_START */
1383 int system_setting_unset_changed_callback_locale_timezone(system_settings_key_e key)
1385 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_TIMEZONE_ID, 4);
1387 /* LCOV_EXCL_STOP */
1389 /* LCOV_EXCL_START */
1390 int system_setting_set_changed_callback_locale_timezone_changed(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1392 SETTING_TRACE_BEGIN;
1393 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
1395 /* LCOV_EXCL_STOP */
1397 /* LCOV_EXCL_START */
1398 int system_setting_unset_changed_callback_locale_timezone_changed(system_settings_key_e key)
1400 SETTING_TRACE_BEGIN;
1401 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
1403 /* LCOV_EXCL_STOP */
1406 /* LCOV_EXCL_START */
1407 int system_setting_get_time_changed(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1409 SETTING_TRACE_BEGIN;
1411 cur_tick = time(NULL);
1412 *value = (void *)cur_tick;
1413 /* struct tm * localtime = time (cur_tick); */
1414 /* printf("%s\n", ctime(&cur_tick); */
1415 return SYSTEM_SETTINGS_ERROR_NONE;
1418 /* LCOV_EXCL_STOP */
1420 int system_setting_set_changed_callback_time_changed(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1422 SETTING_TRACE_BEGIN;
1423 return system_setting_vconf_set_changed_cb(VCONFKEY_SYSTEM_TIME_CHANGED, SYSTEM_SETTINGS_KEY_TIME_CHANGED, 3, user_data);
1426 int system_setting_unset_changed_callback_time_changed(system_settings_key_e key)
1428 SETTING_TRACE_BEGIN;
1429 return system_setting_vconf_unset_changed_cb(VCONFKEY_SYSTEM_TIME_CHANGED, 3);
1434 /* SYSTEM_SETTINGS_KEY_SOUND_LOCK */
1435 int system_setting_get_sound_lock(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1437 SETTING_TRACE_BEGIN;
1440 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_SOUND_LOCK_BOOL, &vconf_value)) {
1441 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1443 *value = (void *)vconf_value;
1445 return SYSTEM_SETTINGS_ERROR_NONE;
1448 int system_setting_set_changed_callback_sound_lock(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1450 SETTING_TRACE_BEGIN;
1451 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_SOUND_LOCK_BOOL, SYSTEM_SETTINGS_KEY_SOUND_LOCK, 3, user_data);
1454 int system_setting_unset_changed_callback_sound_lock(system_settings_key_e key)
1456 SETTING_TRACE_BEGIN;
1457 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_SOUND_LOCK_BOOL, 3);
1461 * a = VCONFKEY_SETAPPL_SOUND_STATUS_BOOL b = VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL
1463 * a == false, b == false --> silent mode
1464 * a == true, b == false --> sound mode
1465 * a == false, b == true --> vibration mode
1467 /* LCOV_EXCL_START */
1468 int system_setting_get_sound_silent_mode(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1470 SETTING_TRACE_BEGIN;
1475 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, &sound_cond)) {
1476 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1479 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, &vib_cond)) {
1480 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1483 if (sound_cond == false && vib_cond == false) {
1485 *value = (void *)vconf_value;
1487 vconf_value = false;
1488 *value = (void *)vconf_value;
1490 return SYSTEM_SETTINGS_ERROR_NONE;
1492 /* LCOV_EXCL_STOP */
1495 * a = VCONFKEY_SETAPPL_SOUND_STATUS_BOOL b = VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL
1497 * a == false, b == false --> silent mode
1498 * a == true, b == false --> sound mode
1500 int system_setting_set_sound_silent_mode(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1502 SETTING_TRACE_BEGIN;
1505 vconf_value = (bool *)value;
1507 bool vconf_sound = false;
1508 bool vconf_vib = false;
1511 vconf_sound = false;
1518 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, vconf_sound)) {
1519 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1521 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, vconf_vib)) {
1522 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1525 return SYSTEM_SETTINGS_ERROR_NONE;
1531 int system_setting_set_changed_callback_sound_silent_mode(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1533 SETTING_TRACE_BEGIN;
1534 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, SYSTEM_SETTINGS_KEY_SOUND_SILENT_MODE, 3, user_data);
1538 int system_setting_unset_changed_callback_sound_silent_mode(system_settings_key_e key)
1540 SETTING_TRACE_BEGIN;
1541 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, 3);
1544 /* SYSTEM_SETTINGS_KEY_SOUND_TOUCH */
1545 int system_setting_get_sound_touch(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1547 SETTING_TRACE_BEGIN;
1550 int ret = system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL, &vconf_value);
1551 if (ret != SYSTEM_SETTINGS_ERROR_NONE) {
1554 *value = (void *)vconf_value;
1558 int system_setting_set_changed_callback_sound_touch(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1560 SETTING_TRACE_BEGIN;
1561 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL, SYSTEM_SETTINGS_KEY_SOUND_TOUCH, 2, user_data);
1564 int system_setting_unset_changed_callback_sound_touch(system_settings_key_e key)
1566 SETTING_TRACE_BEGIN;
1567 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL, 2);
1571 /* SYSTEM_SETTINGS_KEY_SOUND_LOCK */
1572 int system_setting_get_sound_lock(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1576 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_SOUND_LOCK_BOOL, &vconf_value)) {
1577 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1579 *value = (void *)vconf_value;
1581 return SYSTEM_SETTINGS_ERROR_NONE;
1585 int system_setting_get_auto_rotation_mode(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1587 SETTING_TRACE_BEGIN;
1590 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, &vconf_value)) {
1591 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1593 *value = (void *)vconf_value;
1595 return SYSTEM_SETTINGS_ERROR_NONE;
1598 /* LCOV_EXCL_START */
1599 int system_setting_set_auto_rotation_mode(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1601 SETTING_TRACE_BEGIN;
1603 vconf_value = (bool *)value;
1604 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, *vconf_value)) {
1605 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1608 return SYSTEM_SETTINGS_ERROR_NONE;
1610 /* LCOV_EXCL_STOP */
1612 int system_setting_set_changed_callback_auto_rotation_mode(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1614 SETTING_TRACE_BEGIN;
1615 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, SYSTEM_SETTINGS_KEY_DISPLAY_SCREEN_ROTATION_AUTO, 2, user_data);
1618 int system_setting_unset_changed_callback_auto_rotation_mode(system_settings_key_e key)
1620 SETTING_TRACE_BEGIN;
1621 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, 2);
1624 int system_setting_get_screen_backlight_time(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1626 SETTING_TRACE_BEGIN;
1629 if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, &vconf_value)) {
1630 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1632 *value = (void *)vconf_value;
1634 return SYSTEM_SETTINGS_ERROR_NONE;
1638 /* LCOV_EXCL_START */
1639 int system_setting_set_screen_backlight_time(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1641 SETTING_TRACE_BEGIN;
1643 vconf_value = (int *)value;
1645 if (!(*vconf_value > 0 && *vconf_value < 600)) {
1646 SETTING_TRACE(" ERR Betweeny here 0 ~ 600");
1647 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
1650 if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, *vconf_value)) {
1651 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1654 return SYSTEM_SETTINGS_ERROR_NONE;
1656 /* LCOV_EXCL_STOP */
1658 int system_setting_set_changed_callback_screen_backlight_time(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1660 SETTING_TRACE_BEGIN;
1661 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, SYSTEM_SETTINGS_KEY_DISPLAY_SCREEN_ROTATION_AUTO, 2, user_data);
1664 int system_setting_unset_changed_callback_screen_backlight_time(system_settings_key_e key)
1666 SETTING_TRACE_BEGIN;
1667 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, 2);
1670 int system_setting_get_sound_notification(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1672 SETTING_TRACE_BEGIN;
1673 char *vconf_value = NULL;
1674 if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, &vconf_value)) {
1675 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1678 *value = vconf_value;
1679 return SYSTEM_SETTINGS_ERROR_NONE;
1682 /* LCOV_EXCL_START */
1683 int system_setting_set_sound_notification(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1685 SETTING_TRACE_BEGIN;
1686 char *vconf_value = NULL;
1687 vconf_value = (char *)value;
1689 int is_load = _is_file_accessible(vconf_value);
1691 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, vconf_value)) {
1692 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1695 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1698 return SYSTEM_SETTINGS_ERROR_NONE;
1700 /* LCOV_EXCL_STOP */
1702 int system_setting_set_changed_callback_sound_notification(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1704 SETTING_TRACE_BEGIN;
1705 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, SYSTEM_SETTINGS_KEY_INCOMING_CALL_RINGTONE, 0, user_data);
1708 int system_setting_unset_changed_callback_sound_notification(system_settings_key_e key)
1710 SETTING_TRACE_BEGIN;
1711 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, 0);
1714 int system_setting_get_notification_repetition_period(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1716 SETTING_TRACE_BEGIN;
1719 if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_NOTI_MSG_ALERT_REP_TYPE_INT, &vconf_value)) {
1720 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1722 *value = (void *)vconf_value;
1724 return SYSTEM_SETTINGS_ERROR_NONE;
1727 /* LCOV_EXCL_START */
1728 int system_setting_set_notification_repetition_period(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1730 SETTING_TRACE_BEGIN;
1732 vconf_value = (int *)value;
1734 if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_NOTI_MSG_ALERT_REP_TYPE_INT, *vconf_value)) {
1735 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1738 return SYSTEM_SETTINGS_ERROR_NONE;
1740 /* LCOV_EXCL_STOP */
1742 int system_setting_set_changed_callback_notification_repetition_period(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1744 SETTING_TRACE_BEGIN;
1745 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);
1748 int system_setting_unset_changed_callback_notification_repetition_period(system_settings_key_e key)
1750 SETTING_TRACE_BEGIN;
1751 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_ALERT_REP_TYPE_INT, 1);
1754 int system_setting_get_device_name(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1756 SETTING_TRACE_BEGIN;
1757 char *vconf_value = NULL;
1758 if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_DEVICE_NAME_STR, &vconf_value)) {
1759 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1762 *value = vconf_value;
1763 return SYSTEM_SETTINGS_ERROR_NONE;
1766 /* LCOV_EXCL_START */
1767 int system_setting_set_device_name(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1769 SETTING_TRACE_BEGIN;
1770 char *vconf_value = NULL;
1771 vconf_value = (char *)value;
1773 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_DEVICE_NAME_STR, vconf_value)) {
1774 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1777 return SYSTEM_SETTINGS_ERROR_NONE;
1779 /* LCOV_EXCL_STOP */
1781 int system_setting_set_changed_callback_device_name(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1783 SETTING_TRACE_BEGIN;
1784 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_DEVICE_NAME_STR, SYSTEM_SETTINGS_KEY_DEVICE_NAME, 0, user_data);
1787 int system_setting_unset_changed_callback_device_name(system_settings_key_e key)
1789 SETTING_TRACE_BEGIN;
1790 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_DEVICE_NAME_STR, 0);
1793 /*---------------------------------------------- */
1794 int system_setting_get_network_flight_mode(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1796 SETTING_TRACE_BEGIN;
1798 if (system_setting_vconf_get_value_bool(VCONFKEY_TELEPHONY_FLIGHT_MODE, &vconf_value)) {
1799 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1801 *value = (void *)vconf_value;
1803 return SYSTEM_SETTINGS_ERROR_NONE;
1806 int system_setting_set_changed_callback_network_flight_mode(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1808 SETTING_TRACE_BEGIN;
1809 return system_setting_vconf_set_changed_cb(VCONFKEY_TELEPHONY_FLIGHT_MODE, SYSTEM_SETTINGS_KEY_NETWORK_FLIGHT_MODE, 3, user_data);
1812 int system_setting_unset_changed_callback_network_flight_mode(system_settings_key_e key)
1814 SETTING_TRACE_BEGIN;
1815 return system_setting_vconf_unset_changed_cb(VCONFKEY_TELEPHONY_FLIGHT_MODE, 3);
1818 int system_setting_get_network_wifi_notification(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1820 SETTING_TRACE_BEGIN;
1822 if (system_setting_vconf_get_value_int(VCONFKEY_WIFI_ENABLE_QS, &vconf_value)) {
1823 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1826 bret = (vconf_value == VCONFKEY_WIFI_QS_ENABLE) ? true : false;
1828 *value = (void *)bret;
1829 return SYSTEM_SETTINGS_ERROR_NONE;
1832 int system_setting_set_changed_callback_network_wifi_notification(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1834 SETTING_TRACE_BEGIN;
1835 return system_setting_vconf_set_changed_cb(VCONFKEY_WIFI_ENABLE_QS, SYSTEM_SETTINGS_KEY_NETWORK_WIFI_NOTIFICATION, 4, user_data);
1838 int system_setting_unset_changed_callback_network_wifi_notification(system_settings_key_e key)
1840 SETTING_TRACE_BEGIN;
1841 return system_setting_vconf_unset_changed_cb(VCONFKEY_WIFI_ENABLE_QS, 4);
1844 /* LCOV_EXCL_START */
1845 int system_setting_get_lock_state(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1849 if (system_setting_vconf_get_value_int(VCONFKEY_IDLE_LOCK_STATE_READ_ONLY, &vconf_value)) {
1850 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1852 *value = (void *)vconf_value;
1854 return SYSTEM_SETTINGS_ERROR_NONE;
1856 /* LCOV_EXCL_STOP */
1858 /* LCOV_EXCL_START */
1859 int system_setting_set_lock_state(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1861 SETTING_TRACE_BEGIN;
1863 vconf_value = (int *)value;
1865 if (system_setting_vconf_set_value_int(VCONFKEY_IDLE_LOCK_STATE_READ_ONLY, *vconf_value)) {
1866 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1869 return SYSTEM_SETTINGS_ERROR_NONE;
1871 /* LCOV_EXCL_STOP */
1873 /* LCOV_EXCL_START */
1874 int system_setting_set_changed_callback_lock_state(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1876 return system_setting_vconf_set_changed_cb(VCONFKEY_IDLE_LOCK_STATE_READ_ONLY, SYSTEM_SETTINGS_KEY_LOCK_STATE, 4, user_data);
1878 /* LCOV_EXCL_STOP */
1880 /* LCOV_EXCL_START */
1881 int system_setting_unset_changed_callback_lock_state(system_settings_key_e key)
1883 return system_setting_vconf_unset_changed_cb(VCONFKEY_IDLE_LOCK_STATE_READ_ONLY, 4);
1885 /* LCOV_EXCL_STOP */
1887 //----------------------------------------------------------------------------------------------------------------------------
1889 #define DEFAULT_ADS_ID "00000000-0000-0000-0000-000000000000"
1891 int system_setting_get_ads_id(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1893 SETTING_TRACE_BEGIN;
1894 int optout_value = 0;
1895 if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_AD_ID_OPT_OUT, &optout_value)) {
1896 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1899 if (optout_value == 1) {
1900 *value = strdup(DEFAULT_ADS_ID);
1901 return SYSTEM_SETTINGS_ERROR_NONE;
1904 char *vconf_value = NULL;
1905 if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_AD_ID, &vconf_value)) {
1906 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1909 *value = vconf_value;
1910 return SYSTEM_SETTINGS_ERROR_NONE;
1915 void make_ad_id(void)
1918 char uuid_unparsed[50] = {0};
1919 uuid_generate(uuid_value);
1920 uuid_unparse(uuid_value, uuid_unparsed);
1921 system_setting_set_ad_id(key, uuid_unparsed); //example of setting the value
1924 /* LCOV_EXCL_START */
1925 int system_setting_set_ads_id(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1927 SETTING_TRACE_BEGIN;
1928 char *vconf_value = NULL;
1929 vconf_value = (char *)value;
1931 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_AD_ID, vconf_value)) {
1932 SETTING_TRACE("Setting VCONFKEY_SETAPPL_AD_ID failed");
1933 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1936 return SYSTEM_SETTINGS_ERROR_NONE;
1938 /* LCOV_EXCL_STOP */
1940 int system_setting_set_changed_callback_ads_id(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1942 SETTING_TRACE_BEGIN;
1943 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_AD_ID, SYSTEM_SETTINGS_KEY_ADS_ID, 0, user_data);
1946 int system_setting_unset_changed_callback_ads_id(system_settings_key_e key)
1948 SETTING_TRACE_BEGIN;
1949 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_AD_ID, 0);