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