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();
95 int _is_file_accessible(const char *path);
96 int __is_available_font(char *font_name);
99 * VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR has a path of the ringtone file which user choose
100 * @return the ringtone file path specified by user in normal case
101 * if it's not accessable, return the default ringtone path
103 int system_setting_get_incoming_call_ringtone(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
107 if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR, &vconf_value)) {
108 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
111 /* check to see if it's accessable -> OK */
112 /* no --> default ringtone path VCONFKEY_SETAPPL_CALL_RINGTONE_DEFAULT_PATH_STR */
113 int is_load = _is_file_accessible(vconf_value);
115 *value = vconf_value;
116 } else { /* not zero on errro */
117 *value = vconf_get_str(VCONFKEY_SETAPPL_CALL_RINGTONE_DEFAULT_PATH_STR);
120 /**value = vconf_value; */
121 return SYSTEM_SETTINGS_ERROR_NONE;
125 int system_setting_get_email_alert_ringtone(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
129 if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, &vconf_value)) {
130 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
133 /* check to see if it's accessable -> OK */
134 /* no --> default ringtone path VCONFKEY_SETAPPL_NOTI_RINGTONE_DEFAULT_PATH_STR */
135 int is_load = _is_file_accessible(vconf_value);
137 *value = vconf_value;
138 } else { /* not zero on errro */
139 *value = vconf_get_str(VCONFKEY_SETAPPL_NOTI_RINGTONE_DEFAULT_PATH_STR);
142 return SYSTEM_SETTINGS_ERROR_NONE;
146 int system_setting_get_wallpaper_home_screen(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
150 if (system_setting_vconf_get_value_string(VCONFKEY_BGSET, &vconf_value)) {
151 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
153 *value = vconf_value;
154 return SYSTEM_SETTINGS_ERROR_NONE;
158 int system_setting_get_wallpaper_lock_screen(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
163 if (system_setting_vconf_get_value_string(VCONFKEY_IDLE_LOCK_BGSET, &vconf_value)) {
164 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
166 *value = vconf_value;
168 return SYSTEM_SETTINGS_ERROR_NONE;
172 /* [int] vconf GET */
173 int system_setting_get_font_size(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
178 if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, &vconf_value)) {
179 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
181 *value = (void *)vconf_value;
183 return SYSTEM_SETTINGS_ERROR_NONE;
187 int system_setting_get_default_font_type(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
190 char *font_name = _get_default_font();
192 *value = (void *)font_name;
193 return SYSTEM_SETTINGS_ERROR_NONE;
195 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
199 /* [int] vconf GET */
200 int system_setting_get_font_type(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
203 char *font_name = _get_cur_font();
204 *value = (void *)font_name;
206 return SYSTEM_SETTINGS_ERROR_NONE;
210 int system_setting_get_motion_activation(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
215 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_MOTION_ACTIVATION, &vconf_value)) {
216 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
218 *value = (void *)vconf_value;
220 return SYSTEM_SETTINGS_ERROR_NONE;
223 int system_setting_get_usb_debugging_option(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
228 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_USB_DEBUG_MODE_BOOL, &vconf_value)) {
229 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
231 *value = (void *)vconf_value;
233 return SYSTEM_SETTINGS_ERROR_NONE;
236 int system_setting_get_3g_data_network(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
241 if (system_setting_vconf_get_value_bool(VCONFKEY_3G_ENABLE, &vconf_value)) {
242 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
244 *value = (void *)vconf_value;
246 return SYSTEM_SETTINGS_ERROR_NONE;
248 /*////////////////////////////////////////////////////////////////////////////////////////////////// */
252 * get current lock scren app package name (string)
254 * @return SYSTEM_SETTINGS_ERROR_LOCKSCREEN_APP_PASSWORD_MODE raise exception if current lock type is 'password'
256 int system_setting_get_lockscreen_app(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
259 char *pkg_name = NULL;
261 system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_SCREEN_LOCK_TYPE_INT, &locktype);
263 if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_3RD_LOCK_PKG_NAME_STR, &pkg_name)) {
264 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
267 if (pkg_name && strcmp(pkg_name, "com.samsung.lockscreen") == 0 && locktype == SETTING_SCREEN_LOCK_TYPE_PASSWORD) {
268 return SYSTEM_SETTINGS_ERROR_LOCKSCREEN_APP_PASSWORD_MODE;
272 return SYSTEM_SETTINGS_ERROR_NONE;
276 /*////////////////////////////////////////////////////////////////////////////////////////////////// */
278 int _is_file_accessible(const char *path)
281 int ret = access(path , R_OK);
283 SETTING_TRACE("found the file %s", path);
287 SETTING_TRACE("found the file %s --- error code : %d ", path, errno);
292 int system_setting_set_incoming_call_ringtone(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
296 vconf_value = (char *)value;
298 int ret = _is_file_accessible(vconf_value);
300 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR, vconf_value)) {
301 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
304 /* @todo add a common ret_handler */
308 return SYSTEM_SETTINGS_ERROR_NONE;
312 int system_setting_set_email_alert_ringtone(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
316 vconf_value = (char *)value;
318 int ret = _is_file_accessible(vconf_value);
320 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, vconf_value)) {
321 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
324 /*return SYSTEM_SETTINGS_ERROR_IO_ERROR;*/
325 /* @todo add a common ret_handler */
329 return SYSTEM_SETTINGS_ERROR_NONE;
333 bool __is_supported_image_type_load(char *path)
341 ee = ecore_evas_new(NULL, 0, 0, 100, 100, NULL);
342 evas = ecore_evas_get(ee);
344 Evas_Object *img = evas_object_image_add(evas);
345 evas_object_image_file_set(img, path, NULL);
346 Evas_Load_Error ret = evas_object_image_load_error_get(img);
349 if (ret == EVAS_LOAD_ERROR_NONE) {
350 SETTING_TRACE("%s - OK", path);
353 SETTING_TRACE("%s - NO", path);
361 bool __is_supported_image_type(char *path)
367 if (evas_object_image_extension_can_load_get(path))
377 #define PATH_EXT_CHECK_REG ".(jpe?g|jpg|png|gif)$"
378 bool __is_supported_image_type_by_ext(char *file_path)
382 regmatch_t str[2048 + 1];
384 if (!file_path) return false;
387 if ((ret = regcomp(&fsm, PATH_EXT_CHECK_REG, REG_ICASE | REG_EXTENDED))) {
388 SETTING_TRACE("regular expresstion fail");
393 if (regexec(&fsm, file_path, strlen(file_path) + 1, str, 0) == REG_NOMATCH) {
394 /*SETTING_TRACE("FAILED - %s", file_path[i]); */
397 /*SETTING_TRACE("MATCHED - %s", file_path[i]); */
402 #ifdef TIZEN_WEARABLE
403 static int system_setting_get_extended_wallpaper_num(const char *file_path, unsigned int *num)
407 const char *find_str = "extended_wallpaper_";
410 if (!(ch = strstr(file_path, find_str))) {
411 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
413 strncpy(buffer, file_path, ch - file_path);
414 buffer[ch - file_path] = 0;
415 sprintf(buffer + (ch - file_path), "%s%s", "", ch + strlen(find_str));
417 if (!isdigit(buffer[0])) {
418 SETTING_TRACE("%s is not number", buffer);
419 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
424 return SYSTEM_SETTINGS_ERROR_NONE;
427 static int system_setting_copy_extended_wallpaper(const char *dest_file_path, const char *source_file_path)
430 if (!source_file_path || !dest_file_path) {
431 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
437 fd = open(source_file_path, O_RDONLY);
439 SETTING_TRACE("file open failed: %s", source_file_path);
440 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
444 fd2 = open(dest_file_path, O_WRONLY | O_CREAT, S_IRWXU | S_IRWXG | S_IRWXO);
446 SETTING_TRACE("file creation failed: %s", dest_file_path);
448 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
451 while (read(fd, buf, sizeof(buf) - 1) > 0) {
452 write(fd2, buf, sizeof(buf) - 1);
458 if (chmod(dest_file_path, S_IRWXU | S_IRWXG | S_IRWXO) < 0) {
459 SETTING_TRACE("chmod failed: %s", dest_file_path);
462 return SYSTEM_SETTINGS_ERROR_NONE;
465 static int system_setting_remove_oldest_extended_wallpaper()
470 char *min_image_name = NULL;
471 unsigned int min_image_num = 0;
472 unsigned int temp_image_num = 0;
475 if ((dp = opendir(_TZ_SYS_DATA"/setting/wallpaper")) == NULL) {
476 SETTING_TRACE("opendir error");
477 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
480 while ((dirp = readdir(dp))) {
481 if (!strcmp(dirp->d_name, ".") || !strcmp(dirp->d_name, ".."))
484 if (system_setting_get_extended_wallpaper_num(dirp->d_name, &temp_image_num)
485 != SYSTEM_SETTINGS_ERROR_NONE) {
486 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
489 if ((image_count == 0) || (min_image_num > temp_image_num)) {
490 min_image_num = temp_image_num;
491 min_image_name = dirp->d_name;
498 if (min_image_name) {
499 snprintf(buf, sizeof(buf) - 1, _TZ_SYS_DATA"/setting/wallpaper/%s", min_image_name);
500 if (remove(buf) < 0) { /* remove oldest image */
501 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
505 return SYSTEM_SETTINGS_ERROR_NONE;
508 static int system_setting_check_extended_wallpaper(const char *file_path)
512 if (!file_path || !strlen(file_path))
514 snprintf(buffer, 512, "%s/.bgwallpaper", tzplatform_getenv(TZ_USER_CONTENT));
515 return (strstr(file_path, buffer) != NULL);
518 #define WALLPAPER_MAX_COUNT 10
521 int system_setting_set_wallpaper_home_screen(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
525 vconf_value = (char *)value;
527 bool isok = __is_supported_image_type_load(vconf_value);
530 SETTING_TRACE("path : %s is not supported file format", vconf_value);
531 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
533 SETTING_TRACE("path : %s is SUPPORT file format", vconf_value);
536 /* error handling here */
537 if (_is_file_accessible(vconf_value) != 0)
538 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
540 if (system_setting_vconf_set_value_string(VCONFKEY_BGSET, vconf_value)) {
541 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
545 #ifdef TIZEN_WEARABLE
546 if (system_setting_check_extended_wallpaper(vconf_value)) { /* New extended wallpaper */
549 unsigned int max_image_num = 0;
550 unsigned int temp_image_num = 0;
553 if ((dp = opendir(_TZ_SYS_DATA"/setting/wallpaper")) == NULL) {
554 SETTING_TRACE("Setting - dir open error!");
555 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
558 /* Check a max number of wallpapers */
559 while ((dirp = readdir(dp))) {
560 if (!strcmp(dirp->d_name, ".") || !strcmp(dirp->d_name, ".."))
563 if (system_setting_get_extended_wallpaper_num(dirp->d_name, &temp_image_num)
564 != SYSTEM_SETTINGS_ERROR_NONE) {
567 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
570 if ((image_count == 0) || (max_image_num < temp_image_num)) {
571 max_image_num = temp_image_num;
579 /* Numbering rule: Gear is odd number */
580 max_image_num = (max_image_num % 2 == 0) ? max_image_num + 1
583 char file_name_buffer[512];
584 snprintf(file_name_buffer, sizeof(file_name_buffer) - 1,
585 _TZ_SYS_DATA"/setting/wallpaper/extended_wallpaper_%d.jpg", max_image_num);
587 /* Copy image to _TZ_SYS_DATA/setting/wallpaper/ */
588 if (system_setting_copy_extended_wallpaper(file_name_buffer, vconf_value)
589 != SYSTEM_SETTINGS_ERROR_NONE) {
590 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
593 /* remove oldest wallpaper */
594 if (image_count >= WALLPAPER_MAX_COUNT) {
595 if (system_setting_remove_oldest_extended_wallpaper()
596 != SYSTEM_SETTINGS_ERROR_NONE) {
597 remove(file_name_buffer);
598 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
602 if (system_setting_vconf_set_value_string(VCONFKEY_BGSET, file_name_buffer)) {
603 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
606 if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_WALLPAPER_CHANGED_NOTI_INT,
607 VCONFKEY_WALLPAPER_CHANGED_NOTI_GEAR)) {
608 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
611 if (system_setting_vconf_set_value_string(VCONFKEY_BGSET, vconf_value)) {
612 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
617 return SYSTEM_SETTINGS_ERROR_NONE;
620 int system_setting_set_wallpaper_lock_screen(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
624 vconf_value = (char *)value;
626 bool isok = __is_supported_image_type_load(vconf_value);
629 SETTING_TRACE("path : %s is not supported file format", vconf_value);
630 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
632 SETTING_TRACE("path : %s is SUPPORT file format", vconf_value);
635 /* error handling here */
636 if (_is_file_accessible(vconf_value) != 0)
637 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
639 if (system_setting_vconf_set_value_string(VCONFKEY_IDLE_LOCK_BGSET, vconf_value)) {
640 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
643 return SYSTEM_SETTINGS_ERROR_NONE;
646 int system_setting_set_font_size(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
650 vconf_value = (int *)value;
652 if (*vconf_value < 0 || *vconf_value > SYSTEM_SETTINGS_FONT_SIZE_GIANT) {
653 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
656 if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, *vconf_value)) {
657 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
661 return SYSTEM_SETTINGS_ERROR_NONE;
666 void *font_conf_doc_parse(char *doc_name, char *font_name)
669 xmlDocPtr doc = NULL;
670 xmlNodePtr cur = NULL;
671 xmlNodePtr cur2 = NULL;
672 xmlNodePtr cur3 = NULL;
675 doc = xmlParseFile(doc_name);
677 cur = xmlDocGetRootElement(doc);
685 if (xmlStrcmp(cur->name, (const xmlChar *)"fontconfig")) {
691 cur = cur->xmlChildrenNode;
693 Eina_Bool is_changed = EINA_FALSE;
694 while (cur != NULL) {
695 if ((!xmlStrcmp(cur->name, (const xmlChar *)"match"))) {
696 cur2 = cur->xmlChildrenNode;
697 while (cur2 != NULL) {
698 if ((!xmlStrcmp(cur2->name, (const xmlChar *)"edit"))) {
699 xmlChar *name = xmlGetProp(cur2, (const xmlChar *)"name");
700 /* if name is not 'family', break */
701 if (xmlStrcmp(name, (const xmlChar *)"family")) {
709 cur3 = cur2->xmlChildrenNode;
710 while (cur3 != NULL) {
711 if ((!xmlStrcmp(cur3->name, (const xmlChar *)"string"))) {
712 xmlNodeSetContent(cur3->xmlChildrenNode, (const xmlChar *)font_name);
713 key = xmlNodeListGetString(doc, cur3->xmlChildrenNode, 1);
716 is_changed = EINA_TRUE;
723 } else if ((!xmlStrcmp(cur->name, (const xmlChar *)"alias"))) {
724 cur2 = cur->xmlChildrenNode;
725 while (cur2 != NULL) {
726 if ((!xmlStrcmp(cur2->name, (const xmlChar *)"family"))) {
727 xmlNodeSetContent(cur2->xmlChildrenNode, (const xmlChar *)font_name);
728 key = xmlNodeListGetString(doc, cur2->xmlChildrenNode, 1);
731 is_changed = EINA_TRUE;
732 } else if ((!xmlStrcmp(cur2->name, (const xmlChar *)"prefer"))) {
733 cur3 = cur2->xmlChildrenNode;
734 while (cur3 != NULL) {
735 if ((!xmlStrcmp(cur3->name, (const xmlChar *)"family"))) {
736 xmlNodeSetContent(cur3->xmlChildrenNode, (const xmlChar *)font_name);
737 key = xmlNodeListGetString(doc, cur3->xmlChildrenNode, 1);
740 is_changed = EINA_TRUE;
762 int system_setting_set_font_type(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
765 char *font_name = NULL;
766 font_name = (char *)value;
768 /* get current font list */
769 int is_found = __is_available_font(font_name);
772 SETTING_TRACE("found font : %s ", font_name);
774 SETTING_TRACE(" NOT found font : %s ", font_name);
775 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
778 bool bsave = font_config_set(font_name);
781 SETTING_TRACE(" font type save error by font_config_set() ");
782 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
784 SETTING_TRACE(" save OK - font_config_set() ");
787 xmlDocPtr doc = (xmlDocPtr)font_conf_doc_parse(SETTING_FONT_CONF_FILE, font_name);
789 xmlSaveFormatFile(SETTING_FONT_CONF_FILE, doc, 0);
794 font_config_set_notification();
797 vconf_value = (char *)value;
799 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, vconf_value)) {
800 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
802 return SYSTEM_SETTINGS_ERROR_NONE;
805 int system_setting_set_motion_activation(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
809 vconf_value = (bool *)value;
810 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_MOTION_ACTIVATION, *vconf_value)) {
811 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
813 return SYSTEM_SETTINGS_ERROR_NONE;
816 int system_setting_set_usb_debugging_option(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
820 vconf_value = (bool *)value;
821 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_USB_DEBUG_MODE_BOOL, *vconf_value)) {
822 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
824 return SYSTEM_SETTINGS_ERROR_NONE;
828 int system_setting_set_3g_data_network(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
832 vconf_value = (bool *)value;
833 if (system_setting_vconf_set_value_bool(VCONFKEY_3G_ENABLE, *vconf_value)) {
834 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
837 return SYSTEM_SETTINGS_ERROR_NONE;
840 static int category_func(const char *name, void *user_data)
843 static char *category = "lock-screen";
844 if (name && !strcmp(name, category)) {
845 SETTING_TRACE(" SAME ");
848 SETTING_TRACE(" DIFFERENT -- %s, category -- %s ", name, category);
857 * set 'swipe type' if current lockscreen app is 'com.samsung.lockscreen'
860 int system_setting_set_lockscreen_app(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
864 vconf_value = (char *)value; /* ex) com.samsung.lockscreen */
867 pkgmgrinfo_appinfo_h handle;
868 r = pkgmgrinfo_appinfo_get_appinfo(vconf_value, &handle);
869 if (r != PMINFO_R_OK) {
870 SETTING_TRACE("*** pkginfo failed ");
871 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
873 SETTING_TRACE("%x", handle);
876 int ret = pkgmgrinfo_appinfo_foreach_category(handle, category_func, (void *)"lock-screen");
877 if (ret != PMINFO_R_OK) {
878 pkgmgrinfo_appinfo_destroy_appinfo(handle);
879 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
882 pkgmgrinfo_appinfo_destroy_appinfo(handle);
883 /*----------------------------------------------------------------------------------- */
885 if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_SCREEN_LOCK_TYPE_INT, &locktype)) {
886 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
889 if (locktype == SETTING_SCREEN_LOCK_TYPE_PASSWORD)
890 return SYSTEM_SETTINGS_ERROR_LOCKSCREEN_APP_PASSWORD_MODE;
892 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_3RD_LOCK_PKG_NAME_STR, vconf_value)) {
893 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
896 if (vconf_value && strcmp(vconf_value, "com.samsung.lockscreen") == 0) {
897 if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_SCREEN_LOCK_TYPE_INT, SETTING_SCREEN_LOCK_TYPE_SWIPE)) {
898 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
901 return SYSTEM_SETTINGS_ERROR_NONE;
904 /*/////////////////////////////////////////////////////////////////////////////////////////////// */
907 int system_setting_set_changed_callback_incoming_call_ringtone(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
910 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR, SYSTEM_SETTINGS_KEY_INCOMING_CALL_RINGTONE, 0, user_data);
913 int system_setting_unset_changed_callback_incoming_call_ringtone(system_settings_key_e key)
916 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR, 0);
919 int system_setting_set_changed_callback_email_alert_ringtone(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
922 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, SYSTEM_SETTINGS_KEY_EMAIL_ALERT_RINGTONE, 0, user_data);
925 int system_setting_unset_changed_callback_email_alert_ringtone(system_settings_key_e key)
928 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, 0);
931 int system_setting_set_changed_callback_wallpaper_home_screen(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
934 return system_setting_vconf_set_changed_cb(VCONFKEY_BGSET, SYSTEM_SETTINGS_KEY_WALLPAPER_HOME_SCREEN, 0, user_data);
937 int system_setting_unset_changed_callback_wallpaper_home_screen(system_settings_key_e key)
940 return system_setting_vconf_unset_changed_cb(VCONFKEY_BGSET, 0);
943 int system_setting_set_changed_callback_wallpaper_lock_screen(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
946 return system_setting_vconf_set_changed_cb(VCONFKEY_IDLE_LOCK_BGSET, SYSTEM_SETTINGS_KEY_WALLPAPER_LOCK_SCREEN, 0, user_data);
949 int system_setting_unset_changed_callback_wallpaper_lock_screen(system_settings_key_e key)
952 return system_setting_vconf_unset_changed_cb(VCONFKEY_IDLE_LOCK_BGSET, 0);
955 int system_setting_set_changed_callback_font_size(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
958 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, SYSTEM_SETTINGS_KEY_FONT_SIZE, 1, user_data);
961 int system_setting_unset_changed_callback_font_size(system_settings_key_e key)
964 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, 1);
967 int system_setting_set_changed_callback_usb_debugging_option(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
970 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_USB_DEBUG_MODE_BOOL, SYSTEM_SETTINGS_KEY_USB_DEBUGGING_ENABLED, 1, user_data);
973 int system_setting_unset_changed_callback_usb_debugging_option(system_settings_key_e key)
976 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_USB_DEBUG_MODE_BOOL, 1);
979 int system_setting_set_changed_callback_3g_data_network(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
982 return system_setting_vconf_set_changed_cb(VCONFKEY_3G_ENABLE, SYSTEM_SETTINGS_KEY_3G_DATA_NETWORK_ENABLED, 1, user_data);
985 int system_setting_unset_changed_callback_3g_data_network(system_settings_key_e key)
988 return system_setting_vconf_unset_changed_cb(VCONFKEY_3G_ENABLE, 1);
991 int system_setting_set_changed_callback_lockscreen_app(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
994 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_3RD_LOCK_PKG_NAME_STR, SYSTEM_SETTINGS_KEY_LOCKSCREEN_APP, 1, user_data);
997 int system_setting_unset_changed_callback_lockscreen_app(system_settings_key_e key)
1000 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_3RD_LOCK_PKG_NAME_STR, 1);
1005 * @todo need to add custom event notification method
1007 int system_setting_set_changed_callback_font_type(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1009 SETTING_TRACE_BEGIN;
1010 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, SYSTEM_SETTINGS_KEY_FONT_TYPE, 2, user_data);
1013 int system_setting_unset_changed_callback_font_type(system_settings_key_e key)
1015 SETTING_TRACE_BEGIN;
1016 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, 2);
1019 /* TODO : 2th argument, callback, is not in use. */
1020 int system_setting_set_changed_callback_motion_activation(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1022 SETTING_TRACE_BEGIN;
1023 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_MOTION_ACTIVATION, SYSTEM_SETTINGS_KEY_MOTION_ACTIVATION, 3, user_data);
1026 int system_setting_unset_changed_callback_motion_activation(system_settings_key_e key)
1028 SETTING_TRACE_BEGIN;
1029 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_MOTION_ACTIVATION, 3);
1032 static char *_get_cur_font()
1034 SETTING_TRACE_BEGIN;
1035 xmlDocPtr doc = NULL;
1036 xmlNodePtr cur = NULL;
1037 xmlNodePtr cur2 = NULL;
1038 xmlNodePtr cur3 = NULL;
1039 xmlChar *key = NULL;
1041 char *font_name = NULL;
1043 doc = xmlParseFile(SETTING_FONT_CONF_FILE);
1045 cur = xmlDocGetRootElement(doc);
1053 if (xmlStrcmp(cur->name, (const xmlChar *)"fontconfig")) {
1059 cur = cur->xmlChildrenNode;
1061 while (cur != NULL) {
1062 if ((!xmlStrcmp(cur->name, (const xmlChar *)"match"))) {
1063 cur2 = cur->xmlChildrenNode;
1064 while (cur2 != NULL) {
1065 if ((!xmlStrcmp(cur2->name, (const xmlChar *)"edit"))) {
1066 cur3 = cur2->xmlChildrenNode;
1067 while (cur3 != NULL) {
1068 if ((!xmlStrcmp(cur3->name, (const xmlChar *)"string"))) {
1069 key = xmlNodeListGetString(doc, cur3->xmlChildrenNode, 1);
1071 font_name = g_strdup((char *)key);
1092 static void font_config_set_notification()
1094 SETTING_TRACE_BEGIN;
1097 Ecore_X_Window ecore_win = ecore_x_window_root_first_get();
1098 Ecore_X_Atom atom = ecore_x_atom_get("FONT_TYPE_change");
1099 ecore_x_window_prop_string_set(ecore_win, atom, "tizen");
1103 int __is_available_font(char *font_name)
1105 SETTING_TRACE_BEGIN;
1106 FcObjectSet *os = NULL;
1107 FcFontSet *fs = NULL;
1108 FcPattern *pat = 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((char*)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;
1414 int vconf_value = -1;
1415 if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, &vconf_value)) {
1419 switch (vconf_value) {
1420 case SYSTEM_SETTINGS_FONT_SIZE_SMALL:
1421 font_size = SMALL_FONT_DPI;
1423 case SYSTEM_SETTINGS_FONT_SIZE_NORMAL:
1424 font_size = MIDDLE_FONT_DPI;
1426 case SYSTEM_SETTINGS_FONT_SIZE_LARGE:
1427 font_size = LARGE_FONT_DPI;
1429 case SYSTEM_SETTINGS_FONT_SIZE_HUGE:
1430 font_size = HUGE_FONT_DPI;
1432 case SYSTEM_SETTINGS_FONT_SIZE_GIANT:
1433 font_size = GIANT_FONT_DPI;
1436 font_size = MIDDLE_FONT_DPI;
1442 /*//////////////////////////////////////////////////////////////////////////////////////// */
1443 /*--------------------------------------- */
1444 int system_setting_get_locale_country(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1446 SETTING_TRACE_BEGIN;
1447 char *vconf_value = NULL;
1448 if (system_setting_vconf_get_value_string(VCONFKEY_REGIONFORMAT, &vconf_value)) {
1449 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1452 /* parsing validation */
1455 snprintf(arr, 20, "%s", vconf_value);
1457 *value = strdup(arr);
1461 return SYSTEM_SETTINGS_ERROR_NONE;
1464 int system_setting_set_locale_country(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1466 SETTING_TRACE_BEGIN;
1467 char *vconf_value = NULL;
1468 vconf_value = (char *)value;
1470 char *ext = "UTF-8";
1473 snprintf(arr, 20, "%s.%s", vconf_value, ext);
1475 if (system_setting_vconf_set_value_string(VCONFKEY_REGIONFORMAT, arr)) {
1476 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1478 return SYSTEM_SETTINGS_ERROR_NONE;
1481 int system_setting_set_changed_callback_locale_country(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1483 SETTING_TRACE_BEGIN;
1484 return system_setting_vconf_set_changed_cb(VCONFKEY_REGIONFORMAT, SYSTEM_SETTINGS_KEY_LOCALE_COUNTRY, 3, user_data);
1487 int system_setting_unset_changed_callback_locale_country(system_settings_key_e key)
1489 SETTING_TRACE_BEGIN;
1490 return system_setting_vconf_unset_changed_cb(VCONFKEY_REGIONFORMAT, 3);
1494 /*--------------------------------------- */
1495 int system_setting_get_locale_language(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1497 SETTING_TRACE_BEGIN;
1498 char *vconf_value = NULL;
1499 if (system_setting_vconf_get_value_string(VCONFKEY_LANGSET, &vconf_value)) {
1500 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1503 /* parsing validation */
1506 snprintf(arr, 20, "%s", vconf_value);
1508 *value = strdup(arr);
1511 return SYSTEM_SETTINGS_ERROR_NONE;
1514 int system_setting_set_locale_language(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1516 SETTING_TRACE_BEGIN;
1517 char *vconf_value = NULL;
1518 vconf_value = (char *)value;
1520 char *ext = "UTF-8";
1523 snprintf(arr, 20, "%s.%s", vconf_value, ext);
1525 if (system_setting_vconf_set_value_string(VCONFKEY_LANGSET, arr)) {
1526 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1528 return SYSTEM_SETTINGS_ERROR_NONE;
1531 int system_setting_set_changed_callback_locale_language(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1533 SETTING_TRACE_BEGIN;
1534 /*return system_setting_vconf_set_changed_cb(VCONFKEY_LANGSET, SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, 3, user_data ); */
1535 return system_setting_vconf_set_changed_cb(VCONFKEY_LANGSET, SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, 100, user_data);
1538 int system_setting_unset_changed_callback_locale_language(system_settings_key_e key)
1540 SETTING_TRACE_BEGIN;
1541 return system_setting_vconf_unset_changed_cb(VCONFKEY_LANGSET, 100);
1544 /*--------------------------------------- */
1545 int system_setting_get_locale_timeformat_24hour(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1547 SETTING_TRACE_BEGIN;
1550 if (system_setting_vconf_get_value_int(VCONFKEY_REGIONFORMAT_TIME1224, &vconf_value)) {
1551 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1554 bool ret_value = true;
1555 if (vconf_value == VCONFKEY_TIME_FORMAT_12)
1557 else if (vconf_value == VCONFKEY_TIME_FORMAT_24)
1560 *value = (void *)ret_value;
1562 return SYSTEM_SETTINGS_ERROR_NONE;
1565 int system_setting_set_locale_timeformat_24hour(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1567 SETTING_TRACE_BEGIN;
1570 vconf_value = (bool *)value;
1573 if (system_setting_vconf_set_value_int(VCONFKEY_REGIONFORMAT_TIME1224, VCONFKEY_TIME_FORMAT_24)) {
1574 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1578 if (system_setting_vconf_set_value_int(VCONFKEY_REGIONFORMAT_TIME1224, VCONFKEY_TIME_FORMAT_12)) {
1579 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1584 return SYSTEM_SETTINGS_ERROR_NONE;
1587 int system_setting_set_changed_callback_locale_timeformat_24hour(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1589 SETTING_TRACE_BEGIN;
1590 return system_setting_vconf_set_changed_cb(VCONFKEY_REGIONFORMAT_TIME1224, SYSTEM_SETTINGS_KEY_LOCALE_TIMEFORMAT_24HOUR, 3, user_data);
1593 int system_setting_unset_changed_callback_locale_timeformat_24hour(system_settings_key_e key)
1595 SETTING_TRACE_BEGIN;
1596 return system_setting_vconf_unset_changed_cb(VCONFKEY_REGIONFORMAT_TIME1224, 3);
1599 int system_setting_get_locale_timezone(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1601 SETTING_TRACE_BEGIN;
1604 ssize_t len = readlink(SETTING_TZONE_SYMLINK_PATH, tzpath, sizeof(tzpath) - 1);
1608 SETTING_TRACE("parse error for SETTING_TZONE_SYMLINK_PATH");
1609 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1611 /* "/usr/share/zoneinfo/Asia/Seoul" */
1612 SETTING_TRACE("tzpath : %s ", &tzpath[20]);
1613 *value = strdup(&tzpath[20]);
1615 *value = vconf_get_str(VCONFKEY_SETAPPL_TIMEZONE_ID);
1617 return SYSTEM_SETTINGS_ERROR_NONE;
1620 int system_setting_set_changed_callback_locale_timezone_changed(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1622 SETTING_TRACE_BEGIN;
1623 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
1626 int system_setting_unset_changed_callback_locale_timezone_changed(system_settings_key_e key)
1628 SETTING_TRACE_BEGIN;
1629 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
1633 int system_setting_get_time_changed(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1635 SETTING_TRACE_BEGIN;
1637 cur_tick = time(NULL);
1638 *value = (void *)cur_tick;
1639 /* struct tm * localtime = time (cur_tick); */
1640 /* printf("%s\n", ctime(&cur_tick); */
1641 return SYSTEM_SETTINGS_ERROR_NONE;
1645 int system_setting_set_changed_callback_time_changed(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1647 SETTING_TRACE_BEGIN;
1648 return system_setting_vconf_set_changed_cb(VCONFKEY_SYSTEM_TIME_CHANGED, SYSTEM_SETTINGS_KEY_TIME_CHANGED, 3, user_data);
1651 int system_setting_unset_changed_callback_time_changed(system_settings_key_e key)
1653 SETTING_TRACE_BEGIN;
1654 return system_setting_vconf_unset_changed_cb(VCONFKEY_SYSTEM_TIME_CHANGED, 3);
1659 /* SYSTEM_SETTINGS_KEY_SOUND_LOCK */
1660 int system_setting_get_sound_lock(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1662 SETTING_TRACE_BEGIN;
1665 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_SOUND_LOCK_BOOL, &vconf_value)) {
1666 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1668 *value = (void *)vconf_value;
1670 return SYSTEM_SETTINGS_ERROR_NONE;
1673 int system_setting_set_changed_callback_sound_lock(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1675 SETTING_TRACE_BEGIN;
1676 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_SOUND_LOCK_BOOL, SYSTEM_SETTINGS_KEY_SOUND_LOCK, 3, user_data);
1679 int system_setting_unset_changed_callback_sound_lock(system_settings_key_e key)
1681 SETTING_TRACE_BEGIN;
1682 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_SOUND_LOCK_BOOL, 3);
1686 * a = VCONFKEY_SETAPPL_SOUND_STATUS_BOOL b = VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL
1688 * a == false, b == false --> silent mode
1689 * a == true, b == false --> sound mode
1690 * a == false, b == true --> vibration mode
1692 int system_setting_get_sound_silent_mode(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1694 SETTING_TRACE_BEGIN;
1699 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, &sound_cond)) {
1700 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1703 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, &vib_cond)) {
1704 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1707 if (sound_cond == false && vib_cond == false) {
1709 *value = (void *)vconf_value;
1711 vconf_value = false;
1712 *value = (void *)vconf_value;
1714 return SYSTEM_SETTINGS_ERROR_NONE;
1718 * a = VCONFKEY_SETAPPL_SOUND_STATUS_BOOL b = VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL
1720 * a == false, b == false --> silent mode
1721 * a == true, b == false --> sound mode
1723 int system_setting_set_sound_silent_mode(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1725 SETTING_TRACE_BEGIN;
1728 vconf_value = (bool *)value;
1730 bool vconf_sound = false;
1731 bool vconf_vib = false;
1734 vconf_sound = false;
1741 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, vconf_sound)) {
1742 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1744 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, vconf_vib)) {
1745 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1748 return SYSTEM_SETTINGS_ERROR_NONE;
1754 int system_setting_set_changed_callback_sound_silent_mode(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1756 SETTING_TRACE_BEGIN;
1757 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, SYSTEM_SETTINGS_KEY_SOUND_SILENT_MODE, 3, user_data);
1761 int system_setting_unset_changed_callback_sound_silent_mode(system_settings_key_e key)
1763 SETTING_TRACE_BEGIN;
1764 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, 3);
1767 /* SYSTEM_SETTINGS_KEY_SOUND_TOUCH */
1768 int system_setting_get_sound_touch(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1770 SETTING_TRACE_BEGIN;
1773 int ret = system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL, &vconf_value);
1774 if (ret != SYSTEM_SETTINGS_ERROR_NONE) {
1777 *value = (void *)vconf_value;
1781 int system_setting_set_changed_callback_sound_touch(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1783 SETTING_TRACE_BEGIN;
1784 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL, SYSTEM_SETTINGS_KEY_SOUND_TOUCH, 2, user_data);
1787 int system_setting_unset_changed_callback_sound_touch(system_settings_key_e key)
1789 SETTING_TRACE_BEGIN;
1790 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL, 2);
1794 /* SYSTEM_SETTINGS_KEY_SOUND_LOCK */
1795 int system_setting_get_sound_lock(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1799 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_SOUND_LOCK_BOOL, &vconf_value)) {
1800 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1802 *value = (void *)vconf_value;
1804 return SYSTEM_SETTINGS_ERROR_NONE;
1808 int system_setting_get_auto_rotation_mode(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1810 SETTING_TRACE_BEGIN;
1813 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, &vconf_value)) {
1814 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1816 *value = (void *)vconf_value;
1818 return SYSTEM_SETTINGS_ERROR_NONE;
1821 int system_setting_set_auto_rotation_mode(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1823 SETTING_TRACE_BEGIN;
1825 vconf_value = (bool *)value;
1826 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, *vconf_value)) {
1827 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1830 return SYSTEM_SETTINGS_ERROR_NONE;
1833 int system_setting_set_changed_callback_auto_rotation_mode(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1835 SETTING_TRACE_BEGIN;
1836 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, SYSTEM_SETTINGS_KEY_DISPLAY_SCREEN_ROTATION_AUTO, 2, user_data);
1839 int system_setting_unset_changed_callback_auto_rotation_mode(system_settings_key_e key)
1841 SETTING_TRACE_BEGIN;
1842 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, 2);
1845 int system_setting_get_screen_backlight_time(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1847 SETTING_TRACE_BEGIN;
1850 if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, &vconf_value)) {
1851 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1853 *value = (void *)vconf_value;
1855 return SYSTEM_SETTINGS_ERROR_NONE;
1859 int system_setting_set_screen_backlight_time(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1861 SETTING_TRACE_BEGIN;
1863 vconf_value = (int *)value;
1865 if (!(*vconf_value > 0 && *vconf_value < 600)) {
1866 SETTING_TRACE(" ERR Betweeny here 0 ~ 600");
1867 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
1870 if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, *vconf_value)) {
1871 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1874 return SYSTEM_SETTINGS_ERROR_NONE;
1877 int system_setting_set_changed_callback_screen_backlight_time(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1879 SETTING_TRACE_BEGIN;
1880 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, SYSTEM_SETTINGS_KEY_DISPLAY_SCREEN_ROTATION_AUTO, 2, user_data);
1883 int system_setting_unset_changed_callback_screen_backlight_time(system_settings_key_e key)
1885 SETTING_TRACE_BEGIN;
1886 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, 2);
1889 int system_setting_get_sound_notification(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1891 SETTING_TRACE_BEGIN;
1892 char *vconf_value = NULL;
1893 if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, &vconf_value)) {
1894 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1897 *value = vconf_value;
1898 return SYSTEM_SETTINGS_ERROR_NONE;
1901 int system_setting_set_sound_notification(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1903 SETTING_TRACE_BEGIN;
1904 char *vconf_value = NULL;
1905 vconf_value = (char *)value;
1907 int is_load = _is_file_accessible(vconf_value);
1909 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, vconf_value)) {
1910 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1913 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1916 return SYSTEM_SETTINGS_ERROR_NONE;
1919 int system_setting_set_changed_callback_sound_notification(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1921 SETTING_TRACE_BEGIN;
1922 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, SYSTEM_SETTINGS_KEY_INCOMING_CALL_RINGTONE, 0, user_data);
1925 int system_setting_unset_changed_callback_sound_notification(system_settings_key_e key)
1927 SETTING_TRACE_BEGIN;
1928 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, 0);
1931 int system_setting_get_notification_repetition_period(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1933 SETTING_TRACE_BEGIN;
1936 if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_NOTI_MSG_ALERT_REP_TYPE_INT, &vconf_value)) {
1937 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1939 *value = (void *)vconf_value;
1941 return SYSTEM_SETTINGS_ERROR_NONE;
1944 int system_setting_set_notification_repetition_period(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1946 SETTING_TRACE_BEGIN;
1948 vconf_value = (int *)value;
1950 if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_NOTI_MSG_ALERT_REP_TYPE_INT, *vconf_value)) {
1951 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1954 return SYSTEM_SETTINGS_ERROR_NONE;
1957 int system_setting_set_changed_callback_notification_repetition_period(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1959 SETTING_TRACE_BEGIN;
1960 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);
1963 int system_setting_unset_changed_callback_notification_repetition_period(system_settings_key_e key)
1965 SETTING_TRACE_BEGIN;
1966 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_ALERT_REP_TYPE_INT, 1);
1969 int system_setting_get_device_name(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1971 SETTING_TRACE_BEGIN;
1972 char *vconf_value = NULL;
1973 if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_DEVICE_NAME_STR, &vconf_value)) {
1974 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1977 *value = vconf_value;
1978 return SYSTEM_SETTINGS_ERROR_NONE;
1981 int system_setting_set_device_name(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1983 SETTING_TRACE_BEGIN;
1984 char *vconf_value = NULL;
1985 vconf_value = (char *)value;
1987 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_DEVICE_NAME_STR, vconf_value)) {
1988 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1991 return SYSTEM_SETTINGS_ERROR_NONE;
1994 int system_setting_set_changed_callback_device_name(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1996 SETTING_TRACE_BEGIN;
1997 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_DEVICE_NAME_STR, SYSTEM_SETTINGS_KEY_DEVICE_NAME, 0, user_data);
2000 int system_setting_unset_changed_callback_device_name(system_settings_key_e key)
2002 SETTING_TRACE_BEGIN;
2003 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_DEVICE_NAME_STR, 0);
2006 /*---------------------------------------------- */
2007 int system_setting_get_network_flight_mode(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
2009 SETTING_TRACE_BEGIN;
2011 if (system_setting_vconf_get_value_bool(VCONFKEY_TELEPHONY_FLIGHT_MODE, &vconf_value)) {
2012 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2014 *value = (void *)vconf_value;
2016 return SYSTEM_SETTINGS_ERROR_NONE;
2019 int system_setting_set_changed_callback_network_flight_mode(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
2021 SETTING_TRACE_BEGIN;
2022 return system_setting_vconf_set_changed_cb(VCONFKEY_TELEPHONY_FLIGHT_MODE, SYSTEM_SETTINGS_KEY_NETWORK_FLIGHT_MODE, 3, user_data);
2025 int system_setting_unset_changed_callback_network_flight_mode(system_settings_key_e key)
2027 SETTING_TRACE_BEGIN;
2028 return system_setting_vconf_unset_changed_cb(VCONFKEY_TELEPHONY_FLIGHT_MODE, 3);
2031 int system_setting_get_network_wifi_notification(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
2033 SETTING_TRACE_BEGIN;
2035 if (system_setting_vconf_get_value_int(VCONFKEY_WIFI_ENABLE_QS, &vconf_value)) {
2036 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2039 bret = (vconf_value == VCONFKEY_WIFI_QS_ENABLE) ? true : false;
2041 *value = (void *)bret;
2042 return SYSTEM_SETTINGS_ERROR_NONE;
2045 int system_setting_set_changed_callback_network_wifi_notification(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
2047 SETTING_TRACE_BEGIN;
2048 return system_setting_vconf_set_changed_cb(VCONFKEY_WIFI_ENABLE_QS, SYSTEM_SETTINGS_KEY_NETWORK_WIFI_NOTIFICATION, 4, user_data);
2051 int system_setting_unset_changed_callback_network_wifi_notification(system_settings_key_e key)
2053 SETTING_TRACE_BEGIN;
2054 return system_setting_vconf_unset_changed_cb(VCONFKEY_WIFI_ENABLE_QS, 4);
2057 int system_setting_get_lock_state(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
2061 if (system_setting_vconf_get_value_int(VCONFKEY_IDLE_LOCK_STATE_READ_ONLY, &vconf_value)) {
2062 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2064 *value = (void *)vconf_value;
2066 return SYSTEM_SETTINGS_ERROR_NONE;
2069 int system_setting_set_lock_state(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
2071 SETTING_TRACE_BEGIN;
2073 vconf_value = (int *)value;
2075 if (system_setting_vconf_set_value_int(VCONFKEY_IDLE_LOCK_STATE_READ_ONLY, *vconf_value)) {
2076 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2079 return SYSTEM_SETTINGS_ERROR_NONE;
2082 int system_setting_set_changed_callback_lock_state(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
2084 return system_setting_vconf_set_changed_cb(VCONFKEY_IDLE_LOCK_STATE_READ_ONLY, SYSTEM_SETTINGS_KEY_LOCK_STATE, 4, user_data);
2087 int system_setting_unset_changed_callback_lock_state(system_settings_key_e key)
2089 return system_setting_vconf_unset_changed_cb(VCONFKEY_IDLE_LOCK_STATE_READ_ONLY, 4);