summaryrefslogtreecommitdiff
path: root/geofence/include/geofence_client.h
blob: 2d739564feab41ab24894ff6feea41de6379ae7e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
/* Copyright 2014 Samsung Electronics Co., Ltd All Rights Reserved
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/**
 * @file	geofence_client.h
 * @brief	This file contains the internal definitions and structures related to geofence client.
 */
#ifndef __GEOFENCE_CLIENT_H__
#define __GEOFENCE_CLIENT_H__

__BEGIN_DECLS
#include <gio/gio.h>
#include <tizen_error.h>

typedef enum {
    GEOFENCE_STATUS_CB = 0x01,
    GEOFENCE_INOUT_CB = GEOFENCE_STATUS_CB << 0x01,
} geofence_client_callback_e;

typedef enum {
    GEOFENCE_CLIENT_ERROR_NONE = 0x0,
    GEOFENCE_CLIENT_ERROR_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER,
    GEOFENCE_CLIENT_ERROR_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY,
    GEOFENCE_CLIENT_ACCESS_DENIED = TIZEN_ERROR_PERMISSION_DENIED,
    GEOFENCE_CLIENT_ERROR_CONNECTION = TIZEN_ERROR_GEOFENCE_MANAGER | 0x01,
    GEOFENCE_CLIENT_ERROR_DBUS_CALL = TIZEN_ERROR_GEOFENCE_MANAGER | 0x06,
} geofence_client_error_e;

typedef void *geofence_client_dbus_h;

/**
* @brief	Callback registered by the client to get the callback for the geofence in/out status
*/
typedef void (*geofence_client_cb)(const char *sig, GVariant *param, void *user_data);

#if 0
/**
* @brief        Callback registered by the client to get the callback for the geofence event status
*/
typedef void (*geofence_client_event_cb)(const char *sig, GVariant *param, void *user_data);
#endif

/**
* @brief	API to add the geofence. This will call the server API.
* @param[in]	geofence_client - Client dbus handle
* @param[in]	app_id - Caller's application ID
* @param[in]	latitude - latitude value if is a geopoint geofence
* @param[in]	longitude - longitude value if it is a geopint geofence
* @param[in]	radius - radius value if it is a geopoint geofence
* @param[in]	bssid - bssid value if it is a wifi/BT geofence
* @return	int
* @retval	returns the fence-id of the geofence added
* @see geo_client_delete_geofence
*/
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);

/**
* @brief	API to add the place. This will call the server API
* @param[in]	geofence_client - Client dbus handle
* @param[in]	app_id - Caller's application ID
* @param[in]	place_name - Name of the place
* retval	returns the place_id of the place added
* @see geo_client_delete_place
*/
int geo_client_add_place(geofence_client_dbus_h geofence_client, gchar *appid, const gchar *place_name);

/**
* @brief        API to update the place. This will call the server API
* @param[in]    geofence_client - Client dbus handle
* @param[in]	app_id - Caller's application ID
* @param[in]    place_id - Unique id of the place
* @param[in]	place_name - Name of the place[may be a new value]
* @return       int
* @retval       GEOFENCE_CLIENT_ERROR_NONE if success
                GEOFENCE_CLIENT_ERROR_DBUS_CALL if failure
* @see  geo_client_add_place
*/
int geo_client_update_place(geofence_client_dbus_h geofence_client, gchar *app_id, gint place_id, const gchar *place_name);

/**
* @brief	API to delete the geofence from the server
* @param[in]	geofence_client - Client dbus handle
* @param[in]	app_id - Caller's application ID
* @param[in]	fence-id - Fence ID of the fence which needs to be deleted
* @return	int
* @retval	GEOFENCE_CLIENT_ERROR_NONE if success
		GEOFENCE_CLIENT_ERROR_DBUS_CALL if failure
* @see	geo_client_add_geofence
*/
int geo_client_delete_geofence(geofence_client_dbus_h geofence_client, gchar *app_id, gint fence_id);

/**
* @brief        API to delete the place from the server
* @param[in]    geofence_client - Client dbus handle
* @param[in]	app_id - Caller's application ID
* @param[in]    place_id - Place ID of the place which needs to be deleted
* @return       int
* @retval       GEOFENCE_CLIENT_ERROR_NONE if success
                GEOFENCE_CLIENT_ERROR_DBUS_CALL if failure
* @see  geo_client_add_place
*/
int geo_client_delete_place(geofence_client_dbus_h geofence_client, gchar *app_id, gint place_id);

/**
* @brief	API to get the place name
* @param[in]	geofence_client - Client dbus handle
* @param[in]	place_id - Place ID of the place whose name should be retrieved
* @param[out]	place_name - Name of the place
* @param[out]	error_code - Error that has occured on the server side
* @return	GEOFENCE_CLIENT_ERROR_NONE if success
		GEOFENCE_CLIENT_ERROR_DBUS_CALL if failure
*/
int geo_client_get_place_name(geofence_client_dbus_h geofence_client, gchar *app_id, gint place_id, gchar **place_name, gint *error_code);

