[pulseaudio-discuss] [RFC v1 06/14] bluetooth: BlueZ 5 interface rename to org.bluez.MediaEndpoint1
Mikel Astiz
mikel.astiz.oss at gmail.com
Mon Jan 14 07:41:30 PST 2013
From: Mikel Astiz <mikel.astiz at bmw-carit.de>
Use the new interface name if BlueZ 5 has been detected.
---
src/modules/bluetooth/bluetooth-util.c | 52 +++++++++++++++++++++++++---------
1 file changed, 38 insertions(+), 14 deletions(-)
diff --git a/src/modules/bluetooth/bluetooth-util.c b/src/modules/bluetooth/bluetooth-util.c
index ec2476f..c076a6a 100644
--- a/src/modules/bluetooth/bluetooth-util.c
+++ b/src/modules/bluetooth/bluetooth-util.c
@@ -61,6 +61,30 @@
" </interface>" \
"</node>"
+#define MEDIA_ENDPOINT_1_INTROSPECT_XML \
+ DBUS_INTROSPECT_1_0_XML_DOCTYPE_DECL_NODE \
+ "<node>" \
+ " <interface name=\"org.bluez.MediaEndpoint1\">" \
+ " <method name=\"SetConfiguration\">" \
+ " <arg name=\"transport\" direction=\"in\" type=\"o\"/>" \
+ " <arg name=\"configuration\" direction=\"in\" type=\"ay\"/>" \
+ " </method>" \
+ " <method name=\"SelectConfiguration\">" \
+ " <arg name=\"capabilities\" direction=\"in\" type=\"ay\"/>" \
+ " <arg name=\"configuration\" direction=\"out\" type=\"ay\"/>" \
+ " </method>" \
+ " <method name=\"ClearConfiguration\">" \
+ " </method>" \
+ " <method name=\"Release\">" \
+ " </method>" \
+ " </interface>" \
+ " <interface name=\"org.freedesktop.DBus.Introspectable\">" \
+ " <method name=\"Introspect\">" \
+ " <arg name=\"data\" type=\"s\" direction=\"out\"/>" \
+ " </method>" \
+ " </interface>" \
+ "</node>"
+
typedef enum pa_bluez_version {
BLUEZ_VERSION_UNKNOWN,
BLUEZ_VERSION_4,
@@ -1516,7 +1540,7 @@ static DBusMessage *endpoint_set_configuration(DBusConnection *conn, DBusMessage
dbus_message_iter_get_basic(&args, &path);
if (pa_hashmap_get(y->transports, path)) {
- pa_log("org.bluez.MediaEndpoint.SetConfiguration: Transport %s is already configured.", path);
+ pa_log("Endpoint SetConfiguration: Transport %s is already configured.", path);
goto fail2;
}
@@ -1608,11 +1632,10 @@ static DBusMessage *endpoint_set_configuration(DBusConnection *conn, DBusMessage
return r;
fail:
- pa_log("org.bluez.MediaEndpoint.SetConfiguration: invalid arguments");
+ pa_log("Endpoint SetConfiguration: invalid arguments");
fail2:
- pa_assert_se(r = dbus_message_new_error(m, "org.bluez.MediaEndpoint.Error.InvalidArguments",
- "Unable to set configuration"));
+ pa_assert_se(r = dbus_message_new_error(m, "org.bluez.Error.InvalidArguments", "Unable to set configuration"));
return r;
}
@@ -1626,7 +1649,7 @@ static DBusMessage *endpoint_clear_configuration(DBusConnection *c, DBusMessage
dbus_error_init(&e);
if (!dbus_message_get_args(m, &e, DBUS_TYPE_OBJECT_PATH, &path, DBUS_TYPE_INVALID)) {
- pa_log("org.bluez.MediaEndpoint.ClearConfiguration: %s", e.message);
+ pa_log("Endpoint ClearConfiguration: %s", e.message);
dbus_error_free(&e);
goto fail;
}
@@ -1651,8 +1674,7 @@ static DBusMessage *endpoint_clear_configuration(DBusConnection *c, DBusMessage
return r;
fail:
- pa_assert_se(r = dbus_message_new_error(m, "org.bluez.MediaEndpoint.Error.InvalidArguments",
- "Unable to clear configuration"));
+ pa_assert_se(r = dbus_message_new_error(m, "org.bluez.Error.InvalidArguments", "Unable to clear configuration"));
return r;
}
@@ -1722,7 +1744,7 @@ static DBusMessage *endpoint_select_configuration(DBusConnection *c, DBusMessage
dbus_error_init(&e);
if (!dbus_message_get_args(m, &e, DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE, &cap, &size, DBUS_TYPE_INVALID)) {
- pa_log("org.bluez.MediaEndpoint.SelectConfiguration: %s", e.message);
+ pa_log("Endpoint SelectConfiguration: %s", e.message);
dbus_error_free(&e);
goto fail;
}
@@ -1819,8 +1841,7 @@ done:
return r;
fail:
- pa_assert_se(r = dbus_message_new_error(m, "org.bluez.MediaEndpoint.Error.InvalidArguments",
- "Unable to select configuration"));
+ pa_assert_se(r = dbus_message_new_error(m, "org.bluez.Error.InvalidArguments", "Unable to select configuration"));
return r;
}
@@ -1829,9 +1850,12 @@ static DBusHandlerResult endpoint_handler(DBusConnection *c, DBusMessage *m, voi
DBusMessage *r = NULL;
DBusError e;
const char *path;
+ const char *interface;
pa_assert(y);
+ interface = y->version == BLUEZ_VERSION_4 ? "org.bluez.MediaEndpoint" : "org.bluez.MediaEndpoint1";
+
pa_log_debug("dbus: interface=%s, path=%s, member=%s\n",
dbus_message_get_interface(m),
dbus_message_get_path(m),
@@ -1845,7 +1869,7 @@ static DBusHandlerResult endpoint_handler(DBusConnection *c, DBusMessage *m, voi
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
if (dbus_message_is_method_call(m, "org.freedesktop.DBus.Introspectable", "Introspect")) {
- const char *xml = ENDPOINT_INTROSPECT_XML;
+ const char *xml = y->version == BLUEZ_VERSION_4 ? ENDPOINT_INTROSPECT_XML : MEDIA_ENDPOINT_1_INTROSPECT_XML;
pa_assert_se(r = dbus_message_new_method_return(m));
pa_assert_se(dbus_message_append_args(
@@ -1853,11 +1877,11 @@ static DBusHandlerResult endpoint_handler(DBusConnection *c, DBusMessage *m, voi
DBUS_TYPE_STRING, &xml,
DBUS_TYPE_INVALID));
- } else if (dbus_message_is_method_call(m, "org.bluez.MediaEndpoint", "SetConfiguration")) {
+ } else if (dbus_message_is_method_call(m, interface, "SetConfiguration")) {
r = endpoint_set_configuration(c, m, userdata);
- } else if (dbus_message_is_method_call(m, "org.bluez.MediaEndpoint", "SelectConfiguration")) {
+ } else if (dbus_message_is_method_call(m, interface, "SelectConfiguration")) {
r = endpoint_select_configuration(c, m, userdata);
- } else if (dbus_message_is_method_call(m, "org.bluez.MediaEndpoint", "ClearConfiguration"))
+ } else if (dbus_message_is_method_call(m, interface, "ClearConfiguration"))
r = endpoint_clear_configuration(c, m, userdata);
else
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
--
1.7.11.7
More information about the pulseaudio-discuss
mailing list