tizen 2.4 release
[framework/location/geofence-dbus.git] / geofence / include / geofence_client.h
1 /* Copyright 2014 Samsung Electronics Co., Ltd All Rights Reserved
2  *
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15
16 /**
17  * @file        geofence_client.h
18  * @brief       This file contains the internal definitions and structures related to geofence client.
19  */
20 #ifndef __GEOFENCE_CLIENT_H__
21 #define __GEOFENCE_CLIENT_H__
22
23 __BEGIN_DECLS
24 #include <gio/gio.h>
25 #include <tizen_error.h>
26
27 typedef enum {
28     GEOFENCE_STATUS_CB = 0x01,
29     GEOFENCE_INOUT_CB = GEOFENCE_STATUS_CB << 0x01,
30 } geofence_client_callback_e;
31
32 typedef enum {
33     GEOFENCE_CLIENT_ERROR_NONE = 0x0,
34     GEOFENCE_CLIENT_ERROR_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER,
35     GEOFENCE_CLIENT_ERROR_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY,
36     GEOFENCE_CLIENT_ACCESS_DENIED = TIZEN_ERROR_PERMISSION_DENIED,
37     GEOFENCE_CLIENT_ERROR_CONNECTION = TIZEN_ERROR_GEOFENCE_MANAGER | 0x01,
38     GEOFENCE_CLIENT_ERROR_DBUS_CALL = TIZEN_ERROR_GEOFENCE_MANAGER | 0x06,
39 } geofence_client_error_e;
40
41 typedef void *geofence_client_dbus_h;
42
43 /**
44 * @brief        Callback registered by the client to get the callback for the geofence in/out status
45 */
46 typedef void (*geofence_client_cb)(const char *sig, GVariant *param, void *user_data);
47
48 #if 0
49 /**
50 * @brief        Callback registered by the client to get the callback for the geofence event status
51 */
52 typedef void (*geofence_client_event_cb)(const char *sig, GVariant *param, void *user_data);
53 #endif
54
55 /**
56 * @brief        API to add the geofence. This will call the server API.
57 * @param[in]    geofence_client - Client dbus handle
58 * @param[in]    app_id - Caller's application ID
59 * @param[in]    latitude - latitude value if is a geopoint geofence
60 * @param[in]    longitude - longitude value if it is a geopint geofence
61 * @param[in]    radius - radius value if it is a geopoint geofence
62 * @param[in]    bssid - bssid value if it is a wifi/BT geofence
63 * @return       int
64 * @retval       returns the fence-id of the geofence added
65 * @see geo_client_delete_geofence
66 */
67 int geo_client_add_geofence(geofence_client_dbus_h geofence_client, gchar *app_id, gint place_id, gint geofence_type, gdouble latitude, gdouble longitude, gint radius, const gchar *address, const gchar *bssid, const gchar *ssid);
68
69 /**
70 * @brief        API to add the place. This will call the server API
71 * @param[in]    geofence_client - Client dbus handle
72 * @param[in]    app_id - Caller's application ID
73 * @param[in]    place_name - Name of the place
74 * retval        returns the place_id of the place added
75 * @see geo_client_delete_place
76 */
77 int geo_client_add_place(geofence_client_dbus_h geofence_client, gchar *appid, const gchar *place_name);
78
79 /**
80 * @brief        API to update the place. This will call the server API
81 * @param[in]    geofence_client - Client dbus handle
82 * @param[in]    app_id - Caller's application ID
83 * @param[in]    place_id - Unique id of the place
84 * @param[in]    place_name - Name of the place[may be a new value]
85 * @return       int
86 * @retval       GEOFENCE_CLIENT_ERROR_NONE if success
87                 GEOFENCE_CLIENT_ERROR_DBUS_CALL if failure
88 * @see  geo_client_add_place
89 */
90 int geo_client_update_place(geofence_client_dbus_h geofence_client, gchar *app_id, gint place_id, const gchar *place_name);
91
92 /**
93 * @brief        API to delete the geofence from the server
94 * @param[in]    geofence_client - Client dbus handle
95 * @param[in]    app_id - Caller's application ID
96 * @param[in]    fence-id - Fence ID of the fence which needs to be deleted
97 * @return       int
98 * @retval       GEOFENCE_CLIENT_ERROR_NONE if success
99                 GEOFENCE_CLIENT_ERROR_DBUS_CALL if failure
100 * @see  geo_client_add_geofence
101 */
102 int geo_client_delete_geofence(geofence_client_dbus_h geofence_client, gchar *app_id, gint fence_id);
103
104 /**
105 * @brief        API to delete the place from the server
106 * @param[in]    geofence_client - Client dbus handle
107 * @param[in]    app_id - Caller's application ID
108 * @param[in]    place_id - Place ID of the place which needs to be deleted
109 * @return       int
110 * @retval       GEOFENCE_CLIENT_ERROR_NONE if success
111                 GEOFENCE_CLIENT_ERROR_DBUS_CALL if failure
112 * @see  geo_client_add_place
113 */
114 int geo_client_delete_place(geofence_client_dbus_h geofence_client, gchar *app_id, gint place_id);
115
116 /**
117 * @brief        API to get the place name
118 * @param[in]    geofence_client - Client dbus handle
119 * @param[in]    place_id - Place ID of the place whose name should be retrieved
120 * @param[out]   place_name - Name of the place
121 * @param[out]   error_code - Error that has occured on the server side
122 * @return       GEOFENCE_CLIENT_ERROR_NONE if success
123                 GEOFENCE_CLIENT_ERROR_DBUS_CALL if failure
124 */
125 int geo_client_get_place_name(geofence_client_dbus_h geofence_client, gchar *app_id, gint place_id, gchar **place_name, gint *error_code);
126
127 /**
128 * @brief        API to get the fence list
129 * @param[in]    geofence_client - Client dbus handle
130 * @param[in]    app_id - Caller's application ID
131 * @param[in]    place_id - ID of the place whose list has to be retrived
132 * @param[out]   iter - iterator for the array of fences
133 * @param[out]   fenceCnt - total count of the fence
134 * @param[out]   errorCode - error code for the api
135 * @return       int
136 * @retval       GEOFENCE_CLIENT_ERROR_NONE if success
137                 GEOFENCE_CLIENT_ERROR_DBUS_CALL if failure
138 */
139 int geo_client_get_geofences(geofence_client_dbus_h geofence_client, gchar *app_id, gint place_id, GVariantIter **iter, gint *fence_cnt, gint *error_code);
140
141 /**
142 * @brief        API to get the place list
143 * @param[in]    geofence_client - Client dbus handle
144 * @param[in]    app_id - Caller's application ID
145 * @param[out]   iter - iterator for the array of fences
146 * @param[out]   placeCnt - total count of the fence
147 * @param[out]   errorCode - error code for the API
148 * @return       int
149 * @retval       GEOFENCE_CLIENT_ERROR_NONE if success
150                 GEOFENCE_CLIENT_ERROR_DBUS_CALL if failure
151 */
152 int geo_client_get_places(geofence_client_dbus_h geofence_client, gchar *app_id, GVariantIter **iter, gint *fence_cnt, int *error_code);
153
154 /**
155 * @brief        API to enable the geofence. This will call the server API
156 * @param[in]    geofence_client - Client dbus handle
157 * @param[in]    app_id - Caller's application ID
158 * @param[in]    fence_id - Unique id of the fence
159 * @param[in]    bEnable - enable flag for geofence
160 */
161 int geo_client_enable_geofence(geofence_client_dbus_h geofence_client, gchar *app_id, gint geofence_id, gboolean onoff);
162
163 /**
164 * @brief        API to start the geofence service on a particular geofence
165 * @param[in]    app_id - Caller's application ID
166 * @param[in]    geofence_client - Client dbus handle
167 * @param[in]    fence-id - Fence ID of the fence for which geofence service should be started
168 * @return       int
169 * @retval       GEOFENCE_CLIENT_ERROR_NONE if success
170                 GEOFENCE_CLIENT_ERROR_DBUS_CALL if failure
171 * @see  geo_client_stop_geofence
172 */
173 int geo_client_start_geofence(geofence_client_dbus_h geofence_client, gchar *app_id, gint fence_id);
174
175 /**
176 * @brief        API to stop the geofence service on a particular geofence
177 * @param[in]    geofence_client - Client dbus handle
178 * @param[in]    app_id - Caller's application ID
179 * @param[in]    fence-id - Fence ID of the fence for which geofence service should be stopped
180 * @return       int
181 * @retval       GEOFENCE_CLIENT_ERROR_NONE if success
182                 GEOFENCE_CLIENT_ERROR_DBUS_CALL if failure
183 * @see  geo_client_start_geofence
184 */
185 int geo_client_stop_geofence(geofence_client_dbus_h geofence_client, gchar *app_id, gint fence_id);
186
187 /**
188 * @brief        API to start the client and make a subscription to the server
189 * @param[in]    geofence_client - Client dbus handle
190 * @param[in]    callback - callback registered by the client
191 * @param[in]    user_data - Data that has to come back in the callback
192 * @return       int
193 * @retval       GEOFENCE_CLIENT_ERROR_NONE - if success
194                 GEOFENCE_CLIENT_ACCESS_DENIED - if failure
195                 GEOFENCE_CLIENT_ERROR_DBUS_CALL - if failure
196 * @see  geo_client_stop
197 */
198 int geo_client_start(geofence_client_dbus_h geofence_client, geofence_client_cb callback, void *user_data);
199
200 /**
201 * @brief        API to stop the client and remove the subscription to the server
202 * @param[in]    geofence_client - Client dbus handle
203 * @return       int
204 * @retval       GEOFENCE_CLIENT_ERROR_NONE - if success
205                 GEOFENCE_CLIENT_ACCESS_DENIED - if failure
206                 GEOFENCE_CLIENT_ERROR_DBUS_CALL - if failure
207 * @see  geo_client_start
208 */
209 int geo_client_stop(geofence_client_dbus_h geofence_client);
210
211 /**
212 * @brief        API to create the connection with the server
213 * @param[in]    geofence_client - Client dbus handle
214 * @return       int
215 * @retval       GEOFENCE_CLIENT_ERROR_NONE - if success
216                 GEOFENCE_CLIENT_ERROR_CONNECTION - if failure
217 * @see  geo_client_destroy
218 */
219 int geo_client_create(geofence_client_dbus_h *geofence_client);
220
221 /**
222 * @brief        API to destroy the connection with the server
223 * @param[in]    geofence_client - Client dbus handle
224 * @return       int
225 * @retval       GEOFENCE_CLIENT_ERROR_NONE - if success
226                 GEOFENCE_CLIENT_ERROR_CONNECTION - if failure
227 * @see  geo_client_create
228 */
229 int geo_client_destroy(geofence_client_dbus_h geofence_client);
230
231 __END_DECLS
232 #endif /* __GEOFENCE_CLIENT_H__ */