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