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