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 v3 09/12] emulator: Add +BSIR support
Date: Mon, 02 Apr 2012 15:27:19 +0200	[thread overview]
Message-ID: <1333373242-11117-10-git-send-email-frederic.danis@linux.intel.com> (raw)
In-Reply-To: <1333373242-11117-1-git-send-email-frederic.danis@linux.intel.com>

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

---
 src/emulator.c |   58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 58 insertions(+), 0 deletions(-)

diff --git a/src/emulator.c b/src/emulator.c
index c5ec105..0760c79 100644
--- a/src/emulator.c
+++ b/src/emulator.c
@@ -54,6 +54,7 @@ struct ofono_emulator {
 	gboolean ccwa;
 	int pns_id;
 	char *audio_transport;
+	guint audio_watch;
 };
 
 struct indicator {
@@ -1071,9 +1072,15 @@ void ofono_emulator_register(struct ofono_emulator *em, int fd)
 static void emulator_remove(struct ofono_atom *atom)
 {
 	struct ofono_emulator *em = __ofono_atom_get_data(atom);
+	DBusConnection *connection;
 
 	DBG("atom: %p", atom);
 
+	connection = ofono_dbus_get_connection();
+
+	if (em->audio_watch)
+		g_dbus_remove_watch(connection, em->audio_watch);
+
 	g_free(em->audio_transport);
 	g_free(em);
 }
@@ -1101,6 +1108,7 @@ struct ofono_emulator *ofono_emulator_create(struct ofono_modem *modem,
 	em->type = type;
 	em->l_features |= HFP_AG_FEATURE_3WAY;
 	em->l_features |= HFP_AG_FEATURE_ECNR;
+	em->l_features |= HFP_AG_FEATURE_IN_BAND_RING_TONE;
 	em->l_features |= HFP_AG_FEATURE_REJECT_CALL;
 	em->l_features |= HFP_AG_FEATURE_ENHANCED_CALL_STATUS;
 	em->l_features |= HFP_AG_FEATURE_ENHANCED_CALL_CONTROL;
@@ -1119,10 +1127,60 @@ void ofono_emulator_remove(struct ofono_emulator *em)
 	__ofono_atom_free(em->atom);
 }
 
+static gboolean audio_property_changed(DBusConnection *connection,
+					DBusMessage *message, void *user_data)
+{
+	struct ofono_emulator *em = 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);
+		g_at_server_send_unsolicited(em->server, buf);
+	}
+
+	return TRUE;
+}
+
 void ofono_emulator_set_audio_transport(struct ofono_emulator *em,
 						const char *path)
 {
+	DBusConnection *connection;
+
 	em->audio_transport = g_strdup(path);
+
+	connection = ofono_dbus_get_connection();
+
+	em->audio_watch = g_dbus_add_signal_watch(connection, NULL, path,
+						BLUEZ_TRANSPORT_INTERFACE,
+						"PropertyChanged",
+						audio_property_changed, em,
+						NULL);
 }
 
 void ofono_emulator_send_final(struct ofono_emulator *em,
-- 
1.7.1


  parent reply	other threads:[~2012-04-02 13:27 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-02 13:27 [RFC v3 00/12] org.bluez.Telephony interface integration =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
2012-04-02 13:27 ` [RFC v3 01/12] bluetooth: Add org.bluez.Telephony helpers =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
2012-04-02 13:27 ` [RFC v3 02/12] hfp_hf: Update to org.bluez.Telephony interface =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
2012-04-02 13:27 ` [RFC v3 03/12] hfp_ag: " =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
2012-04-02 13:27 ` [RFC v3 04/12] bluetooth: Add org.bluez.MediaTransport interface =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
2012-04-02 13:27 ` [RFC v3 05/12] include: Add audio transport set API =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
2012-04-02 13:27 ` [RFC v3 06/12] emulator: Add audio transport set =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
2012-04-02 13:27 ` [RFC v3 07/12] hfp_ag: Add media transport support =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
2012-04-02 13:27 ` [RFC v3 08/12] emulator: Add AT+NREC support =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
2012-04-04  3:38   ` Denis Kenzior
2012-04-02 13:27 ` =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis [this message]
2012-04-02 13:27 ` [RFC v3 10/12] emulator: Add AT+VGM support =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
2012-04-02 13:27 ` [RFC v3 11/12] emulator: Add AT+VGS support =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
2012-04-02 13:27 ` [RFC v3 12/12] hfp_ag: Update supported features =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis

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=1333373242-11117-10-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