tizen beta release
[framework/location/gps-manager.git] / gps-manager / setting.c
1 /*
2  * gps-manager
3  *
4  * Copyright (c) 2011 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact: Youngae Kang <youngae.kang@samsung.com>, Yunhan Kim <yhan.kim@samsung.com>,
7  *          Genie Kim <daejins.kim@samsung.com>, Minjune Kim <sena06.kim@samsung.com>
8  *
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  * http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  */
21
22 #include <string.h>
23 #include <glib.h>
24 #include "setting.h"
25 #include "debug_util.h"
26
27 int setting_set_int(const char *path, int val)
28 {
29         int ret = vconf_set_int(path, val);
30         if (ret == 0) {
31                 ret = TRUE;
32         } else {
33                 LOG_GPS(DBG_ERR, "vconf_set_int failed, [%s]", path);
34                 ret = FALSE;
35         }
36         return ret;
37 }
38
39 int setting_get_int(const char *path, int *val)
40 {
41         int ret = vconf_get_int(path, val);
42         if (ret == 0) {
43                 ret = TRUE;
44         } else {
45                 LOG_GPS(DBG_ERR, "vconf_get_int failed, [%s]", path);
46                 ret = FALSE;
47         }
48         return ret;
49 }
50
51 int setting_set_double(const char *path, double val)
52 {
53         int ret = vconf_set_dbl(path, val);
54         if (ret == 0) {
55                 ret = TRUE;
56         } else {
57                 LOG_GPS(DBG_ERR, "vconf_set_dbl failed, [%s]", path);
58                 ret = FALSE;
59         }
60         return ret;
61 }
62
63 int setting_get_double(const char *path, double *val)
64 {
65         int ret = vconf_get_dbl(path, val);
66         if (ret == 0) {
67                 ret = TRUE;
68         } else {
69                 LOG_GPS(DBG_ERR, "vconf_get_int failed, [%s]", path);
70                 ret = FALSE;
71         }
72         return ret;
73 }
74
75 int setting_set_string(const char *path, const char *val)
76 {
77         int ret = vconf_set_str(path, val);
78         if (ret == 0) {
79                 ret = TRUE;
80         } else {
81                 LOG_GPS(DBG_ERR, "vconf_set_str failed, [%s]", path);
82                 ret = FALSE;
83         }
84         return ret;
85 }
86
87 char *setting_get_string(const char *path)
88 {
89         return vconf_get_str(path);
90 }
91
92 int setting_notify_key_changed(const char *path, void *key_changed_cb)
93 {
94         int ret = TRUE;
95         if (vconf_notify_key_changed(path, key_changed_cb, NULL) != 0) {
96                 LOG_GPS(DBG_ERR, "Fail to vconf_notify_key_changed [%s]", path);
97                 ret = FALSE;
98         }
99         return ret;
100 }
101
102 int setting_ignore_key_changed(const char *path, void *key_changed_cb)
103 {
104         int ret = TRUE;
105         if (vconf_ignore_key_changed(path, key_changed_cb) != 0) {
106                 LOG_GPS(DBG_ERR, "Fail to vconf_ignore_key_changed [%s]", path);
107                 ret = FALSE;
108         }
109         return ret;
110 }