Divided EFL packages from capi system system setting
[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
29 #include <regex.h>
30
31 #include <dlog.h>
32 #include <vconf.h>
33
34 #include <glib.h>
35 #include <libxml/xmlmemory.h>
36 #include <libxml/parser.h>
37
38 #include <fontconfig/fontconfig.h>
39
40 #include <pkgmgr-info.h>
41
42 #include <system_settings.h>
43 #include <system_settings_private.h>
44
45 #include <tzplatform_config.h>
46
47 #ifdef USE_EFL_ASSIST
48 #include <efl_assist.h>
49 #endif
50
51 #define SETTING_FONT_CONF_FILE _TZ_SYS_ETC"/fonts/conf.avail/99-tizen.conf"
52 #define SETTING_DEFAULT_FONT_CONF_FILE _TZ_SYS_ETC"/fonts/conf.avail/99-tizen.conf"
53
54 #define SETTING_TIME_ZONEINFO_PATH              "/usr/share/zoneinfo/"
55 #define SETTING_TIME_SHARE_LOCAL_PATH   "/usr/share/locale"
56 #define SETTING_TZONE_SYMLINK_PATH              "/etc/localtime"
57
58
59 int _is_file_accessible(const char *path);
60
61 bool dl_is_supported_image_type_load(char *path);
62 bool dl_font_config_set(char *font_name);
63 char *dl_get_font_info(char *str);
64 int *dl_is_available_font(char *str);
65 void dl_font_size_set();
66 void dl_font_config_set_notification();
67
68
69 /**
70  * VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR has a path of the ringtone file which user choose
71  * @return the ringtone file path specified by user in normal case
72  *         if it's not accessable, return the default ringtone path
73  */
74 int system_setting_get_incoming_call_ringtone(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
75 {
76         SETTING_TRACE_BEGIN;
77         char *vconf_value;
78         if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR, &vconf_value)) {
79                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
80         }
81
82         /* check to see if it's accessable -> OK */
83         /* no --> default ringtone path VCONFKEY_SETAPPL_CALL_RINGTONE_DEFAULT_PATH_STR */
84         int is_load = _is_file_accessible(vconf_value);
85         if (is_load == 0) {
86                 *value = vconf_value;
87         } else { /* not zero on errro */
88                 *value = vconf_get_str(VCONFKEY_SETAPPL_CALL_RINGTONE_DEFAULT_PATH_STR);
89         }
90
91         /**value = vconf_value; */
92         return SYSTEM_SETTINGS_ERROR_NONE;
93 }
94
95
96 int system_setting_get_email_alert_ringtone(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
97 {
98         SETTING_TRACE_BEGIN;
99         char *vconf_value;
100         if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, &vconf_value)) {
101                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
102         }
103
104         /* check to see if it's accessable -> OK */
105         /* no --> default ringtone path VCONFKEY_SETAPPL_NOTI_RINGTONE_DEFAULT_PATH_STR */
106         int is_load = _is_file_accessible(vconf_value);
107         if (is_load == 0) {
108                 *value = vconf_value;
109         } else { /* not zero on errro */
110                 *value = vconf_get_str(VCONFKEY_SETAPPL_NOTI_RINGTONE_DEFAULT_PATH_STR);
111         }
112
113         return SYSTEM_SETTINGS_ERROR_NONE;
114 }
115
116
117 int system_setting_get_wallpaper_home_screen(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
118 {
119         SETTING_TRACE_BEGIN;
120         char *vconf_value;
121         if (system_setting_vconf_get_value_string(VCONFKEY_BGSET, &vconf_value)) {
122                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
123         }
124         *value = vconf_value;
125         return SYSTEM_SETTINGS_ERROR_NONE;
126 }
127
128
129 int system_setting_get_wallpaper_lock_screen(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
130 {
131         SETTING_TRACE_BEGIN;
132         char *vconf_value;
133
134         if (system_setting_vconf_get_value_string(VCONFKEY_IDLE_LOCK_BGSET, &vconf_value)) {
135                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
136         }
137         *value = vconf_value;
138
139         return SYSTEM_SETTINGS_ERROR_NONE;
140 }
141
142
143 /* [int] vconf GET */
144 int system_setting_get_font_size(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
145 {
146         SETTING_TRACE_BEGIN;
147         int vconf_value;
148
149         if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, &vconf_value)) {
150                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
151         }
152         *value = (void *)vconf_value;
153
154         return SYSTEM_SETTINGS_ERROR_NONE;
155 }
156
157
158 int system_setting_get_default_font_type(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
159 {
160         SETTING_TRACE_BEGIN;
161         char *font_name = dl_get_font_info("default");
162         if (font_name) {
163                 *value = (void *)font_name;
164                 return SYSTEM_SETTINGS_ERROR_NONE;
165         } else {
166                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
167         }
168 }
169
170 /* [int] vconf GET */
171 int system_setting_get_font_type(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
172 {
173         SETTING_TRACE_BEGIN;
174         char *font_name = dl_get_font_info("cur");
175         *value = (void *)font_name;
176
177         return SYSTEM_SETTINGS_ERROR_NONE;
178 }
179
180
181 int system_setting_get_motion_activation(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
182 {
183         SETTING_TRACE_BEGIN;
184         bool vconf_value;
185
186         if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_MOTION_ACTIVATION, &vconf_value)) {
187                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
188         }
189         *value = (void *)vconf_value;
190
191         return SYSTEM_SETTINGS_ERROR_NONE;
192 }
193
194 int system_setting_get_usb_debugging_option(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
195 {
196         SETTING_TRACE_BEGIN;
197         bool vconf_value;
198
199         if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_USB_DEBUG_MODE_BOOL, &vconf_value)) {
200                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
201         }
202         *value = (void *)vconf_value;
203
204         return SYSTEM_SETTINGS_ERROR_NONE;
205 }
206
207 int system_setting_get_3g_data_network(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
208 {
209         SETTING_TRACE_BEGIN;
210         bool vconf_value;
211
212         if (system_setting_vconf_get_value_bool(VCONFKEY_3G_ENABLE, &vconf_value)) {
213                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
214         }
215         *value = (void *)vconf_value;
216
217         return SYSTEM_SETTINGS_ERROR_NONE;
218 }
219 /*////////////////////////////////////////////////////////////////////////////////////////////////// */
220
221
222 /**
223  * get current lock scren app package name (string)
224  *
225  * @return SYSTEM_SETTINGS_ERROR_LOCKSCREEN_APP_PASSWORD_MODE raise exception if current lock type is 'password'
226  */
227 int system_setting_get_lockscreen_app(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
228 {
229         SETTING_TRACE_BEGIN;
230         char *pkg_name = NULL;
231         int locktype = -1;
232         system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_SCREEN_LOCK_TYPE_INT, &locktype);
233
234         if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_3RD_LOCK_PKG_NAME_STR, &pkg_name)) {
235                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
236         }
237
238         if (pkg_name && strcmp(pkg_name, "com.samsung.lockscreen") == 0 && locktype == SETTING_SCREEN_LOCK_TYPE_PASSWORD) {
239                 return SYSTEM_SETTINGS_ERROR_LOCKSCREEN_APP_PASSWORD_MODE;
240         }
241
242         *value = pkg_name;
243         return SYSTEM_SETTINGS_ERROR_NONE;
244 }
245
246
247 /*////////////////////////////////////////////////////////////////////////////////////////////////// */
248
249 int _is_file_accessible(const char *path)
250 {
251         SETTING_TRACE_BEGIN;
252         int ret = access(path , R_OK);
253         if (ret == 0) {
254                 SETTING_TRACE("found the file  %s", path);
255                 return 0;
256         } else {
257                 /* error code : 13 */
258                 SETTING_TRACE("found the file  %s --- error code : %d ", path, errno);
259                 return -errno;
260         }
261 }
262
263 int system_setting_set_incoming_call_ringtone(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
264 {
265         SETTING_TRACE_BEGIN;
266         char *vconf_value;
267         vconf_value = (char *)value;
268
269         int ret = _is_file_accessible(vconf_value);
270         if (ret == 0) {
271                 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR, vconf_value)) {
272                         return SYSTEM_SETTINGS_ERROR_IO_ERROR;
273                 }
274         } else {
275                 /* @todo add a common ret_handler */
276                 return ret;
277         }
278
279         return SYSTEM_SETTINGS_ERROR_NONE;
280 }
281
282
283 int system_setting_set_email_alert_ringtone(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
284 {
285         SETTING_TRACE_BEGIN;
286         char *vconf_value;
287         vconf_value = (char *)value;
288
289         int ret = _is_file_accessible(vconf_value);
290         if (ret == 0) {
291                 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, vconf_value)) {
292                         return SYSTEM_SETTINGS_ERROR_IO_ERROR;
293                 }
294         } else {
295                 /*return SYSTEM_SETTINGS_ERROR_IO_ERROR;*/
296                 /* @todo add a common ret_handler */
297                 return ret;
298         }
299
300         return SYSTEM_SETTINGS_ERROR_NONE;
301 }
302
303 bool dl_is_supported_image_type_load(char *path)
304 {
305         void *handle;
306         int error;
307         bool ret = false;
308         bool (*image_type_check)(char *path);
309
310         handle = dlopen("/usr/lib/libsystem-settings-util.so.0.1.0",  RTLD_LAZY);
311         if(!handle)
312         {
313                 SETTING_TRACE("ERROR!! canNOT find libsystem-settings-util.so.0.1.0");
314                 return false;
315         }
316
317         image_type_check = dlsym(handle, "__is_supported_image_type_load");
318         if((error = dlerror()) != NULL) {
319                 SETTING_TRACE("ERROR!! canNOT find __is_supported_image_type_load function at libsystem-settings-util.so.0.1.0");
320                 return false;
321         }
322         ret = image_type_check(path);
323         dlclose(handle);
324         return ret;
325 }
326
327 int *dl_is_available_font(char *str)
328 {
329         void *handle;
330         int error;
331         int ret = false;
332         int (*check_available_font)(char *font_name);
333
334         handle = dlopen("/usr/lib/libsystem-settings-util.so.0.1.0",  RTLD_LAZY);
335         if(!handle)
336         {
337                 SETTING_TRACE("ERROR!! canNOT find libsystem-settings-util.so.0.1.0");
338                 return false;
339         }
340
341         check_available_font = dlsym(handle, "_is_available_font");
342         if((error = dlerror()) != NULL) {
343                 SETTING_TRACE("ERROR!! canNOT find font_config_set function at libsystem-settings-util.so.0.1.0");
344                 return false;
345         }
346         ret = check_available_font(str);
347         dlclose(handle);
348         return ret;
349 }
350
351 void dl_font_size_set()
352 {
353         void *handle;
354         int error;
355         void (*set_font_size)();
356
357         handle = dlopen("/usr/lib/libsystem-settings-util.so.0.1.0",  RTLD_LAZY);
358         if(!handle)
359         {
360                 SETTING_TRACE("ERROR!! canNOT find libsystem-settings-util.so.0.1.0");
361                 return;
362         }
363
364         set_font_size = dlsym(handle, "__font_size_set");
365         if((error = dlerror()) != NULL) {
366                 SETTING_TRACE("ERROR!! canNOT find font_config_set function at libsystem-settings-util.so.0.1.0");
367                 return;
368         }
369         set_font_size();
370         dlclose(handle);
371         return;
372 }
373
374 void dl_font_config_set_notification()
375 {
376         void *handle;
377         int error;
378         void (*set_font_nodification)();
379
380         handle = dlopen("/usr/lib/libsystem-settings-util.so.0.1.0",  RTLD_LAZY);
381         if(!handle)
382         {
383                 SETTING_TRACE("ERROR!! canNOT find libsystem-settings-util.so.0.1.0");
384                 return;
385         }
386
387         set_font_nodification = dlsym(handle, "font_config_set_notification");
388         if((error = dlerror()) != NULL) {
389                 SETTING_TRACE("ERROR!! canNOT find font_config_set function at libsystem-settings-util.so.0.1.0");
390                 return;
391         }
392         set_font_nodification();
393         dlclose(handle);
394         return;
395 }
396
397 bool dl_font_config_set(char *font_name)
398 {
399         void *handle;
400         int error;
401         bool ret = false;
402         bool (*check_font_type)(char *font_name);
403
404         handle = dlopen("/usr/lib/libsystem-settings-util.so.0.1.0",  RTLD_LAZY);
405         if(!handle)
406         {
407                 SETTING_TRACE("ERROR!! canNOT find libsystem-settings-util.so.0.1.0");
408                 return false;
409         }
410
411         check_font_type = dlsym(handle, "font_config_set");
412         if((error = dlerror()) != NULL) {
413                 SETTING_TRACE("ERROR!! canNOT find font_config_set function at libsystem-settings-util.so.0.1.0");
414                 return false;
415         }
416         ret = check_font_type(font_name);
417         dlclose(handle);
418         return ret;
419 }
420
421 char *dl_get_font_info(char *str)
422 {
423         void *handle;
424         int error;
425         char* ret = NULL;
426         char *(*get_font_info)();
427
428         handle = dlopen("/usr/lib/libsystem-settings-util.so.0.1.0",  RTLD_LAZY);
429         if(!handle)
430         {
431                 SETTING_TRACE("ERROR!! canNOT find libsystem-settings-util.so.0.1.0");
432                 return false;
433         }
434
435         if(strcmp(str,"cur") == 0)
436                 get_font_info = dlsym(handle, "_get_cur_font");
437         else
438                 get_font_info = dlsym(handle, "_get_default_font");
439
440         if((error = dlerror()) != NULL) {
441                 SETTING_TRACE("ERROR!! canNOT find %s function at libsystem-settings-util.so.0.1.0", str);
442                 return false;
443         }
444         ret = get_font_info();
445         dlclose(handle);
446         return ret;
447 }
448
449 #define PATH_EXT_CHECK_REG ".(jpe?g|jpg|png|gif)$"
450 bool __is_supported_image_type_by_ext(char *file_path)
451 {
452         SETTING_TRACE_BEGIN;
453         regex_t fsm;
454         regmatch_t str[2048 + 1];
455
456         if (!file_path) return false;
457
458         int ret = false;
459         if ((ret = regcomp(&fsm, PATH_EXT_CHECK_REG, REG_ICASE | REG_EXTENDED))) {
460                 SETTING_TRACE("regular expresstion fail");
461                 return 1;
462         }
463
464         /* code */
465         if (regexec(&fsm, file_path, strlen(file_path) + 1, str, 0) == REG_NOMATCH) {
466                 /*SETTING_TRACE("FAILED - %s", file_path[i]); */
467                 ret = 0;
468         } else {
469                 /*SETTING_TRACE("MATCHED - %s", file_path[i]); */
470                 ret = 1;
471         }
472         return ret;
473 }
474 #ifdef TIZEN_WEARABLE
475 static int system_setting_get_extended_wallpaper_num(const char *file_path, unsigned int *num)
476 {
477         SETTING_TRACE_BEGIN;
478         char buffer[256];
479         const char *find_str = "extended_wallpaper_";
480         char *ch = NULL;
481
482         if (!(ch = strstr(file_path, find_str))) {
483                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
484         }
485         strncpy(buffer, file_path, ch - file_path);
486         buffer[ch - file_path] = 0;
487         sprintf(buffer + (ch - file_path), "%s%s", "", ch + strlen(find_str));
488
489         if (!isdigit(buffer[0])) {
490                 SETTING_TRACE("%s is not number", buffer);
491                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
492         }
493
494         *num = atoi(buffer);
495
496         return SYSTEM_SETTINGS_ERROR_NONE;
497 }
498
499 static int system_setting_copy_extended_wallpaper(const char *dest_file_path, const char *source_file_path)
500 {
501         SETTING_TRACE_BEGIN;
502         if (!source_file_path || !dest_file_path) {
503                 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
504         }
505
506         char buf[1024];
507
508         int fd;
509         fd = open(source_file_path, O_RDONLY);
510         if (fd < 0) {
511                 SETTING_TRACE("file open failed: %s", source_file_path);
512                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
513         }
514
515         int fd2;
516         fd2 = open(dest_file_path, O_WRONLY | O_CREAT, S_IRWXU | S_IRWXG | S_IRWXO);
517         if (fd2 < 0) {
518                 SETTING_TRACE("file creation failed: %s", dest_file_path);
519                 close(fd);
520                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
521         }
522
523         while (read(fd, buf, sizeof(buf) - 1) > 0) {
524                 write(fd2, buf, sizeof(buf) - 1);
525         }
526
527         close(fd2);
528         close(fd);
529
530         if (chmod(dest_file_path, S_IRWXU | S_IRWXG | S_IRWXO) < 0) {
531                 SETTING_TRACE("chmod failed: %s", dest_file_path);
532         }
533
534         return SYSTEM_SETTINGS_ERROR_NONE;
535 }
536
537 static int system_setting_remove_oldest_extended_wallpaper()
538 {
539         SETTING_TRACE_BEGIN;
540         DIR *dp;
541         struct dirent *dirp;
542         char *min_image_name = NULL;
543         unsigned int min_image_num = 0;
544         unsigned int temp_image_num = 0;
545         int image_count = 0;
546
547         if ((dp = opendir(_TZ_SYS_DATA"/setting/wallpaper")) == NULL) {
548                 SETTING_TRACE("opendir error");
549                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
550         }
551
552         while ((dirp = readdir(dp))) {
553                 if (!strcmp(dirp->d_name, ".") || !strcmp(dirp->d_name, ".."))
554                         continue;
555
556                 if (system_setting_get_extended_wallpaper_num(dirp->d_name, &temp_image_num)
557                     != SYSTEM_SETTINGS_ERROR_NONE) {
558                         return SYSTEM_SETTINGS_ERROR_IO_ERROR;
559                 }
560
561                 if ((image_count == 0) || (min_image_num > temp_image_num)) {
562                         min_image_num = temp_image_num;
563                         min_image_name = dirp->d_name;
564                 }
565
566                 image_count++;
567         }
568
569         char buf[512];
570         if (min_image_name) {
571                 snprintf(buf, sizeof(buf) - 1, _TZ_SYS_DATA"/setting/wallpaper/%s", min_image_name);
572                 if (remove(buf) < 0) {  /* remove oldest image */
573                         return SYSTEM_SETTINGS_ERROR_IO_ERROR;
574                 }
575         }
576
577         return SYSTEM_SETTINGS_ERROR_NONE;
578 }
579
580 static int system_setting_check_extended_wallpaper(const char *file_path)
581 {
582         char buffer[512];
583         SETTING_TRACE_BEGIN;
584         if (!file_path || !strlen(file_path))
585                 return 0;
586         snprintf(buffer, 512, "%s/.bgwallpaper", tzplatform_getenv(TZ_USER_CONTENT));
587         return (strstr(file_path, buffer) != NULL);
588 }
589
590 #define WALLPAPER_MAX_COUNT             10
591 #endif
592
593 int system_setting_set_wallpaper_home_screen(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
594 {
595         SETTING_TRACE_BEGIN;
596         char *vconf_value;
597         vconf_value = (char *)value;
598
599         bool isok  = dl_is_supported_image_type_load(vconf_value);
600         if (!isok) {
601                 /* not supported */
602                 SETTING_TRACE("path : %s is not supported file format", vconf_value);
603                 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
604         } else {
605                 SETTING_TRACE("path : %s is SUPPORT file format", vconf_value);
606         }
607
608         /* error handling here */
609         if (_is_file_accessible(vconf_value) != 0)
610                 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
611 #ifdef TIZEN_MOBILE
612         if (system_setting_vconf_set_value_string(VCONFKEY_BGSET, vconf_value)) {
613                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
614         }
615 #endif
616
617 #ifdef TIZEN_WEARABLE
618         if (system_setting_check_extended_wallpaper(vconf_value)) {     /* New extended wallpaper */
619                 DIR *dp = NULL;
620                 struct dirent *dirp;
621                 unsigned int max_image_num = 0;
622                 unsigned int temp_image_num = 0;
623                 int image_count = 0;
624
625                 if ((dp = opendir(_TZ_SYS_DATA"/setting/wallpaper")) == NULL) {
626                         SETTING_TRACE("Setting - dir open error!");
627                         return SYSTEM_SETTINGS_ERROR_IO_ERROR;
628                 }
629
630                 /* Check a max number of wallpapers */
631                 while ((dirp = readdir(dp))) {
632                         if (!strcmp(dirp->d_name, ".") || !strcmp(dirp->d_name, ".."))
633                                 continue;
634
635                         if (system_setting_get_extended_wallpaper_num(dirp->d_name, &temp_image_num)
636                             != SYSTEM_SETTINGS_ERROR_NONE) {
637                                 if (dp)
638                                         closedir(dp);
639                                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
640                         }
641
642                         if ((image_count == 0) || (max_image_num < temp_image_num)) {
643                                 max_image_num = temp_image_num;
644                         }
645
646                         image_count++;
647                 }
648                 if (dp)
649                         closedir(dp);
650
651                 /* Numbering rule: Gear is odd number */
652                 max_image_num = (max_image_num % 2 == 0) ? max_image_num + 1
653                                 : max_image_num + 2;
654
655                 char file_name_buffer[512];
656                 snprintf(file_name_buffer, sizeof(file_name_buffer) - 1,
657                          _TZ_SYS_DATA"/setting/wallpaper/extended_wallpaper_%d.jpg", max_image_num);
658
659                 /* Copy image to _TZ_SYS_DATA/setting/wallpaper/ */
660                 if (system_setting_copy_extended_wallpaper(file_name_buffer, vconf_value)
661                     != SYSTEM_SETTINGS_ERROR_NONE) {
662                         return SYSTEM_SETTINGS_ERROR_IO_ERROR;
663                 }
664
665                 /* remove oldest wallpaper */
666                 if (image_count >= WALLPAPER_MAX_COUNT) {
667                         if (system_setting_remove_oldest_extended_wallpaper()
668                             != SYSTEM_SETTINGS_ERROR_NONE) {
669                                 remove(file_name_buffer);
670                                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
671                         }
672                 }
673
674                 if (system_setting_vconf_set_value_string(VCONFKEY_BGSET, file_name_buffer)) {
675                         return SYSTEM_SETTINGS_ERROR_IO_ERROR;
676                 }
677
678                 if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_WALLPAPER_CHANGED_NOTI_INT,
679                                                        VCONFKEY_WALLPAPER_CHANGED_NOTI_GEAR)) {
680                         return SYSTEM_SETTINGS_ERROR_IO_ERROR;
681                 }
682         } else {
683                 if (system_setting_vconf_set_value_string(VCONFKEY_BGSET, vconf_value)) {
684                         return SYSTEM_SETTINGS_ERROR_IO_ERROR;
685                 }
686         }
687 #endif
688
689         return SYSTEM_SETTINGS_ERROR_NONE;
690 }
691
692 int system_setting_set_wallpaper_lock_screen(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
693 {
694         SETTING_TRACE_BEGIN;
695         char *vconf_value;
696         vconf_value = (char *)value;
697
698         bool isok  = dl_is_supported_image_type_load(vconf_value);
699         if (!isok) {
700                 /* not supported */
701                 SETTING_TRACE("path : %s is not supported file format", vconf_value);
702                 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
703         } else {
704                 SETTING_TRACE("path : %s is SUPPORT file format", vconf_value);
705         }
706
707         /* error handling here */
708         if (_is_file_accessible(vconf_value) != 0)
709                 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
710
711         if (system_setting_vconf_set_value_string(VCONFKEY_IDLE_LOCK_BGSET, vconf_value)) {
712                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
713         }
714
715         return SYSTEM_SETTINGS_ERROR_NONE;
716 }
717
718 int system_setting_set_font_size(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
719 {
720         SETTING_TRACE_BEGIN;
721         int *vconf_value;
722         vconf_value = (int *)value;
723
724         if (*vconf_value < 0 || *vconf_value > SYSTEM_SETTINGS_FONT_SIZE_GIANT) {
725                 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
726         }
727
728         if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, *vconf_value)) {
729                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
730         }
731         dl_font_size_set();
732         SETTING_TRACE_END;
733         return SYSTEM_SETTINGS_ERROR_NONE;
734 }
735 /**
736  * [internal API]
737  */
738 void *font_conf_doc_parse(char *doc_name, char *font_name)
739 {
740         SETTING_TRACE_BEGIN;
741         xmlDocPtr doc = NULL;
742         xmlNodePtr cur = NULL;
743         xmlNodePtr cur2 = NULL;
744         xmlNodePtr cur3 = NULL;
745         xmlChar *key = NULL;
746
747         doc = xmlParseFile(doc_name);
748
749         cur = xmlDocGetRootElement(doc);
750
751         if (cur == NULL) {
752                 xmlFreeDoc(doc);
753                 doc = NULL;
754                 return NULL;
755         }
756
757         if (xmlStrcmp(cur->name, (const xmlChar *)"fontconfig")) {
758                 xmlFreeDoc(doc);
759                 doc = NULL;
760                 return NULL;
761         }
762
763         cur = cur->xmlChildrenNode;
764
765         bool is_changed = false;
766         while (cur != NULL) {
767                 if ((!xmlStrcmp(cur->name, (const xmlChar *)"match"))) {
768                         cur2 = cur->xmlChildrenNode;
769                         while (cur2 != NULL) {
770                                 if ((!xmlStrcmp(cur2->name, (const xmlChar *)"edit"))) {
771                                         xmlChar *name = xmlGetProp(cur2, (const xmlChar *)"name");
772                                         /* if name is not 'family', break */
773                                         if (xmlStrcmp(name, (const xmlChar *)"family")) {
774                                                 xmlFree(name);
775                                                 name = NULL;
776                                                 break;
777                                         }
778                                         xmlFree(name);
779                                         name = NULL;
780
781                                         cur3 = cur2->xmlChildrenNode;
782                                         while (cur3 != NULL) {
783                                                 if ((!xmlStrcmp(cur3->name, (const xmlChar *)"string"))) {
784                                                         xmlNodeSetContent(cur3->xmlChildrenNode, (const xmlChar *)font_name);
785                                                         key = xmlNodeListGetString(doc, cur3->xmlChildrenNode, 1);
786                                                         xmlFree(key);
787                                                         key = NULL;
788                                                         is_changed = true;
789                                                 }
790                                                 cur3 = cur3->next;
791                                         }
792                                 }
793                                 cur2 = cur2->next;
794                         }
795                 } else if ((!xmlStrcmp(cur->name, (const xmlChar *)"alias"))) {
796                         cur2 = cur->xmlChildrenNode;
797                         while (cur2 != NULL) {
798                                 if ((!xmlStrcmp(cur2->name, (const xmlChar *)"family"))) {
799                                         xmlNodeSetContent(cur2->xmlChildrenNode, (const xmlChar *)font_name);
800                                         key = xmlNodeListGetString(doc, cur2->xmlChildrenNode, 1);
801                                         xmlFree(key);
802                                         key = NULL;
803                                         is_changed = true;
804                                 } else if ((!xmlStrcmp(cur2->name, (const xmlChar *)"prefer"))) {
805                                         cur3 = cur2->xmlChildrenNode;
806                                         while (cur3 != NULL) {
807                                                 if ((!xmlStrcmp(cur3->name, (const xmlChar *)"family"))) {
808                                                         xmlNodeSetContent(cur3->xmlChildrenNode, (const xmlChar *)font_name);
809                                                         key = xmlNodeListGetString(doc, cur3->xmlChildrenNode, 1);
810                                                         xmlFree(key);
811                                                         key = NULL;
812                                                         is_changed = true;
813                                                         cur3 = cur3->next;
814                                                         return doc;
815                                                 }
816                                                 cur3 = cur3->next;
817                                         }
818                                 }
819                                 cur2 = cur2->next;
820                         }
821                 }
822                 cur = cur->next;
823         }
824
825         if (is_changed) {
826                 return doc;
827         } else {
828                 xmlFreeDoc(doc);
829                 doc = NULL;
830                 return NULL;
831         }
832 }
833
834 int system_setting_set_font_type(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
835 {
836         SETTING_TRACE_BEGIN;
837         char *font_name = NULL;
838         font_name = (char *)value;
839
840         /* get current font list */
841         int is_found = dl_is_available_font(font_name);
842
843         if (is_found) {
844                 SETTING_TRACE("found font : %s ", font_name);
845         } else {
846                 SETTING_TRACE(" NOT found font : %s ", font_name);
847                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
848         }
849
850         bool bsave = dl_font_config_set(font_name);
851
852         if (!bsave) {
853                 SETTING_TRACE(" font type save error by font_config_set() ");
854                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
855         } else {
856                 SETTING_TRACE(" save OK - font_config_set() ");
857         }
858
859         xmlDocPtr doc = (xmlDocPtr)font_conf_doc_parse(SETTING_FONT_CONF_FILE, font_name);
860         if (doc != NULL) {
861                 xmlSaveFormatFile(SETTING_FONT_CONF_FILE, doc, 0);
862                 xmlFreeDoc(doc);
863                 doc = NULL;
864         }
865
866         dl_font_config_set_notification();
867
868         char *vconf_value;
869         vconf_value = (char *)value;
870
871         if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, vconf_value)) {
872                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
873         }
874         return SYSTEM_SETTINGS_ERROR_NONE;
875 }
876
877 int system_setting_set_motion_activation(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
878 {
879         SETTING_TRACE_BEGIN;
880         bool *vconf_value;
881         vconf_value = (bool *)value;
882         if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_MOTION_ACTIVATION, *vconf_value)) {
883                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
884         }
885         return SYSTEM_SETTINGS_ERROR_NONE;
886 }
887
888 int system_setting_set_usb_debugging_option(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
889 {
890         SETTING_TRACE_BEGIN;
891         bool *vconf_value;
892         vconf_value = (bool *)value;
893         if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_USB_DEBUG_MODE_BOOL, *vconf_value)) {
894                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
895         }
896         return SYSTEM_SETTINGS_ERROR_NONE;
897
898 }
899
900 int system_setting_set_3g_data_network(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
901 {
902         SETTING_TRACE_BEGIN;
903         bool *vconf_value;
904         vconf_value = (bool *)value;
905         if (system_setting_vconf_set_value_bool(VCONFKEY_3G_ENABLE, *vconf_value)) {
906                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
907         }
908
909         return SYSTEM_SETTINGS_ERROR_NONE;
910 }
911
912 static int category_func(const char *name, void *user_data)
913 {
914         SETTING_TRACE_BEGIN;
915         static char *category = "lock-screen";
916         if (name && !strcmp(name, category)) {
917                 SETTING_TRACE(" SAME ");
918                 return -1;
919         } else {
920                 SETTING_TRACE(" DIFFERENT -- %s, category -- %s ", name, category);
921                 return 0;
922         }
923
924         return 0;
925 }
926
927 /**
928  *
929  * set 'swipe type' if current lockscreen app is 'com.samsung.lockscreen'
930  *
931  */
932 int system_setting_set_lockscreen_app(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
933 {
934         SETTING_TRACE_BEGIN;
935         char *vconf_value;
936         vconf_value = (char *)value;            /* ex) com.samsung.lockscreen */
937
938         int r = 0;
939         pkgmgrinfo_appinfo_h handle;
940         r = pkgmgrinfo_appinfo_get_appinfo(vconf_value, &handle);
941         if (r != PMINFO_R_OK) {
942                 SETTING_TRACE("*** pkginfo failed ");
943                 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
944         } else {
945                 SETTING_TRACE("%x", handle);
946         }
947
948         int ret = pkgmgrinfo_appinfo_foreach_category(handle, category_func, (void *)"lock-screen");
949         if (ret != PMINFO_R_OK) {
950                 pkgmgrinfo_appinfo_destroy_appinfo(handle);
951                 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
952         }
953
954         pkgmgrinfo_appinfo_destroy_appinfo(handle);
955         /*----------------------------------------------------------------------------------- */
956         int locktype = -1;
957         if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_SCREEN_LOCK_TYPE_INT, &locktype)) {
958                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
959         }
960
961         if (locktype == SETTING_SCREEN_LOCK_TYPE_PASSWORD)
962                 return SYSTEM_SETTINGS_ERROR_LOCKSCREEN_APP_PASSWORD_MODE;
963
964         if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_3RD_LOCK_PKG_NAME_STR, vconf_value)) {
965                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
966         }
967
968         if (vconf_value && strcmp(vconf_value, "com.samsung.lockscreen") == 0) {
969                 if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_SCREEN_LOCK_TYPE_INT, SETTING_SCREEN_LOCK_TYPE_SWIPE)) {
970                         return SYSTEM_SETTINGS_ERROR_IO_ERROR;
971                 }
972         }
973         return SYSTEM_SETTINGS_ERROR_NONE;
974 }
975
976 /*/////////////////////////////////////////////////////////////////////////////////////////////// */
977 /* */
978
979 int system_setting_set_changed_callback_incoming_call_ringtone(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
980 {
981         SETTING_TRACE_BEGIN;
982         return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR, SYSTEM_SETTINGS_KEY_INCOMING_CALL_RINGTONE, 0, user_data);
983 }
984
985 int system_setting_unset_changed_callback_incoming_call_ringtone(system_settings_key_e key)
986 {
987         SETTING_TRACE_BEGIN;
988         return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR, 0);
989 }
990
991 int system_setting_set_changed_callback_email_alert_ringtone(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
992 {
993         SETTING_TRACE_BEGIN;
994         return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, SYSTEM_SETTINGS_KEY_EMAIL_ALERT_RINGTONE, 0, user_data);
995 }
996
997 int system_setting_unset_changed_callback_email_alert_ringtone(system_settings_key_e key)
998 {
999         SETTING_TRACE_BEGIN;
1000         return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, 0);
1001 }
1002
1003 int system_setting_set_changed_callback_wallpaper_home_screen(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1004 {
1005         SETTING_TRACE_BEGIN;
1006         return system_setting_vconf_set_changed_cb(VCONFKEY_BGSET, SYSTEM_SETTINGS_KEY_WALLPAPER_HOME_SCREEN, 0, user_data);
1007 }
1008
1009 int system_setting_unset_changed_callback_wallpaper_home_screen(system_settings_key_e key)
1010 {
1011         SETTING_TRACE_BEGIN;
1012         return system_setting_vconf_unset_changed_cb(VCONFKEY_BGSET, 0);
1013 }
1014
1015 int system_setting_set_changed_callback_wallpaper_lock_screen(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1016 {
1017         SETTING_TRACE_BEGIN;
1018         return system_setting_vconf_set_changed_cb(VCONFKEY_IDLE_LOCK_BGSET, SYSTEM_SETTINGS_KEY_WALLPAPER_LOCK_SCREEN, 0, user_data);
1019 }
1020
1021 int system_setting_unset_changed_callback_wallpaper_lock_screen(system_settings_key_e key)
1022 {
1023         SETTING_TRACE_BEGIN;
1024         return system_setting_vconf_unset_changed_cb(VCONFKEY_IDLE_LOCK_BGSET, 0);
1025 }
1026
1027 int system_setting_set_changed_callback_font_size(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1028 {
1029         SETTING_TRACE_BEGIN;
1030         return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, SYSTEM_SETTINGS_KEY_FONT_SIZE, 1, user_data);
1031 }
1032
1033 int system_setting_unset_changed_callback_font_size(system_settings_key_e key)
1034 {
1035         SETTING_TRACE_BEGIN;
1036         return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, 1);
1037 }
1038
1039 int system_setting_set_changed_callback_usb_debugging_option(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1040 {
1041         SETTING_TRACE_BEGIN;
1042         return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_USB_DEBUG_MODE_BOOL, SYSTEM_SETTINGS_KEY_USB_DEBUGGING_ENABLED, 1, user_data);
1043 }
1044
1045 int system_setting_unset_changed_callback_usb_debugging_option(system_settings_key_e key)
1046 {
1047         SETTING_TRACE_BEGIN;
1048         return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_USB_DEBUG_MODE_BOOL, 1);
1049 }
1050
1051 int system_setting_set_changed_callback_3g_data_network(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1052 {
1053         SETTING_TRACE_BEGIN;
1054         return system_setting_vconf_set_changed_cb(VCONFKEY_3G_ENABLE, SYSTEM_SETTINGS_KEY_3G_DATA_NETWORK_ENABLED, 1, user_data);
1055 }
1056
1057 int system_setting_unset_changed_callback_3g_data_network(system_settings_key_e key)
1058 {
1059         SETTING_TRACE_BEGIN;
1060         return system_setting_vconf_unset_changed_cb(VCONFKEY_3G_ENABLE, 1);
1061 }
1062
1063 int system_setting_set_changed_callback_lockscreen_app(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1064 {
1065         SETTING_TRACE_BEGIN;
1066         return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_3RD_LOCK_PKG_NAME_STR, SYSTEM_SETTINGS_KEY_LOCKSCREEN_APP, 1, user_data);
1067 }
1068
1069 int system_setting_unset_changed_callback_lockscreen_app(system_settings_key_e key)
1070 {
1071         SETTING_TRACE_BEGIN;
1072         return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_3RD_LOCK_PKG_NAME_STR, 1);
1073 }
1074
1075
1076 /**
1077  * @todo need to add custom event notification method
1078  */
1079 int system_setting_set_changed_callback_font_type(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1080 {
1081         SETTING_TRACE_BEGIN;
1082         return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, SYSTEM_SETTINGS_KEY_FONT_TYPE, 2, user_data);
1083 }
1084
1085 int system_setting_unset_changed_callback_font_type(system_settings_key_e key)
1086 {
1087         SETTING_TRACE_BEGIN;
1088         return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, 2);
1089 }
1090
1091 /* TODO : 2th argument, callback, is not in use. */
1092 int system_setting_set_changed_callback_motion_activation(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1093 {
1094         SETTING_TRACE_BEGIN;
1095         return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_MOTION_ACTIVATION, SYSTEM_SETTINGS_KEY_MOTION_ACTIVATION, 3, user_data);
1096 }
1097
1098 int system_setting_unset_changed_callback_motion_activation(system_settings_key_e key)
1099 {
1100         SETTING_TRACE_BEGIN;
1101         return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_MOTION_ACTIVATION, 3);
1102 }
1103
1104 /*//////////////////////////////////////////////////////////////////////////////////////// */
1105 /*--------------------------------------- */
1106 int system_setting_get_locale_country(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1107 {
1108         SETTING_TRACE_BEGIN;
1109         char *vconf_value = NULL;
1110         if (system_setting_vconf_get_value_string(VCONFKEY_REGIONFORMAT, &vconf_value)) {
1111                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1112         }
1113
1114         /* parsing validation */
1115         /* en_US.UTF-8 */
1116         char arr[20];
1117         snprintf(arr, 20, "%s", vconf_value);
1118         arr[5] = '\0';
1119         *value = strdup(arr);
1120         free(vconf_value);
1121         vconf_value = NULL;
1122
1123         return SYSTEM_SETTINGS_ERROR_NONE;
1124 }
1125
1126 int system_setting_set_locale_country(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1127 {
1128         SETTING_TRACE_BEGIN;
1129         char *vconf_value = NULL;
1130         vconf_value = (char *)value;
1131
1132         char *ext = "UTF-8";
1133
1134         char arr[20];
1135         snprintf(arr, 20, "%s.%s", vconf_value, ext);
1136
1137         if (system_setting_vconf_set_value_string(VCONFKEY_REGIONFORMAT, arr)) {
1138                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1139         }
1140         return SYSTEM_SETTINGS_ERROR_NONE;
1141 }
1142
1143 int system_setting_set_changed_callback_locale_country(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1144 {
1145         SETTING_TRACE_BEGIN;
1146         return system_setting_vconf_set_changed_cb(VCONFKEY_REGIONFORMAT, SYSTEM_SETTINGS_KEY_LOCALE_COUNTRY, 3, user_data);
1147 }
1148
1149 int system_setting_unset_changed_callback_locale_country(system_settings_key_e key)
1150 {
1151         SETTING_TRACE_BEGIN;
1152         return system_setting_vconf_unset_changed_cb(VCONFKEY_REGIONFORMAT, 3);
1153 }
1154
1155
1156 /*--------------------------------------- */
1157 int system_setting_get_locale_language(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1158 {
1159         SETTING_TRACE_BEGIN;
1160         char *vconf_value = NULL;
1161         if (system_setting_vconf_get_value_string(VCONFKEY_LANGSET, &vconf_value)) {
1162                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1163         }
1164
1165         /* parsing validation */
1166         /* en_US.UTF-8 */
1167         char arr[20];
1168         snprintf(arr, 20, "%s", vconf_value);
1169         arr[5] = '\0';
1170         *value = strdup(arr);
1171         free(vconf_value);
1172         vconf_value = NULL;
1173         return SYSTEM_SETTINGS_ERROR_NONE;
1174 }
1175
1176 int system_setting_set_locale_language(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1177 {
1178         SETTING_TRACE_BEGIN;
1179         char *vconf_value = NULL;
1180         vconf_value = (char *)value;
1181
1182         char *ext = "UTF-8";
1183
1184         char arr[20];
1185         snprintf(arr, 20, "%s.%s", vconf_value, ext);
1186
1187         if (system_setting_vconf_set_value_string(VCONFKEY_LANGSET, arr)) {
1188                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1189         }
1190         return SYSTEM_SETTINGS_ERROR_NONE;
1191 }
1192
1193 int system_setting_set_changed_callback_locale_language(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1194 {
1195         SETTING_TRACE_BEGIN;
1196         /*return system_setting_vconf_set_changed_cb(VCONFKEY_LANGSET, SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, 3, user_data ); */
1197         return system_setting_vconf_set_changed_cb(VCONFKEY_LANGSET, SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, 100, user_data);
1198 }
1199
1200 int system_setting_unset_changed_callback_locale_language(system_settings_key_e key)
1201 {
1202         SETTING_TRACE_BEGIN;
1203         return system_setting_vconf_unset_changed_cb(VCONFKEY_LANGSET, 100);
1204 }
1205
1206 /*--------------------------------------- */
1207 int system_setting_get_locale_timeformat_24hour(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1208 {
1209         SETTING_TRACE_BEGIN;
1210         int vconf_value;
1211
1212         if (system_setting_vconf_get_value_int(VCONFKEY_REGIONFORMAT_TIME1224, &vconf_value)) {
1213                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1214         }
1215
1216         bool ret_value = true;
1217         if (vconf_value == VCONFKEY_TIME_FORMAT_12)
1218                 ret_value = false;
1219         else if (vconf_value == VCONFKEY_TIME_FORMAT_24)
1220                 ret_value = true;
1221
1222         *value = (void *)ret_value;
1223
1224         return SYSTEM_SETTINGS_ERROR_NONE;
1225 }
1226
1227 int system_setting_set_locale_timeformat_24hour(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1228 {
1229         SETTING_TRACE_BEGIN;
1230         bool *vconf_value;
1231
1232         vconf_value = (bool *)value;
1233
1234         if (*vconf_value) {
1235                 if (system_setting_vconf_set_value_int(VCONFKEY_REGIONFORMAT_TIME1224, VCONFKEY_TIME_FORMAT_24)) {
1236                         return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1237                 }
1238
1239         } else {
1240                 if (system_setting_vconf_set_value_int(VCONFKEY_REGIONFORMAT_TIME1224, VCONFKEY_TIME_FORMAT_12)) {
1241                         return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1242                 }
1243
1244         }
1245
1246         return SYSTEM_SETTINGS_ERROR_NONE;
1247 }
1248
1249 int system_setting_set_changed_callback_locale_timeformat_24hour(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1250 {
1251         SETTING_TRACE_BEGIN;
1252         return system_setting_vconf_set_changed_cb(VCONFKEY_REGIONFORMAT_TIME1224, SYSTEM_SETTINGS_KEY_LOCALE_TIMEFORMAT_24HOUR, 3, user_data);
1253 }
1254
1255 int system_setting_unset_changed_callback_locale_timeformat_24hour(system_settings_key_e key)
1256 {
1257         SETTING_TRACE_BEGIN;
1258         return system_setting_vconf_unset_changed_cb(VCONFKEY_REGIONFORMAT_TIME1224, 3);
1259 }
1260
1261 int system_setting_get_locale_timezone(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1262 {
1263         SETTING_TRACE_BEGIN;
1264 #if 0
1265         char tzpath[256];
1266         ssize_t len = readlink(SETTING_TZONE_SYMLINK_PATH, tzpath, sizeof(tzpath) - 1);
1267         if (len != -1) {
1268                 tzpath[len] = '\0';
1269         } else {
1270                 SETTING_TRACE("parse error for SETTING_TZONE_SYMLINK_PATH");
1271                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1272         }
1273         /* "/usr/share/zoneinfo/Asia/Seoul" */
1274         SETTING_TRACE("tzpath : %s ", &tzpath[20]);
1275         *value = strdup(&tzpath[20]);
1276 #else
1277         *value = vconf_get_str(VCONFKEY_SETAPPL_TIMEZONE_ID);
1278 #endif
1279         return SYSTEM_SETTINGS_ERROR_NONE;
1280 }
1281
1282 int system_setting_set_changed_callback_locale_timezone_changed(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1283 {
1284         SETTING_TRACE_BEGIN;
1285         return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
1286 }
1287
1288 int system_setting_unset_changed_callback_locale_timezone_changed(system_settings_key_e key)
1289 {
1290         SETTING_TRACE_BEGIN;
1291         return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
1292 }
1293
1294
1295 int system_setting_get_time_changed(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1296 {
1297         SETTING_TRACE_BEGIN;
1298         time_t cur_tick;
1299         cur_tick = time(NULL);
1300         *value = (void *)cur_tick;
1301         /* struct tm * localtime = time (cur_tick); */
1302         /* printf("%s\n", ctime(&cur_tick); */
1303         return SYSTEM_SETTINGS_ERROR_NONE;
1304
1305 }
1306
1307 int system_setting_set_changed_callback_time_changed(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1308 {
1309         SETTING_TRACE_BEGIN;
1310         return system_setting_vconf_set_changed_cb(VCONFKEY_SYSTEM_TIME_CHANGED, SYSTEM_SETTINGS_KEY_TIME_CHANGED, 3, user_data);
1311 }
1312
1313 int system_setting_unset_changed_callback_time_changed(system_settings_key_e key)
1314 {
1315         SETTING_TRACE_BEGIN;
1316         return system_setting_vconf_unset_changed_cb(VCONFKEY_SYSTEM_TIME_CHANGED, 3);
1317 }
1318
1319
1320
1321 /* SYSTEM_SETTINGS_KEY_SOUND_LOCK */
1322 int system_setting_get_sound_lock(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1323 {
1324         SETTING_TRACE_BEGIN;
1325         bool vconf_value;
1326
1327         if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_SOUND_LOCK_BOOL, &vconf_value)) {
1328                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1329         }
1330         *value = (void *)vconf_value;
1331
1332         return SYSTEM_SETTINGS_ERROR_NONE;
1333 }
1334
1335 int system_setting_set_changed_callback_sound_lock(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1336 {
1337         SETTING_TRACE_BEGIN;
1338         return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_SOUND_LOCK_BOOL, SYSTEM_SETTINGS_KEY_SOUND_LOCK, 3, user_data);
1339 }
1340
1341 int system_setting_unset_changed_callback_sound_lock(system_settings_key_e key)
1342 {
1343         SETTING_TRACE_BEGIN;
1344         return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_SOUND_LOCK_BOOL, 3);
1345 }
1346
1347 /**
1348  * a = VCONFKEY_SETAPPL_SOUND_STATUS_BOOL b = VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL
1349  *
1350  * a == false, b == false --> silent mode
1351  * a == true, b == false --> sound mode
1352  * a == false, b == true --> vibration mode
1353  */
1354 int system_setting_get_sound_silent_mode(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1355 {
1356         SETTING_TRACE_BEGIN;
1357         bool sound_cond;
1358         bool vib_cond;
1359
1360         bool vconf_value;
1361         if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, &sound_cond)) {
1362                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1363         }
1364
1365         if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, &vib_cond)) {
1366                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1367         }
1368
1369         if (sound_cond == false && vib_cond == false) {
1370                 vconf_value = true;
1371                 *value = (void *)vconf_value;
1372         } else {
1373                 vconf_value = false;
1374                 *value = (void *)vconf_value;
1375         }
1376         return SYSTEM_SETTINGS_ERROR_NONE;
1377 }
1378
1379 /**
1380  * a = VCONFKEY_SETAPPL_SOUND_STATUS_BOOL b = VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL
1381  *
1382  * a == false, b == false --> silent mode
1383  * a == true, b == false --> sound mode
1384  */
1385 int system_setting_set_sound_silent_mode(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1386 {
1387         SETTING_TRACE_BEGIN;
1388         bool *vconf_value;
1389
1390         vconf_value = (bool *)value;
1391
1392         bool vconf_sound = false;
1393         bool vconf_vib = false;
1394
1395         if (*vconf_value) {
1396                 vconf_sound = false;
1397                 vconf_vib = false;
1398         } else {
1399                 vconf_sound = true;
1400                 vconf_vib = false;
1401         }
1402
1403         if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, vconf_sound)) {
1404                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1405         }
1406         if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, vconf_vib)) {
1407                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1408         }
1409
1410         return SYSTEM_SETTINGS_ERROR_NONE;
1411 }
1412
1413
1414
1415 /* TODO */
1416 int system_setting_set_changed_callback_sound_silent_mode(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1417 {
1418         SETTING_TRACE_BEGIN;
1419         return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, SYSTEM_SETTINGS_KEY_SOUND_SILENT_MODE, 3, user_data);
1420 }
1421
1422 /* TODO */
1423 int system_setting_unset_changed_callback_sound_silent_mode(system_settings_key_e key)
1424 {
1425         SETTING_TRACE_BEGIN;
1426         return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, 3);
1427 }
1428
1429 /* SYSTEM_SETTINGS_KEY_SOUND_TOUCH */
1430 int system_setting_get_sound_touch(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1431 {
1432         SETTING_TRACE_BEGIN;
1433         bool vconf_value;
1434
1435         int ret = system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL, &vconf_value);
1436         if (ret != SYSTEM_SETTINGS_ERROR_NONE) {
1437                 return ret;
1438         }
1439         *value = (void *)vconf_value;
1440         return ret;
1441 }
1442
1443 int system_setting_set_changed_callback_sound_touch(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1444 {
1445         SETTING_TRACE_BEGIN;
1446         return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL, SYSTEM_SETTINGS_KEY_SOUND_TOUCH, 2, user_data);
1447 }
1448
1449 int system_setting_unset_changed_callback_sound_touch(system_settings_key_e key)
1450 {
1451         SETTING_TRACE_BEGIN;
1452         return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL, 2);
1453 }
1454
1455 #if 0
1456 /* SYSTEM_SETTINGS_KEY_SOUND_LOCK */
1457 int system_setting_get_sound_lock(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1458 {
1459         bool vconf_value;
1460
1461         if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_SOUND_LOCK_BOOL, &vconf_value)) {
1462                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1463         }
1464         *value = (void *)vconf_value;
1465
1466         return SYSTEM_SETTINGS_ERROR_NONE;
1467 }
1468 #endif
1469
1470 int system_setting_get_auto_rotation_mode(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1471 {
1472         SETTING_TRACE_BEGIN;
1473         bool vconf_value;
1474
1475         if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, &vconf_value)) {
1476                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1477         }
1478         *value = (void *)vconf_value;
1479
1480         return SYSTEM_SETTINGS_ERROR_NONE;
1481 }
1482
1483 int system_setting_set_auto_rotation_mode(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1484 {
1485         SETTING_TRACE_BEGIN;
1486         bool *vconf_value;
1487         vconf_value = (bool *)value;
1488         if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, *vconf_value)) {
1489                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1490         }
1491
1492         return SYSTEM_SETTINGS_ERROR_NONE;
1493 }
1494
1495 int system_setting_set_changed_callback_auto_rotation_mode(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1496 {
1497         SETTING_TRACE_BEGIN;
1498         return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, SYSTEM_SETTINGS_KEY_DISPLAY_SCREEN_ROTATION_AUTO, 2, user_data);
1499 }
1500
1501 int system_setting_unset_changed_callback_auto_rotation_mode(system_settings_key_e key)
1502 {
1503         SETTING_TRACE_BEGIN;
1504         return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, 2);
1505 }
1506
1507 int system_setting_get_screen_backlight_time(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1508 {
1509         SETTING_TRACE_BEGIN;
1510         int vconf_value;
1511
1512         if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, &vconf_value)) {
1513                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1514         }
1515         *value = (void *)vconf_value;
1516
1517         return SYSTEM_SETTINGS_ERROR_NONE;
1518 }
1519
1520
1521 int system_setting_set_screen_backlight_time(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1522 {
1523         SETTING_TRACE_BEGIN;
1524         int *vconf_value;
1525         vconf_value = (int *)value;
1526
1527         if (!(*vconf_value > 0 && *vconf_value < 600)) {
1528                 SETTING_TRACE(" ERR Betweeny here  0 ~ 600");
1529                 return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
1530         }
1531
1532         if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, *vconf_value)) {
1533                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1534         }
1535         SETTING_TRACE_END;
1536         return SYSTEM_SETTINGS_ERROR_NONE;
1537 }
1538
1539 int system_setting_set_changed_callback_screen_backlight_time(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1540 {
1541         SETTING_TRACE_BEGIN;
1542         return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, SYSTEM_SETTINGS_KEY_DISPLAY_SCREEN_ROTATION_AUTO, 2, user_data);
1543 }
1544
1545 int system_setting_unset_changed_callback_screen_backlight_time(system_settings_key_e key)
1546 {
1547         SETTING_TRACE_BEGIN;
1548         return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL, 2);
1549 }
1550
1551 int system_setting_get_sound_notification(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1552 {
1553         SETTING_TRACE_BEGIN;
1554         char *vconf_value = NULL;
1555         if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, &vconf_value)) {
1556                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1557         }
1558
1559         *value = vconf_value;
1560         return SYSTEM_SETTINGS_ERROR_NONE;
1561 }
1562
1563 int system_setting_set_sound_notification(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1564 {
1565         SETTING_TRACE_BEGIN;
1566         char *vconf_value = NULL;
1567         vconf_value = (char *)value;
1568
1569         int is_load = _is_file_accessible(vconf_value);
1570         if (is_load == 0) {
1571                 if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, vconf_value)) {
1572                         return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1573                 }
1574         } else {
1575                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1576         }
1577
1578         return SYSTEM_SETTINGS_ERROR_NONE;
1579 }
1580
1581 int system_setting_set_changed_callback_sound_notification(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1582 {
1583         SETTING_TRACE_BEGIN;
1584         return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, SYSTEM_SETTINGS_KEY_INCOMING_CALL_RINGTONE, 0, user_data);
1585 }
1586
1587 int system_setting_unset_changed_callback_sound_notification(system_settings_key_e key)
1588 {
1589         SETTING_TRACE_BEGIN;
1590         return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, 0);
1591 }
1592
1593 int system_setting_get_notification_repetition_period(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1594 {
1595         SETTING_TRACE_BEGIN;
1596         int vconf_value;
1597
1598         if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_NOTI_MSG_ALERT_REP_TYPE_INT, &vconf_value)) {
1599                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1600         }
1601         *value = (void *)vconf_value;
1602
1603         return SYSTEM_SETTINGS_ERROR_NONE;
1604 }
1605
1606 int system_setting_set_notification_repetition_period(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1607 {
1608         SETTING_TRACE_BEGIN;
1609         int *vconf_value;
1610         vconf_value = (int *)value;
1611
1612         if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_NOTI_MSG_ALERT_REP_TYPE_INT, *vconf_value)) {
1613                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1614         }
1615         SETTING_TRACE_END;
1616         return SYSTEM_SETTINGS_ERROR_NONE;
1617 }
1618
1619 int system_setting_set_changed_callback_notification_repetition_period(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1620 {
1621         SETTING_TRACE_BEGIN;
1622         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);
1623 }
1624
1625 int system_setting_unset_changed_callback_notification_repetition_period(system_settings_key_e key)
1626 {
1627         SETTING_TRACE_BEGIN;
1628         return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_ALERT_REP_TYPE_INT, 1);
1629 }
1630
1631 int system_setting_get_device_name(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1632 {
1633         SETTING_TRACE_BEGIN;
1634         char *vconf_value = NULL;
1635         if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_DEVICE_NAME_STR, &vconf_value)) {
1636                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1637         }
1638
1639         *value = vconf_value;
1640         return SYSTEM_SETTINGS_ERROR_NONE;
1641 }
1642
1643 int system_setting_set_device_name(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1644 {
1645         SETTING_TRACE_BEGIN;
1646         char *vconf_value = NULL;
1647         vconf_value = (char *)value;
1648
1649         if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_DEVICE_NAME_STR, vconf_value)) {
1650                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1651         }
1652
1653         return SYSTEM_SETTINGS_ERROR_NONE;
1654 }
1655
1656 int system_setting_set_changed_callback_device_name(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1657 {
1658         SETTING_TRACE_BEGIN;
1659         return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_DEVICE_NAME_STR, SYSTEM_SETTINGS_KEY_DEVICE_NAME, 0, user_data);
1660 }
1661
1662 int system_setting_unset_changed_callback_device_name(system_settings_key_e key)
1663 {
1664         SETTING_TRACE_BEGIN;
1665         return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_DEVICE_NAME_STR, 0);
1666 }
1667
1668 /*---------------------------------------------- */
1669 int system_setting_get_network_flight_mode(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1670 {
1671         SETTING_TRACE_BEGIN;
1672         bool vconf_value;
1673         if (system_setting_vconf_get_value_bool(VCONFKEY_TELEPHONY_FLIGHT_MODE, &vconf_value)) {
1674                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1675         }
1676         *value = (void *)vconf_value;
1677
1678         return SYSTEM_SETTINGS_ERROR_NONE;
1679 }
1680
1681 int system_setting_set_changed_callback_network_flight_mode(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1682 {
1683         SETTING_TRACE_BEGIN;
1684         return system_setting_vconf_set_changed_cb(VCONFKEY_TELEPHONY_FLIGHT_MODE, SYSTEM_SETTINGS_KEY_NETWORK_FLIGHT_MODE, 3, user_data);
1685 }
1686
1687 int system_setting_unset_changed_callback_network_flight_mode(system_settings_key_e key)
1688 {
1689         SETTING_TRACE_BEGIN;
1690         return system_setting_vconf_unset_changed_cb(VCONFKEY_TELEPHONY_FLIGHT_MODE, 3);
1691 }
1692
1693 int system_setting_get_network_wifi_notification(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1694 {
1695         SETTING_TRACE_BEGIN;
1696         int vconf_value;
1697         if (system_setting_vconf_get_value_int(VCONFKEY_WIFI_ENABLE_QS, &vconf_value)) {
1698                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1699         }
1700         bool bret ;
1701         bret = (vconf_value == VCONFKEY_WIFI_QS_ENABLE) ? true : false;
1702
1703         *value = (void *)bret;
1704         return SYSTEM_SETTINGS_ERROR_NONE;
1705 }
1706
1707 int system_setting_set_changed_callback_network_wifi_notification(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1708 {
1709         SETTING_TRACE_BEGIN;
1710         return system_setting_vconf_set_changed_cb(VCONFKEY_WIFI_ENABLE_QS, SYSTEM_SETTINGS_KEY_NETWORK_WIFI_NOTIFICATION, 4, user_data);
1711 }
1712
1713 int system_setting_unset_changed_callback_network_wifi_notification(system_settings_key_e key)
1714 {
1715         SETTING_TRACE_BEGIN;
1716         return system_setting_vconf_unset_changed_cb(VCONFKEY_WIFI_ENABLE_QS, 4);
1717 }
1718
1719 int system_setting_get_lock_state(system_settings_key_e key, system_setting_data_type_e data_type, void **value)
1720 {
1721         int vconf_value;
1722
1723         if (system_setting_vconf_get_value_int(VCONFKEY_IDLE_LOCK_STATE_READ_ONLY, &vconf_value)) {
1724                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1725         }
1726         *value = (void *)vconf_value;
1727
1728         return SYSTEM_SETTINGS_ERROR_NONE;
1729 }
1730
1731 int system_setting_set_lock_state(system_settings_key_e key, system_setting_data_type_e data_type, void *value)
1732 {
1733         SETTING_TRACE_BEGIN;
1734         int *vconf_value;
1735         vconf_value = (int *)value;
1736
1737         if (system_setting_vconf_set_value_int(VCONFKEY_IDLE_LOCK_STATE_READ_ONLY, *vconf_value)) {
1738                 return SYSTEM_SETTINGS_ERROR_IO_ERROR;
1739         }
1740         SETTING_TRACE_END;
1741         return SYSTEM_SETTINGS_ERROR_NONE;
1742 }
1743
1744 int system_setting_set_changed_callback_lock_state(system_settings_key_e key, system_settings_changed_cb callback, void *user_data)
1745 {
1746         return system_setting_vconf_set_changed_cb(VCONFKEY_IDLE_LOCK_STATE_READ_ONLY, SYSTEM_SETTINGS_KEY_LOCK_STATE, 4, user_data);
1747 }
1748
1749 int system_setting_unset_changed_callback_lock_state(system_settings_key_e key)
1750 {
1751         return system_setting_vconf_unset_changed_cb(VCONFKEY_IDLE_LOCK_STATE_READ_ONLY, 4);
1752 }
1753
1754