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