From 7c9e18eb90954f7534dedb9cfaa55dd1180edc0a Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Fri, 17 Oct 2008 16:59:40 +0300 Subject: Implement better support for AT+CHLD= --- audio/headset.c | 20 ++++++++++++++++++-- audio/telephony-dummy.c | 10 +++++++++- audio/telephony.h | 4 +++- 3 files changed, 30 insertions(+), 4 deletions(-) diff --git a/audio/headset.c b/audio/headset.c index cccc0846..77498d73 100644 --- a/audio/headset.c +++ b/audio/headset.c @@ -81,6 +81,7 @@ static struct { char *number; /* Incoming phone number */ int number_type; /* Incoming number type */ guint ring_timer; /* For incoming call indication */ + const char *chld; /* Response to AT+CHLD=? */ } ag = { .telephony_ready = FALSE, .features = 0, @@ -671,7 +672,15 @@ static int call_hold(struct audio_device *dev, const char *buf) struct headset *hs = dev->headset; int err; - err = headset_send(hs, "\r\n+CHLD:(0,1,1x,2,2x,3,4)\r\n"); + if (strlen(buf) < 9) + return -EINVAL; + + if (buf[8] != '?') { + telephony_call_hold_req(dev, &buf[8]); + return 0; + } + + err = headset_send(hs, "\r\n+CHLD:(%s)\r\n", ag.chld); if (err < 0) return err; @@ -975,6 +984,11 @@ int telephony_operator_selection_rsp(void *telephony_device, cme_error_t err) return telephony_generic_rsp(telephony_device, err); } +int telephony_call_hold_rsp(void *telephony_device, cme_error_t err) +{ + return telephony_generic_rsp(telephony_device, err); +} + int telephony_operator_selection_ind(int mode, const char *oper) { if (!active_devices) @@ -2432,12 +2446,14 @@ int telephony_calling_stopped_ind(void) } int telephony_ready_ind(uint32_t features, - const struct indicator *indicators, int rh) + const struct indicator *indicators, int rh, + const char *chld) { ag.telephony_ready = TRUE; ag.features = features; ag.indicators = indicators; ag.rh = rh; + ag.chld = g_strdup(chld); debug("Telephony plugin initialized"); diff --git a/audio/telephony-dummy.c b/audio/telephony-dummy.c index 8b3f105d..66873b65 100644 --- a/audio/telephony-dummy.c +++ b/audio/telephony-dummy.c @@ -36,6 +36,7 @@ #include "logging.h" #include "telephony.h" +static const char *chld_str = "0,1,1x,2,2x,3,4"; static char *subscriber_number = NULL; static char *active_call_number = NULL; static int active_call_status = 0; @@ -183,6 +184,12 @@ void telephony_operator_selection_req(void *telephony_device) telephony_operator_selection_rsp(telephony_device, CME_ERROR_NONE); } +void telephony_call_hold_req(void *telephony_device, const char *cmd) +{ + debug("telephony-dymmy: got call hold request %s", cmd); + telephony_call_hold_rsp(telephony_device, CME_ERROR_NONE); +} + /* D-Bus method handlers */ static DBusMessage *outgoing_call(DBusConnection *conn, DBusMessage *msg, void *data) @@ -376,7 +383,8 @@ int telephony_init(void) dummy_methods, NULL, NULL, NULL, NULL); - telephony_ready_ind(features, dummy_indicators, response_and_hold); + telephony_ready_ind(features, dummy_indicators, response_and_hold, + chld_str); return 0; } diff --git a/audio/telephony.h b/audio/telephony.h index 4e04e71c..5e972e74 100644 --- a/audio/telephony.h +++ b/audio/telephony.h @@ -145,6 +145,7 @@ void telephony_transmit_dtmf_req(void *telephony_device, char tone); void telephony_subscriber_number_req(void *telephony_device); void telephony_list_current_calls_req(void *telephony_device); void telephony_operator_selection_req(void *telephony_device); +void telephony_call_hold_req(void *telephony_device, const char *cmd); /* AG responses to HF requests. These are implemented by headset.c */ int telephony_event_reporting_rsp(void *telephony_device, cme_error_t err); @@ -157,6 +158,7 @@ int telephony_transmit_dtmf_rsp(void *telephony_device, cme_error_t err); int telephony_subscriber_number_rsp(void *telephony_device, cme_error_t err); int telephony_list_current_calls_rsp(void *telephony_device, cme_error_t err); int telephony_operator_selection_rsp(void *telephony_device, cme_error_t err); +int telephony_call_hold_rsp(void *telephony_device, cme_error_t err); /* Event indications by AG. These are implemented by headset.c */ int telephony_event_ind(int index); @@ -164,7 +166,7 @@ int telephony_response_and_hold_ind(int rh); int telephony_incoming_call_ind(const char *number, int type); int telephony_calling_stopped_ind(void); int telephony_ready_ind(uint32_t features, const struct indicator *indicators, - int rh); + int rh, const char *chld); int telephony_list_current_call_ind(int idx, int dir, int status, int mode, int mprty, const char *number, int type); -- cgit