Set the SMACK security label to run given executable file in systemd services, and...
[platform/core/location/lbs-server.git] / lbs-server / include / gps_plugin_intf.h
1 /*
2  * lbs-server
3  *
4  * Copyright (c) 2011-2013 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact: Youngae Kang <youngae.kang@samsung.com>, Minjune Kim <sena06.kim@samsung.com>
7  *                      Genie Kim <daejins.kim@samsung.com>
8  *
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  * http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  */
21
22 #ifndef _GPS_PLUGIN_PLUGIN_INTF_H_
23 #define _GPS_PLUGIN_PLUGIN_INTF_H_
24
25 #include <gps_plugin_data_types.h>
26 #include <gps_plugin_extra_data_types.h>
27
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31
32 #define GPS_PLUGIN_PATH LIB_DIR"/libSLP-lbs-plugin.so"
33 #define MAX_REQUESTER_ID_LEN    (128)
34 #define MAX_CLIENT_NAME_LEN     (128)
35 #define MAX_SUPL_URL_LEN        (128)
36
37 /**
38  * GPS asynchronous event type
39  */
40 typedef enum {
41         GPS_EVENT_START_SESSION                 = 0x0000,       /**< The session is started */
42         GPS_EVENT_STOP_SESSION,                                         /**< The session is stopped */
43         GPS_EVENT_CHANGE_INTERVAL,                                      /**< Change updating interval */
44         GPS_EVENT_REPORT_POSITION               = 0x0100,       /**< Bring up GPS position data */
45         GPS_EVENT_REPORT_SATELLITE,                                     /**< Bring up GPS SV data */
46         GPS_EVENT_REPORT_NMEA,                                          /**< Bring up GPS NMEA data */
47         GPS_EVENT_REPORT_BATCH,                                         /**< Bring up GPS batch data */
48         GPS_EVENT_SET_OPTION                    = 0x0200,       /**< The option is set */
49         GPS_EVENT_GET_REF_LOCATION              = 0x0300,       /**< Get the reference location for AGPS */
50         GPS_EVENT_GET_IMSI,                                                     /**< Get IMSI for identification */
51         GPS_EVENT_OPEN_DATA_CONNECTION  = 0x0400,       /**< Request opening data network connection */
52         GPS_EVENT_CLOSE_DATA_CONNECTION,                        /**< Request closing data network connection */
53         GPS_EVENT_DNS_LOOKUP_IND,                                       /**< Request resolving host name */
54         GPS_EVENT_AGPS_VERIFICATION_INDI,                       /**< Verification indicator for AGPS is required */
55         GPS_EVENT_FACTORY_TEST                  = 0x0500,       /**< Factory test is done */
56         GPS_EVENT_GEOFENCE_TRANSITION   = 0x0600,       /**< Geofence transition is occured */
57         GPS_EVENT_GEOFENCE_STATUS,                                      /**< Report geofence serivce status */
58         GPS_EVENT_ADD_GEOFENCE,                                         /**< Geofence is added(Start geofence) */
59         GPS_EVENT_DELETE_GEOFENCE,                                      /**< Geofence is deleted(Stop geofence) */
60         GPS_EVENT_PAUSE_GEOFENCE,                                       /**< Geofence is paused */
61         GPS_EVENT_RESUME_GEOFENCE,                                      /**< Geofence is resumed */
62         GPS_EVENT_ERR_CAUSE                             = 0xFFFF        /**< Some error is occurred */
63 } gps_event_id_t;
64
65 /**
66  * Start session response event data
67  */
68 typedef struct {
69         gps_error_t error;
70 } gps_start_session_ev_info_t;
71
72 /**
73  * Response of stop session
74  */
75 typedef struct {
76         gps_error_t error;
77 } gps_stop_session_ev_info_t;
78
79 /**
80  * Set option response event data
81  */
82 typedef struct {
83         gps_error_t error;
84 } gps_set_option_ev_info_t;
85
86 typedef struct {
87         gps_error_t error;
88 } gps_change_interval_ev_info_t;
89
90 /**
91  * Position data from GPS
92  */
93 typedef struct {
94         gps_error_t error;
95         pos_data_t pos;
96 } gps_pos_ev_info_t;
97
98 /**
99  * Batch data from GPS
100  */
101 typedef struct {
102         gps_error_t error;
103         batch_data_t batch;
104 } gps_batch_ev_info_t;
105
106 /**
107  * Satellite data from GPS
108  */
109 typedef struct {
110         gps_error_t error;
111         sv_data_t sv;
112 } gps_sv_ev_info_t;
113
114 /**
115  * NMEA data from GPS
116  */
117 typedef struct {
118         gps_error_t error;
119         nmea_data_t nmea;
120 } gps_nmea_ev_info_t;
121
122 /**
123  * This enumeration defines values for notify type for GPS verification message.
124  */
125 typedef enum {
126         AGPS_NOTIFY_NO_VERIFY                   = 0x00,
127         AGPS_NOTIFY_ONLY                                = 0x01,
128         AGPS_NOTIFY_ALLOW_NORESPONSE    = 0x02,
129         AGPS_NOTIFY_NOTALLOW_NORESPONSE = 0x03,
130         AGPS_NOTIFY_PRIVACY_NEEDED              = 0x04,
131         AGPS_NOTIFY_PRIVACY_OVERRIDE    = 0x05
132 } agps_notify_t;
133
134 /**
135  * This enumeration defines values for requester type for GPS verification message
136  */
137 typedef enum {
138         AGPS_REQ_LOGICAL_NAME   = 0x00, /**< Specifies logical name. */
139         AGPS_REQ_EMAIL_ADDR             = 0x01, /**< Specifies e-mail address */
140         AGPS_REQ_MSISDN                 = 0x02, /**< Specifies MSISDN number */
141         AGPS_REQ_URL                    = 0x03, /**< Specifies URL */
142         AGPS_REQ_SIPURL                 = 0x04, /**< Specifies SIPURL */
143         AGPS_REQ_MIN                    = 0x05, /**< Specifies MIN */
144         AGPS_REQ_MDN                    = 0x06, /**< Specifies MDN */
145         AGPS_REQ_UNKNOWN                = 0x07  /**< Unknown request */
146 } agps_supl_format_t;
147
148 /**
149  * This enumeration defines values for GPS encoding type for GPS verification message.
150  */
151 typedef enum {
152         AGPS_ENCODE_ISO646IRV           = 0x00,
153         AGPS_ENCODE_ISO8859                     = 0x01,
154         AGPS_ENCODE_UTF8                        = 0x02,
155         AGPS_ENCODE_UTF16                       = 0x03,
156         AGPS_ENCODE_UCS2                        = 0x04,
157         AGPS_ENCODE_GSMDEFAULT          = 0x05,
158         AGPS_ENCODE_SHIFT_JIS           = 0x06,
159         AGPS_ENCODE_JIS                         = 0x07,
160         AGPS_ENCODE_EUC                         = 0x08,
161         AGPS_ENCODE_GB2312                      = 0x09,
162         AGPS_ENCODE_CNS11643            = 0x0A,
163         AGPS_ENCODE_KSC1001                     = 0x0B,
164         AGPS_ENCODE_GERMAN                      = 0x0C,
165         AGPS_ENCODE_ENGLISH                     = 0x0D,
166         AGPS_ENCODE_ITALIAN                     = 0x0E,
167         AGPS_ENCODE_FRENCH                      = 0x0F,
168         AGPS_ENCODE_SPANISH                     = 0x10,
169         AGPS_ENCODE_DUTCH                       = 0x11,
170         AGPS_ENCODE_SWEDISH                     = 0x12,
171         AGPS_ENCODE_DANISH                      = 0x13,
172         AGPS_ENCODE_PORTUGUESE          = 0x14,
173         AGPS_ENCODE_FINNISH                     = 0x15,
174         AGPS_ENCODE_NORWEGIAN           = 0x16,
175         AGPS_ENCODE_GREEK                       = 0x17,
176         AGPS_ENCODE_TURKISH                     = 0x18,
177         AGPS_ENCODE_HUNGARIAN           = 0x19,
178         AGPS_ENCODE_POLISH                      = 0x1A,
179         AGPS_ENCODE_LANGUAGE_UNSPEC     = 0xFF
180 } agps_encoding_scheme_t;
181
182 /**
183  * This enumeration defines values for GPS encoding type for GPS verification message.
184  */
185 typedef enum {
186         AGPS_ID_ENCODE_ISO646IRV                = 0x00,
187         AGPS_ID_ENCODE_EXN_PROTOCOL_MSG = 0x01,
188         AGPS_ID_ENCODE_ASCII                    = 0x02,
189         AGPS_ID_ENCODE_IA5                              = 0x03,
190         AGPS_ID_ENCODE_UNICODE                  = 0x04,
191         AGPS_ID_ENCODE_SHIFT_JIS                = 0x05,
192         AGPS_ID_ENCODE_KOREAN                   = 0x06,
193         AGPS_ID_ENCODE_LATIN_HEBREW             = 0x07,
194         AGPS_ID_ENCODE_LATIN                    = 0x08,
195         AGPS_ID_ENCODE_GSM                              = 0x09
196 } agps_requester_id_encoding_t;
197
198 /**
199  * This structure defines the values for GPS Verification message indication.
200  */
201 typedef struct {
202         /** Specifies notification type refer enum tapi_gps_notify_type_t */
203         agps_notify_t                           notify_type;
204
205         /** Specifies encoding type refer enum tapi_gps_encoding_type_t */
206         agps_supl_format_t                      supl_format;
207
208         /** Specifies requester type */
209         agps_encoding_scheme_t          datacoding_scheme;
210
211         agps_requester_id_encoding_t requester_id_encoding;
212
213         /** Specifies requester ID */
214         char                                            requester_id[MAX_REQUESTER_ID_LEN];
215
216         /** Specifies client name */
217         char                                            client_name[MAX_CLIENT_NAME_LEN];
218
219         /** Response timer */
220         int                                                     resp_timer;
221 } agps_verification_ev_info_t;
222
223 /**
224  * Factory test result information
225  */
226 typedef struct {
227         gps_error_t error;
228         int                     prn;
229         double          snr;
230 } gps_factory_test_ev_info_t;
231
232 /**
233  * DNS query request information
234  */
235 typedef struct {
236         gps_error_t error;
237         char            domain_name[MAX_SUPL_URL_LEN];
238 } gps_dns_query_ev_info_t;
239
240 /**
241  * Geofecne transition information
242  */
243 typedef struct {
244         time_t geofence_timestamp;
245         int geofence_id;
246         pos_data_t pos;
247         geofence_zone_state_t state;
248 } geofence_transition_ev_info_t;
249
250 /**
251  * Geofecne status information
252  */
253 typedef struct {
254         geofence_status_t status;
255         pos_data_t last_pos;
256 } geofence_status_ev_info_t;
257
258 /**
259  * Geofecne event information
260  */
261 typedef struct {
262         int geofence_id;
263         geofence_error_t error;
264 } geofence_event_t;
265
266 /**
267  * GPS event info
268  */
269 typedef union {
270         /** Callback related with Response */
271         gps_start_session_ev_info_t             start_session_rsp;
272         gps_stop_session_ev_info_t              stop_session_rsp;
273         gps_set_option_ev_info_t                set_option_rsp;
274         gps_change_interval_ev_info_t   change_interval_rsp;
275
276         /** Callback related with Indication */
277         gps_pos_ev_info_t                       pos_ind;
278         gps_sv_ev_info_t                        sv_ind;
279         gps_nmea_ev_info_t                      nmea_ind;
280         gps_batch_ev_info_t                     batch_ind;
281         agps_verification_ev_info_t agps_verification_ind;
282
283         gps_factory_test_ev_info_t      factory_test_rsp;
284         gps_dns_query_ev_info_t         dns_query_ind;
285
286         /** Callback related with Geofence. */
287         geofence_transition_ev_info_t   geofence_transition_ind;
288         geofence_status_ev_info_t               geofence_status_ind;
289         geofence_event_t                                geofence_event_rsp;
290 } gps_event_data_t;
291
292 /**
293  * Transport Error Cause
294  */
295 typedef enum {
296         GPS_FAILURE_CAUSE_NORMAL        = 0x00,
297         GPS_FAILURE_CAUSE_FACTORY_TEST,
298         GPS_FAILURE_CAUSE_DNS_QUERY
299 } gps_failure_reason_t;
300
301 /**
302  * GPS Event Info
303  */
304 typedef struct {
305         gps_event_id_t          event_id;               /**< GPS asynchronous event id */
306         gps_event_data_t        event_data;             /**< GPS event information data */
307 } gps_event_info_t;
308
309 /**
310  * Callback function
311  * LBS server needs to register a callback function with GPS OEM to receive asynchronous events.
312  */
313 typedef int (*gps_event_cb)(gps_event_info_t *gps_event_info, void *user_data);
314
315 /**
316  * GPS action type
317  */
318 typedef enum {
319         GPS_ACTION_SEND_PARAMS  = 0x000,
320         GPS_ACTION_START_SESSION,
321         GPS_ACTION_STOP_SESSION,
322         GPS_ACTION_START_BATCH,
323         GPS_ACTION_STOP_BATCH,
324         GPS_ACTION_CHANGE_INTERVAL,
325
326         GPS_INDI_SUPL_VERIFICATION,
327         GPS_INDI_SUPL_DNSQUERY,
328
329         GPS_ACTION_START_FACTTEST,
330         GPS_ACTION_STOP_FACTTEST,
331         GPS_ACTION_REQUEST_SUPL_NI,
332         GPS_ACTION_DELETE_GPS_DATA,
333
334         GPS_ACTION_ADD_GEOFENCE,
335         GPS_ACTION_DELETE_GEOFENCE,
336         GPS_ACTION_PAUSE_GEOFENCE,
337         GPS_ACTION_RESUME_GEOFENCE,
338 } gps_action_t;
339
340 /**
341  * Cell information type
342  */
343 typedef enum {
344         GPS_CELL_INFO_TYPE_aRFCNPresent = 0,
345         GPS_CELL_INFO_TYPE_bSICPresent,
346         GPS_CELL_INFO_TYPE_rxLevPresent,
347         GPS_CELL_INFO_TYPE_frequencyInfoPresent,
348         GPS_CELL_INFO_TYPE_cellMeasuredResultPresent,
349
350         GPS_CELL_INFO_TYPE_refMCC,
351         GPS_CELL_INFO_TYPE_refMNC,
352         GPS_CELL_INFO_TYPE_refLAC,
353         GPS_CELL_INFO_TYPE_refCI,
354         GPS_CELL_INFO_TYPE_refUC,
355         GPS_CELL_INFO_TYPE_aRFCN,
356         GPS_CELL_INFO_TYPE_bSIC,
357         GPS_CELL_INFO_TYPE_rxLev
358 } agps_cell_info_t;
359
360 /**
361  * Mobile service type
362  */
363 typedef enum {
364         SVCTYPE_NONE = 0,       /**< Unknown network */
365         SVCTYPE_NOSVC,          /**< Network in no service */
366         SVCTYPE_EMERGENCY,      /**< Network emergency */
367         SVCTYPE_SEARCH,         /**< Network search 1900 */
368         SVCTYPE_2G,             /**< Network 2G */
369         SVCTYPE_2_5G,           /**< Network 2.5G */
370         SVCTYPE_2_5G_EDGE,      /**< Network EDGE */
371         SVCTYPE_3G,             /**< Network UMTS */
372         SVCTYPE_HSDPA           /**< Network HSDPA */
373 } agps_svc_type_t;
374
375 /**
376  * SUPL network-initiated information
377  */
378 typedef struct {
379         char *msg_body;         /**< SUPL NI message body */
380         int msg_size;           /**< SUPL NI message size */
381         int status;                     /**< Return code of Status */
382 } agps_supl_ni_info_t;
383
384 /**
385  * Geofence action data type
386  */
387 typedef struct {
388         geofence_data_t geofence;
389         geofence_zone_state_t last_state;
390         int monitor_states;
391         int notification_responsiveness_ms;
392         int unknown_timer_ms;
393 } geofence_action_data_t;
394
395 typedef struct {
396         int interval;
397         int period;
398 } gps_action_start_data_t;
399
400 typedef struct {
401         int interval;
402 } gps_action_change_interval_data_t;
403
404 /**
405  * gps-plugin plugin interface
406  */
407 typedef struct {
408         /** Initialize plugin module and register callback function for event delivery. */
409         int (*init)(gps_event_cb gps_event_cb, void *user_data);
410
411         /** Deinitialize plugin module */
412         int (*deinit)(gps_failure_reason_t *reason_code);
413
414         /** Request specific action to plugin module */
415         int (*request)(gps_action_t gps_action, void *gps_action_data, gps_failure_reason_t *reason_code);
416 } gps_plugin_interface;
417
418 const gps_plugin_interface *get_gps_plugin_interface();
419
420 #ifdef __cplusplus
421 }
422 #endif
423 #endif /* _GPS_PLUGIN_INTF_H_ */