Merge "remove the unused deps" into tizen
[platform/core/api/system-settings.git] / src / system_setting_platform.c
1 /*
2  * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 #include <stdio.h>
18 #include <stdlib.h>
19 #include <unistd.h>
20 #include <errno.h>
21 #include <time.h>
22
23 #include <string.h>
24 #include <sys/types.h>
25 #include <sys/stat.h>
26 #include <fcntl.h>
27
28 #include <regex.h>
29
30 #include <dlog.h>
31 #include <vconf.h>
32
33 #include <glib.h>
34 #include <libxml/xmlmemory.h>
35 #include <libxml/parser.h>
36
37 #include <fontconfig/fontconfig.h>
38
39 //#include <pkgmgr-info.h>
40
41 #include <Elementary.h>
42 #include <Evas.h>
43 #include <Ecore_Evas.h>
44
45 #include <pkgmgr-info.h>
46
47 #include <system_settings.h>
48 #include <system_settings_private.h>
49
50 #include <tzplatform_config.h>
51
52 #ifdef USE_EFL_ASSIST
53 #include <efl_assist.h>
54 #endif
55
56 #ifdef TIZEN_WEARABLE
57 #define SMALL_FONT_DPI                      (-90)
58 #endif
59 #ifdef TIZEN_MOBILE
60 #define SMALL_FONT_DPI                      (-80)
61 #endif
62 #define MIDDLE_FONT_DPI                     (-100)
63 #ifdef TIZEN_WEARABLE
64 #define LARGE_FONT_DPI                      (-110)
65 #endif
66 #ifdef TIZEN_MOBILE
67 #define LARGE_FONT_DPI                      (-150)
68 #endif
69 #define HUGE_FONT_DPI                       (-190)
70 #define GIANT_FONT_DPI                      (-250)
71
72 #define SETTING_FONT_PRELOAD_FONT_PATH _TZ_SYS_RO_SHARE"/fonts"
73 #define SETTING_FONT_DOWNLOADED_FONT_PATH _TZ_SYS_RO_SHARE"/fonts"
74
75 #define SETTING_FONT_CONF_FILE _TZ_SYS_ETC"/fonts/conf.avail/99-tizen.conf"
76 #define SETTING_DEFAULT_FONT_CONF_FILE _TZ_SYS_ETC"/fonts/conf.avail/99-tizen.conf"
77
78 #define SETTING_STR_LEN  256
79
80 #define SETTING_TIME_ZONEINFO_PATH              "/usr/share/zoneinfo/"
81 #define SETTING_TIME_SHARE_LOCAL_PATH   "/usr/share/locale"
82 #define SETTING_TZONE_SYMLINK_PATH              "/etc/localtime"
83
84
85 static char *_get_cur_font();
86 static void __font_size_set();
87 static int __font_size_get();
88 static char *_get_default_font();
89
90 static bool font_config_set(char *font_name);
91 static void font_config_set_notification();
92 int _is_file_accessible(const char *path);
93 int __is_available_font(char *font_name);
94
95 /**
96  * VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR has a path of the ringtone file which user choose
97  * @return the ringtone file path specified by user in normal case
98  *         if it's not accessable, return the default ringtone path
99  */
100 int system_setting_get_incoming_call_ringtone(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
101 {
102         SETTING_TRACE_BEGIN;
103         char *vconf_value;
104         if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR, &vconf_value)) {
105                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
106         }
107
108         /* check to see if it's accessable -> OK */
109         /* no --> default ringtone path VCONFKEY_SETAPPL_CALL_RINGTONE_DEFAULT_PATH_STR */
110         int is_load = _is_file_accessible(vconf_value);
111         if (is_load == 0) {
112                 *value = vconf_value;
113         } else { /* not zero on errro */
114                 *value = vconf_get_str(VCONFKEY_SETAPPL_CALL_RINGTONE_DEFAULT_PATH_STR);
115         }
116
117         /**value = vconf_value; */
118         return SYSTEM_SETTINGS_ERROR_NONE;
119 }
120
121
122 int system_setting_get_email_alert_ringtone(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
123 {
124         SETTING_TRACE_BEGIN;
125         char *vconf_value;
126         if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, &vconf_value)) {
127                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
128         }
129
130         /* check to see if it's accessable -> OK */
131         /* no --> default ringtone path VCONFKEY_SETAPPL_NOTI_RINGTONE_DEFAULT_PATH_STR */
132         int is_load = _is_file_accessible(vconf_value);
133         if (is_load == 0) {
134                 *value = vconf_value;
135         } else { /* not zero on errro */
136                 *value = vconf_get_str(VCONFKEY_SETAPPL_NOTI_RINGTONE_DEFAULT_PATH_STR);
137         }
138
139         return SYSTEM_SETTINGS_ERROR_NONE;
140 }
141
142
143 int system_setting_get_wallpaper_home_screen(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
144 {
145         SETTING_TRACE_BEGIN;
146         char *vconf_value;
147         if (system_setting_vconf_get_value_string(VCONFKEY_BGSET, &vconf_value)) {
148                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
149         }
150         *value = vconf_value;
151         return SYSTEM_SETTINGS_ERROR_NONE;
152 }
153
154
155 int system_setting_get_wallpaper_lock_screen(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
156 {
157         SETTING_TRACE_BEGIN;
158         char *vconf_value;
159
160         if (system_setting_vconf_get_value_string(VCONFKEY_IDLE_LOCK_BGSET, &vconf_value)) {
161                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
162         }
163         *value = vconf_value;
164
165         return SYSTEM_SETTINGS_ERROR_NONE;
166 }
167
168
169 /* [int] vconf GET */
170 int system_setting_get_font_size(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
171 {
172         SETTING_TRACE_BEGIN;
173         int vconf_value;
174
175         if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, &vconf_value)) {
176                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
177         }
178         *value = (void *)vconf_value;
179
180         return SYSTEM_SETTINGS_ERROR_NONE;
181 }
182
183
184 int system_setting_get_default_font_type(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
185 {
186         SETTING_TRACE_BEGIN;
187         char *font_name = _get_default_font();
188         if (font_name) {
189                 *value = (void *)font_name;
190                 return SYSTEM_SETTINGS_ERROR_NONE;
191         } else {
192                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
193         }
194 }
195
196 /* [int] vconf GET */
197 int system_setting_get_font_type(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
198 {
199         SETTING_TRACE_BEGIN;
200         char *font_name = _get_cur_font();
201         *value = (void *)font_name;
202
203         return SYSTEM_SETTINGS_ERROR_NONE;
204 }
205
206
207 int system_setting_get_motion_activation(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
208 {
209         SETTING_TRACE_BEGIN;
210         bool vconf_value;
211
212         if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_MOTION_ACTIVATION, &vconf_value)) {
213                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
214         }
215         *value = (void *)vconf_value;
216
217         return SYSTEM_SETTINGS_ERROR_NONE;
218 }
219
220 int system_setting_get_usb_debugging_option(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
221 {
222         SETTING_TRACE_BEGIN;
223         bool vconf_value;
224
225         if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_USB_DEBUG_MODE_BOOL, &vconf_value)) {
226                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
227         }
228         *value = (void *)vconf_value;
229
230         return SYSTEM_SETTINGS_ERROR_NONE;
231 }
232
233 int system_setting_get_3g_data_network(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
234 {
235         SETTING_TRACE_BEGIN;
236         bool vconf_value;
237
238         if (system_setting_vconf_get_value_bool(VCONFKEY_3G_ENABLE, &vconf_value)) {
239                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
240         }
241         *value = (void *)vconf_value;
242
243         return SYSTEM_SETTINGS_ERROR_NONE;
244 }
245 /*////////////////////////////////////////////////////////////////////////////////////////////////// */
246
247
248 /**
249  * get current lock scren app package name (string)
250  *
251  * @return SYSTEM_SETTINGS_ERROR_LOCKSCREEN_APP_PASSWORD_MODE raise exception if current lock type is 'password'
252  */
253 int system_setting_get_lockscreen_app(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
254 {
255         SETTING_TRACE_BEGIN;
256         char *pkg_name = NULL;
257         int locktype = -1;
258         system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_SCREEN_LOCK_TYPE_INT, &locktype);
259
260         if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_3RD_LOCK_PKG_NAME_STR, &pkg_name)) {
261                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
262         }
263
264         if (pkg_name && strcmp(pkg_name, "com.samsung.lockscreen") == 0 && locktype == SETTING_SCREEN_LOCK_TYPE_PASSWORD) {
265                 return SYSTEM_SETTINGS_ERROR_LOCKSCREEN_APP_PASSWORD_MODE;
266         }
267
268         *value = pkg_name;
269         return SYSTEM_SETTINGS_ERROR_NONE;
270 }
271
272
273 /*////////////////////////////////////////////////////////////////////////////////////////////////// */
274
275 int _is_file_accessible(const char *path)
276 {
277         SETTING_TRACE_BEGIN;
278         int ret = access(path , R_OK);
279         if (ret == 0) {
280                 SETTING_TRACE("found the file  %s", path);
281                 return 0;
282         } else {
283                 // error code : 13
284                 SETTING_TRACE("found the file  %s --- error code : %d ", path, errno);
285                         return -errno;
286         }
287 }
288
289 int system_setting_set_incoming_call_ringtone(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
290 {
291         SETTING_TRACE_BEGIN;
292         char *vconf_value;
293         vconf_value = (char *)value;
294
295         int ret = _is_file_accessible(vconf_value);
296         if (ret == 0) {
297                 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR, vconf_value)) {
298                         return SYSTEM_SETTINGS_ERROR_IO_ERROR;
299                 }
300         } else {
301                 /* @todo add a common ret_handler */
302                 return ret;
303         }
304
305         return SYSTEM_SETTINGS_ERROR_NONE;
306 }
307
308
309 int system_setting_set_email_alert_ringtone(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
310 {
311         SETTING_TRACE_BEGIN;
312         char *vconf_value;
313         vconf_value = (char *)value;
314
315         int ret = _is_file_accessible(vconf_value);
316         if (ret == 0) {
317                 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, vconf_value)) {
318                         return SYSTEM_SETTINGS_ERROR_IO_ERROR;
319                 }
320         } else {
321                 /*return SYSTEM_SETTINGS_ERROR_IO_ERROR;*/
322                 /* @todo add a common ret_handler */
323                 return ret;
324         }
325
326         return SYSTEM_SETTINGS_ERROR_NONE;
327 }
328
329
330 bool __is_supported_image_type_load(char *path)
331 {
332         SETTING_TRACE_BEGIN;
333         //evas_init();
334         ecore_evas_init();
335         Ecore_Evas  *ee;
336         Evas        *evas;
337
338         ee = ecore_evas_new(NULL, 0, 0, 100, 100, NULL);
339         evas = ecore_evas_get(ee);
340
341         Evas_Object *img = evas_object_image_add(evas);
342         evas_object_image_file_set(img, path, NULL);
343         Evas_Load_Error ret = evas_object_image_load_error_get(img);
344
345         bool result = false;
346         if (ret == EVAS_LOAD_ERROR_NONE) {
347                 SETTING_TRACE("%s - OK", path);
348                 result = true;
349         } else {
350                 SETTING_TRACE("%s - NO", path);
351                 result = false;
352         }
353         ecore_evas_free(ee);
354         evas_shutdown();
355         return result;
356 }
357
358 bool __is_supported_image_type(char *path)
359 {
360         SETTING_TRACE_BEGIN;
361         bool ret = false;
362
363         evas_init();
364         if (evas_object_image_extension_can_load_get(path))
365                 ret = true;
366         else
367                 ret = false;
368
369         evas_shutdown();
370
371         return ret;
372 }
373
374 #define PATH_EXT_CHECK_REG ".(jpe?g|jpg|png|gif)$"
375 bool __is_supported_image_type_by_ext(char *file_path)
376 {
377         SETTING_TRACE_BEGIN;
378         regex_t fsm;
379         regmatch_t str[2048 + 1];
380
381         if (!file_path) return false;
382
383         int ret = false;
384         if ((ret = regcomp(&fsm, PATH_EXT_CHECK_REG, REG_ICASE | REG_EXTENDED))) {
385                 SETTING_TRACE("regular expresstion fail");
386                 return 1;
387         }
388
389         /* code */
390         if (regexec(&fsm, file_path, strlen(file_path) + 1, str, 0) == REG_NOMATCH) {
391                 /*SETTING_TRACE("FAILED - %s", file_path[i]); */
392                 ret = 0;
393         } else {
394                 /*SETTING_TRACE("MATCHED - %s", file_path[i]); */
395                 ret = 1;
396         }
397         return ret;
398 }
399 #ifdef TIZEN_WEARABLE
400 static int system_setting_get_extended_wallpaper_num(const char *file_path, unsigned int *num)
401 {
402         SETTING_TRACE_BEGIN;
403         char buffer[256];
404         const char *find_str = "extended_wallpaper_";
405         char *ch = NULL;
406
407         if (!(ch = strstr(file_path, find_str))) {
408                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
409         }
410         strncpy(buffer, file_path, ch - file_path);
411         buffer[ch - file_path] = 0;
412         sprintf(buffer + (ch - file_path), "%s%s", "", ch + strlen(find_str));
413
414         if (!isdigit(buffer[0])) {
415                 SETTING_TRACE("%s is not number", buffer);
416                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
417         }
418
419         *num = atoi(buffer);
420
421         return SYSTEM_SETTINGS_ERROR_NONE;
422 }
423
424 static int system_setting_copy_extended_wallpaper(const char *dest_file_path, const char *source_file_path)
425 {
426         SETTING_TRACE_BEGIN;
427         if (!source_file_path || !dest_file_path) {
428                 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
429         }
430
431         char buf[1024];
432
433         int fd;
434         fd = open(source_file_path, O_RDONLY);
435         if (fd < 0) {
436                 SETTING_TRACE("file open failed: %s", source_file_path);
437                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
438         }
439
440         int fd2;
441         fd2 = open(dest_file_path, O_WRONLY | O_CREAT, S_IRWXU | S_IRWXG | S_IRWXO);
442         if (fd2 < 0) {
443                 SETTING_TRACE("file creation failed: %s", dest_file_path);
444                 close(fd);
445                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
446         }
447
448         while (read(fd, buf, sizeof(buf) - 1) > 0) {
449                 write(fd2, buf, sizeof(buf) - 1);
450         }
451
452         close(fd2);
453         close(fd);
454
455         if (chmod(dest_file_path, S_IRWXU | S_IRWXG | S_IRWXO) < 0) {
456                 SETTING_TRACE("chmod failed: %s", dest_file_path);
457         }
458
459         return SYSTEM_SETTINGS_ERROR_NONE;
460 }
461
462 static int system_setting_remove_oldest_extended_wallpaper()
463 {
464         SETTING_TRACE_BEGIN;
465         DIR *dp;
466         struct dirent *dirp;
467         char *min_image_name = NULL;
468         unsigned int min_image_num = 0;
469         unsigned int temp_image_num = 0;
470         int image_count = 0;
471
472         if ((dp = opendir(_TZ_SYS_DATA"/setting/wallpaper")) == NULL) {
473                 SETTING_TRACE("opendir error");
474                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
475         }
476
477         while ((dirp = readdir(dp))) {
478                 if (!strcmp(dirp->d_name, ".") || !strcmp(dirp->d_name, ".."))
479                         continue;
480
481                 if (system_setting_get_extended_wallpaper_num(dirp->d_name, &temp_image_num)
482                     != SYSTEM_SETTINGS_ERROR_NONE) {
483                         return SYSTEM_SETTINGS_ERROR_IO_ERROR;
484                 }
485
486                 if ((image_count == 0) || (min_image_num > temp_image_num)) {
487                         min_image_num = temp_image_num;
488                         min_image_name = dirp->d_name;
489                 }
490
491                 image_count++;
492         }
493
494         char buf[512];
495         if (min_image_name) {
496                 snprintf(buf, sizeof(buf) - 1, _TZ_SYS_DATA"/setting/wallpaper/%s", min_image_name);
497                 if (remove(buf) < 0) {  /* remove oldest image */
498                         return SYSTEM_SETTINGS_ERROR_IO_ERROR;
499                 }
500         }
501
502         return SYSTEM_SETTINGS_ERROR_NONE;
503 }
504
505 static int system_setting_check_extended_wallpaper(const char *file_path)
506 {
507         char buffer[512];
508         SETTING_TRACE_BEGIN;
509         if (!file_path || !strlen(file_path))
510                 return 0;
511         snprintf(buffer, 512, "%s/.bgwallpaper", tzplatform_getenv(TZ_USER_CONTENT));
512         return (strstr(file_path, buffer) != NULL);
513 }
514
515 #define WALLPAPER_MAX_COUNT             10
516 #endif
517
518 int system_setting_set_wallpaper_home_screen(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
519 {
520         SETTING_TRACE_BEGIN;
521         char *vconf_value;
522         vconf_value = (char *)value;
523
524         bool isok  = __is_supported_image_type_load(vconf_value);
525         if (!isok) {
526                 /* not supported */
527                 SETTING_TRACE("path : %s is not supported file format", vconf_value);
528                 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
529         } else {
530                 SETTING_TRACE("path : %s is SUPPORT file format", vconf_value);
531         }
532
533         /* error handling here */
534         if (_is_file_accessible(vconf_value) != 0)
535                 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
536 #ifdef TIZEN_MOBILE
537         if (system_setting_vconf_set_value_string(VCONFKEY_BGSET, vconf_value)) {
538                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
539         }
540 #endif
541
542 #ifdef TIZEN_WEARABLE
543         if (system_setting_check_extended_wallpaper(vconf_value)) {     /* New extended wallpaper */
544                 DIR *dp = NULL;
545                 struct dirent *dirp;
546                 unsigned int max_image_num = 0;
547                 unsigned int temp_image_num = 0;
548                 int image_count = 0;
549
550                 if ((dp = opendir(_TZ_SYS_DATA"/setting/wallpaper")) == NULL) {
551                         SETTING_TRACE("Setting - dir open error!");
552                         return SYSTEM_SETTINGS_ERROR_IO_ERROR;
553                 }
554
555                 /* Check a max number of wallpapers */
556                 while ((dirp = readdir(dp))) {
557                         if (!strcmp(dirp->d_name, ".") || !strcmp(dirp->d_name, ".."))
558                                 continue;
559
560                         if (system_setting_get_extended_wallpaper_num(dirp->d_name, &temp_image_num)
561                             != SYSTEM_SETTINGS_ERROR_NONE) {
562                                 if(dp)
563                                         closedir(dp);
564                                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
565                         }
566
567                         if ((image_count == 0) || (max_image_num < temp_image_num)) {
568                                 max_image_num = temp_image_num;
569                         }
570
571                         image_count++;
572                 }
573                 if(dp)
574                         closedir(dp);
575
576                 /* Numbering rule: Gear is odd number */
577                 max_image_num = (max_image_num % 2 == 0) ? max_image_num + 1
578                                 : max_image_num + 2;
579
580                 char file_name_buffer[512];
581                 snprintf(file_name_buffer, sizeof(file_name_buffer) - 1,
582                          _TZ_SYS_DATA"/setting/wallpaper/extended_wallpaper_%d.jpg", max_image_num);
583
584                 /* Copy image to _TZ_SYS_DATA/setting/wallpaper/ */
585                 if (system_setting_copy_extended_wallpaper(file_name_buffer, vconf_value)
586                     != SYSTEM_SETTINGS_ERROR_NONE) {
587                         return SYSTEM_SETTINGS_ERROR_IO_ERROR;
588                 }
589
590                 /* remove oldest wallpaper */
591                 if (image_count >= WALLPAPER_MAX_COUNT) {
592                         if (system_setting_remove_oldest_extended_wallpaper()
593                             != SYSTEM_SETTINGS_ERROR_NONE) {
594                                 remove(file_name_buffer);
595                                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
596                         }
597                 }
598
599                 if (system_setting_vconf_set_value_string(VCONFKEY_BGSET, file_name_buffer)) {
600                         return SYSTEM_SETTINGS_ERROR_IO_ERROR;
601                 }
602
603                 if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_WALLPAPER_CHANGED_NOTI_INT,
604                                                        VCONFKEY_WALLPAPER_CHANGED_NOTI_GEAR)) {
605                         return SYSTEM_SETTINGS_ERROR_IO_ERROR;
606                 }
607         } else {
608                 if (system_setting_vconf_set_value_string(VCONFKEY_BGSET, vconf_value)) {
609                         return SYSTEM_SETTINGS_ERROR_IO_ERROR;
610                 }
611         }
612 #endif
613
614         return SYSTEM_SETTINGS_ERROR_NONE;
615 }
616
617 int system_setting_set_wallpaper_lock_screen(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
618 {
619         SETTING_TRACE_BEGIN;
620         char *vconf_value;
621         vconf_value = (char *)value;
622
623         bool isok  = __is_supported_image_type_load(vconf_value);
624         if (!isok) {
625                 /* not supported */
626                 SETTING_TRACE("path : %s is not supported file format", vconf_value);
627                 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
628         } else {
629                 SETTING_TRACE("path : %s is SUPPORT file format", vconf_value);
630         }
631
632         /* error handling here */
633         if (_is_file_accessible(vconf_value) != 0)
634                 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
635
636         if (system_setting_vconf_set_value_string(VCONFKEY_IDLE_LOCK_BGSET, vconf_value)) {
637                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
638         }
639
640         return SYSTEM_SETTINGS_ERROR_NONE;
641 }
642
643 int system_setting_set_font_size(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
644 {
645         SETTING_TRACE_BEGIN;
646         int *vconf_value;
647         vconf_value = (int *)value;
648
649         if (*vconf_value < 0 || *vconf_value > SYSTEM_SETTINGS_FONT_SIZE_GIANT) {
650                 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
651         }
652
653         if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, *vconf_value)) {
654                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
655         }
656         __font_size_set();
657         SETTING_TRACE_END;
658         return SYSTEM_SETTINGS_ERROR_NONE;
659 }
660 /**
661  * [internal API]
662  */
663 void *font_conf_doc_parse(char *doc_name, char *font_name)
664 {
665         SETTING_TRACE_BEGIN;
666         xmlDocPtr doc = NULL;
667         xmlNodePtr cur = NULL;
668         xmlNodePtr cur2 = NULL;
669         xmlNodePtr cur3 = NULL;
670         xmlChar *key = NULL;
671
672         doc = xmlParseFile(doc_name);
673
674         cur = xmlDocGetRootElement(doc);
675
676         if (cur == NULL) {
677                 xmlFreeDoc(doc);
678                 doc = NULL;
679                 return NULL;
680         }
681
682         if (xmlStrcmp(cur->name, (const xmlChar *)"fontconfig")) {
683                 xmlFreeDoc(doc);
684                 doc = NULL;
685                 return NULL;
686         }
687
688         cur = cur->xmlChildrenNode;
689
690         Eina_Bool is_changed = EINA_FALSE;
691         while (cur != NULL) {
692                 if ((!xmlStrcmp(cur->name, (const xmlChar *)"match"))) {
693                         cur2 = cur->xmlChildrenNode;
694                         while (cur2 != NULL) {
695                                 if ((!xmlStrcmp(cur2->name, (const xmlChar *)"edit"))) {
696                                         xmlChar *name = xmlGetProp(cur2, (const xmlChar *)"name");
697                                         /* if name is not 'family', break */
698                                         if (xmlStrcmp(name, (const xmlChar *)"family")) {
699                                                 xmlFree(name);
700                                                 name = NULL;
701                                                 break;
702                                         }
703                                         xmlFree(name);
704                                         name = NULL;
705
706                                         cur3 = cur2->xmlChildrenNode;
707                                         while (cur3 != NULL) {
708                                                 if ((!xmlStrcmp(cur3->name, (const xmlChar *)"string"))) {
709                                                         xmlNodeSetContent(cur3->xmlChildrenNode, (const xmlChar *)font_name);
710                                                         key = xmlNodeListGetString(doc, cur3->xmlChildrenNode, 1);
711                                                         xmlFree(key);
712                                                         key = NULL;
713                                                         is_changed = EINA_TRUE;
714                                                 }
715                                                 cur3 = cur3->next;
716                                         }
717                                 }
718                                 cur2 = cur2->next;
719                         }
720                 } else if ((!xmlStrcmp(cur->name, (const xmlChar *)"alias"))) {
721                         cur2 = cur->xmlChildrenNode;
722                         while (cur2 != NULL) {
723                                 if ((!xmlStrcmp(cur2->name, (const xmlChar *)"family"))) {
724                                         xmlNodeSetContent(cur2->xmlChildrenNode, (const xmlChar *)font_name);
725                                         key = xmlNodeListGetString(doc, cur2->xmlChildrenNode, 1);
726                                         xmlFree(key);
727                                         key = NULL;
728                                         is_changed = EINA_TRUE;
729                                 } else if ((!xmlStrcmp(cur2->name, (const xmlChar *)"prefer"))) {
730                                         cur3 = cur2->xmlChildrenNode;
731                                         while (cur3 != NULL) {
732                                                 if ((!xmlStrcmp(cur3->name, (const xmlChar *)"family"))) {
733                                                         xmlNodeSetContent(cur3->xmlChildrenNode, (const xmlChar *)font_name);
734                                                         key = xmlNodeListGetString(doc, cur3->xmlChildrenNode, 1);
735                                                         xmlFree(key);
736                                                         key = NULL;
737                                                         is_changed = EINA_TRUE;
738                                                         cur3 = cur3->next;
739                                                         return doc;
740                                                 }
741                                                 cur3 = cur3->next;
742                                         }
743                                 }
744                                 cur2 = cur2->next;
745                         }
746                 }
747                 cur = cur->next;
748         }
749
750         if (is_changed) {
751                 return doc;
752         } else {
753                 xmlFreeDoc(doc);
754                 doc = NULL;
755                 return NULL;
756         }
757 }
758
759 int system_setting_set_font_type(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
760 {
761         SETTING_TRACE_BEGIN;
762         char *font_name = NULL;
763         font_name = (char *)value;
764
765         /* get current font list */
766         int is_found = __is_available_font(font_name);
767
768         if (is_found) {
769                 SETTING_TRACE("found font : %s ", font_name);
770         } else {
771                 SETTING_TRACE(" NOT found font : %s ", font_name);
772                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
773         }
774
775         bool bsave = font_config_set(font_name);
776
777         if (!bsave) {
778                 SETTING_TRACE(" font type save error by font_config_set() ");
779                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
780         } else {
781                 SETTING_TRACE(" save OK - font_config_set() ");
782         }
783
784         xmlDocPtr doc = (xmlDocPtr)font_conf_doc_parse(SETTING_FONT_CONF_FILE, font_name);
785         if (doc != NULL) {
786                 xmlSaveFormatFile(SETTING_FONT_CONF_FILE, doc, 0);
787                 xmlFreeDoc(doc);
788                 doc = NULL;
789         }
790
791         font_config_set_notification();
792
793         char *vconf_value;
794         vconf_value = (char *)value;
795
796         if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, vconf_value)) {
797                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
798         }
799         return SYSTEM_SETTINGS_ERROR_NONE;
800 }
801
802 int system_setting_set_motion_activation(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
803 {
804         SETTING_TRACE_BEGIN;
805         bool *vconf_value;
806         vconf_value = (bool *)value;
807         if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_MOTION_ACTIVATION, *vconf_value)) {
808                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
809         }
810         return SYSTEM_SETTINGS_ERROR_NONE;
811 }
812
813 int system_setting_set_usb_debugging_option(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
814 {
815         SETTING_TRACE_BEGIN;
816         bool *vconf_value;
817         vconf_value = (bool *)value;
818         if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_USB_DEBUG_MODE_BOOL, *vconf_value)) {
819                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
820         }
821         return SYSTEM_SETTINGS_ERROR_NONE;
822
823 }
824
825 int system_setting_set_3g_data_network(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
826 {
827         SETTING_TRACE_BEGIN;
828         bool *vconf_value;
829         vconf_value = (bool *)value;
830         if (system_setting_vconf_set_value_bool(VCONFKEY_3G_ENABLE, *vconf_value)) {
831                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
832         }
833
834         return SYSTEM_SETTINGS_ERROR_NONE;
835 }
836
837 static int category_func(const char *name, void *user_data)
838 {
839         SETTING_TRACE_BEGIN;
840         static char *category = "lock-screen";
841         if (name && !strcmp(name, category)) {
842                 SETTING_TRACE(" SAME ");
843                 return -1;
844         } else {
845                 SETTING_TRACE(" DIFFERENT -- %s, category -- %s ", name, category);
846                 return 0;
847         }
848
849         return 0;
850 }
851
852 /**
853  *
854  * set 'swipe type' if current lockscreen app is 'com.samsung.lockscreen'
855  *
856  */
857 int system_setting_set_lockscreen_app(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
858 {
859         SETTING_TRACE_BEGIN;
860         char *vconf_value;
861         vconf_value = (char *)value;            /* ex) com.samsung.lockscreen */
862
863         int r = 0;
864         pkgmgrinfo_appinfo_h handle;
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;
869         } else {
870                 SETTING_TRACE("%x", handle);
871         }
872
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;
877         }
878
879         pkgmgrinfo_appinfo_destroy_appinfo(handle);
880         /*----------------------------------------------------------------------------------- */
881         int locktype = -1;
882         if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_SCREEN_LOCK_TYPE_INT, &locktype)) {
883                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
884         }
885
886         if (locktype == SETTING_SCREEN_LOCK_TYPE_PASSWORD)
887                 return SYSTEM_SETTINGS_ERROR_LOCKSCREEN_APP_PASSWORD_MODE;
888
889         if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_3RD_LOCK_PKG_NAME_STR, vconf_value)) {
890                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
891         }
892
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;
896                 }
897         }
898         return SYSTEM_SETTINGS_ERROR_NONE;
899 }
900
901 /*/////////////////////////////////////////////////////////////////////////////////////////////// */
902 /* */
903
904 int system_setting_set_changed_callback_incoming_call_ringtone(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
905 {
906         SETTING_TRACE_BEGIN;
907         return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR, SYSTEM_SETTINGS_KEY_INCOMING_CALL_RINGTONE, 0, user_data);
908 }
909
910 int system_setting_unset_changed_callback_incoming_call_ringtone(system_settings_key_e key)
911 {
912         SETTING_TRACE_BEGIN;
913         return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR, 0);
914 }
915
916 int system_setting_set_changed_callback_email_alert_ringtone(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
917 {
918         SETTING_TRACE_BEGIN;
919         return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, SYSTEM_SETTINGS_KEY_EMAIL_ALERT_RINGTONE, 0, user_data);
920 }
921
922 int system_setting_unset_changed_callback_email_alert_ringtone(system_settings_key_e key)
923 {
924         SETTING_TRACE_BEGIN;
925         return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, 0);
926 }
927
928 int system_setting_set_changed_callback_wallpaper_home_screen(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
929 {
930         SETTING_TRACE_BEGIN;
931         return system_setting_vconf_set_changed_cb(VCONFKEY_BGSET, SYSTEM_SETTINGS_KEY_WALLPAPER_HOME_SCREEN, 0, user_data);
932 }
933
934 int system_setting_unset_changed_callback_wallpaper_home_screen(system_settings_key_e key)
935 {
936         SETTING_TRACE_BEGIN;
937         return system_setting_vconf_unset_changed_cb(VCONFKEY_BGSET, 0);
938 }
939
940 int system_setting_set_changed_callback_wallpaper_lock_screen(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
941 {
942         SETTING_TRACE_BEGIN;
943         return system_setting_vconf_set_changed_cb(VCONFKEY_IDLE_LOCK_BGSET, SYSTEM_SETTINGS_KEY_WALLPAPER_LOCK_SCREEN, 0, user_data);
944 }
945
946 int system_setting_unset_changed_callback_wallpaper_lock_screen(system_settings_key_e key)
947 {
948         SETTING_TRACE_BEGIN;
949         return system_setting_vconf_unset_changed_cb(VCONFKEY_IDLE_LOCK_BGSET, 0);
950 }
951
952 int system_setting_set_changed_callback_font_size(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
953 {
954         SETTING_TRACE_BEGIN;
955         return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, SYSTEM_SETTINGS_KEY_FONT_SIZE, 1, user_data);
956 }
957
958 int system_setting_unset_changed_callback_font_size(system_settings_key_e key)
959 {
960         SETTING_TRACE_BEGIN;
961         return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, 1);
962 }
963
964 int system_setting_set_changed_callback_usb_debugging_option(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
965 {
966         SETTING_TRACE_BEGIN;
967         return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_USB_DEBUG_MODE_BOOL, SYSTEM_SETTINGS_KEY_USB_DEBUGGING_ENABLED, 1, user_data);
968 }
969
970 int system_setting_unset_changed_callback_usb_debugging_option(system_settings_key_e key)
971 {
972         SETTING_TRACE_BEGIN;
973         return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_USB_DEBUG_MODE_BOOL, 1);
974 }
975
976 int system_setting_set_changed_callback_3g_data_network(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
977 {
978         SETTING_TRACE_BEGIN;
979         return system_setting_vconf_set_changed_cb(VCONFKEY_3G_ENABLE, SYSTEM_SETTINGS_KEY_3G_DATA_NETWORK_ENABLED, 1, user_data);
980 }
981
982 int system_setting_unset_changed_callback_3g_data_network(system_settings_key_e key)
983 {
984         SETTING_TRACE_BEGIN;
985         return system_setting_vconf_unset_changed_cb(VCONFKEY_3G_ENABLE, 1);
986 }
987
988 int system_setting_set_changed_callback_lockscreen_app(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
989 {
990         SETTING_TRACE_BEGIN;
991         return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_3RD_LOCK_PKG_NAME_STR, SYSTEM_SETTINGS_KEY_LOCKSCREEN_APP, 1, user_data);
992 }
993
994 int system_setting_unset_changed_callback_lockscreen_app(system_settings_key_e key)
995 {
996         SETTING_TRACE_BEGIN;
997         return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_3RD_LOCK_PKG_NAME_STR, 1);
998 }
999
1000
1001 /**
1002  * @todo need to add custom event notification method
1003  */
1004 int system_setting_set_changed_callback_font_type(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1005 {
1006         SETTING_TRACE_BEGIN;
1007         return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, SYSTEM_SETTINGS_KEY_FONT_TYPE, 2, user_data);
1008 }
1009
1010 int system_setting_unset_changed_callback_font_type(system_settings_key_e key)
1011 {
1012         SETTING_TRACE_BEGIN;
1013         return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, 2);
1014 }
1015
1016 /* TODO : 2th argument, callback, is not in use. */
1017 int system_setting_set_changed_callback_motion_activation(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1018 {
1019         SETTING_TRACE_BEGIN;
1020         return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_MOTION_ACTIVATION, SYSTEM_SETTINGS_KEY_MOTION_ACTIVATION, 3, user_data);
1021 }
1022
1023 int system_setting_unset_changed_callback_motion_activation(system_settings_key_e key)
1024 {
1025         SETTING_TRACE_BEGIN;
1026         return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_MOTION_ACTIVATION, 3);
1027 }
1028
1029 static char *_get_cur_font()
1030 {
1031         SETTING_TRACE_BEGIN;
1032         xmlDocPtr doc = NULL;
1033         xmlNodePtr cur = NULL;
1034         xmlNodePtr cur2 = NULL;
1035         xmlNodePtr cur3 = NULL;
1036         xmlChar *key = NULL;
1037
1038         char *font_name = NULL;
1039
1040         doc = xmlParseFile(SETTING_FONT_CONF_FILE);
1041
1042         cur = xmlDocGetRootElement(doc);
1043
1044         if (cur == NULL) {
1045                 xmlFreeDoc(doc);
1046                 doc = NULL;
1047                 return NULL;
1048         }
1049
1050         if (xmlStrcmp(cur->name, (const xmlChar *)"fontconfig")) {
1051                 xmlFreeDoc(doc);
1052                 doc = NULL;
1053                 return NULL;
1054         }
1055
1056         cur = cur->xmlChildrenNode;
1057
1058         while (cur != NULL) {
1059                 if ((!xmlStrcmp(cur->name, (const xmlChar *)"match"))) {
1060                         cur2 = cur->xmlChildrenNode;
1061                         while (cur2 != NULL) {
1062                                 if ((!xmlStrcmp(cur2->name, (const xmlChar *)"edit"))) {
1063                                         cur3 = cur2->xmlChildrenNode;
1064                                         while (cur3 != NULL) {
1065                                                 if ((!xmlStrcmp(cur3->name, (const xmlChar *)"string"))) {
1066                                                         key = xmlNodeListGetString(doc, cur3->xmlChildrenNode, 1);
1067
1068                                                         font_name = g_strdup((char *)key);
1069                                                         xmlFree(key);
1070                                                         key = NULL;
1071                                                         xmlFreeDoc(doc);
1072                                                         doc = NULL;
1073                                                         return font_name;
1074                                                 }
1075                                                 cur3 = cur3->next;
1076                                         }
1077                                 }
1078                                 cur2 = cur2->next;
1079                         }
1080                 }
1081                 cur = cur->next;
1082         }
1083
1084         xmlFreeDoc(doc);
1085         doc = NULL;
1086         return NULL;
1087 }
1088
1089 static void font_config_set_notification()
1090 {
1091         SETTING_TRACE_BEGIN;
1092 #if 0
1093         /* notification */
1094         Ecore_X_Window ecore_win = ecore_x_window_root_first_get();
1095         Ecore_X_Atom atom = ecore_x_atom_get("FONT_TYPE_change");
1096         ecore_x_window_prop_string_set(ecore_win, atom, "tizen");
1097 #endif
1098 }
1099
1100 int __is_available_font(char *font_name)
1101 {
1102         SETTING_TRACE_BEGIN;
1103         FcObjectSet *os = NULL;
1104         FcFontSet *fs = NULL;
1105         FcPattern *pat = NULL;
1106         FcConfig *font_config = NULL;
1107
1108         int ret = 0;
1109
1110         if (font_name == NULL)
1111                 return -1;
1112
1113         font_config = FcInitLoadConfigAndFonts();
1114
1115         /*setting_retvm_if(font_config == NULL, NULL, "Failed: FcInitLoadConfigAndFonts"); */
1116
1117         char *locale = setlocale(0, NULL);
1118
1119         pat = FcPatternCreate();
1120
1121         os = FcObjectSetBuild(FC_FAMILY, FC_FILE, FC_FAMILYLANG, (char *) 0);
1122
1123         if (os) {
1124                 fs = FcFontList(font_config, pat, os);
1125                 FcObjectSetDestroy(os);
1126                 os = NULL;
1127         }
1128
1129         if (pat) {
1130                 FcPatternDestroy(pat);
1131                 pat = NULL;
1132         }
1133
1134         if (fs) {
1135                 int j;
1136                 SETTING_TRACE("fs->nfont = %d", fs->nfont);
1137
1138                 for (j = 0; j < fs->nfont; j++) {
1139                         FcChar8 *family = NULL;
1140                         FcChar8 *file = NULL;
1141
1142                         if (FcPatternGetString(fs->fonts[j], FC_FILE, 0, &file) == FcResultMatch) {
1143                                 int preload_path_len = strlen(SETTING_FONT_PRELOAD_FONT_PATH);
1144                                 int download_path_len = strlen(SETTING_FONT_DOWNLOADED_FONT_PATH);
1145
1146                                 if (file && (!strncmp((const char *)file, SETTING_FONT_PRELOAD_FONT_PATH, preload_path_len)
1147                                              || !strncmp((const char *)file, SETTING_FONT_DOWNLOADED_FONT_PATH, download_path_len))) {
1148                                         char *family_result = NULL;
1149                                         FcChar8 *lang = NULL;
1150                                         int id = 0;
1151                                         if (FcPatternGetString(fs->fonts[j], FC_FAMILY, id, &family) != FcResultMatch) {
1152                                                 break;
1153                                         }
1154                                         if (FcPatternGetString(fs->fonts[j], FC_FAMILYLANG, id, &lang) != FcResultMatch) {
1155                                                 break;
1156                                         }
1157                                         family_result = (char *)family;
1158
1159                                         /* Find proper family name for current locale. */
1160                                         while (locale && family && lang) {
1161                                                 if (!strncmp(locale, (char *)lang, strlen((char *)lang))) {
1162                                                         family_result = (char *)family;
1163                                                         break;
1164                                                 }
1165
1166                                                 /* I will set english as default family language. */
1167                                                 /* If there is no proper family language for current locale, */
1168                                                 /* we have to show the english family name. */
1169                                                 if (!strcmp((char*)lang, "en")) {
1170                                                         family_result = (char *)family;
1171                                                 }
1172                                                 id++;
1173                                                 if (FcPatternGetString(fs->fonts[j], FC_FAMILY, id, &family) != FcResultMatch) {
1174                                                         break;
1175                                                 }
1176                                                 if (FcPatternGetString(fs->fonts[j], FC_FAMILYLANG, id, &lang) != FcResultMatch) {
1177                                                         break;
1178                                                 }
1179                                         }
1180
1181                                         if (family_result) {
1182                                                 SETTING_TRACE("-------- FONT - family_result = %s", (char *)family_result);
1183                                                 if (strcmp(family_result, font_name) == 0) {
1184                                                         ret = 1;
1185                                                         break;
1186                                                 }
1187                                         }
1188                                 }
1189                         }
1190                 }
1191                 FcFontSetDestroy(fs);
1192                 fs = NULL;
1193         }
1194         FcConfigDestroy(font_config);
1195         font_config = NULL;
1196         return ret;
1197 }
1198
1199
1200 static char *_get_default_font()
1201 {
1202         SETTING_TRACE_BEGIN;
1203         xmlDocPtr doc = NULL;
1204         xmlNodePtr cur = NULL;
1205         xmlNodePtr cur2 = NULL;
1206         xmlNodePtr cur3 = NULL;
1207         xmlChar *key = NULL;
1208         struct _xmlAttr *properties = NULL;
1209         char *default_font_name = NULL;
1210
1211         doc = xmlParseFile(SETTING_DEFAULT_FONT_CONF_FILE);
1212
1213         cur = xmlDocGetRootElement(doc);
1214
1215         if (cur == NULL) {
1216                 xmlFreeDoc(doc);
1217                 doc = NULL;
1218                 return NULL;
1219         }
1220
1221         if (xmlStrcmp(cur->name, (const xmlChar *)"fontconfig")) {
1222                 xmlFreeDoc(doc);
1223                 doc = NULL;
1224                 return NULL;
1225         }
1226
1227         cur = cur->xmlChildrenNode;
1228
1229         while (cur != NULL) {
1230                 if ((!xmlStrcmp(cur->name, (const xmlChar *)"match"))) {
1231                         cur2 = cur->xmlChildrenNode;
1232                         while (cur2 != NULL) {
1233                                 if ((!xmlStrcmp(cur2->name, (const xmlChar *)"edit"))) {
1234                                         properties = cur2->properties;
1235                                         /*find the "name" property*/
1236                                         while (NULL != properties) {
1237                                                 if (!xmlStrcmp(properties->name, (const xmlChar *)"name")) {
1238                                                         break;
1239                                                 }
1240                                                 properties = properties->next;
1241                                         }
1242
1243                                         /*If the value of "name" property is "family", then get the child node string,
1244                                         it shall be the default font type*/
1245                                         if (NULL != properties && !xmlStrcmp(properties->children->content, (const xmlChar *)"family")) {
1246                                                 cur3 = cur2->xmlChildrenNode;
1247                                                 while (cur3 != NULL) {
1248                                                         if ((!xmlStrcmp(cur3->name, (const xmlChar *)"string"))) {
1249                                                                 key = xmlNodeListGetString(doc, cur3->xmlChildrenNode, 1);
1250                                                                 default_font_name = g_strdup((char *)key);
1251                                                                 xmlFree(key);
1252                                                                 key = NULL;
1253                                                                 xmlFreeDoc(doc);
1254                                                                 doc = NULL;
1255                                                                 return default_font_name;
1256                                                         }
1257                                                         cur3 = cur3->next;
1258                                                 }
1259                                         }
1260                                 }
1261                                 cur2 = cur2->next;
1262                         }
1263                 }
1264                 cur = cur->next;
1265         }
1266
1267         xmlFreeDoc(doc);
1268         doc = NULL;
1269         return NULL;
1270 }
1271
1272 static bool font_config_set(char *font_name)
1273 {
1274         SETTING_TRACE_BEGIN;
1275         Eina_List *text_classes = NULL;
1276         Elm_Text_Class *etc = NULL;
1277         const Eina_List *l = NULL;
1278         Eina_List *fo_list = NULL;
1279         Elm_Font_Overlay *efo = NULL;
1280
1281         int font_size = __font_size_get();
1282         int size = 0;
1283
1284         text_classes = elm_config_text_classes_list_get();
1285
1286         fo_list = (Eina_List *)elm_config_font_overlay_list_get();
1287
1288         Eina_List *ll = NULL;
1289         Eina_List *l_next = NULL;
1290
1291         Eina_Bool slp_medium_exist = EINA_FALSE;
1292         Eina_Bool slp_roman_exist = EINA_FALSE;
1293         Eina_Bool slp_bold_exist = EINA_FALSE;
1294         Eina_Bool slp_regular_exist = EINA_FALSE;
1295
1296         /* Tizen */
1297         Eina_Bool tizen_exist = EINA_FALSE;
1298
1299         EINA_LIST_FOREACH_SAFE(fo_list, ll, l_next, efo) {
1300                 if (!strcmp(efo->text_class, "tizen_medium")) {
1301                         elm_config_font_overlay_set(efo->text_class, (const char *)font_name, efo->size);
1302                         slp_medium_exist = EINA_TRUE;
1303                 } else if (!strcmp(efo->text_class, "tizen_roman")) {
1304                         elm_config_font_overlay_set(efo->text_class, (const char *)font_name, efo->size);
1305                         slp_roman_exist = EINA_TRUE;
1306                 } else if (!strcmp(efo->text_class, "tizen_bold")) {
1307                         elm_config_font_overlay_set(efo->text_class, (const char *)font_name, efo->size);
1308                         slp_bold_exist = EINA_TRUE;
1309                 } else if (!strcmp(efo->text_class, "tizen_regular")) {
1310                         elm_config_font_overlay_set(efo->text_class, (const char *)font_name, efo->size);
1311                         slp_regular_exist = EINA_TRUE;
1312                 }
1313
1314                 /* Tizen */
1315                 if (!strcmp(efo->text_class, "tizen")) {
1316                         elm_config_font_overlay_set(efo->text_class, (const char *)font_name, efo->size);
1317                         tizen_exist = EINA_TRUE;
1318                 }
1319
1320         }
1321
1322         /* if slp_XX do not exist, need to set them, font size is -100(100%) */
1323         if (slp_medium_exist == EINA_FALSE) {
1324                 elm_config_font_overlay_set("tizen_medium", (const char *)font_name,  MIDDLE_FONT_DPI);
1325         }
1326         if (slp_roman_exist == EINA_FALSE) {
1327                 elm_config_font_overlay_set("tizen_roman", (const char *)font_name,  MIDDLE_FONT_DPI);
1328         }
1329         if (slp_bold_exist == EINA_FALSE) {
1330                 elm_config_font_overlay_set("tizen_bold", (const char *)font_name,  MIDDLE_FONT_DPI);
1331         }
1332         if (slp_regular_exist == EINA_FALSE) {
1333                 elm_config_font_overlay_set("tizen_regular", (const char *)font_name,  MIDDLE_FONT_DPI);
1334         }
1335
1336         /* Tizen */
1337         if (tizen_exist == EINA_FALSE) {
1338                 elm_config_font_overlay_set("tizen", (const char *)font_name,  MIDDLE_FONT_DPI);
1339         }
1340
1341         elm_config_font_overlay_set("tizen", (const char *)font_name,  MIDDLE_FONT_DPI);
1342
1343         /* Tizen */
1344         elm_config_font_overlay_set("tizen", (const char *)font_name,  MIDDLE_FONT_DPI);
1345
1346         EINA_LIST_FOREACH(text_classes, l, etc) {
1347                 ll = NULL;
1348
1349                 size = font_size;
1350                 EINA_LIST_FOREACH(fo_list, ll, efo) {
1351                         if (!strcmp(etc->name, efo->text_class)) {
1352                                 size = efo->size;
1353                         }
1354                 }
1355                 elm_config_font_overlay_set(etc->name, (const char *)font_name, size);
1356         }
1357         elm_config_text_classes_list_free(text_classes);
1358         text_classes = NULL;
1359
1360         /* add new function */
1361 #ifdef USE_EFL_ASSIST
1362         ea_theme_system_font_set(font_name, font_size);
1363         ea_theme_system_fonts_apply();
1364 #endif
1365
1366         elm_config_font_overlay_apply();
1367         elm_config_all_flush();
1368         elm_config_save();
1369         return 1;
1370 }
1371
1372 static void __font_size_set()
1373 {
1374         SETTING_TRACE_BEGIN;
1375         Eina_List *text_classes = NULL;
1376         Elm_Text_Class *etc = NULL;
1377         const Eina_List *l = NULL;
1378         int font_size = __font_size_get();
1379         char *font_name = _get_cur_font();
1380
1381         if (font_size == -1) {
1382                 return;
1383         }
1384
1385         text_classes = elm_config_text_classes_list_get();
1386
1387         EINA_LIST_FOREACH(text_classes, l, etc) {
1388                 elm_config_font_overlay_set(etc->name, font_name, font_size);
1389         }
1390
1391         elm_config_text_classes_list_free(text_classes);
1392
1393 #ifdef USE_EFL_ASSIST
1394         ea_theme_system_font_set(font_name, font_size);
1395         ea_theme_system_fonts_apply();
1396 #endif
1397
1398         elm_config_font_overlay_apply();
1399         elm_config_all_flush();
1400         elm_config_save();
1401
1402         text_classes = NULL;
1403         g_free(font_name);
1404 }
1405
1406 static int __font_size_get()
1407 {
1408         SETTING_TRACE_BEGIN;
1409         int font_size = -1;
1410
1411         int vconf_value = -1;
1412         if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, &vconf_value)) {
1413                 return -1;
1414         }
1415
1416         switch (vconf_value) {
1417                 case SYSTEM_SETTINGS_FONT_SIZE_SMALL:
1418                         font_size = SMALL_FONT_DPI;
1419                         break;
1420                 case SYSTEM_SETTINGS_FONT_SIZE_NORMAL:
1421                         font_size = MIDDLE_FONT_DPI;
1422                         break;
1423                 case SYSTEM_SETTINGS_FONT_SIZE_LARGE:
1424                         font_size = LARGE_FONT_DPI;
1425                         break;
1426                 case SYSTEM_SETTINGS_FONT_SIZE_HUGE:
1427                         font_size = HUGE_FONT_DPI;
1428                         break;
1429                 case SYSTEM_SETTINGS_FONT_SIZE_GIANT:
1430                         font_size = GIANT_FONT_DPI;
1431                         break;
1432                 default:
1433                         font_size = MIDDLE_FONT_DPI;
1434                         break;
1435         }
1436         return font_size;
1437 }
1438
1439 /*//////////////////////////////////////////////////////////////////////////////////////// */
1440 /*--------------------------------------- */
1441 int system_setting_get_locale_country(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1442 {
1443         SETTING_TRACE_BEGIN;
1444         char *vconf_value = NULL;
1445         if (system_setting_vconf_get_value_string(VCONFKEY_REGIONFORMAT, &vconf_value)) {
1446                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1447         }
1448
1449         /* parsing validation */
1450         /* en_US.UTF-8 */
1451         char arr[20];
1452         snprintf(arr, 20, "%s", vconf_value);
1453         arr[5] = '\0';
1454         *value = strdup(arr);
1455         free(vconf_value);
1456         vconf_value = NULL;
1457
1458         return SYSTEM_SETTINGS_ERROR_NONE;
1459 }
1460
1461 int system_setting_set_locale_country(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1462 {
1463         SETTING_TRACE_BEGIN;
1464         char *vconf_value = NULL;
1465         vconf_value = (char *)value;
1466
1467         char *ext = "UTF-8";
1468
1469         char arr[20];
1470         snprintf(arr, 20, "%s.%s", vconf_value, ext);
1471
1472         if (system_setting_vconf_set_value_string(VCONFKEY_REGIONFORMAT, arr)) {
1473                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1474         }
1475         return SYSTEM_SETTINGS_ERROR_NONE;
1476 }
1477
1478 int system_setting_set_changed_callback_locale_country(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1479 {
1480         SETTING_TRACE_BEGIN;
1481         return system_setting_vconf_set_changed_cb(VCONFKEY_REGIONFORMAT, SYSTEM_SETTINGS_KEY_LOCALE_COUNTRY, 3, user_data);
1482 }
1483
1484 int system_setting_unset_changed_callback_locale_country(system_settings_key_e key)
1485 {
1486         SETTING_TRACE_BEGIN;
1487         return system_setting_vconf_unset_changed_cb(VCONFKEY_REGIONFORMAT, 3);
1488 }
1489
1490
1491 /*--------------------------------------- */
1492 int system_setting_get_locale_language(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1493 {
1494         SETTING_TRACE_BEGIN;
1495         char *vconf_value = NULL;
1496         if (system_setting_vconf_get_value_string(VCONFKEY_LANGSET, &vconf_value)) {
1497                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1498         }
1499
1500         /* parsing validation */
1501         /* en_US.UTF-8 */
1502         char arr[20];
1503         snprintf(arr, 20, "%s", vconf_value);
1504         arr[5] = '\0';
1505         *value = strdup(arr);
1506         free(vconf_value);
1507         vconf_value = NULL;
1508         return SYSTEM_SETTINGS_ERROR_NONE;
1509 }
1510
1511 int system_setting_set_locale_language(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1512 {
1513         SETTING_TRACE_BEGIN;
1514         char *vconf_value = NULL;
1515         vconf_value = (char *)value;
1516
1517         char *ext = "UTF-8";
1518
1519         char arr[20];
1520         snprintf(arr, 20, "%s.%s", vconf_value, ext);
1521
1522         if (system_setting_vconf_set_value_string(VCONFKEY_LANGSET, arr)) {
1523                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1524         }
1525         return SYSTEM_SETTINGS_ERROR_NONE;
1526 }
1527
1528 int system_setting_set_changed_callback_locale_language(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1529 {
1530         SETTING_TRACE_BEGIN;
1531         /*return system_setting_vconf_set_changed_cb(VCONFKEY_LANGSET, SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, 3, user_data ); */
1532         return system_setting_vconf_set_changed_cb(VCONFKEY_LANGSET, SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, 100, user_data);
1533 }
1534
1535 int system_setting_unset_changed_callback_locale_language(system_settings_key_e key)
1536 {
1537         SETTING_TRACE_BEGIN;
1538         return system_setting_vconf_unset_changed_cb(VCONFKEY_LANGSET, 100);
1539 }
1540
1541 /*--------------------------------------- */
1542 int system_setting_get_locale_timeformat_24hour(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1543 {
1544         SETTING_TRACE_BEGIN;
1545         int vconf_value;
1546
1547         if (system_setting_vconf_get_value_int(VCONFKEY_REGIONFORMAT_TIME1224, &vconf_value)) {
1548                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1549         }
1550
1551         bool ret_value = true;
1552         if (vconf_value == VCONFKEY_TIME_FORMAT_12)
1553                 ret_value = false;
1554         else if (vconf_value == VCONFKEY_TIME_FORMAT_24)
1555                 ret_value = true;
1556
1557         *value = (void *)ret_value;
1558
1559         return SYSTEM_SETTINGS_ERROR_NONE;
1560 }
1561
1562 int system_setting_set_locale_timeformat_24hour(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1563 {
1564         SETTING_TRACE_BEGIN;
1565         bool *vconf_value;
1566
1567         vconf_value = (bool *)value;
1568
1569         if (*vconf_value) {
1570                 if (system_setting_vconf_set_value_int(VCONFKEY_REGIONFORMAT_TIME1224, VCONFKEY_TIME_FORMAT_24)) {
1571                         return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1572                 }
1573
1574         } else {
1575                 if (system_setting_vconf_set_value_int(VCONFKEY_REGIONFORMAT_TIME1224, VCONFKEY_TIME_FORMAT_12)) {
1576                         return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1577                 }
1578
1579         }
1580
1581         return SYSTEM_SETTINGS_ERROR_NONE;
1582 }
1583
1584 int system_setting_set_changed_callback_locale_timeformat_24hour(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1585 {
1586         SETTING_TRACE_BEGIN;
1587         return system_setting_vconf_set_changed_cb(VCONFKEY_REGIONFORMAT_TIME1224, SYSTEM_SETTINGS_KEY_LOCALE_TIMEFORMAT_24HOUR, 3, user_data);
1588 }
1589
1590 int system_setting_unset_changed_callback_locale_timeformat_24hour(system_settings_key_e key)
1591 {
1592         SETTING_TRACE_BEGIN;
1593         return system_setting_vconf_unset_changed_cb(VCONFKEY_REGIONFORMAT_TIME1224, 3);
1594 }
1595
1596 int system_setting_get_locale_timezone(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1597 {
1598         SETTING_TRACE_BEGIN;
1599 #if 0
1600         char tzpath[256];
1601         ssize_t len = readlink(SETTING_TZONE_SYMLINK_PATH, tzpath, sizeof(tzpath) - 1);
1602         if (len != -1) {
1603                 tzpath[len] = '\0';
1604         } else {
1605                 SETTING_TRACE("parse error for SETTING_TZONE_SYMLINK_PATH");
1606                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1607         }
1608         /* "/usr/share/zoneinfo/Asia/Seoul" */
1609         SETTING_TRACE("tzpath : %s ", &tzpath[20]);
1610         *value = strdup(&tzpath[20]);
1611 #else
1612         *value = vconf_get_str(VCONFKEY_SETAPPL_TIMEZONE_ID);
1613 #endif
1614         return SYSTEM_SETTINGS_ERROR_NONE;
1615 }
1616
1617 int system_setting_set_changed_callback_locale_timezone_changed(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1618 {
1619         SETTING_TRACE_BEGIN;
1620         return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
1621 }
1622
1623 int system_setting_unset_changed_callback_locale_timezone_changed(system_settings_key_e key)
1624 {
1625         SETTING_TRACE_BEGIN;
1626         return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
1627 }
1628
1629
1630 int system_setting_get_time_changed(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1631 {
1632         SETTING_TRACE_BEGIN;
1633         time_t cur_tick;
1634         cur_tick = time(NULL);
1635         *value = (void *)cur_tick;
1636         /* struct tm * localtime = time (cur_tick); */
1637         /* printf("%s\n", ctime(&cur_tick); */
1638         return SYSTEM_SETTINGS_ERROR_NONE;
1639
1640 }
1641
1642 int system_setting_set_changed_callback_time_changed(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1643 {
1644         SETTING_TRACE_BEGIN;
1645         return system_setting_vconf_set_changed_cb(VCONFKEY_SYSTEM_TIME_CHANGED, SYSTEM_SETTINGS_KEY_TIME_CHANGED, 3, user_data);
1646 }
1647
1648 int system_setting_unset_changed_callback_time_changed(system_settings_key_e key)
1649 {
1650         SETTING_TRACE_BEGIN;
1651         return system_setting_vconf_unset_changed_cb(VCONFKEY_SYSTEM_TIME_CHANGED, 3);
1652 }
1653
1654
1655
1656 /* SYSTEM_SETTINGS_KEY_SOUND_LOCK */
1657 int system_setting_get_sound_lock(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1658 {
1659         SETTING_TRACE_BEGIN;
1660         bool vconf_value;
1661
1662         if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_SOUND_LOCK_BOOL, &vconf_value)) {
1663                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1664         }
1665         *value = (void *)vconf_value;
1666
1667         return SYSTEM_SETTINGS_ERROR_NONE;
1668 }
1669
1670 int system_setting_set_changed_callback_sound_lock(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1671 {
1672         SETTING_TRACE_BEGIN;
1673         return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_SOUND_LOCK_BOOL, SYSTEM_SETTINGS_KEY_SOUND_LOCK, 3, user_data);
1674 }
1675
1676 int system_setting_unset_changed_callback_sound_lock(system_settings_key_e key)
1677 {
1678         SETTING_TRACE_BEGIN;
1679         return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_SOUND_LOCK_BOOL, 3);
1680 }
1681
1682 /**
1683  * a = VCONFKEY_SETAPPL_SOUND_STATUS_BOOL b = VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL
1684  *
1685  * a == false, b == false --> silent mode
1686  * a == true, b == false --> sound mode
1687  * a == false, b == true --> vibration mode
1688  */
1689 int system_setting_get_sound_silent_mode(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1690 {
1691         SETTING_TRACE_BEGIN;
1692         bool sound_cond;
1693         bool vib_cond;
1694
1695         bool vconf_value;
1696         if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, &sound_cond)) {
1697                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1698         }
1699
1700         if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, &vib_cond)) {
1701                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1702         }
1703
1704         if (sound_cond == false && vib_cond == false) {
1705                 vconf_value = true;
1706                 *value = (void *)vconf_value;
1707         } else {
1708                 vconf_value = false;
1709                 *value = (void *)vconf_value;
1710         }
1711         return SYSTEM_SETTINGS_ERROR_NONE;
1712 }
1713
1714 /**
1715  * a = VCONFKEY_SETAPPL_SOUND_STATUS_BOOL b = VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL
1716  *
1717  * a == false, b == false --> silent mode
1718  * a == true, b == false --> sound mode
1719  */
1720 int system_setting_set_sound_silent_mode(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1721 {
1722         SETTING_TRACE_BEGIN;
1723         bool *vconf_value;
1724
1725         vconf_value = (bool *)value;
1726
1727         bool vconf_sound = false;
1728         bool vconf_vib = false;
1729
1730         if (*vconf_value) {
1731                 vconf_sound = false;
1732                 vconf_vib = false;
1733         } else {
1734                 vconf_sound = true;
1735                 vconf_vib = false;
1736         }
1737
1738         if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, vconf_sound)) {
1739                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1740         }
1741         if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, vconf_vib)) {
1742                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1743         }
1744
1745         return SYSTEM_SETTINGS_ERROR_NONE;
1746 }
1747
1748
1749
1750 /* TODO */
1751 int system_setting_set_changed_callback_sound_silent_mode(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1752 {
1753         SETTING_TRACE_BEGIN;
1754         return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, SYSTEM_SETTINGS_KEY_SOUND_SILENT_MODE, 3, user_data);
1755 }
1756
1757 /* TODO */
1758 int system_setting_unset_changed_callback_sound_silent_mode(system_settings_key_e key)
1759 {
1760         SETTING_TRACE_BEGIN;
1761         return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, 3);
1762 }
1763
1764 /* SYSTEM_SETTINGS_KEY_SOUND_TOUCH */
1765 int system_setting_get_sound_touch(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1766 {
1767         SETTING_TRACE_BEGIN;
1768         bool vconf_value;
1769
1770         int ret = system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL, &vconf_value);
1771         if (ret != SYSTEM_SETTINGS_ERROR_NONE) {
1772                 return ret;
1773         }
1774         *value = (void *)vconf_value;
1775         return ret;
1776 }
1777
1778 int system_setting_set_changed_callback_sound_touch(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1779 {
1780         SETTING_TRACE_BEGIN;
1781         return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL, SYSTEM_SETTINGS_KEY_SOUND_TOUCH, 2, user_data);
1782 }
1783
1784 int system_setting_unset_changed_callback_sound_touch(system_settings_key_e key)
1785 {
1786         SETTING_TRACE_BEGIN;
1787         return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL, 2);
1788 }
1789
1790 #if 0
1791 /* SYSTEM_SETTINGS_KEY_SOUND_LOCK */
1792 int system_setting_get_sound_lock(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1793 {
1794         bool vconf_value;
1795
1796         if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_SOUND_LOCK_BOOL, &vconf_value)) {
1797                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1798         }
1799         *value = (void *)vconf_value;
1800
1801         return SYSTEM_SETTINGS_ERROR_NONE;
1802 }
1803 #endif
1804
1805 int system_setting_get_auto_rotation_mode(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1806 {
1807         SETTING_TRACE_BEGIN;
1808         bool vconf_value;
1809
1810         if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, &vconf_value)) {
1811                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1812         }
1813         *value = (void *)vconf_value;
1814
1815         return SYSTEM_SETTINGS_ERROR_NONE;
1816 }
1817
1818 int system_setting_set_auto_rotation_mode(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1819 {
1820         SETTING_TRACE_BEGIN;
1821         bool *vconf_value;
1822         vconf_value = (bool *)value;
1823         if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, *vconf_value)) {
1824                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1825         }
1826
1827         return SYSTEM_SETTINGS_ERROR_NONE;
1828 }
1829
1830 int system_setting_set_changed_callback_auto_rotation_mode(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1831 {
1832         SETTING_TRACE_BEGIN;
1833         return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, SYSTEM_SETTINGS_KEY_DISPLAY_SCREEN_ROTATION_AUTO, 2, user_data);
1834 }
1835
1836 int system_setting_unset_changed_callback_auto_rotation_mode(system_settings_key_e key)
1837 {
1838         SETTING_TRACE_BEGIN;
1839         return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, 2);
1840 }
1841
1842 int system_setting_get_screen_backlight_time(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1843 {
1844         SETTING_TRACE_BEGIN;
1845         int vconf_value;
1846
1847         if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, &vconf_value)) {
1848                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1849         }
1850         *value = (void *)vconf_value;
1851
1852         return SYSTEM_SETTINGS_ERROR_NONE;
1853 }
1854
1855
1856 int system_setting_set_screen_backlight_time(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1857 {
1858         SETTING_TRACE_BEGIN;
1859         int *vconf_value;
1860         vconf_value = (int *)value;
1861
1862         if (!(*vconf_value > 0 && *vconf_value < 600)) {
1863                 SETTING_TRACE(" ERR Betweeny here  0 ~ 600");
1864                 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
1865         }
1866
1867         if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, *vconf_value)) {
1868                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1869         }
1870         SETTING_TRACE_END;
1871         return SYSTEM_SETTINGS_ERROR_NONE;
1872 }
1873
1874 int system_setting_set_changed_callback_screen_backlight_time(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1875 {
1876         SETTING_TRACE_BEGIN;
1877         return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, SYSTEM_SETTINGS_KEY_DISPLAY_SCREEN_ROTATION_AUTO, 2, user_data);
1878 }
1879
1880 int system_setting_unset_changed_callback_screen_backlight_time(system_settings_key_e key)
1881 {
1882         SETTING_TRACE_BEGIN;
1883         return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, 2);
1884 }
1885
1886 int system_setting_get_sound_notification(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1887 {
1888         SETTING_TRACE_BEGIN;
1889         char *vconf_value = NULL;
1890         if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, &vconf_value)) {
1891                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1892         }
1893
1894         *value = vconf_value;
1895         return SYSTEM_SETTINGS_ERROR_NONE;
1896 }
1897
1898 int system_setting_set_sound_notification(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1899 {
1900         SETTING_TRACE_BEGIN;
1901         char *vconf_value = NULL;
1902         vconf_value = (char *)value;
1903
1904         int is_load = _is_file_accessible(vconf_value);
1905         if (is_load == 0) {
1906                 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, vconf_value)) {
1907                         return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1908                 }
1909         } else {
1910                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1911         }
1912
1913         return SYSTEM_SETTINGS_ERROR_NONE;
1914 }
1915
1916 int system_setting_set_changed_callback_sound_notification(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1917 {
1918         SETTING_TRACE_BEGIN;
1919         return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, SYSTEM_SETTINGS_KEY_INCOMING_CALL_RINGTONE, 0, user_data);
1920 }
1921
1922 int system_setting_unset_changed_callback_sound_notification(system_settings_key_e key)
1923 {
1924         SETTING_TRACE_BEGIN;
1925         return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, 0);
1926 }
1927
1928 int system_setting_get_notification_repetition_period(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1929 {
1930         SETTING_TRACE_BEGIN;
1931         int vconf_value;
1932
1933         if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_NOTI_MSG_ALERT_REP_TYPE_INT, &vconf_value)) {
1934                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1935         }
1936         *value = (void *)vconf_value;
1937
1938         return SYSTEM_SETTINGS_ERROR_NONE;
1939 }
1940
1941 int system_setting_set_notification_repetition_period(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1942 {
1943         SETTING_TRACE_BEGIN;
1944         int *vconf_value;
1945         vconf_value = (int *)value;
1946
1947         if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_NOTI_MSG_ALERT_REP_TYPE_INT, *vconf_value)) {
1948                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1949         }
1950         SETTING_TRACE_END;
1951         return SYSTEM_SETTINGS_ERROR_NONE;
1952 }
1953
1954 int system_setting_set_changed_callback_notification_repetition_period(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1955 {
1956         SETTING_TRACE_BEGIN;
1957         return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_ALERT_REP_TYPE_INT, SYSTEM_SETTINGS_KEY_SOUND_NOTIFICATION_REPETITION_PERIOD, 1, user_data);
1958 }
1959
1960 int system_setting_unset_changed_callback_notification_repetition_period(system_settings_key_e key)
1961 {
1962         SETTING_TRACE_BEGIN;
1963         return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_ALERT_REP_TYPE_INT, 1);
1964 }
1965
1966 int system_setting_get_device_name(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1967 {
1968         SETTING_TRACE_BEGIN;
1969         char *vconf_value = NULL;
1970         if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_DEVICE_NAME_STR, &vconf_value)) {
1971                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1972         }
1973
1974         *value = vconf_value;
1975         return SYSTEM_SETTINGS_ERROR_NONE;
1976 }
1977
1978 int system_setting_set_device_name(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1979 {
1980         SETTING_TRACE_BEGIN;
1981         char *vconf_value = NULL;
1982         vconf_value = (char *)value;
1983
1984         if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_DEVICE_NAME_STR, vconf_value)) {
1985                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1986         }
1987
1988         return SYSTEM_SETTINGS_ERROR_NONE;
1989 }
1990
1991 int system_setting_set_changed_callback_device_name(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1992 {
1993         SETTING_TRACE_BEGIN;
1994         return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_DEVICE_NAME_STR, SYSTEM_SETTINGS_KEY_DEVICE_NAME, 0, user_data);
1995 }
1996
1997 int system_setting_unset_changed_callback_device_name(system_settings_key_e key)
1998 {
1999         SETTING_TRACE_BEGIN;
2000         return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_DEVICE_NAME_STR, 0);
2001 }
2002
2003 /*---------------------------------------------- */
2004 int system_setting_get_network_flight_mode(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
2005 {
2006         SETTING_TRACE_BEGIN;
2007         bool vconf_value;
2008         if (system_setting_vconf_get_value_bool(VCONFKEY_TELEPHONY_FLIGHT_MODE, &vconf_value)) {
2009                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2010         }
2011         *value = (void *)vconf_value;
2012
2013         return SYSTEM_SETTINGS_ERROR_NONE;
2014 }
2015
2016 int system_setting_set_changed_callback_network_flight_mode(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
2017 {
2018         SETTING_TRACE_BEGIN;
2019         return system_setting_vconf_set_changed_cb(VCONFKEY_TELEPHONY_FLIGHT_MODE, SYSTEM_SETTINGS_KEY_NETWORK_FLIGHT_MODE, 3, user_data);
2020 }
2021
2022 int system_setting_unset_changed_callback_network_flight_mode(system_settings_key_e key)
2023 {
2024         SETTING_TRACE_BEGIN;
2025         return system_setting_vconf_unset_changed_cb(VCONFKEY_TELEPHONY_FLIGHT_MODE, 3);
2026 }
2027
2028 int system_setting_get_network_wifi_notification(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
2029 {
2030         SETTING_TRACE_BEGIN;
2031         int vconf_value;
2032         if (system_setting_vconf_get_value_int(VCONFKEY_WIFI_ENABLE_QS, &vconf_value)) {
2033                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2034         }
2035         bool bret ;
2036         bret = (vconf_value == VCONFKEY_WIFI_QS_ENABLE) ? true : false;
2037
2038         *value = (void *)bret;
2039         return SYSTEM_SETTINGS_ERROR_NONE;
2040 }
2041
2042 int system_setting_set_changed_callback_network_wifi_notification(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
2043 {
2044         SETTING_TRACE_BEGIN;
2045         return system_setting_vconf_set_changed_cb(VCONFKEY_WIFI_ENABLE_QS, SYSTEM_SETTINGS_KEY_NETWORK_WIFI_NOTIFICATION, 4, user_data);
2046 }
2047
2048 int system_setting_unset_changed_callback_network_wifi_notification(system_settings_key_e key)
2049 {
2050         SETTING_TRACE_BEGIN;
2051         return system_setting_vconf_unset_changed_cb(VCONFKEY_WIFI_ENABLE_QS, 4);
2052 }
2053
2054 int system_setting_get_lock_state(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
2055 {
2056         int vconf_value;
2057
2058         if (system_setting_vconf_get_value_int(VCONFKEY_IDLE_LOCK_STATE_READ_ONLY, &vconf_value)) {
2059                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2060         }
2061         *value = (void *)vconf_value;
2062
2063         return SYSTEM_SETTINGS_ERROR_NONE;
2064 }
2065
2066 int system_setting_set_lock_state(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
2067 {
2068         SETTING_TRACE_BEGIN;
2069         int *vconf_value;
2070         vconf_value = (int *)value;
2071
2072         if (system_setting_vconf_set_value_int(VCONFKEY_IDLE_LOCK_STATE_READ_ONLY, *vconf_value)) {
2073                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2074         }
2075         SETTING_TRACE_END;
2076         return SYSTEM_SETTINGS_ERROR_NONE;
2077 }
2078
2079 int system_setting_set_changed_callback_lock_state(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
2080 {
2081         return system_setting_vconf_set_changed_cb(VCONFKEY_IDLE_LOCK_STATE_READ_ONLY, SYSTEM_SETTINGS_KEY_LOCK_STATE, 4, user_data);
2082 }
2083
2084 int system_setting_unset_changed_callback_lock_state(system_settings_key_e key)
2085 {
2086         return system_setting_vconf_unset_changed_cb(VCONFKEY_IDLE_LOCK_STATE_READ_ONLY, 4);
2087 }
2088
2089