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