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