/**
* @brief	API to get the fence list
* @param[in]	geofence_client - Client dbus handle
* @param[in]	app_id - Caller's application ID
* @param[in]	place_id - ID of the place whose list has to be retrived
* @param[out]	iter - iterator for the array of fences
* @param[out]	fenceCnt - total count of the fence
* @param[out]	errorCode - error code for the api
* @return	int
* @retval       GEOFENCE_CLIENT_ERROR_NONE if success
                GEOFENCE_CLIENT_ERROR_DBUS_CALL if failure
*/
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);

/**
* @brief        API to get the place list
* @param[in]    geofence_client - Client dbus handle
* @param[in]	app_id - Caller's application ID
* @param[out]   iter - iterator for the array of fences
* @param[out]   placeCnt - total count of the fence
* @param[out]	errorCode - error code for the API
* @return       int
* @retval       GEOFENCE_CLIENT_ERROR_NONE if success
                GEOFENCE_CLIENT_ERROR_DBUS_CALL if failure
*/
int geo_client_get_places(geofence_client_dbus_h geofence_client, gchar *app_id, GVariantIter **iter, gint *fence_cnt, int *error_code);

/**
* @brief	API to enable the geofence. This will call the server API
* @param[in]	geofence_client - Client dbus handle
* @param[in]	app_id - Caller's application ID
* @param[in]	fence_id - Unique id of the fence
* @param[in]	bEnable - enable flag for geofence
*/
int geo_client_enable_geofence(geofence_client_dbus_h geofence_client, gchar *app_id, gint geofence_id, gboolean onoff);

/**
* @brief	API to start the geofence service on a particular geofence
* @param[in]	app_id - Caller's application ID
* @param[in]	geofence_client - Client dbus handle
* @param[in]	fence-id - Fence ID of the fence for which geofence service should be started
* @return	int
* @retval	GEOFENCE_CLIENT_ERROR_NONE if success
		GEOFENCE_CLIENT_ERROR_DBUS_CALL if failure
* @see	geo_client_stop_geofence
*/
int geo_client_start_geofence(geofence_client_dbus_h geofence_client, gchar *app_id, gint fence_id);

/**
* @brief	API to stop the geofence service on a particular geofence
* @param[in]	geofence_client - Client dbus handle
* @param[in]	app_id - Caller's application ID
* @param[in]	fence-id - Fence ID of the fence for which geofence service should be stopped
* @return	int
* @retval	GEOFENCE_CLIENT_ERROR_NONE if success
		GEOFENCE_CLIENT_ERROR_DBUS_CALL if failure
* @see	geo_client_start_geofence
*/
int geo_client_stop_geofence(geofence_client_dbus_h geofence_client, gchar *app_id, gint fence_id);

/**
* @brief	API to start the client and make a subscription to the server
* @param[in]	geofence_client - Client dbus handle
* @param[in]	callback - callback registered by the client
* @param[in]	user_data - Data that has to come back in the callback
* @return	int
* @retval	GEOFENCE_CLIENT_ERROR_NONE - if success
		GEOFENCE_CLIENT_ACCESS_DENIED - if failure
		GEOFENCE_CLIENT_ERROR_DBUS_CALL - if failure
* @see	geo_client_stop
*/
int geo_client_start(geofence_client_dbus_h geofence_client, geofence_client_cb callback, void *user_data);

/**
* @brief	API to stop the client and remove the subscription to the server
* @param[in]	geofence_client - Client dbus handle
* @return	int
* @retval	GEOFENCE_CLIENT_ERROR_NONE - if success
		GEOFENCE_CLIENT_ACCESS_DENIED - if failure
		GEOFENCE_CLIENT_ERROR_DBUS_CALL - if failure
* @see	geo_client_start
*/
int geo_client_stop(geofence_client_dbus_h geofence_client);

/**
* @brief	API to create the connection with the server
* @param[in]	geofence_client - Client dbus handle
* @return	int
* @retval	GEOFENCE_CLIENT_ERROR_NONE - if success
		GEOFENCE_CLIENT_ERROR_CONNECTION - if failure
* @see	geo_client_destroy
*/
int geo_client_create(geofence_client_dbus_h *geofence_client);

/**
* @brief	API to destroy the connection with the server
* @param[in]	geofence_client - Client dbus handle
* @return	int
* @retval	GEOFENCE_CLIENT_ERROR_NONE - if success
		GEOFENCE_CLIENT_ERROR_CONNECTION - if failure
* @see	geo_client_create
*/
int geo_client_destroy(geofence_client_dbus_h geofence_client);

__END_DECLS
#endif /* __GEOFENCE_CLIENT_H__ */