1 /* Copyright (c) 2013, The Linux Foundation. All rights reserved.
2  *
3  * Redistribution and use in source and binary forms, with or without
4  * modification, are permitted provided that the following conditions are
5  * met:
6  *     * Redistributions of source code must retain the above copyright
7  *       notice, this list of conditions and the following disclaimer.
8  *     * Redistributions in binary form must reproduce the above
9  *       copyright notice, this list of conditions and the following
10  *       disclaimer in the documentation and/or other materials provided
11  *       with the distribution.
12  *     * Neither the name of The Linux Foundation, nor the names of its
13  *       contributors may be used to endorse or promote products derived
14  *       from this software without specific prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
17  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
19  * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
20  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
23  * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
25  * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
26  * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  */
28 
29 #ifndef _DS_CLIENT_H_
30 #define _DS_CLIENT_H_
31 
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35 
36 typedef void* dsClientHandleType;
37 
38 typedef enum
39 {
40   E_DS_CLIENT_SUCCESS                              = 0,
41   /**< Request was successful. */
42 
43   E_DS_CLIENT_FAILURE_GENERAL                      = 1,
44   /**< Failed because of a general failure. */
45 
46   E_DS_CLIENT_FAILURE_UNSUPPORTED                  = 2,
47   /**< Failed because the service does not support the command. */
48 
49   E_DS_CLIENT_FAILURE_INVALID_PARAMETER            = 3,
50   /**< Failed because the request contained invalid parameters. */
51 
52   E_DS_CLIENT_FAILURE_ENGINE_BUSY                  = 4,
53   /**< Failed because the engine is busy. */
54 
55   E_DS_CLIENT_FAILURE_PHONE_OFFLINE                = 5,
56   /**< Failed because the phone is offline. */
57 
58   E_DS_CLIENT_FAILURE_TIMEOUT                      = 6,
59   /**< Failed because of a timeout. */
60 
61   E_DS_CLIENT_FAILURE_SERVICE_NOT_PRESENT          = 7,
62   /**< Failed because the service is not present. */
63 
64   E_DS_CLIENT_FAILURE_SERVICE_VERSION_UNSUPPORTED  = 8,
65   /**< Failed because the service version is unsupported. */
66 
67   E_DS_CLIENT_FAILURE_CLIENT_VERSION_UNSUPPORTED  =  9,
68   /**< Failed because the service does not support client version. */
69 
70   E_DS_CLIENT_FAILURE_INVALID_HANDLE               = 10,
71   /**< Failed because an invalid handle was specified. */
72 
73   E_DS_CLIENT_FAILURE_INTERNAL                     = 11,
74   /**< Failed because of an internal error in the service. */
75 
76   E_DS_CLIENT_FAILURE_NOT_INITIALIZED              = 12,
77   /**< Failed because the service has not been initialized. */
78 
79   E_DS_CLIENT_FAILURE_NOT_ENOUGH_MEMORY             = 13,
80   /**< Failed because not rnough memory to do the operation.*/
81 
82   E_DS_CLIENT_SERVICE_ALREADY_STARTED               = 14,
83   /*Service is already started*/
84 
85   E_DS_CLIENT_DATA_CALL_CONNECTED                   = 15,
86 
87   E_DS_CLIENT_DATA_CALL_DISCONNECTED                = 16,
88 
89   E_DS_CLIENT_RETRY_LATER                           = 17
90 }ds_client_status_enum_type;
91 
92 typedef enum {
93     DATA_CALL_NONE = 0,
94     DATA_CALL_OPEN,
95     DATA_CALL_CLOSE
96 }data_call_request_enum_type;
97 
98 typedef void (*ds_client_event_ind_cb_type)(ds_client_status_enum_type result,
99                                              void* loc_adapter_cookie);
100 typedef struct {
101     ds_client_event_ind_cb_type event_cb;
102 }ds_client_cb_data;
103 
104 /*
105   This function is to be called as a first step by each process that
106   needs to use data services. This call internally calls dsi_init()
107   and prepares the module for making data calls.
108   Needs to be called once for every process
109 */
110 int ds_client_init();
111 
112 /*
113   Obtains a handle to the dsi_netctrl layer and looks up the profile
114   to make the call. As of now. It only searches for profiles that
115   support emergency calls
116  */
117 ds_client_status_enum_type ds_client_open_call(dsClientHandleType *client_handle,
118                                                ds_client_cb_data *callback,
119                                                void *loc_adapter_cookie,
120                                                int *profile_index,
121                                                int *pdp_type);
122 
123 /*
124   Starts a data call using the profile number provided
125  */
126 ds_client_status_enum_type ds_client_start_call(dsClientHandleType client_handle,
127                                                 int profile_index,
128                                                 int pdp_type);
129 
130 /*
131   Stops a data call associated with the handle
132 */
133 ds_client_status_enum_type ds_client_stop_call(dsClientHandleType client_handle);
134 
135 /*
136   Releases the handle used for making data calls
137 */
138 void ds_client_close_call(dsClientHandleType *client_handle);
139 
140 #ifdef __cplusplus
141 }
142 #endif
143 
144 #endif
145