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