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>
50 #include <tzplatform_config.h>
53 #include <efl_assist.h>
57 #define SMALL_FONT_DPI (-90)
60 #define SMALL_FONT_DPI (-80)
62 #define MIDDLE_FONT_DPI (-100)
64 #define LARGE_FONT_DPI (-110)
67 #define LARGE_FONT_DPI (-150)
69 #define HUGE_FONT_DPI (-190)
70 #define GIANT_FONT_DPI (-250)
72 #define SETTING_FONT_PRELOAD_FONT_PATH _TZ_SYS_RO_SHARE"/fonts"
73 #define SETTING_FONT_DOWNLOADED_FONT_PATH _TZ_SYS_RO_SHARE"/fonts"
75 #define SETTING_FONT_CONF_FILE _TZ_SYS_ETC"/fonts/conf.avail/99-tizen.conf"
76 #define SETTING_DEFAULT_FONT_CONF_FILE _TZ_SYS_ETC"/fonts/conf.avail/99-tizen.conf"
78 #define SETTING_STR_LEN 256
80 #define SETTING_TIME_ZONEINFO_PATH "/usr/share/zoneinfo/"
81 #define SETTING_TIME_SHARE_LOCAL_PATH "/usr/share/locale"
82 #define SETTING_TZONE_SYMLINK_PATH "/etc/localtime"
85 static char *_get_cur_font();
86 static void __font_size_set();
87 static int __font_size_get();
88 static char *_get_default_font();
90 static bool font_config_set(char *font_name);
91 static void font_config_set_notification();
92 int _is_file_accessible(const char *path);
93 int __is_available_font(char *font_name);
96 * VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR has a path of the ringtone file which user choose
97 * @return the ringtone file path specified by user in normal case
98 * if it's not accessable, return the default ringtone path
100 int system_setting_get_incoming_call_ringtone(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
104 if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR, &vconf_value)) {
105 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
108 /* check to see if it's accessable -> OK */
109 /* no --> default ringtone path VCONFKEY_SETAPPL_CALL_RINGTONE_DEFAULT_PATH_STR */
110 int is_load = _is_file_accessible(vconf_value);
112 *value = vconf_value;
113 } else { /* not zero on errro */
114 *value = vconf_get_str(VCONFKEY_SETAPPL_CALL_RINGTONE_DEFAULT_PATH_STR);
117 /**value = vconf_value; */
118 return SYSTEM_SETTINGS_ERROR_NONE;
122 int system_setting_get_email_alert_ringtone(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
126 if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, &vconf_value)) {
127 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
130 /* check to see if it's accessable -> OK */
131 /* no --> default ringtone path VCONFKEY_SETAPPL_NOTI_RINGTONE_DEFAULT_PATH_STR */
132 int is_load = _is_file_accessible(vconf_value);
134 *value = vconf_value;
135 } else { /* not zero on errro */
136 *value = vconf_get_str(VCONFKEY_SETAPPL_NOTI_RINGTONE_DEFAULT_PATH_STR);
139 return SYSTEM_SETTINGS_ERROR_NONE;
143 int system_setting_get_wallpaper_home_screen(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
147 if (system_setting_vconf_get_value_string(VCONFKEY_BGSET, &vconf_value)) {
148 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
150 *value = vconf_value;
151 return SYSTEM_SETTINGS_ERROR_NONE;
155 int system_setting_get_wallpaper_lock_screen(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
160 if (system_setting_vconf_get_value_string(VCONFKEY_IDLE_LOCK_BGSET, &vconf_value)) {
161 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
163 *value = vconf_value;
165 return SYSTEM_SETTINGS_ERROR_NONE;
169 /* [int] vconf GET */
170 int system_setting_get_font_size(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
175 if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, &vconf_value)) {
176 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
178 *value = (void *)vconf_value;
180 return SYSTEM_SETTINGS_ERROR_NONE;
184 int system_setting_get_default_font_type(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
187 char *font_name = _get_default_font();
189 *value = (void *)font_name;
190 return SYSTEM_SETTINGS_ERROR_NONE;
192 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
196 /* [int] vconf GET */
197 int system_setting_get_font_type(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
200 char *font_name = _get_cur_font();
201 *value = (void *)font_name;
203 return SYSTEM_SETTINGS_ERROR_NONE;
207 int system_setting_get_motion_activation(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
212 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_MOTION_ACTIVATION, &vconf_value)) {
213 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
215 *value = (void *)vconf_value;
217 return SYSTEM_SETTINGS_ERROR_NONE;
220 int system_setting_get_usb_debugging_option(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
225 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_USB_DEBUG_MODE_BOOL, &vconf_value)) {
226 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
228 *value = (void *)vconf_value;
230 return SYSTEM_SETTINGS_ERROR_NONE;
233 int system_setting_get_3g_data_network(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
238 if (system_setting_vconf_get_value_bool(VCONFKEY_3G_ENABLE, &vconf_value)) {
239 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
241 *value = (void *)vconf_value;
243 return SYSTEM_SETTINGS_ERROR_NONE;
245 /*////////////////////////////////////////////////////////////////////////////////////////////////// */
249 * get current lock scren app package name (string)
251 * @return SYSTEM_SETTINGS_ERROR_LOCKSCREEN_APP_PASSWORD_MODE raise exception if current lock type is 'password'
253 int system_setting_get_lockscreen_app(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
256 char *pkg_name = NULL;
258 system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_SCREEN_LOCK_TYPE_INT, &locktype);
260 if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_3RD_LOCK_PKG_NAME_STR, &pkg_name)) {
261 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
264 if (pkg_name && strcmp(pkg_name, "com.samsung.lockscreen") == 0 && locktype == SETTING_SCREEN_LOCK_TYPE_PASSWORD) {
265 return SYSTEM_SETTINGS_ERROR_LOCKSCREEN_APP_PASSWORD_MODE;
269 return SYSTEM_SETTINGS_ERROR_NONE;
273 /*////////////////////////////////////////////////////////////////////////////////////////////////// */
275 int _is_file_accessible(const char *path)
278 int ret = access(path , R_OK);
280 SETTING_TRACE("found the file %s", path);
284 SETTING_TRACE("found the file %s --- error code : %d ", path, errno);
289 int system_setting_set_incoming_call_ringtone(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
293 vconf_value = (char *)value;
295 int ret = _is_file_accessible(vconf_value);
297 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR, vconf_value)) {
298 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
301 /* @todo add a common ret_handler */
305 return SYSTEM_SETTINGS_ERROR_NONE;
309 int system_setting_set_email_alert_ringtone(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
313 vconf_value = (char *)value;
315 int ret = _is_file_accessible(vconf_value);
317 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, vconf_value)) {
318 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
321 /*return SYSTEM_SETTINGS_ERROR_IO_ERROR;*/
322 /* @todo add a common ret_handler */
326 return SYSTEM_SETTINGS_ERROR_NONE;
330 bool __is_supported_image_type_load(char *path)
338 ee = ecore_evas_new(NULL, 0, 0, 100, 100, NULL);
339 evas = ecore_evas_get(ee);
341 Evas_Object *img = evas_object_image_add(evas);
342 evas_object_image_file_set(img, path, NULL);
343 Evas_Load_Error ret = evas_object_image_load_error_get(img);
346 if (ret == EVAS_LOAD_ERROR_NONE) {
347 SETTING_TRACE("%s - OK", path);
350 SETTING_TRACE("%s - NO", path);
358 bool __is_supported_image_type(char *path)
364 if (evas_object_image_extension_can_load_get(path))
374 #define PATH_EXT_CHECK_REG ".(jpe?g|jpg|png|gif)$"
375 bool __is_supported_image_type_by_ext(char *file_path)
379 regmatch_t str[2048 + 1];
381 if (!file_path) return false;
384 if ((ret = regcomp(&fsm, PATH_EXT_CHECK_REG, REG_ICASE | REG_EXTENDED))) {
385 SETTING_TRACE("regular expresstion fail");
390 if (regexec(&fsm, file_path, strlen(file_path) + 1, str, 0) == REG_NOMATCH) {
391 /*SETTING_TRACE("FAILED - %s", file_path[i]); */
394 /*SETTING_TRACE("MATCHED - %s", file_path[i]); */
399 #ifdef TIZEN_WEARABLE
400 static int system_setting_get_extended_wallpaper_num(const char *file_path, unsigned int *num)
404 const char *find_str = "extended_wallpaper_";
407 if (!(ch = strstr(file_path, find_str))) {
408 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
410 strncpy(buffer, file_path, ch - file_path);
411 buffer[ch - file_path] = 0;
412 sprintf(buffer + (ch - file_path), "%s%s", "", ch + strlen(find_str));
414 if (!isdigit(buffer[0])) {
415 SETTING_TRACE("%s is not number", buffer);
416 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
421 return SYSTEM_SETTINGS_ERROR_NONE;
424 static int system_setting_copy_extended_wallpaper(const char *dest_file_path, const char *source_file_path)
427 if (!source_file_path || !dest_file_path) {
428 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
434 fd = open(source_file_path, O_RDONLY);
436 SETTING_TRACE("file open failed: %s", source_file_path);
437 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
441 fd2 = open(dest_file_path, O_WRONLY | O_CREAT, S_IRWXU | S_IRWXG | S_IRWXO);
443 SETTING_TRACE("file creation failed: %s", dest_file_path);
445 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
448 while (read(fd, buf, sizeof(buf) - 1) > 0) {
449 write(fd2, buf, sizeof(buf) - 1);
455 if (chmod(dest_file_path, S_IRWXU | S_IRWXG | S_IRWXO) < 0) {
456 SETTING_TRACE("chmod failed: %s", dest_file_path);
459 return SYSTEM_SETTINGS_ERROR_NONE;
462 static int system_setting_remove_oldest_extended_wallpaper()
467 char *min_image_name = NULL;
468 unsigned int min_image_num = 0;
469 unsigned int temp_image_num = 0;
472 if ((dp = opendir(_TZ_SYS_DATA"/setting/wallpaper")) == NULL) {
473 SETTING_TRACE("opendir error");
474 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
477 while ((dirp = readdir(dp))) {
478 if (!strcmp(dirp->d_name, ".") || !strcmp(dirp->d_name, ".."))
481 if (system_setting_get_extended_wallpaper_num(dirp->d_name, &temp_image_num)
482 != SYSTEM_SETTINGS_ERROR_NONE) {
483 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
486 if ((image_count == 0) || (min_image_num > temp_image_num)) {
487 min_image_num = temp_image_num;
488 min_image_name = dirp->d_name;
495 if (min_image_name) {
496 snprintf(buf, sizeof(buf) - 1, _TZ_SYS_DATA"/setting/wallpaper/%s", min_image_name);
497 if (remove(buf) < 0) { /* remove oldest image */
498 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
502 return SYSTEM_SETTINGS_ERROR_NONE;
505 static int system_setting_check_extended_wallpaper(const char *file_path)
509 if (!file_path || !strlen(file_path))
511 snprintf(buffer, 512, "%s/.bgwallpaper", tzplatform_getenv(TZ_USER_CONTENT));
512 return (strstr(file_path, buffer) != NULL);
515 #define WALLPAPER_MAX_COUNT 10
518 int system_setting_set_wallpaper_home_screen(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
522 vconf_value = (char *)value;
524 bool isok = __is_supported_image_type_load(vconf_value);
527 SETTING_TRACE("path : %s is not supported file format", vconf_value);
528 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
530 SETTING_TRACE("path : %s is SUPPORT file format", vconf_value);
533 /* error handling here */
534 if (_is_file_accessible(vconf_value) != 0)
535 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
537 if (system_setting_vconf_set_value_string(VCONFKEY_BGSET, vconf_value)) {
538 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
542 #ifdef TIZEN_WEARABLE
543 if (system_setting_check_extended_wallpaper(vconf_value)) { /* New extended wallpaper */
546 unsigned int max_image_num = 0;
547 unsigned int temp_image_num = 0;
550 if ((dp = opendir(_TZ_SYS_DATA"/setting/wallpaper")) == NULL) {
551 SETTING_TRACE("Setting - dir open error!");
552 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
555 /* Check a max number of wallpapers */
556 while ((dirp = readdir(dp))) {
557 if (!strcmp(dirp->d_name, ".") || !strcmp(dirp->d_name, ".."))
560 if (system_setting_get_extended_wallpaper_num(dirp->d_name, &temp_image_num)
561 != SYSTEM_SETTINGS_ERROR_NONE) {
564 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
567 if ((image_count == 0) || (max_image_num < temp_image_num)) {
568 max_image_num = temp_image_num;
576 /* Numbering rule: Gear is odd number */
577 max_image_num = (max_image_num % 2 == 0) ? max_image_num + 1
580 char file_name_buffer[512];
581 snprintf(file_name_buffer, sizeof(file_name_buffer) - 1,
582 _TZ_SYS_DATA"/setting/wallpaper/extended_wallpaper_%d.jpg", max_image_num);
584 /* Copy image to _TZ_SYS_DATA/setting/wallpaper/ */
585 if (system_setting_copy_extended_wallpaper(file_name_buffer, vconf_value)
586 != SYSTEM_SETTINGS_ERROR_NONE) {
587 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
590 /* remove oldest wallpaper */
591 if (image_count >= WALLPAPER_MAX_COUNT) {
592 if (system_setting_remove_oldest_extended_wallpaper()
593 != SYSTEM_SETTINGS_ERROR_NONE) {
594 remove(file_name_buffer);
595 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
599 if (system_setting_vconf_set_value_string(VCONFKEY_BGSET, file_name_buffer)) {
600 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
603 if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_WALLPAPER_CHANGED_NOTI_INT,
604 VCONFKEY_WALLPAPER_CHANGED_NOTI_GEAR)) {
605 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
608 if (system_setting_vconf_set_value_string(VCONFKEY_BGSET, vconf_value)) {
609 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
614 return SYSTEM_SETTINGS_ERROR_NONE;
617 int system_setting_set_wallpaper_lock_screen(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
621 vconf_value = (char *)value;
623 bool isok = __is_supported_image_type_load(vconf_value);
626 SETTING_TRACE("path : %s is not supported file format", vconf_value);
627 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
629 SETTING_TRACE("path : %s is SUPPORT file format", vconf_value);
632 /* error handling here */
633 if (_is_file_accessible(vconf_value) != 0)
634 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
636 if (system_setting_vconf_set_value_string(VCONFKEY_IDLE_LOCK_BGSET, vconf_value)) {
637 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
640 return SYSTEM_SETTINGS_ERROR_NONE;
643 int system_setting_set_font_size(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
647 vconf_value = (int *)value;
649 if (*vconf_value < 0 || *vconf_value > SYSTEM_SETTINGS_FONT_SIZE_GIANT) {
650 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
653 if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, *vconf_value)) {
654 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
658 return SYSTEM_SETTINGS_ERROR_NONE;
663 void *font_conf_doc_parse(char *doc_name, char *font_name)
666 xmlDocPtr doc = NULL;
667 xmlNodePtr cur = NULL;
668 xmlNodePtr cur2 = NULL;
669 xmlNodePtr cur3 = NULL;
672 doc = xmlParseFile(doc_name);
674 cur = xmlDocGetRootElement(doc);
682 if (xmlStrcmp(cur->name, (const xmlChar *)"fontconfig")) {
688 cur = cur->xmlChildrenNode;
690 Eina_Bool is_changed = EINA_FALSE;
691 while (cur != NULL) {
692 if ((!xmlStrcmp(cur->name, (const xmlChar *)"match"))) {
693 cur2 = cur->xmlChildrenNode;
694 while (cur2 != NULL) {
695 if ((!xmlStrcmp(cur2->name, (const xmlChar *)"edit"))) {
696 xmlChar *name = xmlGetProp(cur2, (const xmlChar *)"name");
697 /* if name is not 'family', break */
698 if (xmlStrcmp(name, (const xmlChar *)"family")) {
706 cur3 = cur2->xmlChildrenNode;
707 while (cur3 != NULL) {
708 if ((!xmlStrcmp(cur3->name, (const xmlChar *)"string"))) {
709 xmlNodeSetContent(cur3->xmlChildrenNode, (const xmlChar *)font_name);
710 key = xmlNodeListGetString(doc, cur3->xmlChildrenNode, 1);
713 is_changed = EINA_TRUE;
720 } else if ((!xmlStrcmp(cur->name, (const xmlChar *)"alias"))) {
721 cur2 = cur->xmlChildrenNode;
722 while (cur2 != NULL) {
723 if ((!xmlStrcmp(cur2->name, (const xmlChar *)"family"))) {
724 xmlNodeSetContent(cur2->xmlChildrenNode, (const xmlChar *)font_name);
725 key = xmlNodeListGetString(doc, cur2->xmlChildrenNode, 1);
728 is_changed = EINA_TRUE;
729 } else if ((!xmlStrcmp(cur2->name, (const xmlChar *)"prefer"))) {
730 cur3 = cur2->xmlChildrenNode;
731 while (cur3 != NULL) {
732 if ((!xmlStrcmp(cur3->name, (const xmlChar *)"family"))) {
733 xmlNodeSetContent(cur3->xmlChildrenNode, (const xmlChar *)font_name);
734 key = xmlNodeListGetString(doc, cur3->xmlChildrenNode, 1);
737 is_changed = EINA_TRUE;
759 int system_setting_set_font_type(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
762 char *font_name = NULL;
763 font_name = (char *)value;
765 /* get current font list */
766 int is_found = __is_available_font(font_name);
769 SETTING_TRACE("found font : %s ", font_name);
771 SETTING_TRACE(" NOT found font : %s ", font_name);
772 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
775 bool bsave = font_config_set(font_name);
778 SETTING_TRACE(" font type save error by font_config_set() ");
779 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
781 SETTING_TRACE(" save OK - font_config_set() ");
784 xmlDocPtr doc = (xmlDocPtr)font_conf_doc_parse(SETTING_FONT_CONF_FILE, font_name);
786 xmlSaveFormatFile(SETTING_FONT_CONF_FILE, doc, 0);
791 font_config_set_notification();
794 vconf_value = (char *)value;
796 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, vconf_value)) {
797 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
799 return SYSTEM_SETTINGS_ERROR_NONE;
802 int system_setting_set_motion_activation(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
806 vconf_value = (bool *)value;
807 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_MOTION_ACTIVATION, *vconf_value)) {
808 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
810 return SYSTEM_SETTINGS_ERROR_NONE;
813 int system_setting_set_usb_debugging_option(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
817 vconf_value = (bool *)value;
818 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_USB_DEBUG_MODE_BOOL, *vconf_value)) {
819 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
821 return SYSTEM_SETTINGS_ERROR_NONE;
825 int system_setting_set_3g_data_network(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
829 vconf_value = (bool *)value;
830 if (system_setting_vconf_set_value_bool(VCONFKEY_3G_ENABLE, *vconf_value)) {
831 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
834 return SYSTEM_SETTINGS_ERROR_NONE;
837 static int category_func(const char *name, void *user_data)
840 static char *category = "lock-screen";
841 if (name && !strcmp(name, category)) {
842 SETTING_TRACE(" SAME ");
845 SETTING_TRACE(" DIFFERENT -- %s, category -- %s ", name, category);
854 * set 'swipe type' if current lockscreen app is 'com.samsung.lockscreen'
857 int system_setting_set_lockscreen_app(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
861 vconf_value = (char *)value; /* ex) com.samsung.lockscreen */
864 pkgmgrinfo_appinfo_h handle;
865 r = pkgmgrinfo_appinfo_get_appinfo(vconf_value, &handle);
866 if (r != PMINFO_R_OK) {
867 SETTING_TRACE("*** pkginfo failed ");
868 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
870 SETTING_TRACE("%x", handle);
873 int ret = pkgmgrinfo_appinfo_foreach_category(handle, category_func, (void *)"lock-screen");
874 if (ret != PMINFO_R_OK) {
875 pkgmgrinfo_appinfo_destroy_appinfo(handle);
876 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
879 pkgmgrinfo_appinfo_destroy_appinfo(handle);
880 /*----------------------------------------------------------------------------------- */
882 if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_SCREEN_LOCK_TYPE_INT, &locktype)) {
883 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
886 if (locktype == SETTING_SCREEN_LOCK_TYPE_PASSWORD)
887 return SYSTEM_SETTINGS_ERROR_LOCKSCREEN_APP_PASSWORD_MODE;
889 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_3RD_LOCK_PKG_NAME_STR, vconf_value)) {
890 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
893 if (vconf_value && strcmp(vconf_value, "com.samsung.lockscreen") == 0) {
894 if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_SCREEN_LOCK_TYPE_INT, SETTING_SCREEN_LOCK_TYPE_SWIPE)) {
895 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
898 return SYSTEM_SETTINGS_ERROR_NONE;
901 /*/////////////////////////////////////////////////////////////////////////////////////////////// */
904 int system_setting_set_changed_callback_incoming_call_ringtone(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
907 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR, SYSTEM_SETTINGS_KEY_INCOMING_CALL_RINGTONE, 0, user_data);
910 int system_setting_unset_changed_callback_incoming_call_ringtone(system_settings_key_e key)
913 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR, 0);
916 int system_setting_set_changed_callback_email_alert_ringtone(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
919 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, SYSTEM_SETTINGS_KEY_EMAIL_ALERT_RINGTONE, 0, user_data);
922 int system_setting_unset_changed_callback_email_alert_ringtone(system_settings_key_e key)
925 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, 0);
928 int system_setting_set_changed_callback_wallpaper_home_screen(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
931 return system_setting_vconf_set_changed_cb(VCONFKEY_BGSET, SYSTEM_SETTINGS_KEY_WALLPAPER_HOME_SCREEN, 0, user_data);
934 int system_setting_unset_changed_callback_wallpaper_home_screen(system_settings_key_e key)
937 return system_setting_vconf_unset_changed_cb(VCONFKEY_BGSET, 0);
940 int system_setting_set_changed_callback_wallpaper_lock_screen(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
943 return system_setting_vconf_set_changed_cb(VCONFKEY_IDLE_LOCK_BGSET, SYSTEM_SETTINGS_KEY_WALLPAPER_LOCK_SCREEN, 0, user_data);
946 int system_setting_unset_changed_callback_wallpaper_lock_screen(system_settings_key_e key)
949 return system_setting_vconf_unset_changed_cb(VCONFKEY_IDLE_LOCK_BGSET, 0);
952 int system_setting_set_changed_callback_font_size(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
955 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, SYSTEM_SETTINGS_KEY_FONT_SIZE, 1, user_data);
958 int system_setting_unset_changed_callback_font_size(system_settings_key_e key)
961 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, 1);
964 int system_setting_set_changed_callback_usb_debugging_option(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
967 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_USB_DEBUG_MODE_BOOL, SYSTEM_SETTINGS_KEY_USB_DEBUGGING_ENABLED, 1, user_data);
970 int system_setting_unset_changed_callback_usb_debugging_option(system_settings_key_e key)
973 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_USB_DEBUG_MODE_BOOL, 1);
976 int system_setting_set_changed_callback_3g_data_network(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
979 return system_setting_vconf_set_changed_cb(VCONFKEY_3G_ENABLE, SYSTEM_SETTINGS_KEY_3G_DATA_NETWORK_ENABLED, 1, user_data);
982 int system_setting_unset_changed_callback_3g_data_network(system_settings_key_e key)
985 return system_setting_vconf_unset_changed_cb(VCONFKEY_3G_ENABLE, 1);
988 int system_setting_set_changed_callback_lockscreen_app(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
991 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_3RD_LOCK_PKG_NAME_STR, SYSTEM_SETTINGS_KEY_LOCKSCREEN_APP, 1, user_data);
994 int system_setting_unset_changed_callback_lockscreen_app(system_settings_key_e key)
997 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_3RD_LOCK_PKG_NAME_STR, 1);
1002 * @todo need to add custom event notification method
1004 int system_setting_set_changed_callback_font_type(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1006 SETTING_TRACE_BEGIN;
1007 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, SYSTEM_SETTINGS_KEY_FONT_TYPE, 2, user_data);
1010 int system_setting_unset_changed_callback_font_type(system_settings_key_e key)
1012 SETTING_TRACE_BEGIN;
1013 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, 2);
1016 /* TODO : 2th argument, callback, is not in use. */
1017 int system_setting_set_changed_callback_motion_activation(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1019 SETTING_TRACE_BEGIN;
1020 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_MOTION_ACTIVATION, SYSTEM_SETTINGS_KEY_MOTION_ACTIVATION, 3, user_data);
1023 int system_setting_unset_changed_callback_motion_activation(system_settings_key_e key)
1025 SETTING_TRACE_BEGIN;
1026 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_MOTION_ACTIVATION, 3);
1029 static char *_get_cur_font()
1031 SETTING_TRACE_BEGIN;
1032 xmlDocPtr doc = NULL;
1033 xmlNodePtr cur = NULL;
1034 xmlNodePtr cur2 = NULL;
1035 xmlNodePtr cur3 = NULL;
1036 xmlChar *key = NULL;
1038 char *font_name = NULL;
1040 doc = xmlParseFile(SETTING_FONT_CONF_FILE);
1042 cur = xmlDocGetRootElement(doc);
1050 if (xmlStrcmp(cur->name, (const xmlChar *)"fontconfig")) {
1056 cur = cur->xmlChildrenNode;
1058 while (cur != NULL) {
1059 if ((!xmlStrcmp(cur->name, (const xmlChar *)"match"))) {
1060 cur2 = cur->xmlChildrenNode;
1061 while (cur2 != NULL) {
1062 if ((!xmlStrcmp(cur2->name, (const xmlChar *)"edit"))) {
1063 cur3 = cur2->xmlChildrenNode;
1064 while (cur3 != NULL) {
1065 if ((!xmlStrcmp(cur3->name, (const xmlChar *)"string"))) {
1066 key = xmlNodeListGetString(doc, cur3->xmlChildrenNode, 1);
1068 font_name = g_strdup((char *)key);
1089 static void font_config_set_notification()
1091 SETTING_TRACE_BEGIN;
1094 Ecore_X_Window ecore_win = ecore_x_window_root_first_get();
1095 Ecore_X_Atom atom = ecore_x_atom_get("FONT_TYPE_change");
1096 ecore_x_window_prop_string_set(ecore_win, atom, "tizen");
1100 int __is_available_font(char *font_name)
1102 SETTING_TRACE_BEGIN;
1103 FcObjectSet *os = NULL;
1104 FcFontSet *fs = NULL;
1105 FcPattern *pat = NULL;
1106 FcConfig *font_config = NULL;
1110 if (font_name == NULL)
1113 font_config = FcInitLoadConfigAndFonts();
1115 /*setting_retvm_if(font_config == NULL, NULL, "Failed: FcInitLoadConfigAndFonts"); */
1117 char *locale = setlocale(0, NULL);
1119 pat = FcPatternCreate();
1121 os = FcObjectSetBuild(FC_FAMILY, FC_FILE, FC_FAMILYLANG, (char *) 0);
1124 fs = FcFontList(font_config, pat, os);
1125 FcObjectSetDestroy(os);
1130 FcPatternDestroy(pat);
1136 SETTING_TRACE("fs->nfont = %d", fs->nfont);
1138 for (j = 0; j < fs->nfont; j++) {
1139 FcChar8 *family = NULL;
1140 FcChar8 *file = NULL;
1142 if (FcPatternGetString(fs->fonts[j], FC_FILE, 0, &file) == FcResultMatch) {
1143 int preload_path_len = strlen(SETTING_FONT_PRELOAD_FONT_PATH);
1144 int download_path_len = strlen(SETTING_FONT_DOWNLOADED_FONT_PATH);
1146 if (file && (!strncmp((const char *)file, SETTING_FONT_PRELOAD_FONT_PATH, preload_path_len)
1147 || !strncmp((const char *)file, SETTING_FONT_DOWNLOADED_FONT_PATH, download_path_len))) {
1148 char *family_result = NULL;
1149 FcChar8 *lang = NULL;
1151 if (FcPatternGetString(fs->fonts[j], FC_FAMILY, id, &family) != FcResultMatch) {
1154 if (FcPatternGetString(fs->fonts[j], FC_FAMILYLANG, id, &lang) != FcResultMatch) {
1157 family_result = (char *)family;
1159 /* Find proper family name for current locale. */
1160 while (locale && family && lang) {
1161 if (!strncmp(locale, (char *)lang, strlen((char *)lang))) {
1162 family_result = (char *)family;
1166 /* I will set english as default family language. */
1167 /* If there is no proper family language for current locale, */
1168 /* we have to show the english family name. */
1169 if (!strcmp((char*)lang, "en")) {
1170 family_result = (char *)family;
1173 if (FcPatternGetString(fs->fonts[j], FC_FAMILY, id, &family) != FcResultMatch) {
1176 if (FcPatternGetString(fs->fonts[j], FC_FAMILYLANG, id, &lang) != FcResultMatch) {
1181 if (family_result) {
1182 SETTING_TRACE("-------- FONT - family_result = %s", (char *)family_result);
1183 if (strcmp(family_result, font_name) == 0) {
1191 FcFontSetDestroy(fs);
1194 FcConfigDestroy(font_config);
1200 static char *_get_default_font()
1202 SETTING_TRACE_BEGIN;
1203 xmlDocPtr doc = NULL;
1204 xmlNodePtr cur = NULL;
1205 xmlNodePtr cur2 = NULL;
1206 xmlNodePtr cur3 = NULL;
1207 xmlChar *key = NULL;
1208 struct _xmlAttr *properties = NULL;
1209 char *default_font_name = NULL;
1211 doc = xmlParseFile(SETTING_DEFAULT_FONT_CONF_FILE);
1213 cur = xmlDocGetRootElement(doc);
1221 if (xmlStrcmp(cur->name, (const xmlChar *)"fontconfig")) {
1227 cur = cur->xmlChildrenNode;
1229 while (cur != NULL) {
1230 if ((!xmlStrcmp(cur->name, (const xmlChar *)"match"))) {
1231 cur2 = cur->xmlChildrenNode;
1232 while (cur2 != NULL) {
1233 if ((!xmlStrcmp(cur2->name, (const xmlChar *)"edit"))) {
1234 properties = cur2->properties;
1235 /*find the "name" property*/
1236 while (NULL != properties) {
1237 if (!xmlStrcmp(properties->name, (const xmlChar *)"name")) {
1240 properties = properties->next;
1243 /*If the value of "name" property is "family", then get the child node string,
1244 it shall be the default font type*/
1245 if (NULL != properties && !xmlStrcmp(properties->children->content, (const xmlChar *)"family")) {
1246 cur3 = cur2->xmlChildrenNode;
1247 while (cur3 != NULL) {
1248 if ((!xmlStrcmp(cur3->name, (const xmlChar *)"string"))) {
1249 key = xmlNodeListGetString(doc, cur3->xmlChildrenNode, 1);
1250 default_font_name = g_strdup((char *)key);
1255 return default_font_name;
1272 static bool font_config_set(char *font_name)
1274 SETTING_TRACE_BEGIN;
1275 Eina_List *text_classes = NULL;
1276 Elm_Text_Class *etc = NULL;
1277 const Eina_List *l = NULL;
1278 Eina_List *fo_list = NULL;
1279 Elm_Font_Overlay *efo = NULL;
1281 int font_size = __font_size_get();
1284 text_classes = elm_config_text_classes_list_get();
1286 fo_list = (Eina_List *)elm_config_font_overlay_list_get();
1288 Eina_List *ll = NULL;
1289 Eina_List *l_next = NULL;
1291 Eina_Bool slp_medium_exist = EINA_FALSE;
1292 Eina_Bool slp_roman_exist = EINA_FALSE;
1293 Eina_Bool slp_bold_exist = EINA_FALSE;
1294 Eina_Bool slp_regular_exist = EINA_FALSE;
1297 Eina_Bool tizen_exist = EINA_FALSE;
1299 EINA_LIST_FOREACH_SAFE(fo_list, ll, l_next, efo) {
1300 if (!strcmp(efo->text_class, "tizen_medium")) {
1301 elm_config_font_overlay_set(efo->text_class, (const char *)font_name, efo->size);
1302 slp_medium_exist = EINA_TRUE;
1303 } else if (!strcmp(efo->text_class, "tizen_roman")) {
1304 elm_config_font_overlay_set(efo->text_class, (const char *)font_name, efo->size);
1305 slp_roman_exist = EINA_TRUE;
1306 } else if (!strcmp(efo->text_class, "tizen_bold")) {
1307 elm_config_font_overlay_set(efo->text_class, (const char *)font_name, efo->size);
1308 slp_bold_exist = EINA_TRUE;
1309 } else if (!strcmp(efo->text_class, "tizen_regular")) {
1310 elm_config_font_overlay_set(efo->text_class, (const char *)font_name, efo->size);
1311 slp_regular_exist = EINA_TRUE;
1315 if (!strcmp(efo->text_class, "tizen")) {
1316 elm_config_font_overlay_set(efo->text_class, (const char *)font_name, efo->size);
1317 tizen_exist = EINA_TRUE;
1322 /* if slp_XX do not exist, need to set them, font size is -100(100%) */
1323 if (slp_medium_exist == EINA_FALSE) {
1324 elm_config_font_overlay_set("tizen_medium", (const char *)font_name, MIDDLE_FONT_DPI);
1326 if (slp_roman_exist == EINA_FALSE) {
1327 elm_config_font_overlay_set("tizen_roman", (const char *)font_name, MIDDLE_FONT_DPI);
1329 if (slp_bold_exist == EINA_FALSE) {
1330 elm_config_font_overlay_set("tizen_bold", (const char *)font_name, MIDDLE_FONT_DPI);
1332 if (slp_regular_exist == EINA_FALSE) {
1333 elm_config_font_overlay_set("tizen_regular", (const char *)font_name, MIDDLE_FONT_DPI);
1337 if (tizen_exist == EINA_FALSE) {
1338 elm_config_font_overlay_set("tizen", (const char *)font_name, MIDDLE_FONT_DPI);
1341 elm_config_font_overlay_set("tizen", (const char *)font_name, MIDDLE_FONT_DPI);
1344 elm_config_font_overlay_set("tizen", (const char *)font_name, MIDDLE_FONT_DPI);
1346 EINA_LIST_FOREACH(text_classes, l, etc) {
1350 EINA_LIST_FOREACH(fo_list, ll, efo) {
1351 if (!strcmp(etc->name, efo->text_class)) {
1355 elm_config_font_overlay_set(etc->name, (const char *)font_name, size);
1357 elm_config_text_classes_list_free(text_classes);
1358 text_classes = NULL;
1360 /* add new function */
1361 #ifdef USE_EFL_ASSIST
1362 ea_theme_system_font_set(font_name, font_size);
1363 ea_theme_system_fonts_apply();
1366 elm_config_font_overlay_apply();
1367 elm_config_all_flush();
1372 static void __font_size_set()
1374 SETTING_TRACE_BEGIN;
1375 Eina_List *text_classes = NULL;
1376 Elm_Text_Class *etc = NULL;
1377 const Eina_List *l = NULL;
1378 int font_size = __font_size_get();
1379 char *font_name = _get_cur_font();
1381 if (font_size == -1) {
1385 text_classes = elm_config_text_classes_list_get();
1387 EINA_LIST_FOREACH(text_classes, l, etc) {
1388 elm_config_font_overlay_set(etc->name, font_name, font_size);
1391 elm_config_text_classes_list_free(text_classes);
1393 #ifdef USE_EFL_ASSIST
1394 ea_theme_system_font_set(font_name, font_size);
1395 ea_theme_system_fonts_apply();
1398 elm_config_font_overlay_apply();
1399 elm_config_all_flush();
1402 text_classes = NULL;
1406 static int __font_size_get()
1408 SETTING_TRACE_BEGIN;
1411 int vconf_value = -1;
1412 if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, &vconf_value)) {
1416 switch (vconf_value) {
1417 case SYSTEM_SETTINGS_FONT_SIZE_SMALL:
1418 font_size = SMALL_FONT_DPI;
1420 case SYSTEM_SETTINGS_FONT_SIZE_NORMAL:
1421 font_size = MIDDLE_FONT_DPI;
1423 case SYSTEM_SETTINGS_FONT_SIZE_LARGE:
1424 font_size = LARGE_FONT_DPI;
1426 case SYSTEM_SETTINGS_FONT_SIZE_HUGE:
1427 font_size = HUGE_FONT_DPI;
1429 case SYSTEM_SETTINGS_FONT_SIZE_GIANT:
1430 font_size = GIANT_FONT_DPI;
1433 font_size = MIDDLE_FONT_DPI;
1439 /*//////////////////////////////////////////////////////////////////////////////////////// */
1440 /*--------------------------------------- */
1441 int system_setting_get_locale_country(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1443 SETTING_TRACE_BEGIN;
1444 char *vconf_value = NULL;
1445 if (system_setting_vconf_get_value_string(VCONFKEY_REGIONFORMAT, &vconf_value)) {
1446 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1449 /* parsing validation */
1452 snprintf(arr, 20, "%s", vconf_value);
1454 *value = strdup(arr);
1458 return SYSTEM_SETTINGS_ERROR_NONE;
1461 int system_setting_set_locale_country(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1463 SETTING_TRACE_BEGIN;
1464 char *vconf_value = NULL;
1465 vconf_value = (char *)value;
1467 char *ext = "UTF-8";
1470 snprintf(arr, 20, "%s.%s", vconf_value, ext);
1472 if (system_setting_vconf_set_value_string(VCONFKEY_REGIONFORMAT, arr)) {
1473 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1475 return SYSTEM_SETTINGS_ERROR_NONE;
1478 int system_setting_set_changed_callback_locale_country(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1480 SETTING_TRACE_BEGIN;
1481 return system_setting_vconf_set_changed_cb(VCONFKEY_REGIONFORMAT, SYSTEM_SETTINGS_KEY_LOCALE_COUNTRY, 3, user_data);
1484 int system_setting_unset_changed_callback_locale_country(system_settings_key_e key)
1486 SETTING_TRACE_BEGIN;
1487 return system_setting_vconf_unset_changed_cb(VCONFKEY_REGIONFORMAT, 3);
1491 /*--------------------------------------- */
1492 int system_setting_get_locale_language(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1494 SETTING_TRACE_BEGIN;
1495 char *vconf_value = NULL;
1496 if (system_setting_vconf_get_value_string(VCONFKEY_LANGSET, &vconf_value)) {
1497 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1500 /* parsing validation */
1503 snprintf(arr, 20, "%s", vconf_value);
1505 *value = strdup(arr);
1508 return SYSTEM_SETTINGS_ERROR_NONE;
1511 int system_setting_set_locale_language(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1513 SETTING_TRACE_BEGIN;
1514 char *vconf_value = NULL;
1515 vconf_value = (char *)value;
1517 char *ext = "UTF-8";
1520 snprintf(arr, 20, "%s.%s", vconf_value, ext);
1522 if (system_setting_vconf_set_value_string(VCONFKEY_LANGSET, arr)) {
1523 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1525 return SYSTEM_SETTINGS_ERROR_NONE;
1528 int system_setting_set_changed_callback_locale_language(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1530 SETTING_TRACE_BEGIN;
1531 /*return system_setting_vconf_set_changed_cb(VCONFKEY_LANGSET, SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, 3, user_data ); */
1532 return system_setting_vconf_set_changed_cb(VCONFKEY_LANGSET, SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, 100, user_data);
1535 int system_setting_unset_changed_callback_locale_language(system_settings_key_e key)
1537 SETTING_TRACE_BEGIN;
1538 return system_setting_vconf_unset_changed_cb(VCONFKEY_LANGSET, 100);
1541 /*--------------------------------------- */
1542 int system_setting_get_locale_timeformat_24hour(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1544 SETTING_TRACE_BEGIN;
1547 if (system_setting_vconf_get_value_int(VCONFKEY_REGIONFORMAT_TIME1224, &vconf_value)) {
1548 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1551 bool ret_value = true;
1552 if (vconf_value == VCONFKEY_TIME_FORMAT_12)
1554 else if (vconf_value == VCONFKEY_TIME_FORMAT_24)
1557 *value = (void *)ret_value;
1559 return SYSTEM_SETTINGS_ERROR_NONE;
1562 int system_setting_set_locale_timeformat_24hour(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1564 SETTING_TRACE_BEGIN;
1567 vconf_value = (bool *)value;
1570 if (system_setting_vconf_set_value_int(VCONFKEY_REGIONFORMAT_TIME1224, VCONFKEY_TIME_FORMAT_24)) {
1571 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1575 if (system_setting_vconf_set_value_int(VCONFKEY_REGIONFORMAT_TIME1224, VCONFKEY_TIME_FORMAT_12)) {
1576 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1581 return SYSTEM_SETTINGS_ERROR_NONE;
1584 int system_setting_set_changed_callback_locale_timeformat_24hour(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1586 SETTING_TRACE_BEGIN;
1587 return system_setting_vconf_set_changed_cb(VCONFKEY_REGIONFORMAT_TIME1224, SYSTEM_SETTINGS_KEY_LOCALE_TIMEFORMAT_24HOUR, 3, user_data);
1590 int system_setting_unset_changed_callback_locale_timeformat_24hour(system_settings_key_e key)
1592 SETTING_TRACE_BEGIN;
1593 return system_setting_vconf_unset_changed_cb(VCONFKEY_REGIONFORMAT_TIME1224, 3);
1596 int system_setting_get_locale_timezone(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1598 SETTING_TRACE_BEGIN;
1601 ssize_t len = readlink(SETTING_TZONE_SYMLINK_PATH, tzpath, sizeof(tzpath) - 1);
1605 SETTING_TRACE("parse error for SETTING_TZONE_SYMLINK_PATH");
1606 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1608 /* "/usr/share/zoneinfo/Asia/Seoul" */
1609 SETTING_TRACE("tzpath : %s ", &tzpath[20]);
1610 *value = strdup(&tzpath[20]);
1612 *value = vconf_get_str(VCONFKEY_SETAPPL_TIMEZONE_ID);
1614 return SYSTEM_SETTINGS_ERROR_NONE;
1617 int system_setting_set_changed_callback_locale_timezone_changed(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1619 SETTING_TRACE_BEGIN;
1620 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
1623 int system_setting_unset_changed_callback_locale_timezone_changed(system_settings_key_e key)
1625 SETTING_TRACE_BEGIN;
1626 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
1630 int system_setting_get_time_changed(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1632 SETTING_TRACE_BEGIN;
1634 cur_tick = time(NULL);
1635 *value = (void *)cur_tick;
1636 /* struct tm * localtime = time (cur_tick); */
1637 /* printf("%s\n", ctime(&cur_tick); */
1638 return SYSTEM_SETTINGS_ERROR_NONE;
1642 int system_setting_set_changed_callback_time_changed(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1644 SETTING_TRACE_BEGIN;
1645 return system_setting_vconf_set_changed_cb(VCONFKEY_SYSTEM_TIME_CHANGED, SYSTEM_SETTINGS_KEY_TIME_CHANGED, 3, user_data);
1648 int system_setting_unset_changed_callback_time_changed(system_settings_key_e key)
1650 SETTING_TRACE_BEGIN;
1651 return system_setting_vconf_unset_changed_cb(VCONFKEY_SYSTEM_TIME_CHANGED, 3);
1656 /* SYSTEM_SETTINGS_KEY_SOUND_LOCK */
1657 int system_setting_get_sound_lock(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1659 SETTING_TRACE_BEGIN;
1662 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_SOUND_LOCK_BOOL, &vconf_value)) {
1663 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1665 *value = (void *)vconf_value;
1667 return SYSTEM_SETTINGS_ERROR_NONE;
1670 int system_setting_set_changed_callback_sound_lock(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1672 SETTING_TRACE_BEGIN;
1673 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_SOUND_LOCK_BOOL, SYSTEM_SETTINGS_KEY_SOUND_LOCK, 3, user_data);
1676 int system_setting_unset_changed_callback_sound_lock(system_settings_key_e key)
1678 SETTING_TRACE_BEGIN;
1679 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_SOUND_LOCK_BOOL, 3);
1683 * a = VCONFKEY_SETAPPL_SOUND_STATUS_BOOL b = VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL
1685 * a == false, b == false --> silent mode
1686 * a == true, b == false --> sound mode
1687 * a == false, b == true --> vibration mode
1689 int system_setting_get_sound_silent_mode(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1691 SETTING_TRACE_BEGIN;
1696 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, &sound_cond)) {
1697 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1700 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, &vib_cond)) {
1701 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1704 if (sound_cond == false && vib_cond == false) {
1706 *value = (void *)vconf_value;
1708 vconf_value = false;
1709 *value = (void *)vconf_value;
1711 return SYSTEM_SETTINGS_ERROR_NONE;
1715 * a = VCONFKEY_SETAPPL_SOUND_STATUS_BOOL b = VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL
1717 * a == false, b == false --> silent mode
1718 * a == true, b == false --> sound mode
1720 int system_setting_set_sound_silent_mode(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1722 SETTING_TRACE_BEGIN;
1725 vconf_value = (bool *)value;
1727 bool vconf_sound = false;
1728 bool vconf_vib = false;
1731 vconf_sound = false;
1738 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, vconf_sound)) {
1739 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1741 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, vconf_vib)) {
1742 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1745 return SYSTEM_SETTINGS_ERROR_NONE;
1751 int system_setting_set_changed_callback_sound_silent_mode(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1753 SETTING_TRACE_BEGIN;
1754 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, SYSTEM_SETTINGS_KEY_SOUND_SILENT_MODE, 3, user_data);
1758 int system_setting_unset_changed_callback_sound_silent_mode(system_settings_key_e key)
1760 SETTING_TRACE_BEGIN;
1761 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, 3);
1764 /* SYSTEM_SETTINGS_KEY_SOUND_TOUCH */
1765 int system_setting_get_sound_touch(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1767 SETTING_TRACE_BEGIN;
1770 int ret = system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL, &vconf_value);
1771 if (ret != SYSTEM_SETTINGS_ERROR_NONE) {
1774 *value = (void *)vconf_value;
1778 int system_setting_set_changed_callback_sound_touch(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1780 SETTING_TRACE_BEGIN;
1781 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL, SYSTEM_SETTINGS_KEY_SOUND_TOUCH, 2, user_data);
1784 int system_setting_unset_changed_callback_sound_touch(system_settings_key_e key)
1786 SETTING_TRACE_BEGIN;
1787 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL, 2);
1791 /* SYSTEM_SETTINGS_KEY_SOUND_LOCK */
1792 int system_setting_get_sound_lock(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1796 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_SOUND_LOCK_BOOL, &vconf_value)) {
1797 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1799 *value = (void *)vconf_value;
1801 return SYSTEM_SETTINGS_ERROR_NONE;
1805 int system_setting_get_auto_rotation_mode(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1807 SETTING_TRACE_BEGIN;
1810 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, &vconf_value)) {
1811 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1813 *value = (void *)vconf_value;
1815 return SYSTEM_SETTINGS_ERROR_NONE;
1818 int system_setting_set_auto_rotation_mode(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1820 SETTING_TRACE_BEGIN;
1822 vconf_value = (bool *)value;
1823 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, *vconf_value)) {
1824 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1827 return SYSTEM_SETTINGS_ERROR_NONE;
1830 int system_setting_set_changed_callback_auto_rotation_mode(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1832 SETTING_TRACE_BEGIN;
1833 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, SYSTEM_SETTINGS_KEY_DISPLAY_SCREEN_ROTATION_AUTO, 2, user_data);
1836 int system_setting_unset_changed_callback_auto_rotation_mode(system_settings_key_e key)
1838 SETTING_TRACE_BEGIN;
1839 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, 2);
1842 int system_setting_get_screen_backlight_time(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1844 SETTING_TRACE_BEGIN;
1847 if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, &vconf_value)) {
1848 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1850 *value = (void *)vconf_value;
1852 return SYSTEM_SETTINGS_ERROR_NONE;
1856 int system_setting_set_screen_backlight_time(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1858 SETTING_TRACE_BEGIN;
1860 vconf_value = (int *)value;
1862 if (!(*vconf_value > 0 && *vconf_value < 600)) {
1863 SETTING_TRACE(" ERR Betweeny here 0 ~ 600");
1864 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
1867 if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, *vconf_value)) {
1868 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1871 return SYSTEM_SETTINGS_ERROR_NONE;
1874 int system_setting_set_changed_callback_screen_backlight_time(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1876 SETTING_TRACE_BEGIN;
1877 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, SYSTEM_SETTINGS_KEY_DISPLAY_SCREEN_ROTATION_AUTO, 2, user_data);
1880 int system_setting_unset_changed_callback_screen_backlight_time(system_settings_key_e key)
1882 SETTING_TRACE_BEGIN;
1883 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, 2);
1886 int system_setting_get_sound_notification(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1888 SETTING_TRACE_BEGIN;
1889 char *vconf_value = NULL;
1890 if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, &vconf_value)) {
1891 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1894 *value = vconf_value;
1895 return SYSTEM_SETTINGS_ERROR_NONE;
1898 int system_setting_set_sound_notification(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1900 SETTING_TRACE_BEGIN;
1901 char *vconf_value = NULL;
1902 vconf_value = (char *)value;
1904 int is_load = _is_file_accessible(vconf_value);
1906 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, vconf_value)) {
1907 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1910 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1913 return SYSTEM_SETTINGS_ERROR_NONE;
1916 int system_setting_set_changed_callback_sound_notification(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1918 SETTING_TRACE_BEGIN;
1919 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, SYSTEM_SETTINGS_KEY_INCOMING_CALL_RINGTONE, 0, user_data);
1922 int system_setting_unset_changed_callback_sound_notification(system_settings_key_e key)
1924 SETTING_TRACE_BEGIN;
1925 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, 0);
1928 int system_setting_get_notification_repetition_period(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1930 SETTING_TRACE_BEGIN;
1933 if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_NOTI_MSG_ALERT_REP_TYPE_INT, &vconf_value)) {
1934 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1936 *value = (void *)vconf_value;
1938 return SYSTEM_SETTINGS_ERROR_NONE;
1941 int system_setting_set_notification_repetition_period(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1943 SETTING_TRACE_BEGIN;
1945 vconf_value = (int *)value;
1947 if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_NOTI_MSG_ALERT_REP_TYPE_INT, *vconf_value)) {
1948 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1951 return SYSTEM_SETTINGS_ERROR_NONE;
1954 int system_setting_set_changed_callback_notification_repetition_period(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1956 SETTING_TRACE_BEGIN;
1957 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);
1960 int system_setting_unset_changed_callback_notification_repetition_period(system_settings_key_e key)
1962 SETTING_TRACE_BEGIN;
1963 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_ALERT_REP_TYPE_INT, 1);
1966 int system_setting_get_device_name(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1968 SETTING_TRACE_BEGIN;
1969 char *vconf_value = NULL;
1970 if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_DEVICE_NAME_STR, &vconf_value)) {
1971 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1974 *value = vconf_value;
1975 return SYSTEM_SETTINGS_ERROR_NONE;
1978 int system_setting_set_device_name(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1980 SETTING_TRACE_BEGIN;
1981 char *vconf_value = NULL;
1982 vconf_value = (char *)value;
1984 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_DEVICE_NAME_STR, vconf_value)) {
1985 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1988 return SYSTEM_SETTINGS_ERROR_NONE;
1991 int system_setting_set_changed_callback_device_name(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1993 SETTING_TRACE_BEGIN;
1994 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_DEVICE_NAME_STR, SYSTEM_SETTINGS_KEY_DEVICE_NAME, 0, user_data);
1997 int system_setting_unset_changed_callback_device_name(system_settings_key_e key)
1999 SETTING_TRACE_BEGIN;
2000 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_DEVICE_NAME_STR, 0);
2003 /*---------------------------------------------- */
2004 int system_setting_get_network_flight_mode(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
2006 SETTING_TRACE_BEGIN;
2008 if (system_setting_vconf_get_value_bool(VCONFKEY_TELEPHONY_FLIGHT_MODE, &vconf_value)) {
2009 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2011 *value = (void *)vconf_value;
2013 return SYSTEM_SETTINGS_ERROR_NONE;
2016 int system_setting_set_changed_callback_network_flight_mode(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
2018 SETTING_TRACE_BEGIN;
2019 return system_setting_vconf_set_changed_cb(VCONFKEY_TELEPHONY_FLIGHT_MODE, SYSTEM_SETTINGS_KEY_NETWORK_FLIGHT_MODE, 3, user_data);
2022 int system_setting_unset_changed_callback_network_flight_mode(system_settings_key_e key)
2024 SETTING_TRACE_BEGIN;
2025 return system_setting_vconf_unset_changed_cb(VCONFKEY_TELEPHONY_FLIGHT_MODE, 3);
2028 int system_setting_get_network_wifi_notification(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
2030 SETTING_TRACE_BEGIN;
2032 if (system_setting_vconf_get_value_int(VCONFKEY_WIFI_ENABLE_QS, &vconf_value)) {
2033 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2036 bret = (vconf_value == VCONFKEY_WIFI_QS_ENABLE) ? true : false;
2038 *value = (void *)bret;
2039 return SYSTEM_SETTINGS_ERROR_NONE;
2042 int system_setting_set_changed_callback_network_wifi_notification(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
2044 SETTING_TRACE_BEGIN;
2045 return system_setting_vconf_set_changed_cb(VCONFKEY_WIFI_ENABLE_QS, SYSTEM_SETTINGS_KEY_NETWORK_WIFI_NOTIFICATION, 4, user_data);
2048 int system_setting_unset_changed_callback_network_wifi_notification(system_settings_key_e key)
2050 SETTING_TRACE_BEGIN;
2051 return system_setting_vconf_unset_changed_cb(VCONFKEY_WIFI_ENABLE_QS, 4);
2054 int system_setting_get_lock_state(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
2058 if (system_setting_vconf_get_value_int(VCONFKEY_IDLE_LOCK_STATE_READ_ONLY, &vconf_value)) {
2059 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2061 *value = (void *)vconf_value;
2063 return SYSTEM_SETTINGS_ERROR_NONE;
2066 int system_setting_set_lock_state(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
2068 SETTING_TRACE_BEGIN;
2070 vconf_value = (int *)value;
2072 if (system_setting_vconf_set_value_int(VCONFKEY_IDLE_LOCK_STATE_READ_ONLY, *vconf_value)) {
2073 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2076 return SYSTEM_SETTINGS_ERROR_NONE;
2079 int system_setting_set_changed_callback_lock_state(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
2081 return system_setting_vconf_set_changed_cb(VCONFKEY_IDLE_LOCK_STATE_READ_ONLY, SYSTEM_SETTINGS_KEY_LOCK_STATE, 4, user_data);
2084 int system_setting_unset_changed_callback_lock_state(system_settings_key_e key)
2086 return system_setting_vconf_unset_changed_cb(VCONFKEY_IDLE_LOCK_STATE_READ_ONLY, 4);