Tizen 2.1 base
[platform/core/api/runtime-info.git] / src / runtime_info_location.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 <string.h>
20
21 #include <vconf.h>
22 #include <dlog.h>
23
24 #include <runtime_info.h>
25 #include <runtime_info_private.h>
26
27 #ifdef LOG_TAG
28 #undef LOG_TAG
29 #endif
30
31 #define LOG_TAG "CAPI_SYSTEM_RUNTIME_INFO"
32
33 static const char *VCONF_LOCATION_SERVICE_ENABLED = VCONFKEY_LOCATION_ENABLED;
34 static const char *VCONF_LOCATION_AGPS_ENABLED = "db/location/setting/AgpsEnabled";
35 static const char *VCONF_LOCATION_NETWORK_ENABLED = VCONFKEY_LOCATION_NETWORK_ENABLED;
36 static const char *VCONF_LOCATION_SENSOR_ENABLED = "db/location/setting/SensorEnabled";
37
38 int runtime_info_location_service_get_value(runtime_info_value_h value)
39 {
40         int vconf_value;
41
42         if (runtime_info_vconf_get_value_int(VCONF_LOCATION_SERVICE_ENABLED, &vconf_value))
43                 return RUNTIME_INFO_ERROR_IO_ERROR;
44
45         value->b = vconf_value;
46
47         return RUNTIME_INFO_ERROR_NONE;
48 }
49
50 int runtime_info_location_service_set_event_cb()
51 {
52         return runtime_info_vconf_set_event_cb(VCONF_LOCATION_SERVICE_ENABLED, RUNTIME_INFO_KEY_LOCATION_SERVICE_ENABLED, 0);
53 }
54
55 void runtime_info_location_service_unset_event_cb()
56 {
57         runtime_info_vconf_unset_event_cb(VCONF_LOCATION_SERVICE_ENABLED, 0);
58 }
59
60 int runtime_info_location_agps_get_value(runtime_info_value_h value)
61 {
62         int vconf_value;
63
64         if (runtime_info_vconf_get_value_int(VCONF_LOCATION_AGPS_ENABLED, &vconf_value))
65                 return RUNTIME_INFO_ERROR_IO_ERROR;
66
67         value->b = vconf_value;
68
69         return RUNTIME_INFO_ERROR_NONE;
70 }
71
72 int runtime_info_location_agps_set_event_cb()
73 {
74         return runtime_info_vconf_set_event_cb(VCONF_LOCATION_AGPS_ENABLED, RUNTIME_INFO_KEY_LOCATION_ADVANCED_GPS_ENABLED, 0);
75 }
76
77 void runtime_info_location_agps_unset_event_cb()
78 {
79         runtime_info_vconf_unset_event_cb(VCONF_LOCATION_AGPS_ENABLED, 0);
80 }
81
82 int runtime_info_location_network_get_value(runtime_info_value_h value)
83 {
84         int vconf_value;
85
86         if (runtime_info_vconf_get_value_int(VCONF_LOCATION_NETWORK_ENABLED, &vconf_value))
87                 return RUNTIME_INFO_ERROR_IO_ERROR;
88
89         value->b = vconf_value;
90
91         return RUNTIME_INFO_ERROR_NONE;
92 }
93
94 int runtime_info_location_network_set_event_cb()
95 {
96         return runtime_info_vconf_set_event_cb(VCONF_LOCATION_NETWORK_ENABLED, RUNTIME_INFO_KEY_LOCATION_NETWORK_POSITION_ENABLED, 0);
97 }
98
99 void runtime_info_location_network_unset_event_cb()
100 {
101         runtime_info_vconf_unset_event_cb(VCONF_LOCATION_NETWORK_ENABLED, 0);
102 }
103
104 int runtime_info_location_sensor_get_value(runtime_info_value_h value)
105 {
106         int vconf_value;
107
108         if (runtime_info_vconf_get_value_int(VCONF_LOCATION_SENSOR_ENABLED, &vconf_value))
109                 return RUNTIME_INFO_ERROR_IO_ERROR;
110
111         value->b = vconf_value;
112
113         return RUNTIME_INFO_ERROR_NONE;
114 }
115
116 int runtime_info_location_sensor_set_event_cb()
117 {
118         return runtime_info_vconf_set_event_cb(VCONF_LOCATION_SENSOR_ENABLED, RUNTIME_INFO_KEY_LOCATION_SENSOR_AIDING_ENABLED, 0);
119 }
120
121 void runtime_info_location_sensor_unset_event_cb()
122 {
123         runtime_info_vconf_unset_event_cb(VCONF_LOCATION_SENSOR_ENABLED, 0);
124 }
125