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)
337 ee = ecore_evas_new(NULL, 0, 0, 100, 100, NULL);
338 evas = ecore_evas_get(ee);
340 Evas_Object *img = evas_object_image_add(evas);
341 evas_object_image_file_set(img, path, NULL);
342 Evas_Load_Error ret = evas_object_image_load_error_get(img);
345 if (ret == EVAS_LOAD_ERROR_NONE) {
346 SETTING_TRACE("%s - OK", path);
349 SETTING_TRACE("%s - NO", path);
357 bool __is_supported_image_type(char *path)
363 if (evas_object_image_extension_can_load_get(path))
373 #define PATH_EXT_CHECK_REG ".(jpe?g|jpg|png|gif)$"
374 bool __is_supported_image_type_by_ext(char *file_path)
378 regmatch_t str[2048 + 1];
380 if (!file_path) return false;
383 if (ret = regcomp(&fsm, PATH_EXT_CHECK_REG, REG_ICASE | REG_EXTENDED)) {
384 SETTING_TRACE("regular expresstion fail");
389 if (regexec(&fsm, file_path, strlen(file_path) + 1, str, 0) == REG_NOMATCH) {
390 /*SETTING_TRACE("FAILED - %s", file_path[i]); */
393 /*SETTING_TRACE("MATCHED - %s", file_path[i]); */
398 #ifdef TIZEN_WEARABLE
399 static int system_setting_get_extended_wallpaper_num(const char *file_path, unsigned int *num)
403 const char *find_str = "extended_wallpaper_";
406 if (!(ch = strstr(file_path, find_str))) {
407 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
409 strncpy(buffer, file_path, ch - file_path);
410 buffer[ch - file_path] = 0;
411 sprintf(buffer + (ch - file_path), "%s%s", "", ch + strlen(find_str));
413 if (!isdigit(buffer[0])) {
414 SETTING_TRACE("%s is not number", buffer);
415 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
420 return SYSTEM_SETTINGS_ERROR_NONE;
423 static int system_setting_copy_extended_wallpaper(const char *dest_file_path, const char *source_file_path)
426 if (!source_file_path || !dest_file_path) {
427 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
433 fd = open(source_file_path, O_RDONLY);
435 SETTING_TRACE("file open failed: %s", source_file_path);
436 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
440 fd2 = open(dest_file_path, O_WRONLY | O_CREAT, S_IRWXU | S_IRWXG | S_IRWXO);
442 SETTING_TRACE("file creation failed: %s", dest_file_path);
444 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
447 while (read(fd, buf, sizeof(buf) - 1) > 0) {
448 write(fd2, buf, sizeof(buf) - 1);
454 if (chmod(dest_file_path, S_IRWXU | S_IRWXG | S_IRWXO) < 0) {
455 SETTING_TRACE("chmod failed: %s", dest_file_path);
458 return SYSTEM_SETTINGS_ERROR_NONE;
461 static int system_setting_remove_oldest_extended_wallpaper()
466 char *min_image_name = NULL;
467 unsigned int min_image_num = 0;
468 unsigned int temp_image_num = 0;
471 if ((dp = opendir("/opt/usr/data/setting/wallpaper")) == NULL) {
472 SETTING_TRACE("opendir error");
473 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
476 while ((dirp = readdir(dp))) {
477 if (!strcmp(dirp->d_name, ".") || !strcmp(dirp->d_name, ".."))
480 if (system_setting_get_extended_wallpaper_num(dirp->d_name, &temp_image_num)
481 != SYSTEM_SETTINGS_ERROR_NONE) {
482 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
485 if ((image_count == 0) || (min_image_num > temp_image_num)) {
486 min_image_num = temp_image_num;
487 min_image_name = dirp->d_name;
494 if (min_image_name) {
495 snprintf(buf, sizeof(buf) - 1, "/opt/usr/data/setting/wallpaper/%s", min_image_name);
496 if (remove(buf) < 0) { /* remove oldest image */
497 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
501 return SYSTEM_SETTINGS_ERROR_NONE;
504 static int system_setting_check_extended_wallpaper(const char *file_path)
507 if (!file_path || !strlen(file_path))
509 return (strstr(file_path, "/opt/usr/media/.bgwallpaper") != NULL);
512 #define WALLPAPER_MAX_COUNT 10
515 int system_setting_set_wallpaper_home_screen(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
519 vconf_value = (char *)value;
521 bool isok = __is_supported_image_type_load(vconf_value);
524 SETTING_TRACE("path : %s is not supported file format", vconf_value);
525 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
527 SETTING_TRACE("path : %s is SUPPORT file format", vconf_value);
530 /* error handling here */
531 if (_is_file_accessible(vconf_value) != 0)
532 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
534 if (system_setting_vconf_set_value_string(VCONFKEY_BGSET, vconf_value)) {
535 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
539 #ifdef TIZEN_WEARABLE
540 if (system_setting_check_extended_wallpaper(vconf_value)) { /* New extended wallpaper */
543 unsigned int max_image_num = 0;
544 unsigned int temp_image_num = 0;
547 if ((dp = opendir("/opt/usr/data/setting/wallpaper")) == NULL) {
548 SETTING_TRACE("Setting - dir open error!");
549 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
552 /* Check a max number of wallpapers */
553 while ((dirp = readdir(dp))) {
554 if (!strcmp(dirp->d_name, ".") || !strcmp(dirp->d_name, ".."))
557 if (system_setting_get_extended_wallpaper_num(dirp->d_name, &temp_image_num)
558 != SYSTEM_SETTINGS_ERROR_NONE) {
559 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
562 if ((image_count == 0) || (max_image_num < temp_image_num)) {
563 max_image_num = temp_image_num;
569 /* Numbering rule: Gear is odd number */
570 max_image_num = (max_image_num % 2 == 0) ? max_image_num + 1
573 char file_name_buffer[512];
574 snprintf(file_name_buffer, sizeof(file_name_buffer) - 1,
575 "/opt/usr/data/setting/wallpaper/extended_wallpaper_%d.jpg", max_image_num);
577 /* Copy image to /opt/usr/data/setting/wallpaper/ */
578 if (system_setting_copy_extended_wallpaper(file_name_buffer, vconf_value)
579 != SYSTEM_SETTINGS_ERROR_NONE) {
580 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
583 /* remove oldest wallpaper */
584 if (image_count >= WALLPAPER_MAX_COUNT) {
585 if (system_setting_remove_oldest_extended_wallpaper()
586 != SYSTEM_SETTINGS_ERROR_NONE) {
587 remove(file_name_buffer);
588 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
592 if (system_setting_vconf_set_value_string(VCONFKEY_BGSET, file_name_buffer)) {
593 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
596 if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_WALLPAPER_CHANGED_NOTI_INT,
597 VCONFKEY_WALLPAPER_CHANGED_NOTI_GEAR)) {
598 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
601 if (system_setting_vconf_set_value_string(VCONFKEY_BGSET, vconf_value)) {
602 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
607 return SYSTEM_SETTINGS_ERROR_NONE;
610 int system_setting_set_wallpaper_lock_screen(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
614 vconf_value = (char *)value;
616 bool isok = __is_supported_image_type_load(vconf_value);
619 SETTING_TRACE("path : %s is not supported file format", vconf_value);
620 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
622 SETTING_TRACE("path : %s is SUPPORT file format", vconf_value);
625 /* error handling here */
626 if (_is_file_accessible(vconf_value) != 0)
627 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
629 if (system_setting_vconf_set_value_string(VCONFKEY_IDLE_LOCK_BGSET, vconf_value)) {
630 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
633 return SYSTEM_SETTINGS_ERROR_NONE;
636 int system_setting_set_font_size(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
640 vconf_value = (int *)value;
642 if (*vconf_value < 0 || *vconf_value > SYSTEM_SETTINGS_FONT_SIZE_GIANT) {
643 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
646 if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, *vconf_value)) {
647 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
651 return SYSTEM_SETTINGS_ERROR_NONE;
656 void *font_conf_doc_parse(char *doc_name, char *font_name)
659 xmlDocPtr doc = NULL;
660 xmlNodePtr cur = NULL;
661 xmlNodePtr cur2 = NULL;
662 xmlNodePtr cur3 = NULL;
665 doc = xmlParseFile(doc_name);
667 cur = xmlDocGetRootElement(doc);
675 if (xmlStrcmp(cur->name, (const xmlChar *)"fontconfig")) {
681 cur = cur->xmlChildrenNode;
683 Eina_Bool is_changed = EINA_FALSE;
684 while (cur != NULL) {
685 if ((!xmlStrcmp(cur->name, (const xmlChar *)"match"))) {
686 cur2 = cur->xmlChildrenNode;
687 while (cur2 != NULL) {
688 if ((!xmlStrcmp(cur2->name, (const xmlChar *)"edit"))) {
689 xmlChar *name = xmlGetProp(cur2, (const xmlChar *)"name");
690 /* if name is not 'family', break */
691 if (xmlStrcmp(name, (const xmlChar *)"family")) {
699 cur3 = cur2->xmlChildrenNode;
700 while (cur3 != NULL) {
701 if ((!xmlStrcmp(cur3->name, (const xmlChar *)"string"))) {
702 xmlNodeSetContent(cur3->xmlChildrenNode, (const xmlChar *)font_name);
703 key = xmlNodeListGetString(doc, cur3->xmlChildrenNode, 1);
706 is_changed = EINA_TRUE;
713 } else if ((!xmlStrcmp(cur->name, (const xmlChar *)"alias"))) {
714 cur2 = cur->xmlChildrenNode;
715 while (cur2 != NULL) {
716 if ((!xmlStrcmp(cur2->name, (const xmlChar *)"family"))) {
717 xmlNodeSetContent(cur2->xmlChildrenNode, (const xmlChar *)font_name);
718 key = xmlNodeListGetString(doc, cur2->xmlChildrenNode, 1);
721 is_changed = EINA_TRUE;
722 } else if ((!xmlStrcmp(cur2->name, (const xmlChar *)"prefer"))) {
723 cur3 = cur2->xmlChildrenNode;
724 while (cur3 != NULL) {
725 if ((!xmlStrcmp(cur3->name, (const xmlChar *)"family"))) {
726 xmlNodeSetContent(cur3->xmlChildrenNode, (const xmlChar *)font_name);
727 key = xmlNodeListGetString(doc, cur3->xmlChildrenNode, 1);
730 is_changed = EINA_TRUE;
752 int system_setting_set_font_type(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
755 char *font_name = NULL;
756 font_name = (char *)value;
758 /* get current font list */
759 int is_found = __is_available_font(font_name);
762 SETTING_TRACE("found font : %s ", font_name);
764 SETTING_TRACE(" NOT found font : %s ", font_name);
765 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
768 bool bsave = font_config_set(font_name);
771 SETTING_TRACE(" font type save error by font_config_set() ");
772 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
774 SETTING_TRACE(" save OK - font_config_set() ");
777 xmlDocPtr doc = (xmlDocPtr)font_conf_doc_parse(SETTING_FONT_CONF_FILE, font_name);
779 xmlSaveFormatFile(SETTING_FONT_CONF_FILE, doc, 0);
784 font_config_set_notification();
787 vconf_value = (char *)value;
789 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, vconf_value)) {
790 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
792 return SYSTEM_SETTINGS_ERROR_NONE;
795 int system_setting_set_motion_activation(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
799 vconf_value = (bool *)value;
800 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_MOTION_ACTIVATION, *vconf_value)) {
801 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
803 return SYSTEM_SETTINGS_ERROR_NONE;
806 int system_setting_set_usb_debugging_option(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
810 vconf_value = (bool *)value;
811 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_USB_DEBUG_MODE_BOOL, *vconf_value)) {
812 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
814 return SYSTEM_SETTINGS_ERROR_NONE;
818 int system_setting_set_3g_data_network(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
822 vconf_value = (bool *)value;
823 if (system_setting_vconf_set_value_bool(VCONFKEY_3G_ENABLE, *vconf_value)) {
824 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
827 return SYSTEM_SETTINGS_ERROR_NONE;
830 static int category_func(const char *name, void *user_data)
833 static char *category = "lock-screen";
834 if (name && !strcmp(name, category)) {
835 SETTING_TRACE(" SAME ");
838 SETTING_TRACE(" DIFFERENT -- %s, category -- %s ", name, category);
847 * set 'swipe type' if current lockscreen app is 'com.samsung.lockscreen'
850 int system_setting_set_lockscreen_app(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
854 vconf_value = (char *)value; /* ex) com.samsung.lockscreen */
857 pkgmgrinfo_appinfo_h handle;
858 char *apptype = NULL;
859 r = pkgmgrinfo_appinfo_get_appinfo(vconf_value, &handle);
860 if (r != PMINFO_R_OK) {
861 SETTING_TRACE("*** pkginfo failed ");
862 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
864 SETTING_TRACE("%x", handle);
867 int ret = pkgmgrinfo_appinfo_foreach_category(handle, category_func, (void *)"lock-screen");
868 if (ret != PMINFO_R_OK) {
869 pkgmgrinfo_appinfo_destroy_appinfo(handle);
870 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
873 pkgmgrinfo_appinfo_destroy_appinfo(handle);
874 /*----------------------------------------------------------------------------------- */
876 if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_SCREEN_LOCK_TYPE_INT, &locktype)) {
877 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
880 if (locktype == SETTING_SCREEN_LOCK_TYPE_PASSWORD)
881 return SYSTEM_SETTINGS_ERROR_LOCKSCREEN_APP_PASSWORD_MODE;
883 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_3RD_LOCK_PKG_NAME_STR, vconf_value)) {
884 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
887 if (vconf_value && strcmp(vconf_value, "com.samsung.lockscreen") == 0) {
888 if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_SCREEN_LOCK_TYPE_INT, SETTING_SCREEN_LOCK_TYPE_SWIPE)) {
889 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
892 return SYSTEM_SETTINGS_ERROR_NONE;
895 /*/////////////////////////////////////////////////////////////////////////////////////////////// */
898 int system_setting_set_changed_callback_incoming_call_ringtone(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
901 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR, SYSTEM_SETTINGS_KEY_INCOMING_CALL_RINGTONE, 0, user_data);
904 int system_setting_unset_changed_callback_incoming_call_ringtone(system_settings_key_e key)
907 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR, 0);
910 int system_setting_set_changed_callback_email_alert_ringtone(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
913 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, SYSTEM_SETTINGS_KEY_EMAIL_ALERT_RINGTONE, 0, user_data);
916 int system_setting_unset_changed_callback_email_alert_ringtone(system_settings_key_e key)
919 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, 0);
922 int system_setting_set_changed_callback_wallpaper_home_screen(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
925 return system_setting_vconf_set_changed_cb(VCONFKEY_BGSET, SYSTEM_SETTINGS_KEY_WALLPAPER_HOME_SCREEN, 0, user_data);
928 int system_setting_unset_changed_callback_wallpaper_home_screen(system_settings_key_e key)
931 return system_setting_vconf_unset_changed_cb(VCONFKEY_BGSET, 0);
934 int system_setting_set_changed_callback_wallpaper_lock_screen(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
937 return system_setting_vconf_set_changed_cb(VCONFKEY_IDLE_LOCK_BGSET, SYSTEM_SETTINGS_KEY_WALLPAPER_LOCK_SCREEN, 0, user_data);
940 int system_setting_unset_changed_callback_wallpaper_lock_screen(system_settings_key_e key)
943 return system_setting_vconf_unset_changed_cb(VCONFKEY_IDLE_LOCK_BGSET, 0);
946 int system_setting_set_changed_callback_font_size(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
949 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, SYSTEM_SETTINGS_KEY_FONT_SIZE, 1, user_data);
952 int system_setting_unset_changed_callback_font_size(system_settings_key_e key)
955 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, 1);
958 int system_setting_set_changed_callback_usb_debugging_option(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
961 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_USB_DEBUG_MODE_BOOL, SYSTEM_SETTINGS_KEY_USB_DEBUGGING_ENABLED, 1, user_data);
964 int system_setting_unset_changed_callback_usb_debugging_option(system_settings_key_e key)
967 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_USB_DEBUG_MODE_BOOL, 1);
970 int system_setting_set_changed_callback_3g_data_network(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
973 return system_setting_vconf_set_changed_cb(VCONFKEY_3G_ENABLE, SYSTEM_SETTINGS_KEY_3G_DATA_NETWORK_ENABLED, 1, user_data);
976 int system_setting_unset_changed_callback_3g_data_network(system_settings_key_e key)
979 return system_setting_vconf_unset_changed_cb(VCONFKEY_3G_ENABLE, 1);
982 int system_setting_set_changed_callback_lockscreen_app(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
985 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_3RD_LOCK_PKG_NAME_STR, SYSTEM_SETTINGS_KEY_LOCKSCREEN_APP, 1, user_data);
988 int system_setting_unset_changed_callback_lockscreen_app(system_settings_key_e key)
991 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_3RD_LOCK_PKG_NAME_STR, 1);
996 * @todo need to add custom event notification method
998 int system_setting_set_changed_callback_font_type(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1000 SETTING_TRACE_BEGIN;
1001 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, SYSTEM_SETTINGS_KEY_FONT_TYPE, 2, user_data);
1004 int system_setting_unset_changed_callback_font_type(system_settings_key_e key)
1006 SETTING_TRACE_BEGIN;
1007 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, 2);
1010 /* TODO : 2th argument, callback, is not in use. */
1011 int system_setting_set_changed_callback_motion_activation(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1013 SETTING_TRACE_BEGIN;
1014 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_MOTION_ACTIVATION, SYSTEM_SETTINGS_KEY_MOTION_ACTIVATION, 3, user_data);
1017 int system_setting_unset_changed_callback_motion_activation(system_settings_key_e key)
1019 SETTING_TRACE_BEGIN;
1020 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_MOTION_ACTIVATION, 3);
1023 static char *_get_cur_font()
1025 SETTING_TRACE_BEGIN;
1026 xmlDocPtr doc = NULL;
1027 xmlNodePtr cur = NULL;
1028 xmlNodePtr cur2 = NULL;
1029 xmlNodePtr cur3 = NULL;
1030 xmlChar *key = NULL;
1032 char *font_name = NULL;
1034 doc = xmlParseFile(SETTING_FONT_CONF_FILE);
1036 cur = xmlDocGetRootElement(doc);
1044 if (xmlStrcmp(cur->name, (const xmlChar *)"fontconfig")) {
1050 cur = cur->xmlChildrenNode;
1052 while (cur != NULL) {
1053 if ((!xmlStrcmp(cur->name, (const xmlChar *)"match"))) {
1054 cur2 = cur->xmlChildrenNode;
1055 while (cur2 != NULL) {
1056 if ((!xmlStrcmp(cur2->name, (const xmlChar *)"edit"))) {
1057 cur3 = cur2->xmlChildrenNode;
1058 while (cur3 != NULL) {
1059 if ((!xmlStrcmp(cur3->name, (const xmlChar *)"string"))) {
1060 key = xmlNodeListGetString(doc, cur3->xmlChildrenNode, 1);
1062 font_name = g_strdup((char *)key);
1083 static void font_config_set_notification()
1085 SETTING_TRACE_BEGIN;
1088 Ecore_X_Window ecore_win = ecore_x_window_root_first_get();
1089 Ecore_X_Atom atom = ecore_x_atom_get("FONT_TYPE_change");
1090 ecore_x_window_prop_string_set(ecore_win, atom, "tizen");
1094 int __is_available_font(char *font_name)
1096 SETTING_TRACE_BEGIN;
1097 FcObjectSet *os = NULL;
1098 FcFontSet *fs = NULL;
1099 FcPattern *pat = NULL;
1100 Eina_List *list = NULL;
1101 FcConfig *font_config = NULL;
1105 if (font_name == NULL)
1108 font_config = FcInitLoadConfigAndFonts();
1110 /*setting_retvm_if(font_config == NULL, NULL, "Failed: FcInitLoadConfigAndFonts"); */
1112 char *locale = setlocale(0, NULL);
1114 pat = FcPatternCreate();
1116 os = FcObjectSetBuild(FC_FAMILY, FC_FILE, FC_FAMILYLANG, (char *) 0);
1119 fs = FcFontList(font_config, pat, os);
1120 FcObjectSetDestroy(os);
1125 FcPatternDestroy(pat);
1131 SETTING_TRACE("fs->nfont = %d", fs->nfont);
1133 for (j = 0; j < fs->nfont; j++) {
1134 FcChar8 *family = NULL;
1135 FcChar8 *file = NULL;
1137 if (FcPatternGetString(fs->fonts[j], FC_FILE, 0, &file) == FcResultMatch) {
1138 int preload_path_len = strlen(SETTING_FONT_PRELOAD_FONT_PATH);
1139 int download_path_len = strlen(SETTING_FONT_DOWNLOADED_FONT_PATH);
1141 if (file && (!strncmp((const char *)file, SETTING_FONT_PRELOAD_FONT_PATH, preload_path_len)
1142 || !strncmp((const char *)file, SETTING_FONT_DOWNLOADED_FONT_PATH, download_path_len))) {
1143 char *family_result = NULL;
1144 FcChar8 *lang = NULL;
1146 if (FcPatternGetString(fs->fonts[j], FC_FAMILY, id, &family) != FcResultMatch) {
1149 if (FcPatternGetString(fs->fonts[j], FC_FAMILYLANG, id, &lang) != FcResultMatch) {
1152 family_result = (char *)family;
1154 /* Find proper family name for current locale. */
1155 while (locale && family && lang) {
1156 if (!strncmp(locale, (char *)lang, strlen((char *)lang))) {
1157 family_result = (char *)family;
1161 /* I will set english as default family language. */
1162 /* If there is no proper family language for current locale, */
1163 /* we have to show the english family name. */
1164 if (!strcmp(lang, "en")) {
1165 family_result = (char *)family;
1168 if (FcPatternGetString(fs->fonts[j], FC_FAMILY, id, &family) != FcResultMatch) {
1171 if (FcPatternGetString(fs->fonts[j], FC_FAMILYLANG, id, &lang) != FcResultMatch) {
1176 if (family_result) {
1177 SETTING_TRACE("-------- FONT - family_result = %s", (char *)family_result);
1178 if (strcmp(family_result, font_name) == 0) {
1186 FcFontSetDestroy(fs);
1189 FcConfigDestroy(font_config);
1195 static char *_get_default_font()
1197 SETTING_TRACE_BEGIN;
1198 xmlDocPtr doc = NULL;
1199 xmlNodePtr cur = NULL;
1200 xmlNodePtr cur2 = NULL;
1201 xmlNodePtr cur3 = NULL;
1202 xmlChar *key = NULL;
1203 struct _xmlAttr *properties = NULL;
1204 char *default_font_name = NULL;
1206 doc = xmlParseFile(SETTING_DEFAULT_FONT_CONF_FILE);
1208 cur = xmlDocGetRootElement(doc);
1216 if (xmlStrcmp(cur->name, (const xmlChar *)"fontconfig")) {
1222 cur = cur->xmlChildrenNode;
1224 while (cur != NULL) {
1225 if ((!xmlStrcmp(cur->name, (const xmlChar *)"match"))) {
1226 cur2 = cur->xmlChildrenNode;
1227 while (cur2 != NULL) {
1228 if ((!xmlStrcmp(cur2->name, (const xmlChar *)"edit"))) {
1229 properties = cur2->properties;
1230 /*find the "name" property*/
1231 while (NULL != properties) {
1232 if (!xmlStrcmp(properties->name, (const xmlChar *)"name")) {
1235 properties = properties->next;
1238 /*If the value of "name" property is "family", then get the child node string,
1239 it shall be the default font type*/
1240 if (NULL != properties && !xmlStrcmp(properties->children->content, (const xmlChar *)"family")) {
1241 cur3 = cur2->xmlChildrenNode;
1242 while (cur3 != NULL) {
1243 if ((!xmlStrcmp(cur3->name, (const xmlChar *)"string"))) {
1244 key = xmlNodeListGetString(doc, cur3->xmlChildrenNode, 1);
1245 default_font_name = g_strdup((char *)key);
1250 return default_font_name;
1267 static bool font_config_set(char *font_name)
1269 SETTING_TRACE_BEGIN;
1270 Eina_List *text_classes = NULL;
1271 Elm_Text_Class *etc = NULL;
1272 const Eina_List *l = NULL;
1273 Eina_List *fo_list = NULL;
1274 Elm_Font_Overlay *efo = NULL;
1276 int font_size = __font_size_get();
1279 text_classes = elm_config_text_classes_list_get();
1281 fo_list = (Eina_List *)elm_config_font_overlay_list_get();
1283 Eina_List *ll = NULL;
1284 Eina_List *l_next = NULL;
1286 Eina_Bool slp_medium_exist = EINA_FALSE;
1287 Eina_Bool slp_roman_exist = EINA_FALSE;
1288 Eina_Bool slp_bold_exist = EINA_FALSE;
1289 Eina_Bool slp_regular_exist = EINA_FALSE;
1292 Eina_Bool tizen_exist = EINA_FALSE;
1294 EINA_LIST_FOREACH_SAFE(fo_list, ll, l_next, efo) {
1295 if (!strcmp(efo->text_class, "tizen_medium")) {
1296 elm_config_font_overlay_set(efo->text_class, (const char *)font_name, efo->size);
1297 slp_medium_exist = EINA_TRUE;
1298 } else if (!strcmp(efo->text_class, "tizen_roman")) {
1299 elm_config_font_overlay_set(efo->text_class, (const char *)font_name, efo->size);
1300 slp_roman_exist = EINA_TRUE;
1301 } else if (!strcmp(efo->text_class, "tizen_bold")) {
1302 elm_config_font_overlay_set(efo->text_class, (const char *)font_name, efo->size);
1303 slp_bold_exist = EINA_TRUE;
1304 } else if (!strcmp(efo->text_class, "tizen_regular")) {
1305 elm_config_font_overlay_set(efo->text_class, (const char *)font_name, efo->size);
1306 slp_regular_exist = EINA_TRUE;
1310 if (!strcmp(efo->text_class, "tizen")) {
1311 elm_config_font_overlay_set(efo->text_class, (const char *)font_name, efo->size);
1312 tizen_exist = EINA_TRUE;
1317 /* if slp_XX do not exist, need to set them, font size is -100(100%) */
1318 if (slp_medium_exist == EINA_FALSE) {
1319 elm_config_font_overlay_set("tizen_medium", (const char *)font_name, MIDDLE_FONT_DPI);
1321 if (slp_roman_exist == EINA_FALSE) {
1322 elm_config_font_overlay_set("tizen_roman", (const char *)font_name, MIDDLE_FONT_DPI);
1324 if (slp_bold_exist == EINA_FALSE) {
1325 elm_config_font_overlay_set("tizen_bold", (const char *)font_name, MIDDLE_FONT_DPI);
1327 if (slp_regular_exist == EINA_FALSE) {
1328 elm_config_font_overlay_set("tizen_regular", (const char *)font_name, MIDDLE_FONT_DPI);
1332 if (tizen_exist == EINA_FALSE) {
1333 elm_config_font_overlay_set("tizen", (const char *)font_name, MIDDLE_FONT_DPI);
1336 elm_config_font_overlay_set("tizen", (const char *)font_name, MIDDLE_FONT_DPI);
1339 elm_config_font_overlay_set("tizen", (const char *)font_name, MIDDLE_FONT_DPI);
1341 EINA_LIST_FOREACH(text_classes, l, etc) {
1345 EINA_LIST_FOREACH(fo_list, ll, efo) {
1346 if (!strcmp(etc->name, efo->text_class)) {
1350 elm_config_font_overlay_set(etc->name, (const char *)font_name, size);
1352 elm_config_text_classes_list_free(text_classes);
1353 text_classes = NULL;
1355 /* add new function */
1356 #ifdef USE_EFL_ASSIST
1357 ea_theme_system_font_set(font_name, font_size);
1358 ea_theme_system_fonts_apply();
1361 elm_config_font_overlay_apply();
1362 elm_config_all_flush();
1367 static void __font_size_set()
1369 SETTING_TRACE_BEGIN;
1370 Eina_List *text_classes = NULL;
1371 Elm_Text_Class *etc = NULL;
1372 const Eina_List *l = NULL;
1373 int font_size = __font_size_get();
1374 char *font_name = _get_cur_font();
1376 if (font_size == -1) {
1380 text_classes = elm_config_text_classes_list_get();
1382 EINA_LIST_FOREACH(text_classes, l, etc) {
1383 elm_config_font_overlay_set(etc->name, font_name, font_size);
1386 elm_config_text_classes_list_free(text_classes);
1388 #ifdef USE_EFL_ASSIST
1389 ea_theme_system_font_set(font_name, font_size);
1390 ea_theme_system_fonts_apply();
1393 elm_config_font_overlay_apply();
1394 elm_config_all_flush();
1397 text_classes = NULL;
1401 static int __font_size_get()
1403 SETTING_TRACE_BEGIN;
1407 int vconf_value = -1;
1408 if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, &vconf_value)) {
1412 switch (vconf_value) {
1413 case SYSTEM_SETTINGS_FONT_SIZE_SMALL:
1414 font_size = SMALL_FONT_DPI;
1416 case SYSTEM_SETTINGS_FONT_SIZE_NORMAL:
1417 font_size = MIDDLE_FONT_DPI;
1419 case SYSTEM_SETTINGS_FONT_SIZE_LARGE:
1420 font_size = LARGE_FONT_DPI;
1422 case SYSTEM_SETTINGS_FONT_SIZE_HUGE:
1423 font_size = HUGE_FONT_DPI;
1425 case SYSTEM_SETTINGS_FONT_SIZE_GIANT:
1426 font_size = GIANT_FONT_DPI;
1429 font_size = MIDDLE_FONT_DPI;
1435 /*//////////////////////////////////////////////////////////////////////////////////////// */
1436 /*--------------------------------------- */
1437 int system_setting_get_locale_country(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1439 SETTING_TRACE_BEGIN;
1440 char *vconf_value = NULL;
1441 if (system_setting_vconf_get_value_string(VCONFKEY_REGIONFORMAT, &vconf_value)) {
1442 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1445 /* parsing validation */
1448 snprintf(arr, 20, vconf_value);
1450 *value = strdup(arr);
1454 return SYSTEM_SETTINGS_ERROR_NONE;
1457 int system_setting_set_locale_country(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1459 SETTING_TRACE_BEGIN;
1460 char *vconf_value = NULL;
1461 vconf_value = (char *)value;
1463 char *ext = "UTF-8";
1466 snprintf(arr, 20, "%s.%s", vconf_value, ext);
1468 if (system_setting_vconf_set_value_string(VCONFKEY_REGIONFORMAT, arr)) {
1469 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1471 return SYSTEM_SETTINGS_ERROR_NONE;
1474 int system_setting_set_changed_callback_locale_country(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1476 SETTING_TRACE_BEGIN;
1477 return system_setting_vconf_set_changed_cb(VCONFKEY_REGIONFORMAT, SYSTEM_SETTINGS_KEY_LOCALE_COUNTRY, 3, user_data);
1480 int system_setting_unset_changed_callback_locale_country(system_settings_key_e key)
1482 SETTING_TRACE_BEGIN;
1483 return system_setting_vconf_unset_changed_cb(VCONFKEY_REGIONFORMAT, 3);
1487 /*--------------------------------------- */
1488 int system_setting_get_locale_language(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1490 SETTING_TRACE_BEGIN;
1491 char *vconf_value = NULL;
1492 if (system_setting_vconf_get_value_string(VCONFKEY_LANGSET, &vconf_value)) {
1493 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1496 /* parsing validation */
1499 snprintf(arr, 20, vconf_value);
1501 *value = strdup(arr);
1504 return SYSTEM_SETTINGS_ERROR_NONE;
1507 int system_setting_set_locale_language(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1509 SETTING_TRACE_BEGIN;
1510 char *vconf_value = NULL;
1511 vconf_value = (char *)value;
1513 char *ext = "UTF-8";
1516 snprintf(arr, 20, "%s.%s", vconf_value, ext);
1518 if (system_setting_vconf_set_value_string(VCONFKEY_LANGSET, arr)) {
1519 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1521 return SYSTEM_SETTINGS_ERROR_NONE;
1524 int system_setting_set_changed_callback_locale_language(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1526 SETTING_TRACE_BEGIN;
1527 /*return system_setting_vconf_set_changed_cb(VCONFKEY_LANGSET, SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, 3, user_data ); */
1528 return system_setting_vconf_set_changed_cb(VCONFKEY_LANGSET, SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, 100, user_data);
1531 int system_setting_unset_changed_callback_locale_language(system_settings_key_e key)
1533 SETTING_TRACE_BEGIN;
1534 return system_setting_vconf_unset_changed_cb(VCONFKEY_LANGSET, 100);
1537 /*--------------------------------------- */
1538 int system_setting_get_locale_timeformat_24hour(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1540 SETTING_TRACE_BEGIN;
1543 if (system_setting_vconf_get_value_int(VCONFKEY_REGIONFORMAT_TIME1224, &vconf_value)) {
1544 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1548 if (vconf_value == VCONFKEY_TIME_FORMAT_12)
1550 else if (vconf_value == VCONFKEY_TIME_FORMAT_24)
1553 *value = (void *)ret_value;
1555 return SYSTEM_SETTINGS_ERROR_NONE;
1558 int system_setting_set_locale_timeformat_24hour(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1560 SETTING_TRACE_BEGIN;
1563 vconf_value = (bool *)value;
1566 if (system_setting_vconf_set_value_int(VCONFKEY_REGIONFORMAT_TIME1224, VCONFKEY_TIME_FORMAT_24)) {
1567 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1571 if (system_setting_vconf_set_value_int(VCONFKEY_REGIONFORMAT_TIME1224, VCONFKEY_TIME_FORMAT_12)) {
1572 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1577 return SYSTEM_SETTINGS_ERROR_NONE;
1580 int system_setting_set_changed_callback_locale_timeformat_24hour(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1582 SETTING_TRACE_BEGIN;
1583 return system_setting_vconf_set_changed_cb(VCONFKEY_REGIONFORMAT_TIME1224, SYSTEM_SETTINGS_KEY_LOCALE_TIMEFORMAT_24HOUR, 3, user_data);
1586 int system_setting_unset_changed_callback_locale_timeformat_24hour(system_settings_key_e key)
1588 SETTING_TRACE_BEGIN;
1589 return system_setting_vconf_unset_changed_cb(VCONFKEY_REGIONFORMAT_TIME1224, 3);
1592 int system_setting_get_locale_timezone(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1594 SETTING_TRACE_BEGIN;
1597 ssize_t len = readlink(SETTING_TZONE_SYMLINK_PATH, tzpath, sizeof(tzpath) - 1);
1601 SETTING_TRACE("parse error for SETTING_TZONE_SYMLINK_PATH");
1602 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1604 /* "/usr/share/zoneinfo/Asia/Seoul" */
1605 SETTING_TRACE("tzpath : %s ", &tzpath[20]);
1606 *value = strdup(&tzpath[20]);
1608 *value = vconf_get_str(VCONFKEY_SETAPPL_TIMEZONE_ID);
1610 return SYSTEM_SETTINGS_ERROR_NONE;
1613 int system_setting_set_changed_callback_locale_timezone_changed(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1615 SETTING_TRACE_BEGIN;
1616 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
1619 int system_setting_unset_changed_callback_locale_timezone_changed(system_settings_key_e key)
1621 SETTING_TRACE_BEGIN;
1622 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
1626 int system_setting_get_time_changed(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1628 SETTING_TRACE_BEGIN;
1630 cur_tick = time(NULL);
1631 *value = (void *)cur_tick;
1632 /* struct tm * localtime = time (cur_tick); */
1633 /* printf("%s\n", ctime(&cur_tick); */
1634 return SYSTEM_SETTINGS_ERROR_NONE;
1638 int system_setting_set_changed_callback_time_changed(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1640 SETTING_TRACE_BEGIN;
1641 return system_setting_vconf_set_changed_cb(VCONFKEY_SYSTEM_TIME_CHANGED, SYSTEM_SETTINGS_KEY_TIME_CHANGED, 3, user_data);
1644 int system_setting_unset_changed_callback_time_changed(system_settings_key_e key)
1646 SETTING_TRACE_BEGIN;
1647 return system_setting_vconf_unset_changed_cb(VCONFKEY_SYSTEM_TIME_CHANGED, 3);
1652 /* SYSTEM_SETTINGS_KEY_SOUND_LOCK */
1653 int system_setting_get_sound_lock(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1655 SETTING_TRACE_BEGIN;
1658 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_SOUND_LOCK_BOOL, &vconf_value)) {
1659 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1661 *value = (void *)vconf_value;
1663 return SYSTEM_SETTINGS_ERROR_NONE;
1666 int system_setting_set_changed_callback_sound_lock(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1668 SETTING_TRACE_BEGIN;
1669 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_SOUND_LOCK_BOOL, SYSTEM_SETTINGS_KEY_SOUND_LOCK, 3, user_data);
1672 int system_setting_unset_changed_callback_sound_lock(system_settings_key_e key)
1674 SETTING_TRACE_BEGIN;
1675 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_SOUND_LOCK_BOOL, 3);
1679 * a = VCONFKEY_SETAPPL_SOUND_STATUS_BOOL b = VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL
1681 * a == false, b == false --> silent mode
1682 * a == true, b == false --> sound mode
1683 * a == false, b == true --> vibration mode
1685 int system_setting_get_sound_silent_mode(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1687 SETTING_TRACE_BEGIN;
1692 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, &sound_cond)) {
1693 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1696 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, &vib_cond)) {
1697 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1700 if (sound_cond == false && vib_cond == false) {
1702 *value = (void *)vconf_value;
1704 vconf_value = false;
1705 *value = (void *)vconf_value;
1707 return SYSTEM_SETTINGS_ERROR_NONE;
1711 * a = VCONFKEY_SETAPPL_SOUND_STATUS_BOOL b = VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL
1713 * a == false, b == false --> silent mode
1714 * a == true, b == false --> sound mode
1716 int system_setting_set_sound_silent_mode(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1718 SETTING_TRACE_BEGIN;
1721 vconf_value = (bool *)value;
1723 bool vconf_sound = false;
1724 bool vconf_vib = false;
1727 vconf_sound = false;
1734 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, vconf_sound)) {
1735 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1737 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, vconf_vib)) {
1738 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1741 return SYSTEM_SETTINGS_ERROR_NONE;
1747 int system_setting_set_changed_callback_sound_silent_mode(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1749 SETTING_TRACE_BEGIN;
1750 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, SYSTEM_SETTINGS_KEY_SOUND_SILENT_MODE, 3, user_data);
1754 int system_setting_unset_changed_callback_sound_silent_mode(system_settings_key_e key)
1756 SETTING_TRACE_BEGIN;
1757 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, 3);
1760 /* SYSTEM_SETTINGS_KEY_SOUND_TOUCH */
1761 int system_setting_get_sound_touch(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1763 SETTING_TRACE_BEGIN;
1766 int ret = system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL, &vconf_value);
1767 if (ret != SYSTEM_SETTINGS_ERROR_NONE) {
1770 *value = (void *)vconf_value;
1774 int system_setting_set_changed_callback_sound_touch(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1776 SETTING_TRACE_BEGIN;
1777 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL, SYSTEM_SETTINGS_KEY_SOUND_TOUCH, 2, user_data);
1780 int system_setting_unset_changed_callback_sound_touch(system_settings_key_e key)
1782 SETTING_TRACE_BEGIN;
1783 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL, 2);
1787 /* SYSTEM_SETTINGS_KEY_SOUND_LOCK */
1788 int system_setting_get_sound_lock(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1792 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_SOUND_LOCK_BOOL, &vconf_value)) {
1793 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1795 *value = (void *)vconf_value;
1797 return SYSTEM_SETTINGS_ERROR_NONE;
1801 int system_setting_get_auto_rotation_mode(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1803 SETTING_TRACE_BEGIN;
1806 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, &vconf_value)) {
1807 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1809 *value = (void *)vconf_value;
1811 return SYSTEM_SETTINGS_ERROR_NONE;
1814 int system_setting_set_auto_rotation_mode(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1816 SETTING_TRACE_BEGIN;
1818 vconf_value = (bool *)value;
1819 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, *vconf_value)) {
1820 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1823 return SYSTEM_SETTINGS_ERROR_NONE;
1826 int system_setting_set_changed_callback_auto_rotation_mode(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1828 SETTING_TRACE_BEGIN;
1829 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, SYSTEM_SETTINGS_KEY_DISPLAY_SCREEN_ROTATION_AUTO, 2, user_data);
1832 int system_setting_unset_changed_callback_auto_rotation_mode(system_settings_key_e key)
1834 SETTING_TRACE_BEGIN;
1835 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, 2);
1838 int system_setting_get_screen_backlight_time(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1840 SETTING_TRACE_BEGIN;
1843 if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, &vconf_value)) {
1844 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1846 *value = (void *)vconf_value;
1848 return SYSTEM_SETTINGS_ERROR_NONE;
1852 int system_setting_set_screen_backlight_time(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1854 SETTING_TRACE_BEGIN;
1856 vconf_value = (int *)value;
1858 if (!(*vconf_value > 0 && *vconf_value < 600)) {
1859 SETTING_TRACE(" ERR Betweeny here 0 ~ 600");
1860 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
1863 if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, *vconf_value)) {
1864 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1867 return SYSTEM_SETTINGS_ERROR_NONE;
1870 int system_setting_set_changed_callback_screen_backlight_time(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1872 SETTING_TRACE_BEGIN;
1873 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, SYSTEM_SETTINGS_KEY_DISPLAY_SCREEN_ROTATION_AUTO, 2, user_data);
1876 int system_setting_unset_changed_callback_screen_backlight_time(system_settings_key_e key)
1878 SETTING_TRACE_BEGIN;
1879 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, 2);
1882 int system_setting_get_sound_notification(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1884 SETTING_TRACE_BEGIN;
1885 char *vconf_value = NULL;
1886 if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, &vconf_value)) {
1887 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1890 *value = vconf_value;
1891 return SYSTEM_SETTINGS_ERROR_NONE;
1894 int system_setting_set_sound_notification(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1896 SETTING_TRACE_BEGIN;
1897 char *vconf_value = NULL;
1898 vconf_value = (char *)value;
1900 int is_load = _is_file_accessible(vconf_value);
1902 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, vconf_value)) {
1903 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1906 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1909 return SYSTEM_SETTINGS_ERROR_NONE;
1912 int system_setting_set_changed_callback_sound_notification(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1914 SETTING_TRACE_BEGIN;
1915 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, SYSTEM_SETTINGS_KEY_INCOMING_CALL_RINGTONE, 0, user_data);
1918 int system_setting_unset_changed_callback_sound_notification(system_settings_key_e key)
1920 SETTING_TRACE_BEGIN;
1921 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, 0);
1924 int system_setting_get_notification_repetition_period(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1926 SETTING_TRACE_BEGIN;
1929 if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_NOTI_MSG_ALERT_REP_TYPE_INT, &vconf_value)) {
1930 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1932 *value = (void *)vconf_value;
1934 return SYSTEM_SETTINGS_ERROR_NONE;
1937 int system_setting_set_notification_repetition_period(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1939 SETTING_TRACE_BEGIN;
1941 vconf_value = (int *)value;
1943 if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_NOTI_MSG_ALERT_REP_TYPE_INT, *vconf_value)) {
1944 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1947 return SYSTEM_SETTINGS_ERROR_NONE;
1950 int system_setting_set_changed_callback_notification_repetition_period(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1952 SETTING_TRACE_BEGIN;
1953 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);
1956 int system_setting_unset_changed_callback_notification_repetition_period(system_settings_key_e key)
1958 SETTING_TRACE_BEGIN;
1959 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_ALERT_REP_TYPE_INT, 1);
1962 int system_setting_get_device_name(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1964 SETTING_TRACE_BEGIN;
1965 char *vconf_value = NULL;
1966 if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_DEVICE_NAME_STR, &vconf_value)) {
1967 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1970 *value = vconf_value;
1971 return SYSTEM_SETTINGS_ERROR_NONE;
1974 int system_setting_set_device_name(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1976 SETTING_TRACE_BEGIN;
1977 char *vconf_value = NULL;
1978 vconf_value = (char *)value;
1980 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_DEVICE_NAME_STR, vconf_value)) {
1981 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1984 return SYSTEM_SETTINGS_ERROR_NONE;
1987 int system_setting_set_changed_callback_device_name(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1989 SETTING_TRACE_BEGIN;
1990 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_DEVICE_NAME_STR, SYSTEM_SETTINGS_KEY_DEVICE_NAME, 0, user_data);
1993 int system_setting_unset_changed_callback_device_name(system_settings_key_e key)
1995 SETTING_TRACE_BEGIN;
1996 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_DEVICE_NAME_STR, 0);
1999 /*---------------------------------------------- */
2000 int system_setting_get_network_flight_mode(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
2002 SETTING_TRACE_BEGIN;
2004 if (system_setting_vconf_get_value_bool(VCONFKEY_TELEPHONY_FLIGHT_MODE, &vconf_value)) {
2005 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2007 *value = (void *)vconf_value;
2009 return SYSTEM_SETTINGS_ERROR_NONE;
2012 int system_setting_set_changed_callback_network_flight_mode(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
2014 SETTING_TRACE_BEGIN;
2015 return system_setting_vconf_set_changed_cb(VCONFKEY_TELEPHONY_FLIGHT_MODE, SYSTEM_SETTINGS_KEY_NETWORK_FLIGHT_MODE, 3, user_data);
2018 int system_setting_unset_changed_callback_network_flight_mode(system_settings_key_e key)
2020 SETTING_TRACE_BEGIN;
2021 return system_setting_vconf_unset_changed_cb(VCONFKEY_TELEPHONY_FLIGHT_MODE, 3);
2024 int system_setting_get_network_wifi_notification(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
2026 SETTING_TRACE_BEGIN;
2028 if (system_setting_vconf_get_value_int(VCONFKEY_WIFI_ENABLE_QS, &vconf_value)) {
2029 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2032 bret = (vconf_value == VCONFKEY_WIFI_QS_ENABLE) ? true : false;
2034 *value = (void *)bret;
2035 return SYSTEM_SETTINGS_ERROR_NONE;
2038 int system_setting_set_changed_callback_network_wifi_notification(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
2040 SETTING_TRACE_BEGIN;
2041 return system_setting_vconf_set_changed_cb(VCONFKEY_WIFI_ENABLE_QS, SYSTEM_SETTINGS_KEY_NETWORK_WIFI_NOTIFICATION, 4, user_data);
2044 int system_setting_unset_changed_callback_network_wifi_notification(system_settings_key_e key)
2046 SETTING_TRACE_BEGIN;
2047 return system_setting_vconf_unset_changed_cb(VCONFKEY_WIFI_ENABLE_QS, 4);
2050 int system_setting_get_lock_state(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
2054 if (system_setting_vconf_get_value_int(VCONFKEY_IDLE_LOCK_STATE_READ_ONLY, &vconf_value)) {
2055 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2057 *value = (void *)vconf_value;
2059 return SYSTEM_SETTINGS_ERROR_NONE;
2062 int system_setting_set_lock_state(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
2064 SETTING_TRACE_BEGIN;
2066 vconf_value = (int *)value;
2068 if (system_setting_vconf_set_value_int(VCONFKEY_IDLE_LOCK_STATE_READ_ONLY, *vconf_value)) {
2069 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2072 return SYSTEM_SETTINGS_ERROR_NONE;
2075 int system_setting_set_changed_callback_lock_state(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
2077 return system_setting_vconf_set_changed_cb(VCONFKEY_IDLE_LOCK_STATE_READ_ONLY, SYSTEM_SETTINGS_KEY_LOCK_STATE, 4, user_data);
2080 int system_setting_unset_changed_callback_lock_state(system_settings_key_e key)
2082 return system_setting_vconf_unset_changed_cb(VCONFKEY_IDLE_LOCK_STATE_READ_ONLY, 4);