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>
40 #include <Elementary.h>
42 #include <Ecore_Evas.h>
44 #include <system_settings.h>
45 #include <system_settings_private.h>
48 #include <efl_assist.h>
52 #define SMALL_FONT_DPI (-90)
55 #define SMALL_FONT_DPI (-80)
57 #define MIDDLE_FONT_DPI (-100)
59 #define LARGE_FONT_DPI (-110)
62 #define LARGE_FONT_DPI (-150)
64 #define HUGE_FONT_DPI (-190)
65 #define GIANT_FONT_DPI (-250)
67 #define SETTING_FONT_PRELOAD_FONT_PATH "/usr/share/fonts"
68 #define SETTING_FONT_DOWNLOADED_FONT_PATH "/opt/share/fonts"
70 #define SETTING_FONT_CONF_FILE "/opt/etc/fonts/conf.avail/99-slp.conf"
71 #define SETTING_DEFAULT_FONT_CONF_FILE "/usr/opt/etc/fonts/conf.avail/99-slp.conf"
73 #define SETTING_STR_LEN 256
75 #define SETTING_TIME_ZONEINFO_PATH "/usr/share/zoneinfo/"
76 #define SETTING_TIME_SHARE_LOCAL_PATH "/usr/share/locale"
77 #define SETTING_TZONE_SYMLINK_PATH "/opt/etc/localtime"
80 static char *_get_cur_font();
81 static void __font_size_set();
82 static int __font_size_get();
83 static char *_get_default_font();
85 static bool font_config_set(char *font_name);
86 static void font_config_set_notification();
89 * VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR has a path of the ringtone file which user choose
90 * @return the ringtone file path specified by user in normal case
91 * if it's not accessable, return the default ringtone path
93 int system_setting_get_incoming_call_ringtone(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
96 if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR, &vconf_value)) {
97 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
100 /* check to see if it's accessable -> OK */
101 /* no --> default ringtone path VCONFKEY_SETAPPL_CALL_RINGTONE_DEFAULT_PATH_STR */
102 int is_load = _is_file_accessible(vconf_value);
104 *value = vconf_value;
105 } else { /* not zero on errro */
106 *value = vconf_get_str(VCONFKEY_SETAPPL_CALL_RINGTONE_DEFAULT_PATH_STR);
109 /**value = vconf_value; */
110 return SYSTEM_SETTINGS_ERROR_NONE;
114 int system_setting_get_email_alert_ringtone(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
117 if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, &vconf_value)) {
118 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
121 /* check to see if it's accessable -> OK */
122 /* no --> default ringtone path VCONFKEY_SETAPPL_NOTI_RINGTONE_DEFAULT_PATH_STR */
123 int is_load = _is_file_accessible(vconf_value);
125 *value = vconf_value;
126 } else { /* not zero on errro */
127 *value = vconf_get_str(VCONFKEY_SETAPPL_NOTI_RINGTONE_DEFAULT_PATH_STR);
130 return SYSTEM_SETTINGS_ERROR_NONE;
134 int system_setting_get_wallpaper_home_screen(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
137 if (system_setting_vconf_get_value_string(VCONFKEY_BGSET, &vconf_value)) {
138 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
140 *value = vconf_value;
141 return SYSTEM_SETTINGS_ERROR_NONE;
145 int system_setting_get_wallpaper_lock_screen(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
149 if (system_setting_vconf_get_value_string(VCONFKEY_IDLE_LOCK_BGSET, &vconf_value)) {
150 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
152 *value = vconf_value;
154 return SYSTEM_SETTINGS_ERROR_NONE;
158 /* [int] vconf GET */
159 int system_setting_get_font_size(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
163 if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, &vconf_value)) {
164 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
166 *value = (void *)vconf_value;
168 return SYSTEM_SETTINGS_ERROR_NONE;
172 int system_setting_get_default_font_type(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
174 char *font_name = _get_default_font();
176 *value = (void *)font_name;
177 return SYSTEM_SETTINGS_ERROR_NONE;
179 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
183 /* [int] vconf GET */
184 int system_setting_get_font_type(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
186 char *font_name = _get_cur_font();
187 *value = (void *)font_name;
189 return SYSTEM_SETTINGS_ERROR_NONE;
193 int system_setting_get_motion_activation(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
197 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_MOTION_ACTIVATION, &vconf_value)) {
198 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
200 *value = (void *)vconf_value;
202 return SYSTEM_SETTINGS_ERROR_NONE;
205 int system_setting_get_usb_debugging_option(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
209 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_USB_DEBUG_MODE_BOOL, &vconf_value)) {
210 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
212 *value = (void *)vconf_value;
214 return SYSTEM_SETTINGS_ERROR_NONE;
217 int system_setting_get_3g_data_network(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
221 if (system_setting_vconf_get_value_bool(VCONFKEY_3G_ENABLE, &vconf_value)) {
222 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
224 *value = (void *)vconf_value;
226 return SYSTEM_SETTINGS_ERROR_NONE;
228 /*////////////////////////////////////////////////////////////////////////////////////////////////// */
231 int system_setting_get_tap_and_hold_delay(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
233 char *vconf_value = NULL;
234 if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_ACCESSIBILITY_TAP_HOLD_DELAY_STR, &vconf_value)) {
235 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
238 int val = SYSTEM_SETTINGS_TAP_AND_HOLD_DELAY_MEDIUM;
239 if (vconf_value && strcmp(vconf_value, "IDS_COM_POP_SHORT") == 0) {
240 val = SYSTEM_SETTINGS_TAP_AND_HOLD_DELAY_SHORT;
241 } else if (vconf_value && strcmp(vconf_value, "IDS_ST_BODY_MEDIUM") == 0) {
242 val = SYSTEM_SETTINGS_TAP_AND_HOLD_DELAY_MEDIUM;
243 } else if (vconf_value && strcmp(vconf_value, "IDS_COM_POP_LONG") == 0) {
244 val = SYSTEM_SETTINGS_TAP_AND_HOLD_DELAY_LONG;
247 *value = (void *)val; /* float */
248 return SYSTEM_SETTINGS_ERROR_NONE;
252 * get current lock scren app package name (string)
254 * @return SYSTEM_SETTINGS_ERROR_LOCKSCREEN_APP_PASSWORD_MODE raise exception if current lock type is 'password'
256 int system_setting_get_lockscreen_app(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
258 char *pkg_name = NULL;
260 system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_SCREEN_LOCK_TYPE_INT, &locktype);
262 if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_3RD_LOCK_PKG_NAME_STR, &pkg_name)) {
263 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
266 if (pkg_name && strcmp(pkg_name, "com.samsung.lockscreen") == 0 && locktype == SETTING_SCREEN_LOCK_TYPE_PASSWORD) {
267 return SYSTEM_SETTINGS_ERROR_LOCKSCREEN_APP_PASSWORD_MODE;
271 return SYSTEM_SETTINGS_ERROR_NONE;
275 /*////////////////////////////////////////////////////////////////////////////////////////////////// */
277 int _is_file_accessible(const char *path)
279 int ret = access(path , R_OK);
281 SETTING_TRACE("found the file %s", path);
284 SETTING_TRACE("found the file %s --- error code : %d ", path, errno);
289 int system_setting_set_incoming_call_ringtone(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
292 vconf_value = (char *)value;
294 int is_load = _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 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
303 return SYSTEM_SETTINGS_ERROR_NONE;
307 int system_setting_set_email_alert_ringtone(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
310 vconf_value = (char *)value;
312 int is_load = _is_file_accessible(vconf_value);
314 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, vconf_value)) {
315 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
318 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
321 return SYSTEM_SETTINGS_ERROR_NONE;
325 bool __is_supported_image_type_load(char *path)
331 ee = ecore_evas_new(NULL, 0, 0, 100, 100, NULL);
332 evas = ecore_evas_get(ee);
334 Evas_Object *img = evas_object_image_add(evas);
335 evas_object_image_file_set(img, path, NULL);
336 Evas_Load_Error ret = evas_object_image_load_error_get(img);
339 if (ret == EVAS_LOAD_ERROR_NONE) {
340 SETTING_TRACE("%s - OK", path);
343 SETTING_TRACE("%s - NO", path);
351 bool __is_supported_image_type(char *path)
356 if (evas_object_image_extension_can_load_get(path))
366 #define PATH_EXT_CHECK_REG ".(jpe?g|jpg|png|gif)$"
367 bool __is_supported_image_type_by_ext(char *file_path)
370 regmatch_t str[2048 + 1];
372 if (!file_path) return false;
375 if (ret = regcomp(&fsm, PATH_EXT_CHECK_REG, REG_ICASE | REG_EXTENDED)) {
376 SETTING_TRACE("regular expresstion fail");
381 if (regexec(&fsm, file_path, strlen(file_path) + 1, str, 0) == REG_NOMATCH) {
382 /*SETTING_TRACE("FAILED - %s", file_path[i]); */
385 /*SETTING_TRACE("MATCHED - %s", file_path[i]); */
390 #ifdef TIZEN_WEARABLE
391 static int system_setting_get_extended_wallpaper_num(const char *file_path, unsigned int *num)
394 const char *find_str = "extended_wallpaper_";
397 if (!(ch = strstr(file_path, find_str))) {
398 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
400 strncpy(buffer, file_path, ch - file_path);
401 buffer[ch - file_path] = 0;
402 sprintf(buffer + (ch - file_path), "%s%s", "", ch + strlen(find_str));
404 if (!isdigit(buffer[0])) {
405 SETTING_TRACE("%s is not number", buffer);
406 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
411 return SYSTEM_SETTINGS_ERROR_NONE;
414 static int system_setting_copy_extended_wallpaper(const char *dest_file_path, const char *source_file_path)
416 if (!source_file_path || !dest_file_path) {
417 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
423 fd = open(source_file_path, O_RDONLY);
425 SETTING_TRACE("file open failed: %s", source_file_path);
426 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
430 fd2 = open(dest_file_path, O_WRONLY | O_CREAT, S_IRWXU | S_IRWXG | S_IRWXO);
432 SETTING_TRACE("file creation failed: %s", dest_file_path);
434 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
437 while (read(fd, buf, sizeof(buf) - 1) > 0) {
438 write(fd2, buf, sizeof(buf) - 1);
444 if (chmod(dest_file_path, S_IRWXU | S_IRWXG | S_IRWXO) < 0) {
445 SETTING_TRACE("chmod failed: %s", dest_file_path);
448 return SYSTEM_SETTINGS_ERROR_NONE;
451 static int system_setting_remove_oldest_extended_wallpaper()
455 char *min_image_name = NULL;
456 unsigned int min_image_num = 0;
457 unsigned int temp_image_num = 0;
460 if ((dp = opendir("/opt/usr/data/setting/wallpaper")) == NULL) {
461 SETTING_TRACE("opendir error");
462 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
465 while ((dirp = readdir(dp))) {
466 if (!strcmp(dirp->d_name, ".") || !strcmp(dirp->d_name, ".."))
469 if (system_setting_get_extended_wallpaper_num(dirp->d_name, &temp_image_num)
470 != SYSTEM_SETTINGS_ERROR_NONE) {
471 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
474 if ((image_count == 0) || (min_image_num > temp_image_num)) {
475 min_image_num = temp_image_num;
476 min_image_name = dirp->d_name;
483 if (min_image_name) {
484 snprintf(buf, sizeof(buf) - 1, "/opt/usr/data/setting/wallpaper/%s", min_image_name);
485 if (remove(buf) < 0) { /* remove oldest image */
486 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
490 return SYSTEM_SETTINGS_ERROR_NONE;
493 static int system_setting_check_extended_wallpaper(const char *file_path)
495 if (!file_path || !strlen(file_path))
497 return (strstr(file_path, "/opt/usr/media/.bgwallpaper") != NULL);
500 #define WALLPAPER_MAX_COUNT 10
503 int system_setting_set_wallpaper_home_screen(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
506 vconf_value = (char *)value;
508 bool isok = __is_supported_image_type_load(vconf_value);
511 SETTING_TRACE("path : %s is not supported file format", vconf_value);
512 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
514 SETTING_TRACE("path : %s is SUPPORT file format", vconf_value);
517 /* error handling here */
518 if (_is_file_accessible(vconf_value) != 0)
519 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
521 if (system_setting_vconf_set_value_string(VCONFKEY_BGSET, vconf_value)) {
522 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
526 #ifdef TIZEN_WEARABLE
527 if (system_setting_check_extended_wallpaper(vconf_value)) { /* New extended wallpaper */
530 unsigned int max_image_num = 0;
531 unsigned int temp_image_num = 0;
534 if ((dp = opendir("/opt/usr/data/setting/wallpaper")) == NULL) {
535 SETTING_TRACE("Setting - dir open error!");
536 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
539 /* Check a max number of wallpapers */
540 while ((dirp = readdir(dp))) {
541 if (!strcmp(dirp->d_name, ".") || !strcmp(dirp->d_name, ".."))
544 if (system_setting_get_extended_wallpaper_num(dirp->d_name, &temp_image_num)
545 != SYSTEM_SETTINGS_ERROR_NONE) {
546 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
549 if ((image_count == 0) || (max_image_num < temp_image_num)) {
550 max_image_num = temp_image_num;
556 /* Numbering rule: Gear is odd number */
557 max_image_num = (max_image_num % 2 == 0) ? max_image_num + 1
560 char file_name_buffer[512];
561 snprintf(file_name_buffer, sizeof(file_name_buffer) - 1,
562 "/opt/usr/data/setting/wallpaper/extended_wallpaper_%d.jpg", max_image_num);
564 /* Copy image to /opt/usr/data/setting/wallpaper/ */
565 if (system_setting_copy_extended_wallpaper(file_name_buffer, vconf_value)
566 != SYSTEM_SETTINGS_ERROR_NONE) {
567 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
570 /* remove oldest wallpaper */
571 if (image_count >= WALLPAPER_MAX_COUNT) {
572 if (system_setting_remove_oldest_extended_wallpaper()
573 != SYSTEM_SETTINGS_ERROR_NONE) {
574 remove(file_name_buffer);
575 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
579 if (system_setting_vconf_set_value_string(VCONFKEY_BGSET, file_name_buffer)) {
580 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
583 if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_WALLPAPER_CHANGED_NOTI_INT,
584 VCONFKEY_WALLPAPER_CHANGED_NOTI_GEAR)) {
585 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
588 if (system_setting_vconf_set_value_string(VCONFKEY_BGSET, vconf_value)) {
589 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
594 return SYSTEM_SETTINGS_ERROR_NONE;
597 int system_setting_set_wallpaper_lock_screen(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
600 vconf_value = (char *)value;
602 bool isok = __is_supported_image_type_load(vconf_value);
605 SETTING_TRACE("path : %s is not supported file format", vconf_value);
606 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
608 SETTING_TRACE("path : %s is SUPPORT file format", vconf_value);
611 /* error handling here */
612 if (_is_file_accessible(vconf_value) != 0)
613 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
615 if (system_setting_vconf_set_value_string(VCONFKEY_IDLE_LOCK_BGSET, vconf_value)) {
616 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
619 return SYSTEM_SETTINGS_ERROR_NONE;
622 int system_setting_set_font_size(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
626 vconf_value = (int *)value;
628 if (*vconf_value < 0 || *vconf_value > SYSTEM_SETTINGS_FONT_SIZE_GIANT) {
629 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
632 if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, *vconf_value)) {
633 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
637 return SYSTEM_SETTINGS_ERROR_NONE;
642 void *font_conf_doc_parse(char *doc_name, char *font_name)
644 xmlDocPtr doc = NULL;
645 xmlNodePtr cur = NULL;
646 xmlNodePtr cur2 = NULL;
647 xmlNodePtr cur3 = NULL;
650 doc = xmlParseFile(doc_name);
652 cur = xmlDocGetRootElement(doc);
660 if (xmlStrcmp(cur->name, (const xmlChar *)"fontconfig")) {
666 cur = cur->xmlChildrenNode;
668 Eina_Bool is_changed = EINA_FALSE;
669 while (cur != NULL) {
670 if ((!xmlStrcmp(cur->name, (const xmlChar *)"match"))) {
671 cur2 = cur->xmlChildrenNode;
672 while (cur2 != NULL) {
673 if ((!xmlStrcmp(cur2->name, (const xmlChar *)"edit"))) {
674 xmlChar *name = xmlGetProp(cur2, (const xmlChar *)"name");
675 /* if name is not 'family', break */
676 if (xmlStrcmp(name, (const xmlChar *)"family")) {
684 cur3 = cur2->xmlChildrenNode;
685 while (cur3 != NULL) {
686 if ((!xmlStrcmp(cur3->name, (const xmlChar *)"string"))) {
687 xmlNodeSetContent(cur3->xmlChildrenNode, (const xmlChar *)font_name);
688 key = xmlNodeListGetString(doc, cur3->xmlChildrenNode, 1);
691 is_changed = EINA_TRUE;
698 } else if ((!xmlStrcmp(cur->name, (const xmlChar *)"alias"))) {
699 cur2 = cur->xmlChildrenNode;
700 while (cur2 != NULL) {
701 if ((!xmlStrcmp(cur2->name, (const xmlChar *)"family"))) {
702 xmlNodeSetContent(cur2->xmlChildrenNode, (const xmlChar *)font_name);
703 key = xmlNodeListGetString(doc, cur2->xmlChildrenNode, 1);
706 is_changed = EINA_TRUE;
707 } else if ((!xmlStrcmp(cur2->name, (const xmlChar *)"prefer"))) {
708 cur3 = cur2->xmlChildrenNode;
709 while (cur3 != NULL) {
710 if ((!xmlStrcmp(cur3->name, (const xmlChar *)"family"))) {
711 xmlNodeSetContent(cur3->xmlChildrenNode, (const xmlChar *)font_name);
712 key = xmlNodeListGetString(doc, cur3->xmlChildrenNode, 1);
715 is_changed = EINA_TRUE;
737 int system_setting_set_font_type(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
739 char *font_name = NULL;
740 font_name = (char *)value;
742 /* get current font list */
743 int is_found = __is_available_font(font_name);
746 SETTING_TRACE("found font : %s ", font_name);
748 SETTING_TRACE(" NOT found font : %s ", font_name);
749 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
752 bool bsave = font_config_set(font_name);
755 SETTING_TRACE(" font type save error by font_config_set() ");
756 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
758 SETTING_TRACE(" save OK - font_config_set() ");
761 xmlDocPtr doc = (xmlDocPtr)font_conf_doc_parse(SETTING_FONT_CONF_FILE, font_name);
763 xmlSaveFormatFile(SETTING_FONT_CONF_FILE, doc, 0);
768 font_config_set_notification();
771 vconf_value = (char *)value;
772 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, vconf_value)) {
773 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
775 return SYSTEM_SETTINGS_ERROR_NONE;
778 int system_setting_set_motion_activation(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
781 vconf_value = (bool *)value;
782 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_MOTION_ACTIVATION, *vconf_value)) {
783 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
785 return SYSTEM_SETTINGS_ERROR_NONE;
788 int system_setting_set_usb_debugging_option(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
791 vconf_value = (bool *)value;
792 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_USB_DEBUG_MODE_BOOL, *vconf_value)) {
793 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
795 return SYSTEM_SETTINGS_ERROR_NONE;
799 int system_setting_set_3g_data_network(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
802 vconf_value = (bool *)value;
803 if (system_setting_vconf_set_value_bool(VCONFKEY_3G_ENABLE, *vconf_value)) {
804 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
806 return SYSTEM_SETTINGS_ERROR_NONE;
810 "IDS_COM_POP_SHORT" 0.5
811 "IDS_ST_BODY_MEDIUM" 1.0
812 "IDS_COM_POP_LONG" 1.5
814 int system_setting_set_tap_and_hold_delay(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
817 vconf_value = (int *)value;
819 char *result = "IDS_ST_BODY_MEDIUM"; /* default as 'medium' */
820 if (*vconf_value == SYSTEM_SETTINGS_TAP_AND_HOLD_DELAY_SHORT) {
821 result = "IDS_COM_POP_SHORT";
822 } else if (*vconf_value == SYSTEM_SETTINGS_TAP_AND_HOLD_DELAY_MEDIUM) {
823 result = "IDS_ST_BODY_MEDIUM";
824 } else if (*vconf_value == SYSTEM_SETTINGS_TAP_AND_HOLD_DELAY_LONG) {
825 result = "IDS_COM_POP_LONG";
827 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
830 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_ACCESSIBILITY_TAP_HOLD_DELAY_STR, result)) {
831 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
833 return SYSTEM_SETTINGS_ERROR_NONE;
836 static int category_func(const char *name, void *user_data)
839 static char *category = "lock-screen";
840 if (name && !strcmp(name, category)) {
841 SETTING_TRACE(" SAME ");
844 SETTING_TRACE(" DIFFERENT -- %s, category -- %s ", name, category);
853 * set 'swipe type' if current lockscreen app is 'com.samsung.lockscreen'
856 int system_setting_set_lockscreen_app(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
859 vconf_value = (char *)value; /* ex) com.samsung.lockscreen */
863 pkgmgrinfo_appinfo_h handle;
864 char *apptype = NULL;
865 r = pkgmgrinfo_appinfo_get_appinfo(vconf_value, &handle);
866 if (r != PMINFO_R_OK) {
867 SETTING_TRACE("*** pkginfo failed ");
868 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
870 SETTING_TRACE("%x", handle);
873 int ret = pkgmgrinfo_appinfo_foreach_category(handle, category_func, (void *)"lock-screen");
874 if (ret != PMINFO_R_OK) {
875 pkgmgrinfo_appinfo_destroy_appinfo(handle);
876 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
879 pkgmgrinfo_appinfo_destroy_appinfo(handle);
880 /*----------------------------------------------------------------------------------- */
882 if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_SCREEN_LOCK_TYPE_INT, &locktype)) {
883 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
886 if (locktype == SETTING_SCREEN_LOCK_TYPE_PASSWORD)
887 return SYSTEM_SETTINGS_ERROR_LOCKSCREEN_APP_PASSWORD_MODE;
889 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_3RD_LOCK_PKG_NAME_STR, vconf_value)) {
890 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
893 if (vconf_value && strcmp(vconf_value, "com.samsung.lockscreen") == 0) {
894 if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_SCREEN_LOCK_TYPE_INT, SETTING_SCREEN_LOCK_TYPE_SWIPE)) {
895 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
899 return SYSTEM_SETTINGS_ERROR_NONE;
902 /*/////////////////////////////////////////////////////////////////////////////////////////////// */
905 int system_setting_set_changed_callback_incoming_call_ringtone(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
907 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR, SYSTEM_SETTINGS_KEY_INCOMING_CALL_RINGTONE, 0, user_data);
910 int system_setting_unset_changed_callback_incoming_call_ringtone(system_settings_key_e key)
912 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR, 0);
915 int system_setting_set_changed_callback_email_alert_ringtone(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
917 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, SYSTEM_SETTINGS_KEY_EMAIL_ALERT_RINGTONE, 0, user_data);
920 int system_setting_unset_changed_callback_email_alert_ringtone(system_settings_key_e key)
922 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, 0);
925 int system_setting_set_changed_callback_wallpaper_home_screen(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
927 return system_setting_vconf_set_changed_cb(VCONFKEY_BGSET, SYSTEM_SETTINGS_KEY_WALLPAPER_HOME_SCREEN, 0, user_data);
930 int system_setting_unset_changed_callback_wallpaper_home_screen(system_settings_key_e key)
932 return system_setting_vconf_unset_changed_cb(VCONFKEY_BGSET, 0);
935 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)
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)
947 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, SYSTEM_SETTINGS_KEY_FONT_SIZE, 1, user_data);
950 int system_setting_unset_changed_callback_font_size(system_settings_key_e key)
952 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, 1);
955 int system_setting_set_changed_callback_usb_debugging_option(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
957 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_USB_DEBUG_MODE_BOOL, SYSTEM_SETTINGS_KEY_USB_DEBUGGING_ENABLED, 1, user_data);
960 int system_setting_unset_changed_callback_usb_debugging_option(system_settings_key_e key)
962 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_USB_DEBUG_MODE_BOOL, 1);
965 int system_setting_set_changed_callback_3g_data_network(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
967 return system_setting_vconf_set_changed_cb(VCONFKEY_3G_ENABLE, SYSTEM_SETTINGS_KEY_3G_DATA_NETWORK_ENABLED, 1, user_data);
970 int system_setting_unset_changed_callback_3g_data_network(system_settings_key_e key)
972 return system_setting_vconf_unset_changed_cb(VCONFKEY_3G_ENABLE, 1);
975 int system_setting_set_changed_callback_tap_and_hold_delay(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
977 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_TAP_HOLD_DELAY_STR, SYSTEM_SETTINGS_KEY_TAP_AND_HOLD_DELAY, 1, user_data);
980 int system_setting_unset_changed_callback_tap_and_hold_delay(system_settings_key_e key)
982 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_TAP_HOLD_DELAY_STR, 1);
985 int system_setting_set_changed_callback_lockscreen_app(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
987 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_3RD_LOCK_PKG_NAME_STR, SYSTEM_SETTINGS_KEY_TAP_AND_HOLD_DELAY, 1, user_data);
990 int system_setting_unset_changed_callback_lockscreen_app(system_settings_key_e key)
992 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_3RD_LOCK_PKG_NAME_STR, 1);
997 * @todo need to add custom event notification method
999 int system_setting_set_changed_callback_font_type(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
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 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 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_MOTION_ACTIVATION, SYSTEM_SETTINGS_KEY_MOTION_ACTIVATION, 3, user_data);
1015 int system_setting_unset_changed_callback_motion_activation(system_settings_key_e key)
1017 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_MOTION_ACTIVATION, 3);
1020 static char *_get_cur_font()
1022 xmlDocPtr doc = NULL;
1023 xmlNodePtr cur = NULL;
1024 xmlNodePtr cur2 = NULL;
1025 xmlNodePtr cur3 = NULL;
1026 xmlChar *key = NULL;
1028 char *font_name = NULL;
1030 doc = xmlParseFile(SETTING_FONT_CONF_FILE);
1032 cur = xmlDocGetRootElement(doc);
1040 if (xmlStrcmp(cur->name, (const xmlChar *)"fontconfig")) {
1046 cur = cur->xmlChildrenNode;
1048 while (cur != NULL) {
1049 if ((!xmlStrcmp(cur->name, (const xmlChar *)"match"))) {
1050 cur2 = cur->xmlChildrenNode;
1051 while (cur2 != NULL) {
1052 if ((!xmlStrcmp(cur2->name, (const xmlChar *)"edit"))) {
1053 cur3 = cur2->xmlChildrenNode;
1054 while (cur3 != NULL) {
1055 if ((!xmlStrcmp(cur3->name, (const xmlChar *)"string"))) {
1056 key = xmlNodeListGetString(doc, cur3->xmlChildrenNode, 1);
1058 font_name = g_strdup((char *)key);
1079 static void font_config_set_notification()
1083 Ecore_X_Window ecore_win = ecore_x_window_root_first_get();
1084 Ecore_X_Atom atom = ecore_x_atom_get("FONT_TYPE_change");
1085 ecore_x_window_prop_string_set(ecore_win, atom, "tizen");
1089 int __is_available_font(char *font_name)
1091 SETTING_TRACE_BEGIN;
1092 FcObjectSet *os = NULL;
1093 FcFontSet *fs = NULL;
1094 FcPattern *pat = NULL;
1095 Eina_List *list = NULL;
1096 FcConfig *font_config = NULL;
1100 if (font_name == NULL)
1103 font_config = FcInitLoadConfigAndFonts();
1105 /*setting_retvm_if(font_config == NULL, NULL, "Failed: FcInitLoadConfigAndFonts"); */
1107 char *locale = setlocale(0, NULL);
1109 pat = FcPatternCreate();
1111 os = FcObjectSetBuild(FC_FAMILY, FC_FILE, FC_FAMILYLANG, (char *) 0);
1114 fs = FcFontList(font_config, pat, os);
1115 FcObjectSetDestroy(os);
1120 FcPatternDestroy(pat);
1126 SETTING_TRACE("fs->nfont = %d", fs->nfont);
1128 for (j = 0; j < fs->nfont; j++) {
1129 FcChar8 *family = NULL;
1130 FcChar8 *file = NULL;
1132 if (FcPatternGetString(fs->fonts[j], FC_FILE, 0, &file) == FcResultMatch) {
1133 int preload_path_len = strlen(SETTING_FONT_PRELOAD_FONT_PATH);
1134 int download_path_len = strlen(SETTING_FONT_DOWNLOADED_FONT_PATH);
1136 if (file && (!strncmp((const char *)file, SETTING_FONT_PRELOAD_FONT_PATH, preload_path_len)
1137 || !strncmp((const char *)file, SETTING_FONT_DOWNLOADED_FONT_PATH, download_path_len))) {
1138 char *family_result = NULL;
1139 FcChar8 *lang = NULL;
1141 if (FcPatternGetString(fs->fonts[j], FC_FAMILY, id, &family) != FcResultMatch) {
1144 if (FcPatternGetString(fs->fonts[j], FC_FAMILYLANG, id, &lang) != FcResultMatch) {
1147 family_result = (char *)family;
1149 /* Find proper family name for current locale. */
1150 while (locale && family && lang) {
1151 if (!strncmp(locale, (char *)lang, strlen((char *)lang))) {
1152 family_result = (char *)family;
1156 /* I will set english as default family language. */
1157 /* If there is no proper family language for current locale, */
1158 /* we have to show the english family name. */
1159 if (!strcmp(lang, "en")) {
1160 family_result = (char *)family;
1163 if (FcPatternGetString(fs->fonts[j], FC_FAMILY, id, &family) != FcResultMatch) {
1166 if (FcPatternGetString(fs->fonts[j], FC_FAMILYLANG, id, &lang) != FcResultMatch) {
1171 if (family_result) {
1172 SETTING_TRACE("-------- FONT - family_result = %s", (char *)family_result);
1173 if (strcmp(family_result, font_name) == 0) {
1181 FcFontSetDestroy(fs);
1184 FcConfigDestroy(font_config);
1190 static char *_get_default_font()
1192 xmlDocPtr doc = NULL;
1193 xmlNodePtr cur = NULL;
1194 xmlNodePtr cur2 = NULL;
1195 xmlNodePtr cur3 = NULL;
1196 xmlChar *key = NULL;
1197 struct _xmlAttr *properties = NULL;
1198 char *default_font_name = NULL;
1200 doc = xmlParseFile(SETTING_DEFAULT_FONT_CONF_FILE);
1202 cur = xmlDocGetRootElement(doc);
1210 if (xmlStrcmp(cur->name, (const xmlChar *)"fontconfig")) {
1216 cur = cur->xmlChildrenNode;
1218 while (cur != NULL) {
1219 if ((!xmlStrcmp(cur->name, (const xmlChar *)"match"))) {
1220 cur2 = cur->xmlChildrenNode;
1221 while (cur2 != NULL) {
1222 if ((!xmlStrcmp(cur2->name, (const xmlChar *)"edit"))) {
1223 properties = cur2->properties;
1224 /*find the "name" property*/
1225 while (NULL != properties) {
1226 if (!xmlStrcmp(properties->name, (const xmlChar *)"name")) {
1229 properties = properties->next;
1232 /*If the value of "name" property is "family", then get the child node string,
1233 it shall be the default font type*/
1234 if (NULL != properties && !xmlStrcmp(properties->children->content, (const xmlChar *)"family")) {
1235 cur3 = cur2->xmlChildrenNode;
1236 while (cur3 != NULL) {
1237 if ((!xmlStrcmp(cur3->name, (const xmlChar *)"string"))) {
1238 key = xmlNodeListGetString(doc, cur3->xmlChildrenNode, 1);
1239 default_font_name = g_strdup((char *)key);
1244 return default_font_name;
1261 static bool font_config_set(char *font_name)
1263 Eina_List *text_classes = NULL;
1264 Elm_Text_Class *etc = NULL;
1265 const Eina_List *l = NULL;
1266 Eina_List *fo_list = NULL;
1267 Elm_Font_Overlay *efo = NULL;
1269 int font_size = __font_size_get();
1272 text_classes = elm_config_text_classes_list_get();
1274 fo_list = (Eina_List *)elm_config_font_overlay_list_get();
1276 Eina_List *ll = NULL;
1277 Eina_List *l_next = NULL;
1279 Eina_Bool slp_medium_exist = EINA_FALSE;
1280 Eina_Bool slp_roman_exist = EINA_FALSE;
1281 Eina_Bool slp_bold_exist = EINA_FALSE;
1282 Eina_Bool slp_regular_exist = EINA_FALSE;
1285 Eina_Bool tizen_exist = EINA_FALSE;
1287 EINA_LIST_FOREACH_SAFE(fo_list, ll, l_next, efo) {
1288 if (!strcmp(efo->text_class, "tizen_medium")) {
1289 elm_config_font_overlay_set(efo->text_class, (const char *)font_name, efo->size);
1290 slp_medium_exist = EINA_TRUE;
1291 } else if (!strcmp(efo->text_class, "tizen_roman")) {
1292 elm_config_font_overlay_set(efo->text_class, (const char *)font_name, efo->size);
1293 slp_roman_exist = EINA_TRUE;
1294 } else if (!strcmp(efo->text_class, "tizen_bold")) {
1295 elm_config_font_overlay_set(efo->text_class, (const char *)font_name, efo->size);
1296 slp_bold_exist = EINA_TRUE;
1297 } else if (!strcmp(efo->text_class, "tizen_regular")) {
1298 elm_config_font_overlay_set(efo->text_class, (const char *)font_name, efo->size);
1299 slp_regular_exist = EINA_TRUE;
1303 if (!strcmp(efo->text_class, "tizen")) {
1304 elm_config_font_overlay_set(efo->text_class, (const char *)font_name, efo->size);
1305 tizen_exist = EINA_TRUE;
1310 /* if slp_XX do not exist, need to set them, font size is -100(100%) */
1311 if (slp_medium_exist == EINA_FALSE) {
1312 elm_config_font_overlay_set("tizen_medium", (const char *)font_name, MIDDLE_FONT_DPI);
1314 if (slp_roman_exist == EINA_FALSE) {
1315 elm_config_font_overlay_set("tizen_roman", (const char *)font_name, MIDDLE_FONT_DPI);
1317 if (slp_bold_exist == EINA_FALSE) {
1318 elm_config_font_overlay_set("tizen_bold", (const char *)font_name, MIDDLE_FONT_DPI);
1320 if (slp_regular_exist == EINA_FALSE) {
1321 elm_config_font_overlay_set("tizen_regular", (const char *)font_name, MIDDLE_FONT_DPI);
1325 if (tizen_exist == EINA_FALSE) {
1326 elm_config_font_overlay_set("tizen", (const char *)font_name, MIDDLE_FONT_DPI);
1329 elm_config_font_overlay_set("tizen", (const char *)font_name, MIDDLE_FONT_DPI);
1332 elm_config_font_overlay_set("tizen", (const char *)font_name, MIDDLE_FONT_DPI);
1334 EINA_LIST_FOREACH(text_classes, l, etc) {
1338 EINA_LIST_FOREACH(fo_list, ll, efo) {
1339 if (!strcmp(etc->name, efo->text_class)) {
1343 elm_config_font_overlay_set(etc->name, (const char *)font_name, size);
1345 elm_config_text_classes_list_free(text_classes);
1346 text_classes = NULL;
1348 /* add new function */
1349 #ifdef USE_EFL_ASSIST
1350 ea_theme_system_font_set(font_name, font_size);
1351 ea_theme_system_fonts_apply();
1356 static void __font_size_set()
1358 Eina_List *text_classes = NULL;
1359 Elm_Text_Class *etc = NULL;
1360 const Eina_List *l = NULL;
1361 int font_size = __font_size_get();
1362 char *font_name = _get_cur_font();
1364 if (font_size == -1) {
1368 text_classes = elm_config_text_classes_list_get();
1370 EINA_LIST_FOREACH(text_classes, l, etc) {
1371 elm_config_font_overlay_set(etc->name, font_name, font_size);
1374 elm_config_text_classes_list_free(text_classes);
1376 #ifdef USE_EFL_ASSIST
1377 ea_theme_system_font_set(font_name, font_size);
1378 ea_theme_system_fonts_apply();
1380 text_classes = NULL;
1384 static int __font_size_get()
1389 int vconf_value = -1;
1390 if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, &vconf_value)) {
1394 switch (vconf_value) {
1395 case SYSTEM_SETTINGS_FONT_SIZE_SMALL:
1396 font_size = SMALL_FONT_DPI;
1398 case SYSTEM_SETTINGS_FONT_SIZE_NORMAL:
1399 font_size = MIDDLE_FONT_DPI;
1401 case SYSTEM_SETTINGS_FONT_SIZE_LARGE:
1402 font_size = LARGE_FONT_DPI;
1404 case SYSTEM_SETTINGS_FONT_SIZE_HUGE:
1405 font_size = HUGE_FONT_DPI;
1407 case SYSTEM_SETTINGS_FONT_SIZE_GIANT:
1408 font_size = GIANT_FONT_DPI;
1411 font_size = MIDDLE_FONT_DPI;
1417 /*//////////////////////////////////////////////////////////////////////////////////////// */
1418 /*--------------------------------------- */
1419 int system_setting_get_locale_country(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1421 char *vconf_value = NULL;
1422 if (system_setting_vconf_get_value_string(VCONFKEY_REGIONFORMAT, &vconf_value)) {
1423 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1426 /* parsing validation */
1429 snprintf(arr, 20, vconf_value);
1431 *value = strdup(arr);
1435 return SYSTEM_SETTINGS_ERROR_NONE;
1438 int system_setting_set_locale_country(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1440 char *vconf_value = NULL;
1441 vconf_value = (char *)value;
1443 char *ext = "UTF-8";
1446 snprintf(arr, 20, "%s.%s", vconf_value, ext);
1448 if (system_setting_vconf_set_value_string(VCONFKEY_REGIONFORMAT, arr)) {
1449 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1452 return SYSTEM_SETTINGS_ERROR_NONE;
1455 int system_setting_set_changed_callback_locale_country(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1457 return system_setting_vconf_set_changed_cb(VCONFKEY_REGIONFORMAT, SYSTEM_SETTINGS_KEY_LOCALE_COUNTRY, 3, user_data);
1460 int system_setting_unset_changed_callback_locale_country(system_settings_key_e key)
1462 return system_setting_vconf_unset_changed_cb(VCONFKEY_REGIONFORMAT, 3);
1466 /*--------------------------------------- */
1467 int system_setting_get_locale_language(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1469 char *vconf_value = NULL;
1470 if (system_setting_vconf_get_value_string(VCONFKEY_LANGSET, &vconf_value)) {
1471 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1474 /* parsing validation */
1477 snprintf(arr, 20, vconf_value);
1479 *value = strdup(arr);
1482 return SYSTEM_SETTINGS_ERROR_NONE;
1485 int system_setting_set_locale_language(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1487 char *vconf_value = NULL;
1488 vconf_value = (char *)value;
1490 char *ext = "UTF-8";
1493 snprintf(arr, 20, "%s.%s", vconf_value, ext);
1495 if (system_setting_vconf_set_value_string(VCONFKEY_LANGSET, arr)) {
1496 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1499 return SYSTEM_SETTINGS_ERROR_NONE;
1502 int system_setting_set_changed_callback_locale_language(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1504 /*return system_setting_vconf_set_changed_cb(VCONFKEY_LANGSET, SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, 3, user_data ); */
1505 return system_setting_vconf_set_changed_cb(VCONFKEY_LANGSET, SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, 100, user_data);
1508 int system_setting_unset_changed_callback_locale_language(system_settings_key_e key)
1510 return system_setting_vconf_unset_changed_cb(VCONFKEY_LANGSET, 100);
1513 /*--------------------------------------- */
1514 int system_setting_get_locale_timeformat_24hour(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1518 if (system_setting_vconf_get_value_int(VCONFKEY_REGIONFORMAT_TIME1224, &vconf_value)) {
1519 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1523 if (vconf_value == VCONFKEY_TIME_FORMAT_12)
1525 else if (vconf_value == VCONFKEY_TIME_FORMAT_24)
1528 *value = (void *)ret_value;
1530 return SYSTEM_SETTINGS_ERROR_NONE;
1533 int system_setting_set_locale_timeformat_24hour(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1537 vconf_value = (bool *)value;
1540 if (system_setting_vconf_set_value_int(VCONFKEY_REGIONFORMAT_TIME1224, VCONFKEY_TIME_FORMAT_24)) {
1541 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1545 if (system_setting_vconf_set_value_int(VCONFKEY_REGIONFORMAT_TIME1224, VCONFKEY_TIME_FORMAT_12)) {
1546 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1551 return SYSTEM_SETTINGS_ERROR_NONE;
1554 int system_setting_set_changed_callback_locale_timeformat_24hour(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1556 return system_setting_vconf_set_changed_cb(VCONFKEY_REGIONFORMAT_TIME1224, SYSTEM_SETTINGS_KEY_LOCALE_TIMEFORMAT_24HOUR, 3, user_data);
1559 int system_setting_unset_changed_callback_locale_timeformat_24hour(system_settings_key_e key)
1561 return system_setting_vconf_unset_changed_cb(VCONFKEY_REGIONFORMAT_TIME1224, 3);
1564 int system_setting_get_locale_timezone(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1567 ssize_t len = readlink(SETTING_TZONE_SYMLINK_PATH, tzpath, sizeof(tzpath) - 1);
1571 SETTING_TRACE("parse error for SETTING_TZONE_SYMLINK_PATH");
1572 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1575 /* "/usr/share/zoneinfo/Asia/Seoul" */
1576 SETTING_TRACE("tzpath : %s ", &tzpath[20]);
1577 *value = strdup(&tzpath[20]);
1578 return SYSTEM_SETTINGS_ERROR_NONE;
1581 int system_setting_set_changed_callback_locale_timezone_changed(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1583 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
1586 int system_setting_unset_changed_callback_locale_timezone_changed(system_settings_key_e key)
1588 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
1592 int system_setting_get_time_changed(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1595 cur_tick = time(NULL);
1596 *value = (void *)cur_tick;
1597 /* struct tm * localtime = time (cur_tick); */
1598 /* printf("%s\n", ctime(&cur_tick); */
1599 return SYSTEM_SETTINGS_ERROR_NONE;
1603 int system_setting_set_changed_callback_time_changed(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1605 return system_setting_vconf_set_changed_cb(VCONFKEY_SYSTEM_TIME_CHANGED, SYSTEM_SETTINGS_KEY_TIME_CHANGED, 3, user_data);
1608 int system_setting_unset_changed_callback_time_changed(system_settings_key_e key)
1610 return system_setting_vconf_unset_changed_cb(VCONFKEY_SYSTEM_TIME_CHANGED, 3);
1615 /* SYSTEM_SETTINGS_KEY_SOUND_LOCK */
1616 int system_setting_get_sound_lock(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1620 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_SOUND_LOCK_BOOL, &vconf_value)) {
1621 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1623 *value = (void *)vconf_value;
1625 return SYSTEM_SETTINGS_ERROR_NONE;
1628 int system_setting_set_changed_callback_sound_lock(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1630 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_SOUND_LOCK_BOOL, SYSTEM_SETTINGS_KEY_SOUND_LOCK, 3, user_data);
1633 int system_setting_unset_changed_callback_sound_lock(system_settings_key_e key)
1635 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_SOUND_LOCK_BOOL, 3);
1639 * a = VCONFKEY_SETAPPL_SOUND_STATUS_BOOL b = VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL
1641 * a == false, b == false --> silent mode
1642 * a == true, b == false --> sound mode
1643 * a == false, b == true --> vibration mode
1645 int system_setting_get_sound_silent_mode(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1651 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, &sound_cond)) {
1652 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1655 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, &vib_cond)) {
1656 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1659 if (sound_cond == false && vib_cond == false) {
1661 *value = (void *)vconf_value;
1663 vconf_value = false;
1664 *value = (void *)vconf_value;
1666 return SYSTEM_SETTINGS_ERROR_NONE;
1670 * a = VCONFKEY_SETAPPL_SOUND_STATUS_BOOL b = VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL
1672 * a == false, b == false --> silent mode
1673 * a == true, b == false --> sound mode
1675 int system_setting_set_sound_silent_mode(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1679 vconf_value = (bool *)value;
1681 bool vconf_sound = false;
1682 bool vconf_vib = false;
1685 vconf_sound = false;
1692 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, vconf_sound)) {
1693 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1695 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, vconf_vib)) {
1696 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1699 return SYSTEM_SETTINGS_ERROR_NONE;
1705 int system_setting_set_changed_callback_sound_silent_mode(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1707 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, SYSTEM_SETTINGS_KEY_SOUND_SILENT_MODE, 3, user_data);
1711 int system_setting_unset_changed_callback_sound_silent_mode(system_settings_key_e key)
1713 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, 3);
1716 /* SYSTEM_SETTINGS_KEY_SOUND_TOUCH */
1717 int system_setting_get_sound_touch(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1721 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL, &vconf_value)) {
1722 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1724 *value = (void *)vconf_value;
1727 int system_setting_set_changed_callback_sound_touch(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1729 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL, SYSTEM_SETTINGS_KEY_SOUND_TOUCH, 2, user_data);
1732 int system_setting_unset_changed_callback_sound_touch(system_settings_key_e key)
1734 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL, 2);
1738 /* SYSTEM_SETTINGS_KEY_SOUND_LOCK */
1739 int system_setting_get_sound_lock(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1743 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_SOUND_LOCK_BOOL, &vconf_value)) {
1744 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1746 *value = (void *)vconf_value;
1748 return SYSTEM_SETTINGS_ERROR_NONE;
1752 int system_setting_get_auto_rotation_mode(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1756 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, &vconf_value)) {
1757 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1759 *value = (void *)vconf_value;
1761 return SYSTEM_SETTINGS_ERROR_NONE;
1764 int system_setting_set_auto_rotation_mode(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1767 vconf_value = (bool *)value;
1768 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, *vconf_value)) {
1769 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1771 return SYSTEM_SETTINGS_ERROR_NONE;
1774 int system_setting_set_changed_callback_auto_rotation_mode(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1776 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, SYSTEM_SETTINGS_KEY_DISPLAY_SCREEN_ROTATION_AUTO, 2, user_data);
1779 int system_setting_unset_changed_callback_auto_rotation_mode(system_settings_key_e key)
1781 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, 2);
1784 int system_setting_get_screen_backlight_time(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1788 if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, &vconf_value)) {
1789 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1791 *value = (void *)vconf_value;
1793 return SYSTEM_SETTINGS_ERROR_NONE;
1797 int system_setting_set_screen_backlight_time(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1799 SETTING_TRACE_BEGIN;
1801 vconf_value = (int *)value;
1803 if (*vconf_value < 0 || *vconf_value > 600) {
1804 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
1807 if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, *vconf_value)) {
1808 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1811 return SYSTEM_SETTINGS_ERROR_NONE;
1814 int system_setting_set_changed_callback_screen_backlight_time(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1816 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, SYSTEM_SETTINGS_KEY_DISPLAY_SCREEN_ROTATION_AUTO, 2, user_data);
1819 int system_setting_unset_changed_callback_screen_backlight_time(system_settings_key_e key)
1821 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, 2);
1824 int system_setting_get_sound_notification(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1826 char *vconf_value = NULL;
1827 if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, &vconf_value)) {
1828 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1831 *value = vconf_value;
1832 return SYSTEM_SETTINGS_ERROR_NONE;
1835 int system_setting_set_sound_notification(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1837 char *vconf_value = NULL;
1838 vconf_value = (char *)value;
1840 int is_load = _is_file_accessible(vconf_value);
1842 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, vconf_value)) {
1843 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1846 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1849 return SYSTEM_SETTINGS_ERROR_NONE;
1852 int system_setting_set_changed_callback_sound_notification(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1854 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, SYSTEM_SETTINGS_KEY_INCOMING_CALL_RINGTONE, 0, user_data);
1857 int system_setting_unset_changed_callback_sound_notification(system_settings_key_e key)
1859 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, 0);
1862 int system_setting_get_notification_repetition_period(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1866 if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_NOTI_MSG_ALERT_REP_TYPE_INT, &vconf_value)) {
1867 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1869 *value = (void *)vconf_value;
1871 return SYSTEM_SETTINGS_ERROR_NONE;
1874 int system_setting_set_notification_repetition_period(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1876 SETTING_TRACE_BEGIN;
1878 vconf_value = (int *)value;
1880 if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_NOTI_MSG_ALERT_REP_TYPE_INT, *vconf_value)) {
1881 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1884 return SYSTEM_SETTINGS_ERROR_NONE;
1887 int system_setting_set_changed_callback_notification_repetition_period(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1889 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_ALERT_REP_TYPE_INT, SYSTEM_SETTINGS_KEY_DISPLAY_SCREEN_ROTATION_AUTO, 1, user_data);
1892 int system_setting_unset_changed_callback_notification_repetition_period(system_settings_key_e key)
1894 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_ALERT_REP_TYPE_INT, 1);
1897 int system_setting_get_device_name(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1899 char *vconf_value = NULL;
1900 if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_DEVICE_NAME_STR, &vconf_value)) {
1901 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1904 *value = vconf_value;
1905 return SYSTEM_SETTINGS_ERROR_NONE;
1908 int system_setting_set_device_name(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1910 char *vconf_value = NULL;
1911 vconf_value = (char *)value;
1913 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_DEVICE_NAME_STR, vconf_value)) {
1914 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1917 return SYSTEM_SETTINGS_ERROR_NONE;
1920 int system_setting_set_changed_callback_device_name(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1922 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_DEVICE_NAME_STR, SYSTEM_SETTINGS_KEY_DEVICE_NAME, 0, user_data);
1925 int system_setting_unset_changed_callback_device_name(system_settings_key_e key)
1927 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_DEVICE_NAME_STR, 0);
1930 /*---------------------------------------------- */
1931 int system_setting_get_network_flight_mode(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1934 if (system_setting_vconf_get_value_bool(VCONFKEY_TELEPHONY_FLIGHT_MODE, &vconf_value)) {
1935 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1937 *value = (void *)vconf_value;
1939 return SYSTEM_SETTINGS_ERROR_NONE;
1942 int system_setting_set_changed_callback_network_flight_mode(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1944 return system_setting_vconf_set_changed_cb(VCONFKEY_TELEPHONY_FLIGHT_MODE, SYSTEM_SETTINGS_KEY_NETWORK_FLIGHT_MODE, 3, user_data);
1947 int system_setting_unset_changed_callback_network_flight_mode(system_settings_key_e key)
1949 return system_setting_vconf_unset_changed_cb(VCONFKEY_TELEPHONY_FLIGHT_MODE, 3);
1952 int system_setting_get_network_wifi_notification(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1955 if (system_setting_vconf_get_value_int(VCONFKEY_WIFI_ENABLE_QS, &vconf_value)) {
1956 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1959 bret = (vconf_value == VCONFKEY_WIFI_QS_ENABLE) ? true : false;
1961 *value = (void *)bret;
1962 return SYSTEM_SETTINGS_ERROR_NONE;
1965 int system_setting_set_changed_callback_network_wifi_notification(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1967 return system_setting_vconf_set_changed_cb(VCONFKEY_WIFI_ENABLE_QS, SYSTEM_SETTINGS_KEY_NETWORK_WIFI_NOTIFICATION, 4, user_data);
1970 int system_setting_unset_changed_callback_network_wifi_notification(system_settings_key_e key)
1972 return system_setting_vconf_unset_changed_cb(VCONFKEY_WIFI_ENABLE_QS, 4);