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