From 5dbb2f424a33d387e4602c790fd8fd4e9f18ae87 Mon Sep 17 00:00:00 2001 From: Zhenhua Zhang Date: Wed, 9 Dec 2009 08:55:55 +0800 Subject: [PATCH] Add hfp_release_specific to release specific call Use AT+CHLD=1x to release a specific call if AG supports that. --- drivers/hfpmodem/voicecall.c | 51 +++++++++++++++++++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-) diff --git a/drivers/hfpmodem/voicecall.c b/drivers/hfpmodem/voicecall.c index 7c2b95f1..88c332d8 100644 --- a/drivers/hfpmodem/voicecall.c +++ b/drivers/hfpmodem/voicecall.c @@ -452,6 +452,55 @@ static void hfp_release_all_active(struct ofono_voicecall *vc, CALLBACK_WITH_FAILURE(cb, data); } +static void release_id_cb(gboolean ok, GAtResult *result, + gpointer user_data) +{ + struct release_id_req *req = user_data; + struct voicecall_data *vd = ofono_voicecall_get_data(req->vc); + struct ofono_error error; + + dump_response("release_id_cb", ok, result); + decode_at_error(&error, g_at_result_final_response(result)); + + if (ok) + vd->local_release |= (1 << req->id); + + req->cb(&error, req->data); +} + +static void hfp_release_specific(struct ofono_voicecall *vc, int id, + ofono_voicecall_cb_t cb, void *data) +{ + struct voicecall_data *vd = ofono_voicecall_get_data(vc); + struct release_id_req *req = NULL; + char buf[32]; + + if (!(vd->ag_mpty_features & AG_CHLD_1x)) + goto error; + + req = g_try_new0(struct release_id_req, 1); + + if (!req) + goto error; + + req->vc = vc; + req->cb = cb; + req->data = data; + req->id = id; + + sprintf(buf, "AT+CHLD=1%d", id); + + if (g_at_chat_send(vd->chat, buf, none_prefix, + release_id_cb, req, g_free) > 0) + return; + +error: + if (req) + g_free(req); + + CALLBACK_WITH_FAILURE(cb, data); +} + static void hfp_send_dtmf(struct ofono_voicecall *vc, const char *dtmf, ofono_voicecall_cb_t cb, void *data) { @@ -1009,7 +1058,7 @@ static struct ofono_voicecall_driver driver = { .release_all_held = hfp_release_all_held, .set_udub = hfp_set_udub, .release_all_active = hfp_release_all_active, - .release_specific = NULL, + .release_specific = hfp_release_specific, .private_chat = NULL, .create_multiparty = NULL, .transfer = NULL,