Open Source Telephony
 help / color / mirror / Atom feed
* [PATCH 1/5] hfp_hf_bluez5: Add extracting version
@ 2013-04-03 23:24 Vinicius Costa Gomes
  2013-04-03 23:24 ` [PATCH 2/5] hfp_hf_bluez5: Add audio card .connect() for HFP 1.6 Vinicius Costa Gomes
                   ` (4 more replies)
  0 siblings, 5 replies; 13+ messages in thread
From: Vinicius Costa Gomes @ 2013-04-03 23:24 UTC (permalink / raw)
  To: ofono

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

From: Claudio Takahasi <claudio.takahasi@openbossa.org>

This patch parses and reads the profile "Version" that comes in the fd
dictionary of the NewConnection method. "Version" is input for Audio Card
registration.
---
 plugins/hfp_hf_bluez5.c | 49 ++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 48 insertions(+), 1 deletion(-)

diff --git a/plugins/hfp_hf_bluez5.c b/plugins/hfp_hf_bluez5.c
index f068c70..a6cc156 100644
--- a/plugins/hfp_hf_bluez5.c
+++ b/plugins/hfp_hf_bluez5.c
@@ -350,6 +350,45 @@ static ofono_bool_t device_path_compare(struct ofono_modem *modem,
 	return g_str_equal(path, value);
 }
 
+static int get_version(DBusMessageIter *iter, uint16_t *version)
+{
+	DBusMessageIter dict, entry, valiter;
+	const char *key;
+	uint16_t value;
+
+	/* Points to dict */
+	dbus_message_iter_recurse(iter, &dict);
+
+	/* For each entry in this dict */
+	while (dbus_message_iter_get_arg_type(&dict) != DBUS_TYPE_INVALID) {
+		/* I want to access the entry's contents */
+		dbus_message_iter_recurse(&dict, &entry);
+
+		if (dbus_message_iter_get_arg_type(&entry) != DBUS_TYPE_STRING)
+			return -EINVAL;
+
+		/* If the current key isn't "Version", keep looking */
+		dbus_message_iter_get_basic(&entry, &key);
+		if (!g_str_equal("Version", key)) {
+			dbus_message_iter_next(&dict);
+			continue;
+		}
+
+		dbus_message_iter_next(&entry);
+		if (dbus_message_iter_get_arg_type(&entry) != DBUS_TYPE_VARIANT)
+			return -EINVAL;
+
+		dbus_message_iter_recurse(&entry, &valiter);
+		dbus_message_iter_get_basic(&valiter, &value);
+		break;
+	}
+
+	if (version)
+		*version = value;
+
+	return 0;
+}
+
 static DBusMessage *profile_new_connection(DBusConnection *conn,
 					DBusMessage *msg, void *user_data)
 {
@@ -360,6 +399,7 @@ static DBusMessage *profile_new_connection(DBusConnection *conn,
 	DBusMessageIter entry;
 	const char *device;
 	char local[18], remote[18];
+	uint16_t version = HFP_VERSION_1_5;
 	int fd, err;
 
 	DBG("Profile handler NewConnection");
@@ -380,6 +420,13 @@ static DBusMessage *profile_new_connection(DBusConnection *conn,
 	if (fd < 0)
 		goto invalid;
 
+	dbus_message_iter_next(&entry);
+	if (dbus_message_iter_get_arg_type(&entry) != DBUS_TYPE_ARRAY)
+		goto invalid;
+
+	if (get_version(&entry, &version) < 0)
+		goto invalid;
+
 	modem = ofono_modem_find(device_path_compare, (void *) device);
 	if (modem == NULL) {
 		close(fd);
@@ -388,7 +435,7 @@ static DBusMessage *profile_new_connection(DBusConnection *conn,
 					"Unknown Bluetooth device");
 	}
 
-	err = service_level_connection(modem, fd, HFP_VERSION_LATEST);
+	err = service_level_connection(modem, fd, version);
 	if (err < 0 && err != -EINPROGRESS) {
 		close(fd);
 		return g_dbus_create_error(msg, BLUEZ_ERROR_INTERFACE
-- 
1.8.2


^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2013-04-05 22:00 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-04-03 23:24 [PATCH 1/5] hfp_hf_bluez5: Add extracting version Vinicius Costa Gomes
2013-04-03 23:24 ` [PATCH 2/5] hfp_hf_bluez5: Add audio card .connect() for HFP 1.6 Vinicius Costa Gomes
2013-04-05 17:22   ` Denis Kenzior
2013-04-05 18:45     ` Vinicius Costa Gomes
2013-04-03 23:24 ` [PATCH 3/5] hfp_hf_bluez5: Select the audio card driver based on version Vinicius Costa Gomes
2013-04-05 17:33   ` Denis Kenzior
2013-04-03 23:24 ` [PATCH 4/5] handsfree-audio: Add function to get the codecs Vinicius Costa Gomes
2013-04-05 17:32   ` Denis Kenzior
2013-04-05 20:56     ` Vinicius Costa Gomes
2013-04-05 21:40       ` Denis Kenzior
2013-04-05 22:00         ` Vinicius Costa Gomes
2013-04-03 23:24 ` [PATCH 5/5] hfpmodem: Send AT+BAC with the supported codecs Vinicius Costa Gomes
2013-04-05 17:22 ` [PATCH 1/5] hfp_hf_bluez5: Add extracting version Denis Kenzior

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox