tizen 2.4 release
[framework/location/geofence-dbus.git] / server / include / geofence_dbus_server.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_dbus_server.h
18  * @brief       This file contains the APIs and callback functions for the dbus server.
19  */
20
21 #ifndef __GEOFENCE_DBUS_SERVER_H__
22 #define __GEOFENCE_DBUS_SERVER_H__
23
24 __BEGIN_DECLS
25 #include <gio/gio.h>
26
27 typedef enum {
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;
37
38
39 typedef void *geofence_dbus_server_h;
40
41
42 #if SUPPORT_MULTI_CLIENT
43 /**
44 * @brief        Callback for setting the options
45 */
46 typedef void (*GeofenceDbusSetOptionsCB)(GVariant *options, gpointer userdata);
47 #endif
48
49 /**
50 * @brief        Callback for shutting down the Dbus
51 */
52 typedef void (*GeofenceDbusShutdownCB)(gpointer userdata, gboolean shutdown_arr);
53
54
55 /* for geofence callbacks */
56
57 /**
58 * @brief        Callback for adding the fence
59 */
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);
61
62 /**
63 * @brief        Callback for deleting the geofence
64 */
65 typedef void (*GeofenceDeleteGeofenceCB)(gint fence_id, const gchar *app_id, gpointer userdata);
66
67 /**
68 * @brief        Callback for getting the fence list
69 */
70 typedef GVariant *(*GeofenceGetGeofencesCB)(int place_id, const gchar *app_id, int *fence_cnt, int *error_code, gpointer userdata);
71
72 /**
73 * @brief        Callback for enabling the geofence
74 */
75 typedef void (*GeofenceEnableGeofenceCB)(gint fence_id, const gchar *app_id, gboolean enable, gpointer userdata);
76
77 /**
78 * @brief        Callback for Starting the Geofence service
79 */
80 typedef void (*GeofenceStartGeofenceCB)(gint fence_id, const gchar *app_id, gpointer userdata);
81
82 /**
83 * @brief        Callback for Stopping the Geofence service
84 */
85 typedef void (*GeofenceStopGeofenceCB)(gint fence_id, const gchar *app_id, gpointer userdata);
86
87
88 /* for place callbacks */
89
90 /**
91 * @brief        Callback for adding the place
92 */
93 typedef gint(*GeofenceAddPlaceCB)(const gchar *app_id, const gchar *place_name, gpointer userdata);
94
95 /**
96 * @brief        Callback for deleting the place
97 */
98 typedef void (*GeofenceDeletePlaceCB)(gint place_id, const gchar *app_id, gpointer userdata);
99
100 /**
101 * @brief        Callback for updating the place
102 */
103 typedef void (*GeofenceUpdatePlaceCB)(gint place_id, const gchar *app_id, const gchar *place_name, gpointer userdata);
104
105 /**
106 * @brief        Callback for getting the place name
107 */
108 typedef void (*GeofenceGetPlaceNameCB)(int place_id, const gchar *app_id, char **place_name, int *error_code, gpointer userdata);
109
110 /**
111 * @brief        Callback for getting the place list
112 */
113 typedef GVariant *(*GeofenceGetPlacesCB)(const gchar *app_id, int *fence_cnt, int *error_code, gpointer userdata);
114
115 /**
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
120 * @return       int
121 * @retval       GEOFENCE_DBUS_SERVER_ERROR_NONE
122 */
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);
124
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);
126
127 typedef struct {
128 #if SUPPORT_MULTI_CLIENT
129         /* size_t size; */
130         GeofenceDbusSetOptionsCB set_options_cb;
131 #endif
132         GeofenceDbusShutdownCB shutdown_cb;
133
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;
140
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;
147
148
149 /**
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
156 * return        int
157 * retval        GEOFENCE_DBUS_SERVER_ERROR_NONE if success
158                 GEOFENCE_DBUS_SERVER_ERROR_MEMORY if failure
159 */
160 int geofence_dbus_server_create(geofence_dbus_server_h *geofence_dbus_server, geofence_dbus_callback_s *geofence_dbus_callback, gpointer userdata);
161
162 /**
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
165 * @return       int
166 * @retval       GEOFENCE_DBUS_SERVER_ERROR_NONE if sucess
167                 GEOFENCE_DBUS_SERVER_ERROR_PARAMETER if failure
168 */
169 int geofence_dbus_server_destroy(geofence_dbus_server_h geofence_dbus_server);
170
171 __END_DECLS
172 #endif /* __GEOFENCE_DBUS_SERVER_H__ */