Update AG and HF agent codes from wearable product
[platform/core/connectivity/bluetooth-agent.git] / ag-agent / bluetooth-ag-agent.h
1 /*
2  * Bluetooth-ag-agent.h
3  *
4  * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact:     Hocheol Seo <hocheol.seo@samsung.com>
7  *              Chethan TN <chethan.tn@samsung.com>
8  *              Chanyeol Park <chanyeol.park@samsung.com>
9  *              Rakesh MK <rakesh.mk@samsung.com>
10  *
11  * Licensed under the Apache License, Version 2.0 (the "License");
12  * you may not use this file except in compliance with the License.
13  * You may obtain a copy of the License at
14  *
15  *              http://www.apache.org/licenses/LICENSE-2.0
16  *
17  * Unless required by applicable law or agreed to in writing, software
18  * distributed under the License is distributed on an "AS IS" BASIS,
19  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20  * See the License for the specific language governing permissions and
21  * limitations under the License.
22  *
23  */
24
25 #ifndef __DEF_BT_AG_AGENT_H_
26 #define __DEF_BT_AG_AGENT_H_
27
28 #undef LOG_TAG
29 #define LOG_TAG "BLUETOOTH_AG_AGENT"
30
31 #define LOG_COLOR_RESET    "\033[0m"
32 #define LOG_COLOR_RED      "\033[31m"
33 #define LOG_COLOR_YELLOW   "\033[33m"
34 #define LOG_COLOR_GREEN         "\033[32m"
35 #define LOG_COLOR_BLUE          "\033[36m"
36 #define LOG_COLOR_PURPLE   "\033[35m"
37
38 #define DBG(fmt, args...) SLOGD(fmt, ##args)
39 #define INFO(fmt, args...) SLOGI(fmt, ##args)
40 #define ERR(fmt, args...) SLOGE(fmt, ##args)
41 #define DBG_SECURE(fmt, args...) SECURE_SLOGD(fmt, ##args)
42 #define INFO_SECURE(fmt, args...) SECURE_SLOGI(fmt, ##args)
43 #define ERR_SECURE(fmt, args...) SECURE_SLOGE(fmt, ##args)
44 #define DBG_SECURE(fmt, args...) SECURE_SLOGD(fmt, ##args)
45 #define ERR_SECURE(fmt, args...) SECURE_SLOGE(fmt, ##args)
46 #define INFO_C(fmt, arg...) \
47         SLOGI_IF(TRUE,  LOG_COLOR_BLUE" "fmt" "LOG_COLOR_RESET, ##arg)
48 #define ERR_C(fmt, arg...) \
49         SLOGI_IF(TRUE,  LOG_COLOR_RED" "fmt" "LOG_COLOR_RESET, ##arg)
50
51 #include <unistd.h>
52 #include <dlog.h>
53 #include <stdio.h>
54 #include <signal.h>
55 #include <string.h>
56 #include <unistd.h>
57 #include <fcntl.h>
58 #include <inttypes.h>
59 #include <sys/socket.h>
60 #include <glib.h>
61 #include <gio/gio.h>
62 #include <errno.h>
63 #include <TapiUtility.h>
64 #include <ITapiSim.h>
65 #include <ITapiModem.h>
66 #include <TelNetwork.h>
67
68 #include "vconf.h"
69 #include "vconf-keys.h"
70
71 #define BT_AG_SERVICE_NAME "org.bluez.ag_agent"
72 #define BT_AG_AGENT_OBJECT_PATH "/org/bluez/hfp_agent"
73 #define BT_HS_AG_AGENT_OBJECT_PATH "/org/bluez/hsp_agent"
74 #define BLUEZ_AG_INTERFACE_NAME "Hands-Free Audio Gateway"
75 #define BLUEZ_SERVICE_NAME "org.bluez"
76 #define BLUEZ_PROFILE_MGMT_INTERFACE "org.bluez.ProfileManager1"
77 #define BT_MANAGER_INTERFACE "org.freedesktop.DBus.ObjectManager"
78 #define HFP_APP_INTERFACE "Org.Hfp.App.Interface"
79 #define TELEPHONY_APP_INTERFACE "org.tizen.csd.Call.Instance"
80 #define BT_HEADSET_INTERFACE "org.bluez.Headset"
81 #define BT_ADAPTER_INTERFACE    "org.bluez.Adapter1"
82 #define BT_PROPERTIES_INTERFACE "org.freedesktop.DBus.Properties"
83 #define BLUEZ_DEVICE_INTERFACE  "org.bluez.Device1"
84 #define BT_INTERFACES_ADDED "InterfacesAdded"
85 #define BT_INTERFACES_REMOVED "InterfacesRemoved"
86 #define BT_PROPERTY_CHANGED "PropertiesChanged"
87
88 #ifdef TIZEN_FEATURE_BT_MEDIA_ENHANCE
89 #define BLUEZ_MEDIA_TRANSPORT_INTERFACE "org.bluez.MediaTransport1"
90 #define BLUEZ_MEDIA_ENDPOINT_INTERFACE "org.bluez.MediaEndpoint1"
91 #define A2DP_SOURCE_ENDPOINT "/MediaEndpoint/A2DPSource"
92 #endif
93
94 #define BT_ADAPTER_OBJECT_PATH_MAX 50
95
96 #define BT_ADDRESS_STRING_SIZE 18
97 #define MAX_BUFFER_SIZE 1024
98
99 /* Response and hold values */
100 #define BT_RSP_HOLD_NOT_SUPPORTED       -2
101 #define HANDSFREE_FEATURE_CALL_WAITING_AND_3WAY 0x0002
102
103 /* HFP Agent Indicator event values */
104 #define INDICATOR_EVENT_SERVICE_NONE                    0
105 #define INDICATOR_EVENT_SERVICE_PRESENT         1
106
107 #define INDICATOR_EVENT_CALL_INACTIVE                   0
108 #define INDICATOR_EVENT_CALL_ACTIVE                     1
109
110 #define INDICATOR_EVENT_CALLSETUP_INACTIVE               0
111 #define INDICATOR_EVENT_CALLSETUP_INCOMING               1
112 #define INDICATOR_EVENT_CALLSETUP_OUTGOING               2
113 #define INDICATOR_EVENT_CALLSETUP_ALERTING               3
114
115 #define INDICATOR_EVENT_CALLHELD_NONE                   0
116 #define INDICATOR_EVENT_CALLHELD_MULTIPLE               1
117 #define INDICATOR_EVENT_CALLHELD_ON_HOLD                2
118
119 #define INDICATOR_EVENT_ROAM_INACTIVE                   0
120 #define INDICATOR_EVENT_ROAM_ACTIVE                     1
121
122 /* Telephony number types */
123 #define AGENT_NUMBER_TYPE_TELEPHONY             129
124 #define AGENT_NUMBER_TYPE_INTERNATIONAL 145
125
126 /* Call direction parameters */
127 #define AGENT_CALL_DIRECTION_OUTGOING   0
128 #define AGENT_CALL_DIRECTION_INCOMING           1
129
130 #define AGENT_CALL_STATUS_ACTIVE                0
131 #define AGENT_CALL_STATUS_HELD          1
132 #define AGENT_CALL_STATUS_DIALING               2
133 #define AGENT_CALL_STATUS_ALERTING      3
134 #define AGENT_CALL_STATUS_INCOMING      4
135 #define AGENT_CALL_STATUS_WAITING               5
136
137 #define AGENT_CALL_MODE_VOICE           0
138 #define AGENT_CALL_MODE_DATA            1
139 #define AGENT_CALL_MODE_FAX             2
140
141 #define AGENT_CALL_MULTIPARTY_NO                0
142 #define AGENT_CALL_MULTIPARTY_YES               1
143
144 /* Subscriber number parameters*/
145 #define AGENT_SUBSCRIBER_SERVICE_VOICE  4
146
147 /* Operator selection mode values */
148 #define AGENT_OPERATOR_MODE_AUTO                        0
149 #define HSP_VERSION_1_2  0x0102
150
151 /* Voice recognition blacklist file */
152 #define AGENT_VR_BLACKLIST_FILE (APP_SYSCONFDIR"/voice-recognition-blacklist")
153
154 #define BT_LOWER_ADDRESS_LENGTH 9
155
156 enum hfp_version {
157         HFP_VERSION_1_5 = 0x0105,
158         HFP_VERSION_1_6 = 0x0106,
159         HFP_VERSION_1_7 = 0x0107,
160         HFP_VERSION_LATEST = HFP_VERSION_1_7,
161 };
162
163 /* BD Address */
164 typedef struct {
165         uint8_t b[6];
166 } __attribute__((packed)) bt_addrs;
167
168 /**
169  * @brief Outgoing call type status
170  *
171  * 0 : Follow last call log \n
172  * 1 : Voice call \n
173  * 2 : Video call \n
174  */
175 #define BT_FOLLOW_CALL_LOG 0
176 #define BT_VOICE_CALL 1
177 #define BT_VIDEO_CALL 2
178
179 /**
180  * @brief The status of making outgoing calls with BT headsets
181  *
182  * 0 : Even when device locked \n
183  * 1 : Only when device unlocked \n
184  */
185 #define BT_MO_EVEN_LOCKED 0
186 #define BT_MO_ONLY_UNLOCKED 1
187
188 #define BT_CVSD_CODEC_ID 1
189 #define BT_MSBC_CODEC_ID 2
190
191 #define BT_CVSD_CODEC_MASK 0x0001
192 #define BT_MSBC_CODEC_MASK 0x0002
193
194 #define BT_HFP_MSBC_VOICE                       0x0063
195 #define BT_HFP_CVSD_VOICE                       0x0060
196
197 #define BT_SOCKET_LEVEL                 274
198 #define BT_VOICE_NUM                    11
199
200 #define BT_SCO_PRTCL    2
201
202 #define HFP_CODEC_NEGOTIATION_TIMEOUT 3 /* 3 seconds */
203
204 #define BT_SCO_OPEN_DELAY_TIMER 1000 /*1000 milliseconds*/
205
206 /* AT+CSQ : Returns received signal strength indication.
207      Command response: +CSQ: <rssi>,<ber>
208     <ber> is not supported and has a constant value of 99, included for compatibility reasons.
209 */
210 #define BT_SIGNAL_QUALITY_BER 99
211
212 /*Length of the string used to send telephone number*/
213 #define BT_MAX_TEL_NUM_STRING 30
214
215 #define FUCNTION_CALLS
216 #ifdef FUCNTION_CALLS
217 #define FN_START        DBG("ENTER==>")
218 #define FN_END          DBG("EXIT===>")
219 #else
220 #define FN_START
221 #define FN_END
222 #endif
223
224 /* HS states */
225 typedef enum {
226         HEADSET_STATE_DISCONNECTED,
227         HEADSET_STATE_CONNECTING,
228         HEADSET_STATE_CONNECTED,
229         HEADSET_STATE_PLAY_IN_PROGRESS,
230         HEADSET_STATE_ON_CALL
231 } hs_state_t;
232
233 typedef enum {
234         HFP_STATE_MNGR_ERR_AG_FAILURE = 0,
235         HFP_STATE_MNGR_NO_PHONE_CONNECTION = 1,
236         HFP_STATE_MNGR_ERR_NOT_ALLOWED  = 3,
237         HFP_STATE_MNGR_ERR_NOT_SUPPORTED        = 4,
238         HFP_STATE_MNGR_ERR_SIM_BUSY     = 14,
239         HFP_STATE_MNGR_ERR_INVALID_INDEX        = 21,
240         HFP_STATE_MNGR_ERR_INVALID_CHAR_IN_STRING       = 25,
241         HFP_STATE_MNGR_ERR_NO_NETWORK_SERVICE   = 30,
242         HFP_STATE_MNGR_ERR_NONE = 0x8000
243 } hfp_state_manager_err_t;
244
245 typedef enum {
246         BT_AG_FEATURE_THREE_WAY_CALL                    = 0x0001,
247         BT_AG_FEATURE_EC_AND_NR                         = 0x0002,
248         BT_AG_FEATURE_VOICE_RECOGNITION                 = 0x0004,
249         BT_AG_FEATURE_INBAND_RINGTONE                   = 0x0008,
250         BT_AG_FEATURE_ATTACH_NUMBER_TO_VOICETAG         = 0x0010,
251         BT_AG_FEATURE_REJECT_CALL                       = 0x0020,
252         BT_AG_FEATURE_ENHANCED_CALL_STATUS              = 0x0040,
253         BT_AG_FEATURE_ENHANCED_CALL_CONTROL             = 0x0080,
254         BT_AG_FEATURE_EXTENDED_ERROR_RESULT_CODES       = 0x0100,
255         BT_AG_FEATURE_CODEC_NEGOTIATION                 = 0x0200,
256         BT_AG_FEATURE_HF_INDICATORS                     = 0x0400,
257         BT_AG_FEATURE_ESCO_S4_T2_SUPPORT                = 0x0800,
258 } bt_ag_agent_feature_t;
259
260 typedef enum {
261         BT_HF_FEATURE_EC_ANDOR_NR                       = 0x0001,
262         BT_HF_FEATURE_CALL_WAITING_AND_3WAY     = 0x0002,
263         BT_HF_FEATURE_CLI_PRESENTATION          = 0x0004,
264         BT_HF_FEATURE_VOICE_RECOGNITION         = 0x0008,
265         BT_HF_FEATURE_REMOTE_VOLUME_CONTROL     = 0x0010,
266         BT_HF_FEATURE_ENHANCED_CALL_STATUS              = 0x0020,
267         BT_HF_FEATURE_ENHANCED_CALL_CONTROL     = 0x0040,
268         BT_HF_FEATURE_CODEC_NEGOTIATION = 0x0080,
269 } bt_hf_agent_feature_t;
270
271 typedef enum {
272         BT_AG_FEATURE_PBAP_SHOW_AUTHORIZATION = 0x0000,
273         BT_AG_FEATURE_PBAP_BLOCKED = 0x0001,
274         BT_AG_FEATURE_PBAP_CANCEL = 0x0002,
275         BT_AG_FEATURE_PBAP_ALLOWED= 0x0004
276 } bt_pbap_trusted_feature_t;
277
278 typedef enum {
279         BT_PROFILE_SHOW_AUTHORIZATION = 0x0, /* 0b00 */
280         BT_PROFILE_SUPPORTED_BLOCKED = 0x1, /* 0b01 */
281         BT_PROFILE_SUPPORTED_TRUSTED= 0x2, /* 0b10 */
282 } bt_profile_trusted_states;
283
284 /* HFP AG service record bitmap. Bluetooth HFP 1.6 spec page 95 */
285 #define BT_AG_FEATURE_SDP_3WAY                  0x1
286 #define BT_AG_FEATURE_SDP_ECNR                  0x2
287 #define BT_AG_FEATURE_SDP_VOICE_RECOG           0x4
288 #define BT_AG_FEATURE_SDP_IN_BAND_RING_TONE     0x8
289 #define BT_AG_FEATURE_SDP_ATTACH_VOICE_TAG              0x10
290 #define BT_AG_FEATURE_SDP_WIDEBAND_SPEECH               0x20
291
292 #define BT_AG_AGENT_ERROR (__bt_ag_agent_error_quark())
293
294 #define BT_ERROR_INTERNAL "InternalError"
295 #define BT_ERROR_NOT_AVAILABLE "NotAvailable"
296 #define BT_ERROR_NOT_CONNECTED "NotConnected"
297 #define BT_ERROR_BUSY "InProgress"
298 #define BT_ERROR_INVALID_PARAM "InvalidArguments"
299 #define BT_ERROR_ALREADY_EXSIST "AlreadyExists"
300 #define BT_ERROR_ALREADY_CONNECTED "Already Connected"
301 #define BT_ERROR_NO_MEMORY "No memory"
302 #define BT_ERROR_I_O_ERROR "I/O error"
303 #define BT_ERROR_OPERATION_NOT_AVAILABLE "Operation currently not available"
304 #define BT_ERROR_BATTERY "Battery error "
305 #define BT_ERROR_SIGNAL "Signal error"
306 #define BT_ERROR_NO_CALL_LOG "No Call log"
307 #define BT_ERROR_INVLAID_DTMF "Invalid dtmf"
308
309 #define BT_CHECK_SIGNAL_STRENGTH(rssi) \
310         if (rssi >= VCONFKEY_TELEPHONY_RSSI_4) \
311                 rssi = VCONFKEY_TELEPHONY_RSSI_5
312
313 typedef enum {
314         BT_HFP_AGENT_ERROR_NONE,
315         BT_HFP_AGENT_ERROR_INTERNAL,
316         BT_HFP_AGENT_ERROR_NOT_AVAILABLE,
317         BT_HFP_AGENT_ERROR_NOT_CONNECTED,
318         BT_HFP_AGENT_ERROR_BUSY,
319         BT_HFP_AGENT_ERROR_INVALID_PARAM,
320         BT_HFP_AGENT_ERROR_ALREADY_EXSIST,
321         BT_HFP_AGENT_ERROR_ALREADY_CONNECTED,
322         BT_HFP_AGENT_ERROR_NO_MEMORY,
323         BT_HFP_AGENT_ERROR_I_O_ERROR,
324         BT_HFP_AGENT_ERROR_OPERATION_NOT_AVAILABLE,
325         BT_HFP_AGENT_ERROR_NO_CALL_LOGS,
326         BT_HFP_AGENT_ERROR_INVALID_MEMORY_INDEX,
327         BT_HFP_AGENT_ERROR_INVALID_CHLD_INDEX,
328         BT_HFP_AGENT_ERROR_BATTERY_STATUS,
329         BT_HFP_AGENT_ERROR_SIGNAL_STATUS,
330         BT_HFP_AGENT_ERROR_NOT_SUPPORTED,
331         BT_HFP_AGENT_ERROR_INVALID_NUMBER,
332         BT_HFP_AGENT_ERROR_APPLICATION,
333         BT_HFP_AGENT_ERROR_INVALID_DTMF,
334 } bt_hfp_agent_error_t;
335
336 typedef enum {
337         BT_AGENT_NETWORK_REG_STATUS_HOME,
338         BT_AGENT_NETWORK_REG_STATUS_ROAMING,
339         BT_AGENT_NETWORK_REG_STATUS_OFFLINE,
340         BT_AGENT_NETWORK_REG_STATUS_SEARCHING,
341         BT_AGENT_NETWORK_REG_STATUS_NO_SIM,
342         BT_AGENT_NETWORK_REG_STATUS_POWEROFF,
343         BT_AGENT_NETWORK_REG_STATUS_POWERSAFE,
344         BT_AGENT_NETWORK_REG_STATUS_NO_COVERAGE,
345         BT_AGENT_NETWORK_REG_STATUS_REJECTED,
346         BT_AGENT_NETWORK_REG_STATUS_UNKOWN,
347 } bt_hfp_agent_network_registration_status_t;
348
349 typedef enum {
350         BT_AGENT_NETWORK_REG_STATUS_NOT_REGISTER,
351         BT_AGENT_NETWORK_REG_STATUS_REGISTER_HOME_NETWORK,
352         BT_AGENT_NETWORK_REG_STATUS_SEARCH,
353         BT_AGENT_NETWORK_REG_STATUS_REGISTRATION_DENIED,
354         BT_AGENT_NETWORK_REG_STATUS_UNKNOWN,
355         BT_AGENT_NETWORK_REG_STATUS_REGISTERED_ROAMING,
356         BT_AGENT_NETWORK_REG_STATUS_REGISTERED_SMS_HOME,
357         BT_AGENT_NETWORK_REG_STATUS_REGISTERED_SMS_ROAMING,
358         BT_AGENT_NETWORK_REG_STATUS_EMERGENCY,
359         BT_AGENT_NETWORK_REG_STATUS_REGISTERED_CSFB_HOME,
360         BT_AGENT_NETWORK_REG_STATUS_REGISTERED_CSFB_ROAMING,
361 } bt_hfp_agent_reg_status_t;
362
363 #ifdef TIZEN_FEATURE_BT_MEDIA_ENHANCE
364 typedef enum media_transport_state {
365         MEDIA_TRANSPORT_STATE_DISCONNECTED,
366         MEDIA_TRANSPORT_STATE_IDLE,
367         MEDIA_TRANSPORT_STATE_PLAYING
368 } bt_ag_media_transport_state_t;
369
370 /* Profile states matched to btd_service_state_t of bluez service.h */
371 typedef enum {
372         BT_PROFILE_STATE_UNAVAILABLE,
373         BT_PROFILE_STATE_DISCONNECTED,
374         BT_PROFILE_STATE_CONNECTING,
375         BT_PROFILE_STATE_CONNECTED,
376         BT_PROFILE_STATE_DISCONNECTING,
377 } bt_profile_state_t;
378 #endif
379
380 #define retv_if(expr, val) \
381         do { \
382                 if (expr) { \
383                         ERR("(%s) return", #expr); \
384                         return (val); \
385                 } \
386         } while (0)
387
388 #define ret_if(expr) \
389         do { \
390                 if (expr) { \
391                         ERR("(%s) return", #expr); \
392                         return; \
393                 } \
394         } while (0)
395
396 typedef struct {
397         unsigned char b[6];
398 } __attribute__((packed)) bdaddr_t;
399
400 /* Remote socket address */
401 struct sockaddr_remote {
402         sa_family_t     family;
403         bdaddr_t        remote_bdaddr;
404         uint8_t         channel;
405 };
406
407 typedef struct {
408         const char *indicator_desc;
409         const char *indicator_range;
410         int hfp_value;
411         gboolean ignore;
412         gboolean is_activated;
413 } bt_ag_indicators_t;
414
415 typedef struct {
416         gboolean telephony_ready;       /* plugin initialized */
417         uint32_t features;            /* AG features */
418         const bt_ag_indicators_t *indicators;     /* Supported indicators */
419         int er_mode;               /* Event reporting mode */
420         int er_ind;                 /* Event reporting for indicators */
421         int rh;                 /* Response and Hold state */
422         char *number;             /* Incoming phone number */
423         int number_type;                /* Incoming number type */
424         guint ring_timer;               /* For incoming call indication */
425         const char *chld;               /* Response to AT+CHLD=? */
426         uint32_t sdp_features; /* SDP features */
427 } bt_ag_status_t;
428
429 typedef struct {
430         char buffer[MAX_BUFFER_SIZE];
431
432         int start;
433         int length;
434
435         gboolean is_nrec;
436         gboolean is_nrec_req;
437         gboolean is_pending_ring;
438         gboolean is_inband_ring;
439         gboolean is_cme_enabled;
440         gboolean is_cwa_enabled;
441         gboolean is_client_active;
442         gboolean is_voice_recognition_running;
443
444         int speaker_gain;
445         int microphone_gain;
446
447         unsigned int hs_features;
448 } bt_ag_slconn_t;
449
450 typedef struct {
451 /*      DBusMessage *msg;
452         DBusPendingCall *call;*/
453         GIOChannel *io;
454         int err;
455         hs_state_t target_state;
456         GSList *callbacks;
457         uint16_t svclass;
458 } hs_connecting_t;
459
460 typedef struct {
461         char *object_path;
462         gboolean is_negotiating;
463         gboolean requested_by_hf;
464         guint nego_timer;
465         unsigned int remote_codecs;
466         unsigned int sending_codec;
467         unsigned int final_codec;
468         char *status;
469 } bt_negotiation_info_t;
470
471 typedef struct {
472         const char *path;
473         guint32 fd;
474
475         gboolean auto_connect;
476         GIOChannel *io_chan;
477         char *remote_addr;
478         guint watch_id;
479         GIOChannel *sco_server;
480         guint sco_watch_id;
481
482         GIOChannel *rfcomm;
483         GIOChannel *sco;
484         guint sco_id;
485         guint sco_incoming_id;
486         guint codec;
487
488         gboolean auto_dc;
489
490         guint dc_timer;
491
492         gboolean hfp_active;
493         gboolean search_hfp;
494         gboolean rfcomm_initiator;
495         gboolean vr_blacklisted;
496
497         hs_state_t state;
498         bt_ag_slconn_t *slc;
499         hs_connecting_t *pending;
500         GSList *nrec_cbs;
501         gboolean sco_server_started;
502         gboolean nrec_status;
503         bt_negotiation_info_t codec_info;
504 #if defined(TIZEN_SUPPORT_DUAL_HF)
505         gboolean is_companion_device;
506 #endif
507         int pbap_trusted;
508         char at_pbap_buf[30];
509         GDBusMethodInvocation *invocation;
510 } bt_ag_info_t;
511
512 typedef void (*headset_nrec_cb) (bt_ag_info_t *hs,
513                                         gboolean nrec,
514                                         void *user_data);
515
516 struct hs_nrec_callback {
517         unsigned int id;
518         headset_nrec_cb cb;
519         void *user_data;
520 };
521
522 typedef void (*hs_state_cb) (bt_ag_info_t *hs,
523                 hs_state_t old_state,
524                 hs_state_t new_state,
525                 void *user_data);
526
527 struct hs_state_callback {
528                 hs_state_cb cb;
529                 void *user_data;
530                 unsigned int id;
531 };
532
533 int __attribute__((format(printf, 2, 3)))
534                         _bt_ag_send_at(bt_ag_info_t *hs, char *format, ...);
535 void __attribute__((format(printf, 3, 4)))
536                 _bt_ag_send_foreach_headset(GSList *devices,
537                 int (*cmp) (bt_ag_info_t *hs),
538                 char *format, ...);
539 void _bt_ag_slconn_complete(bt_ag_info_t *hs);
540 int _bt_ag_send_response(bt_ag_info_t *hs, hfp_state_manager_err_t err);
541 void _bt_hfp_call_hold_request(const char *t_cmd, void *t_device);
542 void _bt_hfp_key_press_request(const char *t_key_press, void *t_device);
543 void _bt_hfp_terminate_call_request(void *t_device);
544 void _bt_hfp_answer_call_request(void *t_device);
545 void _bt_hfp_update_event_request(int indicator, void *t_device);
546 void _bt_hfp_response_and_hold_request(void *t_device);
547 void _bt_hfp_last_dialed_number_request(void *t_device);
548 void _bt_hfp_dial_number_request(const char *dial_number, void *t_device);
549 void _bt_hfp_channel_dtmf_request(char t_tone, void *t_device);
550 void _bt_hfp_subscriber_number_request(void *t_device);
551 void _bt_hfp_get_operator_selection_request(void *t_device);
552 void _bt_hfp_noise_red_and_echo_cancel_request(gboolean t_enable,
553                         void *t_device);
554 void _bt_hfp_voice_dial_request(gboolean t_enable, void *t_device);
555 void _bt_hfp_set_indicators(const char *t_command, void *t_device);
556 void _bt_hfp_select_phonebook_memory_status(void *t_device);
557 void _bt_hfp_select_phonebook_memory_list(void *t_device);
558 void _bt_hfp_select_phonebook_memory(void *t_device, const gchar *pb_path);
559 void _bt_hfp_read_phonebook_entries_list(void *t_device);
560 void _bt_hfp_read_phonebook_entries(void *t_device, const char *cmd);
561 void _bt_hfp_find_phonebook_entries_status(void *t_device);
562 void _bt_hfp_find_phonebook_entries(void *t_device, const char *cmd);
563 void _bt_hfp_get_character_set(void *t_device);
564 void _bt_hfp_list_supported_character(void *t_device);
565 void _bt_hfp_set_character_set(void *t_device, const char *cmd);
566 void _bt_hfp_get_battery_property(void *t_device);
567 void _bt_hfp_signal_quality_reply(int32_t rssi, int32_t ber,
568         void *t_device);
569 void _bt_hfp_battery_property_reply(void *data, int32_t bcs,
570                         int32_t bcl);
571 void _bt_hfp_operator_reply(char *operator_name,  void *t_device);
572 bt_hfp_agent_error_t _bt_ag_agent_dial_num(const gchar *number, guint flags);
573 bt_hfp_agent_error_t _bt_ag_agent_dial_last_num(void *device);
574 bt_hfp_agent_error_t _bt_ag_agent_send_dtmf(const gchar *dtmf,
575                                 const gchar *path, const gchar *sender);
576 bt_hfp_agent_error_t _bt_ag_agent_dial_memory(unsigned int location);
577 gboolean _bt_ag_agent_get_signal_quality(void *device);
578 gboolean _bt_ag_agent_get_battery_status(void *device);
579 gboolean _bt_ag_agent_get_operator_name(void *device);
580 gboolean _bt_hfp_agent_nrec_status(gboolean status,
581         void *t_device);
582 gboolean _bt_ag_agent_voice_dial(gboolean activate);
583 gboolean _bt_ag_agent_answer_call(unsigned int call_id,
584                                 const gchar *path, const gchar *sender);
585 gboolean _bt_ag_agent_reject_call(unsigned int call_id,
586                                 const gchar *path, const gchar *sender);
587 gboolean _bt_ag_agent_release_call(unsigned int call_id,
588                                 const gchar *path, const gchar *sender);
589 gboolean _bt_ag_agent_threeway_call(unsigned int chld_value,
590                                 const gchar *path, const gchar *sender);
591 void _bt_list_current_calls(void *t_device);
592 void _bt_get_activity_status(void *t_device);
593 int _bt_hfp_set_property_name(const char *property, const char *operator_name);
594 void _bt_hfp_get_imei_number_reply(char *imei_number,  void *t_device);
595 void _bt_hfp_get_model_info_reply(char *model,  void *t_device);
596 void _bt_hfp_get_device_manufacturer_reply(char *manufacturer,  void *t_device);
597 void _bt_hfp_get_revision_info_reply(char *revision,  void *t_device);
598 void _bt_hfp_device_disconnected(void *t_device);
599 int _bt_hfp_get_equipment_identity(bt_ag_info_t *device, const char *buf);
600 int _bt_hfp_get_model_information(bt_ag_info_t *device, const char *buf);
601 int _bt_hfp_get_device_manufacturer(bt_ag_info_t *device, const char *buf);
602 int _bt_hfp_get_imsi(bt_ag_info_t *device, const char *buf);
603 int _bt_hfp_get_creg_status(bt_ag_info_t *device, const char *buf);
604 int _bt_hfp_get_revision_information(bt_ag_info_t *device, const char *buf);
605 void _bt_hfp_get_equipment_identity_req(void *t_device);
606 bt_hfp_agent_error_t _bt_hfp_register_telephony_agent(gboolean register_flag,
607                 const char *path_to_register,
608                 const char *sender);
609 bt_hfp_agent_error_t _bt_hfp_incoming_call(const char *call_path,
610                 const char *incoming_number,
611                 uint32_t incoming_call_id,
612                 const char *sender);
613 bt_hfp_agent_error_t _bt_hfp_outgoing_call(const char *call_path,
614                 const char *number,
615                 uint32_t call_id, const char *sender);
616 bt_hfp_agent_error_t _bt_hfp_change_call_status(const char *call_path,
617                 const char *number,
618                 uint32_t call_status,
619                 uint32_t call_id,
620                 const char *sender);
621 void _bt_hfp_initialize_telephony_manager(uint32_t ag_features, TapiHandle *handler);
622 void _bt_hfp_deinitialize_telephony_manager(void);
623 gboolean _bt_ag_agent_emit_property_changed(
624                                 GDBusConnection *connection,
625                                 const char *path,
626                                 const char *interface,
627                                 const char *name,
628                                 GVariant *property);
629 void _bt_hfp_get_model_info_req(void *t_device);
630 void _bt_hfp_get_device_manufacturer_req(void *t_device);
631 void _bt_hfp_get_imsi_req(void *t_device);
632 void _bt_hfp_get_creg_status_req(void *t_device);
633 void _bt_hfp_get_revision_info_req(void *t_device);
634 gboolean _bt_hfp_is_call_exist(void);
635 void _bt_hfp_release_all_calls_by_sender(const char *sender);
636 void _bt_hfp_get_imsi_reply(char *mcc, char *mnc, char *msin, void *t_device);
637 void _bt_hfp_get_creg_status_reply(int n, int status, void *t_device);
638 int _bt_hfp_set_property_value(const char *property, int value);
639 void _bt_hfp_vendor_cmd_request(const char *cmd,
640                                                 void *t_device);
641
642 gboolean _bt_ag_agent_get_imei_number(void *device);
643 void _bt_ag_agent_get_model_name(void *device);
644 void _bt_ag_agent_get_manufacturer_name(void *device);
645 void _bt_ag_agent_get_imsi(void *device);
646 void _bt_ag_agent_get_creg_status(void *device);
647 void _bt_ag_agent_get_revision_information(void *device);
648 bt_hfp_agent_error_t _bt_ag_agent_vendor_cmd(const gchar *cmd,
649                 const gchar *path, const gchar *sender);
650 #ifdef TIZEN_FEATURE_BT_MEDIA_ENHANCE
651 void _bt_ag_agent_check_transport_state(void);
652 #endif
653 void _bt_ag_agent_set_last_speaker_gain(int gain);
654
655 #endif /* __DEF_BT_AG_AGENT_H_ */