Remove #if 0
[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 <libgen.h>
26 #include <sys/types.h>
27 #include <sys/stat.h>
28 #include <fcntl.h>
29 #include <regex.h>
30
31 #include <aul.h>
32 #include <dlog.h>
33 #include <vconf.h>
34
35 #include <glib.h>
36 #include <libxml/xmlmemory.h>
37 #include <libxml/parser.h>
38
39 #include <fontconfig/fontconfig.h>
40
41 #include <pkgmgr-info.h>
42 #include <package_manager.h>
43 #include <app_manager.h>
44
45 #include <system_settings.h>
46 #include <system_settings_private.h>
47 #include <system_settings_ringtones.h>
48 #include <system_settings_json.h>
49
50 #include <system-setting-config.h>
51
52 #include <tzplatform_config.h>
53 #include <alarm.h>
54
55 #include <system_info.h>
56
57 #define SETTING_FONT_CONF_FILE _TZ_SYS_ETC"/fonts/conf.avail/99-tizen.conf"
58 #define SETTING_DEFAULT_FONT_CONF_FILE _TZ_SYS_ETC"/fonts/conf.avail/99-tizen.conf"
59
60 #define SETTING_TIME_ZONEINFO_PATH              "/usr/share/zoneinfo/"
61 #define SETTING_TIME_SHARE_LOCAL_PATH   "/usr/share/locale"
62 #define SETTING_TZONE_SYMLINK_PATH              "/opt/etc/localtime"
63
64
65 #define __FREE(del, arg) do { \
66                 if (arg) { \
67                         del((void *)(arg)); /*cast any argument to (void*) to avoid build warring*/\
68                         arg = NULL; \
69                 } \
70         } while (0);
71 #define FREE(arg) __FREE(free, arg)
72
73 #ifdef SETTING_ARCH_64
74 #define SETTING_UTILS_SO_FILE_PATH "/usr/lib64/libsystem-settings-util.so.0.1.0"
75 #else
76 #define SETTING_UTILS_SO_FILE_PATH "/usr/lib/libsystem-settings-util.so.0.1.0"
77 #endif
78
79 int _is_file_accessible(const char *path);
80
81 static bool dl_is_supported_image_type_load(char *path);
82 static bool dl_font_config_set(char *font_name);
83 static char *dl_get_default_font_info();
84 static int dl_is_available_font(char *str);
85 static void dl_font_size_set();
86 static void dl_font_config_set_notification();
87
88 /**
89  * VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR has a path of the ringtone file which user choose
90  * @return the ringtone file path specified by user in normal case
91  *                 if it's not accessable, return the default ringtone path
92  */
93 int system_setting_get_incoming_call_ringtone(system_settings_key_e key, void **value)
94 {
95         SETTING_TRACE_BEGIN;
96         char *vconf_value = NULL;
97         if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR, &vconf_value)) {
98                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
99         }
100
101         /* check to see if it's accessable -> OK */
102         /* no --> default ringtone path VCONFKEY_SETAPPL_CALL_RINGTONE_DEFAULT_PATH_STR */
103         int is_load = _is_file_accessible(vconf_value);
104         if (is_load == 0) {
105                 *value = vconf_value;
106         } else { /* not zero on errro */
107                 *value = vconf_get_str(VCONFKEY_SETAPPL_CALL_RINGTONE_DEFAULT_PATH_STR);
108                 free(vconf_value);
109         }
110
111         /**value = vconf_value; */
112         return SYSTEM_SETTINGS_ERROR_NONE;
113 }
114
115
116 int system_setting_get_email_alert_ringtone(system_settings_key_e key, void **value)
117 {
118         SETTING_TRACE_BEGIN;
119         char *vconf_value = NULL;
120         if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, &vconf_value)) {
121                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
122         }
123
124         /* check to see if it's accessable -> OK */
125         /* no --> default ringtone path VCONFKEY_SETAPPL_NOTI_RINGTONE_DEFAULT_PATH_STR */
126         int is_load = _is_file_accessible(vconf_value);
127         if (is_load == 0) {
128                 *value = vconf_value;
129         } else { /* not zero on errro */
130                 *value = vconf_get_str(VCONFKEY_SETAPPL_NOTI_RINGTONE_DEFAULT_PATH_STR);
131                 free(vconf_value);
132         }
133
134         return SYSTEM_SETTINGS_ERROR_NONE;
135 }
136
137
138 int system_setting_get_wallpaper_home_screen(system_settings_key_e key, void **value)
139 {
140         SETTING_TRACE_BEGIN;
141         char *vconf_value;
142         if (system_setting_vconf_get_value_string(VCONFKEY_BGSET, &vconf_value)) {
143                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
144         }
145         *value = vconf_value;
146         return SYSTEM_SETTINGS_ERROR_NONE;
147 }
148
149
150 int system_setting_get_wallpaper_lock_screen(system_settings_key_e key, void **value)
151 {
152         SETTING_TRACE_BEGIN;
153         char *vconf_value;
154
155         if (system_setting_vconf_get_value_string(VCONFKEY_IDLE_LOCK_BGSET, &vconf_value)) {
156                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
157         }
158         *value = vconf_value;
159
160         return SYSTEM_SETTINGS_ERROR_NONE;
161 }
162
163
164 /* [int] vconf GET */
165 int system_setting_get_font_size(system_settings_key_e key, void **value)
166 {
167         SETTING_TRACE_BEGIN;
168         int vconf_value;
169         int ** val = (int**)value;
170
171         if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, &vconf_value)) {
172                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
173         }
174         **val = vconf_value;
175
176         return SYSTEM_SETTINGS_ERROR_NONE;
177 }
178
179
180 int system_setting_get_default_font_type(system_settings_key_e key, void **value)
181 {
182         SETTING_TRACE_BEGIN;
183         char *font_name = dl_get_default_font_info();
184         if (font_name) {
185                 *value = (void *)font_name;
186                 return SYSTEM_SETTINGS_ERROR_NONE;
187         } else {
188                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
189         }
190 }
191
192 /* [int] vconf GET */
193 int system_setting_get_font_type(system_settings_key_e key, void **value)
194 {
195         SETTING_TRACE_BEGIN;
196         char *font_name = NULL;
197
198         if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, &font_name)) {
199                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
200         }
201
202         *value = font_name;
203         return SYSTEM_SETTINGS_ERROR_NONE;
204 }
205
206
207 int system_setting_get_motion_activation(system_settings_key_e key, void **value)
208 {
209         SETTING_TRACE_BEGIN;
210         bool vconf_value;
211
212         if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_MOTION_ACTIVATION, &vconf_value)) {
213                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
214         }
215         *value = (void *)vconf_value;
216
217         return SYSTEM_SETTINGS_ERROR_NONE;
218 }
219
220 int system_setting_get_usb_debugging_option(system_settings_key_e key, void **value)
221 {
222         SETTING_TRACE_BEGIN;
223         bool vconf_value;
224
225         if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_USB_DEBUG_MODE_BOOL, &vconf_value)) {
226                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
227         }
228         *value = (void *)vconf_value;
229
230         return SYSTEM_SETTINGS_ERROR_NONE;
231 }
232
233 int system_setting_get_3g_data_network(system_settings_key_e key, void **value)
234 {
235         SETTING_TRACE_BEGIN;
236         bool vconf_value;
237
238         if (system_setting_vconf_get_value_bool(VCONFKEY_3G_ENABLE, &vconf_value)) {
239                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
240         }
241         *value = (void *)vconf_value;
242
243         return SYSTEM_SETTINGS_ERROR_NONE;
244 }
245 /*////////////////////////////////////////////////////////////////////////////////////////////////// */
246
247
248 /**
249  * get current lock scren app package name (string)
250  *
251  * @return SYSTEM_SETTINGS_ERROR_LOCKSCREEN_APP_PASSWORD_MODE raise exception if current lock type is 'password'
252  */
253 int system_setting_get_lockscreen_app(system_settings_key_e key, void **value)
254 {
255         SETTING_TRACE_BEGIN;
256         char *pkg_name = NULL;
257         int locktype = -1;
258         if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_SCREEN_LOCK_TYPE_INT, &locktype)) {
259                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
260         }
261
262         if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_3RD_LOCK_PKG_NAME_STR, &pkg_name)) {
263                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
264         }
265
266         if (pkg_name && strcmp(pkg_name, "com.samsung.lockscreen") == 0 && locktype == SETTING_SCREEN_LOCK_TYPE_PASSWORD) {
267                 free(pkg_name);
268                 return SYSTEM_SETTINGS_ERROR_LOCKSCREEN_APP_PASSWORD_MODE;
269         }
270
271         *value = pkg_name;
272         return SYSTEM_SETTINGS_ERROR_NONE;
273 }
274
275
276 /*////////////////////////////////////////////////////////////////////////////////////////////////// */
277
278 int _is_file_accessible(const char *path)
279 {
280         SETTING_TRACE_BEGIN;
281         int ret = access(path , R_OK);
282         if (ret == 0) {
283                 SETTING_TRACE("found the file  %s", path);
284                 return 0;
285         } else {
286                 /* error code : 13 */
287                 SETTING_TRACE("found the file  %s --- error code : %d ", path, errno);
288                 return -errno;
289         }
290 }
291
292
293
294 /*////////////////////////////////////////////////////////////////////////////////////////////////// */
295 // @todo move to CMake
296 #define DEF_RINGTONE_FILE_PATH SETTING_DEF_RES"/Ringtones"
297
298 #define USR_RINGTONE_FILE_PATH "/home/owner/content/Sounds/Ringtones"
299 #define JSONFILE "/opt/home/owner/apps_rw/org.tizen.setting/data/.user-ringtones.json"
300
301 int system_setting_add_incoming_call_ringtone(system_settings_key_e key, void *value)
302 {
303         SETTING_TRACE_BEGIN;
304         char* pathval = (char*)value;
305         char* dnameval = NULL;
306         char* baseval = NULL;
307
308 #ifdef USE_JSONFILE
309         // NOT IN USE
310         JsonParser *parser = ss_json_ringtone_open_file(JSONFILE);
311 #else
312         JsonParser *parser = ss_json_ringtone_load_from_data();
313 #endif
314
315         JsonNode *root = json_parser_get_root(parser);
316
317         // dirname
318         // basename
319         int ret = SYSTEM_SETTINGS_ERROR_NONE;
320         if (false == ss_json_ringtone_contain(root, pathval)) {
321                 // @todo : MAKE SURE THE ACTUAL FILE IS THERE ON PATHVAL(SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER)
322                 ss_json_ringtone_add(root, JSONFILE, pathval, pathval);
323                 SETTING_TRACE("pathval is : %s -- OK", pathval);
324         } else {
325                 SETTING_TRACE("pathval is duplicated : %s", pathval);
326                 ret = SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
327         }
328
329         dnameval = strdup(pathval);
330         baseval = strdup(pathval);
331         if (dnameval && baseval) {
332                 SETTING_TRACE("---> dirname is : %s ", dirname(dnameval));
333                 SETTING_TRACE("---> basename is : %s ", basename(baseval));
334         }
335         FREE(dnameval);
336         FREE(baseval);
337
338         if (parser) {
339                 g_object_unref(parser);
340                 parser = NULL;
341         }
342
343         return ret;
344 }
345
346 int system_setting_del_incoming_call_ringtone(system_settings_key_e key, void *value)
347 {
348         SETTING_TRACE_BEGIN;
349         char* pathval = (char*)value;
350 #ifdef USE_JSONFILE
351         // NOT IN USE
352         JsonParser* parser = ss_json_ringtone_open_file(JSONFILE);
353 #else
354         JsonParser* parser = ss_json_ringtone_load_from_data();
355 #endif
356         JsonNode *root = json_parser_get_root(parser);
357
358         ss_json_ringtone_remove(root, JSONFILE, pathval);
359         //void ss_json_ringtone_remove(JsonNode *root,  char* filename, char* path_to_del)
360
361         ss_json_ringtone_print(root);
362         if (parser) {
363                 g_object_unref(parser);
364                 parser = NULL;
365         }
366
367         return SYSTEM_SETTINGS_ERROR_NONE;
368 }
369
370
371 /*  LCOV_EXCL_START */
372 gint _compare_cb(gconstpointer d1, gconstpointer d2)
373 {
374         fileNodeInfo *pNode1 = (fileNodeInfo *)d1;
375         fileNodeInfo *pNode2 = (fileNodeInfo *)d2;
376
377         return strcmp(pNode1->media_name, pNode2->media_name);
378 }
379 /*  LCOV_EXCL_STOP */
380
381 /*
382  * get the RINGTONE list
383  */
384 static void _get_default_ringtones(system_settings_key_e key, system_settings_iter_cb callback, void *data)
385 {
386         SETTING_TRACE_BEGIN;
387         /*Get file list */
388         GList *filelist = NULL;
389         GList *iter;
390         fileNodeInfo *node = NULL;
391         int idx = 0;
392
393         //-----------------------------------------------------------------------------------------------------------------
394         // 1. get the default ringtone list
395         //-----------------------------------------------------------------------------------------------------------------
396         int ret = get_filelist_from_dir_path(DEF_RINGTONE_FILE_PATH, &filelist);
397         if (ret != 0) {
398                 SETTING_TRACE("Failed to get filelist, ret = %d %s", ret, DEF_RINGTONE_FILE_PATH);
399         }
400
401         filelist = g_list_sort(filelist, _compare_cb);
402
403         for (iter = filelist; iter != NULL; iter = g_list_next(iter)) {
404                 node = (fileNodeInfo *)iter->data;
405                 SETTING_TRACE("file path = (%d) : name:%s path:%s [%s]", ret, node->name, node->path, node->media_name);
406                 // @todo assert NULL check
407                 if (callback) {
408                         char temp[1024];
409                         snprintf(temp, 1024, "%s/%s", node->path, node->name);
410                         char* path = strdup(temp);
411                         bool ret = callback(idx, (void *)(path), data);
412                         if (path) {
413                                 free(path);
414                                 path = NULL;
415                         }
416                         if (ret == false) {
417                                 SETTING_TRACE("quit the iteration by return value == false : %d", ret);
418                                 break;
419                         }
420
421                 } else {
422                         SETTING_TRACE("--> system_setting_data_iterator is NULL");
423                 }
424         }
425
426         for (iter = filelist; iter != NULL; iter = g_list_next(iter)) {
427                 node = (fileNodeInfo *)iter->data;
428                 FREE(node->path);
429                 FREE(node->name);
430                 FREE(node->media_name);
431                 FREE(node);
432         }
433         g_list_free(filelist);
434         filelist = NULL;
435
436 }
437
438 static void _get_user_ringtones(system_settings_key_e key, system_settings_iter_cb callback, void *data)
439 {
440         SETTING_TRACE_BEGIN;
441
442 #ifdef USE_JSONFILE
443         // NOT IN USE
444         JsonParser* parser = ss_json_ringtone_open_file(JSONFILE);
445 #else
446         JsonParser* parser = ss_json_ringtone_load_from_data();
447 #endif
448
449         JsonNode *root = json_parser_get_root(parser);
450         int size = json_array_get_length(json_node_get_array(root));
451
452         int i = 0;
453         for (i = 0; i < size ; i++) {
454                 JsonObject *ringtone = json_array_get_object_element(json_node_get_array(root), i);
455                 char *nameval = (char *)json_object_get_string_member(ringtone, "name");
456                 char *pathval = (char *)json_object_get_string_member(ringtone, "path");
457                 SETTING_TRACE("(%s) --- (%s) \n", nameval, pathval);
458                 if (callback && pathval) {
459                         char* path = strdup(pathval);
460                         bool ret = callback(i, (void *)(path), data);
461                         if (ret == false) {
462                                 SETTING_TRACE("quit the iteration by return value == false : %d", ret);
463                                 break;
464                         }
465                         FREE(path);
466                 } else {
467                         SETTING_TRACE("--> callback is NULL");
468                 }
469         }
470
471         g_object_unref(parser);
472 }
473
474 int system_setting_list_incoming_call_ringtone(system_settings_key_e key, system_settings_iter_cb callback, void *data)
475 {
476         SETTING_TRACE_BEGIN;
477
478         _get_default_ringtones(key, callback, data);
479         //-----------------------------------------------------------------------------------------------------------------
480         // 2. get the USER ringtone list
481         //-----------------------------------------------------------------------------------------------------------------
482         _get_user_ringtones(key, callback, data);
483
484         return SYSTEM_SETTINGS_ERROR_NONE;
485 }
486
487
488 /*  LCOV_EXCL_START */
489 int system_setting_set_incoming_call_ringtone(system_settings_key_e key, void *value)
490 {
491         SETTING_TRACE_BEGIN;
492         char *vconf_value;
493         vconf_value = (char *)value;
494
495         int ret = _is_file_accessible(vconf_value);
496         if (ret == 0) {
497                 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR, vconf_value)) {
498                         return SYSTEM_SETTINGS_ERROR_IO_ERROR;
499                 }
500         } else {
501                 /* @todo add a common ret_handler */
502                 return ret;
503         }
504
505         return SYSTEM_SETTINGS_ERROR_NONE;
506 }
507 /*  LCOV_EXCL_STOP */
508
509
510 /*  LCOV_EXCL_START */
511 int system_setting_set_email_alert_ringtone(system_settings_key_e key, void *value)
512 {
513         SETTING_TRACE_BEGIN;
514         char *vconf_value;
515         vconf_value = (char *)value;
516
517         int ret = _is_file_accessible(vconf_value);
518         if (ret == 0) {
519                 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, vconf_value)) {
520                         return SYSTEM_SETTINGS_ERROR_IO_ERROR;
521                 }
522         } else {
523                 /*return SYSTEM_SETTINGS_ERROR_IO_ERROR;*/
524                 /* @todo add a common ret_handler */
525                 return ret;
526         }
527
528         return SYSTEM_SETTINGS_ERROR_NONE;
529 }
530 /*  LCOV_EXCL_STOP */
531
532 /*  LCOV_EXCL_START */
533 static bool dl_is_supported_image_type_load(char *path)
534 {
535         void *handle = NULL;
536         char *error;
537         bool ret = false;
538         bool (*image_type_check)(char *path);
539
540         handle = dlopen(SETTING_UTILS_SO_FILE_PATH,  RTLD_LAZY);
541         if (!handle) {
542                 SETTING_TRACE("ERROR!! canNOT find libsystem-settings-util.so.0.1.0");
543                 return false;
544         }
545
546         image_type_check = dlsym(handle, "__is_supported_image_type_load");
547         if ((error = dlerror()) != NULL) {
548                 SETTING_TRACE("ERROR!! canNOT find __is_supported_image_type_load function at libsystem-settings-util.so.0.1.0");
549                 if (handle)
550                         dlclose(handle);
551                 return false;
552         }
553         ret = image_type_check(path);
554         if (handle)
555                 dlclose(handle);
556         return ret;
557 }
558 /*  LCOV_EXCL_STOP */
559
560 /*  LCOV_EXCL_START */
561 static int dl_is_available_font(char *str)
562 {
563         void *handle = NULL;
564         char *error;
565         int ret = false;
566         int (*check_available_font)(char *font_name);
567
568         handle = dlopen(SETTING_UTILS_SO_FILE_PATH,  RTLD_LAZY);
569         if (!handle) {
570                 SETTING_TRACE("ERROR!! canNOT find libsystem-settings-util.so.0.1.0");
571                 return false;
572         }
573
574         check_available_font = dlsym(handle, "__is_available_font");
575         if ((error = dlerror()) != NULL) {
576                 SETTING_TRACE("ERROR!! canNOT find __is_available_font function at libsystem-settings-util.so.0.1.0");
577                 if (handle)
578                         dlclose(handle);
579                 return false;
580         }
581         ret = check_available_font(str);
582         if (handle)
583                 dlclose(handle);
584         return ret;
585 }
586 /*  LCOV_EXCL_STOP */
587
588 /*  LCOV_EXCL_START */
589 static void dl_font_size_set()
590 {
591         void *handle = NULL;
592         char *error;
593         void (*set_font_size)();
594
595         handle = dlopen(SETTING_UTILS_SO_FILE_PATH,  RTLD_LAZY);
596         if (!handle) {
597                 SETTING_TRACE("ERROR!! canNOT find libsystem-settings-util.so.0.1.0");
598                 return;
599         }
600
601         set_font_size = dlsym(handle, "__font_size_set");
602         if ((error = dlerror()) != NULL) {
603                 SETTING_TRACE("ERROR!! canNOT find __font_size_set function at libsystem-settings-util.so.0.1.0");
604                 if (handle)
605                         dlclose(handle);
606                 return;
607         }
608         set_font_size();
609         if (handle)
610                 dlclose(handle);
611         return;
612 }
613 /*  LCOV_EXCL_STOP */
614
615 /*  LCOV_EXCL_START */
616 static void dl_font_config_set_notification()
617 {
618         void *handle = NULL;
619         char *error;
620         void (*set_font_nodification)();
621
622         handle = dlopen(SETTING_UTILS_SO_FILE_PATH,  RTLD_LAZY);
623         if (!handle) {
624                 SETTING_TRACE("ERROR!! canNOT find libsystem-settings-util.so.0.1.0");
625                 return;
626         }
627
628         set_font_nodification = dlsym(handle, "font_config_set_notification");
629         if ((error = dlerror()) != NULL) {
630                 SETTING_TRACE("ERROR!! canNOT find font_config_set_notification function at libsystem-settings-util.so.0.1.0");
631                 if (handle)
632                         dlclose(handle);
633                 return;
634         }
635         set_font_nodification();
636         if (handle)
637                 dlclose(handle);
638         return;
639 }
640 /*  LCOV_EXCL_STOP */
641
642 /*  LCOV_EXCL_START */
643 static bool dl_font_config_set(char *font_name)
644 {
645         void *handle = NULL;
646         char *error;
647         bool ret = false;
648         bool (*check_font_type)(char *font_name);
649
650         handle = dlopen(SETTING_UTILS_SO_FILE_PATH,  RTLD_LAZY);
651         if (!handle) {
652                 SETTING_TRACE("ERROR!! canNOT find libsystem-settings-util.so.0.1.0");
653                 return false;
654         }
655
656         check_font_type = dlsym(handle, "font_config_set");
657         if ((error = dlerror()) != NULL) {
658                 SETTING_TRACE("ERROR!! canNOT find font_config_set function at libsystem-settings-util.so.0.1.0");
659                 if (handle)
660                         dlclose(handle);
661                 return false;
662         }
663         ret = check_font_type(font_name);
664         if (handle)
665                 dlclose(handle);
666         return ret;
667 }
668 /*  LCOV_EXCL_STOP */
669
670 /*  LCOV_EXCL_START */
671 static char *dl_get_default_font_info()
672 {
673         void *handle = NULL;
674         char *error;
675         char *ret = NULL;
676         char *(*get_font_info)();
677
678         handle = dlopen(SETTING_UTILS_SO_FILE_PATH,  RTLD_LAZY);
679         if (!handle) {
680                 SETTING_TRACE("ERROR!! canNOT find libsystem-settings-util.so.0.1.0");
681                 return false;
682         }
683
684         get_font_info = dlsym(handle, "_get_default_font");
685
686         if ((error = dlerror()) != NULL) {
687                 SETTING_TRACE("ERROR!! canNOT find _get_default_font function at libsystem-settings-util.so.0.1.0");
688                 if (handle)
689                         dlclose(handle);
690                 return false;
691         }
692         ret = get_font_info();
693         if (handle)
694                 dlclose(handle);
695         return ret;
696 }
697 /*  LCOV_EXCL_STOP */
698
699 #ifdef TIZEN_WEARABLE
700 /*  LCOV_EXCL_START */
701 static int system_setting_get_extended_wallpaper_num(const char *file_path, unsigned int *num)
702 {
703         SETTING_TRACE_BEGIN;
704         char buffer[256];
705         const char *find_str = "extended_wallpaper_";
706         char *ch = NULL;
707
708         if (!(ch = strstr(file_path, find_str))) {
709                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
710         }
711         strncpy(buffer, file_path, ch - file_path);
712         buffer[ch - file_path] = 0;
713         sprintf(buffer + (ch - file_path), "%s%s", "", ch + strlen(find_str));
714
715         if (!isdigit(buffer[0])) {
716                 SETTING_TRACE("%s is not number", buffer);
717                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
718         }
719
720         *num = atoi(buffer);
721
722         return SYSTEM_SETTINGS_ERROR_NONE;
723 }
724 /*  LCOV_EXCL_STOP */
725
726 /*  LCOV_EXCL_START */
727 static int system_setting_copy_extended_wallpaper(const char *dest_file_path, const char *source_file_path)
728 {
729         SETTING_TRACE_BEGIN;
730         if (!source_file_path || !dest_file_path) {
731                 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
732         }
733
734         char buf[1024];
735
736         int fd;
737         fd = open(source_file_path, O_RDONLY);
738         if (fd < 0) {
739                 SETTING_TRACE("file open failed: %s", source_file_path);
740                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
741         }
742
743         int fd2;
744         fd2 = open(dest_file_path, O_WRONLY | O_CREAT, S_IRWXU | S_IRWXG | S_IRWXO);
745         if (fd2 < 0) {
746                 SETTING_TRACE("file creation failed: %s", dest_file_path);
747                 close(fd);
748                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
749         }
750
751         while (read(fd, buf, sizeof(buf) - 1) > 0) {
752                 write(fd2, buf, sizeof(buf) - 1);
753         }
754
755         close(fd2);
756         close(fd);
757
758         if (chmod(dest_file_path, S_IRWXU | S_IRWXG | S_IRWXO) < 0) {
759                 SETTING_TRACE("chmod failed: %s", dest_file_path);
760         }
761
762         return SYSTEM_SETTINGS_ERROR_NONE;
763 }
764 /*  LCOV_EXCL_STOP */
765
766 /*  LCOV_EXCL_START */
767 static int system_setting_remove_oldest_extended_wallpaper()
768 {
769         SETTING_TRACE_BEGIN;
770         DIR *dp;
771         struct dirent *dirp;
772         char *min_image_name = NULL;
773         unsigned int min_image_num = 0;
774         unsigned int temp_image_num = 0;
775         int image_count = 0;
776
777         if ((dp = opendir(_TZ_SYS_DATA"/setting/wallpaper")) == NULL) {
778                 SETTING_TRACE("opendir error");
779                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
780         }
781
782         while ((dirp = readdir(dp))) {
783                 if (!strcmp(dirp->d_name, ".") || !strcmp(dirp->d_name, ".."))
784                         continue;
785
786                 if (system_setting_get_extended_wallpaper_num(dirp->d_name, &temp_image_num)
787                     != SYSTEM_SETTINGS_ERROR_NONE) {
788                         return SYSTEM_SETTINGS_ERROR_IO_ERROR;
789                 }
790
791                 if ((image_count == 0) || (min_image_num > temp_image_num)) {
792                         min_image_num = temp_image_num;
793                         min_image_name = dirp->d_name;
794                 }
795
796                 image_count++;
797         }
798
799         char buf[512];
800         if (min_image_name) {
801                 snprintf(buf, sizeof(buf) - 1, _TZ_SYS_DATA"/setting/wallpaper/%s", min_image_name);
802                 if (remove(buf) < 0) {  /* remove oldest image */
803                         return SYSTEM_SETTINGS_ERROR_IO_ERROR;
804                 }
805         }
806
807         return SYSTEM_SETTINGS_ERROR_NONE;
808 }
809 /*  LCOV_EXCL_STOP */
810
811 /*  LCOV_EXCL_START */
812 static int system_setting_check_extended_wallpaper(const char *file_path)
813 {
814         char buffer[512];
815         SETTING_TRACE_BEGIN;
816         if (!file_path || !strlen(file_path))
817                 return 0;
818         snprintf(buffer, 512, "%s/.bgwallpaper", tzplatform_getenv(TZ_USER_CONTENT));
819         return (strstr(file_path, buffer) != NULL);
820 }
821 /*  LCOV_EXCL_STOP */
822
823 #define WALLPAPER_MAX_COUNT             10
824 #endif
825 /*  LCOV_EXCL_START */
826 int system_setting_set_wallpaper_home_screen(system_settings_key_e key, void *value)
827 {
828         SETTING_TRACE_BEGIN;
829         char *vconf_value;
830         vconf_value = (char *)value;
831
832         bool isok  = dl_is_supported_image_type_load(vconf_value);
833         if (!isok) {
834                 /* not supported */
835                 SETTING_TRACE("path : %s is not supported file format", vconf_value);
836                 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
837         } else {
838                 SETTING_TRACE("path : %s is SUPPORT file format", vconf_value);
839         }
840
841         /* error handling here */
842         if (_is_file_accessible(vconf_value) != 0)
843                 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
844 #ifdef TIZEN_MOBILE
845         if (system_setting_vconf_set_value_string(VCONFKEY_BGSET, vconf_value)) {
846                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
847         }
848 #endif
849
850 #ifdef TIZEN_WEARABLE
851         if (system_setting_check_extended_wallpaper(vconf_value)) {     /* New extended wallpaper */
852                 DIR *dp = NULL;
853                 struct dirent *dirp;
854                 unsigned int max_image_num = 0;
855                 unsigned int temp_image_num = 0;
856                 int image_count = 0;
857
858                 if ((dp = opendir(_TZ_SYS_DATA"/setting/wallpaper")) == NULL) {
859                         SETTING_TRACE("Setting - dir open error!");
860                         return SYSTEM_SETTINGS_ERROR_IO_ERROR;
861                 }
862
863                 /* Check a max number of wallpapers */
864                 while ((dirp = readdir(dp))) {
865                         if (!strcmp(dirp->d_name, ".") || !strcmp(dirp->d_name, ".."))
866                                 continue;
867
868                         if (system_setting_get_extended_wallpaper_num(dirp->d_name, &temp_image_num)
869                             != SYSTEM_SETTINGS_ERROR_NONE) {
870                                 if (dp)
871                                         closedir(dp);
872                                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
873                         }
874
875                         if ((image_count == 0) || (max_image_num < temp_image_num)) {
876                                 max_image_num = temp_image_num;
877                         }
878
879                         image_count++;
880                 }
881                 if (dp)
882                         closedir(dp);
883
884                 /* Numbering rule: Gear is odd number */
885                 max_image_num = (max_image_num % 2 == 0) ? max_image_num + 1
886                                                         : max_image_num + 2;
887
888                 char file_name_buffer[512];
889                 snprintf(file_name_buffer, sizeof(file_name_buffer) - 1,
890                                         _TZ_SYS_DATA"/setting/wallpaper/extended_wallpaper_%d.jpg", max_image_num);
891
892                 /* Copy image to _TZ_SYS_DATA/setting/wallpaper/ */
893                 if (system_setting_copy_extended_wallpaper(file_name_buffer, vconf_value)
894                     != SYSTEM_SETTINGS_ERROR_NONE) {
895                         return SYSTEM_SETTINGS_ERROR_IO_ERROR;
896                 }
897
898                 /* remove oldest wallpaper */
899                 if (image_count >= WALLPAPER_MAX_COUNT) {
900                         if (system_setting_remove_oldest_extended_wallpaper()
901                             != SYSTEM_SETTINGS_ERROR_NONE) {
902                                 remove(file_name_buffer);
903                                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
904                         }
905                 }
906
907                 if (system_setting_vconf_set_value_string(VCONFKEY_BGSET, file_name_buffer)) {
908                         return SYSTEM_SETTINGS_ERROR_IO_ERROR;
909                 }
910
911                 if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_WALLPAPER_CHANGED_NOTI_INT,
912                                                                                                         VCONFKEY_WALLPAPER_CHANGED_NOTI_GEAR)) {
913                         return SYSTEM_SETTINGS_ERROR_IO_ERROR;
914                 }
915         } else {
916                 if (system_setting_vconf_set_value_string(VCONFKEY_BGSET, vconf_value)) {
917                         return SYSTEM_SETTINGS_ERROR_IO_ERROR;
918                 }
919         }
920 #endif
921
922         return SYSTEM_SETTINGS_ERROR_NONE;
923 }
924 /*  LCOV_EXCL_STOP */
925
926 /*  LCOV_EXCL_START */
927 int system_setting_set_wallpaper_lock_screen(system_settings_key_e key, void *value)
928 {
929         SETTING_TRACE_BEGIN;
930         char *vconf_value;
931         vconf_value = (char *)value;
932
933         bool isok  = dl_is_supported_image_type_load(vconf_value);
934         if (!isok) {
935                 /* not supported */
936                 SETTING_TRACE("path : %s is not supported file format", vconf_value);
937                 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
938         } else {
939                 SETTING_TRACE("path : %s is SUPPORT file format", vconf_value);
940         }
941
942         /* error handling here */
943         if (_is_file_accessible(vconf_value) != 0)
944                 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
945
946         if (system_setting_vconf_set_value_string(VCONFKEY_IDLE_LOCK_BGSET, vconf_value)) {
947                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
948         }
949
950         return SYSTEM_SETTINGS_ERROR_NONE;
951 }
952 /*  LCOV_EXCL_STOP */
953
954 /*  LCOV_EXCL_START */
955 int system_setting_set_font_size(system_settings_key_e key, void *value)
956 {
957         SETTING_TRACE_BEGIN;
958         int *vconf_value;
959         vconf_value = *(int **)value;
960
961         if (*vconf_value < 0 || *vconf_value > SYSTEM_SETTINGS_FONT_SIZE_GIANT) {
962                 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
963         }
964
965         if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, *vconf_value)) {
966                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
967         }
968         dl_font_size_set();
969         SETTING_TRACE_END;
970         return SYSTEM_SETTINGS_ERROR_NONE;
971 }
972 /*  LCOV_EXCL_STOP */
973 /**
974  * [internal API]
975  */
976 /*  LCOV_EXCL_START */
977 void *font_conf_doc_parse(char *doc_name, char *font_name)
978 {
979         SETTING_TRACE_BEGIN;
980         xmlDocPtr doc = NULL;
981         xmlNodePtr cur = NULL;
982         xmlNodePtr cur2 = NULL;
983         xmlNodePtr cur3 = NULL;
984         xmlChar *key = NULL;
985
986         doc = xmlParseFile(doc_name);
987
988         cur = xmlDocGetRootElement(doc);
989
990         if (cur == NULL) {
991                 xmlFreeDoc(doc);
992                 doc = NULL;
993                 return NULL;
994         }
995
996         if (xmlStrcmp(cur->name, (const xmlChar *)"fontconfig")) {
997                 xmlFreeDoc(doc);
998                 doc = NULL;
999                 return NULL;
1000         }
1001
1002         cur = cur->xmlChildrenNode;
1003
1004         bool is_changed = false;
1005         while (cur != NULL) {
1006                 if ((!xmlStrcmp(cur->name, (const xmlChar *)"match"))) {
1007                         cur2 = cur->xmlChildrenNode;
1008                         while (cur2 != NULL) {
1009                                 if ((!xmlStrcmp(cur2->name, (const xmlChar *)"edit"))) {
1010                                         xmlChar *name = xmlGetProp(cur2, (const xmlChar *)"name");
1011                                         /* if name is not 'family', break */
1012                                         if (xmlStrcmp(name, (const xmlChar *)"family")) {
1013                                                 xmlFree(name);
1014                                                 name = NULL;
1015                                                 break;
1016                                         }
1017                                         xmlFree(name);
1018                                         name = NULL;
1019
1020                                         cur3 = cur2->xmlChildrenNode;
1021                                         while (cur3 != NULL) {
1022                                                 if ((!xmlStrcmp(cur3->name, (const xmlChar *)"string"))) {
1023                                                         xmlNodeSetContent(cur3->xmlChildrenNode, (const xmlChar *)font_name);
1024                                                         key = xmlNodeListGetString(doc, cur3->xmlChildrenNode, 1);
1025                                                         xmlFree(key);
1026                                                         key = NULL;
1027                                                         is_changed = true;
1028                                                 }
1029                                                 cur3 = cur3->next;
1030                                         }
1031                                 }
1032                                 cur2 = cur2->next;
1033                         }
1034                 } else if ((!xmlStrcmp(cur->name, (const xmlChar *)"alias"))) {
1035                         cur2 = cur->xmlChildrenNode;
1036                         while (cur2 != NULL) {
1037                                 if ((!xmlStrcmp(cur2->name, (const xmlChar *)"family"))) {
1038                                         xmlNodeSetContent(cur2->xmlChildrenNode, (const xmlChar *)font_name);
1039                                         key = xmlNodeListGetString(doc, cur2->xmlChildrenNode, 1);
1040                                         xmlFree(key);
1041                                         key = NULL;
1042                                         is_changed = true;
1043                                 } else if ((!xmlStrcmp(cur2->name, (const xmlChar *)"prefer"))) {
1044                                         cur3 = cur2->xmlChildrenNode;
1045                                         while (cur3 != NULL) {
1046                                                 if ((!xmlStrcmp(cur3->name, (const xmlChar *)"family"))) {
1047                                                         xmlNodeSetContent(cur3->xmlChildrenNode, (const xmlChar *)font_name);
1048                                                         key = xmlNodeListGetString(doc, cur3->xmlChildrenNode, 1);
1049                                                         xmlFree(key);
1050                                                         key = NULL;
1051                                                         is_changed = true;
1052                                                         cur3 = cur3->next;
1053                                                         return doc;
1054                                                 }
1055                                                 cur3 = cur3->next;
1056                                         }
1057                                 }
1058                                 cur2 = cur2->next;
1059                         }
1060                 }
1061                 cur = cur->next;
1062         }
1063
1064         if (is_changed) {
1065                 return doc;
1066         } else {
1067                 xmlFreeDoc(doc);
1068                 doc = NULL;
1069                 return NULL;
1070         }
1071 }
1072 /*  LCOV_EXCL_STOP */
1073
1074 /*  LCOV_EXCL_START */
1075 int system_setting_set_font_type(system_settings_key_e key, void *value)
1076 {
1077         SETTING_TRACE_BEGIN;
1078         char *font_name = NULL;
1079         font_name = (char *)value;
1080
1081         /* get current font list */
1082         int is_found = dl_is_available_font(font_name);
1083
1084         if (is_found == 1) {
1085                 SETTING_TRACE("found font : %s ", font_name);
1086         } else {
1087                 SETTING_TRACE(" NOT found font : %s ", font_name);
1088                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1089         }
1090
1091         bool bsave = dl_font_config_set(font_name);
1092
1093         if (!bsave) {
1094                 SETTING_TRACE(" font type save error by font_config_set() ");
1095                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1096         } else {
1097                 SETTING_TRACE(" save OK - font_config_set() ");
1098         }
1099
1100         xmlDocPtr doc = (xmlDocPtr)font_conf_doc_parse(SETTING_FONT_CONF_FILE, font_name);
1101         if (doc != NULL) {
1102                 xmlSaveFormatFile(SETTING_FONT_CONF_FILE, doc, 0);
1103                 xmlFreeDoc(doc);
1104                 doc = NULL;
1105         }
1106
1107         dl_font_config_set_notification();
1108
1109         char *vconf_value;
1110         vconf_value = (char *)value;
1111
1112         if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, vconf_value)) {
1113                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1114         }
1115         return SYSTEM_SETTINGS_ERROR_NONE;
1116 }
1117 /*  LCOV_EXCL_STOP */
1118
1119 /*  LCOV_EXCL_START */
1120 int system_setting_set_motion_activation(system_settings_key_e key, void *value)
1121 {
1122         SETTING_TRACE_BEGIN;
1123         bool *vconf_value;
1124         vconf_value = (bool *)value;
1125         if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_MOTION_ACTIVATION, *vconf_value)) {
1126                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1127         }
1128         return SYSTEM_SETTINGS_ERROR_NONE;
1129 }
1130 /*  LCOV_EXCL_STOP */
1131
1132 /*  LCOV_EXCL_START */
1133 int system_setting_set_usb_debugging_option(system_settings_key_e key, void *value)
1134 {
1135         SETTING_TRACE_BEGIN;
1136         bool *vconf_value;
1137         vconf_value = (bool *)value;
1138         if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_USB_DEBUG_MODE_BOOL, *vconf_value)) {
1139                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1140         }
1141         return SYSTEM_SETTINGS_ERROR_NONE;
1142
1143 }
1144 /*  LCOV_EXCL_STOP */
1145
1146 /*  LCOV_EXCL_START */
1147 int system_setting_set_3g_data_network(system_settings_key_e key, void *value)
1148 {
1149         SETTING_TRACE_BEGIN;
1150         bool *vconf_value;
1151         vconf_value = (bool *)value;
1152         if (system_setting_vconf_set_value_bool(VCONFKEY_3G_ENABLE, *vconf_value)) {
1153                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1154         }
1155
1156         return SYSTEM_SETTINGS_ERROR_NONE;
1157 }
1158 /*  LCOV_EXCL_STOP */
1159
1160 /*  LCOV_EXCL_START */
1161 static int category_func(const char *name, void *user_data)
1162 {
1163         SETTING_TRACE_BEGIN;
1164         static char *category = "lock-screen";
1165         if (name && !strcmp(name, category)) {
1166                 SETTING_TRACE(" SAME ");
1167                 return -1;
1168         } else {
1169                 SETTING_TRACE(" DIFFERENT -- %s, category -- %s ", name, category);
1170                 return 0;
1171         }
1172
1173         return 0;
1174 }
1175 /*  LCOV_EXCL_STOP */
1176
1177 /**
1178  *
1179  * set 'swipe type' if current lockscreen app is 'com.samsung.lockscreen'
1180  *
1181  */
1182
1183 /*  LCOV_EXCL_START */
1184 int system_setting_set_lockscreen_app(system_settings_key_e key, void *value)
1185 {
1186         SETTING_TRACE_BEGIN;
1187         char *vconf_value;
1188         vconf_value = (char *)value;            /* ex) com.samsung.lockscreen */
1189
1190         int r = 0;
1191         pkgmgrinfo_appinfo_h handle;
1192         r = pkgmgrinfo_appinfo_get_appinfo(vconf_value, &handle);
1193         if (r != PMINFO_R_OK) {
1194                 SETTING_TRACE("*** pkginfo failed ");
1195                 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
1196         } else {
1197                 SETTING_TRACE("%p", handle);
1198         }
1199
1200         int ret = pkgmgrinfo_appinfo_foreach_category(handle, category_func, (void *)"lock-screen");
1201         if (ret != PMINFO_R_OK) {
1202                 pkgmgrinfo_appinfo_destroy_appinfo(handle);
1203                 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
1204         }
1205
1206         pkgmgrinfo_appinfo_destroy_appinfo(handle);
1207         /*----------------------------------------------------------------------------------- */
1208         int locktype = -1;
1209         if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_SCREEN_LOCK_TYPE_INT, &locktype)) {
1210                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1211         }
1212
1213         if (locktype == SETTING_SCREEN_LOCK_TYPE_PASSWORD)
1214                 return SYSTEM_SETTINGS_ERROR_LOCKSCREEN_APP_PASSWORD_MODE;
1215
1216         if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_3RD_LOCK_PKG_NAME_STR, vconf_value)) {
1217                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1218         }
1219
1220         if (vconf_value && strcmp(vconf_value, "com.samsung.lockscreen") == 0) {
1221                 if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_SCREEN_LOCK_TYPE_INT, SETTING_SCREEN_LOCK_TYPE_SWIPE)) {
1222                         return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1223                 }
1224         }
1225         return SYSTEM_SETTINGS_ERROR_NONE;
1226 }
1227 /*  LCOV_EXCL_STOP */
1228
1229 /*/////////////////////////////////////////////////////////////////////////////////////////////// */
1230 /* */
1231
1232 int system_setting_set_changed_callback_incoming_call_ringtone(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1233 {
1234         SETTING_TRACE_BEGIN;
1235         return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR, SYSTEM_SETTINGS_KEY_INCOMING_CALL_RINGTONE, SYSTEM_SETTING_CALLBACK_SLOT_0, user_data);
1236 }
1237
1238 int system_setting_unset_changed_callback_incoming_call_ringtone(system_settings_key_e key)
1239 {
1240         SETTING_TRACE_BEGIN;
1241         return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR, SYSTEM_SETTING_CALLBACK_SLOT_0);
1242 }
1243
1244 int system_setting_set_changed_callback_email_alert_ringtone(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1245 {
1246         SETTING_TRACE_BEGIN;
1247         return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, SYSTEM_SETTINGS_KEY_EMAIL_ALERT_RINGTONE, SYSTEM_SETTING_CALLBACK_SLOT_0, user_data);
1248 }
1249
1250 int system_setting_unset_changed_callback_email_alert_ringtone(system_settings_key_e key)
1251 {
1252         SETTING_TRACE_BEGIN;
1253         return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, SYSTEM_SETTING_CALLBACK_SLOT_0);
1254 }
1255
1256 int system_setting_set_changed_callback_wallpaper_home_screen(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1257 {
1258         SETTING_TRACE_BEGIN;
1259         return system_setting_vconf_set_changed_cb(VCONFKEY_BGSET, SYSTEM_SETTINGS_KEY_WALLPAPER_HOME_SCREEN, SYSTEM_SETTING_CALLBACK_SLOT_0, user_data);
1260 }
1261
1262 int system_setting_unset_changed_callback_wallpaper_home_screen(system_settings_key_e key)
1263 {
1264         SETTING_TRACE_BEGIN;
1265         return system_setting_vconf_unset_changed_cb(VCONFKEY_BGSET, SYSTEM_SETTING_CALLBACK_SLOT_0);
1266 }
1267
1268 int system_setting_set_changed_callback_wallpaper_lock_screen(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1269 {
1270         SETTING_TRACE_BEGIN;
1271         return system_setting_vconf_set_changed_cb(VCONFKEY_IDLE_LOCK_BGSET, SYSTEM_SETTINGS_KEY_WALLPAPER_LOCK_SCREEN, SYSTEM_SETTING_CALLBACK_SLOT_0, user_data);
1272 }
1273
1274 int system_setting_unset_changed_callback_wallpaper_lock_screen(system_settings_key_e key)
1275 {
1276         SETTING_TRACE_BEGIN;
1277         return system_setting_vconf_unset_changed_cb(VCONFKEY_IDLE_LOCK_BGSET, SYSTEM_SETTING_CALLBACK_SLOT_0);
1278 }
1279
1280 int system_setting_set_changed_callback_font_size(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1281 {
1282         SETTING_TRACE_BEGIN;
1283         return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, SYSTEM_SETTINGS_KEY_FONT_SIZE, SYSTEM_SETTING_CALLBACK_SLOT_1, user_data);
1284 }
1285
1286 int system_setting_unset_changed_callback_font_size(system_settings_key_e key)
1287 {
1288         SETTING_TRACE_BEGIN;
1289         return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, SYSTEM_SETTING_CALLBACK_SLOT_1);
1290 }
1291
1292 int system_setting_set_changed_callback_usb_debugging_option(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1293 {
1294         SETTING_TRACE_BEGIN;
1295         return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_USB_DEBUG_MODE_BOOL, SYSTEM_SETTINGS_KEY_USB_DEBUGGING_ENABLED, SYSTEM_SETTING_CALLBACK_SLOT_1, user_data);
1296 }
1297
1298 int system_setting_unset_changed_callback_usb_debugging_option(system_settings_key_e key)
1299 {
1300         SETTING_TRACE_BEGIN;
1301         return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_USB_DEBUG_MODE_BOOL, SYSTEM_SETTING_CALLBACK_SLOT_1);
1302 }
1303
1304 int system_setting_set_changed_callback_3g_data_network(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1305 {
1306         SETTING_TRACE_BEGIN;
1307         return system_setting_vconf_set_changed_cb(VCONFKEY_3G_ENABLE, SYSTEM_SETTINGS_KEY_3G_DATA_NETWORK_ENABLED, SYSTEM_SETTING_CALLBACK_SLOT_1, user_data);
1308 }
1309
1310 int system_setting_unset_changed_callback_3g_data_network(system_settings_key_e key)
1311 {
1312         SETTING_TRACE_BEGIN;
1313         return system_setting_vconf_unset_changed_cb(VCONFKEY_3G_ENABLE, SYSTEM_SETTING_CALLBACK_SLOT_1);
1314 }
1315
1316 int system_setting_set_changed_callback_lockscreen_app(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1317 {
1318         SETTING_TRACE_BEGIN;
1319         return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_3RD_LOCK_PKG_NAME_STR, SYSTEM_SETTINGS_KEY_LOCKSCREEN_APP, SYSTEM_SETTING_CALLBACK_SLOT_1, user_data);
1320 }
1321
1322 int system_setting_unset_changed_callback_lockscreen_app(system_settings_key_e key)
1323 {
1324         SETTING_TRACE_BEGIN;
1325         return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_3RD_LOCK_PKG_NAME_STR, SYSTEM_SETTING_CALLBACK_SLOT_1);
1326 }
1327
1328
1329 /**
1330  * @todo need to add custom event notification method
1331  */
1332 int system_setting_set_changed_callback_font_type(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1333 {
1334         SETTING_TRACE_BEGIN;
1335         return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, SYSTEM_SETTINGS_KEY_FONT_TYPE, SYSTEM_SETTING_CALLBACK_SLOT_2, user_data);
1336 }
1337
1338 int system_setting_unset_changed_callback_font_type(system_settings_key_e key)
1339 {
1340         SETTING_TRACE_BEGIN;
1341         return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, SYSTEM_SETTING_CALLBACK_SLOT_2);
1342 }
1343
1344 /* TODO : 2th argument, callback, is not in use. */
1345 int system_setting_set_changed_callback_motion_activation(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1346 {
1347         SETTING_TRACE_BEGIN;
1348         return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_MOTION_ACTIVATION, SYSTEM_SETTINGS_KEY_MOTION_ACTIVATION, SYSTEM_SETTING_CALLBACK_SLOT_3, user_data);
1349 }
1350
1351 int system_setting_unset_changed_callback_motion_activation(system_settings_key_e key)
1352 {
1353         SETTING_TRACE_BEGIN;
1354         return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_MOTION_ACTIVATION, SYSTEM_SETTING_CALLBACK_SLOT_3);
1355 }
1356
1357 /*//////////////////////////////////////////////////////////////////////////////////////// */
1358 /*--------------------------------------- */
1359 int system_setting_get_locale_country(system_settings_key_e key, void **value)
1360 {
1361         SETTING_TRACE_BEGIN;
1362         char *vconf_value = NULL;
1363         if (system_setting_vconf_get_value_string(VCONFKEY_REGIONFORMAT, &vconf_value)) {
1364                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1365         }
1366
1367         /* parsing validation */
1368         /* en_US.UTF-8 */
1369         char arr[21] = {0,};
1370         snprintf(arr, 20, "%s", vconf_value);
1371         for (int i = 0; i < strlen(arr); i++) {
1372                 if ('.' == arr[i]) {
1373                         arr[i] = 0;
1374                         SETTING_TRACE("replace . to NULL : %d", i);
1375                         break;
1376                 }
1377         }
1378         *value = strdup(arr);
1379         free(vconf_value);
1380         vconf_value = NULL;
1381
1382         return SYSTEM_SETTINGS_ERROR_NONE;
1383 }
1384
1385 /*  LCOV_EXCL_START */
1386 int system_setting_set_locale_country(system_settings_key_e key, void *value)
1387 {
1388         SETTING_TRACE_BEGIN;
1389         char *vconf_value = NULL;
1390         vconf_value = (char *)value;
1391
1392         char *ext = "UTF-8";
1393
1394         char arr[20];
1395         snprintf(arr, 20, "%s.%s", vconf_value, ext);
1396
1397         if (system_setting_vconf_set_value_string(VCONFKEY_REGIONFORMAT, arr)) {
1398                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1399         }
1400         return SYSTEM_SETTINGS_ERROR_NONE;
1401 }
1402 /*  LCOV_EXCL_STOP */
1403
1404 int system_setting_set_changed_callback_locale_country(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1405 {
1406         SETTING_TRACE_BEGIN;
1407         return system_setting_vconf_set_changed_cb(VCONFKEY_REGIONFORMAT, SYSTEM_SETTINGS_KEY_LOCALE_COUNTRY, SYSTEM_SETTING_CALLBACK_SLOT_3, user_data);
1408 }
1409
1410 int system_setting_unset_changed_callback_locale_country(system_settings_key_e key)
1411 {
1412         SETTING_TRACE_BEGIN;
1413         return system_setting_vconf_unset_changed_cb(VCONFKEY_REGIONFORMAT, SYSTEM_SETTING_CALLBACK_SLOT_3);
1414 }
1415
1416
1417 /*--------------------------------------- */
1418 int system_setting_get_locale_language(system_settings_key_e key, void **value)
1419 {
1420         SETTING_TRACE_BEGIN;
1421         char *vconf_value = NULL;
1422         if (system_setting_vconf_get_value_string(VCONFKEY_LANGSET, &vconf_value)) {
1423                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1424         }
1425
1426         /* parsing validation */
1427         /* en_US.UTF-8 */
1428         char arr[21] = {0,};
1429         snprintf(arr, 20, "%s", vconf_value);
1430         for (int i = 0; i < strlen(arr); i++) {
1431                 if ('.' == arr[i]) {
1432                         arr[i] = 0;
1433                         SETTING_TRACE("replace . to NULL : %d", i);
1434                         break;
1435                 }
1436         }
1437         *value = strdup(arr);
1438         free(vconf_value);
1439         vconf_value = NULL;
1440         return SYSTEM_SETTINGS_ERROR_NONE;
1441 }
1442
1443 /*  LCOV_EXCL_START */
1444 int system_setting_set_locale_language(system_settings_key_e key, void *value)
1445 {
1446         SETTING_TRACE_BEGIN;
1447         char *vconf_value = NULL;
1448         vconf_value = (char *)value;
1449
1450         char *ext = "UTF-8";
1451
1452         char arr[20];
1453         snprintf(arr, 20, "%s.%s", vconf_value, ext);
1454
1455         if (system_setting_vconf_set_value_string(VCONFKEY_LANGSET, arr)) {
1456                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1457         }
1458         return SYSTEM_SETTINGS_ERROR_NONE;
1459 }
1460 /*  LCOV_EXCL_STOP */
1461
1462 int system_setting_set_changed_callback_locale_language(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1463 {
1464         SETTING_TRACE_BEGIN;
1465         /*return system_setting_vconf_set_changed_cb(VCONFKEY_LANGSET, SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, 3, user_data ); */
1466         return system_setting_vconf_set_changed_cb(VCONFKEY_LANGSET, SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, SYSTEM_SETTING_CALLBACK_SLOT_5, user_data);
1467 }
1468
1469 int system_setting_unset_changed_callback_locale_language(system_settings_key_e key)
1470 {
1471         SETTING_TRACE_BEGIN;
1472         return system_setting_vconf_unset_changed_cb(VCONFKEY_LANGSET, SYSTEM_SETTING_CALLBACK_SLOT_5);
1473 }
1474
1475 /*--------------------------------------- */
1476 /*  LCOV_EXCL_START */
1477 int system_setting_get_locale_timeformat_24hour(system_settings_key_e key, void **value)
1478 {
1479         SETTING_TRACE_BEGIN;
1480         int vconf_value;
1481
1482         if (system_setting_vconf_get_value_int(VCONFKEY_REGIONFORMAT_TIME1224, &vconf_value)) {
1483                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1484         }
1485
1486         bool ret_value = true;
1487         if (vconf_value == VCONFKEY_TIME_FORMAT_12)
1488                 ret_value = false;
1489         else if (vconf_value == VCONFKEY_TIME_FORMAT_24)
1490                 ret_value = true;
1491
1492         *value = (void *)ret_value;
1493
1494         return SYSTEM_SETTINGS_ERROR_NONE;
1495 }
1496 /*  LCOV_EXCL_STOP */
1497
1498 int system_setting_set_locale_timeformat_24hour(system_settings_key_e key, void *value)
1499 {
1500         SETTING_TRACE_BEGIN;
1501         bool *vconf_value;
1502
1503         vconf_value = (bool *)value;
1504
1505         if (*vconf_value) {
1506                 if (system_setting_vconf_set_value_int(VCONFKEY_REGIONFORMAT_TIME1224, VCONFKEY_TIME_FORMAT_24)) {
1507                         return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1508                 }
1509
1510         } else {
1511                 if (system_setting_vconf_set_value_int(VCONFKEY_REGIONFORMAT_TIME1224, VCONFKEY_TIME_FORMAT_12)) {
1512                         return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1513                 }
1514
1515         }
1516
1517         return SYSTEM_SETTINGS_ERROR_NONE;
1518 }
1519
1520 int system_setting_set_changed_callback_locale_timeformat_24hour(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1521 {
1522         SETTING_TRACE_BEGIN;
1523         return system_setting_vconf_set_changed_cb(VCONFKEY_REGIONFORMAT_TIME1224, SYSTEM_SETTINGS_KEY_LOCALE_TIMEFORMAT_24HOUR, SYSTEM_SETTING_CALLBACK_SLOT_3, user_data);
1524 }
1525
1526 int system_setting_unset_changed_callback_locale_timeformat_24hour(system_settings_key_e key)
1527 {
1528         SETTING_TRACE_BEGIN;
1529         return system_setting_vconf_unset_changed_cb(VCONFKEY_REGIONFORMAT_TIME1224, SYSTEM_SETTING_CALLBACK_SLOT_3);
1530 }
1531
1532 int system_setting_get_locale_timezone(system_settings_key_e key, void **value)
1533 {
1534         char tzpath[256];
1535         ssize_t len = readlink(SETTING_TZONE_SYMLINK_PATH, tzpath, sizeof(tzpath)-1);
1536         if (len != -1) {
1537                 tzpath[len] = '\0';
1538         } else {
1539                 SETTING_TRACE("parse error for SETTING_TZONE_SYMLINK_PATH");
1540                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1541         }
1542
1543         SETTING_TRACE("tzpath : %s ", &tzpath[20]);
1544         *value = strdup(&tzpath[20]);
1545         return SYSTEM_SETTINGS_ERROR_NONE;
1546 }
1547
1548 /*  LCOV_EXCL_START */
1549 int system_setting_set_locale_timezone(system_settings_key_e key, void *value)
1550 {
1551         SETTING_TRACE_BEGIN;
1552         char *timezone_value = NULL;
1553         timezone_value = (char *)value;
1554
1555         char tz_path[1024];
1556         snprintf(tz_path, 1024, "/usr/share/zoneinfo/%s", timezone_value);
1557
1558         int is_load = _is_file_accessible(tz_path);
1559         if (is_load == 0) {
1560                 alarmmgr_set_timezone(tz_path);
1561
1562                 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_TIMEZONE_ID, timezone_value)) {
1563                         return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1564                 }
1565                 return SYSTEM_SETTINGS_ERROR_NONE;
1566         }
1567         return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
1568 }
1569 /*  LCOV_EXCL_STOP */
1570
1571
1572
1573 /*  LCOV_EXCL_START */
1574 int system_setting_set_changed_callback_locale_timezone(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1575 {
1576         return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_TIMEZONE_ID, SYSTEM_SETTINGS_KEY_LOCALE_TIMEZONE, SYSTEM_SETTING_CALLBACK_SLOT_4, user_data);
1577 }
1578 /*  LCOV_EXCL_STOP */
1579
1580 /*  LCOV_EXCL_START */
1581 int system_setting_unset_changed_callback_locale_timezone(system_settings_key_e key)
1582 {
1583         return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_TIMEZONE_ID, SYSTEM_SETTING_CALLBACK_SLOT_4);
1584 }
1585 /*  LCOV_EXCL_STOP */
1586
1587 /*  LCOV_EXCL_START */
1588 int system_setting_set_changed_callback_locale_timezone_changed(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1589 {
1590         SETTING_TRACE_BEGIN;
1591         return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
1592 }
1593 /*  LCOV_EXCL_STOP */
1594
1595 /*  LCOV_EXCL_START */
1596 int system_setting_unset_changed_callback_locale_timezone_changed(system_settings_key_e key)
1597 {
1598         SETTING_TRACE_BEGIN;
1599         return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
1600 }
1601 /*  LCOV_EXCL_STOP */
1602
1603
1604 /*  LCOV_EXCL_START */
1605 int system_setting_get_time_changed(system_settings_key_e key, void **value)
1606 {
1607         SETTING_TRACE_BEGIN;
1608         time_t cur_tick;
1609         int ** val = (int**)value;
1610         cur_tick = time(NULL);
1611         **val = cur_tick;
1612         /* struct tm * localtime = time (cur_tick); */
1613         /* printf("%s\n", ctime(&cur_tick); */
1614         return SYSTEM_SETTINGS_ERROR_NONE;
1615
1616 }
1617 /*  LCOV_EXCL_STOP */
1618
1619 int system_setting_set_changed_callback_time_changed(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1620 {
1621         SETTING_TRACE_BEGIN;
1622         return system_setting_vconf_set_changed_cb(VCONFKEY_SYSTEM_TIME_CHANGED, SYSTEM_SETTINGS_KEY_TIME_CHANGED, SYSTEM_SETTING_CALLBACK_SLOT_3, user_data);
1623 }
1624
1625 int system_setting_unset_changed_callback_time_changed(system_settings_key_e key)
1626 {
1627         SETTING_TRACE_BEGIN;
1628         return system_setting_vconf_unset_changed_cb(VCONFKEY_SYSTEM_TIME_CHANGED, SYSTEM_SETTING_CALLBACK_SLOT_3);
1629 }
1630
1631 /* SYSTEM_SETTINGS_KEY_SOUND_LOCK */
1632 int system_setting_get_sound_lock(system_settings_key_e key, void **value)
1633 {
1634         SETTING_TRACE_BEGIN;
1635         bool vconf_value;
1636
1637         if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_SOUND_LOCK_BOOL, &vconf_value)) {
1638                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1639         }
1640         *value = (void *)vconf_value;
1641
1642         return SYSTEM_SETTINGS_ERROR_NONE;
1643 }
1644
1645 int system_setting_set_changed_callback_sound_lock(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1646 {
1647         SETTING_TRACE_BEGIN;
1648         return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_SOUND_LOCK_BOOL, SYSTEM_SETTINGS_KEY_SOUND_LOCK, SYSTEM_SETTING_CALLBACK_SLOT_3, user_data);
1649 }
1650
1651 int system_setting_unset_changed_callback_sound_lock(system_settings_key_e key)
1652 {
1653         SETTING_TRACE_BEGIN;
1654         return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_SOUND_LOCK_BOOL, SYSTEM_SETTING_CALLBACK_SLOT_3);
1655 }
1656
1657 /**
1658  * a = VCONFKEY_SETAPPL_SOUND_STATUS_BOOL b = VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL
1659  *
1660  * a == false, b == false --> silent mode
1661  * a == true, b == false --> sound mode
1662  * a == false, b == true --> vibration mode
1663  */
1664 /*  LCOV_EXCL_START */
1665 int system_setting_get_sound_silent_mode(system_settings_key_e key, void **value)
1666 {
1667         SETTING_TRACE_BEGIN;
1668         bool sound_cond;
1669         bool vib_cond;
1670
1671         bool vconf_value;
1672         if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, &sound_cond)) {
1673                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1674         }
1675
1676         if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, &vib_cond)) {
1677                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1678         }
1679
1680         if (sound_cond == false && vib_cond == false) {
1681                 vconf_value = true;
1682                 *value = (void *)vconf_value;
1683         } else {
1684                 vconf_value = false;
1685                 *value = (void *)vconf_value;
1686         }
1687         return SYSTEM_SETTINGS_ERROR_NONE;
1688 }
1689 /*  LCOV_EXCL_STOP */
1690
1691 /**
1692  * a = VCONFKEY_SETAPPL_SOUND_STATUS_BOOL b = VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL
1693  *
1694  * a == false, b == false --> silent mode
1695  * a == true, b == false --> sound mode
1696  */
1697 int system_setting_set_sound_silent_mode(system_settings_key_e key, void *value)
1698 {
1699         SETTING_TRACE_BEGIN;
1700         bool *vconf_value;
1701
1702         vconf_value = (bool *)value;
1703
1704         bool vconf_sound = false;
1705         bool vconf_vib = false;
1706
1707         if (*vconf_value) {
1708                 vconf_sound = false;
1709                 vconf_vib = false;
1710         } else {
1711                 vconf_sound = true;
1712                 vconf_vib = false;
1713         }
1714
1715         if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, vconf_sound)) {
1716                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1717         }
1718         if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, vconf_vib)) {
1719                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1720         }
1721
1722         return SYSTEM_SETTINGS_ERROR_NONE;
1723 }
1724
1725
1726
1727 /* TODO */
1728 int system_setting_set_changed_callback_sound_silent_mode(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1729 {
1730         SETTING_TRACE_BEGIN;
1731         return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, SYSTEM_SETTINGS_KEY_SOUND_SILENT_MODE, SYSTEM_SETTING_CALLBACK_SLOT_3, user_data);
1732 }
1733
1734 /* TODO */
1735 int system_setting_unset_changed_callback_sound_silent_mode(system_settings_key_e key)
1736 {
1737         SETTING_TRACE_BEGIN;
1738         return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, SYSTEM_SETTING_CALLBACK_SLOT_3);
1739 }
1740
1741 /* SYSTEM_SETTINGS_KEY_SOUND_TOUCH */
1742 int system_setting_get_sound_touch(system_settings_key_e key, void **value)
1743 {
1744         SETTING_TRACE_BEGIN;
1745         bool vconf_value;
1746
1747         int ret = system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL, &vconf_value);
1748         if (ret != SYSTEM_SETTINGS_ERROR_NONE) {
1749                 return ret;
1750         }
1751         *value = (void *)vconf_value;
1752         return ret;
1753 }
1754
1755 int system_setting_set_sound_touch(system_settings_key_e key, void *value)
1756 {
1757         SETTING_TRACE_BEGIN;
1758         return system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL, *(bool *)value);
1759 }
1760
1761
1762 int system_setting_set_changed_callback_sound_touch(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1763 {
1764         SETTING_TRACE_BEGIN;
1765         return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL, SYSTEM_SETTINGS_KEY_SOUND_TOUCH, SYSTEM_SETTING_CALLBACK_SLOT_2, user_data);
1766 }
1767
1768 int system_setting_unset_changed_callback_sound_touch(system_settings_key_e key)
1769 {
1770         SETTING_TRACE_BEGIN;
1771         return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL, SYSTEM_SETTING_CALLBACK_SLOT_2);
1772 }
1773
1774 int system_setting_get_auto_rotation_mode(system_settings_key_e key, void **value)
1775 {
1776         SETTING_TRACE_BEGIN;
1777         bool vconf_value;
1778
1779         if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, &vconf_value)) {
1780                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1781         }
1782         *value = (void *)vconf_value;
1783
1784         return SYSTEM_SETTINGS_ERROR_NONE;
1785 }
1786
1787 /*  LCOV_EXCL_START */
1788 int system_setting_set_auto_rotation_mode(system_settings_key_e key, void *value)
1789 {
1790         SETTING_TRACE_BEGIN;
1791         bool *vconf_value;
1792         vconf_value = (bool *)value;
1793         if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, *vconf_value)) {
1794                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1795         }
1796
1797         return SYSTEM_SETTINGS_ERROR_NONE;
1798 }
1799 /*  LCOV_EXCL_STOP */
1800
1801 int system_setting_set_changed_callback_auto_rotation_mode(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1802 {
1803         SETTING_TRACE_BEGIN;
1804         return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, SYSTEM_SETTINGS_KEY_DISPLAY_SCREEN_ROTATION_AUTO, SYSTEM_SETTING_CALLBACK_SLOT_2, user_data);
1805 }
1806
1807 int system_setting_unset_changed_callback_auto_rotation_mode(system_settings_key_e key)
1808 {
1809         SETTING_TRACE_BEGIN;
1810         return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, SYSTEM_SETTING_CALLBACK_SLOT_2);
1811 }
1812
1813 int system_setting_get_screen_backlight_time(system_settings_key_e key, void **value)
1814 {
1815         SETTING_TRACE_BEGIN;
1816         int vconf_value;
1817         int ** val = (int**)value;
1818
1819         if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, &vconf_value)) {
1820                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1821         }
1822         **val = vconf_value;
1823
1824         return SYSTEM_SETTINGS_ERROR_NONE;
1825 }
1826
1827
1828 /*  LCOV_EXCL_START */
1829 int system_setting_set_screen_backlight_time(system_settings_key_e key, void *value)
1830 {
1831         SETTING_TRACE_BEGIN;
1832         int *vconf_value;
1833         vconf_value = *(int **)value;
1834
1835         if (!(*vconf_value > 0 && *vconf_value <= 600)) {
1836                 SETTING_TRACE(" ERR Betweeny here  0 ~ 600");
1837                 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
1838         }
1839
1840         if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, *vconf_value)) {
1841                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1842         }
1843         SETTING_TRACE_END;
1844         return SYSTEM_SETTINGS_ERROR_NONE;
1845 }
1846 /*  LCOV_EXCL_STOP */
1847
1848 int system_setting_set_changed_callback_screen_backlight_time(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1849 {
1850         SETTING_TRACE_BEGIN;
1851         return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, SYSTEM_SETTINGS_KEY_SCREEN_BACKLIGHT_TIME, SYSTEM_SETTING_CALLBACK_SLOT_2, user_data);
1852 }
1853
1854 int system_setting_unset_changed_callback_screen_backlight_time(system_settings_key_e key)
1855 {
1856         SETTING_TRACE_BEGIN;
1857         return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, SYSTEM_SETTING_CALLBACK_SLOT_2);
1858 }
1859
1860 int system_setting_get_sound_notification(system_settings_key_e key, void **value)
1861 {
1862         SETTING_TRACE_BEGIN;
1863         char *vconf_value = NULL;
1864         if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, &vconf_value)) {
1865                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1866         }
1867
1868         *value = vconf_value;
1869         return SYSTEM_SETTINGS_ERROR_NONE;
1870 }
1871
1872 /*  LCOV_EXCL_START */
1873 int system_setting_set_sound_notification(system_settings_key_e key, void *value)
1874 {
1875         SETTING_TRACE_BEGIN;
1876         char *vconf_value = NULL;
1877         vconf_value = (char *)value;
1878
1879         int is_load = _is_file_accessible(vconf_value);
1880         if (is_load == 0) {
1881                 //SETTING_TRACE(" system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, %s) TRY", vconf_value);
1882                 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, vconf_value)) {
1883                         //SETTING_TRACE(" system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, %s) FAIL", vconf_value);
1884                         return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1885                 }
1886         } else {
1887                 //SETTING_TRACE(" is_file_accessibile FAILED - system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, %s) FAIL", vconf_value);
1888                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1889         }
1890
1891         return SYSTEM_SETTINGS_ERROR_NONE;
1892 }
1893 /*  LCOV_EXCL_STOP */
1894
1895 int system_setting_set_changed_callback_sound_notification(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1896 {
1897         SETTING_TRACE_BEGIN;
1898         return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, SYSTEM_SETTINGS_KEY_SOUND_NOTIFICATION, SYSTEM_SETTING_CALLBACK_SLOT_0, user_data);
1899 }
1900
1901 int system_setting_unset_changed_callback_sound_notification(system_settings_key_e key)
1902 {
1903         SETTING_TRACE_BEGIN;
1904         return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, SYSTEM_SETTING_CALLBACK_SLOT_0);
1905 }
1906
1907 int system_setting_get_notification_repetition_period(system_settings_key_e key, void **value)
1908 {
1909         SETTING_TRACE_BEGIN;
1910         int ** val = (int**)value;
1911         int vconf_value;
1912
1913         if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_NOTI_MSG_ALERT_REP_TYPE_INT, &vconf_value)) {
1914                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1915         }
1916         **val = vconf_value;
1917
1918         return SYSTEM_SETTINGS_ERROR_NONE;
1919 }
1920
1921 /*  LCOV_EXCL_START */
1922 int system_setting_set_notification_repetition_period(system_settings_key_e key, void *value)
1923 {
1924         SETTING_TRACE_BEGIN;
1925         int *vconf_value;
1926         vconf_value = *(int **)value;
1927
1928         if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_NOTI_MSG_ALERT_REP_TYPE_INT, *vconf_value)) {
1929                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1930         }
1931         SETTING_TRACE_END;
1932         return SYSTEM_SETTINGS_ERROR_NONE;
1933 }
1934 /*  LCOV_EXCL_STOP */
1935
1936 int system_setting_set_changed_callback_notification_repetition_period(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1937 {
1938         SETTING_TRACE_BEGIN;
1939         return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_ALERT_REP_TYPE_INT, SYSTEM_SETTINGS_KEY_SOUND_NOTIFICATION_REPETITION_PERIOD, SYSTEM_SETTING_CALLBACK_SLOT_1, user_data);
1940 }
1941
1942 int system_setting_unset_changed_callback_notification_repetition_period(system_settings_key_e key)
1943 {
1944         SETTING_TRACE_BEGIN;
1945         return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_ALERT_REP_TYPE_INT, SYSTEM_SETTING_CALLBACK_SLOT_1);
1946 }
1947
1948 int system_setting_get_device_name(system_settings_key_e key, void **value)
1949 {
1950         SETTING_TRACE_BEGIN;
1951         char *vconf_value = NULL;
1952         if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_DEVICE_NAME_STR, &vconf_value)) {
1953                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1954         }
1955
1956         *value = vconf_value;
1957         return SYSTEM_SETTINGS_ERROR_NONE;
1958 }
1959
1960 /*  LCOV_EXCL_START */
1961 int system_setting_set_device_name(system_settings_key_e key, void *value)
1962 {
1963         SETTING_TRACE_BEGIN;
1964         char *vconf_value = NULL;
1965         vconf_value = (char *)value;
1966
1967         if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_DEVICE_NAME_STR, vconf_value)) {
1968                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1969         }
1970
1971         return SYSTEM_SETTINGS_ERROR_NONE;
1972 }
1973 /*  LCOV_EXCL_STOP */
1974
1975 int system_setting_set_changed_callback_device_name(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1976 {
1977         SETTING_TRACE_BEGIN;
1978         return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_DEVICE_NAME_STR, SYSTEM_SETTINGS_KEY_DEVICE_NAME, SYSTEM_SETTING_CALLBACK_SLOT_0, user_data);
1979 }
1980
1981 int system_setting_unset_changed_callback_device_name(system_settings_key_e key)
1982 {
1983         SETTING_TRACE_BEGIN;
1984         return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_DEVICE_NAME_STR, SYSTEM_SETTING_CALLBACK_SLOT_0);
1985 }
1986
1987 /*---------------------------------------------- */
1988 int system_setting_get_network_flight_mode(system_settings_key_e key, void **value)
1989 {
1990         SETTING_TRACE_BEGIN;
1991         bool vconf_value;
1992         if (system_setting_vconf_get_value_bool(VCONFKEY_TELEPHONY_FLIGHT_MODE, &vconf_value)) {
1993                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1994         }
1995         *value = (void *)vconf_value;
1996
1997         return SYSTEM_SETTINGS_ERROR_NONE;
1998 }
1999
2000 int system_setting_set_changed_callback_network_flight_mode(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
2001 {
2002         SETTING_TRACE_BEGIN;
2003         return system_setting_vconf_set_changed_cb(VCONFKEY_TELEPHONY_FLIGHT_MODE, SYSTEM_SETTINGS_KEY_NETWORK_FLIGHT_MODE, SYSTEM_SETTING_CALLBACK_SLOT_3, user_data);
2004 }
2005
2006 int system_setting_unset_changed_callback_network_flight_mode(system_settings_key_e key)
2007 {
2008         SETTING_TRACE_BEGIN;
2009         return system_setting_vconf_unset_changed_cb(VCONFKEY_TELEPHONY_FLIGHT_MODE, SYSTEM_SETTING_CALLBACK_SLOT_3);
2010 }
2011
2012 int system_setting_get_network_wifi_notification(system_settings_key_e key, void **value)
2013 {
2014         SETTING_TRACE_BEGIN;
2015         int vconf_value;
2016         if (system_setting_vconf_get_value_int(VCONFKEY_WIFI_ENABLE_QS, &vconf_value)) {
2017                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2018         }
2019         bool bret ;
2020         bret = (vconf_value == VCONFKEY_WIFI_QS_ENABLE) ? true : false;
2021
2022         *value = (void *)bret;
2023         return SYSTEM_SETTINGS_ERROR_NONE;
2024 }
2025
2026 int system_setting_set_changed_callback_network_wifi_notification(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
2027 {
2028         SETTING_TRACE_BEGIN;
2029         return system_setting_vconf_set_changed_cb(VCONFKEY_WIFI_ENABLE_QS, SYSTEM_SETTINGS_KEY_NETWORK_WIFI_NOTIFICATION, SYSTEM_SETTING_CALLBACK_SLOT_4, user_data);
2030 }
2031
2032 int system_setting_unset_changed_callback_network_wifi_notification(system_settings_key_e key)
2033 {
2034         SETTING_TRACE_BEGIN;
2035         return system_setting_vconf_unset_changed_cb(VCONFKEY_WIFI_ENABLE_QS, SYSTEM_SETTING_CALLBACK_SLOT_4);
2036 }
2037
2038 /*  LCOV_EXCL_START */
2039 int system_setting_get_lock_state(system_settings_key_e key, void **value)
2040 {
2041         int vconf_value;
2042         int ** val = (int**)value;
2043
2044         if (system_setting_vconf_get_value_int(VCONFKEY_IDLE_LOCK_STATE_READ_ONLY, &vconf_value)) {
2045                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2046         }
2047         **val = vconf_value;
2048
2049         return SYSTEM_SETTINGS_ERROR_NONE;
2050 }
2051 /*  LCOV_EXCL_STOP */
2052
2053 /*  LCOV_EXCL_START */
2054 int system_setting_set_lock_state(system_settings_key_e key, void *value)
2055 {
2056         SETTING_TRACE_BEGIN;
2057         int *vconf_value;
2058         vconf_value = *(int **)value;
2059
2060         if (system_setting_vconf_set_value_int(VCONFKEY_IDLE_LOCK_STATE_READ_ONLY, *vconf_value)) {
2061                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2062         }
2063         SETTING_TRACE_END;
2064         return SYSTEM_SETTINGS_ERROR_NONE;
2065 }
2066 /*  LCOV_EXCL_STOP */
2067
2068 /*  LCOV_EXCL_START */
2069 int system_setting_set_changed_callback_lock_state(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
2070 {
2071         return system_setting_vconf_set_changed_cb(VCONFKEY_IDLE_LOCK_STATE_READ_ONLY, SYSTEM_SETTINGS_KEY_LOCK_STATE, SYSTEM_SETTING_CALLBACK_SLOT_4, user_data);
2072 }
2073 /*  LCOV_EXCL_STOP */
2074
2075 /*  LCOV_EXCL_START */
2076 int system_setting_unset_changed_callback_lock_state(system_settings_key_e key)
2077 {
2078         return system_setting_vconf_unset_changed_cb(VCONFKEY_IDLE_LOCK_STATE_READ_ONLY, SYSTEM_SETTING_CALLBACK_SLOT_4);
2079 }
2080 /*  LCOV_EXCL_STOP */
2081
2082 //----------------------------------------------------------------------------------------------------------------------------
2083
2084 #define DEFAULT_ADS_ID "00000000-0000-0000-0000-000000000000"
2085
2086 int system_setting_get_ads_id(system_settings_key_e key, void **value)
2087 {
2088         SETTING_TRACE_BEGIN;
2089         int optout_value = 0;
2090         if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_AD_ID_OPT_OUT, &optout_value)) {
2091                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2092         }
2093
2094         if (optout_value == 1) {
2095                 *value = strdup(DEFAULT_ADS_ID);
2096                 return SYSTEM_SETTINGS_ERROR_NONE;
2097         }
2098
2099         char *vconf_value = NULL;
2100         if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_AD_ID, &vconf_value)) {
2101                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2102         }
2103
2104         *value = vconf_value;
2105         return SYSTEM_SETTINGS_ERROR_NONE;
2106 }
2107
2108
2109 #if DEBUG_DUMP_CONTEXT
2110 void make_ad_id(void)
2111 {
2112         uuid_t uuid_value;
2113         char uuid_unparsed[50] = {0};
2114         uuid_generate(uuid_value);
2115         uuid_unparse(uuid_value, uuid_unparsed);
2116         system_setting_set_ad_id(key, uuid_unparsed); //example of setting the value
2117 }
2118 #endif
2119 int system_setting_set_ads_id(system_settings_key_e key, void *value)
2120 {
2121         SETTING_TRACE_BEGIN;
2122         char *vconf_value = NULL;
2123         vconf_value = (char *)value;
2124
2125         if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_AD_ID, vconf_value)) {
2126                 SETTING_TRACE("Setting VCONFKEY_SETAPPL_AD_ID failed");
2127                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2128         }
2129
2130         return SYSTEM_SETTINGS_ERROR_NONE;
2131 }
2132
2133 int system_setting_set_changed_callback_ads_id(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
2134 {
2135         SETTING_TRACE_BEGIN;
2136         return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_AD_ID, SYSTEM_SETTINGS_KEY_ADS_ID, SYSTEM_SETTING_CALLBACK_SLOT_0, user_data);
2137 }
2138
2139 int system_setting_unset_changed_callback_ads_id(system_settings_key_e key)
2140 {
2141         SETTING_TRACE_BEGIN;
2142         return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_AD_ID, SYSTEM_SETTING_CALLBACK_SLOT_0);
2143 }
2144
2145 int system_settings_feature_check_bool(char *path)
2146 {
2147         bool feature_data = false;
2148         int ret = system_info_get_platform_bool(path, &feature_data);
2149         if (ret != SYSTEM_INFO_ERROR_NONE) {
2150                 SETTING_TRACE("Setting - reading feature data failed, %d", ret);
2151                 return SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED;
2152         }
2153
2154         ret = (feature_data == true) ? SYSTEM_SETTINGS_ERROR_NONE : SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED;
2155
2156         return ret;
2157
2158 }
2159
2160 int system_setting_feature_check_incoming_call(void *value)
2161 {
2162         static bool first_query = true;
2163         static int ret = SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED;
2164
2165         if (first_query == true) {
2166                 ret = system_settings_feature_check_bool(SETTING_INCOMING_CALL_PATH);
2167                 first_query = false;
2168         }
2169
2170         return ret;
2171 }
2172
2173 int system_setting_feature_check_home_screen(void *value)
2174 {
2175         static bool first_query = true;
2176         static int ret = SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED;
2177
2178         if (first_query == true) {
2179                 ret = system_settings_feature_check_bool(SETTING_HOME_SCREEN_PATH);
2180                 first_query = false;
2181         }
2182
2183         return ret;
2184 }
2185
2186 int system_setting_feature_check_lock_screen(void *value)
2187 {
2188         static bool first_query = true;
2189         static int ret = SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED;
2190
2191         if (first_query == true) {
2192                 ret = system_settings_feature_check_bool(SETTING_LOCK_SCREEN_PATH);
2193                 first_query = false;
2194         }
2195
2196         return ret;
2197 }
2198
2199 int system_setting_feature_check_notification_email(void *value)
2200 {
2201         static bool first_query = true;
2202         static int ret = SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED;
2203
2204         if (first_query == true) {
2205                 ret = system_settings_feature_check_bool(SETTING_NOTIFICATION_EMAIL_PATH);
2206                 first_query = false;
2207         }
2208
2209         return ret;
2210 }
2211
2212 int system_setting_feature_check_wifi(void *value)
2213 {
2214         static bool first_query = true;
2215         static int ret = SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED;
2216
2217         if (first_query == true) {
2218                 ret = system_settings_feature_check_bool(SETTING_WIFI_PATH);
2219                 first_query = false;
2220         }
2221
2222         return ret;
2223 }
2224
2225 int system_setting_feature_check_telephony(void *value)
2226 {
2227         static bool first_query = true;
2228         static int ret = SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED;
2229
2230         if (first_query == true) {
2231                 ret = system_settings_feature_check_bool(SETTING_TELEPHONY_PATH);
2232                 first_query = false;
2233         }
2234
2235         return ret;
2236 }
2237
2238
2239 int system_setting_feature_check_font(void *value)
2240 {
2241         static bool first_query = true;
2242         static int ret = SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED;
2243
2244         if (first_query == true) {
2245                 ret = system_settings_feature_check_bool(SETTING_FONT_PATH);
2246                 first_query = false;
2247         }
2248
2249         return ret;
2250 }
2251
2252 int system_setting_feature_check_accessibility_grayscale(void *value)
2253 {
2254         static bool first_query = true;
2255         static int ret = SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED;
2256
2257         if (first_query == true) {
2258                 ret = system_settings_feature_check_bool(SETTING_ACCESSIBILITY_GRAYSCALE_PATH);
2259                 first_query = false;
2260         }
2261
2262         return ret;
2263 }
2264
2265 int system_setting_feature_check_accessibility_negative(void *value)
2266 {
2267         static bool first_query = true;
2268         static int ret = SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED;
2269
2270         if (first_query == true) {
2271                 ret = system_settings_feature_check_bool(SETTING_ACCESSIBILITY_NEGATIVE_PATH);
2272                 first_query = false;
2273         }
2274
2275         return ret;
2276 }
2277
2278 int system_setting_feature_check_wearable_profile(void *value)
2279 {
2280         static bool first_query = true;
2281         static int ret = SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED;
2282
2283         if (first_query == true) {
2284                 char *profile_data = NULL;
2285                 int rotary_feature = SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED;
2286                 ret = system_info_get_platform_string(SETTING_PROFILE_PATH, &profile_data);
2287                 if (ret != SYSTEM_INFO_ERROR_NONE) {
2288                         SETTING_TRACE("Setting - reading profile string failed, %d", ret);
2289                         return SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED;
2290                 }
2291
2292                 rotary_feature = system_settings_feature_check_bool(SETTING_INPUT_ROTATING_BEZEL_PATH);
2293
2294                 if ((rotary_feature == SYSTEM_SETTINGS_ERROR_NONE) && profile_data && !strcmp(profile_data, "wearable"))
2295                         ret = SYSTEM_SETTINGS_ERROR_NONE;
2296                 else
2297                         ret = SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED;
2298
2299                 if (profile_data)
2300                         free(profile_data);
2301
2302                 first_query = false;
2303         }
2304
2305         return ret;
2306 }
2307
2308 /*  LCOV_EXCL_START */
2309 int system_setting_get_uds_state(system_settings_key_e key, void **value)
2310 {
2311         int ** p_value = (int**)value;
2312         int vconf_value;
2313         char *vconf_string_value = NULL;
2314
2315         if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_UDSM, &vconf_value)) {
2316                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2317         }
2318
2319         SETTING_TRACE("[%s] udsm: %d", __FUNCTION__, vconf_value);
2320
2321         if (vconf_value == SYSTEM_SETTINGS_UDS_ON) {
2322                 if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_UDSM_PKGID_LIST, &vconf_string_value))
2323                         return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2324
2325                 if (vconf_string_value) {
2326                         if (!strcmp(vconf_string_value, "NONE")) {
2327                                 vconf_value = SYSTEM_SETTINGS_UDS_ON;
2328                         } else {
2329                                 char *app_id = NULL;
2330                                 char *package_id = NULL;
2331                                 pid_t pid = getpid();
2332
2333                                 int ret = app_manager_get_app_id(pid, &app_id);
2334                                 if (ret != APP_MANAGER_ERROR_NONE) {
2335                                         free(vconf_string_value);
2336                                         return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2337                                 }
2338
2339                                 if (app_id) {
2340                                         int result = 0;
2341                                         result = package_manager_get_package_id_by_app_id(app_id, &package_id);
2342                                         if (result != PACKAGE_MANAGER_ERROR_NONE) {
2343                                                 SETTING_TRACE("package_manager_get_package_id_by_app_id returned error! %d", result);
2344                                                 free(app_id);
2345                                                 free(vconf_string_value);
2346                                                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2347                                         }
2348
2349                                         SETTING_TRACE("[%s] udsm_pkg_list : %s", __FUNCTION__, vconf_string_value);
2350                                 }
2351
2352                                 if (package_id && strstr(vconf_string_value, package_id)) {
2353                                         vconf_value = SYSTEM_SETTINGS_UDS_ON_WHITELISTED;
2354                                         SETTING_TRACE("[%s] pkg id : %s", __FUNCTION__, package_id);
2355                                 } else {
2356                                         vconf_value = SYSTEM_SETTINGS_UDS_ON;
2357                                 }
2358
2359                         }
2360                         free(vconf_string_value);
2361                 }
2362         }
2363
2364         **p_value = vconf_value;
2365
2366
2367         return SYSTEM_SETTINGS_ERROR_NONE;
2368 }
2369 /*  LCOV_EXCL_STOP */
2370
2371 /*  LCOV_EXCL_START */
2372 int system_setting_set_changed_callback_uds_state(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
2373 {
2374         return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_UDSM, SYSTEM_SETTINGS_KEY_ULTRA_DATA_SAVE, SYSTEM_SETTING_CALLBACK_SLOT_4, user_data);
2375 }
2376 /*  LCOV_EXCL_STOP */
2377
2378 /*  LCOV_EXCL_START */
2379 int system_setting_unset_changed_callback_uds_state(system_settings_key_e key)
2380 {
2381         return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_UDSM, SYSTEM_SETTING_CALLBACK_SLOT_4);
2382 }
2383 /*  LCOV_EXCL_STOP */
2384
2385 /*  LCOV_EXCL_START */
2386 int system_setting_set_changed_callback_uds_pkg_list(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
2387 {
2388         return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_UDSM_PKGID_LIST, SYSTEM_SETTINGS_KEY_ULTRA_DATA_SAVE_PKG_LIST, SYSTEM_SETTING_CALLBACK_SLOT_4, user_data);
2389 }
2390 /*  LCOV_EXCL_STOP */
2391
2392 /*  LCOV_EXCL_START */
2393 int system_setting_unset_changed_callback_uds_pkg_list(system_settings_key_e key)
2394 {
2395         return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_UDSM_PKGID_LIST, SYSTEM_SETTING_CALLBACK_SLOT_4);
2396 }
2397 /*  LCOV_EXCL_STOP */
2398
2399 /* SYSTEM_SETTINGS_KEY_ACCESSIBILITY_TTS */
2400 int system_setting_get_accessibility_tts(system_settings_key_e key, void **value)
2401 {
2402         SETTING_TRACE_BEGIN;
2403         bool vconf_value;
2404
2405         int ret = system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_ACCESSIBILITY_TTS, &vconf_value);
2406         if (ret != SYSTEM_SETTINGS_ERROR_NONE) {
2407                 return ret;
2408         }
2409         *value = (void *)vconf_value;
2410         return ret;
2411 }
2412
2413 /*  LCOV_EXCL_START */
2414 int system_setting_set_accessibility_tts(system_settings_key_e key, void *value)
2415 {
2416         SETTING_TRACE_BEGIN;
2417         bool *vconf_value;
2418         vconf_value = (bool *)value;
2419         if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_ACCESSIBILITY_TTS, *vconf_value)) {
2420                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2421         }
2422
2423         return SYSTEM_SETTINGS_ERROR_NONE;
2424 }
2425 /*  LCOV_EXCL_STOP */
2426
2427 int system_setting_set_changed_callback_accessibility_tts(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
2428 {
2429         SETTING_TRACE_BEGIN;
2430         return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_TTS, SYSTEM_SETTINGS_KEY_ACCESSIBILITY_TTS, SYSTEM_SETTING_CALLBACK_SLOT_2, user_data);
2431 }
2432
2433 int system_setting_unset_changed_callback_accessibility_tts(system_settings_key_e key)
2434 {
2435         SETTING_TRACE_BEGIN;
2436         return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_TTS, SYSTEM_SETTING_CALLBACK_SLOT_2);
2437 }
2438
2439 /* SYSTEM_SETTINGS_KEY_VIBRATION */
2440 int system_setting_get_vibration(system_settings_key_e key, void **value)
2441 {
2442         SETTING_TRACE_BEGIN;
2443         bool vconf_value;
2444
2445         if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, &vconf_value)) {
2446                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2447         }
2448         *value = (void *)vconf_value;
2449
2450         return SYSTEM_SETTINGS_ERROR_NONE;
2451 }
2452
2453 /*  LCOV_EXCL_START */
2454 int system_setting_set_vibration(system_settings_key_e key, void *value)
2455 {
2456         SETTING_TRACE_BEGIN;
2457         bool *vconf_value;
2458         vconf_value = (bool *)value;
2459         if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, *vconf_value)) {
2460                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2461         }
2462
2463         return SYSTEM_SETTINGS_ERROR_NONE;
2464 }
2465 /*  LCOV_EXCL_STOP */
2466
2467 int system_setting_set_changed_callback_vibration(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
2468 {
2469         SETTING_TRACE_BEGIN;
2470         return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, SYSTEM_SETTINGS_KEY_VIBRATION, SYSTEM_SETTING_CALLBACK_SLOT_2, user_data);
2471 }
2472
2473 int system_setting_unset_changed_callback_vibration(system_settings_key_e key)
2474 {
2475         SETTING_TRACE_BEGIN;
2476         return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, SYSTEM_SETTING_CALLBACK_SLOT_2);
2477 }
2478
2479 /* SYSTEM_SETTINGS_KEY_AUTOMATIC_TIME_UPDATE */
2480 int system_setting_get_automatic_time_update(system_settings_key_e key, void **value)
2481 {
2482         SETTING_TRACE_BEGIN;
2483         bool vconf_value;
2484
2485         if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_STATE_AUTOMATIC_TIME_UPDATE_BOOL, &vconf_value)) {
2486                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2487         }
2488         *value = (void *)vconf_value;
2489
2490         return SYSTEM_SETTINGS_ERROR_NONE;
2491 }
2492
2493 /*  LCOV_EXCL_START */
2494 int system_setting_set_automatic_time_update(system_settings_key_e key, void *value)
2495 {
2496         SETTING_TRACE_BEGIN;
2497         bool *vconf_value;
2498         vconf_value = (bool *)value;
2499         if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_STATE_AUTOMATIC_TIME_UPDATE_BOOL, *vconf_value)) {
2500                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2501         }
2502
2503         return SYSTEM_SETTINGS_ERROR_NONE;
2504 }
2505 /*  LCOV_EXCL_STOP */
2506
2507 int system_setting_set_changed_callback_automatic_time_update(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
2508 {
2509         SETTING_TRACE_BEGIN;
2510         return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_STATE_AUTOMATIC_TIME_UPDATE_BOOL, SYSTEM_SETTINGS_KEY_AUTOMATIC_TIME_UPDATE, SYSTEM_SETTING_CALLBACK_SLOT_2, user_data);
2511 }
2512
2513 int system_setting_unset_changed_callback_automatic_time_update(system_settings_key_e key)
2514 {
2515         SETTING_TRACE_BEGIN;
2516         return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_STATE_AUTOMATIC_TIME_UPDATE_BOOL, SYSTEM_SETTING_CALLBACK_SLOT_2);
2517 }
2518
2519 /* SYSTEM_SETTINGS_KEY_DEVELOPER_OPTION_STATE */
2520 int system_setting_get_developer_option_state(system_settings_key_e key, void **value)
2521 {
2522         SETTING_TRACE_BEGIN;
2523         bool vconf_value;
2524
2525         if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_DEVELOPER_OPTION_STATE, &vconf_value)) {
2526                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2527         }
2528         *value = (void *)vconf_value;
2529
2530         return SYSTEM_SETTINGS_ERROR_NONE;
2531 }
2532
2533 /*  LCOV_EXCL_START */
2534 int system_setting_set_developer_option_state(system_settings_key_e key, void *value)
2535 {
2536         SETTING_TRACE_BEGIN;
2537         bool *vconf_value;
2538         vconf_value = (bool *)value;
2539         if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_DEVELOPER_OPTION_STATE, *vconf_value)) {
2540                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2541         }
2542
2543         return SYSTEM_SETTINGS_ERROR_NONE;
2544 }
2545 /*  LCOV_EXCL_STOP */
2546
2547 int system_setting_set_changed_callback_developer_option_state(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
2548 {
2549         SETTING_TRACE_BEGIN;
2550         return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_DEVELOPER_OPTION_STATE, SYSTEM_SETTINGS_KEY_DEVELOPER_OPTION_STATE, SYSTEM_SETTING_CALLBACK_SLOT_2, user_data);
2551 }
2552
2553 int system_setting_unset_changed_callback_developer_option_state(system_settings_key_e key)
2554 {
2555         SETTING_TRACE_BEGIN;
2556         return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_DEVELOPER_OPTION_STATE, SYSTEM_SETTING_CALLBACK_SLOT_2);
2557 }
2558
2559 /* SYSTEM_SETTINGS_KEY_ACCESSIBILITY_GRAYSCALE */
2560 int system_setting_get_accessibility_grayscale(system_settings_key_e key, void **value)
2561 {
2562         SETTING_TRACE_BEGIN;
2563         bool vconf_value;
2564
2565         if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_ACCESSIBILITY_GREYSCALE, &vconf_value)) {
2566                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2567         }
2568         *value = (void *)vconf_value;
2569
2570         return SYSTEM_SETTINGS_ERROR_NONE;
2571 }
2572
2573 /*  LCOV_EXCL_START */
2574 int system_setting_set_accessibility_grayscale(system_settings_key_e key, void *value)
2575 {
2576         SETTING_TRACE_BEGIN;
2577         bool *vconf_value;
2578         vconf_value = (bool *)value;
2579         if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_ACCESSIBILITY_GREYSCALE, *vconf_value)) {
2580                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2581         }
2582
2583         return SYSTEM_SETTINGS_ERROR_NONE;
2584 }
2585 /*  LCOV_EXCL_STOP */
2586
2587 int system_setting_set_changed_callback_accessibility_grayscale(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
2588 {
2589         SETTING_TRACE_BEGIN;
2590         return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_GREYSCALE, SYSTEM_SETTINGS_KEY_ACCESSIBILITY_GRAYSCALE, SYSTEM_SETTING_CALLBACK_SLOT_2, user_data);
2591 }
2592
2593 int system_setting_unset_changed_callback_accessibility_grayscale(system_settings_key_e key)
2594 {
2595         SETTING_TRACE_BEGIN;
2596         return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_GREYSCALE, SYSTEM_SETTING_CALLBACK_SLOT_2);
2597 }
2598
2599 /* SYSTEM_SETTINGS_KEY_ACCESSIBILITY_NEGATIVE_COLOR */
2600 int system_setting_get_accessibility_negative_color(system_settings_key_e key, void **value)
2601 {
2602         SETTING_TRACE_BEGIN;
2603         bool vconf_value;
2604
2605         if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_ACCESSIBILITY_HIGH_CONTRAST, &vconf_value)) {
2606                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2607         }
2608         *value = (void *)vconf_value;
2609
2610         return SYSTEM_SETTINGS_ERROR_NONE;
2611 }
2612
2613 /*  LCOV_EXCL_START */
2614 int system_setting_set_accessibility_negative_color(system_settings_key_e key, void *value)
2615 {
2616         SETTING_TRACE_BEGIN;
2617         bool *vconf_value;
2618         vconf_value = (bool *)value;
2619         if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_ACCESSIBILITY_HIGH_CONTRAST, *vconf_value)) {
2620                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2621         }
2622
2623         return SYSTEM_SETTINGS_ERROR_NONE;
2624 }
2625 /*  LCOV_EXCL_STOP */
2626
2627 int system_setting_set_changed_callback_accessibility_negative_color(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
2628 {
2629         SETTING_TRACE_BEGIN;
2630         return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_HIGH_CONTRAST, SYSTEM_SETTINGS_KEY_ACCESSIBILITY_NEGATIVE_COLOR, SYSTEM_SETTING_CALLBACK_SLOT_2, user_data);
2631 }
2632
2633 int system_setting_unset_changed_callback_accessibility_negative_color(system_settings_key_e key)
2634 {
2635         SETTING_TRACE_BEGIN;
2636         return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_HIGH_CONTRAST, SYSTEM_SETTING_CALLBACK_SLOT_2);
2637 }
2638
2639 /* SYSTEM_SETTINGS_KEY_ROTARY_EVENT_ENABLED */
2640 /*  LCOV_EXCL_START */
2641 int system_setting_get_rotary_event_enabled(system_settings_key_e key, void **value)
2642 {
2643         SETTING_TRACE_BEGIN;
2644         bool vconf_value;
2645
2646         if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_ROTARY_EVENT_ENABLED_BOOL, &vconf_value)) {
2647                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2648         }
2649         *value = (void *)vconf_value;
2650
2651         return SYSTEM_SETTINGS_ERROR_NONE;
2652 }
2653 /*  LCOV_EXCL_STOP */
2654
2655 /*  LCOV_EXCL_START */
2656 int system_setting_set_rotary_event_enabled(system_settings_key_e key, void *value)
2657 {
2658         SETTING_TRACE_BEGIN;
2659         bool *vconf_value;
2660         vconf_value = (bool *)value;
2661         if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_ROTARY_EVENT_ENABLED_BOOL, *vconf_value)) {
2662                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
2663         }
2664
2665         return SYSTEM_SETTINGS_ERROR_NONE;
2666 }
2667 /*  LCOV_EXCL_STOP */
2668
2669 /*  LCOV_EXCL_START */
2670 int system_setting_set_changed_callback_rotary_event_enabled(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
2671 {
2672         SETTING_TRACE_BEGIN;
2673         return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_ROTARY_EVENT_ENABLED_BOOL, SYSTEM_SETTINGS_KEY_ROTARY_EVENT_ENABLED, SYSTEM_SETTING_CALLBACK_SLOT_3, user_data);
2674 }
2675 /*  LCOV_EXCL_STOP */
2676
2677 /*  LCOV_EXCL_START */
2678 int system_setting_unset_changed_callback_rotary_event_enabled(system_settings_key_e key)
2679 {
2680         SETTING_TRACE_BEGIN;
2681         return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_ROTARY_EVENT_ENABLED_BOOL, SYSTEM_SETTING_CALLBACK_SLOT_3);
2682 }
2683 /*  LCOV_EXCL_STOP */
2684