Fix the dbus permission problem in mesh
[platform/core/connectivity/bluetooth-frwk.git] / include / bluetooth-telephony-api.h
1 /*
2  * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 #ifndef _BLUETOOTH_TELEPHONY_API_H_
19 #define _BLUETOOTH_TELEPHONY_API_H_
20
21 #include <stdint.h>
22 #include <glib.h>
23 #include <dlog.h>
24
25 #ifdef __cplusplus
26 extern "C" {
27 #endif /*__cplusplus*/
28
29 typedef void (*bt_telephony_func_ptr)(int, void *, void *);
30
31 #define BLUETOOTH_TELEPHONY_ERROR_NONE ((int)0)
32 #define BLUETOOTH_TELEPHONY_ERROR_INTERNAL \
33                                 ((int)BLUETOOTH_TELEPHONY_ERROR_NONE - 0x01)
34 #define BLUETOOTH_TELEPHONY_ERROR_INVALID_PARAM \
35                                 ((int)BLUETOOTH_TELEPHONY_ERROR_NONE - 0x02)
36 #define BLUETOOTH_TELEPHONY_ERROR_ALREADY_INITIALIZED \
37                                 ((int)BLUETOOTH_TELEPHONY_ERROR_NONE - 0x03)
38 #define BLUETOOTH_TELEPHONY_ERROR_NOT_INITIALIZED \
39                                 ((int)BLUETOOTH_TELEPHONY_ERROR_NONE - 0x04)
40 #define BLUETOOTH_TELEPHONY_ERROR_AUDIO_NOT_CONNECTED \
41                                 ((int)BLUETOOTH_TELEPHONY_ERROR_NONE - 0x05)
42 #define BLUETOOTH_TELEPHONY_ERROR_NOT_ENABLED \
43                                 ((int)BLUETOOTH_TELEPHONY_ERROR_NONE - 0x06)
44 #define BLUETOOTH_TELEPHONY_ERROR_NOT_AVAILABLE \
45                                 ((int)BLUETOOTH_TELEPHONY_ERROR_NONE - 0x07)
46 #define BLUETOOTH_TELEPHONY_ERROR_NOT_CONNECTED \
47                                 ((int)BLUETOOTH_TELEPHONY_ERROR_NONE - 0x08)
48 #define BLUETOOTH_TELEPHONY_ERROR_BUSY \
49                                 ((int)BLUETOOTH_TELEPHONY_ERROR_NONE - 0x09)
50 #define BLUETOOTH_TELEPHONY_ERROR_ALREADY_EXSIST \
51                                 ((int)BLUETOOTH_TELEPHONY_ERROR_NONE - 0x0A)
52 #define BLUETOOTH_TELEPHONY_ERROR_NO_MEMORY \
53                                 ((int)BLUETOOTH_TELEPHONY_ERROR_NONE - 0x0B)
54 #define BLUETOOTH_TELEPHONY_ERROR_I_O_ERROR \
55                                 ((int)BLUETOOTH_TELEPHONY_ERROR_NONE - 0x0C)
56 #define BLUETOOTH_TELEPHONY_ERROR_ALREADY_CONNECTED \
57                                 ((int)BLUETOOTH_TELEPHONY_ERROR_NONE - 0x0D)
58 #define BLUETOOTH_TELEPHONY_ERROR_OPERATION_NOT_AVAILABLE \
59                                 ((int)BLUETOOTH_TELEPHONY_ERROR_NONE - 0x0E)
60 #define BLUETOOTH_TELEPHONY_ERROR_PERMISSION_DENIED \
61                                         ((int)BLUETOOTH_TELEPHONY_ERROR_NONE - 0x0F)
62
63 #define BT_ADDRESS_STR_LEN 18
64 #define BT_ADAPTER_PATH_LEN 50
65 #define BT_AUDIO_CALL_PATH_LEN 50
66
67 typedef struct {
68         int event;
69         int result;
70         void *param_data;
71 } telephony_event_param_t;
72
73 typedef struct {
74          int callid;
75 } telephony_event_callid_t;
76
77 typedef struct {
78         gchar *dtmf;
79 } telephony_event_dtmf_t;
80
81 typedef struct {
82         const gchar *remote_address;
83         guint battery_level;
84 } telephony_event_hf_battery_level_t;
85
86 typedef enum {
87         BLUETOOTH_STATE_CONNECTED,
88         BLUETOOTH_STATE_PLAYING,
89         BLUETOOTH_STATE_DISCONNETED,
90 } bluetooth_headset_state_t;
91
92 typedef enum {
93         BLUETOOTH_TELEPHONY_ERROR_INVALID_CHLD_INDEX,
94         BLUETOOTH_TELEPHONY_ERROR_BATTERY_STATUS,
95         BLUETOOTH_TELEPHONY_ERROR_SIGNAL_STATUS,
96         BLUETOOTH_TELEPHONY_ERROR_NOT_SUPPORTED,
97         BLUETOOTH_TELEPHONY_ERROR_APPLICATION,
98         BLUETOOTH_TELEPHONY_ERROR_INVALID_DTMF,
99 } bluetooth_telephony_error_t;
100
101 typedef enum {
102         CSD_CALL_STATUS_IDLE,
103         CSD_CALL_STATUS_CREATE,
104         CSD_CALL_STATUS_COMING,
105         CSD_CALL_STATUS_PROCEEDING,
106         CSD_CALL_STATUS_MO_ALERTING,
107         CSD_CALL_STATUS_MT_ALERTING,
108         CSD_CALL_STATUS_WAITING,
109         CSD_CALL_STATUS_ANSWERED,
110         CSD_CALL_STATUS_ACTIVE,
111         CSD_CALL_STATUS_MO_RELEASE,
112         CSD_CALL_STATUS_MT_RELEASE,
113         CSD_CALL_STATUS_HOLD_INITIATED,
114         CSD_CALL_STATUS_HOLD,
115         CSD_CALL_STATUS_RETRIEVE_INITIATED,
116         CSD_CALL_STATUS_RECONNECT_PENDING,
117         CSD_CALL_STATUS_TERMINATED,
118         CSD_CALL_STATUS_SWAP_INITIATED,
119 } bt_telephony_call_status_t;
120
121 #define BLUETOOTH_EVENT_TYPE_TELEPHONY_BASE     (unsigned int)(0x00500)
122
123 typedef enum {
124         BLUETOOTH_EVENT_TELEPHONY_ANSWER_CALL = BLUETOOTH_EVENT_TYPE_TELEPHONY_BASE,
125         BLUETOOTH_EVENT_TELEPHONY_RELEASE_CALL,
126         BLUETOOTH_EVENT_TELEPHONY_REJECT_CALL,
127         BLUETOOTH_EVENT_TELEPHONY_CHLD_0_RELEASE_ALL_HELD_CALL,
128         BLUETOOTH_EVENT_TELEPHONY_CHLD_1_RELEASE_ALL_ACTIVE_CALL,
129         BLUETOOTH_EVENT_TELEPHONY_CHLD_2_ACTIVE_HELD_CALL,
130         BLUETOOTH_EVENT_TELEPHONY_CHLD_3_MERGE_CALL,
131         BLUETOOTH_EVENT_TELEPHONY_CHLD_4_EXPLICIT_CALL_TRANSFER,
132         BLUETOOTH_EVENT_TELEPHONY_SEND_DTMF,
133         BLUETOOTH_EVENT_TELEPHONY_HFP_CONNECTED,
134         BLUETOOTH_EVENT_TELEPHONY_HFP_DISCONNECTED,
135         BLUETOOTH_EVENT_TELEPHONY_AUDIO_CONNECTED,
136         BLUETOOTH_EVENT_TELEPHONY_AUDIO_DISCONNECTED,
137         BLUETOOTH_EVENT_TELEPHONY_SET_SPEAKER_GAIN,
138         BLUETOOTH_EVENT_TELEPHONY_SET_MIC_GAIN,
139         BLUETOOTH_EVENT_TELEPHONY_NREC_CHANGED,
140         BLUETOOTH_EVENT_TELEPHONY_VENDOR_AT_CMD,
141         BLUETOOTH_EVENT_TELEPHONY_HF_BATTERY_LEVEL_CHANGED,
142 } bluetooth_telephony_event_type;
143
144 typedef enum {
145         BLUETOOTH_CALL_STATE_NONE,
146         BLUETOOTH_CALL_STATE_CONNECTED,
147         BLUETOOTH_CALL_STATE_HELD,
148         BLUETOOTH_CALL_STATE_DIALLING,
149         BLUETOOTH_CALL_STATE_ALERTING,
150         BLUETOOTH_CALL_STATE_INCOMING,
151         BLUETOOTH_CALL_STATE_WAITING,
152         BLUETOOTH_CALL_STATE_ERROR,
153 } bt_telephony_call_state_t;
154
155 typedef enum {
156         BLUETOOTH_AGENT_ERROR_NONE,
157         BLUETOOTH_AGENT_ERROR_INTERNAL,
158         BLUETOOTH_AGENT_ERROR_NOT_AVAILABLE,
159         BLUETOOTH_AGENT_ERROR_NOT_CONNECTED,
160         BLUETOOTH_AGENT_ERROR_BUSY,
161         BLUETOOTH_AGENT_ERROR_INVALID_PARAM,
162         BLUETOOTH_AGENT_ERROR_ALREADY_EXSIST,
163         BLUETOOTH_AGENT_ERROR_ALREADY_CONNECTED,
164         BLUETOOTH_AGENT_ERROR_NO_MEMORY,
165         BLUETOOTH_AGENT_ERROR_I_O_ERROR,
166         BLUETOOTH_AGENT_ERROR_OPERATION_NOT_AVAILABLE,
167         BLUETOOTH_AGENT_ERROR_NO_CALL_LOGS,
168         BLUETOOTH_AGENT_ERROR_INVALID_MEMORY_INDEX,
169         BLUETOOTH_AGENT_ERROR_INVALID_CHLD_INDEX,
170         BLUETOOTH_AGENT_ERROR_BATTERY_STATUS,
171         BLUETOOTH_AGENT_ERROR_SIGNAL_STATUS,
172         BLUETOOTH_AGENT_ERROR_NOT_SUPPORTED,
173         BLUETOOTH_AGENT_ERROR_INVALID_NUMBER,
174         BLUETOOTH_AGENT_ERROR_APPLICATION,
175         BLUETOOTH_AGENT_ERROR_INVALID_DTMF,
176 } bluetooth_telephony_agent_error_t;
177
178 typedef struct {
179         unsigned int call_id;
180         bt_telephony_call_state_t call_status;
181         char *phone_number;
182 } bt_telephony_call_status_info_t;
183
184 /**
185  * @brief       The function bluetooth_telephony_init is initialize telephony calls.
186  *
187  * @param[in]   cb      Callback function
188  * @param[in]   user_data       Data sent by application, which will be
189  *                              returned in event handler.
190  * @return      int     Zero on Success or reason for error if any.
191  *
192  */
193 int bluetooth_telephony_init(bt_telephony_func_ptr cb, void  *user_data);
194
195 /**
196  * @brief       The function bluetooth_telephony_deinit is deinitialize telephony calls.
197  *
198  * @return      int     Zero on Success or reason for error if any.
199  *
200  */
201 int bluetooth_telephony_deinit(void);
202
203 /**
204  * @brief       The function bluetooth_telephony_audio_open is to open SCO channel
205  *
206  * @return      int     Zero on Success or reason for error if any.
207  *
208  */
209 int bluetooth_telephony_audio_open(void);
210
211 /**
212  * @brief       The function bluetooth_telephony_audio_close is to close SCO channel.
213  *      that the Volume on AG is changed.
214  *
215  * @return      int     Zero on Success or reason for error if any.
216  *
217  */
218 int bluetooth_telephony_audio_close(void);
219
220 /**
221   * @brief      The function bluetooth_telephony_call_remote_ringing is send
222   *     call status.
223  *
224  * @param[in]   call_id Call Id.
225  * @return      int     Zero on Success or reason for error if any.
226  *
227  */
228 int bluetooth_telephony_call_remote_ringing(unsigned int call_id);
229
230 /**
231  * @brief       The function bluetooth_telephony_call_answered is called to
232  *      answer calls.
233  *
234  * @param[in]   call_id Call Id.
235   * @param[in]  bt_audio        flag
236  * @return      int     Zero on Success or reason for error if any.
237  *
238  */
239 int bluetooth_telephony_call_answered(unsigned int call_id,
240                                                 unsigned int bt_audio);
241
242 /**
243  * @brief       The function bluetooth_telephony_call_end to end call
244  *
245  * @param[in]   call_id Call Id.
246  * @return      int     Zero on Success or reason for error if any.
247  *
248  */
249 int bluetooth_telephony_call_end(unsigned int call_id);
250
251 /**
252  * @brief       The function bluetooth_telephony_call_held to hold call
253  *
254  * @param[in]   call_id Call Id.
255  * @return      int     Zero on Success or reason for error if any.
256  *
257  */
258 int bluetooth_telephony_call_held(unsigned int call_id);
259
260 /**
261  * @brief       The function bluetooth_telephony_call_retrieved to retrieve call
262  *
263  * @param[in]   call_id Call Id.
264  * @return      int     Zero on Success or reason for error if any.
265  *
266  */
267 int bluetooth_telephony_call_retrieved(unsigned int call_id);
268
269 /**
270  * @brief       The function bluetooth_telephony_call_swapped to swap call
271  *
272  * @param[in]   call_list       Call info such as id and status.
273  * @param[in]   call_count      Call count.
274  * @return      int     Zero on Success or reason for error if any.
275  *
276  */
277 int bluetooth_telephony_call_swapped(void *call_list,
278                                 unsigned int call_count);
279
280 /**
281  * @brief       The function bluetooth_telephony_set_call_status to set call status
282  *
283  * @param[in]   call_list       Call info such as id and status.
284  * @param[in]   call_count      Call count.
285  * @return      int     Zero on Success or reason for error if any.
286  *
287  */
288 int bluetooth_telephony_set_call_status(void *call_list,
289                                 unsigned int call_count);
290
291 /**
292  * @brief       The function bluetooth_telephony_indicate_outgoing_call toindicate
293  *      outgoing call.
294  *
295  * @param[in]   ph_number       Phone number of the outgoing call.
296  * @param[in]   call_id         Call ID.
297  * @param[in]   bt_audio                Flag.
298  * @return      int     Zero on Success or reason for error if any.
299  *
300  */
301 int bluetooth_telephony_indicate_outgoing_call(
302                 const char *ph_number, unsigned int call_id,
303                 unsigned int bt_audio);
304
305 /**
306  * @brief       The function bluetooth_telephony_indicate_incoming_call  to indicate
307  *      incoming call.
308  *
309  * @param[in]   call_info       Call info such as id and status.
310  * @param[in]   call_count      Call count.
311  * @return      int     Zero on Success or reason for error if any.
312  *
313  */
314 int bluetooth_telephony_indicate_incoming_call(
315                 const char *ph_number, unsigned int call_id);
316
317 /**
318  * @brief       The function bluetooth_telephony_is_sco_connected  to check
319  *              if SCO channel is connected.
320  *
321  * @return      gboolean        TRUE if headset playing else FALSE.
322  *
323  */
324 gboolean bluetooth_telephony_is_sco_connected(void);
325
326 /**
327  * @brief       The function bluetooth_telephony_is_nrec_enabled  to check
328  *              for noise reduction and echo cancelation(nrec) status
329  *
330  * @return      int     Zero on Success or reason for error if any.
331  *
332  */
333 int bluetooth_telephony_is_nrec_enabled(gboolean *status);
334
335 /**
336  * @brief       The function bluetooth_telephony_is_nrec_enabled  to check
337  *              for wide band speech status
338  *
339  * @return      int     Zero on Success or reason for error if any.
340  *
341  */
342 int bluetooth_telephony_is_wbs_mode(gboolean *status);
343
344 /**
345  * @brief This function send XSAT vendor specific AT command
346  *
347  * @return      int     Zero on Success or reason for error if any.
348  */
349 int bluetooth_telephony_send_vendor_cmd(const char *cmd);
350
351
352 /**
353  * @brief This function sends request to enable voice recognition feature
354  *
355  * @return      int     Zero on Success or reason for error if any.
356  */
357 int bluetooth_telephony_start_voice_recognition(void);
358
359 /**
360  * @brief This function sends request to disable voice recognition feature
361  *
362  * @return      int     Zero on Success or reason for error if any.
363  */
364 int bluetooth_telephony_stop_voice_recognition(void);
365
366
367 /**
368  * @brief       The function bluetooth_telephony_get_headset_volume is called to get
369  *      the changed Volume on AG.
370  *
371  * @param[out]  speaker_gain            Speaker gain.
372  * @return      int     Zero on Success or reason for error if any.
373  *
374  */
375 int bluetooth_telephony_get_headset_volume(unsigned int *speaker_gain);
376
377 /**
378  * @brief       The function bluetooth_telephony_set_speaker_gain is called to indicate
379  *      that the Volume on AG is changed.
380  *
381  * @param[in]   speaker_gain            Speaker gain.
382  * @return      int     Zero on Success or reason for error if any.
383  *
384  */
385 int bluetooth_telephony_set_speaker_gain(unsigned short speaker_gain);
386
387 /**
388  * @brief       The function bluetooth_telephony_get_battery_level is called to get
389  *      the changed battery level on AG.
390  *
391  * @param[in]   remote_address  Remote Addr.
392  * @param[out]  level                   Battery level.
393  * @return      int     Zero on Success or reason for error if any.
394  *
395  */
396 int bluetooth_telephony_get_battery_level(
397                         const char *remote_address, unsigned int *level);
398
399 /**
400  * @brief       The function bluetooth_telephony_is_connected is called to get
401  *      the connection state on AG.
402  *
403  * @param[in]   ag_connnected   Connection state.
404  * @return      int     Zero on Success or reason for error if any.
405  *
406  */
407 int bluetooth_telephony_is_connected(gboolean *ag_connected);
408
409 /**
410  * @brief       The function bluetooth_telephony_set_active_headset is called to select
411  *      the active headset device for AG role if more than one headset is connected.
412  *
413  * @param[in]   remote_addr     Remote Addr.
414  * @return      int     Zero on Success or reason for error if any.
415  *
416  */
417 int bluetooth_telephony_set_active_headset(const char *remote_addr);
418
419 #ifdef __cplusplus
420 }
421 #endif /*__cplusplus*/
422 #endif/*_BLUETOOTH_TELEPHONY_API_H_*/