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"
61 int _is_file_accessible(const char *path);
63 static bool dl_is_supported_image_type_load(char *path);
64 static bool dl_font_config_set(char *font_name);
65 static char *dl_get_font_info(char *str);
66 static int dl_is_available_font(char *str);
67 static void dl_font_size_set();
68 static void dl_font_config_set_notification();
72 * VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR has a path of the ringtone file which user choose
73 * @return the ringtone file path specified by user in normal case
74 * if it's not accessable, return the default ringtone path
76 int system_setting_get_incoming_call_ringtone(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
80 if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR, &vconf_value)) {
81 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
84 /* check to see if it's accessable -> OK */
85 /* no --> default ringtone path VCONFKEY_SETAPPL_CALL_RINGTONE_DEFAULT_PATH_STR */
86 int is_load = _is_file_accessible(vconf_value);
89 } else { /* not zero on errro */
90 *value = vconf_get_str(VCONFKEY_SETAPPL_CALL_RINGTONE_DEFAULT_PATH_STR);
93 /**value = vconf_value; */
94 return SYSTEM_SETTINGS_ERROR_NONE;
98 int system_setting_get_email_alert_ringtone(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
102 if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, &vconf_value)) {
103 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
106 /* check to see if it's accessable -> OK */
107 /* no --> default ringtone path VCONFKEY_SETAPPL_NOTI_RINGTONE_DEFAULT_PATH_STR */
108 int is_load = _is_file_accessible(vconf_value);
110 *value = vconf_value;
111 } else { /* not zero on errro */
112 *value = vconf_get_str(VCONFKEY_SETAPPL_NOTI_RINGTONE_DEFAULT_PATH_STR);
115 return SYSTEM_SETTINGS_ERROR_NONE;
119 int system_setting_get_wallpaper_home_screen(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
123 if (system_setting_vconf_get_value_string(VCONFKEY_BGSET, &vconf_value)) {
124 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
126 *value = vconf_value;
127 return SYSTEM_SETTINGS_ERROR_NONE;
131 int system_setting_get_wallpaper_lock_screen(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
136 if (system_setting_vconf_get_value_string(VCONFKEY_IDLE_LOCK_BGSET, &vconf_value)) {
137 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
139 *value = vconf_value;
141 return SYSTEM_SETTINGS_ERROR_NONE;
145 /* [int] vconf GET */
146 int system_setting_get_font_size(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
151 if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, &vconf_value)) {
152 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
154 *value = (void *)vconf_value;
156 return SYSTEM_SETTINGS_ERROR_NONE;
160 int system_setting_get_default_font_type(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
163 char *font_name = dl_get_font_info("default");
165 *value = (void *)font_name;
166 return SYSTEM_SETTINGS_ERROR_NONE;
168 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
172 /* [int] vconf GET */
173 int system_setting_get_font_type(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
176 char *font_name = dl_get_font_info("cur");
177 *value = (void *)font_name;
179 return SYSTEM_SETTINGS_ERROR_NONE;
183 int system_setting_get_motion_activation(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
188 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_MOTION_ACTIVATION, &vconf_value)) {
189 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
191 *value = (void *)vconf_value;
193 return SYSTEM_SETTINGS_ERROR_NONE;
196 int system_setting_get_usb_debugging_option(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
201 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_USB_DEBUG_MODE_BOOL, &vconf_value)) {
202 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
204 *value = (void *)vconf_value;
206 return SYSTEM_SETTINGS_ERROR_NONE;
209 int system_setting_get_3g_data_network(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
214 if (system_setting_vconf_get_value_bool(VCONFKEY_3G_ENABLE, &vconf_value)) {
215 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
217 *value = (void *)vconf_value;
219 return SYSTEM_SETTINGS_ERROR_NONE;
221 /*////////////////////////////////////////////////////////////////////////////////////////////////// */
225 * get current lock scren app package name (string)
227 * @return SYSTEM_SETTINGS_ERROR_LOCKSCREEN_APP_PASSWORD_MODE raise exception if current lock type is 'password'
229 /* LCOV_EXCL_START */
230 int system_setting_get_lockscreen_app(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
233 char *pkg_name = NULL;
235 system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_SCREEN_LOCK_TYPE_INT, &locktype);
237 if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_3RD_LOCK_PKG_NAME_STR, &pkg_name)) {
238 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
241 if (pkg_name && strcmp(pkg_name, "com.samsung.lockscreen") == 0 && locktype == SETTING_SCREEN_LOCK_TYPE_PASSWORD) {
242 return SYSTEM_SETTINGS_ERROR_LOCKSCREEN_APP_PASSWORD_MODE;
246 return SYSTEM_SETTINGS_ERROR_NONE;
251 /*////////////////////////////////////////////////////////////////////////////////////////////////// */
253 int _is_file_accessible(const char *path)
256 int ret = access(path , R_OK);
258 SETTING_TRACE("found the file %s", path);
261 /* error code : 13 */
262 SETTING_TRACE("found the file %s --- error code : %d ", path, errno);
267 /* LCOV_EXCL_START */
268 int system_setting_set_incoming_call_ringtone(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
272 vconf_value = (char *)value;
274 int ret = _is_file_accessible(vconf_value);
276 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR, vconf_value)) {
277 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
280 /* @todo add a common ret_handler */
284 return SYSTEM_SETTINGS_ERROR_NONE;
289 /* LCOV_EXCL_START */
290 int system_setting_set_email_alert_ringtone(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
294 vconf_value = (char *)value;
296 int ret = _is_file_accessible(vconf_value);
298 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, vconf_value)) {
299 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
302 /*return SYSTEM_SETTINGS_ERROR_IO_ERROR;*/
303 /* @todo add a common ret_handler */
307 return SYSTEM_SETTINGS_ERROR_NONE;
311 /* LCOV_EXCL_START */
312 static bool dl_is_supported_image_type_load(char *path)
317 bool (*image_type_check)(char *path);
319 handle = dlopen("/usr/lib/libsystem-settings-util.so.0.1.0", RTLD_LAZY);
321 SETTING_TRACE("ERROR!! canNOT find libsystem-settings-util.so.0.1.0");
325 image_type_check = dlsym(handle, "__is_supported_image_type_load");
326 if ((error = dlerror()) != NULL) {
327 SETTING_TRACE("ERROR!! canNOT find __is_supported_image_type_load function at libsystem-settings-util.so.0.1.0");
332 ret = image_type_check(path);
339 /* LCOV_EXCL_START */
340 static int dl_is_available_font(char *str)
345 int (*check_available_font)(char *font_name);
347 handle = dlopen("/usr/lib/libsystem-settings-util.so.0.1.0", RTLD_LAZY);
349 SETTING_TRACE("ERROR!! canNOT find libsystem-settings-util.so.0.1.0");
353 check_available_font = dlsym(handle, "__is_available_font");
354 if ((error = dlerror()) != NULL) {
355 SETTING_TRACE("ERROR!! canNOT find __is_available_font function at libsystem-settings-util.so.0.1.0");
360 ret = check_available_font(str);
367 /* LCOV_EXCL_START */
368 static void dl_font_size_set()
372 void (*set_font_size)();
374 handle = dlopen("/usr/lib/libsystem-settings-util.so.0.1.0", RTLD_LAZY);
376 SETTING_TRACE("ERROR!! canNOT find libsystem-settings-util.so.0.1.0");
380 set_font_size = dlsym(handle, "__font_size_set");
381 if ((error = dlerror()) != NULL) {
382 SETTING_TRACE("ERROR!! canNOT find __font_size_set function at libsystem-settings-util.so.0.1.0");
394 /* LCOV_EXCL_START */
395 static void dl_font_config_set_notification()
399 void (*set_font_nodification)();
401 handle = dlopen("/usr/lib/libsystem-settings-util.so.0.1.0", RTLD_LAZY);
403 SETTING_TRACE("ERROR!! canNOT find libsystem-settings-util.so.0.1.0");
407 set_font_nodification = dlsym(handle, "font_config_set_notification");
408 if ((error = dlerror()) != NULL) {
409 SETTING_TRACE("ERROR!! canNOT find font_config_set_notification function at libsystem-settings-util.so.0.1.0");
414 set_font_nodification();
421 /* LCOV_EXCL_START */
422 static bool dl_font_config_set(char *font_name)
427 bool (*check_font_type)(char *font_name);
429 handle = dlopen("/usr/lib/libsystem-settings-util.so.0.1.0", RTLD_LAZY);
431 SETTING_TRACE("ERROR!! canNOT find libsystem-settings-util.so.0.1.0");
435 check_font_type = dlsym(handle, "font_config_set");
436 if ((error = dlerror()) != NULL) {
437 SETTING_TRACE("ERROR!! canNOT find font_config_set function at libsystem-settings-util.so.0.1.0");
442 ret = check_font_type(font_name);
449 /* LCOV_EXCL_START */
450 static char *dl_get_font_info(char *str)
455 char *(*get_font_info)();
457 handle = dlopen("/usr/lib/libsystem-settings-util.so.0.1.0", RTLD_LAZY);
459 SETTING_TRACE("ERROR!! canNOT find libsystem-settings-util.so.0.1.0");
463 if (strcmp(str, "cur") == 0)
464 get_font_info = dlsym(handle, "_get_cur_font");
466 get_font_info = dlsym(handle, "_get_default_font");
468 if ((error = dlerror()) != NULL) {
469 SETTING_TRACE("ERROR!! canNOT find %s function at libsystem-settings-util.so.0.1.0", str);
474 ret = get_font_info();
481 /* LCOV_EXCL_START */
482 #define PATH_EXT_CHECK_REG ".(jpe?g|jpg|png|gif)$"
483 bool __is_supported_image_type_by_ext(char *file_path)
487 regmatch_t str[2048 + 1];
489 if (!file_path) return false;
492 if ((ret = regcomp(&fsm, PATH_EXT_CHECK_REG, REG_ICASE | REG_EXTENDED))) {
493 SETTING_TRACE("regular expresstion fail");
498 if (regexec(&fsm, file_path, strlen(file_path) + 1, str, 0) == REG_NOMATCH) {
499 /*SETTING_TRACE("FAILED - %s", file_path[i]); */
502 /*SETTING_TRACE("MATCHED - %s", file_path[i]); */
508 #ifdef TIZEN_WEARABLE
509 /* LCOV_EXCL_START */
510 static int system_setting_get_extended_wallpaper_num(const char *file_path, unsigned int *num)
514 const char *find_str = "extended_wallpaper_";
517 if (!(ch = strstr(file_path, find_str))) {
518 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
520 strncpy(buffer, file_path, ch - file_path);
521 buffer[ch - file_path] = 0;
522 sprintf(buffer + (ch - file_path), "%s%s", "", ch + strlen(find_str));
524 if (!isdigit(buffer[0])) {
525 SETTING_TRACE("%s is not number", buffer);
526 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
531 return SYSTEM_SETTINGS_ERROR_NONE;
535 /* LCOV_EXCL_START */
536 static int system_setting_copy_extended_wallpaper(const char *dest_file_path, const char *source_file_path)
539 if (!source_file_path || !dest_file_path) {
540 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
546 fd = open(source_file_path, O_RDONLY);
548 SETTING_TRACE("file open failed: %s", source_file_path);
549 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
553 fd2 = open(dest_file_path, O_WRONLY | O_CREAT, S_IRWXU | S_IRWXG | S_IRWXO);
555 SETTING_TRACE("file creation failed: %s", dest_file_path);
557 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
560 while (read(fd, buf, sizeof(buf) - 1) > 0) {
561 write(fd2, buf, sizeof(buf) - 1);
567 if (chmod(dest_file_path, S_IRWXU | S_IRWXG | S_IRWXO) < 0) {
568 SETTING_TRACE("chmod failed: %s", dest_file_path);
571 return SYSTEM_SETTINGS_ERROR_NONE;
575 /* LCOV_EXCL_START */
576 static int system_setting_remove_oldest_extended_wallpaper()
581 char *min_image_name = NULL;
582 unsigned int min_image_num = 0;
583 unsigned int temp_image_num = 0;
586 if ((dp = opendir(_TZ_SYS_DATA"/setting/wallpaper")) == NULL) {
587 SETTING_TRACE("opendir error");
588 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
591 while ((dirp = readdir(dp))) {
592 if (!strcmp(dirp->d_name, ".") || !strcmp(dirp->d_name, ".."))
595 if (system_setting_get_extended_wallpaper_num(dirp->d_name, &temp_image_num)
596 != SYSTEM_SETTINGS_ERROR_NONE) {
597 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
600 if ((image_count == 0) || (min_image_num > temp_image_num)) {
601 min_image_num = temp_image_num;
602 min_image_name = dirp->d_name;
609 if (min_image_name) {
610 snprintf(buf, sizeof(buf) - 1, _TZ_SYS_DATA"/setting/wallpaper/%s", min_image_name);
611 if (remove(buf) < 0) { /* remove oldest image */
612 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
616 return SYSTEM_SETTINGS_ERROR_NONE;
620 /* LCOV_EXCL_START */
621 static int system_setting_check_extended_wallpaper(const char *file_path)
625 if (!file_path || !strlen(file_path))
627 snprintf(buffer, 512, "%s/.bgwallpaper", tzplatform_getenv(TZ_USER_CONTENT));
628 return (strstr(file_path, buffer) != NULL);
632 #define WALLPAPER_MAX_COUNT 10
634 /* LCOV_EXCL_START */
635 int system_setting_set_wallpaper_home_screen(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
639 vconf_value = (char *)value;
641 bool isok = dl_is_supported_image_type_load(vconf_value);
644 SETTING_TRACE("path : %s is not supported file format", vconf_value);
645 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
647 SETTING_TRACE("path : %s is SUPPORT file format", vconf_value);
650 /* error handling here */
651 if (_is_file_accessible(vconf_value) != 0)
652 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
654 if (system_setting_vconf_set_value_string(VCONFKEY_BGSET, vconf_value)) {
655 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
659 #ifdef TIZEN_WEARABLE
660 if (system_setting_check_extended_wallpaper(vconf_value)) { /* New extended wallpaper */
663 unsigned int max_image_num = 0;
664 unsigned int temp_image_num = 0;
667 if ((dp = opendir(_TZ_SYS_DATA"/setting/wallpaper")) == NULL) {
668 SETTING_TRACE("Setting - dir open error!");
669 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
672 /* Check a max number of wallpapers */
673 while ((dirp = readdir(dp))) {
674 if (!strcmp(dirp->d_name, ".") || !strcmp(dirp->d_name, ".."))
677 if (system_setting_get_extended_wallpaper_num(dirp->d_name, &temp_image_num)
678 != SYSTEM_SETTINGS_ERROR_NONE) {
681 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
684 if ((image_count == 0) || (max_image_num < temp_image_num)) {
685 max_image_num = temp_image_num;
693 /* Numbering rule: Gear is odd number */
694 max_image_num = (max_image_num % 2 == 0) ? max_image_num + 1
697 char file_name_buffer[512];
698 snprintf(file_name_buffer, sizeof(file_name_buffer) - 1,
699 _TZ_SYS_DATA"/setting/wallpaper/extended_wallpaper_%d.jpg", max_image_num);
701 /* Copy image to _TZ_SYS_DATA/setting/wallpaper/ */
702 if (system_setting_copy_extended_wallpaper(file_name_buffer, vconf_value)
703 != SYSTEM_SETTINGS_ERROR_NONE) {
704 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
707 /* remove oldest wallpaper */
708 if (image_count >= WALLPAPER_MAX_COUNT) {
709 if (system_setting_remove_oldest_extended_wallpaper()
710 != SYSTEM_SETTINGS_ERROR_NONE) {
711 remove(file_name_buffer);
712 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
716 if (system_setting_vconf_set_value_string(VCONFKEY_BGSET, file_name_buffer)) {
717 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
720 if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_WALLPAPER_CHANGED_NOTI_INT,
721 VCONFKEY_WALLPAPER_CHANGED_NOTI_GEAR)) {
722 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
725 if (system_setting_vconf_set_value_string(VCONFKEY_BGSET, vconf_value)) {
726 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
731 return SYSTEM_SETTINGS_ERROR_NONE;
735 /* LCOV_EXCL_START */
736 int system_setting_set_wallpaper_lock_screen(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
740 vconf_value = (char *)value;
742 bool isok = dl_is_supported_image_type_load(vconf_value);
745 SETTING_TRACE("path : %s is not supported file format", vconf_value);
746 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
748 SETTING_TRACE("path : %s is SUPPORT file format", vconf_value);
751 /* error handling here */
752 if (_is_file_accessible(vconf_value) != 0)
753 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
755 if (system_setting_vconf_set_value_string(VCONFKEY_IDLE_LOCK_BGSET, vconf_value)) {
756 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
759 return SYSTEM_SETTINGS_ERROR_NONE;
763 /* LCOV_EXCL_START */
764 int system_setting_set_font_size(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
768 vconf_value = (int *)value;
770 if (*vconf_value < 0 || *vconf_value > SYSTEM_SETTINGS_FONT_SIZE_GIANT) {
771 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
774 if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, *vconf_value)) {
775 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
779 return SYSTEM_SETTINGS_ERROR_NONE;
785 /* LCOV_EXCL_START */
786 void *font_conf_doc_parse(char *doc_name, char *font_name)
789 xmlDocPtr doc = NULL;
790 xmlNodePtr cur = NULL;
791 xmlNodePtr cur2 = NULL;
792 xmlNodePtr cur3 = NULL;
795 doc = xmlParseFile(doc_name);
797 cur = xmlDocGetRootElement(doc);
805 if (xmlStrcmp(cur->name, (const xmlChar *)"fontconfig")) {
811 cur = cur->xmlChildrenNode;
813 bool is_changed = false;
814 while (cur != NULL) {
815 if ((!xmlStrcmp(cur->name, (const xmlChar *)"match"))) {
816 cur2 = cur->xmlChildrenNode;
817 while (cur2 != NULL) {
818 if ((!xmlStrcmp(cur2->name, (const xmlChar *)"edit"))) {
819 xmlChar *name = xmlGetProp(cur2, (const xmlChar *)"name");
820 /* if name is not 'family', break */
821 if (xmlStrcmp(name, (const xmlChar *)"family")) {
829 cur3 = cur2->xmlChildrenNode;
830 while (cur3 != NULL) {
831 if ((!xmlStrcmp(cur3->name, (const xmlChar *)"string"))) {
832 xmlNodeSetContent(cur3->xmlChildrenNode, (const xmlChar *)font_name);
833 key = xmlNodeListGetString(doc, cur3->xmlChildrenNode, 1);
843 } else if ((!xmlStrcmp(cur->name, (const xmlChar *)"alias"))) {
844 cur2 = cur->xmlChildrenNode;
845 while (cur2 != NULL) {
846 if ((!xmlStrcmp(cur2->name, (const xmlChar *)"family"))) {
847 xmlNodeSetContent(cur2->xmlChildrenNode, (const xmlChar *)font_name);
848 key = xmlNodeListGetString(doc, cur2->xmlChildrenNode, 1);
852 } else if ((!xmlStrcmp(cur2->name, (const xmlChar *)"prefer"))) {
853 cur3 = cur2->xmlChildrenNode;
854 while (cur3 != NULL) {
855 if ((!xmlStrcmp(cur3->name, (const xmlChar *)"family"))) {
856 xmlNodeSetContent(cur3->xmlChildrenNode, (const xmlChar *)font_name);
857 key = xmlNodeListGetString(doc, cur3->xmlChildrenNode, 1);
883 /* LCOV_EXCL_START */
884 int system_setting_set_font_type(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
887 char *font_name = NULL;
888 font_name = (char *)value;
890 /* get current font list */
891 int is_found = dl_is_available_font(font_name);
894 SETTING_TRACE("found font : %s ", font_name);
896 SETTING_TRACE(" NOT found font : %s ", font_name);
897 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
900 bool bsave = dl_font_config_set(font_name);
903 SETTING_TRACE(" font type save error by font_config_set() ");
904 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
906 SETTING_TRACE(" save OK - font_config_set() ");
909 xmlDocPtr doc = (xmlDocPtr)font_conf_doc_parse(SETTING_FONT_CONF_FILE, font_name);
911 xmlSaveFormatFile(SETTING_FONT_CONF_FILE, doc, 0);
916 dl_font_config_set_notification();
919 vconf_value = (char *)value;
921 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, vconf_value)) {
922 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
924 return SYSTEM_SETTINGS_ERROR_NONE;
928 /* LCOV_EXCL_START */
929 int system_setting_set_motion_activation(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
933 vconf_value = (bool *)value;
934 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_MOTION_ACTIVATION, *vconf_value)) {
935 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
937 return SYSTEM_SETTINGS_ERROR_NONE;
941 /* LCOV_EXCL_START */
942 int system_setting_set_usb_debugging_option(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
946 vconf_value = (bool *)value;
947 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_USB_DEBUG_MODE_BOOL, *vconf_value)) {
948 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
950 return SYSTEM_SETTINGS_ERROR_NONE;
955 /* LCOV_EXCL_START */
956 int system_setting_set_3g_data_network(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
960 vconf_value = (bool *)value;
961 if (system_setting_vconf_set_value_bool(VCONFKEY_3G_ENABLE, *vconf_value)) {
962 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
965 return SYSTEM_SETTINGS_ERROR_NONE;
969 /* LCOV_EXCL_START */
970 static int category_func(const char *name, void *user_data)
973 static char *category = "lock-screen";
974 if (name && !strcmp(name, category)) {
975 SETTING_TRACE(" SAME ");
978 SETTING_TRACE(" DIFFERENT -- %s, category -- %s ", name, category);
988 * set 'swipe type' if current lockscreen app is 'com.samsung.lockscreen'
992 /* LCOV_EXCL_START */
993 int system_setting_set_lockscreen_app(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
997 vconf_value = (char *)value; /* ex) com.samsung.lockscreen */
1000 pkgmgrinfo_appinfo_h handle;
1001 r = pkgmgrinfo_appinfo_get_appinfo(vconf_value, &handle);
1002 if (r != PMINFO_R_OK) {
1003 SETTING_TRACE("*** pkginfo failed ");
1004 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
1006 SETTING_TRACE("%x", handle);
1009 int ret = pkgmgrinfo_appinfo_foreach_category(handle, category_func, (void *)"lock-screen");
1010 if (ret != PMINFO_R_OK) {
1011 pkgmgrinfo_appinfo_destroy_appinfo(handle);
1012 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
1015 pkgmgrinfo_appinfo_destroy_appinfo(handle);
1016 /*----------------------------------------------------------------------------------- */
1018 if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_SCREEN_LOCK_TYPE_INT, &locktype)) {
1019 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1022 if (locktype == SETTING_SCREEN_LOCK_TYPE_PASSWORD)
1023 return SYSTEM_SETTINGS_ERROR_LOCKSCREEN_APP_PASSWORD_MODE;
1025 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_3RD_LOCK_PKG_NAME_STR, vconf_value)) {
1026 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1029 if (vconf_value && strcmp(vconf_value, "com.samsung.lockscreen") == 0) {
1030 if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_SCREEN_LOCK_TYPE_INT, SETTING_SCREEN_LOCK_TYPE_SWIPE)) {
1031 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1034 return SYSTEM_SETTINGS_ERROR_NONE;
1036 /* LCOV_EXCL_STOP */
1038 /*/////////////////////////////////////////////////////////////////////////////////////////////// */
1041 int system_setting_set_changed_callback_incoming_call_ringtone(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1043 SETTING_TRACE_BEGIN;
1044 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR, SYSTEM_SETTINGS_KEY_INCOMING_CALL_RINGTONE, 0, user_data);
1047 int system_setting_unset_changed_callback_incoming_call_ringtone(system_settings_key_e key)
1049 SETTING_TRACE_BEGIN;
1050 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR, 0);
1053 int system_setting_set_changed_callback_email_alert_ringtone(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1055 SETTING_TRACE_BEGIN;
1056 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, SYSTEM_SETTINGS_KEY_EMAIL_ALERT_RINGTONE, 0, user_data);
1059 int system_setting_unset_changed_callback_email_alert_ringtone(system_settings_key_e key)
1061 SETTING_TRACE_BEGIN;
1062 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, 0);
1065 int system_setting_set_changed_callback_wallpaper_home_screen(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1067 SETTING_TRACE_BEGIN;
1068 return system_setting_vconf_set_changed_cb(VCONFKEY_BGSET, SYSTEM_SETTINGS_KEY_WALLPAPER_HOME_SCREEN, 0, user_data);
1071 int system_setting_unset_changed_callback_wallpaper_home_screen(system_settings_key_e key)
1073 SETTING_TRACE_BEGIN;
1074 return system_setting_vconf_unset_changed_cb(VCONFKEY_BGSET, 0);
1077 int system_setting_set_changed_callback_wallpaper_lock_screen(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1079 SETTING_TRACE_BEGIN;
1080 return system_setting_vconf_set_changed_cb(VCONFKEY_IDLE_LOCK_BGSET, SYSTEM_SETTINGS_KEY_WALLPAPER_LOCK_SCREEN, 0, user_data);
1083 int system_setting_unset_changed_callback_wallpaper_lock_screen(system_settings_key_e key)
1085 SETTING_TRACE_BEGIN;
1086 return system_setting_vconf_unset_changed_cb(VCONFKEY_IDLE_LOCK_BGSET, 0);
1089 int system_setting_set_changed_callback_font_size(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1091 SETTING_TRACE_BEGIN;
1092 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, SYSTEM_SETTINGS_KEY_FONT_SIZE, 1, user_data);
1095 int system_setting_unset_changed_callback_font_size(system_settings_key_e key)
1097 SETTING_TRACE_BEGIN;
1098 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, 1);
1101 int system_setting_set_changed_callback_usb_debugging_option(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1103 SETTING_TRACE_BEGIN;
1104 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_USB_DEBUG_MODE_BOOL, SYSTEM_SETTINGS_KEY_USB_DEBUGGING_ENABLED, 1, user_data);
1107 int system_setting_unset_changed_callback_usb_debugging_option(system_settings_key_e key)
1109 SETTING_TRACE_BEGIN;
1110 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_USB_DEBUG_MODE_BOOL, 1);
1113 int system_setting_set_changed_callback_3g_data_network(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1115 SETTING_TRACE_BEGIN;
1116 return system_setting_vconf_set_changed_cb(VCONFKEY_3G_ENABLE, SYSTEM_SETTINGS_KEY_3G_DATA_NETWORK_ENABLED, 1, user_data);
1119 int system_setting_unset_changed_callback_3g_data_network(system_settings_key_e key)
1121 SETTING_TRACE_BEGIN;
1122 return system_setting_vconf_unset_changed_cb(VCONFKEY_3G_ENABLE, 1);
1125 int system_setting_set_changed_callback_lockscreen_app(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1127 SETTING_TRACE_BEGIN;
1128 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_3RD_LOCK_PKG_NAME_STR, SYSTEM_SETTINGS_KEY_LOCKSCREEN_APP, 1, user_data);
1131 int system_setting_unset_changed_callback_lockscreen_app(system_settings_key_e key)
1133 SETTING_TRACE_BEGIN;
1134 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_3RD_LOCK_PKG_NAME_STR, 1);
1139 * @todo need to add custom event notification method
1141 int system_setting_set_changed_callback_font_type(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1143 SETTING_TRACE_BEGIN;
1144 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, SYSTEM_SETTINGS_KEY_FONT_TYPE, 2, user_data);
1147 int system_setting_unset_changed_callback_font_type(system_settings_key_e key)
1149 SETTING_TRACE_BEGIN;
1150 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, 2);
1153 /* TODO : 2th argument, callback, is not in use. */
1154 int system_setting_set_changed_callback_motion_activation(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1156 SETTING_TRACE_BEGIN;
1157 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_MOTION_ACTIVATION, SYSTEM_SETTINGS_KEY_MOTION_ACTIVATION, 3, user_data);
1160 int system_setting_unset_changed_callback_motion_activation(system_settings_key_e key)
1162 SETTING_TRACE_BEGIN;
1163 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_MOTION_ACTIVATION, 3);
1166 /*//////////////////////////////////////////////////////////////////////////////////////// */
1167 /*--------------------------------------- */
1168 int system_setting_get_locale_country(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1170 SETTING_TRACE_BEGIN;
1171 char *vconf_value = NULL;
1172 if (system_setting_vconf_get_value_string(VCONFKEY_REGIONFORMAT, &vconf_value)) {
1173 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1176 /* parsing validation */
1179 snprintf(arr, 20, "%s", vconf_value);
1181 *value = strdup(arr);
1185 return SYSTEM_SETTINGS_ERROR_NONE;
1188 /* LCOV_EXCL_START */
1189 int system_setting_set_locale_country(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1191 SETTING_TRACE_BEGIN;
1192 char *vconf_value = NULL;
1193 vconf_value = (char *)value;
1195 char *ext = "UTF-8";
1198 snprintf(arr, 20, "%s.%s", vconf_value, ext);
1200 if (system_setting_vconf_set_value_string(VCONFKEY_REGIONFORMAT, arr)) {
1201 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1203 return SYSTEM_SETTINGS_ERROR_NONE;
1205 /* LCOV_EXCL_STOP */
1207 int system_setting_set_changed_callback_locale_country(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1209 SETTING_TRACE_BEGIN;
1210 return system_setting_vconf_set_changed_cb(VCONFKEY_REGIONFORMAT, SYSTEM_SETTINGS_KEY_LOCALE_COUNTRY, 3, user_data);
1213 int system_setting_unset_changed_callback_locale_country(system_settings_key_e key)
1215 SETTING_TRACE_BEGIN;
1216 return system_setting_vconf_unset_changed_cb(VCONFKEY_REGIONFORMAT, 3);
1220 /*--------------------------------------- */
1221 int system_setting_get_locale_language(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1223 SETTING_TRACE_BEGIN;
1224 char *vconf_value = NULL;
1225 if (system_setting_vconf_get_value_string(VCONFKEY_LANGSET, &vconf_value)) {
1226 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1229 /* parsing validation */
1232 snprintf(arr, 20, "%s", vconf_value);
1234 *value = strdup(arr);
1237 return SYSTEM_SETTINGS_ERROR_NONE;
1240 /* LCOV_EXCL_START */
1241 int system_setting_set_locale_language(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1243 SETTING_TRACE_BEGIN;
1244 char *vconf_value = NULL;
1245 vconf_value = (char *)value;
1247 char *ext = "UTF-8";
1250 snprintf(arr, 20, "%s.%s", vconf_value, ext);
1252 if (system_setting_vconf_set_value_string(VCONFKEY_LANGSET, arr)) {
1253 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1255 return SYSTEM_SETTINGS_ERROR_NONE;
1257 /* LCOV_EXCL_STOP */
1259 int system_setting_set_changed_callback_locale_language(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1261 SETTING_TRACE_BEGIN;
1262 /*return system_setting_vconf_set_changed_cb(VCONFKEY_LANGSET, SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, 3, user_data ); */
1263 return system_setting_vconf_set_changed_cb(VCONFKEY_LANGSET, SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, 100, user_data);
1266 int system_setting_unset_changed_callback_locale_language(system_settings_key_e key)
1268 SETTING_TRACE_BEGIN;
1269 return system_setting_vconf_unset_changed_cb(VCONFKEY_LANGSET, 100);
1272 /*--------------------------------------- */
1273 /* LCOV_EXCL_START */
1274 int system_setting_get_locale_timeformat_24hour(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1276 SETTING_TRACE_BEGIN;
1279 if (system_setting_vconf_get_value_int(VCONFKEY_REGIONFORMAT_TIME1224, &vconf_value)) {
1280 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1283 bool ret_value = true;
1284 if (vconf_value == VCONFKEY_TIME_FORMAT_12)
1286 else if (vconf_value == VCONFKEY_TIME_FORMAT_24)
1289 *value = (void *)ret_value;
1291 return SYSTEM_SETTINGS_ERROR_NONE;
1293 /* LCOV_EXCL_STOP */
1295 int system_setting_set_locale_timeformat_24hour(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1297 SETTING_TRACE_BEGIN;
1300 vconf_value = (bool *)value;
1303 if (system_setting_vconf_set_value_int(VCONFKEY_REGIONFORMAT_TIME1224, VCONFKEY_TIME_FORMAT_24)) {
1304 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1308 if (system_setting_vconf_set_value_int(VCONFKEY_REGIONFORMAT_TIME1224, VCONFKEY_TIME_FORMAT_12)) {
1309 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1314 return SYSTEM_SETTINGS_ERROR_NONE;
1317 int system_setting_set_changed_callback_locale_timeformat_24hour(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1319 SETTING_TRACE_BEGIN;
1320 return system_setting_vconf_set_changed_cb(VCONFKEY_REGIONFORMAT_TIME1224, SYSTEM_SETTINGS_KEY_LOCALE_TIMEFORMAT_24HOUR, 3, user_data);
1323 int system_setting_unset_changed_callback_locale_timeformat_24hour(system_settings_key_e key)
1325 SETTING_TRACE_BEGIN;
1326 return system_setting_vconf_unset_changed_cb(VCONFKEY_REGIONFORMAT_TIME1224, 3);
1329 int system_setting_get_locale_timezone(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1332 ssize_t len = readlink(SETTING_TZONE_SYMLINK_PATH, tzpath, sizeof(tzpath)-1);
1336 SETTING_TRACE("parse error for SETTING_TZONE_SYMLINK_PATH");
1337 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1340 SETTING_TRACE("tzpath : %s ", &tzpath[20]);
1341 *value = strdup(&tzpath[20]);
1342 return SYSTEM_SETTINGS_ERROR_NONE;
1345 /* LCOV_EXCL_START */
1346 int system_setting_set_locale_timezone(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1348 SETTING_TRACE_BEGIN;
1349 char *timezone_value = NULL;
1350 timezone_value = (char *)value;
1353 snprintf(tz_path, 1024, "/usr/share/zoneinfo/%s", timezone_value);
1355 int is_load = _is_file_accessible(tz_path);
1357 alarmmgr_set_timezone(tz_path);
1359 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_TIMEZONE_ID, timezone_value)) {
1360 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1362 return SYSTEM_SETTINGS_ERROR_NONE;
1364 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
1366 /* LCOV_EXCL_STOP */
1370 /* LCOV_EXCL_START */
1371 int system_setting_set_changed_callback_locale_timezone(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1373 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_TIMEZONE_ID, SYSTEM_SETTINGS_KEY_LOCALE_TIMEZONE, 4, user_data);
1375 /* LCOV_EXCL_STOP */
1377 /* LCOV_EXCL_START */
1378 int system_setting_unset_changed_callback_locale_timezone(system_settings_key_e key)
1380 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_TIMEZONE_ID, 4);
1382 /* LCOV_EXCL_STOP */
1384 /* LCOV_EXCL_START */
1385 int system_setting_set_changed_callback_locale_timezone_changed(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1387 SETTING_TRACE_BEGIN;
1388 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
1390 /* LCOV_EXCL_STOP */
1392 /* LCOV_EXCL_START */
1393 int system_setting_unset_changed_callback_locale_timezone_changed(system_settings_key_e key)
1395 SETTING_TRACE_BEGIN;
1396 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
1398 /* LCOV_EXCL_STOP */
1401 /* LCOV_EXCL_START */
1402 int system_setting_get_time_changed(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1404 SETTING_TRACE_BEGIN;
1406 cur_tick = time(NULL);
1407 *value = (void *)cur_tick;
1408 /* struct tm * localtime = time (cur_tick); */
1409 /* printf("%s\n", ctime(&cur_tick); */
1410 return SYSTEM_SETTINGS_ERROR_NONE;
1413 /* LCOV_EXCL_STOP */
1415 int system_setting_set_changed_callback_time_changed(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1417 SETTING_TRACE_BEGIN;
1418 return system_setting_vconf_set_changed_cb(VCONFKEY_SYSTEM_TIME_CHANGED, SYSTEM_SETTINGS_KEY_TIME_CHANGED, 3, user_data);
1421 int system_setting_unset_changed_callback_time_changed(system_settings_key_e key)
1423 SETTING_TRACE_BEGIN;
1424 return system_setting_vconf_unset_changed_cb(VCONFKEY_SYSTEM_TIME_CHANGED, 3);
1429 /* SYSTEM_SETTINGS_KEY_SOUND_LOCK */
1430 int system_setting_get_sound_lock(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1432 SETTING_TRACE_BEGIN;
1435 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_SOUND_LOCK_BOOL, &vconf_value)) {
1436 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1438 *value = (void *)vconf_value;
1440 return SYSTEM_SETTINGS_ERROR_NONE;
1443 int system_setting_set_changed_callback_sound_lock(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1445 SETTING_TRACE_BEGIN;
1446 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_SOUND_LOCK_BOOL, SYSTEM_SETTINGS_KEY_SOUND_LOCK, 3, user_data);
1449 int system_setting_unset_changed_callback_sound_lock(system_settings_key_e key)
1451 SETTING_TRACE_BEGIN;
1452 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_SOUND_LOCK_BOOL, 3);
1456 * a = VCONFKEY_SETAPPL_SOUND_STATUS_BOOL b = VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL
1458 * a == false, b == false --> silent mode
1459 * a == true, b == false --> sound mode
1460 * a == false, b == true --> vibration mode
1462 /* LCOV_EXCL_START */
1463 int system_setting_get_sound_silent_mode(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1465 SETTING_TRACE_BEGIN;
1470 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, &sound_cond)) {
1471 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1474 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, &vib_cond)) {
1475 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1478 if (sound_cond == false && vib_cond == false) {
1480 *value = (void *)vconf_value;
1482 vconf_value = false;
1483 *value = (void *)vconf_value;
1485 return SYSTEM_SETTINGS_ERROR_NONE;
1487 /* LCOV_EXCL_STOP */
1490 * a = VCONFKEY_SETAPPL_SOUND_STATUS_BOOL b = VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL
1492 * a == false, b == false --> silent mode
1493 * a == true, b == false --> sound mode
1495 int system_setting_set_sound_silent_mode(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1497 SETTING_TRACE_BEGIN;
1500 vconf_value = (bool *)value;
1502 bool vconf_sound = false;
1503 bool vconf_vib = false;
1506 vconf_sound = false;
1513 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, vconf_sound)) {
1514 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1516 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, vconf_vib)) {
1517 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1520 return SYSTEM_SETTINGS_ERROR_NONE;
1526 int system_setting_set_changed_callback_sound_silent_mode(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1528 SETTING_TRACE_BEGIN;
1529 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, SYSTEM_SETTINGS_KEY_SOUND_SILENT_MODE, 3, user_data);
1533 int system_setting_unset_changed_callback_sound_silent_mode(system_settings_key_e key)
1535 SETTING_TRACE_BEGIN;
1536 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, 3);
1539 /* SYSTEM_SETTINGS_KEY_SOUND_TOUCH */
1540 int system_setting_get_sound_touch(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1542 SETTING_TRACE_BEGIN;
1545 int ret = system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL, &vconf_value);
1546 if (ret != SYSTEM_SETTINGS_ERROR_NONE) {
1549 *value = (void *)vconf_value;
1553 int system_setting_set_changed_callback_sound_touch(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1555 SETTING_TRACE_BEGIN;
1556 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL, SYSTEM_SETTINGS_KEY_SOUND_TOUCH, 2, user_data);
1559 int system_setting_unset_changed_callback_sound_touch(system_settings_key_e key)
1561 SETTING_TRACE_BEGIN;
1562 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL, 2);
1566 /* SYSTEM_SETTINGS_KEY_SOUND_LOCK */
1567 int system_setting_get_sound_lock(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1571 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_SOUND_LOCK_BOOL, &vconf_value)) {
1572 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1574 *value = (void *)vconf_value;
1576 return SYSTEM_SETTINGS_ERROR_NONE;
1580 int system_setting_get_auto_rotation_mode(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1582 SETTING_TRACE_BEGIN;
1585 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, &vconf_value)) {
1586 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1588 *value = (void *)vconf_value;
1590 return SYSTEM_SETTINGS_ERROR_NONE;
1593 /* LCOV_EXCL_START */
1594 int system_setting_set_auto_rotation_mode(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1596 SETTING_TRACE_BEGIN;
1598 vconf_value = (bool *)value;
1599 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, *vconf_value)) {
1600 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1603 return SYSTEM_SETTINGS_ERROR_NONE;
1605 /* LCOV_EXCL_STOP */
1607 int system_setting_set_changed_callback_auto_rotation_mode(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1609 SETTING_TRACE_BEGIN;
1610 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, SYSTEM_SETTINGS_KEY_DISPLAY_SCREEN_ROTATION_AUTO, 2, user_data);
1613 int system_setting_unset_changed_callback_auto_rotation_mode(system_settings_key_e key)
1615 SETTING_TRACE_BEGIN;
1616 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, 2);
1619 int system_setting_get_screen_backlight_time(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1621 SETTING_TRACE_BEGIN;
1624 if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, &vconf_value)) {
1625 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1627 *value = (void *)vconf_value;
1629 return SYSTEM_SETTINGS_ERROR_NONE;
1633 /* LCOV_EXCL_START */
1634 int system_setting_set_screen_backlight_time(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1636 SETTING_TRACE_BEGIN;
1638 vconf_value = (int *)value;
1640 if (!(*vconf_value > 0 && *vconf_value < 600)) {
1641 SETTING_TRACE(" ERR Betweeny here 0 ~ 600");
1642 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
1645 if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, *vconf_value)) {
1646 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1649 return SYSTEM_SETTINGS_ERROR_NONE;
1651 /* LCOV_EXCL_STOP */
1653 int system_setting_set_changed_callback_screen_backlight_time(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1655 SETTING_TRACE_BEGIN;
1656 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, SYSTEM_SETTINGS_KEY_DISPLAY_SCREEN_ROTATION_AUTO, 2, user_data);
1659 int system_setting_unset_changed_callback_screen_backlight_time(system_settings_key_e key)
1661 SETTING_TRACE_BEGIN;
1662 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, 2);
1665 int system_setting_get_sound_notification(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1667 SETTING_TRACE_BEGIN;
1668 char *vconf_value = NULL;
1669 if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, &vconf_value)) {
1670 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1673 *value = vconf_value;
1674 return SYSTEM_SETTINGS_ERROR_NONE;
1677 /* LCOV_EXCL_START */
1678 int system_setting_set_sound_notification(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1680 SETTING_TRACE_BEGIN;
1681 char *vconf_value = NULL;
1682 vconf_value = (char *)value;
1684 int is_load = _is_file_accessible(vconf_value);
1686 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, vconf_value)) {
1687 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1690 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1693 return SYSTEM_SETTINGS_ERROR_NONE;
1695 /* LCOV_EXCL_STOP */
1697 int system_setting_set_changed_callback_sound_notification(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1699 SETTING_TRACE_BEGIN;
1700 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, SYSTEM_SETTINGS_KEY_INCOMING_CALL_RINGTONE, 0, user_data);
1703 int system_setting_unset_changed_callback_sound_notification(system_settings_key_e key)
1705 SETTING_TRACE_BEGIN;
1706 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, 0);
1709 int system_setting_get_notification_repetition_period(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1711 SETTING_TRACE_BEGIN;
1714 if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_NOTI_MSG_ALERT_REP_TYPE_INT, &vconf_value)) {
1715 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1717 *value = (void *)vconf_value;
1719 return SYSTEM_SETTINGS_ERROR_NONE;
1722 /* LCOV_EXCL_START */
1723 int system_setting_set_notification_repetition_period(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1725 SETTING_TRACE_BEGIN;
1727 vconf_value = (int *)value;
1729 if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_NOTI_MSG_ALERT_REP_TYPE_INT, *vconf_value)) {
1730 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1733 return SYSTEM_SETTINGS_ERROR_NONE;
1735 /* LCOV_EXCL_STOP */
1737 int system_setting_set_changed_callback_notification_repetition_period(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1739 SETTING_TRACE_BEGIN;
1740 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);
1743 int system_setting_unset_changed_callback_notification_repetition_period(system_settings_key_e key)
1745 SETTING_TRACE_BEGIN;
1746 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_ALERT_REP_TYPE_INT, 1);
1749 int system_setting_get_device_name(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1751 SETTING_TRACE_BEGIN;
1752 char *vconf_value = NULL;
1753 if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_DEVICE_NAME_STR, &vconf_value)) {
1754 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1757 *value = vconf_value;
1758 return SYSTEM_SETTINGS_ERROR_NONE;
1761 /* LCOV_EXCL_START */
1762 int system_setting_set_device_name(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1764 SETTING_TRACE_BEGIN;
1765 char *vconf_value = NULL;
1766 vconf_value = (char *)value;
1768 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_DEVICE_NAME_STR, vconf_value)) {
1769 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1772 return SYSTEM_SETTINGS_ERROR_NONE;
1774 /* LCOV_EXCL_STOP */
1776 int system_setting_set_changed_callback_device_name(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1778 SETTING_TRACE_BEGIN;
1779 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_DEVICE_NAME_STR, SYSTEM_SETTINGS_KEY_DEVICE_NAME, 0, user_data);
1782 int system_setting_unset_changed_callback_device_name(system_settings_key_e key)
1784 SETTING_TRACE_BEGIN;
1785 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_DEVICE_NAME_STR, 0);
1788 /*---------------------------------------------- */
1789 int system_setting_get_network_flight_mode(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1791 SETTING_TRACE_BEGIN;
1793 if (system_setting_vconf_get_value_bool(VCONFKEY_TELEPHONY_FLIGHT_MODE, &vconf_value)) {
1794 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1796 *value = (void *)vconf_value;
1798 return SYSTEM_SETTINGS_ERROR_NONE;
1801 int system_setting_set_changed_callback_network_flight_mode(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1803 SETTING_TRACE_BEGIN;
1804 return system_setting_vconf_set_changed_cb(VCONFKEY_TELEPHONY_FLIGHT_MODE, SYSTEM_SETTINGS_KEY_NETWORK_FLIGHT_MODE, 3, user_data);
1807 int system_setting_unset_changed_callback_network_flight_mode(system_settings_key_e key)
1809 SETTING_TRACE_BEGIN;
1810 return system_setting_vconf_unset_changed_cb(VCONFKEY_TELEPHONY_FLIGHT_MODE, 3);
1813 int system_setting_get_network_wifi_notification(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1815 SETTING_TRACE_BEGIN;
1817 if (system_setting_vconf_get_value_int(VCONFKEY_WIFI_ENABLE_QS, &vconf_value)) {
1818 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1821 bret = (vconf_value == VCONFKEY_WIFI_QS_ENABLE) ? true : false;
1823 *value = (void *)bret;
1824 return SYSTEM_SETTINGS_ERROR_NONE;
1827 int system_setting_set_changed_callback_network_wifi_notification(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1829 SETTING_TRACE_BEGIN;
1830 return system_setting_vconf_set_changed_cb(VCONFKEY_WIFI_ENABLE_QS, SYSTEM_SETTINGS_KEY_NETWORK_WIFI_NOTIFICATION, 4, user_data);
1833 int system_setting_unset_changed_callback_network_wifi_notification(system_settings_key_e key)
1835 SETTING_TRACE_BEGIN;
1836 return system_setting_vconf_unset_changed_cb(VCONFKEY_WIFI_ENABLE_QS, 4);
1839 /* LCOV_EXCL_START */
1840 int system_setting_get_lock_state(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1844 if (system_setting_vconf_get_value_int(VCONFKEY_IDLE_LOCK_STATE_READ_ONLY, &vconf_value)) {
1845 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1847 *value = (void *)vconf_value;
1849 return SYSTEM_SETTINGS_ERROR_NONE;
1851 /* LCOV_EXCL_STOP */
1853 /* LCOV_EXCL_START */
1854 int system_setting_set_lock_state(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1856 SETTING_TRACE_BEGIN;
1858 vconf_value = (int *)value;
1860 if (system_setting_vconf_set_value_int(VCONFKEY_IDLE_LOCK_STATE_READ_ONLY, *vconf_value)) {
1861 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1864 return SYSTEM_SETTINGS_ERROR_NONE;
1866 /* LCOV_EXCL_STOP */
1868 /* LCOV_EXCL_START */
1869 int system_setting_set_changed_callback_lock_state(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1871 return system_setting_vconf_set_changed_cb(VCONFKEY_IDLE_LOCK_STATE_READ_ONLY, SYSTEM_SETTINGS_KEY_LOCK_STATE, 4, user_data);
1873 /* LCOV_EXCL_STOP */
1875 /* LCOV_EXCL_START */
1876 int system_setting_unset_changed_callback_lock_state(system_settings_key_e key)
1878 return system_setting_vconf_unset_changed_cb(VCONFKEY_IDLE_LOCK_STATE_READ_ONLY, 4);
1880 /* LCOV_EXCL_STOP */
1882 //----------------------------------------------------------------------------------------------------------------------------
1884 #define DEFAULT_ADS_ID "00000000-0000-0000-0000-000000000000"
1886 int system_setting_get_ads_id(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1888 SETTING_TRACE_BEGIN;
1889 int optout_value = 0;
1890 if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_AD_ID_OPT_OUT, &optout_value)) {
1891 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1894 if (optout_value == 1) {
1895 *value = strdup(DEFAULT_ADS_ID);
1896 return SYSTEM_SETTINGS_ERROR_NONE;
1899 char *vconf_value = NULL;
1900 if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_AD_ID, &vconf_value)) {
1901 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1904 *value = vconf_value;
1905 return SYSTEM_SETTINGS_ERROR_NONE;
1910 void make_ad_id(void)
1913 char uuid_unparsed[50] = {0};
1914 uuid_generate(uuid_value);
1915 uuid_unparse(uuid_value, uuid_unparsed);
1916 system_setting_set_ad_id(key, uuid_unparsed); //example of setting the value
1919 /* LCOV_EXCL_START */
1920 int system_setting_set_ads_id(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1922 SETTING_TRACE_BEGIN;
1923 char *vconf_value = NULL;
1924 vconf_value = (char *)value;
1926 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_AD_ID, vconf_value))
1928 SETTING_TRACE("Setting VCONFKEY_SETAPPL_AD_ID failed");
1929 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1932 return SYSTEM_SETTINGS_ERROR_NONE;
1934 /* LCOV_EXCL_STOP */
1936 int system_setting_set_changed_callback_ads_id(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1938 SETTING_TRACE_BEGIN;
1939 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_AD_ID, SYSTEM_SETTINGS_KEY_ADS_ID, 0, user_data);
1942 int system_setting_unset_changed_callback_ads_id(system_settings_key_e key)
1944 SETTING_TRACE_BEGIN;
1945 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_AD_ID, 0);