Added exclusive area in source code for gcov
[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         SETTING_TRACE_BEGIN;
1332         *value = vconf_get_str(VCONFKEY_SETAPPL_TIMEZONE_ID);
1333         return SYSTEM_SETTINGS_ERROR_NONE;
1334 }
1335
1336 /*  LCOV_EXCL_START */
1337 int system_setting_set_locale_timezone(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1338 {
1339         SETTING_TRACE_BEGIN;
1340         char *vconf_value = NULL;
1341         vconf_value = (char *)value;
1342
1343         char tz_path[1024];
1344         snprintf(tz_path, 1024, "/usr/share/zoneinfo/%s", vconf_value);
1345
1346         int is_load = _is_file_accessible(tz_path);
1347         if (is_load == 0) {
1348                 alarmmgr_set_timezone(tz_path);
1349
1350                 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_TIMEZONE_ID, vconf_value)) {
1351                         return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1352                 }
1353                 return SYSTEM_SETTINGS_ERROR_NONE;
1354         }
1355         return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
1356 }
1357 /*  LCOV_EXCL_STOP */
1358
1359
1360
1361 /*  LCOV_EXCL_START */
1362 int system_setting_set_changed_callback_locale_timezone(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1363 {
1364         return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_TIMEZONE_ID, SYSTEM_SETTINGS_KEY_LOCALE_TIMEZONE, 4, user_data);
1365 }
1366 /*  LCOV_EXCL_STOP */
1367
1368 /*  LCOV_EXCL_START */
1369 int system_setting_unset_changed_callback_locale_timezone(system_settings_key_e key)
1370 {
1371         return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_TIMEZONE_ID, 4);
1372 }
1373 /*  LCOV_EXCL_STOP */
1374
1375 /*  LCOV_EXCL_START */
1376 int system_setting_set_changed_callback_locale_timezone_changed(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1377 {
1378         SETTING_TRACE_BEGIN;
1379         return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
1380 }
1381 /*  LCOV_EXCL_STOP */
1382
1383 /*  LCOV_EXCL_START */
1384 int system_setting_unset_changed_callback_locale_timezone_changed(system_settings_key_e key)
1385 {
1386         SETTING_TRACE_BEGIN;
1387         return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
1388 }
1389 /*  LCOV_EXCL_STOP */
1390
1391
1392 /*  LCOV_EXCL_START */
1393 int system_setting_get_time_changed(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1394 {
1395         SETTING_TRACE_BEGIN;
1396         time_t cur_tick;
1397         cur_tick = time(NULL);
1398         *value = (void *)cur_tick;
1399         /* struct tm * localtime = time (cur_tick); */
1400         /* printf("%s\n", ctime(&cur_tick); */
1401         return SYSTEM_SETTINGS_ERROR_NONE;
1402
1403 }
1404 /*  LCOV_EXCL_STOP */
1405
1406 int system_setting_set_changed_callback_time_changed(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1407 {
1408         SETTING_TRACE_BEGIN;
1409         return system_setting_vconf_set_changed_cb(VCONFKEY_SYSTEM_TIME_CHANGED, SYSTEM_SETTINGS_KEY_TIME_CHANGED, 3, user_data);
1410 }
1411
1412 int system_setting_unset_changed_callback_time_changed(system_settings_key_e key)
1413 {
1414         SETTING_TRACE_BEGIN;
1415         return system_setting_vconf_unset_changed_cb(VCONFKEY_SYSTEM_TIME_CHANGED, 3);
1416 }
1417
1418
1419
1420 /* SYSTEM_SETTINGS_KEY_SOUND_LOCK */
1421 int system_setting_get_sound_lock(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1422 {
1423         SETTING_TRACE_BEGIN;
1424         bool vconf_value;
1425
1426         if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_SOUND_LOCK_BOOL, &vconf_value)) {
1427                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1428         }
1429         *value = (void *)vconf_value;
1430
1431         return SYSTEM_SETTINGS_ERROR_NONE;
1432 }
1433
1434 int system_setting_set_changed_callback_sound_lock(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1435 {
1436         SETTING_TRACE_BEGIN;
1437         return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_SOUND_LOCK_BOOL, SYSTEM_SETTINGS_KEY_SOUND_LOCK, 3, user_data);
1438 }
1439
1440 int system_setting_unset_changed_callback_sound_lock(system_settings_key_e key)
1441 {
1442         SETTING_TRACE_BEGIN;
1443         return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_SOUND_LOCK_BOOL, 3);
1444 }
1445
1446 /**
1447  * a = VCONFKEY_SETAPPL_SOUND_STATUS_BOOL b = VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL
1448  *
1449  * a == false, b == false --> silent mode
1450  * a == true, b == false --> sound mode
1451  * a == false, b == true --> vibration mode
1452  */
1453 /*  LCOV_EXCL_START */
1454 int system_setting_get_sound_silent_mode(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1455 {
1456         SETTING_TRACE_BEGIN;
1457         bool sound_cond;
1458         bool vib_cond;
1459
1460         bool vconf_value;
1461         if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, &sound_cond)) {
1462                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1463         }
1464
1465         if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, &vib_cond)) {
1466                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1467         }
1468
1469         if (sound_cond == false && vib_cond == false) {
1470                 vconf_value = true;
1471                 *value = (void *)vconf_value;
1472         } else {
1473                 vconf_value = false;
1474                 *value = (void *)vconf_value;
1475         }
1476         return SYSTEM_SETTINGS_ERROR_NONE;
1477 }
1478 /*  LCOV_EXCL_STOP */
1479
1480 /**
1481  * a = VCONFKEY_SETAPPL_SOUND_STATUS_BOOL b = VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL
1482  *
1483  * a == false, b == false --> silent mode
1484  * a == true, b == false --> sound mode
1485  */
1486 int system_setting_set_sound_silent_mode(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1487 {
1488         SETTING_TRACE_BEGIN;
1489         bool *vconf_value;
1490
1491         vconf_value = (bool *)value;
1492
1493         bool vconf_sound = false;
1494         bool vconf_vib = false;
1495
1496         if (*vconf_value) {
1497                 vconf_sound = false;
1498                 vconf_vib = false;
1499         } else {
1500                 vconf_sound = true;
1501                 vconf_vib = false;
1502         }
1503
1504         if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, vconf_sound)) {
1505                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1506         }
1507         if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, vconf_vib)) {
1508                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1509         }
1510
1511         return SYSTEM_SETTINGS_ERROR_NONE;
1512 }
1513
1514
1515
1516 /* TODO */
1517 int system_setting_set_changed_callback_sound_silent_mode(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1518 {
1519         SETTING_TRACE_BEGIN;
1520         return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, SYSTEM_SETTINGS_KEY_SOUND_SILENT_MODE, 3, user_data);
1521 }
1522
1523 /* TODO */
1524 int system_setting_unset_changed_callback_sound_silent_mode(system_settings_key_e key)
1525 {
1526         SETTING_TRACE_BEGIN;
1527         return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, 3);
1528 }
1529
1530 /* SYSTEM_SETTINGS_KEY_SOUND_TOUCH */
1531 int system_setting_get_sound_touch(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1532 {
1533         SETTING_TRACE_BEGIN;
1534         bool vconf_value;
1535
1536         int ret = system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL, &vconf_value);
1537         if (ret != SYSTEM_SETTINGS_ERROR_NONE) {
1538                 return ret;
1539         }
1540         *value = (void *)vconf_value;
1541         return ret;
1542 }
1543
1544 int system_setting_set_changed_callback_sound_touch(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1545 {
1546         SETTING_TRACE_BEGIN;
1547         return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL, SYSTEM_SETTINGS_KEY_SOUND_TOUCH, 2, user_data);
1548 }
1549
1550 int system_setting_unset_changed_callback_sound_touch(system_settings_key_e key)
1551 {
1552         SETTING_TRACE_BEGIN;
1553         return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL, 2);
1554 }
1555
1556 #if 0
1557 /* SYSTEM_SETTINGS_KEY_SOUND_LOCK */
1558 int system_setting_get_sound_lock(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1559 {
1560         bool vconf_value;
1561
1562         if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_SOUND_LOCK_BOOL, &vconf_value)) {
1563                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1564         }
1565         *value = (void *)vconf_value;
1566
1567         return SYSTEM_SETTINGS_ERROR_NONE;
1568 }
1569 #endif
1570
1571 int system_setting_get_auto_rotation_mode(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1572 {
1573         SETTING_TRACE_BEGIN;
1574         bool vconf_value;
1575
1576         if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, &vconf_value)) {
1577                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1578         }
1579         *value = (void *)vconf_value;
1580
1581         return SYSTEM_SETTINGS_ERROR_NONE;
1582 }
1583
1584 /*  LCOV_EXCL_START */
1585 int system_setting_set_auto_rotation_mode(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1586 {
1587         SETTING_TRACE_BEGIN;
1588         bool *vconf_value;
1589         vconf_value = (bool *)value;
1590         if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, *vconf_value)) {
1591                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1592         }
1593
1594         return SYSTEM_SETTINGS_ERROR_NONE;
1595 }
1596 /*  LCOV_EXCL_STOP */
1597
1598 int system_setting_set_changed_callback_auto_rotation_mode(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1599 {
1600         SETTING_TRACE_BEGIN;
1601         return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, SYSTEM_SETTINGS_KEY_DISPLAY_SCREEN_ROTATION_AUTO, 2, user_data);
1602 }
1603
1604 int system_setting_unset_changed_callback_auto_rotation_mode(system_settings_key_e key)
1605 {
1606         SETTING_TRACE_BEGIN;
1607         return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, 2);
1608 }
1609
1610 int system_setting_get_screen_backlight_time(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1611 {
1612         SETTING_TRACE_BEGIN;
1613         int vconf_value;
1614
1615         if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, &vconf_value)) {
1616                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1617         }
1618         *value = (void *)vconf_value;
1619
1620         return SYSTEM_SETTINGS_ERROR_NONE;
1621 }
1622
1623
1624 /*  LCOV_EXCL_START */
1625 int system_setting_set_screen_backlight_time(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1626 {
1627         SETTING_TRACE_BEGIN;
1628         int *vconf_value;
1629         vconf_value = (int *)value;
1630
1631         if (!(*vconf_value > 0 && *vconf_value < 600)) {
1632                 SETTING_TRACE(" ERR Betweeny here  0 ~ 600");
1633                 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
1634         }
1635
1636         if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, *vconf_value)) {
1637                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1638         }
1639         SETTING_TRACE_END;
1640         return SYSTEM_SETTINGS_ERROR_NONE;
1641 }
1642 /*  LCOV_EXCL_STOP */
1643
1644 int system_setting_set_changed_callback_screen_backlight_time(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1645 {
1646         SETTING_TRACE_BEGIN;
1647         return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, SYSTEM_SETTINGS_KEY_DISPLAY_SCREEN_ROTATION_AUTO, 2, user_data);
1648 }
1649
1650 int system_setting_unset_changed_callback_screen_backlight_time(system_settings_key_e key)
1651 {
1652         SETTING_TRACE_BEGIN;
1653         return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, 2);
1654 }
1655
1656 int system_setting_get_sound_notification(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1657 {
1658         SETTING_TRACE_BEGIN;
1659         char *vconf_value = NULL;
1660         if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, &vconf_value)) {
1661                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1662         }
1663
1664         *value = vconf_value;
1665         return SYSTEM_SETTINGS_ERROR_NONE;
1666 }
1667
1668 /*  LCOV_EXCL_START */
1669 int system_setting_set_sound_notification(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1670 {
1671         SETTING_TRACE_BEGIN;
1672         char *vconf_value = NULL;
1673         vconf_value = (char *)value;
1674
1675         int is_load = _is_file_accessible(vconf_value);
1676         if (is_load == 0) {
1677                 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, vconf_value)) {
1678                         return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1679                 }
1680         } else {
1681                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1682         }
1683
1684         return SYSTEM_SETTINGS_ERROR_NONE;
1685 }
1686 /*  LCOV_EXCL_STOP */
1687
1688 int system_setting_set_changed_callback_sound_notification(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1689 {
1690         SETTING_TRACE_BEGIN;
1691         return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, SYSTEM_SETTINGS_KEY_INCOMING_CALL_RINGTONE, 0, user_data);
1692 }
1693
1694 int system_setting_unset_changed_callback_sound_notification(system_settings_key_e key)
1695 {
1696         SETTING_TRACE_BEGIN;
1697         return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, 0);
1698 }
1699
1700 int system_setting_get_notification_repetition_period(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1701 {
1702         SETTING_TRACE_BEGIN;
1703         int vconf_value;
1704
1705         if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_NOTI_MSG_ALERT_REP_TYPE_INT, &vconf_value)) {
1706                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1707         }
1708         *value = (void *)vconf_value;
1709
1710         return SYSTEM_SETTINGS_ERROR_NONE;
1711 }
1712
1713 /*  LCOV_EXCL_START */
1714 int system_setting_set_notification_repetition_period(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1715 {
1716         SETTING_TRACE_BEGIN;
1717         int *vconf_value;
1718         vconf_value = (int *)value;
1719
1720         if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_NOTI_MSG_ALERT_REP_TYPE_INT, *vconf_value)) {
1721                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1722         }
1723         SETTING_TRACE_END;
1724         return SYSTEM_SETTINGS_ERROR_NONE;
1725 }
1726 /*  LCOV_EXCL_STOP */
1727
1728 int system_setting_set_changed_callback_notification_repetition_period(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1729 {
1730         SETTING_TRACE_BEGIN;
1731         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);
1732 }
1733
1734 int system_setting_unset_changed_callback_notification_repetition_period(system_settings_key_e key)
1735 {
1736         SETTING_TRACE_BEGIN;
1737         return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_ALERT_REP_TYPE_INT, 1);
1738 }
1739
1740 int system_setting_get_device_name(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1741 {
1742         SETTING_TRACE_BEGIN;
1743         char *vconf_value = NULL;
1744         if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_DEVICE_NAME_STR, &vconf_value)) {
1745                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1746         }
1747
1748         *value = vconf_value;
1749         return SYSTEM_SETTINGS_ERROR_NONE;
1750 }
1751
1752 /*  LCOV_EXCL_START */
1753 int system_setting_set_device_name(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1754 {
1755         SETTING_TRACE_BEGIN;
1756         char *vconf_value = NULL;
1757         vconf_value = (char *)value;
1758
1759         if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_DEVICE_NAME_STR, vconf_value)) {
1760                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1761         }
1762
1763         return SYSTEM_SETTINGS_ERROR_NONE;
1764 }
1765 /*  LCOV_EXCL_STOP */
1766
1767 int system_setting_set_changed_callback_device_name(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1768 {
1769         SETTING_TRACE_BEGIN;
1770         return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_DEVICE_NAME_STR, SYSTEM_SETTINGS_KEY_DEVICE_NAME, 0, user_data);
1771 }
1772
1773 int system_setting_unset_changed_callback_device_name(system_settings_key_e key)
1774 {
1775         SETTING_TRACE_BEGIN;
1776         return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_DEVICE_NAME_STR, 0);
1777 }
1778
1779 /*---------------------------------------------- */
1780 int system_setting_get_network_flight_mode(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1781 {
1782         SETTING_TRACE_BEGIN;
1783         bool vconf_value;
1784         if (system_setting_vconf_get_value_bool(VCONFKEY_TELEPHONY_FLIGHT_MODE, &vconf_value)) {
1785                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1786         }
1787         *value = (void *)vconf_value;
1788
1789         return SYSTEM_SETTINGS_ERROR_NONE;
1790 }
1791
1792 int system_setting_set_changed_callback_network_flight_mode(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1793 {
1794         SETTING_TRACE_BEGIN;
1795         return system_setting_vconf_set_changed_cb(VCONFKEY_TELEPHONY_FLIGHT_MODE, SYSTEM_SETTINGS_KEY_NETWORK_FLIGHT_MODE, 3, user_data);
1796 }
1797
1798 int system_setting_unset_changed_callback_network_flight_mode(system_settings_key_e key)
1799 {
1800         SETTING_TRACE_BEGIN;
1801         return system_setting_vconf_unset_changed_cb(VCONFKEY_TELEPHONY_FLIGHT_MODE, 3);
1802 }
1803
1804 int system_setting_get_network_wifi_notification(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1805 {
1806         SETTING_TRACE_BEGIN;
1807         int vconf_value;
1808         if (system_setting_vconf_get_value_int(VCONFKEY_WIFI_ENABLE_QS, &vconf_value)) {
1809                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1810         }
1811         bool bret ;
1812         bret = (vconf_value == VCONFKEY_WIFI_QS_ENABLE) ? true : false;
1813
1814         *value = (void *)bret;
1815         return SYSTEM_SETTINGS_ERROR_NONE;
1816 }
1817
1818 int system_setting_set_changed_callback_network_wifi_notification(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1819 {
1820         SETTING_TRACE_BEGIN;
1821         return system_setting_vconf_set_changed_cb(VCONFKEY_WIFI_ENABLE_QS, SYSTEM_SETTINGS_KEY_NETWORK_WIFI_NOTIFICATION, 4, user_data);
1822 }
1823
1824 int system_setting_unset_changed_callback_network_wifi_notification(system_settings_key_e key)
1825 {
1826         SETTING_TRACE_BEGIN;
1827         return system_setting_vconf_unset_changed_cb(VCONFKEY_WIFI_ENABLE_QS, 4);
1828 }
1829
1830 /*  LCOV_EXCL_START */
1831 int system_setting_get_lock_state(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1832 {
1833         int vconf_value;
1834
1835         if (system_setting_vconf_get_value_int(VCONFKEY_IDLE_LOCK_STATE_READ_ONLY, &vconf_value)) {
1836                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1837         }
1838         *value = (void *)vconf_value;
1839
1840         return SYSTEM_SETTINGS_ERROR_NONE;
1841 }
1842 /*  LCOV_EXCL_STOP */
1843
1844 /*  LCOV_EXCL_START */
1845 int system_setting_set_lock_state(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1846 {
1847         SETTING_TRACE_BEGIN;
1848         int *vconf_value;
1849         vconf_value = (int *)value;
1850
1851         if (system_setting_vconf_set_value_int(VCONFKEY_IDLE_LOCK_STATE_READ_ONLY, *vconf_value)) {
1852                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1853         }
1854         SETTING_TRACE_END;
1855         return SYSTEM_SETTINGS_ERROR_NONE;
1856 }
1857 /*  LCOV_EXCL_STOP */
1858
1859 /*  LCOV_EXCL_START */
1860 int system_setting_set_changed_callback_lock_state(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1861 {
1862         return system_setting_vconf_set_changed_cb(VCONFKEY_IDLE_LOCK_STATE_READ_ONLY, SYSTEM_SETTINGS_KEY_LOCK_STATE, 4, user_data);
1863 }
1864 /*  LCOV_EXCL_STOP */
1865
1866 /*  LCOV_EXCL_START */
1867 int system_setting_unset_changed_callback_lock_state(system_settings_key_e key)
1868 {
1869         return system_setting_vconf_unset_changed_cb(VCONFKEY_IDLE_LOCK_STATE_READ_ONLY, 4);
1870 }
1871 /*  LCOV_EXCL_STOP */
1872
1873