Open Source Telephony
 help / color / mirror / Atom feed
From: =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis <frederic.danis@linux.intel.com>
To: ofono@ofono.org
Subject: [RFC v4 06/10] bluetooth: Add +BSIR support
Date: Fri, 06 Apr 2012 15:17:08 +0200	[thread overview]
Message-ID: <1333718232-8447-7-git-send-email-frederic.danis@linux.intel.com> (raw)
In-Reply-To: <1333718232-8447-1-git-send-email-frederic.danis@linux.intel.com>

[-- Attachment #1: Type: text/plain, Size: 2215 bytes --]

---
 plugins/bluetooth.c |   49 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 49 insertions(+), 0 deletions(-)

diff --git a/plugins/bluetooth.c b/plugins/bluetooth.c
index b6328bc..b90852d 100644
--- a/plugins/bluetooth.c
+++ b/plugins/bluetooth.c
@@ -78,6 +78,7 @@ struct hfp_data {
 	struct ofono_emulator *em;
 	char *path;
 	guint16 r_features;
+	guint watch;
 };
 
 void bluetooth_create_path(const char *dev_addr, const char *adapter_addr,
@@ -267,6 +268,46 @@ fail:
 	};
 }
 
+static gboolean audio_property_changed(DBusConnection *connection,
+					DBusMessage *message, void *user_data)
+{
+	struct hfp_data *hfp = user_data;
+	const char *property;
+	char buf[10];
+	DBusMessageIter iter;
+
+	dbus_message_iter_init(message, &iter);
+
+	if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_STRING)
+		return FALSE;
+
+	dbus_message_iter_get_basic(&iter, &property);
+
+	if (g_str_equal(property, "InbandRingtone") == TRUE) {
+		DBusMessageIter variant;
+		gboolean value;
+
+		if (!dbus_message_iter_next(&iter))
+			return TRUE;
+
+		if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_VARIANT)
+			return TRUE;
+
+		dbus_message_iter_recurse(&iter, &variant);
+
+		if (dbus_message_iter_get_arg_type(&variant) !=
+							DBUS_TYPE_BOOLEAN)
+			return TRUE;
+
+		dbus_message_iter_get_basic(&variant, &value);
+
+		sprintf(buf, "+BSIR: %d", value);
+		ofono_emulator_send_unsolicited(hfp->em, buf);
+	}
+
+	return TRUE;
+}
+
 void bluetooth_free_audio_management(void *data)
 {
 	struct hfp_data *hfp = data;
@@ -275,6 +316,8 @@ void bluetooth_free_audio_management(void *data)
 
 	ofono_emulator_remove_handler(hfp->em, "+NREC");
 
+	g_dbus_remove_watch(connection, hfp->watch);
+
 	g_free(hfp->path);
 	g_free(hfp);
 }
@@ -293,6 +336,12 @@ void *bluetooth_set_audio_management(void *em, const char *path,
 
 	ofono_emulator_add_handler(em, "+NREC", emulator_nrec_cb, hfp, NULL);
 
+	hfp->watch = g_dbus_add_signal_watch(connection, NULL, path,
+						BLUEZ_TRANSPORT_INTERFACE,
+						"PropertyChanged",
+						audio_property_changed,
+						hfp, NULL);
+
 	return hfp;
 }
 
-- 
1.7.1


  parent reply	other threads:[~2012-04-06 13:17 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-06 13:17 [RFC v4 00/10] org.bluez.Telephony interface integration =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
2012-04-06 13:17 ` [RFC v4 01/10] bluetooth: Add org.bluez.Telephony helpers =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
2012-04-06 13:17 ` [RFC v4 02/10] hfp_hf: Update to org.bluez.Telephony interface =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
2012-04-06 13:17 ` [RFC v4 03/10] hfp_ag: " =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
2012-04-06 13:17 ` [RFC v4 04/10] bluetooth: Add audio APIs for HFP AG =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
2012-04-06 17:27   ` Denis Kenzior
2012-04-06 13:17 ` [RFC v4 05/10] bluetooth: Add AT+NREC support =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
2012-04-06 17:32   ` Denis Kenzior
2012-04-06 13:17 ` =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis [this message]
2012-04-06 13:17 ` [RFC v4 07/10] bluetooth: Add AT+VGM support =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
2012-04-06 13:17 ` [RFC v4 08/10] bluetooth: Add AT+VGS support =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
2012-04-06 13:17 ` [RFC v4 09/10] hfp_ag: Add media transport support =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
2012-04-06 17:38   ` Denis Kenzior
2012-04-24 16:19     ` Frederic Danis
2012-04-23 19:24       ` Denis Kenzior
2012-04-06 13:17 ` [RFC v4 10/10] emulator: Update supported features =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
2012-04-06 17:38   ` Denis Kenzior
2012-04-23 14:01     ` Frederic Danis
2012-04-23  0:03       ` Denis Kenzior

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=1333718232-8447-7-git-send-email-frederic.danis@linux.intel.com \
    --to=frederic.danis@linux.intel.com \
    --cc=ofono@ofono.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