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