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