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>
46 #include <bundle_internal.h>
47 #include <app_control_internal.h>
48 #include <pkgmgr-info.h>
50 #include <system_settings.h>
51 #include <system_settings_private.h>
53 #include <tzplatform_config.h>
56 #include <efl_assist.h>
60 #define SMALL_FONT_DPI (-90)
63 #define SMALL_FONT_DPI (-80)
65 #define MIDDLE_FONT_DPI (-100)
67 #define LARGE_FONT_DPI (-110)
70 #define LARGE_FONT_DPI (-150)
72 #define HUGE_FONT_DPI (-190)
73 #define GIANT_FONT_DPI (-250)
75 #define SETTING_FONT_PRELOAD_FONT_PATH _TZ_SYS_RO_SHARE"/fonts"
76 #define SETTING_FONT_DOWNLOADED_FONT_PATH _TZ_SYS_RO_SHARE"/fonts"
78 #define SETTING_FONT_CONF_FILE _TZ_SYS_ETC"/fonts/conf.avail/99-tizen.conf"
79 #define SETTING_DEFAULT_FONT_CONF_FILE _TZ_SYS_ETC"/fonts/conf.avail/99-tizen.conf"
81 #define SETTING_STR_LEN 256
83 #define SETTING_TIME_ZONEINFO_PATH "/usr/share/zoneinfo/"
84 #define SETTING_TIME_SHARE_LOCAL_PATH "/usr/share/locale"
85 #define SETTING_TZONE_SYMLINK_PATH "/etc/localtime"
88 static char *_get_cur_font();
89 static void __font_size_set();
90 static int __font_size_get();
91 static char *_get_default_font();
93 static bool font_config_set(char *font_name);
94 static void font_config_set_notification();
97 * VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR has a path of the ringtone file which user choose
98 * @return the ringtone file path specified by user in normal case
99 * if it's not accessable, return the default ringtone path
101 int system_setting_get_incoming_call_ringtone(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
105 if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR, &vconf_value)) {
106 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
109 /* check to see if it's accessable -> OK */
110 /* no --> default ringtone path VCONFKEY_SETAPPL_CALL_RINGTONE_DEFAULT_PATH_STR */
111 int is_load = _is_file_accessible(vconf_value);
113 *value = vconf_value;
114 } else { /* not zero on errro */
115 *value = vconf_get_str(VCONFKEY_SETAPPL_CALL_RINGTONE_DEFAULT_PATH_STR);
118 /**value = vconf_value; */
119 return SYSTEM_SETTINGS_ERROR_NONE;
123 int system_setting_get_email_alert_ringtone(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
127 if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, &vconf_value)) {
128 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
131 /* check to see if it's accessable -> OK */
132 /* no --> default ringtone path VCONFKEY_SETAPPL_NOTI_RINGTONE_DEFAULT_PATH_STR */
133 int is_load = _is_file_accessible(vconf_value);
135 *value = vconf_value;
136 } else { /* not zero on errro */
137 *value = vconf_get_str(VCONFKEY_SETAPPL_NOTI_RINGTONE_DEFAULT_PATH_STR);
140 return SYSTEM_SETTINGS_ERROR_NONE;
144 int system_setting_get_wallpaper_home_screen(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
148 if (system_setting_vconf_get_value_string(VCONFKEY_BGSET, &vconf_value)) {
149 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
151 *value = vconf_value;
152 return SYSTEM_SETTINGS_ERROR_NONE;
156 int system_setting_get_wallpaper_lock_screen(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
161 if (system_setting_vconf_get_value_string(VCONFKEY_IDLE_LOCK_BGSET, &vconf_value)) {
162 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
164 *value = vconf_value;
166 return SYSTEM_SETTINGS_ERROR_NONE;
170 /* [int] vconf GET */
171 int system_setting_get_font_size(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
176 if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, &vconf_value)) {
177 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
179 *value = (void *)vconf_value;
181 return SYSTEM_SETTINGS_ERROR_NONE;
185 int system_setting_get_default_font_type(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
188 char *font_name = _get_default_font();
190 *value = (void *)font_name;
191 return SYSTEM_SETTINGS_ERROR_NONE;
193 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
197 /* [int] vconf GET */
198 int system_setting_get_font_type(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
201 char *font_name = _get_cur_font();
202 *value = (void *)font_name;
204 return SYSTEM_SETTINGS_ERROR_NONE;
208 int system_setting_get_motion_activation(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
213 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_MOTION_ACTIVATION, &vconf_value)) {
214 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
216 *value = (void *)vconf_value;
218 return SYSTEM_SETTINGS_ERROR_NONE;
221 int system_setting_get_usb_debugging_option(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
226 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_USB_DEBUG_MODE_BOOL, &vconf_value)) {
227 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
229 *value = (void *)vconf_value;
231 return SYSTEM_SETTINGS_ERROR_NONE;
234 int system_setting_get_3g_data_network(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
239 if (system_setting_vconf_get_value_bool(VCONFKEY_3G_ENABLE, &vconf_value)) {
240 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
242 *value = (void *)vconf_value;
244 return SYSTEM_SETTINGS_ERROR_NONE;
246 /*////////////////////////////////////////////////////////////////////////////////////////////////// */
250 * get current lock scren app package name (string)
252 * @return SYSTEM_SETTINGS_ERROR_LOCKSCREEN_APP_PASSWORD_MODE raise exception if current lock type is 'password'
254 int system_setting_get_lockscreen_app(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
257 char *pkg_name = NULL;
259 system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_SCREEN_LOCK_TYPE_INT, &locktype);
261 if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_3RD_LOCK_PKG_NAME_STR, &pkg_name)) {
262 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
265 if (pkg_name && strcmp(pkg_name, "com.samsung.lockscreen") == 0 && locktype == SETTING_SCREEN_LOCK_TYPE_PASSWORD) {
266 return SYSTEM_SETTINGS_ERROR_LOCKSCREEN_APP_PASSWORD_MODE;
270 return SYSTEM_SETTINGS_ERROR_NONE;
274 /*////////////////////////////////////////////////////////////////////////////////////////////////// */
276 int _is_file_accessible(const char *path)
279 int ret = access(path , R_OK);
281 SETTING_TRACE("found the file %s", path);
285 SETTING_TRACE("found the file %s --- error code : %d ", path, errno);
290 int system_setting_set_incoming_call_ringtone(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
294 vconf_value = (char *)value;
296 int ret = _is_file_accessible(vconf_value);
298 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR, vconf_value)) {
299 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
302 /* @todo add a common ret_handler */
306 return SYSTEM_SETTINGS_ERROR_NONE;
310 int system_setting_set_email_alert_ringtone(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
314 vconf_value = (char *)value;
316 int ret = _is_file_accessible(vconf_value);
318 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, vconf_value)) {
319 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
322 /*return SYSTEM_SETTINGS_ERROR_IO_ERROR;*/
323 /* @todo add a common ret_handler */
327 return SYSTEM_SETTINGS_ERROR_NONE;
331 bool __is_supported_image_type_load(char *path)
339 ee = ecore_evas_new(NULL, 0, 0, 100, 100, NULL);
340 evas = ecore_evas_get(ee);
342 Evas_Object *img = evas_object_image_add(evas);
343 evas_object_image_file_set(img, path, NULL);
344 Evas_Load_Error ret = evas_object_image_load_error_get(img);
347 if (ret == EVAS_LOAD_ERROR_NONE) {
348 SETTING_TRACE("%s - OK", path);
351 SETTING_TRACE("%s - NO", path);
359 bool __is_supported_image_type(char *path)
365 if (evas_object_image_extension_can_load_get(path))
375 #define PATH_EXT_CHECK_REG ".(jpe?g|jpg|png|gif)$"
376 bool __is_supported_image_type_by_ext(char *file_path)
380 regmatch_t str[2048 + 1];
382 if (!file_path) return false;
385 if (ret = regcomp(&fsm, PATH_EXT_CHECK_REG, REG_ICASE | REG_EXTENDED)) {
386 SETTING_TRACE("regular expresstion fail");
391 if (regexec(&fsm, file_path, strlen(file_path) + 1, str, 0) == REG_NOMATCH) {
392 /*SETTING_TRACE("FAILED - %s", file_path[i]); */
395 /*SETTING_TRACE("MATCHED - %s", file_path[i]); */
400 #ifdef TIZEN_WEARABLE
401 static int system_setting_get_extended_wallpaper_num(const char *file_path, unsigned int *num)
405 const char *find_str = "extended_wallpaper_";
408 if (!(ch = strstr(file_path, find_str))) {
409 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
411 strncpy(buffer, file_path, ch - file_path);
412 buffer[ch - file_path] = 0;
413 sprintf(buffer + (ch - file_path), "%s%s", "", ch + strlen(find_str));
415 if (!isdigit(buffer[0])) {
416 SETTING_TRACE("%s is not number", buffer);
417 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
422 return SYSTEM_SETTINGS_ERROR_NONE;
425 static int system_setting_copy_extended_wallpaper(const char *dest_file_path, const char *source_file_path)
428 if (!source_file_path || !dest_file_path) {
429 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
435 fd = open(source_file_path, O_RDONLY);
437 SETTING_TRACE("file open failed: %s", source_file_path);
438 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
442 fd2 = open(dest_file_path, O_WRONLY | O_CREAT, S_IRWXU | S_IRWXG | S_IRWXO);
444 SETTING_TRACE("file creation failed: %s", dest_file_path);
446 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
449 while (read(fd, buf, sizeof(buf) - 1) > 0) {
450 write(fd2, buf, sizeof(buf) - 1);
456 if (chmod(dest_file_path, S_IRWXU | S_IRWXG | S_IRWXO) < 0) {
457 SETTING_TRACE("chmod failed: %s", dest_file_path);
460 return SYSTEM_SETTINGS_ERROR_NONE;
463 static int system_setting_remove_oldest_extended_wallpaper()
468 char *min_image_name = NULL;
469 unsigned int min_image_num = 0;
470 unsigned int temp_image_num = 0;
473 if ((dp = opendir(_TZ_SYS_DATA"/setting/wallpaper")) == NULL) {
474 SETTING_TRACE("opendir error");
475 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
478 while ((dirp = readdir(dp))) {
479 if (!strcmp(dirp->d_name, ".") || !strcmp(dirp->d_name, ".."))
482 if (system_setting_get_extended_wallpaper_num(dirp->d_name, &temp_image_num)
483 != SYSTEM_SETTINGS_ERROR_NONE) {
484 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
487 if ((image_count == 0) || (min_image_num > temp_image_num)) {
488 min_image_num = temp_image_num;
489 min_image_name = dirp->d_name;
496 if (min_image_name) {
497 snprintf(buf, sizeof(buf) - 1, _TZ_SYS_DATA"/setting/wallpaper/%s", min_image_name);
498 if (remove(buf) < 0) { /* remove oldest image */
499 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
503 return SYSTEM_SETTINGS_ERROR_NONE;
506 static int system_setting_check_extended_wallpaper(const char *file_path)
510 if (!file_path || !strlen(file_path))
512 snprintf(buffer, 512, "%s/.bgwallpaper", tzplatform_getenv(TZ_USER_CONTENT));
513 return (strstr(file_path, buffer) != NULL);
516 #define WALLPAPER_MAX_COUNT 10
519 int system_setting_set_wallpaper_home_screen(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
523 vconf_value = (char *)value;
525 bool isok = __is_supported_image_type_load(vconf_value);
528 SETTING_TRACE("path : %s is not supported file format", vconf_value);
529 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
531 SETTING_TRACE("path : %s is SUPPORT file format", vconf_value);
534 /* error handling here */
535 if (_is_file_accessible(vconf_value) != 0)
536 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
538 if (system_setting_vconf_set_value_string(VCONFKEY_BGSET, vconf_value)) {
539 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
543 #ifdef TIZEN_WEARABLE
544 if (system_setting_check_extended_wallpaper(vconf_value)) { /* New extended wallpaper */
547 unsigned int max_image_num = 0;
548 unsigned int temp_image_num = 0;
551 if ((dp = opendir(_TZ_SYS_DATA"/setting/wallpaper")) == NULL) {
552 SETTING_TRACE("Setting - dir open error!");
553 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
556 /* Check a max number of wallpapers */
557 while ((dirp = readdir(dp))) {
558 if (!strcmp(dirp->d_name, ".") || !strcmp(dirp->d_name, ".."))
561 if (system_setting_get_extended_wallpaper_num(dirp->d_name, &temp_image_num)
562 != SYSTEM_SETTINGS_ERROR_NONE) {
565 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
568 if ((image_count == 0) || (max_image_num < temp_image_num)) {
569 max_image_num = temp_image_num;
577 /* Numbering rule: Gear is odd number */
578 max_image_num = (max_image_num % 2 == 0) ? max_image_num + 1
581 char file_name_buffer[512];
582 snprintf(file_name_buffer, sizeof(file_name_buffer) - 1,
583 _TZ_SYS_DATA"/setting/wallpaper/extended_wallpaper_%d.jpg", max_image_num);
585 /* Copy image to _TZ_SYS_DATA/setting/wallpaper/ */
586 if (system_setting_copy_extended_wallpaper(file_name_buffer, vconf_value)
587 != SYSTEM_SETTINGS_ERROR_NONE) {
588 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
591 /* remove oldest wallpaper */
592 if (image_count >= WALLPAPER_MAX_COUNT) {
593 if (system_setting_remove_oldest_extended_wallpaper()
594 != SYSTEM_SETTINGS_ERROR_NONE) {
595 remove(file_name_buffer);
596 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
600 if (system_setting_vconf_set_value_string(VCONFKEY_BGSET, file_name_buffer)) {
601 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
604 if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_WALLPAPER_CHANGED_NOTI_INT,
605 VCONFKEY_WALLPAPER_CHANGED_NOTI_GEAR)) {
606 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
609 if (system_setting_vconf_set_value_string(VCONFKEY_BGSET, vconf_value)) {
610 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
615 return SYSTEM_SETTINGS_ERROR_NONE;
618 int system_setting_set_wallpaper_lock_screen(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
622 vconf_value = (char *)value;
624 bool isok = __is_supported_image_type_load(vconf_value);
627 SETTING_TRACE("path : %s is not supported file format", vconf_value);
628 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
630 SETTING_TRACE("path : %s is SUPPORT file format", vconf_value);
633 /* error handling here */
634 if (_is_file_accessible(vconf_value) != 0)
635 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
637 if (system_setting_vconf_set_value_string(VCONFKEY_IDLE_LOCK_BGSET, vconf_value)) {
638 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
641 return SYSTEM_SETTINGS_ERROR_NONE;
644 int system_setting_set_font_size(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
648 vconf_value = (int *)value;
650 if (*vconf_value < 0 || *vconf_value > SYSTEM_SETTINGS_FONT_SIZE_GIANT) {
651 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
654 if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, *vconf_value)) {
655 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
659 return SYSTEM_SETTINGS_ERROR_NONE;
664 void *font_conf_doc_parse(char *doc_name, char *font_name)
667 xmlDocPtr doc = NULL;
668 xmlNodePtr cur = NULL;
669 xmlNodePtr cur2 = NULL;
670 xmlNodePtr cur3 = NULL;
673 doc = xmlParseFile(doc_name);
675 cur = xmlDocGetRootElement(doc);
683 if (xmlStrcmp(cur->name, (const xmlChar *)"fontconfig")) {
689 cur = cur->xmlChildrenNode;
691 Eina_Bool is_changed = EINA_FALSE;
692 while (cur != NULL) {
693 if ((!xmlStrcmp(cur->name, (const xmlChar *)"match"))) {
694 cur2 = cur->xmlChildrenNode;
695 while (cur2 != NULL) {
696 if ((!xmlStrcmp(cur2->name, (const xmlChar *)"edit"))) {
697 xmlChar *name = xmlGetProp(cur2, (const xmlChar *)"name");
698 /* if name is not 'family', break */
699 if (xmlStrcmp(name, (const xmlChar *)"family")) {
707 cur3 = cur2->xmlChildrenNode;
708 while (cur3 != NULL) {
709 if ((!xmlStrcmp(cur3->name, (const xmlChar *)"string"))) {
710 xmlNodeSetContent(cur3->xmlChildrenNode, (const xmlChar *)font_name);
711 key = xmlNodeListGetString(doc, cur3->xmlChildrenNode, 1);
714 is_changed = EINA_TRUE;
721 } else if ((!xmlStrcmp(cur->name, (const xmlChar *)"alias"))) {
722 cur2 = cur->xmlChildrenNode;
723 while (cur2 != NULL) {
724 if ((!xmlStrcmp(cur2->name, (const xmlChar *)"family"))) {
725 xmlNodeSetContent(cur2->xmlChildrenNode, (const xmlChar *)font_name);
726 key = xmlNodeListGetString(doc, cur2->xmlChildrenNode, 1);
729 is_changed = EINA_TRUE;
730 } else if ((!xmlStrcmp(cur2->name, (const xmlChar *)"prefer"))) {
731 cur3 = cur2->xmlChildrenNode;
732 while (cur3 != NULL) {
733 if ((!xmlStrcmp(cur3->name, (const xmlChar *)"family"))) {
734 xmlNodeSetContent(cur3->xmlChildrenNode, (const xmlChar *)font_name);
735 key = xmlNodeListGetString(doc, cur3->xmlChildrenNode, 1);
738 is_changed = EINA_TRUE;
760 int system_setting_set_font_type(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
763 char *font_name = NULL;
764 font_name = (char *)value;
766 /* get current font list */
767 int is_found = __is_available_font(font_name);
770 SETTING_TRACE("found font : %s ", font_name);
772 SETTING_TRACE(" NOT found font : %s ", font_name);
773 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
776 bool bsave = font_config_set(font_name);
779 SETTING_TRACE(" font type save error by font_config_set() ");
780 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
782 SETTING_TRACE(" save OK - font_config_set() ");
785 xmlDocPtr doc = (xmlDocPtr)font_conf_doc_parse(SETTING_FONT_CONF_FILE, font_name);
787 xmlSaveFormatFile(SETTING_FONT_CONF_FILE, doc, 0);
792 font_config_set_notification();
795 vconf_value = (char *)value;
797 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, vconf_value)) {
798 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
800 return SYSTEM_SETTINGS_ERROR_NONE;
803 int system_setting_set_motion_activation(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_MOTION_ACTIVATION, *vconf_value)) {
809 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
811 return SYSTEM_SETTINGS_ERROR_NONE;
814 int system_setting_set_usb_debugging_option(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
818 vconf_value = (bool *)value;
819 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_USB_DEBUG_MODE_BOOL, *vconf_value)) {
820 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
822 return SYSTEM_SETTINGS_ERROR_NONE;
826 int system_setting_set_3g_data_network(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
830 vconf_value = (bool *)value;
831 if (system_setting_vconf_set_value_bool(VCONFKEY_3G_ENABLE, *vconf_value)) {
832 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
835 return SYSTEM_SETTINGS_ERROR_NONE;
838 static int category_func(const char *name, void *user_data)
841 static char *category = "lock-screen";
842 if (name && !strcmp(name, category)) {
843 SETTING_TRACE(" SAME ");
846 SETTING_TRACE(" DIFFERENT -- %s, category -- %s ", name, category);
855 * set 'swipe type' if current lockscreen app is 'com.samsung.lockscreen'
858 int system_setting_set_lockscreen_app(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
862 vconf_value = (char *)value; /* ex) com.samsung.lockscreen */
865 pkgmgrinfo_appinfo_h handle;
866 char *apptype = NULL;
867 r = pkgmgrinfo_appinfo_get_appinfo(vconf_value, &handle);
868 if (r != PMINFO_R_OK) {
869 SETTING_TRACE("*** pkginfo failed ");
870 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
872 SETTING_TRACE("%x", handle);
875 int ret = pkgmgrinfo_appinfo_foreach_category(handle, category_func, (void *)"lock-screen");
876 if (ret != PMINFO_R_OK) {
877 pkgmgrinfo_appinfo_destroy_appinfo(handle);
878 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
881 pkgmgrinfo_appinfo_destroy_appinfo(handle);
882 /*----------------------------------------------------------------------------------- */
884 if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_SCREEN_LOCK_TYPE_INT, &locktype)) {
885 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
888 if (locktype == SETTING_SCREEN_LOCK_TYPE_PASSWORD)
889 return SYSTEM_SETTINGS_ERROR_LOCKSCREEN_APP_PASSWORD_MODE;
891 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_3RD_LOCK_PKG_NAME_STR, vconf_value)) {
892 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
895 if (vconf_value && strcmp(vconf_value, "com.samsung.lockscreen") == 0) {
896 if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_SCREEN_LOCK_TYPE_INT, SETTING_SCREEN_LOCK_TYPE_SWIPE)) {
897 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
900 return SYSTEM_SETTINGS_ERROR_NONE;
903 /*/////////////////////////////////////////////////////////////////////////////////////////////// */
906 int system_setting_set_changed_callback_incoming_call_ringtone(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
909 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR, SYSTEM_SETTINGS_KEY_INCOMING_CALL_RINGTONE, 0, user_data);
912 int system_setting_unset_changed_callback_incoming_call_ringtone(system_settings_key_e key)
915 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR, 0);
918 int system_setting_set_changed_callback_email_alert_ringtone(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
921 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, SYSTEM_SETTINGS_KEY_EMAIL_ALERT_RINGTONE, 0, user_data);
924 int system_setting_unset_changed_callback_email_alert_ringtone(system_settings_key_e key)
927 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, 0);
930 int system_setting_set_changed_callback_wallpaper_home_screen(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
933 return system_setting_vconf_set_changed_cb(VCONFKEY_BGSET, SYSTEM_SETTINGS_KEY_WALLPAPER_HOME_SCREEN, 0, user_data);
936 int system_setting_unset_changed_callback_wallpaper_home_screen(system_settings_key_e key)
939 return system_setting_vconf_unset_changed_cb(VCONFKEY_BGSET, 0);
942 int system_setting_set_changed_callback_wallpaper_lock_screen(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
945 return system_setting_vconf_set_changed_cb(VCONFKEY_IDLE_LOCK_BGSET, SYSTEM_SETTINGS_KEY_WALLPAPER_LOCK_SCREEN, 0, user_data);
948 int system_setting_unset_changed_callback_wallpaper_lock_screen(system_settings_key_e key)
951 return system_setting_vconf_unset_changed_cb(VCONFKEY_IDLE_LOCK_BGSET, 0);
954 int system_setting_set_changed_callback_font_size(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
957 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, SYSTEM_SETTINGS_KEY_FONT_SIZE, 1, user_data);
960 int system_setting_unset_changed_callback_font_size(system_settings_key_e key)
963 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, 1);
966 int system_setting_set_changed_callback_usb_debugging_option(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
969 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_USB_DEBUG_MODE_BOOL, SYSTEM_SETTINGS_KEY_USB_DEBUGGING_ENABLED, 1, user_data);
972 int system_setting_unset_changed_callback_usb_debugging_option(system_settings_key_e key)
975 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_USB_DEBUG_MODE_BOOL, 1);
978 int system_setting_set_changed_callback_3g_data_network(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
981 return system_setting_vconf_set_changed_cb(VCONFKEY_3G_ENABLE, SYSTEM_SETTINGS_KEY_3G_DATA_NETWORK_ENABLED, 1, user_data);
984 int system_setting_unset_changed_callback_3g_data_network(system_settings_key_e key)
987 return system_setting_vconf_unset_changed_cb(VCONFKEY_3G_ENABLE, 1);
990 int system_setting_set_changed_callback_lockscreen_app(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
993 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_3RD_LOCK_PKG_NAME_STR, SYSTEM_SETTINGS_KEY_LOCKSCREEN_APP, 1, user_data);
996 int system_setting_unset_changed_callback_lockscreen_app(system_settings_key_e key)
999 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_3RD_LOCK_PKG_NAME_STR, 1);
1004 * @todo need to add custom event notification method
1006 int system_setting_set_changed_callback_font_type(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1008 SETTING_TRACE_BEGIN;
1009 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, SYSTEM_SETTINGS_KEY_FONT_TYPE, 2, user_data);
1012 int system_setting_unset_changed_callback_font_type(system_settings_key_e key)
1014 SETTING_TRACE_BEGIN;
1015 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, 2);
1018 /* TODO : 2th argument, callback, is not in use. */
1019 int system_setting_set_changed_callback_motion_activation(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1021 SETTING_TRACE_BEGIN;
1022 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_MOTION_ACTIVATION, SYSTEM_SETTINGS_KEY_MOTION_ACTIVATION, 3, user_data);
1025 int system_setting_unset_changed_callback_motion_activation(system_settings_key_e key)
1027 SETTING_TRACE_BEGIN;
1028 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_MOTION_ACTIVATION, 3);
1031 static char *_get_cur_font()
1033 SETTING_TRACE_BEGIN;
1034 xmlDocPtr doc = NULL;
1035 xmlNodePtr cur = NULL;
1036 xmlNodePtr cur2 = NULL;
1037 xmlNodePtr cur3 = NULL;
1038 xmlChar *key = NULL;
1040 char *font_name = NULL;
1042 doc = xmlParseFile(SETTING_FONT_CONF_FILE);
1044 cur = xmlDocGetRootElement(doc);
1052 if (xmlStrcmp(cur->name, (const xmlChar *)"fontconfig")) {
1058 cur = cur->xmlChildrenNode;
1060 while (cur != NULL) {
1061 if ((!xmlStrcmp(cur->name, (const xmlChar *)"match"))) {
1062 cur2 = cur->xmlChildrenNode;
1063 while (cur2 != NULL) {
1064 if ((!xmlStrcmp(cur2->name, (const xmlChar *)"edit"))) {
1065 cur3 = cur2->xmlChildrenNode;
1066 while (cur3 != NULL) {
1067 if ((!xmlStrcmp(cur3->name, (const xmlChar *)"string"))) {
1068 key = xmlNodeListGetString(doc, cur3->xmlChildrenNode, 1);
1070 font_name = g_strdup((char *)key);
1091 static void font_config_set_notification()
1093 SETTING_TRACE_BEGIN;
1096 Ecore_X_Window ecore_win = ecore_x_window_root_first_get();
1097 Ecore_X_Atom atom = ecore_x_atom_get("FONT_TYPE_change");
1098 ecore_x_window_prop_string_set(ecore_win, atom, "tizen");
1102 int __is_available_font(char *font_name)
1104 SETTING_TRACE_BEGIN;
1105 FcObjectSet *os = NULL;
1106 FcFontSet *fs = NULL;
1107 FcPattern *pat = NULL;
1108 Eina_List *list = NULL;
1109 FcConfig *font_config = NULL;
1113 if (font_name == NULL)
1116 font_config = FcInitLoadConfigAndFonts();
1118 /*setting_retvm_if(font_config == NULL, NULL, "Failed: FcInitLoadConfigAndFonts"); */
1120 char *locale = setlocale(0, NULL);
1122 pat = FcPatternCreate();
1124 os = FcObjectSetBuild(FC_FAMILY, FC_FILE, FC_FAMILYLANG, (char *) 0);
1127 fs = FcFontList(font_config, pat, os);
1128 FcObjectSetDestroy(os);
1133 FcPatternDestroy(pat);
1139 SETTING_TRACE("fs->nfont = %d", fs->nfont);
1141 for (j = 0; j < fs->nfont; j++) {
1142 FcChar8 *family = NULL;
1143 FcChar8 *file = NULL;
1145 if (FcPatternGetString(fs->fonts[j], FC_FILE, 0, &file) == FcResultMatch) {
1146 int preload_path_len = strlen(SETTING_FONT_PRELOAD_FONT_PATH);
1147 int download_path_len = strlen(SETTING_FONT_DOWNLOADED_FONT_PATH);
1149 if (file && (!strncmp((const char *)file, SETTING_FONT_PRELOAD_FONT_PATH, preload_path_len)
1150 || !strncmp((const char *)file, SETTING_FONT_DOWNLOADED_FONT_PATH, download_path_len))) {
1151 char *family_result = NULL;
1152 FcChar8 *lang = NULL;
1154 if (FcPatternGetString(fs->fonts[j], FC_FAMILY, id, &family) != FcResultMatch) {
1157 if (FcPatternGetString(fs->fonts[j], FC_FAMILYLANG, id, &lang) != FcResultMatch) {
1160 family_result = (char *)family;
1162 /* Find proper family name for current locale. */
1163 while (locale && family && lang) {
1164 if (!strncmp(locale, (char *)lang, strlen((char *)lang))) {
1165 family_result = (char *)family;
1169 /* I will set english as default family language. */
1170 /* If there is no proper family language for current locale, */
1171 /* we have to show the english family name. */
1172 if (!strcmp(lang, "en")) {
1173 family_result = (char *)family;
1176 if (FcPatternGetString(fs->fonts[j], FC_FAMILY, id, &family) != FcResultMatch) {
1179 if (FcPatternGetString(fs->fonts[j], FC_FAMILYLANG, id, &lang) != FcResultMatch) {
1184 if (family_result) {
1185 SETTING_TRACE("-------- FONT - family_result = %s", (char *)family_result);
1186 if (strcmp(family_result, font_name) == 0) {
1194 FcFontSetDestroy(fs);
1197 FcConfigDestroy(font_config);
1203 static char *_get_default_font()
1205 SETTING_TRACE_BEGIN;
1206 xmlDocPtr doc = NULL;
1207 xmlNodePtr cur = NULL;
1208 xmlNodePtr cur2 = NULL;
1209 xmlNodePtr cur3 = NULL;
1210 xmlChar *key = NULL;
1211 struct _xmlAttr *properties = NULL;
1212 char *default_font_name = NULL;
1214 doc = xmlParseFile(SETTING_DEFAULT_FONT_CONF_FILE);
1216 cur = xmlDocGetRootElement(doc);
1224 if (xmlStrcmp(cur->name, (const xmlChar *)"fontconfig")) {
1230 cur = cur->xmlChildrenNode;
1232 while (cur != NULL) {
1233 if ((!xmlStrcmp(cur->name, (const xmlChar *)"match"))) {
1234 cur2 = cur->xmlChildrenNode;
1235 while (cur2 != NULL) {
1236 if ((!xmlStrcmp(cur2->name, (const xmlChar *)"edit"))) {
1237 properties = cur2->properties;
1238 /*find the "name" property*/
1239 while (NULL != properties) {
1240 if (!xmlStrcmp(properties->name, (const xmlChar *)"name")) {
1243 properties = properties->next;
1246 /*If the value of "name" property is "family", then get the child node string,
1247 it shall be the default font type*/
1248 if (NULL != properties && !xmlStrcmp(properties->children->content, (const xmlChar *)"family")) {
1249 cur3 = cur2->xmlChildrenNode;
1250 while (cur3 != NULL) {
1251 if ((!xmlStrcmp(cur3->name, (const xmlChar *)"string"))) {
1252 key = xmlNodeListGetString(doc, cur3->xmlChildrenNode, 1);
1253 default_font_name = g_strdup((char *)key);
1258 return default_font_name;
1275 static bool font_config_set(char *font_name)
1277 SETTING_TRACE_BEGIN;
1278 Eina_List *text_classes = NULL;
1279 Elm_Text_Class *etc = NULL;
1280 const Eina_List *l = NULL;
1281 Eina_List *fo_list = NULL;
1282 Elm_Font_Overlay *efo = NULL;
1284 int font_size = __font_size_get();
1287 text_classes = elm_config_text_classes_list_get();
1289 fo_list = (Eina_List *)elm_config_font_overlay_list_get();
1291 Eina_List *ll = NULL;
1292 Eina_List *l_next = NULL;
1294 Eina_Bool slp_medium_exist = EINA_FALSE;
1295 Eina_Bool slp_roman_exist = EINA_FALSE;
1296 Eina_Bool slp_bold_exist = EINA_FALSE;
1297 Eina_Bool slp_regular_exist = EINA_FALSE;
1300 Eina_Bool tizen_exist = EINA_FALSE;
1302 EINA_LIST_FOREACH_SAFE(fo_list, ll, l_next, efo) {
1303 if (!strcmp(efo->text_class, "tizen_medium")) {
1304 elm_config_font_overlay_set(efo->text_class, (const char *)font_name, efo->size);
1305 slp_medium_exist = EINA_TRUE;
1306 } else if (!strcmp(efo->text_class, "tizen_roman")) {
1307 elm_config_font_overlay_set(efo->text_class, (const char *)font_name, efo->size);
1308 slp_roman_exist = EINA_TRUE;
1309 } else if (!strcmp(efo->text_class, "tizen_bold")) {
1310 elm_config_font_overlay_set(efo->text_class, (const char *)font_name, efo->size);
1311 slp_bold_exist = EINA_TRUE;
1312 } else if (!strcmp(efo->text_class, "tizen_regular")) {
1313 elm_config_font_overlay_set(efo->text_class, (const char *)font_name, efo->size);
1314 slp_regular_exist = EINA_TRUE;
1318 if (!strcmp(efo->text_class, "tizen")) {
1319 elm_config_font_overlay_set(efo->text_class, (const char *)font_name, efo->size);
1320 tizen_exist = EINA_TRUE;
1325 /* if slp_XX do not exist, need to set them, font size is -100(100%) */
1326 if (slp_medium_exist == EINA_FALSE) {
1327 elm_config_font_overlay_set("tizen_medium", (const char *)font_name, MIDDLE_FONT_DPI);
1329 if (slp_roman_exist == EINA_FALSE) {
1330 elm_config_font_overlay_set("tizen_roman", (const char *)font_name, MIDDLE_FONT_DPI);
1332 if (slp_bold_exist == EINA_FALSE) {
1333 elm_config_font_overlay_set("tizen_bold", (const char *)font_name, MIDDLE_FONT_DPI);
1335 if (slp_regular_exist == EINA_FALSE) {
1336 elm_config_font_overlay_set("tizen_regular", (const char *)font_name, MIDDLE_FONT_DPI);
1340 if (tizen_exist == EINA_FALSE) {
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);
1347 elm_config_font_overlay_set("tizen", (const char *)font_name, MIDDLE_FONT_DPI);
1349 EINA_LIST_FOREACH(text_classes, l, etc) {
1353 EINA_LIST_FOREACH(fo_list, ll, efo) {
1354 if (!strcmp(etc->name, efo->text_class)) {
1358 elm_config_font_overlay_set(etc->name, (const char *)font_name, size);
1360 elm_config_text_classes_list_free(text_classes);
1361 text_classes = NULL;
1363 /* add new function */
1364 #ifdef USE_EFL_ASSIST
1365 ea_theme_system_font_set(font_name, font_size);
1366 ea_theme_system_fonts_apply();
1369 elm_config_font_overlay_apply();
1370 elm_config_all_flush();
1375 static void __font_size_set()
1377 SETTING_TRACE_BEGIN;
1378 Eina_List *text_classes = NULL;
1379 Elm_Text_Class *etc = NULL;
1380 const Eina_List *l = NULL;
1381 int font_size = __font_size_get();
1382 char *font_name = _get_cur_font();
1384 if (font_size == -1) {
1388 text_classes = elm_config_text_classes_list_get();
1390 EINA_LIST_FOREACH(text_classes, l, etc) {
1391 elm_config_font_overlay_set(etc->name, font_name, font_size);
1394 elm_config_text_classes_list_free(text_classes);
1396 #ifdef USE_EFL_ASSIST
1397 ea_theme_system_font_set(font_name, font_size);
1398 ea_theme_system_fonts_apply();
1401 elm_config_font_overlay_apply();
1402 elm_config_all_flush();
1405 text_classes = NULL;
1409 static int __font_size_get()
1411 SETTING_TRACE_BEGIN;
1415 int vconf_value = -1;
1416 if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, &vconf_value)) {
1420 switch (vconf_value) {
1421 case SYSTEM_SETTINGS_FONT_SIZE_SMALL:
1422 font_size = SMALL_FONT_DPI;
1424 case SYSTEM_SETTINGS_FONT_SIZE_NORMAL:
1425 font_size = MIDDLE_FONT_DPI;
1427 case SYSTEM_SETTINGS_FONT_SIZE_LARGE:
1428 font_size = LARGE_FONT_DPI;
1430 case SYSTEM_SETTINGS_FONT_SIZE_HUGE:
1431 font_size = HUGE_FONT_DPI;
1433 case SYSTEM_SETTINGS_FONT_SIZE_GIANT:
1434 font_size = GIANT_FONT_DPI;
1437 font_size = MIDDLE_FONT_DPI;
1443 /*//////////////////////////////////////////////////////////////////////////////////////// */
1444 /*--------------------------------------- */
1445 int system_setting_get_locale_country(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1447 SETTING_TRACE_BEGIN;
1448 char *vconf_value = NULL;
1449 if (system_setting_vconf_get_value_string(VCONFKEY_REGIONFORMAT, &vconf_value)) {
1450 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1453 /* parsing validation */
1456 snprintf(arr, 20, vconf_value);
1458 *value = strdup(arr);
1462 return SYSTEM_SETTINGS_ERROR_NONE;
1465 int system_setting_set_locale_country(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1467 SETTING_TRACE_BEGIN;
1468 char *vconf_value = NULL;
1469 vconf_value = (char *)value;
1471 char *ext = "UTF-8";
1474 snprintf(arr, 20, "%s.%s", vconf_value, ext);
1476 if (system_setting_vconf_set_value_string(VCONFKEY_REGIONFORMAT, arr)) {
1477 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1479 return SYSTEM_SETTINGS_ERROR_NONE;
1482 int system_setting_set_changed_callback_locale_country(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1484 SETTING_TRACE_BEGIN;
1485 return system_setting_vconf_set_changed_cb(VCONFKEY_REGIONFORMAT, SYSTEM_SETTINGS_KEY_LOCALE_COUNTRY, 3, user_data);
1488 int system_setting_unset_changed_callback_locale_country(system_settings_key_e key)
1490 SETTING_TRACE_BEGIN;
1491 return system_setting_vconf_unset_changed_cb(VCONFKEY_REGIONFORMAT, 3);
1495 /*--------------------------------------- */
1496 int system_setting_get_locale_language(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1498 SETTING_TRACE_BEGIN;
1499 char *vconf_value = NULL;
1500 if (system_setting_vconf_get_value_string(VCONFKEY_LANGSET, &vconf_value)) {
1501 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1504 /* parsing validation */
1507 snprintf(arr, 20, vconf_value);
1509 *value = strdup(arr);
1512 return SYSTEM_SETTINGS_ERROR_NONE;
1515 int system_setting_set_locale_language(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1517 SETTING_TRACE_BEGIN;
1518 char *vconf_value = NULL;
1519 vconf_value = (char *)value;
1521 char *ext = "UTF-8";
1524 snprintf(arr, 20, "%s.%s", vconf_value, ext);
1526 if (system_setting_vconf_set_value_string(VCONFKEY_LANGSET, arr)) {
1527 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1529 return SYSTEM_SETTINGS_ERROR_NONE;
1532 int system_setting_set_changed_callback_locale_language(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1534 SETTING_TRACE_BEGIN;
1535 /*return system_setting_vconf_set_changed_cb(VCONFKEY_LANGSET, SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, 3, user_data ); */
1536 return system_setting_vconf_set_changed_cb(VCONFKEY_LANGSET, SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, 100, user_data);
1539 int system_setting_unset_changed_callback_locale_language(system_settings_key_e key)
1541 SETTING_TRACE_BEGIN;
1542 return system_setting_vconf_unset_changed_cb(VCONFKEY_LANGSET, 100);
1545 /*--------------------------------------- */
1546 int system_setting_get_locale_timeformat_24hour(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1548 SETTING_TRACE_BEGIN;
1551 if (system_setting_vconf_get_value_int(VCONFKEY_REGIONFORMAT_TIME1224, &vconf_value)) {
1552 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1556 if (vconf_value == VCONFKEY_TIME_FORMAT_12)
1558 else if (vconf_value == VCONFKEY_TIME_FORMAT_24)
1561 *value = (void *)ret_value;
1563 return SYSTEM_SETTINGS_ERROR_NONE;
1566 int system_setting_set_locale_timeformat_24hour(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1568 SETTING_TRACE_BEGIN;
1571 vconf_value = (bool *)value;
1574 if (system_setting_vconf_set_value_int(VCONFKEY_REGIONFORMAT_TIME1224, VCONFKEY_TIME_FORMAT_24)) {
1575 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1579 if (system_setting_vconf_set_value_int(VCONFKEY_REGIONFORMAT_TIME1224, VCONFKEY_TIME_FORMAT_12)) {
1580 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1585 return SYSTEM_SETTINGS_ERROR_NONE;
1588 int system_setting_set_changed_callback_locale_timeformat_24hour(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1590 SETTING_TRACE_BEGIN;
1591 return system_setting_vconf_set_changed_cb(VCONFKEY_REGIONFORMAT_TIME1224, SYSTEM_SETTINGS_KEY_LOCALE_TIMEFORMAT_24HOUR, 3, user_data);
1594 int system_setting_unset_changed_callback_locale_timeformat_24hour(system_settings_key_e key)
1596 SETTING_TRACE_BEGIN;
1597 return system_setting_vconf_unset_changed_cb(VCONFKEY_REGIONFORMAT_TIME1224, 3);
1600 int system_setting_get_locale_timezone(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1602 SETTING_TRACE_BEGIN;
1605 ssize_t len = readlink(SETTING_TZONE_SYMLINK_PATH, tzpath, sizeof(tzpath) - 1);
1609 SETTING_TRACE("parse error for SETTING_TZONE_SYMLINK_PATH");
1610 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1612 /* "/usr/share/zoneinfo/Asia/Seoul" */
1613 SETTING_TRACE("tzpath : %s ", &tzpath[20]);
1614 *value = strdup(&tzpath[20]);
1616 *value = vconf_get_str(VCONFKEY_SETAPPL_TIMEZONE_ID);
1618 return SYSTEM_SETTINGS_ERROR_NONE;
1621 int system_setting_set_changed_callback_locale_timezone_changed(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1623 SETTING_TRACE_BEGIN;
1624 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
1627 int system_setting_unset_changed_callback_locale_timezone_changed(system_settings_key_e key)
1629 SETTING_TRACE_BEGIN;
1630 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
1634 int system_setting_get_time_changed(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1636 SETTING_TRACE_BEGIN;
1638 cur_tick = time(NULL);
1639 *value = (void *)cur_tick;
1640 /* struct tm * localtime = time (cur_tick); */
1641 /* printf("%s\n", ctime(&cur_tick); */
1642 return SYSTEM_SETTINGS_ERROR_NONE;
1646 int system_setting_set_changed_callback_time_changed(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1648 SETTING_TRACE_BEGIN;
1649 return system_setting_vconf_set_changed_cb(VCONFKEY_SYSTEM_TIME_CHANGED, SYSTEM_SETTINGS_KEY_TIME_CHANGED, 3, user_data);
1652 int system_setting_unset_changed_callback_time_changed(system_settings_key_e key)
1654 SETTING_TRACE_BEGIN;
1655 return system_setting_vconf_unset_changed_cb(VCONFKEY_SYSTEM_TIME_CHANGED, 3);
1660 /* SYSTEM_SETTINGS_KEY_SOUND_LOCK */
1661 int system_setting_get_sound_lock(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1663 SETTING_TRACE_BEGIN;
1666 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_SOUND_LOCK_BOOL, &vconf_value)) {
1667 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1669 *value = (void *)vconf_value;
1671 return SYSTEM_SETTINGS_ERROR_NONE;
1674 int system_setting_set_changed_callback_sound_lock(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1676 SETTING_TRACE_BEGIN;
1677 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_SOUND_LOCK_BOOL, SYSTEM_SETTINGS_KEY_SOUND_LOCK, 3, user_data);
1680 int system_setting_unset_changed_callback_sound_lock(system_settings_key_e key)
1682 SETTING_TRACE_BEGIN;
1683 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_SOUND_LOCK_BOOL, 3);
1687 * a = VCONFKEY_SETAPPL_SOUND_STATUS_BOOL b = VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL
1689 * a == false, b == false --> silent mode
1690 * a == true, b == false --> sound mode
1691 * a == false, b == true --> vibration mode
1693 int system_setting_get_sound_silent_mode(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1695 SETTING_TRACE_BEGIN;
1700 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, &sound_cond)) {
1701 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1704 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, &vib_cond)) {
1705 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1708 if (sound_cond == false && vib_cond == false) {
1710 *value = (void *)vconf_value;
1712 vconf_value = false;
1713 *value = (void *)vconf_value;
1715 return SYSTEM_SETTINGS_ERROR_NONE;
1719 * a = VCONFKEY_SETAPPL_SOUND_STATUS_BOOL b = VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL
1721 * a == false, b == false --> silent mode
1722 * a == true, b == false --> sound mode
1724 int system_setting_set_sound_silent_mode(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1726 SETTING_TRACE_BEGIN;
1729 vconf_value = (bool *)value;
1731 bool vconf_sound = false;
1732 bool vconf_vib = false;
1735 vconf_sound = false;
1742 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, vconf_sound)) {
1743 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1745 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, vconf_vib)) {
1746 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1749 return SYSTEM_SETTINGS_ERROR_NONE;
1755 int system_setting_set_changed_callback_sound_silent_mode(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1757 SETTING_TRACE_BEGIN;
1758 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, SYSTEM_SETTINGS_KEY_SOUND_SILENT_MODE, 3, user_data);
1762 int system_setting_unset_changed_callback_sound_silent_mode(system_settings_key_e key)
1764 SETTING_TRACE_BEGIN;
1765 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, 3);
1768 /* SYSTEM_SETTINGS_KEY_SOUND_TOUCH */
1769 int system_setting_get_sound_touch(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1771 SETTING_TRACE_BEGIN;
1774 int ret = system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL, &vconf_value);
1775 if (ret != SYSTEM_SETTINGS_ERROR_NONE) {
1778 *value = (void *)vconf_value;
1782 int system_setting_set_changed_callback_sound_touch(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1784 SETTING_TRACE_BEGIN;
1785 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL, SYSTEM_SETTINGS_KEY_SOUND_TOUCH, 2, user_data);
1788 int system_setting_unset_changed_callback_sound_touch(system_settings_key_e key)
1790 SETTING_TRACE_BEGIN;
1791 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL, 2);
1795 /* SYSTEM_SETTINGS_KEY_SOUND_LOCK */
1796 int system_setting_get_sound_lock(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1800 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_SOUND_LOCK_BOOL, &vconf_value)) {
1801 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1803 *value = (void *)vconf_value;
1805 return SYSTEM_SETTINGS_ERROR_NONE;
1809 int system_setting_get_auto_rotation_mode(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1811 SETTING_TRACE_BEGIN;
1814 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, &vconf_value)) {
1815 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1817 *value = (void *)vconf_value;
1819 return SYSTEM_SETTINGS_ERROR_NONE;
1822 int system_setting_set_auto_rotation_mode(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1824 SETTING_TRACE_BEGIN;
1826 vconf_value = (bool *)value;
1827 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, *vconf_value)) {
1828 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1831 return SYSTEM_SETTINGS_ERROR_NONE;
1834 int system_setting_set_changed_callback_auto_rotation_mode(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1836 SETTING_TRACE_BEGIN;
1837 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, SYSTEM_SETTINGS_KEY_DISPLAY_SCREEN_ROTATION_AUTO, 2, user_data);
1840 int system_setting_unset_changed_callback_auto_rotation_mode(system_settings_key_e key)
1842 SETTING_TRACE_BEGIN;
1843 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, 2);
1846 int system_setting_get_screen_backlight_time(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1848 SETTING_TRACE_BEGIN;
1851 if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, &vconf_value)) {
1852 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1854 *value = (void *)vconf_value;
1856 return SYSTEM_SETTINGS_ERROR_NONE;
1860 int system_setting_set_screen_backlight_time(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1862 SETTING_TRACE_BEGIN;
1864 vconf_value = (int *)value;
1866 if (!(*vconf_value > 0 && *vconf_value < 600)) {
1867 SETTING_TRACE(" ERR Betweeny here 0 ~ 600");
1868 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
1871 if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, *vconf_value)) {
1872 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1875 return SYSTEM_SETTINGS_ERROR_NONE;
1878 int system_setting_set_changed_callback_screen_backlight_time(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1880 SETTING_TRACE_BEGIN;
1881 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, SYSTEM_SETTINGS_KEY_DISPLAY_SCREEN_ROTATION_AUTO, 2, user_data);
1884 int system_setting_unset_changed_callback_screen_backlight_time(system_settings_key_e key)
1886 SETTING_TRACE_BEGIN;
1887 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, 2);
1890 int system_setting_get_sound_notification(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1892 SETTING_TRACE_BEGIN;
1893 char *vconf_value = NULL;
1894 if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, &vconf_value)) {
1895 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1898 *value = vconf_value;
1899 return SYSTEM_SETTINGS_ERROR_NONE;
1902 int system_setting_set_sound_notification(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1904 SETTING_TRACE_BEGIN;
1905 char *vconf_value = NULL;
1906 vconf_value = (char *)value;
1908 int is_load = _is_file_accessible(vconf_value);
1910 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, vconf_value)) {
1911 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1914 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1917 return SYSTEM_SETTINGS_ERROR_NONE;
1920 int system_setting_set_changed_callback_sound_notification(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1922 SETTING_TRACE_BEGIN;
1923 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, SYSTEM_SETTINGS_KEY_INCOMING_CALL_RINGTONE, 0, user_data);
1926 int system_setting_unset_changed_callback_sound_notification(system_settings_key_e key)
1928 SETTING_TRACE_BEGIN;
1929 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, 0);
1932 int system_setting_get_notification_repetition_period(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1934 SETTING_TRACE_BEGIN;
1937 if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_NOTI_MSG_ALERT_REP_TYPE_INT, &vconf_value)) {
1938 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1940 *value = (void *)vconf_value;
1942 return SYSTEM_SETTINGS_ERROR_NONE;
1945 int system_setting_set_notification_repetition_period(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1947 SETTING_TRACE_BEGIN;
1949 vconf_value = (int *)value;
1951 if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_NOTI_MSG_ALERT_REP_TYPE_INT, *vconf_value)) {
1952 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1955 return SYSTEM_SETTINGS_ERROR_NONE;
1958 int system_setting_set_changed_callback_notification_repetition_period(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1960 SETTING_TRACE_BEGIN;
1961 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);
1964 int system_setting_unset_changed_callback_notification_repetition_period(system_settings_key_e key)
1966 SETTING_TRACE_BEGIN;
1967 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_ALERT_REP_TYPE_INT, 1);
1970 int system_setting_get_device_name(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1972 SETTING_TRACE_BEGIN;
1973 char *vconf_value = NULL;
1974 if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_DEVICE_NAME_STR, &vconf_value)) {
1975 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1978 *value = vconf_value;
1979 return SYSTEM_SETTINGS_ERROR_NONE;
1982 int system_setting_set_device_name(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1984 SETTING_TRACE_BEGIN;
1985 char *vconf_value = NULL;
1986 vconf_value = (char *)value;
1988 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_DEVICE_NAME_STR, vconf_value)) {
1989 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1992 return SYSTEM_SETTINGS_ERROR_NONE;
1995 int system_setting_set_changed_callback_device_name(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1997 SETTING_TRACE_BEGIN;
1998 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_DEVICE_NAME_STR, SYSTEM_SETTINGS_KEY_DEVICE_NAME, 0, user_data);
2001 int system_setting_unset_changed_callback_device_name(system_settings_key_e key)
2003 SETTING_TRACE_BEGIN;
2004 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_DEVICE_NAME_STR, 0);
2007 /*---------------------------------------------- */
2008 int system_setting_get_network_flight_mode(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
2010 SETTING_TRACE_BEGIN;
2012 if (system_setting_vconf_get_value_bool(VCONFKEY_TELEPHONY_FLIGHT_MODE, &vconf_value)) {
2013 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2015 *value = (void *)vconf_value;
2017 return SYSTEM_SETTINGS_ERROR_NONE;
2020 int system_setting_set_changed_callback_network_flight_mode(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
2022 SETTING_TRACE_BEGIN;
2023 return system_setting_vconf_set_changed_cb(VCONFKEY_TELEPHONY_FLIGHT_MODE, SYSTEM_SETTINGS_KEY_NETWORK_FLIGHT_MODE, 3, user_data);
2026 int system_setting_unset_changed_callback_network_flight_mode(system_settings_key_e key)
2028 SETTING_TRACE_BEGIN;
2029 return system_setting_vconf_unset_changed_cb(VCONFKEY_TELEPHONY_FLIGHT_MODE, 3);
2032 int system_setting_get_network_wifi_notification(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
2034 SETTING_TRACE_BEGIN;
2036 if (system_setting_vconf_get_value_int(VCONFKEY_WIFI_ENABLE_QS, &vconf_value)) {
2037 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2040 bret = (vconf_value == VCONFKEY_WIFI_QS_ENABLE) ? true : false;
2042 *value = (void *)bret;
2043 return SYSTEM_SETTINGS_ERROR_NONE;
2046 int system_setting_set_changed_callback_network_wifi_notification(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
2048 SETTING_TRACE_BEGIN;
2049 return system_setting_vconf_set_changed_cb(VCONFKEY_WIFI_ENABLE_QS, SYSTEM_SETTINGS_KEY_NETWORK_WIFI_NOTIFICATION, 4, user_data);
2052 int system_setting_unset_changed_callback_network_wifi_notification(system_settings_key_e key)
2054 SETTING_TRACE_BEGIN;
2055 return system_setting_vconf_unset_changed_cb(VCONFKEY_WIFI_ENABLE_QS, 4);
2058 int system_setting_get_lock_state(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
2062 if (system_setting_vconf_get_value_int(VCONFKEY_IDLE_LOCK_STATE_READ_ONLY, &vconf_value)) {
2063 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2065 *value = (void *)vconf_value;
2067 return SYSTEM_SETTINGS_ERROR_NONE;
2070 int system_setting_set_lock_state(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
2072 SETTING_TRACE_BEGIN;
2074 vconf_value = (int *)value;
2076 if (system_setting_vconf_set_value_int(VCONFKEY_IDLE_LOCK_STATE_READ_ONLY, *vconf_value)) {
2077 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2080 return SYSTEM_SETTINGS_ERROR_NONE;
2083 int system_setting_set_changed_callback_lock_state(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
2085 return system_setting_vconf_set_changed_cb(VCONFKEY_IDLE_LOCK_STATE_READ_ONLY, SYSTEM_SETTINGS_KEY_LOCK_STATE, 4, user_data);
2088 int system_setting_unset_changed_callback_lock_state(system_settings_key_e key)
2090 return system_setting_vconf_unset_changed_cb(VCONFKEY_IDLE_LOCK_STATE_READ_ONLY, 4);