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