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.
24 #include <sys/types.h>
34 #include <libxml/xmlmemory.h>
35 #include <libxml/parser.h>
37 #include <fontconfig/fontconfig.h>
40 #include <Elementary.h>
42 #include <Ecore_Evas.h>
44 #include <system_settings.h>
45 #include <system_settings_private.h>
48 #include <efl_assist.h>
52 #define SMALL_FONT_DPI (-90)
55 #define SMALL_FONT_DPI (-80)
57 #define MIDDLE_FONT_DPI (-100)
59 #define LARGE_FONT_DPI (-110)
62 #define LARGE_FONT_DPI (-150)
64 #define HUGE_FONT_DPI (-190)
65 #define GIANT_FONT_DPI (-250)
67 #define SETTING_FONT_PRELOAD_FONT_PATH "/usr/share/fonts"
68 #define SETTING_FONT_DOWNLOADED_FONT_PATH "/opt/share/fonts"
70 #define SETTING_FONT_CONF_FILE "/opt/etc/fonts/conf.avail/99-slp.conf"
71 #define SETTING_DEFAULT_FONT_CONF_FILE "/usr/opt/etc/fonts/conf.avail/99-slp.conf"
73 #define SETTING_STR_LEN 256
75 #define SETTING_TIME_ZONEINFO_PATH "/usr/share/zoneinfo/"
76 #define SETTING_TIME_SHARE_LOCAL_PATH "/usr/share/locale"
77 #define SETTING_TZONE_SYMLINK_PATH "/opt/etc/localtime"
80 static char *_get_cur_font();
81 static void __font_size_set();
82 static int __font_size_get();
83 static char *_get_default_font();
85 static bool font_config_set(char *font_name);
86 static void font_config_set_notification();
89 * VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR has a path of the ringtone file which user choose
90 * @return the ringtone file path specified by user in normal case
91 * if it's not accessable, return the default ringtone path
93 int system_setting_get_incoming_call_ringtone(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
97 if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR, &vconf_value)) {
98 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
101 /* check to see if it's accessable -> OK */
102 /* no --> default ringtone path VCONFKEY_SETAPPL_CALL_RINGTONE_DEFAULT_PATH_STR */
103 int is_load = _is_file_accessible(vconf_value);
105 *value = vconf_value;
106 } else { /* not zero on errro */
107 *value = vconf_get_str(VCONFKEY_SETAPPL_CALL_RINGTONE_DEFAULT_PATH_STR);
110 /**value = vconf_value; */
111 return SYSTEM_SETTINGS_ERROR_NONE;
115 int system_setting_get_email_alert_ringtone(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
119 if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, &vconf_value)) {
120 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
123 /* check to see if it's accessable -> OK */
124 /* no --> default ringtone path VCONFKEY_SETAPPL_NOTI_RINGTONE_DEFAULT_PATH_STR */
125 int is_load = _is_file_accessible(vconf_value);
127 *value = vconf_value;
128 } else { /* not zero on errro */
129 *value = vconf_get_str(VCONFKEY_SETAPPL_NOTI_RINGTONE_DEFAULT_PATH_STR);
132 return SYSTEM_SETTINGS_ERROR_NONE;
136 int system_setting_get_wallpaper_home_screen(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
140 if (system_setting_vconf_get_value_string(VCONFKEY_BGSET, &vconf_value)) {
141 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
143 *value = vconf_value;
144 return SYSTEM_SETTINGS_ERROR_NONE;
148 int system_setting_get_wallpaper_lock_screen(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
153 if (system_setting_vconf_get_value_string(VCONFKEY_IDLE_LOCK_BGSET, &vconf_value)) {
154 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
156 *value = vconf_value;
158 return SYSTEM_SETTINGS_ERROR_NONE;
162 /* [int] vconf GET */
163 int system_setting_get_font_size(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
168 if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, &vconf_value)) {
169 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
171 *value = (void *)vconf_value;
173 return SYSTEM_SETTINGS_ERROR_NONE;
177 int system_setting_get_default_font_type(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
180 char *font_name = _get_default_font();
182 *value = (void *)font_name;
183 return SYSTEM_SETTINGS_ERROR_NONE;
185 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
189 /* [int] vconf GET */
190 int system_setting_get_font_type(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
193 char *font_name = _get_cur_font();
194 *value = (void *)font_name;
196 return SYSTEM_SETTINGS_ERROR_NONE;
200 int system_setting_get_motion_activation(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
205 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_MOTION_ACTIVATION, &vconf_value)) {
206 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
208 *value = (void *)vconf_value;
210 return SYSTEM_SETTINGS_ERROR_NONE;
213 int system_setting_get_usb_debugging_option(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
218 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_USB_DEBUG_MODE_BOOL, &vconf_value)) {
219 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
221 *value = (void *)vconf_value;
223 return SYSTEM_SETTINGS_ERROR_NONE;
226 int system_setting_get_3g_data_network(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
231 if (system_setting_vconf_get_value_bool(VCONFKEY_3G_ENABLE, &vconf_value)) {
232 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
234 *value = (void *)vconf_value;
236 return SYSTEM_SETTINGS_ERROR_NONE;
238 /*////////////////////////////////////////////////////////////////////////////////////////////////// */
242 * get current lock scren app package name (string)
244 * @return SYSTEM_SETTINGS_ERROR_LOCKSCREEN_APP_PASSWORD_MODE raise exception if current lock type is 'password'
246 int system_setting_get_lockscreen_app(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
249 char *pkg_name = NULL;
251 system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_SCREEN_LOCK_TYPE_INT, &locktype);
253 if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_3RD_LOCK_PKG_NAME_STR, &pkg_name)) {
254 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
257 if (pkg_name && strcmp(pkg_name, "com.samsung.lockscreen") == 0 && locktype == SETTING_SCREEN_LOCK_TYPE_PASSWORD) {
258 return SYSTEM_SETTINGS_ERROR_LOCKSCREEN_APP_PASSWORD_MODE;
262 return SYSTEM_SETTINGS_ERROR_NONE;
266 /*////////////////////////////////////////////////////////////////////////////////////////////////// */
268 int _is_file_accessible(const char *path)
271 int ret = access(path , R_OK);
273 SETTING_TRACE("found the file %s", path);
277 SETTING_TRACE("found the file %s --- error code : %d ", path, errno);
282 int system_setting_set_incoming_call_ringtone(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
286 vconf_value = (char *)value;
288 int ret = _is_file_accessible(vconf_value);
290 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR, vconf_value)) {
291 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
294 /* @todo add a common ret_handler */
298 return SYSTEM_SETTINGS_ERROR_NONE;
302 int system_setting_set_email_alert_ringtone(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
306 vconf_value = (char *)value;
308 int ret = _is_file_accessible(vconf_value);
310 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, vconf_value)) {
311 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
314 /*return SYSTEM_SETTINGS_ERROR_IO_ERROR;*/
315 /* @todo add a common ret_handler */
319 return SYSTEM_SETTINGS_ERROR_NONE;
323 bool __is_supported_image_type_load(char *path)
330 ee = ecore_evas_new(NULL, 0, 0, 100, 100, NULL);
331 evas = ecore_evas_get(ee);
333 Evas_Object *img = evas_object_image_add(evas);
334 evas_object_image_file_set(img, path, NULL);
335 Evas_Load_Error ret = evas_object_image_load_error_get(img);
338 if (ret == EVAS_LOAD_ERROR_NONE) {
339 SETTING_TRACE("%s - OK", path);
342 SETTING_TRACE("%s - NO", path);
350 bool __is_supported_image_type(char *path)
356 if (evas_object_image_extension_can_load_get(path))
366 #define PATH_EXT_CHECK_REG ".(jpe?g|jpg|png|gif)$"
367 bool __is_supported_image_type_by_ext(char *file_path)
371 regmatch_t str[2048 + 1];
373 if (!file_path) return false;
376 if (ret = regcomp(&fsm, PATH_EXT_CHECK_REG, REG_ICASE | REG_EXTENDED)) {
377 SETTING_TRACE("regular expresstion fail");
382 if (regexec(&fsm, file_path, strlen(file_path) + 1, str, 0) == REG_NOMATCH) {
383 /*SETTING_TRACE("FAILED - %s", file_path[i]); */
386 /*SETTING_TRACE("MATCHED - %s", file_path[i]); */
391 #ifdef TIZEN_WEARABLE
392 static int system_setting_get_extended_wallpaper_num(const char *file_path, unsigned int *num)
396 const char *find_str = "extended_wallpaper_";
399 if (!(ch = strstr(file_path, find_str))) {
400 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
402 strncpy(buffer, file_path, ch - file_path);
403 buffer[ch - file_path] = 0;
404 sprintf(buffer + (ch - file_path), "%s%s", "", ch + strlen(find_str));
406 if (!isdigit(buffer[0])) {
407 SETTING_TRACE("%s is not number", buffer);
408 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
413 return SYSTEM_SETTINGS_ERROR_NONE;
416 static int system_setting_copy_extended_wallpaper(const char *dest_file_path, const char *source_file_path)
419 if (!source_file_path || !dest_file_path) {
420 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
426 fd = open(source_file_path, O_RDONLY);
428 SETTING_TRACE("file open failed: %s", source_file_path);
429 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
433 fd2 = open(dest_file_path, O_WRONLY | O_CREAT, S_IRWXU | S_IRWXG | S_IRWXO);
435 SETTING_TRACE("file creation failed: %s", dest_file_path);
437 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
440 while (read(fd, buf, sizeof(buf) - 1) > 0) {
441 write(fd2, buf, sizeof(buf) - 1);
447 if (chmod(dest_file_path, S_IRWXU | S_IRWXG | S_IRWXO) < 0) {
448 SETTING_TRACE("chmod failed: %s", dest_file_path);
451 return SYSTEM_SETTINGS_ERROR_NONE;
454 static int system_setting_remove_oldest_extended_wallpaper()
459 char *min_image_name = NULL;
460 unsigned int min_image_num = 0;
461 unsigned int temp_image_num = 0;
464 if ((dp = opendir("/opt/usr/data/setting/wallpaper")) == NULL) {
465 SETTING_TRACE("opendir error");
466 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
469 while ((dirp = readdir(dp))) {
470 if (!strcmp(dirp->d_name, ".") || !strcmp(dirp->d_name, ".."))
473 if (system_setting_get_extended_wallpaper_num(dirp->d_name, &temp_image_num)
474 != SYSTEM_SETTINGS_ERROR_NONE) {
475 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
478 if ((image_count == 0) || (min_image_num > temp_image_num)) {
479 min_image_num = temp_image_num;
480 min_image_name = dirp->d_name;
487 if (min_image_name) {
488 snprintf(buf, sizeof(buf) - 1, "/opt/usr/data/setting/wallpaper/%s", min_image_name);
489 if (remove(buf) < 0) { /* remove oldest image */
490 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
494 return SYSTEM_SETTINGS_ERROR_NONE;
497 static int system_setting_check_extended_wallpaper(const char *file_path)
500 if (!file_path || !strlen(file_path))
502 return (strstr(file_path, "/opt/usr/media/.bgwallpaper") != NULL);
505 #define WALLPAPER_MAX_COUNT 10
508 int system_setting_set_wallpaper_home_screen(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
512 vconf_value = (char *)value;
514 bool isok = __is_supported_image_type_load(vconf_value);
517 SETTING_TRACE("path : %s is not supported file format", vconf_value);
518 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
520 SETTING_TRACE("path : %s is SUPPORT file format", vconf_value);
523 /* error handling here */
524 if (_is_file_accessible(vconf_value) != 0)
525 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
527 if (system_setting_vconf_set_value_string(VCONFKEY_BGSET, vconf_value)) {
528 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
532 #ifdef TIZEN_WEARABLE
533 if (system_setting_check_extended_wallpaper(vconf_value)) { /* New extended wallpaper */
536 unsigned int max_image_num = 0;
537 unsigned int temp_image_num = 0;
540 if ((dp = opendir("/opt/usr/data/setting/wallpaper")) == NULL) {
541 SETTING_TRACE("Setting - dir open error!");
542 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
545 /* Check a max number of wallpapers */
546 while ((dirp = readdir(dp))) {
547 if (!strcmp(dirp->d_name, ".") || !strcmp(dirp->d_name, ".."))
550 if (system_setting_get_extended_wallpaper_num(dirp->d_name, &temp_image_num)
551 != SYSTEM_SETTINGS_ERROR_NONE) {
552 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
555 if ((image_count == 0) || (max_image_num < temp_image_num)) {
556 max_image_num = temp_image_num;
562 /* Numbering rule: Gear is odd number */
563 max_image_num = (max_image_num % 2 == 0) ? max_image_num + 1
566 char file_name_buffer[512];
567 snprintf(file_name_buffer, sizeof(file_name_buffer) - 1,
568 "/opt/usr/data/setting/wallpaper/extended_wallpaper_%d.jpg", max_image_num);
570 /* Copy image to /opt/usr/data/setting/wallpaper/ */
571 if (system_setting_copy_extended_wallpaper(file_name_buffer, vconf_value)
572 != SYSTEM_SETTINGS_ERROR_NONE) {
573 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
576 /* remove oldest wallpaper */
577 if (image_count >= WALLPAPER_MAX_COUNT) {
578 if (system_setting_remove_oldest_extended_wallpaper()
579 != SYSTEM_SETTINGS_ERROR_NONE) {
580 remove(file_name_buffer);
581 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
585 if (system_setting_vconf_set_value_string(VCONFKEY_BGSET, file_name_buffer)) {
586 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
589 if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_WALLPAPER_CHANGED_NOTI_INT,
590 VCONFKEY_WALLPAPER_CHANGED_NOTI_GEAR)) {
591 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
594 if (system_setting_vconf_set_value_string(VCONFKEY_BGSET, vconf_value)) {
595 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
600 return SYSTEM_SETTINGS_ERROR_NONE;
603 int system_setting_set_wallpaper_lock_screen(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
606 vconf_value = (char *)value;
608 bool isok = __is_supported_image_type_load(vconf_value);
611 SETTING_TRACE("path : %s is not supported file format", vconf_value);
612 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
614 SETTING_TRACE("path : %s is SUPPORT file format", vconf_value);
617 /* error handling here */
618 if (_is_file_accessible(vconf_value) != 0)
619 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
621 if (system_setting_vconf_set_value_string(VCONFKEY_IDLE_LOCK_BGSET, vconf_value)) {
622 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
625 return SYSTEM_SETTINGS_ERROR_NONE;
628 int system_setting_set_font_size(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
632 vconf_value = (int *)value;
634 if (*vconf_value < 0 || *vconf_value > SYSTEM_SETTINGS_FONT_SIZE_GIANT) {
635 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
638 if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, *vconf_value)) {
639 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
643 return SYSTEM_SETTINGS_ERROR_NONE;
648 void *font_conf_doc_parse(char *doc_name, char *font_name)
650 xmlDocPtr doc = NULL;
651 xmlNodePtr cur = NULL;
652 xmlNodePtr cur2 = NULL;
653 xmlNodePtr cur3 = NULL;
656 doc = xmlParseFile(doc_name);
658 cur = xmlDocGetRootElement(doc);
666 if (xmlStrcmp(cur->name, (const xmlChar *)"fontconfig")) {
672 cur = cur->xmlChildrenNode;
674 Eina_Bool is_changed = EINA_FALSE;
675 while (cur != NULL) {
676 if ((!xmlStrcmp(cur->name, (const xmlChar *)"match"))) {
677 cur2 = cur->xmlChildrenNode;
678 while (cur2 != NULL) {
679 if ((!xmlStrcmp(cur2->name, (const xmlChar *)"edit"))) {
680 xmlChar *name = xmlGetProp(cur2, (const xmlChar *)"name");
681 /* if name is not 'family', break */
682 if (xmlStrcmp(name, (const xmlChar *)"family")) {
690 cur3 = cur2->xmlChildrenNode;
691 while (cur3 != NULL) {
692 if ((!xmlStrcmp(cur3->name, (const xmlChar *)"string"))) {
693 xmlNodeSetContent(cur3->xmlChildrenNode, (const xmlChar *)font_name);
694 key = xmlNodeListGetString(doc, cur3->xmlChildrenNode, 1);
697 is_changed = EINA_TRUE;
704 } else if ((!xmlStrcmp(cur->name, (const xmlChar *)"alias"))) {
705 cur2 = cur->xmlChildrenNode;
706 while (cur2 != NULL) {
707 if ((!xmlStrcmp(cur2->name, (const xmlChar *)"family"))) {
708 xmlNodeSetContent(cur2->xmlChildrenNode, (const xmlChar *)font_name);
709 key = xmlNodeListGetString(doc, cur2->xmlChildrenNode, 1);
712 is_changed = EINA_TRUE;
713 } else if ((!xmlStrcmp(cur2->name, (const xmlChar *)"prefer"))) {
714 cur3 = cur2->xmlChildrenNode;
715 while (cur3 != NULL) {
716 if ((!xmlStrcmp(cur3->name, (const xmlChar *)"family"))) {
717 xmlNodeSetContent(cur3->xmlChildrenNode, (const xmlChar *)font_name);
718 key = xmlNodeListGetString(doc, cur3->xmlChildrenNode, 1);
721 is_changed = EINA_TRUE;
743 int system_setting_set_font_type(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
746 char *font_name = NULL;
747 font_name = (char *)value;
749 /* get current font list */
750 int is_found = __is_available_font(font_name);
753 SETTING_TRACE("found font : %s ", font_name);
755 SETTING_TRACE(" NOT found font : %s ", font_name);
756 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
759 bool bsave = font_config_set(font_name);
762 SETTING_TRACE(" font type save error by font_config_set() ");
763 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
765 SETTING_TRACE(" save OK - font_config_set() ");
768 xmlDocPtr doc = (xmlDocPtr)font_conf_doc_parse(SETTING_FONT_CONF_FILE, font_name);
770 xmlSaveFormatFile(SETTING_FONT_CONF_FILE, doc, 0);
775 font_config_set_notification();
778 vconf_value = (char *)value;
779 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, vconf_value)) {
780 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
782 return SYSTEM_SETTINGS_ERROR_NONE;
785 int system_setting_set_motion_activation(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
789 vconf_value = (bool *)value;
790 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_MOTION_ACTIVATION, *vconf_value)) {
791 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
793 return SYSTEM_SETTINGS_ERROR_NONE;
796 int system_setting_set_usb_debugging_option(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
800 vconf_value = (bool *)value;
801 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_USB_DEBUG_MODE_BOOL, *vconf_value)) {
802 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
804 return SYSTEM_SETTINGS_ERROR_NONE;
808 int system_setting_set_3g_data_network(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
812 vconf_value = (bool *)value;
813 if (system_setting_vconf_set_value_bool(VCONFKEY_3G_ENABLE, *vconf_value)) {
814 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
816 return SYSTEM_SETTINGS_ERROR_NONE;
819 static int category_func(const char *name, void *user_data)
822 static char *category = "lock-screen";
823 if (name && !strcmp(name, category)) {
824 SETTING_TRACE(" SAME ");
827 SETTING_TRACE(" DIFFERENT -- %s, category -- %s ", name, category);
836 * set 'swipe type' if current lockscreen app is 'com.samsung.lockscreen'
839 int system_setting_set_lockscreen_app(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
843 vconf_value = (char *)value; /* ex) com.samsung.lockscreen */
847 pkgmgrinfo_appinfo_h handle;
848 char *apptype = NULL;
849 r = pkgmgrinfo_appinfo_get_appinfo(vconf_value, &handle);
850 if (r != PMINFO_R_OK) {
851 SETTING_TRACE("*** pkginfo failed ");
852 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
854 SETTING_TRACE("%x", handle);
857 int ret = pkgmgrinfo_appinfo_foreach_category(handle, category_func, (void *)"lock-screen");
858 if (ret != PMINFO_R_OK) {
859 pkgmgrinfo_appinfo_destroy_appinfo(handle);
860 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
863 pkgmgrinfo_appinfo_destroy_appinfo(handle);
864 /*----------------------------------------------------------------------------------- */
866 if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_SCREEN_LOCK_TYPE_INT, &locktype)) {
867 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
870 if (locktype == SETTING_SCREEN_LOCK_TYPE_PASSWORD)
871 return SYSTEM_SETTINGS_ERROR_LOCKSCREEN_APP_PASSWORD_MODE;
873 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_3RD_LOCK_PKG_NAME_STR, vconf_value)) {
874 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
877 if (vconf_value && strcmp(vconf_value, "com.samsung.lockscreen") == 0) {
878 if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_SCREEN_LOCK_TYPE_INT, SETTING_SCREEN_LOCK_TYPE_SWIPE)) {
879 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
883 return SYSTEM_SETTINGS_ERROR_NONE;
886 /*/////////////////////////////////////////////////////////////////////////////////////////////// */
889 int system_setting_set_changed_callback_incoming_call_ringtone(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
892 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR, SYSTEM_SETTINGS_KEY_INCOMING_CALL_RINGTONE, 0, user_data);
895 int system_setting_unset_changed_callback_incoming_call_ringtone(system_settings_key_e key)
898 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR, 0);
901 int system_setting_set_changed_callback_email_alert_ringtone(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
904 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, SYSTEM_SETTINGS_KEY_EMAIL_ALERT_RINGTONE, 0, user_data);
907 int system_setting_unset_changed_callback_email_alert_ringtone(system_settings_key_e key)
910 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, 0);
913 int system_setting_set_changed_callback_wallpaper_home_screen(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
916 return system_setting_vconf_set_changed_cb(VCONFKEY_BGSET, SYSTEM_SETTINGS_KEY_WALLPAPER_HOME_SCREEN, 0, user_data);
919 int system_setting_unset_changed_callback_wallpaper_home_screen(system_settings_key_e key)
922 return system_setting_vconf_unset_changed_cb(VCONFKEY_BGSET, 0);
925 int system_setting_set_changed_callback_wallpaper_lock_screen(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
928 return system_setting_vconf_set_changed_cb(VCONFKEY_IDLE_LOCK_BGSET, SYSTEM_SETTINGS_KEY_WALLPAPER_LOCK_SCREEN, 0, user_data);
931 int system_setting_unset_changed_callback_wallpaper_lock_screen(system_settings_key_e key)
934 return system_setting_vconf_unset_changed_cb(VCONFKEY_IDLE_LOCK_BGSET, 0);
937 int system_setting_set_changed_callback_font_size(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
940 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, SYSTEM_SETTINGS_KEY_FONT_SIZE, 1, user_data);
943 int system_setting_unset_changed_callback_font_size(system_settings_key_e key)
946 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, 1);
949 int system_setting_set_changed_callback_usb_debugging_option(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
952 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_USB_DEBUG_MODE_BOOL, SYSTEM_SETTINGS_KEY_USB_DEBUGGING_ENABLED, 1, user_data);
955 int system_setting_unset_changed_callback_usb_debugging_option(system_settings_key_e key)
958 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_USB_DEBUG_MODE_BOOL, 1);
961 int system_setting_set_changed_callback_3g_data_network(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
964 return system_setting_vconf_set_changed_cb(VCONFKEY_3G_ENABLE, SYSTEM_SETTINGS_KEY_3G_DATA_NETWORK_ENABLED, 1, user_data);
967 int system_setting_unset_changed_callback_3g_data_network(system_settings_key_e key)
970 return system_setting_vconf_unset_changed_cb(VCONFKEY_3G_ENABLE, 1);
973 int system_setting_set_changed_callback_lockscreen_app(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
976 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_3RD_LOCK_PKG_NAME_STR, SYSTEM_SETTINGS_KEY_LOCKSCREEN_APP, 1, user_data);
979 int system_setting_unset_changed_callback_lockscreen_app(system_settings_key_e key)
982 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_3RD_LOCK_PKG_NAME_STR, 1);
987 * @todo need to add custom event notification method
989 int system_setting_set_changed_callback_font_type(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
992 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, SYSTEM_SETTINGS_KEY_FONT_TYPE, 2, user_data);
995 int system_setting_unset_changed_callback_font_type(system_settings_key_e key)
998 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, 2);
1001 /* TODO : 2th argument, callback, is not in use. */
1002 int system_setting_set_changed_callback_motion_activation(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1004 SETTING_TRACE_BEGIN;
1005 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_MOTION_ACTIVATION, SYSTEM_SETTINGS_KEY_MOTION_ACTIVATION, 3, user_data);
1008 int system_setting_unset_changed_callback_motion_activation(system_settings_key_e key)
1010 SETTING_TRACE_BEGIN;
1011 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_MOTION_ACTIVATION, 3);
1014 static char *_get_cur_font()
1016 SETTING_TRACE_BEGIN;
1017 xmlDocPtr doc = NULL;
1018 xmlNodePtr cur = NULL;
1019 xmlNodePtr cur2 = NULL;
1020 xmlNodePtr cur3 = NULL;
1021 xmlChar *key = NULL;
1023 char *font_name = NULL;
1025 doc = xmlParseFile(SETTING_FONT_CONF_FILE);
1027 cur = xmlDocGetRootElement(doc);
1035 if (xmlStrcmp(cur->name, (const xmlChar *)"fontconfig")) {
1041 cur = cur->xmlChildrenNode;
1043 while (cur != NULL) {
1044 if ((!xmlStrcmp(cur->name, (const xmlChar *)"match"))) {
1045 cur2 = cur->xmlChildrenNode;
1046 while (cur2 != NULL) {
1047 if ((!xmlStrcmp(cur2->name, (const xmlChar *)"edit"))) {
1048 cur3 = cur2->xmlChildrenNode;
1049 while (cur3 != NULL) {
1050 if ((!xmlStrcmp(cur3->name, (const xmlChar *)"string"))) {
1051 key = xmlNodeListGetString(doc, cur3->xmlChildrenNode, 1);
1053 font_name = g_strdup((char *)key);
1074 static void font_config_set_notification()
1076 SETTING_TRACE_BEGIN;
1079 Ecore_X_Window ecore_win = ecore_x_window_root_first_get();
1080 Ecore_X_Atom atom = ecore_x_atom_get("FONT_TYPE_change");
1081 ecore_x_window_prop_string_set(ecore_win, atom, "tizen");
1085 int __is_available_font(char *font_name)
1087 SETTING_TRACE_BEGIN;
1088 FcObjectSet *os = NULL;
1089 FcFontSet *fs = NULL;
1090 FcPattern *pat = NULL;
1091 Eina_List *list = NULL;
1092 FcConfig *font_config = NULL;
1096 if (font_name == NULL)
1099 font_config = FcInitLoadConfigAndFonts();
1101 /*setting_retvm_if(font_config == NULL, NULL, "Failed: FcInitLoadConfigAndFonts"); */
1103 char *locale = setlocale(0, NULL);
1105 pat = FcPatternCreate();
1107 os = FcObjectSetBuild(FC_FAMILY, FC_FILE, FC_FAMILYLANG, (char *) 0);
1110 fs = FcFontList(font_config, pat, os);
1111 FcObjectSetDestroy(os);
1116 FcPatternDestroy(pat);
1122 SETTING_TRACE("fs->nfont = %d", fs->nfont);
1124 for (j = 0; j < fs->nfont; j++) {
1125 FcChar8 *family = NULL;
1126 FcChar8 *file = NULL;
1128 if (FcPatternGetString(fs->fonts[j], FC_FILE, 0, &file) == FcResultMatch) {
1129 int preload_path_len = strlen(SETTING_FONT_PRELOAD_FONT_PATH);
1130 int download_path_len = strlen(SETTING_FONT_DOWNLOADED_FONT_PATH);
1132 if (file && (!strncmp((const char *)file, SETTING_FONT_PRELOAD_FONT_PATH, preload_path_len)
1133 || !strncmp((const char *)file, SETTING_FONT_DOWNLOADED_FONT_PATH, download_path_len))) {
1134 char *family_result = NULL;
1135 FcChar8 *lang = NULL;
1137 if (FcPatternGetString(fs->fonts[j], FC_FAMILY, id, &family) != FcResultMatch) {
1140 if (FcPatternGetString(fs->fonts[j], FC_FAMILYLANG, id, &lang) != FcResultMatch) {
1143 family_result = (char *)family;
1145 /* Find proper family name for current locale. */
1146 while (locale && family && lang) {
1147 if (!strncmp(locale, (char *)lang, strlen((char *)lang))) {
1148 family_result = (char *)family;
1152 /* I will set english as default family language. */
1153 /* If there is no proper family language for current locale, */
1154 /* we have to show the english family name. */
1155 if (!strcmp(lang, "en")) {
1156 family_result = (char *)family;
1159 if (FcPatternGetString(fs->fonts[j], FC_FAMILY, id, &family) != FcResultMatch) {
1162 if (FcPatternGetString(fs->fonts[j], FC_FAMILYLANG, id, &lang) != FcResultMatch) {
1167 if (family_result) {
1168 SETTING_TRACE("-------- FONT - family_result = %s", (char *)family_result);
1169 if (strcmp(family_result, font_name) == 0) {
1177 FcFontSetDestroy(fs);
1180 FcConfigDestroy(font_config);
1186 static char *_get_default_font()
1188 SETTING_TRACE_BEGIN;
1189 xmlDocPtr doc = NULL;
1190 xmlNodePtr cur = NULL;
1191 xmlNodePtr cur2 = NULL;
1192 xmlNodePtr cur3 = NULL;
1193 xmlChar *key = NULL;
1194 struct _xmlAttr *properties = NULL;
1195 char *default_font_name = NULL;
1197 doc = xmlParseFile(SETTING_DEFAULT_FONT_CONF_FILE);
1199 cur = xmlDocGetRootElement(doc);
1207 if (xmlStrcmp(cur->name, (const xmlChar *)"fontconfig")) {
1213 cur = cur->xmlChildrenNode;
1215 while (cur != NULL) {
1216 if ((!xmlStrcmp(cur->name, (const xmlChar *)"match"))) {
1217 cur2 = cur->xmlChildrenNode;
1218 while (cur2 != NULL) {
1219 if ((!xmlStrcmp(cur2->name, (const xmlChar *)"edit"))) {
1220 properties = cur2->properties;
1221 /*find the "name" property*/
1222 while (NULL != properties) {
1223 if (!xmlStrcmp(properties->name, (const xmlChar *)"name")) {
1226 properties = properties->next;
1229 /*If the value of "name" property is "family", then get the child node string,
1230 it shall be the default font type*/
1231 if (NULL != properties && !xmlStrcmp(properties->children->content, (const xmlChar *)"family")) {
1232 cur3 = cur2->xmlChildrenNode;
1233 while (cur3 != NULL) {
1234 if ((!xmlStrcmp(cur3->name, (const xmlChar *)"string"))) {
1235 key = xmlNodeListGetString(doc, cur3->xmlChildrenNode, 1);
1236 default_font_name = g_strdup((char *)key);
1241 return default_font_name;
1258 static bool font_config_set(char *font_name)
1260 SETTING_TRACE_BEGIN;
1261 Eina_List *text_classes = NULL;
1262 Elm_Text_Class *etc = NULL;
1263 const Eina_List *l = NULL;
1264 Eina_List *fo_list = NULL;
1265 Elm_Font_Overlay *efo = NULL;
1267 int font_size = __font_size_get();
1270 text_classes = elm_config_text_classes_list_get();
1272 fo_list = (Eina_List *)elm_config_font_overlay_list_get();
1274 Eina_List *ll = NULL;
1275 Eina_List *l_next = NULL;
1277 Eina_Bool slp_medium_exist = EINA_FALSE;
1278 Eina_Bool slp_roman_exist = EINA_FALSE;
1279 Eina_Bool slp_bold_exist = EINA_FALSE;
1280 Eina_Bool slp_regular_exist = EINA_FALSE;
1283 Eina_Bool tizen_exist = EINA_FALSE;
1285 EINA_LIST_FOREACH_SAFE(fo_list, ll, l_next, efo) {
1286 if (!strcmp(efo->text_class, "tizen_medium")) {
1287 elm_config_font_overlay_set(efo->text_class, (const char *)font_name, efo->size);
1288 slp_medium_exist = EINA_TRUE;
1289 } else if (!strcmp(efo->text_class, "tizen_roman")) {
1290 elm_config_font_overlay_set(efo->text_class, (const char *)font_name, efo->size);
1291 slp_roman_exist = EINA_TRUE;
1292 } else if (!strcmp(efo->text_class, "tizen_bold")) {
1293 elm_config_font_overlay_set(efo->text_class, (const char *)font_name, efo->size);
1294 slp_bold_exist = EINA_TRUE;
1295 } else if (!strcmp(efo->text_class, "tizen_regular")) {
1296 elm_config_font_overlay_set(efo->text_class, (const char *)font_name, efo->size);
1297 slp_regular_exist = EINA_TRUE;
1301 if (!strcmp(efo->text_class, "tizen")) {
1302 elm_config_font_overlay_set(efo->text_class, (const char *)font_name, efo->size);
1303 tizen_exist = EINA_TRUE;
1308 /* if slp_XX do not exist, need to set them, font size is -100(100%) */
1309 if (slp_medium_exist == EINA_FALSE) {
1310 elm_config_font_overlay_set("tizen_medium", (const char *)font_name, MIDDLE_FONT_DPI);
1312 if (slp_roman_exist == EINA_FALSE) {
1313 elm_config_font_overlay_set("tizen_roman", (const char *)font_name, MIDDLE_FONT_DPI);
1315 if (slp_bold_exist == EINA_FALSE) {
1316 elm_config_font_overlay_set("tizen_bold", (const char *)font_name, MIDDLE_FONT_DPI);
1318 if (slp_regular_exist == EINA_FALSE) {
1319 elm_config_font_overlay_set("tizen_regular", (const char *)font_name, MIDDLE_FONT_DPI);
1323 if (tizen_exist == EINA_FALSE) {
1324 elm_config_font_overlay_set("tizen", (const char *)font_name, MIDDLE_FONT_DPI);
1327 elm_config_font_overlay_set("tizen", (const char *)font_name, MIDDLE_FONT_DPI);
1330 elm_config_font_overlay_set("tizen", (const char *)font_name, MIDDLE_FONT_DPI);
1332 EINA_LIST_FOREACH(text_classes, l, etc) {
1336 EINA_LIST_FOREACH(fo_list, ll, efo) {
1337 if (!strcmp(etc->name, efo->text_class)) {
1341 elm_config_font_overlay_set(etc->name, (const char *)font_name, size);
1343 elm_config_text_classes_list_free(text_classes);
1344 text_classes = NULL;
1346 /* add new function */
1347 #ifdef USE_EFL_ASSIST
1348 ea_theme_system_font_set(font_name, font_size);
1349 ea_theme_system_fonts_apply();
1352 elm_config_font_overlay_apply();
1353 elm_config_all_flush();
1358 static void __font_size_set()
1360 SETTING_TRACE_BEGIN;
1361 Eina_List *text_classes = NULL;
1362 Elm_Text_Class *etc = NULL;
1363 const Eina_List *l = NULL;
1364 int font_size = __font_size_get();
1365 char *font_name = _get_cur_font();
1367 if (font_size == -1) {
1371 text_classes = elm_config_text_classes_list_get();
1373 EINA_LIST_FOREACH(text_classes, l, etc) {
1374 elm_config_font_overlay_set(etc->name, font_name, font_size);
1377 elm_config_text_classes_list_free(text_classes);
1379 #ifdef USE_EFL_ASSIST
1380 ea_theme_system_font_set(font_name, font_size);
1381 ea_theme_system_fonts_apply();
1384 elm_config_font_overlay_apply();
1385 elm_config_all_flush();
1388 text_classes = NULL;
1392 static int __font_size_get()
1394 SETTING_TRACE_BEGIN;
1398 int vconf_value = -1;
1399 if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, &vconf_value)) {
1403 switch (vconf_value) {
1404 case SYSTEM_SETTINGS_FONT_SIZE_SMALL:
1405 font_size = SMALL_FONT_DPI;
1407 case SYSTEM_SETTINGS_FONT_SIZE_NORMAL:
1408 font_size = MIDDLE_FONT_DPI;
1410 case SYSTEM_SETTINGS_FONT_SIZE_LARGE:
1411 font_size = LARGE_FONT_DPI;
1413 case SYSTEM_SETTINGS_FONT_SIZE_HUGE:
1414 font_size = HUGE_FONT_DPI;
1416 case SYSTEM_SETTINGS_FONT_SIZE_GIANT:
1417 font_size = GIANT_FONT_DPI;
1420 font_size = MIDDLE_FONT_DPI;
1426 /*//////////////////////////////////////////////////////////////////////////////////////// */
1427 /*--------------------------------------- */
1428 int system_setting_get_locale_country(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1430 SETTING_TRACE_BEGIN;
1431 char *vconf_value = NULL;
1432 if (system_setting_vconf_get_value_string(VCONFKEY_REGIONFORMAT, &vconf_value)) {
1433 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1436 /* parsing validation */
1439 snprintf(arr, 20, vconf_value);
1441 *value = strdup(arr);
1445 return SYSTEM_SETTINGS_ERROR_NONE;
1448 int system_setting_set_locale_country(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1450 SETTING_TRACE_BEGIN;
1451 char *vconf_value = NULL;
1452 vconf_value = (char *)value;
1454 char *ext = "UTF-8";
1457 snprintf(arr, 20, "%s.%s", vconf_value, ext);
1459 if (system_setting_vconf_set_value_string(VCONFKEY_REGIONFORMAT, arr)) {
1460 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1463 return SYSTEM_SETTINGS_ERROR_NONE;
1466 int system_setting_set_changed_callback_locale_country(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1468 SETTING_TRACE_BEGIN;
1469 return system_setting_vconf_set_changed_cb(VCONFKEY_REGIONFORMAT, SYSTEM_SETTINGS_KEY_LOCALE_COUNTRY, 3, user_data);
1472 int system_setting_unset_changed_callback_locale_country(system_settings_key_e key)
1474 SETTING_TRACE_BEGIN;
1475 return system_setting_vconf_unset_changed_cb(VCONFKEY_REGIONFORMAT, 3);
1479 /*--------------------------------------- */
1480 int system_setting_get_locale_language(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1482 SETTING_TRACE_BEGIN;
1483 char *vconf_value = NULL;
1484 if (system_setting_vconf_get_value_string(VCONFKEY_LANGSET, &vconf_value)) {
1485 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1488 /* parsing validation */
1491 snprintf(arr, 20, vconf_value);
1493 *value = strdup(arr);
1496 return SYSTEM_SETTINGS_ERROR_NONE;
1499 int system_setting_set_locale_language(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1501 SETTING_TRACE_BEGIN;
1502 char *vconf_value = NULL;
1503 vconf_value = (char *)value;
1505 char *ext = "UTF-8";
1508 snprintf(arr, 20, "%s.%s", vconf_value, ext);
1510 if (system_setting_vconf_set_value_string(VCONFKEY_LANGSET, arr)) {
1511 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1514 return SYSTEM_SETTINGS_ERROR_NONE;
1517 int system_setting_set_changed_callback_locale_language(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1519 SETTING_TRACE_BEGIN;
1520 /*return system_setting_vconf_set_changed_cb(VCONFKEY_LANGSET, SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, 3, user_data ); */
1521 return system_setting_vconf_set_changed_cb(VCONFKEY_LANGSET, SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, 100, user_data);
1524 int system_setting_unset_changed_callback_locale_language(system_settings_key_e key)
1526 SETTING_TRACE_BEGIN;
1527 return system_setting_vconf_unset_changed_cb(VCONFKEY_LANGSET, 100);
1530 /*--------------------------------------- */
1531 int system_setting_get_locale_timeformat_24hour(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1533 SETTING_TRACE_BEGIN;
1536 if (system_setting_vconf_get_value_int(VCONFKEY_REGIONFORMAT_TIME1224, &vconf_value)) {
1537 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1541 if (vconf_value == VCONFKEY_TIME_FORMAT_12)
1543 else if (vconf_value == VCONFKEY_TIME_FORMAT_24)
1546 *value = (void *)ret_value;
1548 return SYSTEM_SETTINGS_ERROR_NONE;
1551 int system_setting_set_locale_timeformat_24hour(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1553 SETTING_TRACE_BEGIN;
1556 vconf_value = (bool *)value;
1559 if (system_setting_vconf_set_value_int(VCONFKEY_REGIONFORMAT_TIME1224, VCONFKEY_TIME_FORMAT_24)) {
1560 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1564 if (system_setting_vconf_set_value_int(VCONFKEY_REGIONFORMAT_TIME1224, VCONFKEY_TIME_FORMAT_12)) {
1565 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1570 return SYSTEM_SETTINGS_ERROR_NONE;
1573 int system_setting_set_changed_callback_locale_timeformat_24hour(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1575 SETTING_TRACE_BEGIN;
1576 return system_setting_vconf_set_changed_cb(VCONFKEY_REGIONFORMAT_TIME1224, SYSTEM_SETTINGS_KEY_LOCALE_TIMEFORMAT_24HOUR, 3, user_data);
1579 int system_setting_unset_changed_callback_locale_timeformat_24hour(system_settings_key_e key)
1581 SETTING_TRACE_BEGIN;
1582 return system_setting_vconf_unset_changed_cb(VCONFKEY_REGIONFORMAT_TIME1224, 3);
1585 int system_setting_get_locale_timezone(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1587 SETTING_TRACE_BEGIN;
1589 ssize_t len = readlink(SETTING_TZONE_SYMLINK_PATH, tzpath, sizeof(tzpath) - 1);
1593 SETTING_TRACE("parse error for SETTING_TZONE_SYMLINK_PATH");
1594 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1597 /* "/usr/share/zoneinfo/Asia/Seoul" */
1598 SETTING_TRACE("tzpath : %s ", &tzpath[20]);
1599 *value = strdup(&tzpath[20]);
1600 return SYSTEM_SETTINGS_ERROR_NONE;
1603 int system_setting_set_changed_callback_locale_timezone_changed(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1605 SETTING_TRACE_BEGIN;
1606 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
1609 int system_setting_unset_changed_callback_locale_timezone_changed(system_settings_key_e key)
1611 SETTING_TRACE_BEGIN;
1612 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
1616 int system_setting_get_time_changed(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1618 SETTING_TRACE_BEGIN;
1620 cur_tick = time(NULL);
1621 *value = (void *)cur_tick;
1622 /* struct tm * localtime = time (cur_tick); */
1623 /* printf("%s\n", ctime(&cur_tick); */
1624 return SYSTEM_SETTINGS_ERROR_NONE;
1628 int system_setting_set_changed_callback_time_changed(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1630 SETTING_TRACE_BEGIN;
1631 return system_setting_vconf_set_changed_cb(VCONFKEY_SYSTEM_TIME_CHANGED, SYSTEM_SETTINGS_KEY_TIME_CHANGED, 3, user_data);
1634 int system_setting_unset_changed_callback_time_changed(system_settings_key_e key)
1636 SETTING_TRACE_BEGIN;
1637 return system_setting_vconf_unset_changed_cb(VCONFKEY_SYSTEM_TIME_CHANGED, 3);
1642 /* SYSTEM_SETTINGS_KEY_SOUND_LOCK */
1643 int system_setting_get_sound_lock(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1645 SETTING_TRACE_BEGIN;
1648 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_SOUND_LOCK_BOOL, &vconf_value)) {
1649 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1651 *value = (void *)vconf_value;
1653 return SYSTEM_SETTINGS_ERROR_NONE;
1656 int system_setting_set_changed_callback_sound_lock(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1658 SETTING_TRACE_BEGIN;
1659 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_SOUND_LOCK_BOOL, SYSTEM_SETTINGS_KEY_SOUND_LOCK, 3, user_data);
1662 int system_setting_unset_changed_callback_sound_lock(system_settings_key_e key)
1664 SETTING_TRACE_BEGIN;
1665 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_SOUND_LOCK_BOOL, 3);
1669 * a = VCONFKEY_SETAPPL_SOUND_STATUS_BOOL b = VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL
1671 * a == false, b == false --> silent mode
1672 * a == true, b == false --> sound mode
1673 * a == false, b == true --> vibration mode
1675 int system_setting_get_sound_silent_mode(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1677 SETTING_TRACE_BEGIN;
1682 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, &sound_cond)) {
1683 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1686 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, &vib_cond)) {
1687 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1690 if (sound_cond == false && vib_cond == false) {
1692 *value = (void *)vconf_value;
1694 vconf_value = false;
1695 *value = (void *)vconf_value;
1697 return SYSTEM_SETTINGS_ERROR_NONE;
1701 * a = VCONFKEY_SETAPPL_SOUND_STATUS_BOOL b = VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL
1703 * a == false, b == false --> silent mode
1704 * a == true, b == false --> sound mode
1706 int system_setting_set_sound_silent_mode(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1708 SETTING_TRACE_BEGIN;
1711 vconf_value = (bool *)value;
1713 bool vconf_sound = false;
1714 bool vconf_vib = false;
1717 vconf_sound = false;
1724 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, vconf_sound)) {
1725 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1727 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, vconf_vib)) {
1728 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1731 return SYSTEM_SETTINGS_ERROR_NONE;
1737 int system_setting_set_changed_callback_sound_silent_mode(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_SOUND_STATUS_BOOL, SYSTEM_SETTINGS_KEY_SOUND_SILENT_MODE, 3, user_data);
1744 int system_setting_unset_changed_callback_sound_silent_mode(system_settings_key_e key)
1746 SETTING_TRACE_BEGIN;
1747 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, 3);
1750 /* SYSTEM_SETTINGS_KEY_SOUND_TOUCH */
1751 int system_setting_get_sound_touch(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1753 SETTING_TRACE_BEGIN;
1756 int ret = system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL, &vconf_value);
1757 if (ret != SYSTEM_SETTINGS_ERROR_NONE) {
1760 *value = (void *)vconf_value;
1764 int system_setting_set_changed_callback_sound_touch(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1766 SETTING_TRACE_BEGIN;
1767 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL, SYSTEM_SETTINGS_KEY_SOUND_TOUCH, 2, user_data);
1770 int system_setting_unset_changed_callback_sound_touch(system_settings_key_e key)
1772 SETTING_TRACE_BEGIN;
1773 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL, 2);
1777 /* SYSTEM_SETTINGS_KEY_SOUND_LOCK */
1778 int system_setting_get_sound_lock(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1782 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_SOUND_LOCK_BOOL, &vconf_value)) {
1783 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1785 *value = (void *)vconf_value;
1787 return SYSTEM_SETTINGS_ERROR_NONE;
1791 int system_setting_get_auto_rotation_mode(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1793 SETTING_TRACE_BEGIN;
1796 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, &vconf_value)) {
1797 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1799 *value = (void *)vconf_value;
1801 return SYSTEM_SETTINGS_ERROR_NONE;
1804 int system_setting_set_auto_rotation_mode(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1806 SETTING_TRACE_BEGIN;
1808 vconf_value = (bool *)value;
1809 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, *vconf_value)) {
1810 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1812 return SYSTEM_SETTINGS_ERROR_NONE;
1815 int system_setting_set_changed_callback_auto_rotation_mode(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1817 SETTING_TRACE_BEGIN;
1818 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, SYSTEM_SETTINGS_KEY_DISPLAY_SCREEN_ROTATION_AUTO, 2, user_data);
1821 int system_setting_unset_changed_callback_auto_rotation_mode(system_settings_key_e key)
1823 SETTING_TRACE_BEGIN;
1824 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, 2);
1827 int system_setting_get_screen_backlight_time(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1829 SETTING_TRACE_BEGIN;
1832 if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, &vconf_value)) {
1833 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1835 *value = (void *)vconf_value;
1837 return SYSTEM_SETTINGS_ERROR_NONE;
1841 int system_setting_set_screen_backlight_time(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1843 SETTING_TRACE_BEGIN;
1845 vconf_value = (int *)value;
1847 if (!(*vconf_value > 0 && *vconf_value < 600)) {
1848 SETTING_TRACE(" ERR Betweeny here 0 ~ 600");
1849 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
1852 if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, *vconf_value)) {
1853 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1856 return SYSTEM_SETTINGS_ERROR_NONE;
1859 int system_setting_set_changed_callback_screen_backlight_time(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1861 SETTING_TRACE_BEGIN;
1862 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, SYSTEM_SETTINGS_KEY_DISPLAY_SCREEN_ROTATION_AUTO, 2, user_data);
1865 int system_setting_unset_changed_callback_screen_backlight_time(system_settings_key_e key)
1867 SETTING_TRACE_BEGIN;
1868 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, 2);
1871 int system_setting_get_sound_notification(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1873 SETTING_TRACE_BEGIN;
1874 char *vconf_value = NULL;
1875 if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, &vconf_value)) {
1876 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1879 *value = vconf_value;
1880 return SYSTEM_SETTINGS_ERROR_NONE;
1883 int system_setting_set_sound_notification(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1885 SETTING_TRACE_BEGIN;
1886 char *vconf_value = NULL;
1887 vconf_value = (char *)value;
1889 int is_load = _is_file_accessible(vconf_value);
1891 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, vconf_value)) {
1892 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1895 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1898 return SYSTEM_SETTINGS_ERROR_NONE;
1901 int system_setting_set_changed_callback_sound_notification(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1903 SETTING_TRACE_BEGIN;
1904 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, SYSTEM_SETTINGS_KEY_INCOMING_CALL_RINGTONE, 0, user_data);
1907 int system_setting_unset_changed_callback_sound_notification(system_settings_key_e key)
1909 SETTING_TRACE_BEGIN;
1910 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, 0);
1913 int system_setting_get_notification_repetition_period(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1915 SETTING_TRACE_BEGIN;
1918 if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_NOTI_MSG_ALERT_REP_TYPE_INT, &vconf_value)) {
1919 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1921 *value = (void *)vconf_value;
1923 return SYSTEM_SETTINGS_ERROR_NONE;
1926 int system_setting_set_notification_repetition_period(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1928 SETTING_TRACE_BEGIN;
1930 vconf_value = (int *)value;
1932 if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_NOTI_MSG_ALERT_REP_TYPE_INT, *vconf_value)) {
1933 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1936 return SYSTEM_SETTINGS_ERROR_NONE;
1939 int system_setting_set_changed_callback_notification_repetition_period(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1941 SETTING_TRACE_BEGIN;
1942 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_ALERT_REP_TYPE_INT, SYSTEM_SETTINGS_KEY_DISPLAY_SCREEN_ROTATION_AUTO, 1, user_data);
1945 int system_setting_unset_changed_callback_notification_repetition_period(system_settings_key_e key)
1947 SETTING_TRACE_BEGIN;
1948 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_ALERT_REP_TYPE_INT, 1);
1951 int system_setting_get_device_name(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1953 SETTING_TRACE_BEGIN;
1954 char *vconf_value = NULL;
1955 if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_DEVICE_NAME_STR, &vconf_value)) {
1956 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1959 *value = vconf_value;
1960 return SYSTEM_SETTINGS_ERROR_NONE;
1963 int system_setting_set_device_name(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1965 SETTING_TRACE_BEGIN;
1966 char *vconf_value = NULL;
1967 vconf_value = (char *)value;
1969 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_DEVICE_NAME_STR, vconf_value)) {
1970 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1973 return SYSTEM_SETTINGS_ERROR_NONE;
1976 int system_setting_set_changed_callback_device_name(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1978 SETTING_TRACE_BEGIN;
1979 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_DEVICE_NAME_STR, SYSTEM_SETTINGS_KEY_DEVICE_NAME, 0, user_data);
1982 int system_setting_unset_changed_callback_device_name(system_settings_key_e key)
1984 SETTING_TRACE_BEGIN;
1985 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_DEVICE_NAME_STR, 0);
1988 /*---------------------------------------------- */
1989 int system_setting_get_network_flight_mode(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1991 SETTING_TRACE_BEGIN;
1993 if (system_setting_vconf_get_value_bool(VCONFKEY_TELEPHONY_FLIGHT_MODE, &vconf_value)) {
1994 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1996 *value = (void *)vconf_value;
1998 return SYSTEM_SETTINGS_ERROR_NONE;
2001 int system_setting_set_changed_callback_network_flight_mode(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
2003 SETTING_TRACE_BEGIN;
2004 return system_setting_vconf_set_changed_cb(VCONFKEY_TELEPHONY_FLIGHT_MODE, SYSTEM_SETTINGS_KEY_NETWORK_FLIGHT_MODE, 3, user_data);
2007 int system_setting_unset_changed_callback_network_flight_mode(system_settings_key_e key)
2009 SETTING_TRACE_BEGIN;
2010 return system_setting_vconf_unset_changed_cb(VCONFKEY_TELEPHONY_FLIGHT_MODE, 3);
2013 int system_setting_get_network_wifi_notification(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
2015 SETTING_TRACE_BEGIN;
2017 if (system_setting_vconf_get_value_int(VCONFKEY_WIFI_ENABLE_QS, &vconf_value)) {
2018 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2021 bret = (vconf_value == VCONFKEY_WIFI_QS_ENABLE) ? true : false;
2023 *value = (void *)bret;
2024 return SYSTEM_SETTINGS_ERROR_NONE;
2027 int system_setting_set_changed_callback_network_wifi_notification(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
2029 SETTING_TRACE_BEGIN;
2030 return system_setting_vconf_set_changed_cb(VCONFKEY_WIFI_ENABLE_QS, SYSTEM_SETTINGS_KEY_NETWORK_WIFI_NOTIFICATION, 4, user_data);
2033 int system_setting_unset_changed_callback_network_wifi_notification(system_settings_key_e key)
2035 SETTING_TRACE_BEGIN;
2036 return system_setting_vconf_unset_changed_cb(VCONFKEY_WIFI_ENABLE_QS, 4);