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>
39 //#include <pkgmgr-info.h>
41 #include <Elementary.h>
43 #include <Ecore_Evas.h>
45 #include <pkgmgr-info.h>
47 #include <system_settings.h>
48 #include <system_settings_private.h>
51 #include <efl_assist.h>
55 #define SMALL_FONT_DPI (-90)
58 #define SMALL_FONT_DPI (-80)
60 #define MIDDLE_FONT_DPI (-100)
62 #define LARGE_FONT_DPI (-110)
65 #define LARGE_FONT_DPI (-150)
67 #define HUGE_FONT_DPI (-190)
68 #define GIANT_FONT_DPI (-250)
70 #define SETTING_FONT_PRELOAD_FONT_PATH "/usr/share/fonts"
71 #define SETTING_FONT_DOWNLOADED_FONT_PATH "/opt/share/fonts"
73 #define SETTING_FONT_CONF_FILE "/opt/etc/fonts/conf.avail/99-slp.conf"
74 #define SETTING_DEFAULT_FONT_CONF_FILE "/usr/opt/etc/fonts/conf.avail/99-slp.conf"
76 #define SETTING_STR_LEN 256
78 #define SETTING_TIME_ZONEINFO_PATH "/usr/share/zoneinfo/"
79 #define SETTING_TIME_SHARE_LOCAL_PATH "/usr/share/locale"
80 #define SETTING_TZONE_SYMLINK_PATH "/etc/localtime"
83 static char *_get_cur_font();
84 static void __font_size_set();
85 static int __font_size_get();
86 static char *_get_default_font();
88 static bool font_config_set(char *font_name);
89 static void font_config_set_notification();
92 * VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR has a path of the ringtone file which user choose
93 * @return the ringtone file path specified by user in normal case
94 * if it's not accessable, return the default ringtone path
96 int system_setting_get_incoming_call_ringtone(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
100 if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR, &vconf_value)) {
101 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
104 /* check to see if it's accessable -> OK */
105 /* no --> default ringtone path VCONFKEY_SETAPPL_CALL_RINGTONE_DEFAULT_PATH_STR */
106 int is_load = _is_file_accessible(vconf_value);
108 *value = vconf_value;
109 } else { /* not zero on errro */
110 *value = vconf_get_str(VCONFKEY_SETAPPL_CALL_RINGTONE_DEFAULT_PATH_STR);
113 /**value = vconf_value; */
114 return SYSTEM_SETTINGS_ERROR_NONE;
118 int system_setting_get_email_alert_ringtone(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
122 if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, &vconf_value)) {
123 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
126 /* check to see if it's accessable -> OK */
127 /* no --> default ringtone path VCONFKEY_SETAPPL_NOTI_RINGTONE_DEFAULT_PATH_STR */
128 int is_load = _is_file_accessible(vconf_value);
130 *value = vconf_value;
131 } else { /* not zero on errro */
132 *value = vconf_get_str(VCONFKEY_SETAPPL_NOTI_RINGTONE_DEFAULT_PATH_STR);
135 return SYSTEM_SETTINGS_ERROR_NONE;
139 int system_setting_get_wallpaper_home_screen(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
143 if (system_setting_vconf_get_value_string(VCONFKEY_BGSET, &vconf_value)) {
144 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
146 *value = vconf_value;
147 return SYSTEM_SETTINGS_ERROR_NONE;
151 int system_setting_get_wallpaper_lock_screen(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
156 if (system_setting_vconf_get_value_string(VCONFKEY_IDLE_LOCK_BGSET, &vconf_value)) {
157 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
159 *value = vconf_value;
161 return SYSTEM_SETTINGS_ERROR_NONE;
165 /* [int] vconf GET */
166 int system_setting_get_font_size(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
171 if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, &vconf_value)) {
172 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
174 *value = (void *)vconf_value;
176 return SYSTEM_SETTINGS_ERROR_NONE;
180 int system_setting_get_default_font_type(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
183 char *font_name = _get_default_font();
185 *value = (void *)font_name;
186 return SYSTEM_SETTINGS_ERROR_NONE;
188 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
192 /* [int] vconf GET */
193 int system_setting_get_font_type(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
196 char *font_name = _get_cur_font();
197 *value = (void *)font_name;
199 return SYSTEM_SETTINGS_ERROR_NONE;
203 int system_setting_get_motion_activation(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
208 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_MOTION_ACTIVATION, &vconf_value)) {
209 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
211 *value = (void *)vconf_value;
213 return SYSTEM_SETTINGS_ERROR_NONE;
216 int system_setting_get_usb_debugging_option(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
221 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_USB_DEBUG_MODE_BOOL, &vconf_value)) {
222 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
224 *value = (void *)vconf_value;
226 return SYSTEM_SETTINGS_ERROR_NONE;
229 int system_setting_get_3g_data_network(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
234 if (system_setting_vconf_get_value_bool(VCONFKEY_3G_ENABLE, &vconf_value)) {
235 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
237 *value = (void *)vconf_value;
239 return SYSTEM_SETTINGS_ERROR_NONE;
241 /*////////////////////////////////////////////////////////////////////////////////////////////////// */
245 * get current lock scren app package name (string)
247 * @return SYSTEM_SETTINGS_ERROR_LOCKSCREEN_APP_PASSWORD_MODE raise exception if current lock type is 'password'
249 int system_setting_get_lockscreen_app(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
252 char *pkg_name = NULL;
254 system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_SCREEN_LOCK_TYPE_INT, &locktype);
256 if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_3RD_LOCK_PKG_NAME_STR, &pkg_name)) {
257 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
260 if (pkg_name && strcmp(pkg_name, "com.samsung.lockscreen") == 0 && locktype == SETTING_SCREEN_LOCK_TYPE_PASSWORD) {
261 return SYSTEM_SETTINGS_ERROR_LOCKSCREEN_APP_PASSWORD_MODE;
265 return SYSTEM_SETTINGS_ERROR_NONE;
269 /*////////////////////////////////////////////////////////////////////////////////////////////////// */
271 int _is_file_accessible(const char *path)
274 int ret = access(path , R_OK);
276 SETTING_TRACE("found the file %s", path);
280 SETTING_TRACE("found the file %s --- error code : %d ", path, errno);
285 int system_setting_set_incoming_call_ringtone(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
289 vconf_value = (char *)value;
291 int ret = _is_file_accessible(vconf_value);
293 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR, vconf_value)) {
294 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
297 /* @todo add a common ret_handler */
301 return SYSTEM_SETTINGS_ERROR_NONE;
305 int system_setting_set_email_alert_ringtone(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
309 vconf_value = (char *)value;
311 int ret = _is_file_accessible(vconf_value);
313 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, vconf_value)) {
314 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
317 /*return SYSTEM_SETTINGS_ERROR_IO_ERROR;*/
318 /* @todo add a common ret_handler */
322 return SYSTEM_SETTINGS_ERROR_NONE;
326 bool __is_supported_image_type_load(char *path)
334 ee = ecore_evas_new(NULL, 0, 0, 100, 100, NULL);
335 evas = ecore_evas_get(ee);
337 Evas_Object *img = evas_object_image_add(evas);
338 evas_object_image_file_set(img, path, NULL);
339 Evas_Load_Error ret = evas_object_image_load_error_get(img);
342 if (ret == EVAS_LOAD_ERROR_NONE) {
343 SETTING_TRACE("%s - OK", path);
346 SETTING_TRACE("%s - NO", path);
354 bool __is_supported_image_type(char *path)
360 if (evas_object_image_extension_can_load_get(path))
370 #define PATH_EXT_CHECK_REG ".(jpe?g|jpg|png|gif)$"
371 bool __is_supported_image_type_by_ext(char *file_path)
375 regmatch_t str[2048 + 1];
377 if (!file_path) return false;
380 if (ret = regcomp(&fsm, PATH_EXT_CHECK_REG, REG_ICASE | REG_EXTENDED)) {
381 SETTING_TRACE("regular expresstion fail");
386 if (regexec(&fsm, file_path, strlen(file_path) + 1, str, 0) == REG_NOMATCH) {
387 /*SETTING_TRACE("FAILED - %s", file_path[i]); */
390 /*SETTING_TRACE("MATCHED - %s", file_path[i]); */
395 #ifdef TIZEN_WEARABLE
396 static int system_setting_get_extended_wallpaper_num(const char *file_path, unsigned int *num)
400 const char *find_str = "extended_wallpaper_";
403 if (!(ch = strstr(file_path, find_str))) {
404 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
406 strncpy(buffer, file_path, ch - file_path);
407 buffer[ch - file_path] = 0;
408 sprintf(buffer + (ch - file_path), "%s%s", "", ch + strlen(find_str));
410 if (!isdigit(buffer[0])) {
411 SETTING_TRACE("%s is not number", buffer);
412 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
417 return SYSTEM_SETTINGS_ERROR_NONE;
420 static int system_setting_copy_extended_wallpaper(const char *dest_file_path, const char *source_file_path)
423 if (!source_file_path || !dest_file_path) {
424 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
430 fd = open(source_file_path, O_RDONLY);
432 SETTING_TRACE("file open failed: %s", source_file_path);
433 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
437 fd2 = open(dest_file_path, O_WRONLY | O_CREAT, S_IRWXU | S_IRWXG | S_IRWXO);
439 SETTING_TRACE("file creation failed: %s", dest_file_path);
441 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
444 while (read(fd, buf, sizeof(buf) - 1) > 0) {
445 write(fd2, buf, sizeof(buf) - 1);
451 if (chmod(dest_file_path, S_IRWXU | S_IRWXG | S_IRWXO) < 0) {
452 SETTING_TRACE("chmod failed: %s", dest_file_path);
455 return SYSTEM_SETTINGS_ERROR_NONE;
458 static int system_setting_remove_oldest_extended_wallpaper()
463 char *min_image_name = NULL;
464 unsigned int min_image_num = 0;
465 unsigned int temp_image_num = 0;
468 if ((dp = opendir("/opt/usr/data/setting/wallpaper")) == NULL) {
469 SETTING_TRACE("opendir error");
470 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
473 while ((dirp = readdir(dp))) {
474 if (!strcmp(dirp->d_name, ".") || !strcmp(dirp->d_name, ".."))
477 if (system_setting_get_extended_wallpaper_num(dirp->d_name, &temp_image_num)
478 != SYSTEM_SETTINGS_ERROR_NONE) {
479 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
482 if ((image_count == 0) || (min_image_num > temp_image_num)) {
483 min_image_num = temp_image_num;
484 min_image_name = dirp->d_name;
491 if (min_image_name) {
492 snprintf(buf, sizeof(buf) - 1, "/opt/usr/data/setting/wallpaper/%s", min_image_name);
493 if (remove(buf) < 0) { /* remove oldest image */
494 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
498 return SYSTEM_SETTINGS_ERROR_NONE;
501 static int system_setting_check_extended_wallpaper(const char *file_path)
504 if (!file_path || !strlen(file_path))
506 return (strstr(file_path, "/opt/usr/media/.bgwallpaper") != NULL);
509 #define WALLPAPER_MAX_COUNT 10
512 int system_setting_set_wallpaper_home_screen(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
516 vconf_value = (char *)value;
518 bool isok = __is_supported_image_type_load(vconf_value);
521 SETTING_TRACE("path : %s is not supported file format", vconf_value);
522 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
524 SETTING_TRACE("path : %s is SUPPORT file format", vconf_value);
527 /* error handling here */
528 if (_is_file_accessible(vconf_value) != 0)
529 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
531 if (system_setting_vconf_set_value_string(VCONFKEY_BGSET, vconf_value)) {
532 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
536 #ifdef TIZEN_WEARABLE
537 if (system_setting_check_extended_wallpaper(vconf_value)) { /* New extended wallpaper */
540 unsigned int max_image_num = 0;
541 unsigned int temp_image_num = 0;
544 if ((dp = opendir("/opt/usr/data/setting/wallpaper")) == NULL) {
545 SETTING_TRACE("Setting - dir open error!");
546 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
549 /* Check a max number of wallpapers */
550 while ((dirp = readdir(dp))) {
551 if (!strcmp(dirp->d_name, ".") || !strcmp(dirp->d_name, ".."))
554 if (system_setting_get_extended_wallpaper_num(dirp->d_name, &temp_image_num)
555 != SYSTEM_SETTINGS_ERROR_NONE) {
556 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
559 if ((image_count == 0) || (max_image_num < temp_image_num)) {
560 max_image_num = temp_image_num;
566 /* Numbering rule: Gear is odd number */
567 max_image_num = (max_image_num % 2 == 0) ? max_image_num + 1
570 char file_name_buffer[512];
571 snprintf(file_name_buffer, sizeof(file_name_buffer) - 1,
572 "/opt/usr/data/setting/wallpaper/extended_wallpaper_%d.jpg", max_image_num);
574 /* Copy image to /opt/usr/data/setting/wallpaper/ */
575 if (system_setting_copy_extended_wallpaper(file_name_buffer, vconf_value)
576 != SYSTEM_SETTINGS_ERROR_NONE) {
577 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
580 /* remove oldest wallpaper */
581 if (image_count >= WALLPAPER_MAX_COUNT) {
582 if (system_setting_remove_oldest_extended_wallpaper()
583 != SYSTEM_SETTINGS_ERROR_NONE) {
584 remove(file_name_buffer);
585 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
589 if (system_setting_vconf_set_value_string(VCONFKEY_BGSET, file_name_buffer)) {
590 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
593 if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_WALLPAPER_CHANGED_NOTI_INT,
594 VCONFKEY_WALLPAPER_CHANGED_NOTI_GEAR)) {
595 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
598 if (system_setting_vconf_set_value_string(VCONFKEY_BGSET, vconf_value)) {
599 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
604 return SYSTEM_SETTINGS_ERROR_NONE;
607 int system_setting_set_wallpaper_lock_screen(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
611 vconf_value = (char *)value;
613 bool isok = __is_supported_image_type_load(vconf_value);
616 SETTING_TRACE("path : %s is not supported file format", vconf_value);
617 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
619 SETTING_TRACE("path : %s is SUPPORT file format", vconf_value);
622 /* error handling here */
623 if (_is_file_accessible(vconf_value) != 0)
624 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
626 if (system_setting_vconf_set_value_string(VCONFKEY_IDLE_LOCK_BGSET, vconf_value)) {
627 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
630 return SYSTEM_SETTINGS_ERROR_NONE;
633 int system_setting_set_font_size(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
637 vconf_value = (int *)value;
639 if (*vconf_value < 0 || *vconf_value > SYSTEM_SETTINGS_FONT_SIZE_GIANT) {
640 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
643 if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, *vconf_value)) {
644 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
648 return SYSTEM_SETTINGS_ERROR_NONE;
653 void *font_conf_doc_parse(char *doc_name, char *font_name)
656 xmlDocPtr doc = NULL;
657 xmlNodePtr cur = NULL;
658 xmlNodePtr cur2 = NULL;
659 xmlNodePtr cur3 = NULL;
662 doc = xmlParseFile(doc_name);
664 cur = xmlDocGetRootElement(doc);
672 if (xmlStrcmp(cur->name, (const xmlChar *)"fontconfig")) {
678 cur = cur->xmlChildrenNode;
680 Eina_Bool is_changed = EINA_FALSE;
681 while (cur != NULL) {
682 if ((!xmlStrcmp(cur->name, (const xmlChar *)"match"))) {
683 cur2 = cur->xmlChildrenNode;
684 while (cur2 != NULL) {
685 if ((!xmlStrcmp(cur2->name, (const xmlChar *)"edit"))) {
686 xmlChar *name = xmlGetProp(cur2, (const xmlChar *)"name");
687 /* if name is not 'family', break */
688 if (xmlStrcmp(name, (const xmlChar *)"family")) {
696 cur3 = cur2->xmlChildrenNode;
697 while (cur3 != NULL) {
698 if ((!xmlStrcmp(cur3->name, (const xmlChar *)"string"))) {
699 xmlNodeSetContent(cur3->xmlChildrenNode, (const xmlChar *)font_name);
700 key = xmlNodeListGetString(doc, cur3->xmlChildrenNode, 1);
703 is_changed = EINA_TRUE;
710 } else if ((!xmlStrcmp(cur->name, (const xmlChar *)"alias"))) {
711 cur2 = cur->xmlChildrenNode;
712 while (cur2 != NULL) {
713 if ((!xmlStrcmp(cur2->name, (const xmlChar *)"family"))) {
714 xmlNodeSetContent(cur2->xmlChildrenNode, (const xmlChar *)font_name);
715 key = xmlNodeListGetString(doc, cur2->xmlChildrenNode, 1);
718 is_changed = EINA_TRUE;
719 } else if ((!xmlStrcmp(cur2->name, (const xmlChar *)"prefer"))) {
720 cur3 = cur2->xmlChildrenNode;
721 while (cur3 != NULL) {
722 if ((!xmlStrcmp(cur3->name, (const xmlChar *)"family"))) {
723 xmlNodeSetContent(cur3->xmlChildrenNode, (const xmlChar *)font_name);
724 key = xmlNodeListGetString(doc, cur3->xmlChildrenNode, 1);
727 is_changed = EINA_TRUE;
749 int system_setting_set_font_type(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
752 char *font_name = NULL;
753 font_name = (char *)value;
755 /* get current font list */
756 int is_found = __is_available_font(font_name);
759 SETTING_TRACE("found font : %s ", font_name);
761 SETTING_TRACE(" NOT found font : %s ", font_name);
762 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
765 bool bsave = font_config_set(font_name);
768 SETTING_TRACE(" font type save error by font_config_set() ");
769 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
771 SETTING_TRACE(" save OK - font_config_set() ");
774 xmlDocPtr doc = (xmlDocPtr)font_conf_doc_parse(SETTING_FONT_CONF_FILE, font_name);
776 xmlSaveFormatFile(SETTING_FONT_CONF_FILE, doc, 0);
781 font_config_set_notification();
784 vconf_value = (char *)value;
786 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, vconf_value)) {
787 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
789 return SYSTEM_SETTINGS_ERROR_NONE;
792 int system_setting_set_motion_activation(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
796 vconf_value = (bool *)value;
797 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_MOTION_ACTIVATION, *vconf_value)) {
798 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
800 return SYSTEM_SETTINGS_ERROR_NONE;
803 int system_setting_set_usb_debugging_option(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
807 vconf_value = (bool *)value;
808 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_USB_DEBUG_MODE_BOOL, *vconf_value)) {
809 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
811 return SYSTEM_SETTINGS_ERROR_NONE;
815 int system_setting_set_3g_data_network(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
819 vconf_value = (bool *)value;
820 if (system_setting_vconf_set_value_bool(VCONFKEY_3G_ENABLE, *vconf_value)) {
821 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
824 return SYSTEM_SETTINGS_ERROR_NONE;
827 static int category_func(const char *name, void *user_data)
830 static char *category = "lock-screen";
831 if (name && !strcmp(name, category)) {
832 SETTING_TRACE(" SAME ");
835 SETTING_TRACE(" DIFFERENT -- %s, category -- %s ", name, category);
844 * set 'swipe type' if current lockscreen app is 'com.samsung.lockscreen'
847 int system_setting_set_lockscreen_app(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
851 vconf_value = (char *)value; /* ex) com.samsung.lockscreen */
854 pkgmgrinfo_appinfo_h handle;
855 char *apptype = NULL;
856 r = pkgmgrinfo_appinfo_get_appinfo(vconf_value, &handle);
857 if (r != PMINFO_R_OK) {
858 SETTING_TRACE("*** pkginfo failed ");
859 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
861 SETTING_TRACE("%x", handle);
864 int ret = pkgmgrinfo_appinfo_foreach_category(handle, category_func, (void *)"lock-screen");
865 if (ret != PMINFO_R_OK) {
866 pkgmgrinfo_appinfo_destroy_appinfo(handle);
867 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
870 pkgmgrinfo_appinfo_destroy_appinfo(handle);
871 /*----------------------------------------------------------------------------------- */
873 if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_SCREEN_LOCK_TYPE_INT, &locktype)) {
874 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
877 if (locktype == SETTING_SCREEN_LOCK_TYPE_PASSWORD)
878 return SYSTEM_SETTINGS_ERROR_LOCKSCREEN_APP_PASSWORD_MODE;
880 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_3RD_LOCK_PKG_NAME_STR, vconf_value)) {
881 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
884 if (vconf_value && strcmp(vconf_value, "com.samsung.lockscreen") == 0) {
885 if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_SCREEN_LOCK_TYPE_INT, SETTING_SCREEN_LOCK_TYPE_SWIPE)) {
886 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
889 return SYSTEM_SETTINGS_ERROR_NONE;
892 /*/////////////////////////////////////////////////////////////////////////////////////////////// */
895 int system_setting_set_changed_callback_incoming_call_ringtone(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
898 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR, SYSTEM_SETTINGS_KEY_INCOMING_CALL_RINGTONE, 0, user_data);
901 int system_setting_unset_changed_callback_incoming_call_ringtone(system_settings_key_e key)
904 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR, 0);
907 int system_setting_set_changed_callback_email_alert_ringtone(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
910 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, SYSTEM_SETTINGS_KEY_EMAIL_ALERT_RINGTONE, 0, user_data);
913 int system_setting_unset_changed_callback_email_alert_ringtone(system_settings_key_e key)
916 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, 0);
919 int system_setting_set_changed_callback_wallpaper_home_screen(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
922 return system_setting_vconf_set_changed_cb(VCONFKEY_BGSET, SYSTEM_SETTINGS_KEY_WALLPAPER_HOME_SCREEN, 0, user_data);
925 int system_setting_unset_changed_callback_wallpaper_home_screen(system_settings_key_e key)
928 return system_setting_vconf_unset_changed_cb(VCONFKEY_BGSET, 0);
931 int system_setting_set_changed_callback_wallpaper_lock_screen(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
934 return system_setting_vconf_set_changed_cb(VCONFKEY_IDLE_LOCK_BGSET, SYSTEM_SETTINGS_KEY_WALLPAPER_LOCK_SCREEN, 0, user_data);
937 int system_setting_unset_changed_callback_wallpaper_lock_screen(system_settings_key_e key)
940 return system_setting_vconf_unset_changed_cb(VCONFKEY_IDLE_LOCK_BGSET, 0);
943 int system_setting_set_changed_callback_font_size(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
946 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, SYSTEM_SETTINGS_KEY_FONT_SIZE, 1, user_data);
949 int system_setting_unset_changed_callback_font_size(system_settings_key_e key)
952 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, 1);
955 int system_setting_set_changed_callback_usb_debugging_option(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
958 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_USB_DEBUG_MODE_BOOL, SYSTEM_SETTINGS_KEY_USB_DEBUGGING_ENABLED, 1, user_data);
961 int system_setting_unset_changed_callback_usb_debugging_option(system_settings_key_e key)
964 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_USB_DEBUG_MODE_BOOL, 1);
967 int system_setting_set_changed_callback_3g_data_network(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
970 return system_setting_vconf_set_changed_cb(VCONFKEY_3G_ENABLE, SYSTEM_SETTINGS_KEY_3G_DATA_NETWORK_ENABLED, 1, user_data);
973 int system_setting_unset_changed_callback_3g_data_network(system_settings_key_e key)
976 return system_setting_vconf_unset_changed_cb(VCONFKEY_3G_ENABLE, 1);
979 int system_setting_set_changed_callback_lockscreen_app(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
982 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_3RD_LOCK_PKG_NAME_STR, SYSTEM_SETTINGS_KEY_LOCKSCREEN_APP, 1, user_data);
985 int system_setting_unset_changed_callback_lockscreen_app(system_settings_key_e key)
988 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_3RD_LOCK_PKG_NAME_STR, 1);
993 * @todo need to add custom event notification method
995 int system_setting_set_changed_callback_font_type(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
998 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, SYSTEM_SETTINGS_KEY_FONT_TYPE, 2, user_data);
1001 int system_setting_unset_changed_callback_font_type(system_settings_key_e key)
1003 SETTING_TRACE_BEGIN;
1004 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, 2);
1007 /* TODO : 2th argument, callback, is not in use. */
1008 int system_setting_set_changed_callback_motion_activation(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1010 SETTING_TRACE_BEGIN;
1011 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_MOTION_ACTIVATION, SYSTEM_SETTINGS_KEY_MOTION_ACTIVATION, 3, user_data);
1014 int system_setting_unset_changed_callback_motion_activation(system_settings_key_e key)
1016 SETTING_TRACE_BEGIN;
1017 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_MOTION_ACTIVATION, 3);
1020 static char *_get_cur_font()
1022 SETTING_TRACE_BEGIN;
1023 xmlDocPtr doc = NULL;
1024 xmlNodePtr cur = NULL;
1025 xmlNodePtr cur2 = NULL;
1026 xmlNodePtr cur3 = NULL;
1027 xmlChar *key = NULL;
1029 char *font_name = NULL;
1031 doc = xmlParseFile(SETTING_FONT_CONF_FILE);
1033 cur = xmlDocGetRootElement(doc);
1041 if (xmlStrcmp(cur->name, (const xmlChar *)"fontconfig")) {
1047 cur = cur->xmlChildrenNode;
1049 while (cur != NULL) {
1050 if ((!xmlStrcmp(cur->name, (const xmlChar *)"match"))) {
1051 cur2 = cur->xmlChildrenNode;
1052 while (cur2 != NULL) {
1053 if ((!xmlStrcmp(cur2->name, (const xmlChar *)"edit"))) {
1054 cur3 = cur2->xmlChildrenNode;
1055 while (cur3 != NULL) {
1056 if ((!xmlStrcmp(cur3->name, (const xmlChar *)"string"))) {
1057 key = xmlNodeListGetString(doc, cur3->xmlChildrenNode, 1);
1059 font_name = g_strdup((char *)key);
1080 static void font_config_set_notification()
1082 SETTING_TRACE_BEGIN;
1085 Ecore_X_Window ecore_win = ecore_x_window_root_first_get();
1086 Ecore_X_Atom atom = ecore_x_atom_get("FONT_TYPE_change");
1087 ecore_x_window_prop_string_set(ecore_win, atom, "tizen");
1091 int __is_available_font(char *font_name)
1093 SETTING_TRACE_BEGIN;
1094 FcObjectSet *os = NULL;
1095 FcFontSet *fs = NULL;
1096 FcPattern *pat = NULL;
1097 Eina_List *list = NULL;
1098 FcConfig *font_config = NULL;
1102 if (font_name == NULL)
1105 font_config = FcInitLoadConfigAndFonts();
1107 /*setting_retvm_if(font_config == NULL, NULL, "Failed: FcInitLoadConfigAndFonts"); */
1109 char *locale = setlocale(0, NULL);
1111 pat = FcPatternCreate();
1113 os = FcObjectSetBuild(FC_FAMILY, FC_FILE, FC_FAMILYLANG, (char *) 0);
1116 fs = FcFontList(font_config, pat, os);
1117 FcObjectSetDestroy(os);
1122 FcPatternDestroy(pat);
1128 SETTING_TRACE("fs->nfont = %d", fs->nfont);
1130 for (j = 0; j < fs->nfont; j++) {
1131 FcChar8 *family = NULL;
1132 FcChar8 *file = NULL;
1134 if (FcPatternGetString(fs->fonts[j], FC_FILE, 0, &file) == FcResultMatch) {
1135 int preload_path_len = strlen(SETTING_FONT_PRELOAD_FONT_PATH);
1136 int download_path_len = strlen(SETTING_FONT_DOWNLOADED_FONT_PATH);
1138 if (file && (!strncmp((const char *)file, SETTING_FONT_PRELOAD_FONT_PATH, preload_path_len)
1139 || !strncmp((const char *)file, SETTING_FONT_DOWNLOADED_FONT_PATH, download_path_len))) {
1140 char *family_result = NULL;
1141 FcChar8 *lang = NULL;
1143 if (FcPatternGetString(fs->fonts[j], FC_FAMILY, id, &family) != FcResultMatch) {
1146 if (FcPatternGetString(fs->fonts[j], FC_FAMILYLANG, id, &lang) != FcResultMatch) {
1149 family_result = (char *)family;
1151 /* Find proper family name for current locale. */
1152 while (locale && family && lang) {
1153 if (!strncmp(locale, (char *)lang, strlen((char *)lang))) {
1154 family_result = (char *)family;
1158 /* I will set english as default family language. */
1159 /* If there is no proper family language for current locale, */
1160 /* we have to show the english family name. */
1161 if (!strcmp(lang, "en")) {
1162 family_result = (char *)family;
1165 if (FcPatternGetString(fs->fonts[j], FC_FAMILY, id, &family) != FcResultMatch) {
1168 if (FcPatternGetString(fs->fonts[j], FC_FAMILYLANG, id, &lang) != FcResultMatch) {
1173 if (family_result) {
1174 SETTING_TRACE("-------- FONT - family_result = %s", (char *)family_result);
1175 if (strcmp(family_result, font_name) == 0) {
1183 FcFontSetDestroy(fs);
1186 FcConfigDestroy(font_config);
1192 static char *_get_default_font()
1194 SETTING_TRACE_BEGIN;
1195 xmlDocPtr doc = NULL;
1196 xmlNodePtr cur = NULL;
1197 xmlNodePtr cur2 = NULL;
1198 xmlNodePtr cur3 = NULL;
1199 xmlChar *key = NULL;
1200 struct _xmlAttr *properties = NULL;
1201 char *default_font_name = NULL;
1203 doc = xmlParseFile(SETTING_DEFAULT_FONT_CONF_FILE);
1205 cur = xmlDocGetRootElement(doc);
1213 if (xmlStrcmp(cur->name, (const xmlChar *)"fontconfig")) {
1219 cur = cur->xmlChildrenNode;
1221 while (cur != NULL) {
1222 if ((!xmlStrcmp(cur->name, (const xmlChar *)"match"))) {
1223 cur2 = cur->xmlChildrenNode;
1224 while (cur2 != NULL) {
1225 if ((!xmlStrcmp(cur2->name, (const xmlChar *)"edit"))) {
1226 properties = cur2->properties;
1227 /*find the "name" property*/
1228 while (NULL != properties) {
1229 if (!xmlStrcmp(properties->name, (const xmlChar *)"name")) {
1232 properties = properties->next;
1235 /*If the value of "name" property is "family", then get the child node string,
1236 it shall be the default font type*/
1237 if (NULL != properties && !xmlStrcmp(properties->children->content, (const xmlChar *)"family")) {
1238 cur3 = cur2->xmlChildrenNode;
1239 while (cur3 != NULL) {
1240 if ((!xmlStrcmp(cur3->name, (const xmlChar *)"string"))) {
1241 key = xmlNodeListGetString(doc, cur3->xmlChildrenNode, 1);
1242 default_font_name = g_strdup((char *)key);
1247 return default_font_name;
1264 static bool font_config_set(char *font_name)
1266 SETTING_TRACE_BEGIN;
1267 Eina_List *text_classes = NULL;
1268 Elm_Text_Class *etc = NULL;
1269 const Eina_List *l = NULL;
1270 Eina_List *fo_list = NULL;
1271 Elm_Font_Overlay *efo = NULL;
1273 int font_size = __font_size_get();
1276 text_classes = elm_config_text_classes_list_get();
1278 fo_list = (Eina_List *)elm_config_font_overlay_list_get();
1280 Eina_List *ll = NULL;
1281 Eina_List *l_next = NULL;
1283 Eina_Bool slp_medium_exist = EINA_FALSE;
1284 Eina_Bool slp_roman_exist = EINA_FALSE;
1285 Eina_Bool slp_bold_exist = EINA_FALSE;
1286 Eina_Bool slp_regular_exist = EINA_FALSE;
1289 Eina_Bool tizen_exist = EINA_FALSE;
1291 EINA_LIST_FOREACH_SAFE(fo_list, ll, l_next, efo) {
1292 if (!strcmp(efo->text_class, "tizen_medium")) {
1293 elm_config_font_overlay_set(efo->text_class, (const char *)font_name, efo->size);
1294 slp_medium_exist = EINA_TRUE;
1295 } else if (!strcmp(efo->text_class, "tizen_roman")) {
1296 elm_config_font_overlay_set(efo->text_class, (const char *)font_name, efo->size);
1297 slp_roman_exist = EINA_TRUE;
1298 } else if (!strcmp(efo->text_class, "tizen_bold")) {
1299 elm_config_font_overlay_set(efo->text_class, (const char *)font_name, efo->size);
1300 slp_bold_exist = EINA_TRUE;
1301 } else if (!strcmp(efo->text_class, "tizen_regular")) {
1302 elm_config_font_overlay_set(efo->text_class, (const char *)font_name, efo->size);
1303 slp_regular_exist = EINA_TRUE;
1307 if (!strcmp(efo->text_class, "tizen")) {
1308 elm_config_font_overlay_set(efo->text_class, (const char *)font_name, efo->size);
1309 tizen_exist = EINA_TRUE;
1314 /* if slp_XX do not exist, need to set them, font size is -100(100%) */
1315 if (slp_medium_exist == EINA_FALSE) {
1316 elm_config_font_overlay_set("tizen_medium", (const char *)font_name, MIDDLE_FONT_DPI);
1318 if (slp_roman_exist == EINA_FALSE) {
1319 elm_config_font_overlay_set("tizen_roman", (const char *)font_name, MIDDLE_FONT_DPI);
1321 if (slp_bold_exist == EINA_FALSE) {
1322 elm_config_font_overlay_set("tizen_bold", (const char *)font_name, MIDDLE_FONT_DPI);
1324 if (slp_regular_exist == EINA_FALSE) {
1325 elm_config_font_overlay_set("tizen_regular", (const char *)font_name, MIDDLE_FONT_DPI);
1329 if (tizen_exist == EINA_FALSE) {
1330 elm_config_font_overlay_set("tizen", (const char *)font_name, MIDDLE_FONT_DPI);
1333 elm_config_font_overlay_set("tizen", (const char *)font_name, MIDDLE_FONT_DPI);
1336 elm_config_font_overlay_set("tizen", (const char *)font_name, MIDDLE_FONT_DPI);
1338 EINA_LIST_FOREACH(text_classes, l, etc) {
1342 EINA_LIST_FOREACH(fo_list, ll, efo) {
1343 if (!strcmp(etc->name, efo->text_class)) {
1347 elm_config_font_overlay_set(etc->name, (const char *)font_name, size);
1349 elm_config_text_classes_list_free(text_classes);
1350 text_classes = NULL;
1352 /* add new function */
1353 #ifdef USE_EFL_ASSIST
1354 ea_theme_system_font_set(font_name, font_size);
1355 ea_theme_system_fonts_apply();
1358 elm_config_font_overlay_apply();
1359 elm_config_all_flush();
1364 static void __font_size_set()
1366 SETTING_TRACE_BEGIN;
1367 Eina_List *text_classes = NULL;
1368 Elm_Text_Class *etc = NULL;
1369 const Eina_List *l = NULL;
1370 int font_size = __font_size_get();
1371 char *font_name = _get_cur_font();
1373 if (font_size == -1) {
1377 text_classes = elm_config_text_classes_list_get();
1379 EINA_LIST_FOREACH(text_classes, l, etc) {
1380 elm_config_font_overlay_set(etc->name, font_name, font_size);
1383 elm_config_text_classes_list_free(text_classes);
1385 #ifdef USE_EFL_ASSIST
1386 ea_theme_system_font_set(font_name, font_size);
1387 ea_theme_system_fonts_apply();
1390 elm_config_font_overlay_apply();
1391 elm_config_all_flush();
1394 text_classes = NULL;
1398 static int __font_size_get()
1400 SETTING_TRACE_BEGIN;
1404 int vconf_value = -1;
1405 if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, &vconf_value)) {
1409 switch (vconf_value) {
1410 case SYSTEM_SETTINGS_FONT_SIZE_SMALL:
1411 font_size = SMALL_FONT_DPI;
1413 case SYSTEM_SETTINGS_FONT_SIZE_NORMAL:
1414 font_size = MIDDLE_FONT_DPI;
1416 case SYSTEM_SETTINGS_FONT_SIZE_LARGE:
1417 font_size = LARGE_FONT_DPI;
1419 case SYSTEM_SETTINGS_FONT_SIZE_HUGE:
1420 font_size = HUGE_FONT_DPI;
1422 case SYSTEM_SETTINGS_FONT_SIZE_GIANT:
1423 font_size = GIANT_FONT_DPI;
1426 font_size = MIDDLE_FONT_DPI;
1432 /*//////////////////////////////////////////////////////////////////////////////////////// */
1433 /*--------------------------------------- */
1434 int system_setting_get_locale_country(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1436 SETTING_TRACE_BEGIN;
1437 char *vconf_value = NULL;
1438 if (system_setting_vconf_get_value_string(VCONFKEY_REGIONFORMAT, &vconf_value)) {
1439 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1442 /* parsing validation */
1445 snprintf(arr, 20, vconf_value);
1447 *value = strdup(arr);
1451 return SYSTEM_SETTINGS_ERROR_NONE;
1454 int system_setting_set_locale_country(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1456 SETTING_TRACE_BEGIN;
1457 char *vconf_value = NULL;
1458 vconf_value = (char *)value;
1460 char *ext = "UTF-8";
1463 snprintf(arr, 20, "%s.%s", vconf_value, ext);
1465 if (system_setting_vconf_set_value_string(VCONFKEY_REGIONFORMAT, arr)) {
1466 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1468 return SYSTEM_SETTINGS_ERROR_NONE;
1471 int system_setting_set_changed_callback_locale_country(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1473 SETTING_TRACE_BEGIN;
1474 return system_setting_vconf_set_changed_cb(VCONFKEY_REGIONFORMAT, SYSTEM_SETTINGS_KEY_LOCALE_COUNTRY, 3, user_data);
1477 int system_setting_unset_changed_callback_locale_country(system_settings_key_e key)
1479 SETTING_TRACE_BEGIN;
1480 return system_setting_vconf_unset_changed_cb(VCONFKEY_REGIONFORMAT, 3);
1484 /*--------------------------------------- */
1485 int system_setting_get_locale_language(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1487 SETTING_TRACE_BEGIN;
1488 char *vconf_value = NULL;
1489 if (system_setting_vconf_get_value_string(VCONFKEY_LANGSET, &vconf_value)) {
1490 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1493 /* parsing validation */
1496 snprintf(arr, 20, vconf_value);
1498 *value = strdup(arr);
1501 return SYSTEM_SETTINGS_ERROR_NONE;
1504 int system_setting_set_locale_language(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1506 SETTING_TRACE_BEGIN;
1507 char *vconf_value = NULL;
1508 vconf_value = (char *)value;
1510 char *ext = "UTF-8";
1513 snprintf(arr, 20, "%s.%s", vconf_value, ext);
1515 if (system_setting_vconf_set_value_string(VCONFKEY_LANGSET, arr)) {
1516 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1518 return SYSTEM_SETTINGS_ERROR_NONE;
1521 int system_setting_set_changed_callback_locale_language(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1523 SETTING_TRACE_BEGIN;
1524 /*return system_setting_vconf_set_changed_cb(VCONFKEY_LANGSET, SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, 3, user_data ); */
1525 return system_setting_vconf_set_changed_cb(VCONFKEY_LANGSET, SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, 100, user_data);
1528 int system_setting_unset_changed_callback_locale_language(system_settings_key_e key)
1530 SETTING_TRACE_BEGIN;
1531 return system_setting_vconf_unset_changed_cb(VCONFKEY_LANGSET, 100);
1534 /*--------------------------------------- */
1535 int system_setting_get_locale_timeformat_24hour(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1537 SETTING_TRACE_BEGIN;
1540 if (system_setting_vconf_get_value_int(VCONFKEY_REGIONFORMAT_TIME1224, &vconf_value)) {
1541 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1545 if (vconf_value == VCONFKEY_TIME_FORMAT_12)
1547 else if (vconf_value == VCONFKEY_TIME_FORMAT_24)
1550 *value = (void *)ret_value;
1552 return SYSTEM_SETTINGS_ERROR_NONE;
1555 int system_setting_set_locale_timeformat_24hour(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1557 SETTING_TRACE_BEGIN;
1560 vconf_value = (bool *)value;
1563 if (system_setting_vconf_set_value_int(VCONFKEY_REGIONFORMAT_TIME1224, VCONFKEY_TIME_FORMAT_24)) {
1564 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1568 if (system_setting_vconf_set_value_int(VCONFKEY_REGIONFORMAT_TIME1224, VCONFKEY_TIME_FORMAT_12)) {
1569 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1574 return SYSTEM_SETTINGS_ERROR_NONE;
1577 int system_setting_set_changed_callback_locale_timeformat_24hour(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1579 SETTING_TRACE_BEGIN;
1580 return system_setting_vconf_set_changed_cb(VCONFKEY_REGIONFORMAT_TIME1224, SYSTEM_SETTINGS_KEY_LOCALE_TIMEFORMAT_24HOUR, 3, user_data);
1583 int system_setting_unset_changed_callback_locale_timeformat_24hour(system_settings_key_e key)
1585 SETTING_TRACE_BEGIN;
1586 return system_setting_vconf_unset_changed_cb(VCONFKEY_REGIONFORMAT_TIME1224, 3);
1589 int system_setting_get_locale_timezone(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1591 SETTING_TRACE_BEGIN;
1594 ssize_t len = readlink(SETTING_TZONE_SYMLINK_PATH, tzpath, sizeof(tzpath) - 1);
1598 SETTING_TRACE("parse error for SETTING_TZONE_SYMLINK_PATH");
1599 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1601 /* "/usr/share/zoneinfo/Asia/Seoul" */
1602 SETTING_TRACE("tzpath : %s ", &tzpath[20]);
1603 *value = strdup(&tzpath[20]);
1605 *value = vconf_get_str(VCONFKEY_SETAPPL_TIMEZONE_ID);
1607 return SYSTEM_SETTINGS_ERROR_NONE;
1610 int system_setting_set_changed_callback_locale_timezone_changed(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1612 SETTING_TRACE_BEGIN;
1613 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
1616 int system_setting_unset_changed_callback_locale_timezone_changed(system_settings_key_e key)
1618 SETTING_TRACE_BEGIN;
1619 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
1623 int system_setting_get_time_changed(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1625 SETTING_TRACE_BEGIN;
1627 cur_tick = time(NULL);
1628 *value = (void *)cur_tick;
1629 /* struct tm * localtime = time (cur_tick); */
1630 /* printf("%s\n", ctime(&cur_tick); */
1631 return SYSTEM_SETTINGS_ERROR_NONE;
1635 int system_setting_set_changed_callback_time_changed(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1637 SETTING_TRACE_BEGIN;
1638 return system_setting_vconf_set_changed_cb(VCONFKEY_SYSTEM_TIME_CHANGED, SYSTEM_SETTINGS_KEY_TIME_CHANGED, 3, user_data);
1641 int system_setting_unset_changed_callback_time_changed(system_settings_key_e key)
1643 SETTING_TRACE_BEGIN;
1644 return system_setting_vconf_unset_changed_cb(VCONFKEY_SYSTEM_TIME_CHANGED, 3);
1649 /* SYSTEM_SETTINGS_KEY_SOUND_LOCK */
1650 int system_setting_get_sound_lock(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1652 SETTING_TRACE_BEGIN;
1655 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_SOUND_LOCK_BOOL, &vconf_value)) {
1656 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1658 *value = (void *)vconf_value;
1660 return SYSTEM_SETTINGS_ERROR_NONE;
1663 int system_setting_set_changed_callback_sound_lock(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1665 SETTING_TRACE_BEGIN;
1666 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_SOUND_LOCK_BOOL, SYSTEM_SETTINGS_KEY_SOUND_LOCK, 3, user_data);
1669 int system_setting_unset_changed_callback_sound_lock(system_settings_key_e key)
1671 SETTING_TRACE_BEGIN;
1672 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_SOUND_LOCK_BOOL, 3);
1676 * a = VCONFKEY_SETAPPL_SOUND_STATUS_BOOL b = VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL
1678 * a == false, b == false --> silent mode
1679 * a == true, b == false --> sound mode
1680 * a == false, b == true --> vibration mode
1682 int system_setting_get_sound_silent_mode(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1684 SETTING_TRACE_BEGIN;
1689 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, &sound_cond)) {
1690 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1693 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, &vib_cond)) {
1694 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1697 if (sound_cond == false && vib_cond == false) {
1699 *value = (void *)vconf_value;
1701 vconf_value = false;
1702 *value = (void *)vconf_value;
1704 return SYSTEM_SETTINGS_ERROR_NONE;
1708 * a = VCONFKEY_SETAPPL_SOUND_STATUS_BOOL b = VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL
1710 * a == false, b == false --> silent mode
1711 * a == true, b == false --> sound mode
1713 int system_setting_set_sound_silent_mode(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1715 SETTING_TRACE_BEGIN;
1718 vconf_value = (bool *)value;
1720 bool vconf_sound = false;
1721 bool vconf_vib = false;
1724 vconf_sound = false;
1731 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, vconf_sound)) {
1732 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1734 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, vconf_vib)) {
1735 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1738 return SYSTEM_SETTINGS_ERROR_NONE;
1744 int system_setting_set_changed_callback_sound_silent_mode(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1746 SETTING_TRACE_BEGIN;
1747 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, SYSTEM_SETTINGS_KEY_SOUND_SILENT_MODE, 3, user_data);
1751 int system_setting_unset_changed_callback_sound_silent_mode(system_settings_key_e key)
1753 SETTING_TRACE_BEGIN;
1754 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, 3);
1757 /* SYSTEM_SETTINGS_KEY_SOUND_TOUCH */
1758 int system_setting_get_sound_touch(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1760 SETTING_TRACE_BEGIN;
1763 int ret = system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL, &vconf_value);
1764 if (ret != SYSTEM_SETTINGS_ERROR_NONE) {
1767 *value = (void *)vconf_value;
1771 int system_setting_set_changed_callback_sound_touch(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1773 SETTING_TRACE_BEGIN;
1774 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL, SYSTEM_SETTINGS_KEY_SOUND_TOUCH, 2, user_data);
1777 int system_setting_unset_changed_callback_sound_touch(system_settings_key_e key)
1779 SETTING_TRACE_BEGIN;
1780 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL, 2);
1784 /* SYSTEM_SETTINGS_KEY_SOUND_LOCK */
1785 int system_setting_get_sound_lock(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1789 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_SOUND_LOCK_BOOL, &vconf_value)) {
1790 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1792 *value = (void *)vconf_value;
1794 return SYSTEM_SETTINGS_ERROR_NONE;
1798 int system_setting_get_auto_rotation_mode(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1800 SETTING_TRACE_BEGIN;
1803 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, &vconf_value)) {
1804 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1806 *value = (void *)vconf_value;
1808 return SYSTEM_SETTINGS_ERROR_NONE;
1811 int system_setting_set_auto_rotation_mode(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1813 SETTING_TRACE_BEGIN;
1815 vconf_value = (bool *)value;
1816 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, *vconf_value)) {
1817 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1820 return SYSTEM_SETTINGS_ERROR_NONE;
1823 int system_setting_set_changed_callback_auto_rotation_mode(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1825 SETTING_TRACE_BEGIN;
1826 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, SYSTEM_SETTINGS_KEY_DISPLAY_SCREEN_ROTATION_AUTO, 2, user_data);
1829 int system_setting_unset_changed_callback_auto_rotation_mode(system_settings_key_e key)
1831 SETTING_TRACE_BEGIN;
1832 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, 2);
1835 int system_setting_get_screen_backlight_time(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1837 SETTING_TRACE_BEGIN;
1840 if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, &vconf_value)) {
1841 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1843 *value = (void *)vconf_value;
1845 return SYSTEM_SETTINGS_ERROR_NONE;
1849 int system_setting_set_screen_backlight_time(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1851 SETTING_TRACE_BEGIN;
1853 vconf_value = (int *)value;
1855 if (!(*vconf_value > 0 && *vconf_value < 600)) {
1856 SETTING_TRACE(" ERR Betweeny here 0 ~ 600");
1857 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
1860 if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, *vconf_value)) {
1861 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1864 return SYSTEM_SETTINGS_ERROR_NONE;
1867 int system_setting_set_changed_callback_screen_backlight_time(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1869 SETTING_TRACE_BEGIN;
1870 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, SYSTEM_SETTINGS_KEY_DISPLAY_SCREEN_ROTATION_AUTO, 2, user_data);
1873 int system_setting_unset_changed_callback_screen_backlight_time(system_settings_key_e key)
1875 SETTING_TRACE_BEGIN;
1876 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, 2);
1879 int system_setting_get_sound_notification(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1881 SETTING_TRACE_BEGIN;
1882 char *vconf_value = NULL;
1883 if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, &vconf_value)) {
1884 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1887 *value = vconf_value;
1888 return SYSTEM_SETTINGS_ERROR_NONE;
1891 int system_setting_set_sound_notification(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1893 SETTING_TRACE_BEGIN;
1894 char *vconf_value = NULL;
1895 vconf_value = (char *)value;
1897 int is_load = _is_file_accessible(vconf_value);
1899 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, vconf_value)) {
1900 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1903 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1906 return SYSTEM_SETTINGS_ERROR_NONE;
1909 int system_setting_set_changed_callback_sound_notification(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1911 SETTING_TRACE_BEGIN;
1912 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, SYSTEM_SETTINGS_KEY_INCOMING_CALL_RINGTONE, 0, user_data);
1915 int system_setting_unset_changed_callback_sound_notification(system_settings_key_e key)
1917 SETTING_TRACE_BEGIN;
1918 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, 0);
1921 int system_setting_get_notification_repetition_period(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1923 SETTING_TRACE_BEGIN;
1926 if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_NOTI_MSG_ALERT_REP_TYPE_INT, &vconf_value)) {
1927 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1929 *value = (void *)vconf_value;
1931 return SYSTEM_SETTINGS_ERROR_NONE;
1934 int system_setting_set_notification_repetition_period(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1936 SETTING_TRACE_BEGIN;
1938 vconf_value = (int *)value;
1940 if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_NOTI_MSG_ALERT_REP_TYPE_INT, *vconf_value)) {
1941 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1944 return SYSTEM_SETTINGS_ERROR_NONE;
1947 int system_setting_set_changed_callback_notification_repetition_period(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1949 SETTING_TRACE_BEGIN;
1950 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);
1953 int system_setting_unset_changed_callback_notification_repetition_period(system_settings_key_e key)
1955 SETTING_TRACE_BEGIN;
1956 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_ALERT_REP_TYPE_INT, 1);
1959 int system_setting_get_device_name(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1961 SETTING_TRACE_BEGIN;
1962 char *vconf_value = NULL;
1963 if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_DEVICE_NAME_STR, &vconf_value)) {
1964 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1967 *value = vconf_value;
1968 return SYSTEM_SETTINGS_ERROR_NONE;
1971 int system_setting_set_device_name(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1973 SETTING_TRACE_BEGIN;
1974 char *vconf_value = NULL;
1975 vconf_value = (char *)value;
1977 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_DEVICE_NAME_STR, vconf_value)) {
1978 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1981 return SYSTEM_SETTINGS_ERROR_NONE;
1984 int system_setting_set_changed_callback_device_name(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1986 SETTING_TRACE_BEGIN;
1987 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_DEVICE_NAME_STR, SYSTEM_SETTINGS_KEY_DEVICE_NAME, 0, user_data);
1990 int system_setting_unset_changed_callback_device_name(system_settings_key_e key)
1992 SETTING_TRACE_BEGIN;
1993 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_DEVICE_NAME_STR, 0);
1996 /*---------------------------------------------- */
1997 int system_setting_get_network_flight_mode(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1999 SETTING_TRACE_BEGIN;
2001 if (system_setting_vconf_get_value_bool(VCONFKEY_TELEPHONY_FLIGHT_MODE, &vconf_value)) {
2002 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2004 *value = (void *)vconf_value;
2006 return SYSTEM_SETTINGS_ERROR_NONE;
2009 int system_setting_set_changed_callback_network_flight_mode(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
2011 SETTING_TRACE_BEGIN;
2012 return system_setting_vconf_set_changed_cb(VCONFKEY_TELEPHONY_FLIGHT_MODE, SYSTEM_SETTINGS_KEY_NETWORK_FLIGHT_MODE, 3, user_data);
2015 int system_setting_unset_changed_callback_network_flight_mode(system_settings_key_e key)
2017 SETTING_TRACE_BEGIN;
2018 return system_setting_vconf_unset_changed_cb(VCONFKEY_TELEPHONY_FLIGHT_MODE, 3);
2021 int system_setting_get_network_wifi_notification(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
2023 SETTING_TRACE_BEGIN;
2025 if (system_setting_vconf_get_value_int(VCONFKEY_WIFI_ENABLE_QS, &vconf_value)) {
2026 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2029 bret = (vconf_value == VCONFKEY_WIFI_QS_ENABLE) ? true : false;
2031 *value = (void *)bret;
2032 return SYSTEM_SETTINGS_ERROR_NONE;
2035 int system_setting_set_changed_callback_network_wifi_notification(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
2037 SETTING_TRACE_BEGIN;
2038 return system_setting_vconf_set_changed_cb(VCONFKEY_WIFI_ENABLE_QS, SYSTEM_SETTINGS_KEY_NETWORK_WIFI_NOTIFICATION, 4, user_data);
2041 int system_setting_unset_changed_callback_network_wifi_notification(system_settings_key_e key)
2043 SETTING_TRACE_BEGIN;
2044 return system_setting_vconf_unset_changed_cb(VCONFKEY_WIFI_ENABLE_QS, 4);
2047 int system_setting_get_lock_state(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
2051 if (system_setting_vconf_get_value_int(VCONFKEY_IDLE_LOCK_STATE_READ_ONLY, &vconf_value)) {
2052 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2054 *value = (void *)vconf_value;
2056 return SYSTEM_SETTINGS_ERROR_NONE;
2059 int system_setting_set_lock_state(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
2061 SETTING_TRACE_BEGIN;
2063 vconf_value = (int *)value;
2065 if (system_setting_vconf_set_value_int(VCONFKEY_IDLE_LOCK_STATE_READ_ONLY, *vconf_value)) {
2066 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2069 return SYSTEM_SETTINGS_ERROR_NONE;
2072 int system_setting_set_changed_callback_lock_state(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
2074 return system_setting_vconf_set_changed_cb(VCONFKEY_IDLE_LOCK_STATE_READ_ONLY, SYSTEM_SETTINGS_KEY_LOCK_STATE, 4, user_data);
2077 int system_setting_unset_changed_callback_lock_state(system_settings_key_e key)
2079 return system_setting_vconf_unset_changed_cb(VCONFKEY_IDLE_LOCK_STATE_READ_ONLY, 4);