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