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()
1082 Ecore_X_Window ecore_win = ecore_x_window_root_first_get();
1083 Ecore_X_Atom atom = ecore_x_atom_get("FONT_TYPE_change");
1084 ecore_x_window_prop_string_set(ecore_win, atom, "tizen");
1087 int __is_available_font(char *font_name)
1089 SETTING_TRACE_BEGIN;
1090 FcObjectSet *os = NULL;
1091 FcFontSet *fs = NULL;
1092 FcPattern *pat = NULL;
1093 Eina_List *list = NULL;
1094 FcConfig *font_config = NULL;
1098 if (font_name == NULL)
1101 font_config = FcInitLoadConfigAndFonts();
1103 /*setting_retvm_if(font_config == NULL, NULL, "Failed: FcInitLoadConfigAndFonts"); */
1105 char *locale = setlocale(0, NULL);
1107 pat = FcPatternCreate();
1109 os = FcObjectSetBuild(FC_FAMILY, FC_FILE, FC_FAMILYLANG, (char *) 0);
1112 fs = FcFontList(font_config, pat, os);
1113 FcObjectSetDestroy(os);
1118 FcPatternDestroy(pat);
1124 SETTING_TRACE("fs->nfont = %d", fs->nfont);
1126 for (j = 0; j < fs->nfont; j++) {
1127 FcChar8 *family = NULL;
1128 FcChar8 *file = NULL;
1130 if (FcPatternGetString(fs->fonts[j], FC_FILE, 0, &file) == FcResultMatch) {
1131 int preload_path_len = strlen(SETTING_FONT_PRELOAD_FONT_PATH);
1132 int download_path_len = strlen(SETTING_FONT_DOWNLOADED_FONT_PATH);
1134 if (file && (!strncmp((const char *)file, SETTING_FONT_PRELOAD_FONT_PATH, preload_path_len)
1135 || !strncmp((const char *)file, SETTING_FONT_DOWNLOADED_FONT_PATH, download_path_len))) {
1136 char *family_result = NULL;
1137 FcChar8 *lang = NULL;
1139 if (FcPatternGetString(fs->fonts[j], FC_FAMILY, id, &family) != FcResultMatch) {
1142 if (FcPatternGetString(fs->fonts[j], FC_FAMILYLANG, id, &lang) != FcResultMatch) {
1145 family_result = (char *)family;
1147 /* Find proper family name for current locale. */
1148 while (locale && family && lang) {
1149 if (!strncmp(locale, (char *)lang, strlen((char *)lang))) {
1150 family_result = (char *)family;
1154 /* I will set english as default family language. */
1155 /* If there is no proper family language for current locale, */
1156 /* we have to show the english family name. */
1157 if (!strcmp(lang, "en")) {
1158 family_result = (char *)family;
1161 if (FcPatternGetString(fs->fonts[j], FC_FAMILY, id, &family) != FcResultMatch) {
1164 if (FcPatternGetString(fs->fonts[j], FC_FAMILYLANG, id, &lang) != FcResultMatch) {
1169 if (family_result) {
1170 SETTING_TRACE("-------- FONT - family_result = %s", (char *)family_result);
1171 if (strcmp(family_result, font_name) == 0) {
1179 FcFontSetDestroy(fs);
1182 FcConfigDestroy(font_config);
1188 static char *_get_default_font()
1190 xmlDocPtr doc = NULL;
1191 xmlNodePtr cur = NULL;
1192 xmlNodePtr cur2 = NULL;
1193 xmlNodePtr cur3 = NULL;
1194 xmlChar *key = NULL;
1195 struct _xmlAttr *properties = NULL;
1196 char *default_font_name = NULL;
1198 doc = xmlParseFile(SETTING_DEFAULT_FONT_CONF_FILE);
1200 cur = xmlDocGetRootElement(doc);
1208 if (xmlStrcmp(cur->name, (const xmlChar *)"fontconfig")) {
1214 cur = cur->xmlChildrenNode;
1216 while (cur != NULL) {
1217 if ((!xmlStrcmp(cur->name, (const xmlChar *)"match"))) {
1218 cur2 = cur->xmlChildrenNode;
1219 while (cur2 != NULL) {
1220 if ((!xmlStrcmp(cur2->name, (const xmlChar *)"edit"))) {
1221 properties = cur2->properties;
1222 /*find the "name" property*/
1223 while (NULL != properties) {
1224 if (!xmlStrcmp(properties->name, (const xmlChar *)"name")) {
1227 properties = properties->next;
1230 /*If the value of "name" property is "family", then get the child node string,
1231 it shall be the default font type*/
1232 if (NULL != properties && !xmlStrcmp(properties->children->content, (const xmlChar *)"family")) {
1233 cur3 = cur2->xmlChildrenNode;
1234 while (cur3 != NULL) {
1235 if ((!xmlStrcmp(cur3->name, (const xmlChar *)"string"))) {
1236 key = xmlNodeListGetString(doc, cur3->xmlChildrenNode, 1);
1237 default_font_name = g_strdup((char *)key);
1242 return default_font_name;
1259 static bool font_config_set(char *font_name)
1261 Eina_List *text_classes = NULL;
1262 Elm_Text_Class *etc = NULL;
1263 const Eina_List *l = NULL;
1264 Eina_List *fo_list = NULL;
1265 Elm_Font_Overlay *efo = NULL;
1267 int font_size = __font_size_get();
1270 text_classes = elm_config_text_classes_list_get();
1272 fo_list = (Eina_List *)elm_config_font_overlay_list_get();
1274 Eina_List *ll = NULL;
1275 Eina_List *l_next = NULL;
1277 Eina_Bool slp_medium_exist = EINA_FALSE;
1278 Eina_Bool slp_roman_exist = EINA_FALSE;
1279 Eina_Bool slp_bold_exist = EINA_FALSE;
1280 Eina_Bool slp_regular_exist = EINA_FALSE;
1283 Eina_Bool tizen_exist = EINA_FALSE;
1285 EINA_LIST_FOREACH_SAFE(fo_list, ll, l_next, efo) {
1286 if (!strcmp(efo->text_class, "tizen_medium")) {
1287 elm_config_font_overlay_set(efo->text_class, (const char *)font_name, efo->size);
1288 slp_medium_exist = EINA_TRUE;
1289 } else if (!strcmp(efo->text_class, "tizen_roman")) {
1290 elm_config_font_overlay_set(efo->text_class, (const char *)font_name, efo->size);
1291 slp_roman_exist = EINA_TRUE;
1292 } else if (!strcmp(efo->text_class, "tizen_bold")) {
1293 elm_config_font_overlay_set(efo->text_class, (const char *)font_name, efo->size);
1294 slp_bold_exist = EINA_TRUE;
1295 } else if (!strcmp(efo->text_class, "tizen_regular")) {
1296 elm_config_font_overlay_set(efo->text_class, (const char *)font_name, efo->size);
1297 slp_regular_exist = EINA_TRUE;
1301 if (!strcmp(efo->text_class, "tizen")) {
1302 elm_config_font_overlay_set(efo->text_class, (const char *)font_name, efo->size);
1303 tizen_exist = EINA_TRUE;
1308 /* if slp_XX do not exist, need to set them, font size is -100(100%) */
1309 if (slp_medium_exist == EINA_FALSE) {
1310 elm_config_font_overlay_set("tizen_medium", (const char *)font_name, MIDDLE_FONT_DPI);
1312 if (slp_roman_exist == EINA_FALSE) {
1313 elm_config_font_overlay_set("tizen_roman", (const char *)font_name, MIDDLE_FONT_DPI);
1315 if (slp_bold_exist == EINA_FALSE) {
1316 elm_config_font_overlay_set("tizen_bold", (const char *)font_name, MIDDLE_FONT_DPI);
1318 if (slp_regular_exist == EINA_FALSE) {
1319 elm_config_font_overlay_set("tizen_regular", (const char *)font_name, MIDDLE_FONT_DPI);
1323 if (tizen_exist == EINA_FALSE) {
1324 elm_config_font_overlay_set("tizen", (const char *)font_name, MIDDLE_FONT_DPI);
1327 elm_config_font_overlay_set("tizen", (const char *)font_name, MIDDLE_FONT_DPI);
1330 elm_config_font_overlay_set("tizen", (const char *)font_name, MIDDLE_FONT_DPI);
1332 EINA_LIST_FOREACH(text_classes, l, etc) {
1336 EINA_LIST_FOREACH(fo_list, ll, efo) {
1337 if (!strcmp(etc->name, efo->text_class)) {
1341 elm_config_font_overlay_set(etc->name, (const char *)font_name, size);
1343 elm_config_text_classes_list_free(text_classes);
1344 text_classes = NULL;
1346 /* add new function */
1347 #ifdef USE_EFL_ASSIST
1348 ea_theme_system_font_set(font_name, font_size);
1349 ea_theme_system_fonts_apply();
1354 static void __font_size_set()
1356 Eina_List *text_classes = NULL;
1357 Elm_Text_Class *etc = NULL;
1358 const Eina_List *l = NULL;
1359 int font_size = __font_size_get();
1360 char *font_name = _get_cur_font();
1362 if (font_size == -1) {
1366 text_classes = elm_config_text_classes_list_get();
1368 EINA_LIST_FOREACH(text_classes, l, etc) {
1369 elm_config_font_overlay_set(etc->name, font_name, font_size);
1372 elm_config_text_classes_list_free(text_classes);
1374 #ifdef USE_EFL_ASSIST
1375 ea_theme_system_font_set(font_name, font_size);
1376 ea_theme_system_fonts_apply();
1378 text_classes = NULL;
1382 static int __font_size_get()
1387 int vconf_value = -1;
1388 if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, &vconf_value)) {
1392 switch (vconf_value) {
1393 case SYSTEM_SETTINGS_FONT_SIZE_SMALL:
1394 font_size = SMALL_FONT_DPI;
1396 case SYSTEM_SETTINGS_FONT_SIZE_NORMAL:
1397 font_size = MIDDLE_FONT_DPI;
1399 case SYSTEM_SETTINGS_FONT_SIZE_LARGE:
1400 font_size = LARGE_FONT_DPI;
1402 case SYSTEM_SETTINGS_FONT_SIZE_HUGE:
1403 font_size = HUGE_FONT_DPI;
1405 case SYSTEM_SETTINGS_FONT_SIZE_GIANT:
1406 font_size = GIANT_FONT_DPI;
1409 font_size = MIDDLE_FONT_DPI;
1415 /*//////////////////////////////////////////////////////////////////////////////////////// */
1416 /*--------------------------------------- */
1417 int system_setting_get_locale_country(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1419 char *vconf_value = NULL;
1420 if (system_setting_vconf_get_value_string(VCONFKEY_REGIONFORMAT, &vconf_value)) {
1421 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1424 /* parsing validation */
1427 snprintf(arr, 20, vconf_value);
1429 *value = strdup(arr);
1433 return SYSTEM_SETTINGS_ERROR_NONE;
1436 int system_setting_set_locale_country(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1438 char *vconf_value = NULL;
1439 vconf_value = (char *)value;
1441 char *ext = "UTF-8";
1444 snprintf(arr, 20, "%s.%s", vconf_value, ext);
1446 if (system_setting_vconf_set_value_string(VCONFKEY_REGIONFORMAT, arr)) {
1447 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1450 return SYSTEM_SETTINGS_ERROR_NONE;
1453 int system_setting_set_changed_callback_locale_country(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1455 return system_setting_vconf_set_changed_cb(VCONFKEY_REGIONFORMAT, SYSTEM_SETTINGS_KEY_LOCALE_COUNTRY, 3, user_data);
1458 int system_setting_unset_changed_callback_locale_country(system_settings_key_e key)
1460 return system_setting_vconf_unset_changed_cb(VCONFKEY_REGIONFORMAT, 3);
1464 /*--------------------------------------- */
1465 int system_setting_get_locale_language(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1467 char *vconf_value = NULL;
1468 if (system_setting_vconf_get_value_string(VCONFKEY_LANGSET, &vconf_value)) {
1469 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1472 /* parsing validation */
1475 snprintf(arr, 20, vconf_value);
1477 *value = strdup(arr);
1480 return SYSTEM_SETTINGS_ERROR_NONE;
1483 int system_setting_set_locale_language(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1485 char *vconf_value = NULL;
1486 vconf_value = (char *)value;
1488 char *ext = "UTF-8";
1491 snprintf(arr, 20, "%s.%s", vconf_value, ext);
1493 if (system_setting_vconf_set_value_string(VCONFKEY_LANGSET, arr)) {
1494 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1497 return SYSTEM_SETTINGS_ERROR_NONE;
1500 int system_setting_set_changed_callback_locale_language(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1502 /*return system_setting_vconf_set_changed_cb(VCONFKEY_LANGSET, SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, 3, user_data ); */
1503 return system_setting_vconf_set_changed_cb(VCONFKEY_LANGSET, SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, 100, user_data);
1506 int system_setting_unset_changed_callback_locale_language(system_settings_key_e key)
1508 return system_setting_vconf_unset_changed_cb(VCONFKEY_LANGSET, 100);
1511 /*--------------------------------------- */
1512 int system_setting_get_locale_timeformat_24hour(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1516 if (system_setting_vconf_get_value_int(VCONFKEY_REGIONFORMAT_TIME1224, &vconf_value)) {
1517 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1521 if (vconf_value == VCONFKEY_TIME_FORMAT_12)
1523 else if (vconf_value == VCONFKEY_TIME_FORMAT_24)
1526 *value = (void *)ret_value;
1528 return SYSTEM_SETTINGS_ERROR_NONE;
1531 int system_setting_set_locale_timeformat_24hour(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1535 vconf_value = (bool *)value;
1538 if (system_setting_vconf_set_value_int(VCONFKEY_REGIONFORMAT_TIME1224, VCONFKEY_TIME_FORMAT_24)) {
1539 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1543 if (system_setting_vconf_set_value_int(VCONFKEY_REGIONFORMAT_TIME1224, VCONFKEY_TIME_FORMAT_12)) {
1544 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1549 return SYSTEM_SETTINGS_ERROR_NONE;
1552 int system_setting_set_changed_callback_locale_timeformat_24hour(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1554 return system_setting_vconf_set_changed_cb(VCONFKEY_REGIONFORMAT_TIME1224, SYSTEM_SETTINGS_KEY_LOCALE_TIMEFORMAT_24HOUR, 3, user_data);
1557 int system_setting_unset_changed_callback_locale_timeformat_24hour(system_settings_key_e key)
1559 return system_setting_vconf_unset_changed_cb(VCONFKEY_REGIONFORMAT_TIME1224, 3);
1562 int system_setting_get_locale_timezone(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1565 ssize_t len = readlink(SETTING_TZONE_SYMLINK_PATH, tzpath, sizeof(tzpath) - 1);
1569 SETTING_TRACE("parse error for SETTING_TZONE_SYMLINK_PATH");
1570 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1573 /* "/usr/share/zoneinfo/Asia/Seoul" */
1574 SETTING_TRACE("tzpath : %s ", &tzpath[20]);
1575 *value = strdup(&tzpath[20]);
1576 return SYSTEM_SETTINGS_ERROR_NONE;
1579 int system_setting_set_changed_callback_locale_timezone_changed(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1581 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
1584 int system_setting_unset_changed_callback_locale_timezone_changed(system_settings_key_e key)
1586 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
1590 int system_setting_get_time_changed(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1593 cur_tick = time(NULL);
1594 *value = (void *)cur_tick;
1595 /* struct tm * localtime = time (cur_tick); */
1596 /* printf("%s\n", ctime(&cur_tick); */
1597 return SYSTEM_SETTINGS_ERROR_NONE;
1601 int system_setting_set_changed_callback_time_changed(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1603 return system_setting_vconf_set_changed_cb(VCONFKEY_SYSTEM_TIME_CHANGED, SYSTEM_SETTINGS_KEY_TIME_CHANGED, 3, user_data);
1606 int system_setting_unset_changed_callback_time_changed(system_settings_key_e key)
1608 return system_setting_vconf_unset_changed_cb(VCONFKEY_SYSTEM_TIME_CHANGED, 3);
1613 /* SYSTEM_SETTINGS_KEY_SOUND_LOCK */
1614 int system_setting_get_sound_lock(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1618 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_SOUND_LOCK_BOOL, &vconf_value)) {
1619 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1621 *value = (void *)vconf_value;
1623 return SYSTEM_SETTINGS_ERROR_NONE;
1626 int system_setting_set_changed_callback_sound_lock(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1628 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_SOUND_LOCK_BOOL, SYSTEM_SETTINGS_KEY_SOUND_LOCK, 3, user_data);
1631 int system_setting_unset_changed_callback_sound_lock(system_settings_key_e key)
1633 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_SOUND_LOCK_BOOL, 3);
1637 * a = VCONFKEY_SETAPPL_SOUND_STATUS_BOOL b = VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL
1639 * a == false, b == false --> silent mode
1640 * a == true, b == false --> sound mode
1641 * a == false, b == true --> vibration mode
1643 int system_setting_get_sound_silent_mode(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1649 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, &sound_cond)) {
1650 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1653 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, &vib_cond)) {
1654 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1657 if (sound_cond == false && vib_cond == false) {
1659 *value = (void *)vconf_value;
1661 vconf_value = false;
1662 *value = (void *)vconf_value;
1664 return SYSTEM_SETTINGS_ERROR_NONE;
1668 * a = VCONFKEY_SETAPPL_SOUND_STATUS_BOOL b = VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL
1670 * a == false, b == false --> silent mode
1671 * a == true, b == false --> sound mode
1673 int system_setting_set_sound_silent_mode(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1677 vconf_value = (bool *)value;
1679 bool vconf_sound = false;
1680 bool vconf_vib = false;
1683 vconf_sound = false;
1690 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, vconf_sound)) {
1691 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1693 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, vconf_vib)) {
1694 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1697 return SYSTEM_SETTINGS_ERROR_NONE;
1703 int system_setting_set_changed_callback_sound_silent_mode(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1705 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, SYSTEM_SETTINGS_KEY_SOUND_SILENT_MODE, 3, user_data);
1709 int system_setting_unset_changed_callback_sound_silent_mode(system_settings_key_e key)
1711 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, 3);
1714 /* SYSTEM_SETTINGS_KEY_SOUND_TOUCH */
1715 int system_setting_get_sound_touch(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1719 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL, &vconf_value)) {
1720 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1722 *value = (void *)vconf_value;
1725 int system_setting_set_changed_callback_sound_touch(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1727 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL, SYSTEM_SETTINGS_KEY_SOUND_TOUCH, 2, user_data);
1730 int system_setting_unset_changed_callback_sound_touch(system_settings_key_e key)
1732 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL, 2);
1736 /* SYSTEM_SETTINGS_KEY_SOUND_LOCK */
1737 int system_setting_get_sound_lock(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1741 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_SOUND_LOCK_BOOL, &vconf_value)) {
1742 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1744 *value = (void *)vconf_value;
1746 return SYSTEM_SETTINGS_ERROR_NONE;
1750 int system_setting_get_auto_rotation_mode(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1754 if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, &vconf_value)) {
1755 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1757 *value = (void *)vconf_value;
1759 return SYSTEM_SETTINGS_ERROR_NONE;
1762 int system_setting_set_auto_rotation_mode(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1765 vconf_value = (bool *)value;
1766 if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, *vconf_value)) {
1767 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1769 return SYSTEM_SETTINGS_ERROR_NONE;
1772 int system_setting_set_changed_callback_auto_rotation_mode(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1774 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, SYSTEM_SETTINGS_KEY_DISPLAY_SCREEN_ROTATION_AUTO, 2, user_data);
1777 int system_setting_unset_changed_callback_auto_rotation_mode(system_settings_key_e key)
1779 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, 2);
1782 int system_setting_get_screen_backlight_time(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1786 if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, &vconf_value)) {
1787 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1789 *value = (void *)vconf_value;
1791 return SYSTEM_SETTINGS_ERROR_NONE;
1795 int system_setting_set_screen_backlight_time(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1797 SETTING_TRACE_BEGIN;
1799 vconf_value = (int *)value;
1801 if (*vconf_value < 0 || *vconf_value > 600) {
1802 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
1805 if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, *vconf_value)) {
1806 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1809 return SYSTEM_SETTINGS_ERROR_NONE;
1812 int system_setting_set_changed_callback_screen_backlight_time(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1814 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, SYSTEM_SETTINGS_KEY_DISPLAY_SCREEN_ROTATION_AUTO, 2, user_data);
1817 int system_setting_unset_changed_callback_screen_backlight_time(system_settings_key_e key)
1819 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, 2);
1822 int system_setting_get_sound_notification(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1824 char *vconf_value = NULL;
1825 if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, &vconf_value)) {
1826 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1829 *value = vconf_value;
1830 return SYSTEM_SETTINGS_ERROR_NONE;
1833 int system_setting_set_sound_notification(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1835 char *vconf_value = NULL;
1836 vconf_value = (char *)value;
1838 int is_load = _is_file_accessible(vconf_value);
1840 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, vconf_value)) {
1841 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1844 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1847 return SYSTEM_SETTINGS_ERROR_NONE;
1850 int system_setting_set_changed_callback_sound_notification(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1852 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, SYSTEM_SETTINGS_KEY_INCOMING_CALL_RINGTONE, 0, user_data);
1855 int system_setting_unset_changed_callback_sound_notification(system_settings_key_e key)
1857 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, 0);
1860 int system_setting_get_notification_repetition_period(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1864 if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_NOTI_MSG_ALERT_REP_TYPE_INT, &vconf_value)) {
1865 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1867 *value = (void *)vconf_value;
1869 return SYSTEM_SETTINGS_ERROR_NONE;
1872 int system_setting_set_notification_repetition_period(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1874 SETTING_TRACE_BEGIN;
1876 vconf_value = (int *)value;
1878 if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_NOTI_MSG_ALERT_REP_TYPE_INT, *vconf_value)) {
1879 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1882 return SYSTEM_SETTINGS_ERROR_NONE;
1885 int system_setting_set_changed_callback_notification_repetition_period(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1887 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);
1890 int system_setting_unset_changed_callback_notification_repetition_period(system_settings_key_e key)
1892 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_ALERT_REP_TYPE_INT, 1);
1895 int system_setting_get_device_name(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1897 char *vconf_value = NULL;
1898 if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_DEVICE_NAME_STR, &vconf_value)) {
1899 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1902 *value = vconf_value;
1903 return SYSTEM_SETTINGS_ERROR_NONE;
1906 int system_setting_set_device_name(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1908 char *vconf_value = NULL;
1909 vconf_value = (char *)value;
1911 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_DEVICE_NAME_STR, vconf_value)) {
1912 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1915 return SYSTEM_SETTINGS_ERROR_NONE;
1918 int system_setting_set_changed_callback_device_name(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1920 return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_DEVICE_NAME_STR, SYSTEM_SETTINGS_KEY_DEVICE_NAME, 0, user_data);
1923 int system_setting_unset_changed_callback_device_name(system_settings_key_e key)
1925 return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_DEVICE_NAME_STR, 0);
1928 /*---------------------------------------------- */
1929 int system_setting_get_network_flight_mode(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1932 if (system_setting_vconf_get_value_bool(VCONFKEY_TELEPHONY_FLIGHT_MODE, &vconf_value)) {
1933 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1935 *value = (void *)vconf_value;
1937 return SYSTEM_SETTINGS_ERROR_NONE;
1940 int system_setting_set_changed_callback_network_flight_mode(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1942 return system_setting_vconf_set_changed_cb(VCONFKEY_TELEPHONY_FLIGHT_MODE, SYSTEM_SETTINGS_KEY_NETWORK_FLIGHT_MODE, 3, user_data);
1945 int system_setting_unset_changed_callback_network_flight_mode(system_settings_key_e key)
1947 return system_setting_vconf_unset_changed_cb(VCONFKEY_TELEPHONY_FLIGHT_MODE, 3);
1950 int system_setting_get_network_wifi_notification(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1953 if (system_setting_vconf_get_value_int(VCONFKEY_WIFI_ENABLE_QS, &vconf_value)) {
1954 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1957 bret = (vconf_value == VCONFKEY_WIFI_QS_ENABLE) ? true : false;
1959 *value = (void *)bret;
1960 return SYSTEM_SETTINGS_ERROR_NONE;
1963 int system_setting_set_changed_callback_network_wifi_notification(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1965 return system_setting_vconf_set_changed_cb(VCONFKEY_WIFI_ENABLE_QS, SYSTEM_SETTINGS_KEY_NETWORK_WIFI_NOTIFICATION, 4, user_data);
1968 int system_setting_unset_changed_callback_network_wifi_notification(system_settings_key_e key)
1970 return system_setting_vconf_unset_changed_cb(VCONFKEY_WIFI_ENABLE_QS, 4);