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>
54 #include <efl_assist.h>
58 #define SMALL_FONT_DPI (-90)
61 #define SMALL_FONT_DPI (-80)
63 #define MIDDLE_FONT_DPI (-100)
65 #define LARGE_FONT_DPI (-110)
68 #define LARGE_FONT_DPI (-150)
70 #define HUGE_FONT_DPI (-190)
71 #define GIANT_FONT_DPI (-250)
73 #define SETTING_FONT_PRELOAD_FONT_PATH "/usr/share/fonts"
74 #define SETTING_FONT_DOWNLOADED_FONT_PATH "/opt/share/fonts"
76 #define SETTING_FONT_CONF_FILE "/opt/etc/fonts/conf.avail/99-slp.conf"
77 #define SETTING_DEFAULT_FONT_CONF_FILE "/usr/opt/etc/fonts/conf.avail/99-slp.conf"
79 #define SETTING_STR_LEN 256
81 #define SETTING_TIME_ZONEINFO_PATH "/usr/share/zoneinfo/"
82 #define SETTING_TIME_SHARE_LOCAL_PATH "/usr/share/locale"
83 #define SETTING_TZONE_SYMLINK_PATH "/etc/localtime"
86 static char *_get_cur_font();
87 static void __font_size_set();
88 static int __font_size_get();
89 static char *_get_default_font();
91 static bool font_config_set(char *font_name);
92 static void font_config_set_notification();
95 * VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR has a path of the ringtone file which user choose
96 * @return the ringtone file path specified by user in normal case
97 * if it's not accessable, return the default ringtone path
99 int system_setting_get_incoming_call_ringtone(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
103 if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR, &vconf_value)) {
104 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
107 /* check to see if it's accessable -> OK */
108 /* no --> default ringtone path VCONFKEY_SETAPPL_CALL_RINGTONE_DEFAULT_PATH_STR */
109 int is_load = _is_file_accessible(vconf_value);
111 *value = vconf_value;
112 } else { /* not zero on errro */
113 *value = vconf_get_str(VCONFKEY_SETAPPL_CALL_RINGTONE_DEFAULT_PATH_STR);
116 /**value = vconf_value; */
117 return SYSTEM_SETTINGS_ERROR_NONE;
121 int system_setting_get_email_alert_ringtone(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
125 if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, &vconf_value)) {
126 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
129 /* check to see if it's accessable -> OK */
130 /* no --> default ringtone path VCONFKEY_SETAPPL_NOTI_RINGTONE_DEFAULT_PATH_STR */
131 int is_load = _is_file_accessible(vconf_value);
133 *value = vconf_value;
134 } else { /* not zero on errro */
135 *value = vconf_get_str(VCONFKEY_SETAPPL_NOTI_RINGTONE_DEFAULT_PATH_STR);
138 return SYSTEM_SETTINGS_ERROR_NONE;
142 int system_setting_get_wallpaper_home_screen(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
146 if (system_setting_vconf_get_value_string(VCONFKEY_BGSET, &vconf_value)) {
147 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
149 *value = vconf_value;
150 return SYSTEM_SETTINGS_ERROR_NONE;
154 int system_setting_get_wallpaper_lock_screen(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
159 if (system_setting_vconf_get_value_string(VCONFKEY_IDLE_LOCK_BGSET, &vconf_value)) {
160 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
162 *value = vconf_value;
164 return SYSTEM_SETTINGS_ERROR_NONE;
168 /* [int] vconf GET */
169 int system_setting_get_font_size(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
174 if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, &vconf_value)) {
175 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
177 *value = (void *)vconf_value;
179 return SYSTEM_SETTINGS_ERROR_NONE;
183 int system_setting_get_default_font_type(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
186 char *font_name = _get_default_font();
188 *value = (void *)font_name;
189 return SYSTEM_SETTINGS_ERROR_NONE;
191 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
195 /* [int] vconf GET */
196 int system_setting_get_font_type(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
199 char *font_name = _get_cur_font();
200 *value = (void *)font_name;
202 return SYSTEM_SETTINGS_ERROR_NONE;
206 int system_setting_get_motion_activation(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
211 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_MOTION_ACTIVATION, &vconf_value)) {
212 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
214 *value = (void *)vconf_value;
216 return SYSTEM_SETTINGS_ERROR_NONE;
219 int system_setting_get_usb_debugging_option(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
224 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_USB_DEBUG_MODE_BOOL, &vconf_value)) {
225 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
227 *value = (void *)vconf_value;
229 return SYSTEM_SETTINGS_ERROR_NONE;
232 int system_setting_get_3g_data_network(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
237 if (system_setting_vconf_get_value_bool(VCONFKEY_3G_ENABLE, &vconf_value)) {
238 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
240 *value = (void *)vconf_value;
242 return SYSTEM_SETTINGS_ERROR_NONE;
244 /*////////////////////////////////////////////////////////////////////////////////////////////////// */
248 * get current lock scren app package name (string)
250 * @return SYSTEM_SETTINGS_ERROR_LOCKSCREEN_APP_PASSWORD_MODE raise exception if current lock type is 'password'
252 int system_setting_get_lockscreen_app(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
255 char *pkg_name = NULL;
257 system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_SCREEN_LOCK_TYPE_INT, &locktype);
259 if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_3RD_LOCK_PKG_NAME_STR, &pkg_name)) {
260 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
263 if (pkg_name && strcmp(pkg_name, "com.samsung.lockscreen") == 0 && locktype == SETTING_SCREEN_LOCK_TYPE_PASSWORD) {
264 return SYSTEM_SETTINGS_ERROR_LOCKSCREEN_APP_PASSWORD_MODE;
268 return SYSTEM_SETTINGS_ERROR_NONE;
272 /*////////////////////////////////////////////////////////////////////////////////////////////////// */
274 int _is_file_accessible(const char *path)
277 int ret = access(path , R_OK);
279 SETTING_TRACE("found the file %s", path);
283 SETTING_TRACE("found the file %s --- error code : %d ", path, errno);
288 int system_setting_set_incoming_call_ringtone(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
292 vconf_value = (char *)value;
294 int ret = _is_file_accessible(vconf_value);
296 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR, vconf_value)) {
297 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
300 /* @todo add a common ret_handler */
304 return SYSTEM_SETTINGS_ERROR_NONE;
308 int system_setting_set_email_alert_ringtone(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
312 vconf_value = (char *)value;
314 int ret = _is_file_accessible(vconf_value);
316 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, vconf_value)) {
317 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
320 /*return SYSTEM_SETTINGS_ERROR_IO_ERROR;*/
321 /* @todo add a common ret_handler */
325 return SYSTEM_SETTINGS_ERROR_NONE;
329 bool __is_supported_image_type_load(char *path)
336 ee = ecore_evas_new(NULL, 0, 0, 100, 100, NULL);
337 evas = ecore_evas_get(ee);
339 Evas_Object *img = evas_object_image_add(evas);
340 evas_object_image_file_set(img, path, NULL);
341 Evas_Load_Error ret = evas_object_image_load_error_get(img);
344 if (ret == EVAS_LOAD_ERROR_NONE) {
345 SETTING_TRACE("%s - OK", path);
348 SETTING_TRACE("%s - NO", path);
356 bool __is_supported_image_type(char *path)
362 if (evas_object_image_extension_can_load_get(path))
372 #define PATH_EXT_CHECK_REG ".(jpe?g|jpg|png|gif)$"
373 bool __is_supported_image_type_by_ext(char *file_path)
377 regmatch_t str[2048 + 1];
379 if (!file_path) return false;
382 if (ret = regcomp(&fsm, PATH_EXT_CHECK_REG, REG_ICASE | REG_EXTENDED)) {
383 SETTING_TRACE("regular expresstion fail");
388 if (regexec(&fsm, file_path, strlen(file_path) + 1, str, 0) == REG_NOMATCH) {
389 /*SETTING_TRACE("FAILED - %s", file_path[i]); */
392 /*SETTING_TRACE("MATCHED - %s", file_path[i]); */
397 #ifdef TIZEN_WEARABLE
398 static int system_setting_get_extended_wallpaper_num(const char *file_path, unsigned int *num)
402 const char *find_str = "extended_wallpaper_";
405 if (!(ch = strstr(file_path, find_str))) {
406 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
408 strncpy(buffer, file_path, ch - file_path);
409 buffer[ch - file_path] = 0;
410 sprintf(buffer + (ch - file_path), "%s%s", "", ch + strlen(find_str));
412 if (!isdigit(buffer[0])) {
413 SETTING_TRACE("%s is not number", buffer);
414 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
419 return SYSTEM_SETTINGS_ERROR_NONE;
422 static int system_setting_copy_extended_wallpaper(const char *dest_file_path, const char *source_file_path)
425 if (!source_file_path || !dest_file_path) {
426 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
432 fd = open(source_file_path, O_RDONLY);
434 SETTING_TRACE("file open failed: %s", source_file_path);
435 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
439 fd2 = open(dest_file_path, O_WRONLY | O_CREAT, S_IRWXU | S_IRWXG | S_IRWXO);
441 SETTING_TRACE("file creation failed: %s", dest_file_path);
443 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
446 while (read(fd, buf, sizeof(buf) - 1) > 0) {
447 write(fd2, buf, sizeof(buf) - 1);
453 if (chmod(dest_file_path, S_IRWXU | S_IRWXG | S_IRWXO) < 0) {
454 SETTING_TRACE("chmod failed: %s", dest_file_path);
457 return SYSTEM_SETTINGS_ERROR_NONE;
460 static int system_setting_remove_oldest_extended_wallpaper()
465 char *min_image_name = NULL;
466 unsigned int min_image_num = 0;
467 unsigned int temp_image_num = 0;
470 if ((dp = opendir("/opt/usr/data/setting/wallpaper")) == NULL) {
471 SETTING_TRACE("opendir error");
472 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
475 while ((dirp = readdir(dp))) {
476 if (!strcmp(dirp->d_name, ".") || !strcmp(dirp->d_name, ".."))
479 if (system_setting_get_extended_wallpaper_num(dirp->d_name, &temp_image_num)
480 != SYSTEM_SETTINGS_ERROR_NONE) {
481 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
484 if ((image_count == 0) || (min_image_num > temp_image_num)) {
485 min_image_num = temp_image_num;
486 min_image_name = dirp->d_name;
493 if (min_image_name) {
494 snprintf(buf, sizeof(buf) - 1, "/opt/usr/data/setting/wallpaper/%s", min_image_name);
495 if (remove(buf) < 0) { /* remove oldest image */
496 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
500 return SYSTEM_SETTINGS_ERROR_NONE;
503 static int system_setting_check_extended_wallpaper(const char *file_path)
506 if (!file_path || !strlen(file_path))
508 return (strstr(file_path, "/opt/usr/media/.bgwallpaper") != NULL);
511 #define WALLPAPER_MAX_COUNT 10
514 int system_setting_set_wallpaper_home_screen(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
518 vconf_value = (char *)value;
520 bool isok = __is_supported_image_type_load(vconf_value);
523 SETTING_TRACE("path : %s is not supported file format", vconf_value);
524 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
526 SETTING_TRACE("path : %s is SUPPORT file format", vconf_value);
529 /* error handling here */
530 if (_is_file_accessible(vconf_value) != 0)
531 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
533 if (system_setting_vconf_set_value_string(VCONFKEY_BGSET, vconf_value)) {
534 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
538 #ifdef TIZEN_WEARABLE
539 if (system_setting_check_extended_wallpaper(vconf_value)) { /* New extended wallpaper */
542 unsigned int max_image_num = 0;
543 unsigned int temp_image_num = 0;
546 if ((dp = opendir("/opt/usr/data/setting/wallpaper")) == NULL) {
547 SETTING_TRACE("Setting - dir open error!");
548 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
551 /* Check a max number of wallpapers */
552 while ((dirp = readdir(dp))) {
553 if (!strcmp(dirp->d_name, ".") || !strcmp(dirp->d_name, ".."))
556 if (system_setting_get_extended_wallpaper_num(dirp->d_name, &temp_image_num)
557 != SYSTEM_SETTINGS_ERROR_NONE) {
558 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
561 if ((image_count == 0) || (max_image_num < temp_image_num)) {
562 max_image_num = temp_image_num;
568 /* Numbering rule: Gear is odd number */
569 max_image_num = (max_image_num % 2 == 0) ? max_image_num + 1
572 char file_name_buffer[512];
573 snprintf(file_name_buffer, sizeof(file_name_buffer) - 1,
574 "/opt/usr/data/setting/wallpaper/extended_wallpaper_%d.jpg", max_image_num);
576 /* Copy image to /opt/usr/data/setting/wallpaper/ */
577 if (system_setting_copy_extended_wallpaper(file_name_buffer, vconf_value)
578 != SYSTEM_SETTINGS_ERROR_NONE) {
579 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
582 /* remove oldest wallpaper */
583 if (image_count >= WALLPAPER_MAX_COUNT) {
584 if (system_setting_remove_oldest_extended_wallpaper()
585 != SYSTEM_SETTINGS_ERROR_NONE) {
586 remove(file_name_buffer);
587 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
591 if (system_setting_vconf_set_value_string(VCONFKEY_BGSET, file_name_buffer)) {
592 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
595 if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_WALLPAPER_CHANGED_NOTI_INT,
596 VCONFKEY_WALLPAPER_CHANGED_NOTI_GEAR)) {
597 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
600 if (system_setting_vconf_set_value_string(VCONFKEY_BGSET, vconf_value)) {
601 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
606 return SYSTEM_SETTINGS_ERROR_NONE;
609 int system_setting_set_wallpaper_lock_screen(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
613 vconf_value = (char *)value;
615 bool isok = __is_supported_image_type_load(vconf_value);
618 SETTING_TRACE("path : %s is not supported file format", vconf_value);
619 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
621 SETTING_TRACE("path : %s is SUPPORT file format", vconf_value);
624 /* error handling here */
625 if (_is_file_accessible(vconf_value) != 0)
626 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
628 if (system_setting_vconf_set_value_string(VCONFKEY_IDLE_LOCK_BGSET, vconf_value)) {
629 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
632 return SYSTEM_SETTINGS_ERROR_NONE;
635 int system_setting_set_font_size(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
639 vconf_value = (int *)value;
641 if (*vconf_value < 0 || *vconf_value > SYSTEM_SETTINGS_FONT_SIZE_GIANT) {
642 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
645 if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, *vconf_value)) {
646 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
650 return SYSTEM_SETTINGS_ERROR_NONE;
655 void *font_conf_doc_parse(char *doc_name, char *font_name)
658 xmlDocPtr doc = NULL;
659 xmlNodePtr cur = NULL;
660 xmlNodePtr cur2 = NULL;
661 xmlNodePtr cur3 = NULL;
664 doc = xmlParseFile(doc_name);
666 cur = xmlDocGetRootElement(doc);
674 if (xmlStrcmp(cur->name, (const xmlChar *)"fontconfig")) {
680 cur = cur->xmlChildrenNode;
682 Eina_Bool is_changed = EINA_FALSE;
683 while (cur != NULL) {
684 if ((!xmlStrcmp(cur->name, (const xmlChar *)"match"))) {
685 cur2 = cur->xmlChildrenNode;
686 while (cur2 != NULL) {
687 if ((!xmlStrcmp(cur2->name, (const xmlChar *)"edit"))) {
688 xmlChar *name = xmlGetProp(cur2, (const xmlChar *)"name");
689 /* if name is not 'family', break */
690 if (xmlStrcmp(name, (const xmlChar *)"family")) {
698 cur3 = cur2->xmlChildrenNode;
699 while (cur3 != NULL) {
700 if ((!xmlStrcmp(cur3->name, (const xmlChar *)"string"))) {
701 xmlNodeSetContent(cur3->xmlChildrenNode, (const xmlChar *)font_name);
702 key = xmlNodeListGetString(doc, cur3->xmlChildrenNode, 1);
705 is_changed = EINA_TRUE;
712 } else if ((!xmlStrcmp(cur->name, (const xmlChar *)"alias"))) {
713 cur2 = cur->xmlChildrenNode;
714 while (cur2 != NULL) {
715 if ((!xmlStrcmp(cur2->name, (const xmlChar *)"family"))) {
716 xmlNodeSetContent(cur2->xmlChildrenNode, (const xmlChar *)font_name);
717 key = xmlNodeListGetString(doc, cur2->xmlChildrenNode, 1);
720 is_changed = EINA_TRUE;
721 } else if ((!xmlStrcmp(cur2->name, (const xmlChar *)"prefer"))) {
722 cur3 = cur2->xmlChildrenNode;
723 while (cur3 != NULL) {
724 if ((!xmlStrcmp(cur3->name, (const xmlChar *)"family"))) {
725 xmlNodeSetContent(cur3->xmlChildrenNode, (const xmlChar *)font_name);
726 key = xmlNodeListGetString(doc, cur3->xmlChildrenNode, 1);
729 is_changed = EINA_TRUE;
751 int system_setting_set_font_type(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
754 char *font_name = NULL;
755 font_name = (char *)value;
757 /* get current font list */
758 int is_found = __is_available_font(font_name);
761 SETTING_TRACE("found font : %s ", font_name);
763 SETTING_TRACE(" NOT found font : %s ", font_name);
764 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
767 bool bsave = font_config_set(font_name);
770 SETTING_TRACE(" font type save error by font_config_set() ");
771 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
773 SETTING_TRACE(" save OK - font_config_set() ");
776 xmlDocPtr doc = (xmlDocPtr)font_conf_doc_parse(SETTING_FONT_CONF_FILE, font_name);
778 xmlSaveFormatFile(SETTING_FONT_CONF_FILE, doc, 0);
783 font_config_set_notification();
786 vconf_value = (char *)value;
788 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, vconf_value)) {
789 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
791 return SYSTEM_SETTINGS_ERROR_NONE;
794 int system_setting_set_motion_activation(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
798 vconf_value = (bool *)value;
799 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_MOTION_ACTIVATION, *vconf_value)) {
800 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
802 return SYSTEM_SETTINGS_ERROR_NONE;
805 int system_setting_set_usb_debugging_option(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_USB_DEBUG_MODE_BOOL, *vconf_value)) {
811 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
813 return SYSTEM_SETTINGS_ERROR_NONE;
817 int system_setting_set_3g_data_network(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
821 vconf_value = (bool *)value;
822 if (system_setting_vconf_set_value_bool(VCONFKEY_3G_ENABLE, *vconf_value)) {
823 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
826 return SYSTEM_SETTINGS_ERROR_NONE;
829 static int category_func(const char *name, void *user_data)
832 static char *category = "lock-screen";
833 if (name && !strcmp(name, category)) {
834 SETTING_TRACE(" SAME ");
837 SETTING_TRACE(" DIFFERENT -- %s, category -- %s ", name, category);
846 * set 'swipe type' if current lockscreen app is 'com.samsung.lockscreen'
849 int system_setting_set_lockscreen_app(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
853 vconf_value = (char *)value; /* ex) com.samsung.lockscreen */
856 pkgmgrinfo_appinfo_h handle;
857 char *apptype = NULL;
858 r = pkgmgrinfo_appinfo_get_appinfo(vconf_value, &handle);
859 if (r != PMINFO_R_OK) {
860 SETTING_TRACE("*** pkginfo failed ");
861 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
863 SETTING_TRACE("%x", handle);
866 int ret = pkgmgrinfo_appinfo_foreach_category(handle, category_func, (void *)"lock-screen");
867 if (ret != PMINFO_R_OK) {
868 pkgmgrinfo_appinfo_destroy_appinfo(handle);
869 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
872 pkgmgrinfo_appinfo_destroy_appinfo(handle);
873 /*----------------------------------------------------------------------------------- */
875 if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_SCREEN_LOCK_TYPE_INT, &locktype)) {
876 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
879 if (locktype == SETTING_SCREEN_LOCK_TYPE_PASSWORD)
880 return SYSTEM_SETTINGS_ERROR_LOCKSCREEN_APP_PASSWORD_MODE;
882 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_3RD_LOCK_PKG_NAME_STR, vconf_value)) {
883 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
886 if (vconf_value && strcmp(vconf_value, "com.samsung.lockscreen") == 0) {
887 if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_SCREEN_LOCK_TYPE_INT, SETTING_SCREEN_LOCK_TYPE_SWIPE)) {
888 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
891 return SYSTEM_SETTINGS_ERROR_NONE;
894 /*/////////////////////////////////////////////////////////////////////////////////////////////// */
897 int system_setting_set_changed_callback_incoming_call_ringtone(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
900 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR, SYSTEM_SETTINGS_KEY_INCOMING_CALL_RINGTONE, 0, user_data);
903 int system_setting_unset_changed_callback_incoming_call_ringtone(system_settings_key_e key)
906 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR, 0);
909 int system_setting_set_changed_callback_email_alert_ringtone(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
912 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, SYSTEM_SETTINGS_KEY_EMAIL_ALERT_RINGTONE, 0, user_data);
915 int system_setting_unset_changed_callback_email_alert_ringtone(system_settings_key_e key)
918 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, 0);
921 int system_setting_set_changed_callback_wallpaper_home_screen(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
924 return system_setting_vconf_set_changed_cb(VCONFKEY_BGSET, SYSTEM_SETTINGS_KEY_WALLPAPER_HOME_SCREEN, 0, user_data);
927 int system_setting_unset_changed_callback_wallpaper_home_screen(system_settings_key_e key)
930 return system_setting_vconf_unset_changed_cb(VCONFKEY_BGSET, 0);
933 int system_setting_set_changed_callback_wallpaper_lock_screen(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
936 return system_setting_vconf_set_changed_cb(VCONFKEY_IDLE_LOCK_BGSET, SYSTEM_SETTINGS_KEY_WALLPAPER_LOCK_SCREEN, 0, user_data);
939 int system_setting_unset_changed_callback_wallpaper_lock_screen(system_settings_key_e key)
942 return system_setting_vconf_unset_changed_cb(VCONFKEY_IDLE_LOCK_BGSET, 0);
945 int system_setting_set_changed_callback_font_size(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
948 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, SYSTEM_SETTINGS_KEY_FONT_SIZE, 1, user_data);
951 int system_setting_unset_changed_callback_font_size(system_settings_key_e key)
954 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, 1);
957 int system_setting_set_changed_callback_usb_debugging_option(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
960 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_USB_DEBUG_MODE_BOOL, SYSTEM_SETTINGS_KEY_USB_DEBUGGING_ENABLED, 1, user_data);
963 int system_setting_unset_changed_callback_usb_debugging_option(system_settings_key_e key)
966 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_USB_DEBUG_MODE_BOOL, 1);
969 int system_setting_set_changed_callback_3g_data_network(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
972 return system_setting_vconf_set_changed_cb(VCONFKEY_3G_ENABLE, SYSTEM_SETTINGS_KEY_3G_DATA_NETWORK_ENABLED, 1, user_data);
975 int system_setting_unset_changed_callback_3g_data_network(system_settings_key_e key)
978 return system_setting_vconf_unset_changed_cb(VCONFKEY_3G_ENABLE, 1);
981 int system_setting_set_changed_callback_lockscreen_app(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
984 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_3RD_LOCK_PKG_NAME_STR, SYSTEM_SETTINGS_KEY_LOCKSCREEN_APP, 1, user_data);
987 int system_setting_unset_changed_callback_lockscreen_app(system_settings_key_e key)
990 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_3RD_LOCK_PKG_NAME_STR, 1);
995 * @todo need to add custom event notification method
997 int system_setting_set_changed_callback_font_type(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1000 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, SYSTEM_SETTINGS_KEY_FONT_TYPE, 2, user_data);
1003 int system_setting_unset_changed_callback_font_type(system_settings_key_e key)
1005 SETTING_TRACE_BEGIN;
1006 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, 2);
1009 /* TODO : 2th argument, callback, is not in use. */
1010 int system_setting_set_changed_callback_motion_activation(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1012 SETTING_TRACE_BEGIN;
1013 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_MOTION_ACTIVATION, SYSTEM_SETTINGS_KEY_MOTION_ACTIVATION, 3, user_data);
1016 int system_setting_unset_changed_callback_motion_activation(system_settings_key_e key)
1018 SETTING_TRACE_BEGIN;
1019 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_MOTION_ACTIVATION, 3);
1022 static char *_get_cur_font()
1024 SETTING_TRACE_BEGIN;
1025 xmlDocPtr doc = NULL;
1026 xmlNodePtr cur = NULL;
1027 xmlNodePtr cur2 = NULL;
1028 xmlNodePtr cur3 = NULL;
1029 xmlChar *key = NULL;
1031 char *font_name = NULL;
1033 doc = xmlParseFile(SETTING_FONT_CONF_FILE);
1035 cur = xmlDocGetRootElement(doc);
1043 if (xmlStrcmp(cur->name, (const xmlChar *)"fontconfig")) {
1049 cur = cur->xmlChildrenNode;
1051 while (cur != NULL) {
1052 if ((!xmlStrcmp(cur->name, (const xmlChar *)"match"))) {
1053 cur2 = cur->xmlChildrenNode;
1054 while (cur2 != NULL) {
1055 if ((!xmlStrcmp(cur2->name, (const xmlChar *)"edit"))) {
1056 cur3 = cur2->xmlChildrenNode;
1057 while (cur3 != NULL) {
1058 if ((!xmlStrcmp(cur3->name, (const xmlChar *)"string"))) {
1059 key = xmlNodeListGetString(doc, cur3->xmlChildrenNode, 1);
1061 font_name = g_strdup((char *)key);
1082 static void font_config_set_notification()
1084 SETTING_TRACE_BEGIN;
1087 Ecore_X_Window ecore_win = ecore_x_window_root_first_get();
1088 Ecore_X_Atom atom = ecore_x_atom_get("FONT_TYPE_change");
1089 ecore_x_window_prop_string_set(ecore_win, atom, "tizen");
1093 int __is_available_font(char *font_name)
1095 SETTING_TRACE_BEGIN;
1096 FcObjectSet *os = NULL;
1097 FcFontSet *fs = NULL;
1098 FcPattern *pat = NULL;
1099 Eina_List *list = NULL;
1100 FcConfig *font_config = NULL;
1104 if (font_name == NULL)
1107 font_config = FcInitLoadConfigAndFonts();
1109 /*setting_retvm_if(font_config == NULL, NULL, "Failed: FcInitLoadConfigAndFonts"); */
1111 char *locale = setlocale(0, NULL);
1113 pat = FcPatternCreate();
1115 os = FcObjectSetBuild(FC_FAMILY, FC_FILE, FC_FAMILYLANG, (char *) 0);
1118 fs = FcFontList(font_config, pat, os);
1119 FcObjectSetDestroy(os);
1124 FcPatternDestroy(pat);
1130 SETTING_TRACE("fs->nfont = %d", fs->nfont);
1132 for (j = 0; j < fs->nfont; j++) {
1133 FcChar8 *family = NULL;
1134 FcChar8 *file = NULL;
1136 if (FcPatternGetString(fs->fonts[j], FC_FILE, 0, &file) == FcResultMatch) {
1137 int preload_path_len = strlen(SETTING_FONT_PRELOAD_FONT_PATH);
1138 int download_path_len = strlen(SETTING_FONT_DOWNLOADED_FONT_PATH);
1140 if (file && (!strncmp((const char *)file, SETTING_FONT_PRELOAD_FONT_PATH, preload_path_len)
1141 || !strncmp((const char *)file, SETTING_FONT_DOWNLOADED_FONT_PATH, download_path_len))) {
1142 char *family_result = NULL;
1143 FcChar8 *lang = NULL;
1145 if (FcPatternGetString(fs->fonts[j], FC_FAMILY, id, &family) != FcResultMatch) {
1148 if (FcPatternGetString(fs->fonts[j], FC_FAMILYLANG, id, &lang) != FcResultMatch) {
1151 family_result = (char *)family;
1153 /* Find proper family name for current locale. */
1154 while (locale && family && lang) {
1155 if (!strncmp(locale, (char *)lang, strlen((char *)lang))) {
1156 family_result = (char *)family;
1160 /* I will set english as default family language. */
1161 /* If there is no proper family language for current locale, */
1162 /* we have to show the english family name. */
1163 if (!strcmp(lang, "en")) {
1164 family_result = (char *)family;
1167 if (FcPatternGetString(fs->fonts[j], FC_FAMILY, id, &family) != FcResultMatch) {
1170 if (FcPatternGetString(fs->fonts[j], FC_FAMILYLANG, id, &lang) != FcResultMatch) {
1175 if (family_result) {
1176 SETTING_TRACE("-------- FONT - family_result = %s", (char *)family_result);
1177 if (strcmp(family_result, font_name) == 0) {
1185 FcFontSetDestroy(fs);
1188 FcConfigDestroy(font_config);
1194 static char *_get_default_font()
1196 SETTING_TRACE_BEGIN;
1197 xmlDocPtr doc = NULL;
1198 xmlNodePtr cur = NULL;
1199 xmlNodePtr cur2 = NULL;
1200 xmlNodePtr cur3 = NULL;
1201 xmlChar *key = NULL;
1202 struct _xmlAttr *properties = NULL;
1203 char *default_font_name = NULL;
1205 doc = xmlParseFile(SETTING_DEFAULT_FONT_CONF_FILE);
1207 cur = xmlDocGetRootElement(doc);
1215 if (xmlStrcmp(cur->name, (const xmlChar *)"fontconfig")) {
1221 cur = cur->xmlChildrenNode;
1223 while (cur != NULL) {
1224 if ((!xmlStrcmp(cur->name, (const xmlChar *)"match"))) {
1225 cur2 = cur->xmlChildrenNode;
1226 while (cur2 != NULL) {
1227 if ((!xmlStrcmp(cur2->name, (const xmlChar *)"edit"))) {
1228 properties = cur2->properties;
1229 /*find the "name" property*/
1230 while (NULL != properties) {
1231 if (!xmlStrcmp(properties->name, (const xmlChar *)"name")) {
1234 properties = properties->next;
1237 /*If the value of "name" property is "family", then get the child node string,
1238 it shall be the default font type*/
1239 if (NULL != properties && !xmlStrcmp(properties->children->content, (const xmlChar *)"family")) {
1240 cur3 = cur2->xmlChildrenNode;
1241 while (cur3 != NULL) {
1242 if ((!xmlStrcmp(cur3->name, (const xmlChar *)"string"))) {
1243 key = xmlNodeListGetString(doc, cur3->xmlChildrenNode, 1);
1244 default_font_name = g_strdup((char *)key);
1249 return default_font_name;
1266 static bool font_config_set(char *font_name)
1268 SETTING_TRACE_BEGIN;
1269 Eina_List *text_classes = NULL;
1270 Elm_Text_Class *etc = NULL;
1271 const Eina_List *l = NULL;
1272 Eina_List *fo_list = NULL;
1273 Elm_Font_Overlay *efo = NULL;
1275 int font_size = __font_size_get();
1278 text_classes = elm_config_text_classes_list_get();
1280 fo_list = (Eina_List *)elm_config_font_overlay_list_get();
1282 Eina_List *ll = NULL;
1283 Eina_List *l_next = NULL;
1285 Eina_Bool slp_medium_exist = EINA_FALSE;
1286 Eina_Bool slp_roman_exist = EINA_FALSE;
1287 Eina_Bool slp_bold_exist = EINA_FALSE;
1288 Eina_Bool slp_regular_exist = EINA_FALSE;
1291 Eina_Bool tizen_exist = EINA_FALSE;
1293 EINA_LIST_FOREACH_SAFE(fo_list, ll, l_next, efo) {
1294 if (!strcmp(efo->text_class, "tizen_medium")) {
1295 elm_config_font_overlay_set(efo->text_class, (const char *)font_name, efo->size);
1296 slp_medium_exist = EINA_TRUE;
1297 } else if (!strcmp(efo->text_class, "tizen_roman")) {
1298 elm_config_font_overlay_set(efo->text_class, (const char *)font_name, efo->size);
1299 slp_roman_exist = EINA_TRUE;
1300 } else if (!strcmp(efo->text_class, "tizen_bold")) {
1301 elm_config_font_overlay_set(efo->text_class, (const char *)font_name, efo->size);
1302 slp_bold_exist = EINA_TRUE;
1303 } else if (!strcmp(efo->text_class, "tizen_regular")) {
1304 elm_config_font_overlay_set(efo->text_class, (const char *)font_name, efo->size);
1305 slp_regular_exist = EINA_TRUE;
1309 if (!strcmp(efo->text_class, "tizen")) {
1310 elm_config_font_overlay_set(efo->text_class, (const char *)font_name, efo->size);
1311 tizen_exist = EINA_TRUE;
1316 /* if slp_XX do not exist, need to set them, font size is -100(100%) */
1317 if (slp_medium_exist == EINA_FALSE) {
1318 elm_config_font_overlay_set("tizen_medium", (const char *)font_name, MIDDLE_FONT_DPI);
1320 if (slp_roman_exist == EINA_FALSE) {
1321 elm_config_font_overlay_set("tizen_roman", (const char *)font_name, MIDDLE_FONT_DPI);
1323 if (slp_bold_exist == EINA_FALSE) {
1324 elm_config_font_overlay_set("tizen_bold", (const char *)font_name, MIDDLE_FONT_DPI);
1326 if (slp_regular_exist == EINA_FALSE) {
1327 elm_config_font_overlay_set("tizen_regular", (const char *)font_name, MIDDLE_FONT_DPI);
1331 if (tizen_exist == EINA_FALSE) {
1332 elm_config_font_overlay_set("tizen", (const char *)font_name, MIDDLE_FONT_DPI);
1335 elm_config_font_overlay_set("tizen", (const char *)font_name, MIDDLE_FONT_DPI);
1338 elm_config_font_overlay_set("tizen", (const char *)font_name, MIDDLE_FONT_DPI);
1340 EINA_LIST_FOREACH(text_classes, l, etc) {
1344 EINA_LIST_FOREACH(fo_list, ll, efo) {
1345 if (!strcmp(etc->name, efo->text_class)) {
1349 elm_config_font_overlay_set(etc->name, (const char *)font_name, size);
1351 elm_config_text_classes_list_free(text_classes);
1352 text_classes = NULL;
1354 /* add new function */
1355 #ifdef USE_EFL_ASSIST
1356 ea_theme_system_font_set(font_name, font_size);
1357 ea_theme_system_fonts_apply();
1360 elm_config_font_overlay_apply();
1361 elm_config_all_flush();
1366 static void __font_size_set()
1368 SETTING_TRACE_BEGIN;
1369 Eina_List *text_classes = NULL;
1370 Elm_Text_Class *etc = NULL;
1371 const Eina_List *l = NULL;
1372 int font_size = __font_size_get();
1373 char *font_name = _get_cur_font();
1375 if (font_size == -1) {
1379 text_classes = elm_config_text_classes_list_get();
1381 EINA_LIST_FOREACH(text_classes, l, etc) {
1382 elm_config_font_overlay_set(etc->name, font_name, font_size);
1385 elm_config_text_classes_list_free(text_classes);
1387 #ifdef USE_EFL_ASSIST
1388 ea_theme_system_font_set(font_name, font_size);
1389 ea_theme_system_fonts_apply();
1392 elm_config_font_overlay_apply();
1393 elm_config_all_flush();
1396 text_classes = NULL;
1400 static int __font_size_get()
1402 SETTING_TRACE_BEGIN;
1406 int vconf_value = -1;
1407 if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, &vconf_value)) {
1411 switch (vconf_value) {
1412 case SYSTEM_SETTINGS_FONT_SIZE_SMALL:
1413 font_size = SMALL_FONT_DPI;
1415 case SYSTEM_SETTINGS_FONT_SIZE_NORMAL:
1416 font_size = MIDDLE_FONT_DPI;
1418 case SYSTEM_SETTINGS_FONT_SIZE_LARGE:
1419 font_size = LARGE_FONT_DPI;
1421 case SYSTEM_SETTINGS_FONT_SIZE_HUGE:
1422 font_size = HUGE_FONT_DPI;
1424 case SYSTEM_SETTINGS_FONT_SIZE_GIANT:
1425 font_size = GIANT_FONT_DPI;
1428 font_size = MIDDLE_FONT_DPI;
1434 /*//////////////////////////////////////////////////////////////////////////////////////// */
1435 /*--------------------------------------- */
1436 int system_setting_get_locale_country(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1438 SETTING_TRACE_BEGIN;
1439 char *vconf_value = NULL;
1440 if (system_setting_vconf_get_value_string(VCONFKEY_REGIONFORMAT, &vconf_value)) {
1441 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1444 /* parsing validation */
1447 snprintf(arr, 20, vconf_value);
1449 *value = strdup(arr);
1453 return SYSTEM_SETTINGS_ERROR_NONE;
1456 int system_setting_set_locale_country(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1458 SETTING_TRACE_BEGIN;
1459 char *vconf_value = NULL;
1460 vconf_value = (char *)value;
1462 char *ext = "UTF-8";
1465 snprintf(arr, 20, "%s.%s", vconf_value, ext);
1467 if (system_setting_vconf_set_value_string(VCONFKEY_REGIONFORMAT, arr)) {
1468 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1470 return SYSTEM_SETTINGS_ERROR_NONE;
1473 int system_setting_set_changed_callback_locale_country(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1475 SETTING_TRACE_BEGIN;
1476 return system_setting_vconf_set_changed_cb(VCONFKEY_REGIONFORMAT, SYSTEM_SETTINGS_KEY_LOCALE_COUNTRY, 3, user_data);
1479 int system_setting_unset_changed_callback_locale_country(system_settings_key_e key)
1481 SETTING_TRACE_BEGIN;
1482 return system_setting_vconf_unset_changed_cb(VCONFKEY_REGIONFORMAT, 3);
1486 /*--------------------------------------- */
1487 int system_setting_get_locale_language(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1489 SETTING_TRACE_BEGIN;
1490 char *vconf_value = NULL;
1491 if (system_setting_vconf_get_value_string(VCONFKEY_LANGSET, &vconf_value)) {
1492 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1495 /* parsing validation */
1498 snprintf(arr, 20, vconf_value);
1500 *value = strdup(arr);
1503 return SYSTEM_SETTINGS_ERROR_NONE;
1506 int system_setting_set_locale_language(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1508 SETTING_TRACE_BEGIN;
1509 char *vconf_value = NULL;
1510 vconf_value = (char *)value;
1512 char *ext = "UTF-8";
1515 snprintf(arr, 20, "%s.%s", vconf_value, ext);
1517 if (system_setting_vconf_set_value_string(VCONFKEY_LANGSET, arr)) {
1518 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1520 return SYSTEM_SETTINGS_ERROR_NONE;
1523 int system_setting_set_changed_callback_locale_language(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1525 SETTING_TRACE_BEGIN;
1526 /*return system_setting_vconf_set_changed_cb(VCONFKEY_LANGSET, SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, 3, user_data ); */
1527 return system_setting_vconf_set_changed_cb(VCONFKEY_LANGSET, SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, 100, user_data);
1530 int system_setting_unset_changed_callback_locale_language(system_settings_key_e key)
1532 SETTING_TRACE_BEGIN;
1533 return system_setting_vconf_unset_changed_cb(VCONFKEY_LANGSET, 100);
1536 /*--------------------------------------- */
1537 int system_setting_get_locale_timeformat_24hour(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1539 SETTING_TRACE_BEGIN;
1542 if (system_setting_vconf_get_value_int(VCONFKEY_REGIONFORMAT_TIME1224, &vconf_value)) {
1543 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1547 if (vconf_value == VCONFKEY_TIME_FORMAT_12)
1549 else if (vconf_value == VCONFKEY_TIME_FORMAT_24)
1552 *value = (void *)ret_value;
1554 return SYSTEM_SETTINGS_ERROR_NONE;
1557 int system_setting_set_locale_timeformat_24hour(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1559 SETTING_TRACE_BEGIN;
1562 vconf_value = (bool *)value;
1565 if (system_setting_vconf_set_value_int(VCONFKEY_REGIONFORMAT_TIME1224, VCONFKEY_TIME_FORMAT_24)) {
1566 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1570 if (system_setting_vconf_set_value_int(VCONFKEY_REGIONFORMAT_TIME1224, VCONFKEY_TIME_FORMAT_12)) {
1571 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1576 return SYSTEM_SETTINGS_ERROR_NONE;
1579 int system_setting_set_changed_callback_locale_timeformat_24hour(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1581 SETTING_TRACE_BEGIN;
1582 return system_setting_vconf_set_changed_cb(VCONFKEY_REGIONFORMAT_TIME1224, SYSTEM_SETTINGS_KEY_LOCALE_TIMEFORMAT_24HOUR, 3, user_data);
1585 int system_setting_unset_changed_callback_locale_timeformat_24hour(system_settings_key_e key)
1587 SETTING_TRACE_BEGIN;
1588 return system_setting_vconf_unset_changed_cb(VCONFKEY_REGIONFORMAT_TIME1224, 3);
1591 int system_setting_get_locale_timezone(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1593 SETTING_TRACE_BEGIN;
1596 ssize_t len = readlink(SETTING_TZONE_SYMLINK_PATH, tzpath, sizeof(tzpath) - 1);
1600 SETTING_TRACE("parse error for SETTING_TZONE_SYMLINK_PATH");
1601 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1603 /* "/usr/share/zoneinfo/Asia/Seoul" */
1604 SETTING_TRACE("tzpath : %s ", &tzpath[20]);
1605 *value = strdup(&tzpath[20]);
1607 *value = vconf_get_str(VCONFKEY_SETAPPL_TIMEZONE_ID);
1609 return SYSTEM_SETTINGS_ERROR_NONE;
1612 int system_setting_set_changed_callback_locale_timezone_changed(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1614 SETTING_TRACE_BEGIN;
1615 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
1618 int system_setting_unset_changed_callback_locale_timezone_changed(system_settings_key_e key)
1620 SETTING_TRACE_BEGIN;
1621 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
1625 int system_setting_get_time_changed(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1627 SETTING_TRACE_BEGIN;
1629 cur_tick = time(NULL);
1630 *value = (void *)cur_tick;
1631 /* struct tm * localtime = time (cur_tick); */
1632 /* printf("%s\n", ctime(&cur_tick); */
1633 return SYSTEM_SETTINGS_ERROR_NONE;
1637 int system_setting_set_changed_callback_time_changed(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1639 SETTING_TRACE_BEGIN;
1640 return system_setting_vconf_set_changed_cb(VCONFKEY_SYSTEM_TIME_CHANGED, SYSTEM_SETTINGS_KEY_TIME_CHANGED, 3, user_data);
1643 int system_setting_unset_changed_callback_time_changed(system_settings_key_e key)
1645 SETTING_TRACE_BEGIN;
1646 return system_setting_vconf_unset_changed_cb(VCONFKEY_SYSTEM_TIME_CHANGED, 3);
1651 /* SYSTEM_SETTINGS_KEY_SOUND_LOCK */
1652 int system_setting_get_sound_lock(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1654 SETTING_TRACE_BEGIN;
1657 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_SOUND_LOCK_BOOL, &vconf_value)) {
1658 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1660 *value = (void *)vconf_value;
1662 return SYSTEM_SETTINGS_ERROR_NONE;
1665 int system_setting_set_changed_callback_sound_lock(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1667 SETTING_TRACE_BEGIN;
1668 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_SOUND_LOCK_BOOL, SYSTEM_SETTINGS_KEY_SOUND_LOCK, 3, user_data);
1671 int system_setting_unset_changed_callback_sound_lock(system_settings_key_e key)
1673 SETTING_TRACE_BEGIN;
1674 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_SOUND_LOCK_BOOL, 3);
1678 * a = VCONFKEY_SETAPPL_SOUND_STATUS_BOOL b = VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL
1680 * a == false, b == false --> silent mode
1681 * a == true, b == false --> sound mode
1682 * a == false, b == true --> vibration mode
1684 int system_setting_get_sound_silent_mode(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1686 SETTING_TRACE_BEGIN;
1691 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, &sound_cond)) {
1692 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1695 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, &vib_cond)) {
1696 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1699 if (sound_cond == false && vib_cond == false) {
1701 *value = (void *)vconf_value;
1703 vconf_value = false;
1704 *value = (void *)vconf_value;
1706 return SYSTEM_SETTINGS_ERROR_NONE;
1710 * a = VCONFKEY_SETAPPL_SOUND_STATUS_BOOL b = VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL
1712 * a == false, b == false --> silent mode
1713 * a == true, b == false --> sound mode
1715 int system_setting_set_sound_silent_mode(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1717 SETTING_TRACE_BEGIN;
1720 vconf_value = (bool *)value;
1722 bool vconf_sound = false;
1723 bool vconf_vib = false;
1726 vconf_sound = false;
1733 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, vconf_sound)) {
1734 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1736 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, vconf_vib)) {
1737 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1740 return SYSTEM_SETTINGS_ERROR_NONE;
1746 int system_setting_set_changed_callback_sound_silent_mode(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1748 SETTING_TRACE_BEGIN;
1749 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, SYSTEM_SETTINGS_KEY_SOUND_SILENT_MODE, 3, user_data);
1753 int system_setting_unset_changed_callback_sound_silent_mode(system_settings_key_e key)
1755 SETTING_TRACE_BEGIN;
1756 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, 3);
1759 /* SYSTEM_SETTINGS_KEY_SOUND_TOUCH */
1760 int system_setting_get_sound_touch(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1762 SETTING_TRACE_BEGIN;
1765 int ret = system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL, &vconf_value);
1766 if (ret != SYSTEM_SETTINGS_ERROR_NONE) {
1769 *value = (void *)vconf_value;
1773 int system_setting_set_changed_callback_sound_touch(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1775 SETTING_TRACE_BEGIN;
1776 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL, SYSTEM_SETTINGS_KEY_SOUND_TOUCH, 2, user_data);
1779 int system_setting_unset_changed_callback_sound_touch(system_settings_key_e key)
1781 SETTING_TRACE_BEGIN;
1782 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL, 2);
1786 /* SYSTEM_SETTINGS_KEY_SOUND_LOCK */
1787 int system_setting_get_sound_lock(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1791 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_SOUND_LOCK_BOOL, &vconf_value)) {
1792 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1794 *value = (void *)vconf_value;
1796 return SYSTEM_SETTINGS_ERROR_NONE;
1800 int system_setting_get_auto_rotation_mode(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1802 SETTING_TRACE_BEGIN;
1805 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, &vconf_value)) {
1806 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1808 *value = (void *)vconf_value;
1810 return SYSTEM_SETTINGS_ERROR_NONE;
1813 int system_setting_set_auto_rotation_mode(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1815 SETTING_TRACE_BEGIN;
1817 vconf_value = (bool *)value;
1818 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, *vconf_value)) {
1819 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1822 return SYSTEM_SETTINGS_ERROR_NONE;
1825 int system_setting_set_changed_callback_auto_rotation_mode(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1827 SETTING_TRACE_BEGIN;
1828 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, SYSTEM_SETTINGS_KEY_DISPLAY_SCREEN_ROTATION_AUTO, 2, user_data);
1831 int system_setting_unset_changed_callback_auto_rotation_mode(system_settings_key_e key)
1833 SETTING_TRACE_BEGIN;
1834 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, 2);
1837 int system_setting_get_screen_backlight_time(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1839 SETTING_TRACE_BEGIN;
1842 if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, &vconf_value)) {
1843 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1845 *value = (void *)vconf_value;
1847 return SYSTEM_SETTINGS_ERROR_NONE;
1851 int system_setting_set_screen_backlight_time(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1853 SETTING_TRACE_BEGIN;
1855 vconf_value = (int *)value;
1857 if (!(*vconf_value > 0 && *vconf_value < 600)) {
1858 SETTING_TRACE(" ERR Betweeny here 0 ~ 600");
1859 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
1862 if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, *vconf_value)) {
1863 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1866 return SYSTEM_SETTINGS_ERROR_NONE;
1869 int system_setting_set_changed_callback_screen_backlight_time(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1871 SETTING_TRACE_BEGIN;
1872 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, SYSTEM_SETTINGS_KEY_DISPLAY_SCREEN_ROTATION_AUTO, 2, user_data);
1875 int system_setting_unset_changed_callback_screen_backlight_time(system_settings_key_e key)
1877 SETTING_TRACE_BEGIN;
1878 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, 2);
1881 int system_setting_get_sound_notification(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1883 SETTING_TRACE_BEGIN;
1884 char *vconf_value = NULL;
1885 if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, &vconf_value)) {
1886 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1889 *value = vconf_value;
1890 return SYSTEM_SETTINGS_ERROR_NONE;
1893 int system_setting_set_sound_notification(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1895 SETTING_TRACE_BEGIN;
1896 char *vconf_value = NULL;
1897 vconf_value = (char *)value;
1899 int is_load = _is_file_accessible(vconf_value);
1901 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, vconf_value)) {
1902 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1905 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1908 return SYSTEM_SETTINGS_ERROR_NONE;
1911 int system_setting_set_changed_callback_sound_notification(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1913 SETTING_TRACE_BEGIN;
1914 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, SYSTEM_SETTINGS_KEY_INCOMING_CALL_RINGTONE, 0, user_data);
1917 int system_setting_unset_changed_callback_sound_notification(system_settings_key_e key)
1919 SETTING_TRACE_BEGIN;
1920 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, 0);
1923 int system_setting_get_notification_repetition_period(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1925 SETTING_TRACE_BEGIN;
1928 if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_NOTI_MSG_ALERT_REP_TYPE_INT, &vconf_value)) {
1929 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1931 *value = (void *)vconf_value;
1933 return SYSTEM_SETTINGS_ERROR_NONE;
1936 int system_setting_set_notification_repetition_period(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1938 SETTING_TRACE_BEGIN;
1940 vconf_value = (int *)value;
1942 if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_NOTI_MSG_ALERT_REP_TYPE_INT, *vconf_value)) {
1943 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1946 return SYSTEM_SETTINGS_ERROR_NONE;
1949 int system_setting_set_changed_callback_notification_repetition_period(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1951 SETTING_TRACE_BEGIN;
1952 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);
1955 int system_setting_unset_changed_callback_notification_repetition_period(system_settings_key_e key)
1957 SETTING_TRACE_BEGIN;
1958 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_ALERT_REP_TYPE_INT, 1);
1961 int system_setting_get_device_name(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1963 SETTING_TRACE_BEGIN;
1964 char *vconf_value = NULL;
1965 if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_DEVICE_NAME_STR, &vconf_value)) {
1966 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1969 *value = vconf_value;
1970 return SYSTEM_SETTINGS_ERROR_NONE;
1973 int system_setting_set_device_name(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1975 SETTING_TRACE_BEGIN;
1976 char *vconf_value = NULL;
1977 vconf_value = (char *)value;
1979 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_DEVICE_NAME_STR, vconf_value)) {
1980 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1983 return SYSTEM_SETTINGS_ERROR_NONE;
1986 int system_setting_set_changed_callback_device_name(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1988 SETTING_TRACE_BEGIN;
1989 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_DEVICE_NAME_STR, SYSTEM_SETTINGS_KEY_DEVICE_NAME, 0, user_data);
1992 int system_setting_unset_changed_callback_device_name(system_settings_key_e key)
1994 SETTING_TRACE_BEGIN;
1995 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_DEVICE_NAME_STR, 0);
1998 /*---------------------------------------------- */
1999 int system_setting_get_network_flight_mode(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
2001 SETTING_TRACE_BEGIN;
2003 if (system_setting_vconf_get_value_bool(VCONFKEY_TELEPHONY_FLIGHT_MODE, &vconf_value)) {
2004 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2006 *value = (void *)vconf_value;
2008 return SYSTEM_SETTINGS_ERROR_NONE;
2011 int system_setting_set_changed_callback_network_flight_mode(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
2013 SETTING_TRACE_BEGIN;
2014 return system_setting_vconf_set_changed_cb(VCONFKEY_TELEPHONY_FLIGHT_MODE, SYSTEM_SETTINGS_KEY_NETWORK_FLIGHT_MODE, 3, user_data);
2017 int system_setting_unset_changed_callback_network_flight_mode(system_settings_key_e key)
2019 SETTING_TRACE_BEGIN;
2020 return system_setting_vconf_unset_changed_cb(VCONFKEY_TELEPHONY_FLIGHT_MODE, 3);
2023 int system_setting_get_network_wifi_notification(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
2025 SETTING_TRACE_BEGIN;
2027 if (system_setting_vconf_get_value_int(VCONFKEY_WIFI_ENABLE_QS, &vconf_value)) {
2028 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2031 bret = (vconf_value == VCONFKEY_WIFI_QS_ENABLE) ? true : false;
2033 *value = (void *)bret;
2034 return SYSTEM_SETTINGS_ERROR_NONE;
2037 int system_setting_set_changed_callback_network_wifi_notification(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
2039 SETTING_TRACE_BEGIN;
2040 return system_setting_vconf_set_changed_cb(VCONFKEY_WIFI_ENABLE_QS, SYSTEM_SETTINGS_KEY_NETWORK_WIFI_NOTIFICATION, 4, user_data);
2043 int system_setting_unset_changed_callback_network_wifi_notification(system_settings_key_e key)
2045 SETTING_TRACE_BEGIN;
2046 return system_setting_vconf_unset_changed_cb(VCONFKEY_WIFI_ENABLE_QS, 4);
2049 int system_setting_get_lock_state(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
2053 if (system_setting_vconf_get_value_int(VCONFKEY_IDLE_LOCK_STATE_READ_ONLY, &vconf_value)) {
2054 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2056 *value = (void *)vconf_value;
2058 return SYSTEM_SETTINGS_ERROR_NONE;
2061 int system_setting_set_lock_state(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
2063 SETTING_TRACE_BEGIN;
2065 vconf_value = (int *)value;
2067 if (system_setting_vconf_set_value_int(VCONFKEY_IDLE_LOCK_STATE_READ_ONLY, *vconf_value)) {
2068 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2071 return SYSTEM_SETTINGS_ERROR_NONE;
2074 int system_setting_set_changed_callback_lock_state(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
2076 return system_setting_vconf_set_changed_cb(VCONFKEY_IDLE_LOCK_STATE_READ_ONLY, SYSTEM_SETTINGS_KEY_LOCK_STATE, 4, user_data);
2079 int system_setting_unset_changed_callback_lock_state(system_settings_key_e key)
2081 return system_setting_vconf_unset_changed_cb(VCONFKEY_IDLE_LOCK_STATE_READ_ONLY, 4);