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 08/12] emulator: Add AT+NREC support
Date: Mon, 02 Apr 2012 15:27:18 +0200	[thread overview]
Message-ID: <1333373242-11117-9-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: 4417 bytes --]

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

diff --git a/src/emulator.c b/src/emulator.c
index dc3c10d..c5ec105 100644
--- a/src/emulator.c
+++ b/src/emulator.c
@@ -33,6 +33,7 @@
 #include "common.h"
 #include "gatserver.h"
 #include "gatppp.h"
+#include "../plugins/bluetooth.h"
 
 #define RING_TIMEOUT 3
 
@@ -312,6 +313,85 @@ error:
 	}
 }
 
+static void audio_transport_set_property_cb(DBusPendingCall *call,
+						gpointer user_data)
+{
+	GAtServer *server = user_data;
+	DBusMessage *reply;
+	struct DBusError derr;
+	GAtServerResult result;
+
+	reply = dbus_pending_call_steal_reply(call);
+
+	dbus_error_init(&derr);
+
+	if (dbus_set_error_from_message(&derr, reply)) {
+		ofono_error("MediaTransport.SetProperties replied an error: " \
+				"%s, %s", derr.name, derr.message);
+		dbus_error_free(&derr);
+		result = G_AT_SERVER_RESULT_ERROR;
+	} else
+		result = G_AT_SERVER_RESULT_OK;
+
+	g_at_server_send_final(server, result);
+
+	dbus_message_unref(reply);
+}
+
+static void audio_transport_set_property(GAtServer *server, const char *path,
+						const char *name, int type,
+						const void *value)
+{
+	DBusMessage *msg;
+	DBusMessageIter iter, var;
+	const char *str_type;
+	DBusConnection *connection;
+	DBusPendingCall *c;
+
+	if (path == NULL)
+		return;
+
+	switch (type) {
+	case DBUS_TYPE_BOOLEAN:
+		str_type = DBUS_TYPE_BOOLEAN_AS_STRING;
+		break;
+
+	case DBUS_TYPE_UINT16:
+		str_type = DBUS_TYPE_UINT16_AS_STRING;
+		break;
+
+	default:
+		return;
+	}
+
+	msg = dbus_message_new_method_call(BLUEZ_SERVICE, path,
+				BLUEZ_TRANSPORT_INTERFACE, "SetProperty");
+	if (msg == NULL)
+		return;
+
+	dbus_message_iter_init_append(msg, &iter);
+	dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &name);
+
+	dbus_message_iter_open_container(&iter, DBUS_TYPE_VARIANT, str_type,
+						&var);
+	dbus_message_iter_append_basic(&var, type, value);
+	dbus_message_iter_close_container(&iter, &var);
+
+	connection = ofono_dbus_get_connection();
+
+	if (!dbus_connection_send_with_reply(connection, msg, &c, -1)) {
+		ofono_error("Sending SetProperty failed");
+		goto fail;
+	}
+
+	dbus_pending_call_set_notify(c, audio_transport_set_property_cb, server,
+									NULL);
+	dbus_pending_call_unref(c);
+
+fail:
+	dbus_message_unref(msg);
+}
+
 static struct indicator *find_indicator(struct ofono_emulator *em,
 						const char *name, int *index)
 {
@@ -829,6 +909,44 @@ fail:
 	}
 }
 
+static void nrec_cb(GAtServer *server, GAtServerRequestType type,
+			GAtResult *result, gpointer user_data)
+{
+	struct ofono_emulator *em = user_data;
+	GAtResultIter iter;
+	int val;
+
+	if (em->slc == FALSE)
+		goto fail;
+
+	switch (type) {
+	case G_AT_SERVER_REQUEST_TYPE_SET:
+		if (em->audio_transport == NULL)
+			goto fail;
+
+		g_at_result_iter_init(&iter, result);
+		g_at_result_iter_next(&iter, "");
+
+		if (!g_at_result_iter_next_number(&iter, &val))
+			goto fail;
+
+		if (val != 0 && val != 1)
+			goto fail;
+
+		/* check this is last parameter */
+		if (g_at_result_iter_skip_next(&iter))
+			goto fail;
+
+		audio_transport_set_property(server, em->audio_transport,
+					"NREC", DBUS_TYPE_BOOLEAN, &val);
+		break;
+
+	default:
+fail:
+		g_at_server_send_final(server, G_AT_SERVER_RESULT_ERROR);
+	};
+}
+
 static void emulator_add_indicator(struct ofono_emulator *em, const char* name,
 					int min, int max, int dflt,
 					gboolean mandatory)
@@ -931,6 +1049,7 @@ void ofono_emulator_register(struct ofono_emulator *em, int fd)
 		g_at_server_register(em->server, "+CCWA", ccwa_cb, em, NULL);
 		g_at_server_register(em->server, "+CMEE", cmee_cb, em, NULL);
 		g_at_server_register(em->server, "+BIA", bia_cb, em, NULL);
+		g_at_server_register(em->server, "+NREC", nrec_cb, em, NULL);
 	}
 
 	__ofono_atom_register(em->atom, emulator_unregister);
@@ -981,6 +1100,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_REJECT_CALL;
 	em->l_features |= HFP_AG_FEATURE_ENHANCED_CALL_STATUS;
 	em->l_features |= HFP_AG_FEATURE_ENHANCED_CALL_CONTROL;
-- 
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 ` =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis [this message]
2012-04-04  3:38   ` [RFC v3 08/12] emulator: Add AT+NREC support Denis Kenzior
2012-04-02 13:27 ` [RFC v3 09/12] emulator: Add +BSIR support =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
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-9-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