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