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