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