public inbox for linux-bluetooth@vger.kernel.org
 help / color / mirror / Atom feed
From: "Frédéric Danis" <frederic.danis@collabora.com>
To: linux-bluetooth@vger.kernel.org
Subject: [RFC BlueZ v2 12/27] audio/hfp-hf: Add hangup_active and hangup_held support
Date: Fri, 27 Jun 2025 16:51:21 +0200	[thread overview]
Message-ID: <20250627145136.421853-13-frederic.danis@collabora.com> (raw)
In-Reply-To: <20250627145136.421853-1-frederic.danis@collabora.com>

From: Frédéric Danis <frederic.danis.oss@gmail.com>

---
 profiles/audio/hfp-hf.c | 87 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 87 insertions(+)

diff --git a/profiles/audio/hfp-hf.c b/profiles/audio/hfp-hf.c
index ad759b8c3..a2a1ae39f 100644
--- a/profiles/audio/hfp-hf.c
+++ b/profiles/audio/hfp-hf.c
@@ -1156,6 +1156,91 @@ failed:
 	return btd_error_failed(msg, "Hang up all command failed");
 }
 
+static DBusMessage *hfp_hangup_active(DBusConnection *conn, DBusMessage *msg,
+				void *profile_data)
+{
+	struct hfp_device *dev = profile_data;
+	bool found_active = FALSE;
+	GSList *l;
+
+	DBG("");
+
+	for (l = dev->calls; l; l = l->next) {
+		struct call *call = l->data;
+
+		switch (call->state) {
+		case CALL_STATE_ACTIVE:
+		case CALL_STATE_DIALING:
+		case CALL_STATE_ALERTING:
+		case CALL_STATE_INCOMING:
+			found_active = TRUE;
+			break;
+		case CALL_STATE_HELD:
+		case CALL_STATE_WAITING:
+		case CALL_STATE_DISCONNECTED:
+			break;
+		}
+	}
+
+	if (!found_active)
+		return g_dbus_create_error(msg, ERROR_INTERFACE
+					".InvalidState",
+					"No active call to hang up");
+
+	if (!hfp_hf_send_command(dev->hf, cmd_complete_cb,
+			dbus_message_ref(msg),
+			"AT+CHUP")) {
+		warn("Failed to hangup active calls");
+		return btd_error_failed(msg, "Hang up active command failed");
+	}
+
+	return NULL;
+}
+
+static DBusMessage *hfp_hangup_held(DBusConnection *conn, DBusMessage *msg,
+				void *profile_data)
+{
+	struct hfp_device *dev = profile_data;
+	bool found_held = FALSE;
+	GSList *l;
+
+	DBG("");
+
+	if (!(dev->chld_features & CHLD_FEAT_REL))
+		return btd_error_not_supported(msg);
+
+	for (l = dev->calls; l; l = l->next) {
+		struct call *call = l->data;
+
+		switch (call->state) {
+		case CALL_STATE_HELD:
+		case CALL_STATE_WAITING:
+			found_held = TRUE;
+			break;
+		case CALL_STATE_ACTIVE:
+		case CALL_STATE_DIALING:
+		case CALL_STATE_ALERTING:
+		case CALL_STATE_INCOMING:
+		case CALL_STATE_DISCONNECTED:
+			break;
+		}
+	}
+
+	if (!found_held)
+		return g_dbus_create_error(msg, ERROR_INTERFACE
+					".InvalidState",
+					"No held call to hang up");
+
+	if (!hfp_hf_send_command(dev->hf, cmd_complete_cb,
+			dbus_message_ref(msg),
+			"AT+CHLD=0")) {
+		warn("Failed to hangup held calls");
+		return btd_error_failed(msg, "Hang up held command failed");
+	}
+
+	return NULL;
+}
+
 static DBusMessage *call_answer(DBusConnection *conn, DBusMessage *msg,
 	void *call_data)
 {
@@ -1180,6 +1265,8 @@ failed:
 struct telephony_callbacks hfp_callbacks = {
 	.dial = hfp_dial,
 	.hangup_all = hfp_hangup_all,
+	.hangup_active = hfp_hangup_active,
+	.hangup_held = hfp_hangup_held,
 	.call_answer = call_answer,
 };
 
-- 
2.43.0


  parent reply	other threads:[~2025-06-27 14:51 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-27 14:51 [RFC BlueZ v2 00/27] New Telephony interface for HSP, HFP and CCP Frédéric Danis
2025-06-27 14:51 ` [RFC BlueZ v2 01/27] doc: Add new telephony related profiles interfaces Frédéric Danis
2025-06-27 16:15   ` New Telephony interface for HSP, HFP and CCP bluez.test.bot
2025-07-02 17:38   ` [RFC BlueZ v2 01/27] doc: Add new telephony related profiles interfaces Luiz Augusto von Dentz
2025-06-27 14:51 ` [RFC BlueZ v2 02/27] audio/telephony: Add shared interfaces implementation Frédéric Danis
2025-06-27 14:51 ` [RFC BlueZ v2 03/27] audio/telephony: Add skeleton for HFP profile Frédéric Danis
2025-06-27 14:51 ` [RFC BlueZ v2 04/27] audio/hfp-hf: Add HFP SLC connection and event support Frédéric Danis
2025-06-27 14:51 ` [RFC BlueZ v2 05/27] audio/hfp-hf: Add dial support Frédéric Danis
2025-06-27 14:51 ` [RFC BlueZ v2 06/27] audio/hfp-hf: Add hangup all calls support Frédéric Danis
2025-06-27 14:51 ` [RFC BlueZ v2 07/27] audio/hfp-hf: Add answer a specific call support Frédéric Danis
2025-06-27 14:51 ` [RFC BlueZ v2 08/27] client/telephony: Add new submenu Frédéric Danis
2025-06-27 14:51 ` [RFC BlueZ v2 09/27] audio/hfp-hf: Remove call interface during profile disconnection Frédéric Danis
2025-06-27 14:51 ` [RFC BlueZ v2 10/27] audio/hfp-hf: Create existing call during SLC phase Frédéric Danis
2025-06-27 14:51 ` [RFC BlueZ v2 11/27] audio/telephony: Add hangup_active and hangup_held functions Frédéric Danis
2025-06-27 14:51 ` Frédéric Danis [this message]
2025-06-27 14:51 ` [RFC BlueZ v2 13/27] client/telephony: Add hangup_active and hangup_held support Frédéric Danis
2025-06-27 14:51 ` [RFC BlueZ v2 14/27] audio/hfp-hf: Add SendTones support Frédéric Danis
2025-06-27 14:51 ` [RFC BlueZ v2 15/27] client/telephony: " Frédéric Danis
2025-06-27 14:51 ` [RFC BlueZ v2 16/27] doc: Make telephony docs more generic Frédéric Danis
2025-06-27 14:51 ` [RFC BlueZ v2 17/27] client/telephony: Remove IncomingLine Frédéric Danis
2025-06-27 14:51 ` [RFC BlueZ v2 18/27] audio/telephony: " Frédéric Danis
2025-06-27 14:51 ` [RFC BlueZ v2 19/27] audio/hfp-hf: Add HFP HF server and SDP record Frédéric Danis
2025-06-27 14:51 ` [RFC BlueZ v2 20/27] audio/hfp-hf: Add operator name support Frédéric Danis
2025-06-27 14:51 ` [RFC BlueZ v2 21/27] audio/telephony: Add call line identication property support Frédéric Danis
2025-06-27 14:51 ` [RFC BlueZ v2 22/27] audio/hfp-hf: Add call line idenfication support Frédéric Danis
2025-06-27 14:51 ` [RFC BlueZ v2 23/27] audio/hfp-hf: Disable NREC during connection setup Frédéric Danis
2025-06-27 14:51 ` [RFC BlueZ v2 24/27] audio/hfp-hf: Enable waiting call if supported by remote AG Frédéric Danis
2025-06-27 14:51 ` [RFC BlueZ v2 25/27] audio/hfp-hf: Enable extended error " Frédéric Danis
2025-06-27 14:51 ` [RFC BlueZ v2 26/27] audio/telephony: Add call multiparty property support Frédéric Danis
2025-06-27 14:51 ` [RFC BlueZ v2 27/27] audio/hfp-hf: Enable enhanced call status if supported by remote AG Frédéric Danis
2025-07-02 17:50 ` [RFC BlueZ v2 00/27] New Telephony interface for HSP, HFP and CCP Luiz Augusto von Dentz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250627145136.421853-13-frederic.danis@collabora.com \
    --to=frederic.danis@collabora.com \
    --cc=linux-bluetooth@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox