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_dbus_server.h
18 * @brief This file contains the APIs and callback functions for the dbus server.
21 #ifndef __GEOFENCE_DBUS_SERVER_H__
22 #define __GEOFENCE_DBUS_SERVER_H__
28 GEOFENCE_DBUS_SERVER_ERROR_NONE = 0x0,
29 GEOFENCE_DBUS_SERVER_ERROR_UNKNOWN,
30 GEOFENCE_DBUS_SERVER_ERROR_PARAMETER,
31 GEOFENCE_DBUS_SERVER_ERROR_MEMORY,
32 GEOFENCE_DBUS_SERVER_ERROR_CONNECTION,
33 GEOFENCE_DBUS_SERVER_ERROR_STATUS,
34 GEOFENCE_DBUS_SERVER_ERROR_DBUS_CALL,
35 GEOFENCE_DBUS_SERVER_ERROR_NO_RESULT,
36 } geofence_dbus_server_error_e;
39 typedef void *geofence_dbus_server_h;
42 #if SUPPORT_MULTI_CLIENT
44 * @brief Callback for setting the options
46 typedef void (*GeofenceDbusSetOptionsCB)(GVariant *options, gpointer userdata);
50 * @brief Callback for shutting down the Dbus
52 typedef void (*GeofenceDbusShutdownCB)(gpointer userdata, gboolean shutdown_arr);
55 /* for geofence callbacks */
58 * @brief Callback for adding the fence
60 typedef gint(*GeofenceAddGeofenceCB)(const gchar *app_id, gint place_id, gint geofence_type, gdouble latitude, gdouble longitude, gint radius, const gchar *address, const gchar *bssid, const gchar *ssid, gpointer userdata);
63 * @brief Callback for deleting the geofence
65 typedef void (*GeofenceDeleteGeofenceCB)(gint fence_id, const gchar *app_id, gpointer userdata);
68 * @brief Callback for getting the fence list
70 typedef GVariant *(*GeofenceGetGeofencesCB)(int place_id, const gchar *app_id, int *fence_cnt, int *error_code, gpointer userdata);
73 * @brief Callback for enabling the geofence
75 typedef void (*GeofenceEnableGeofenceCB)(gint fence_id, const gchar *app_id, gboolean enable, gpointer userdata);
78 * @brief Callback for Starting the Geofence service
80 typedef void (*GeofenceStartGeofenceCB)(gint fence_id, const gchar *app_id, gpointer userdata);
83 * @brief Callback for Stopping the Geofence service
85 typedef void (*GeofenceStopGeofenceCB)(gint fence_id, const gchar *app_id, gpointer userdata);
88 /* for place callbacks */
91 * @brief Callback for adding the place
93 typedef gint(*GeofenceAddPlaceCB)(const gchar *app_id, const gchar *place_name, gpointer userdata);
96 * @brief Callback for deleting the place
98 typedef void (*GeofenceDeletePlaceCB)(gint place_id, const gchar *app_id, gpointer userdata);
101 * @brief Callback for updating the place
103 typedef void (*GeofenceUpdatePlaceCB)(gint place_id, const gchar *app_id, const gchar *place_name, gpointer userdata);
106 * @brief Callback for getting the place name
108 typedef void (*GeofenceGetPlaceNameCB)(int place_id, const gchar *app_id, char **place_name, int *error_code, gpointer userdata);
111 * @brief Callback for getting the place list
113 typedef GVariant *(*GeofenceGetPlacesCB)(const gchar *app_id, int *fence_cnt, int *error_code, gpointer userdata);
116 * @brief API to send the geofence status to the application
117 * @param[in] geofence_dbus_server - The dbus server
118 * @param[in] app_id - The application to which the status needs to be sent
119 * @param[in] fence_state - The state of the fence whether in/out
121 * @retval GEOFENCE_DBUS_SERVER_ERROR_NONE
123 int geofence_dbus_server_send_geofence_inout_changed(geofence_dbus_server_h geofence_dbus_server, const gchar *app_id, gint fence_id, gint access_type, gint fence_state);
125 int geofence_dbus_server_send_geofence_event_changed(geofence_dbus_server_h geofence_dbus_server, gint place_id, gint fence_id, gint access_type, const gchar *app_id, gint error, gint state);
128 #if SUPPORT_MULTI_CLIENT
130 GeofenceDbusSetOptionsCB set_options_cb;
132 GeofenceDbusShutdownCB shutdown_cb;
134 GeofenceAddGeofenceCB add_geofence_cb;
135 GeofenceDeleteGeofenceCB delete_geofence_cb;
136 GeofenceGetGeofencesCB get_geofences_cb;
137 GeofenceEnableGeofenceCB enable_geofence_cb;
138 GeofenceStartGeofenceCB start_geofence_cb;
139 GeofenceStopGeofenceCB stop_geofence_cb;
141 GeofenceAddPlaceCB add_place_cb;
142 GeofenceUpdatePlaceCB update_place_cb;
143 GeofenceDeletePlaceCB delete_place_cb;
144 GeofenceGetPlaceNameCB get_place_name_cb;
145 GeofenceGetPlacesCB get_places_cb;
146 } geofence_dbus_callback_s;
150 * @brief API to create the server
151 * @param[in] service_name - Name of the service for which the server has to be created
152 * @param[in] service_path - Path for the service
153 * @param[in] geofence_dbus_server - Dbus server pointer
154 * @param[in] geofence_dbus_callback - Callback for all dbus interface
155 * @param[in] userdata - Userdata if any which will come back in the callbacks
157 * retval GEOFENCE_DBUS_SERVER_ERROR_NONE if success
158 GEOFENCE_DBUS_SERVER_ERROR_MEMORY if failure
160 int geofence_dbus_server_create(geofence_dbus_server_h *geofence_dbus_server, geofence_dbus_callback_s *geofence_dbus_callback, gpointer userdata);
163 * @brief API to destroy the dbus server which was created
164 * @param[in] geofence_dbus_server - Handle to the dbus server which was created
166 * @retval GEOFENCE_DBUS_SERVER_ERROR_NONE if sucess
167 GEOFENCE_DBUS_SERVER_ERROR_PARAMETER if failure
169 int geofence_dbus_server_destroy(geofence_dbus_server_h geofence_dbus_server);
172 #endif /* __GEOFENCE_DBUS_SERVER_H__ */