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