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