1 /* Copyright 2014 Samsung Electronics Co., Ltd All Rights Reserved
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
7 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 * @file geofence_client.h
18 * @brief This file contains the internal definitions and structures related to geofence client.
20 #ifndef __GEOFENCE_CLIENT_H__
21 #define __GEOFENCE_CLIENT_H__
25 #include <tizen_error.h>
28 GEOFENCE_STATUS_CB = 0x01,
29 GEOFENCE_INOUT_CB = GEOFENCE_STATUS_CB << 0x01,
30 } geofence_client_callback_e;
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;
41 typedef void *geofence_client_dbus_h;
44 * @brief Callback registered by the client to get the callback for the geofence in/out status
46 typedef void (*geofence_client_cb)(const char *sig, GVariant *param, void *user_data);
50 * @brief Callback registered by the client to get the callback for the geofence event status
52 typedef void (*geofence_client_event_cb)(const char *sig, GVariant *param, void *user_data);
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
64 * @retval returns the fence-id of the geofence added
65 * @see geo_client_delete_geofence
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);
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
77 int geo_client_add_place(geofence_client_dbus_h geofence_client, gchar *appid, const gchar *place_name);
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]
86 * @retval GEOFENCE_CLIENT_ERROR_NONE if success
87 GEOFENCE_CLIENT_ERROR_DBUS_CALL if failure
88 * @see geo_client_add_place
90 int geo_client_update_place(geofence_client_dbus_h geofence_client, gchar *app_id, gint place_id, const gchar *place_name);
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
98 * @retval GEOFENCE_CLIENT_ERROR_NONE if success
99 GEOFENCE_CLIENT_ERROR_DBUS_CALL if failure
100 * @see geo_client_add_geofence
102 int geo_client_delete_geofence(geofence_client_dbus_h geofence_client, gchar *app_id, gint fence_id);
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
110 * @retval GEOFENCE_CLIENT_ERROR_NONE if success
111 GEOFENCE_CLIENT_ERROR_DBUS_CALL if failure
112 * @see geo_client_add_place
114 int geo_client_delete_place(geofence_client_dbus_h geofence_client, gchar *app_id, gint place_id);
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
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);
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
136 * @retval GEOFENCE_CLIENT_ERROR_NONE if success
137 GEOFENCE_CLIENT_ERROR_DBUS_CALL if failure
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);
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
149 * @retval GEOFENCE_CLIENT_ERROR_NONE if success
150 GEOFENCE_CLIENT_ERROR_DBUS_CALL if failure
152 int geo_client_get_places(geofence_client_dbus_h geofence_client, gchar *app_id, GVariantIter **iter, gint *fence_cnt, int *error_code);
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
161 int geo_client_enable_geofence(geofence_client_dbus_h geofence_client, gchar *app_id, gint geofence_id, gboolean onoff);
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
169 * @retval GEOFENCE_CLIENT_ERROR_NONE if success
170 GEOFENCE_CLIENT_ERROR_DBUS_CALL if failure
171 * @see geo_client_stop_geofence
173 int geo_client_start_geofence(geofence_client_dbus_h geofence_client, gchar *app_id, gint fence_id);
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
181 * @retval GEOFENCE_CLIENT_ERROR_NONE if success
182 GEOFENCE_CLIENT_ERROR_DBUS_CALL if failure
183 * @see geo_client_start_geofence
185 int geo_client_stop_geofence(geofence_client_dbus_h geofence_client, gchar *app_id, gint fence_id);
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
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
198 int geo_client_start(geofence_client_dbus_h geofence_client, geofence_client_cb callback, void *user_data);
201 * @brief API to stop the client and remove the subscription to the server
202 * @param[in] geofence_client - Client dbus handle
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
209 int geo_client_stop(geofence_client_dbus_h geofence_client);
212 * @brief API to create the connection with the server
213 * @param[in] geofence_client - Client dbus handle
215 * @retval GEOFENCE_CLIENT_ERROR_NONE - if success
216 GEOFENCE_CLIENT_ERROR_CONNECTION - if failure
217 * @see geo_client_destroy
219 int geo_client_create(geofence_client_dbus_h *geofence_client);
222 * @brief API to destroy the connection with the server
223 * @param[in] geofence_client - Client dbus handle
225 * @retval GEOFENCE_CLIENT_ERROR_NONE - if success
226 GEOFENCE_CLIENT_ERROR_CONNECTION - if failure
227 * @see geo_client_create
229 int geo_client_destroy(geofence_client_dbus_h geofence_client);
232 #endif /* __GEOFENCE_CLIENT_H__ */