* [PATCH BlueZ 01/11] audio: Remove AudioSink interface
@ 2012-11-26 13:09 Luiz Augusto von Dentz
2012-11-26 13:09 ` [PATCH BlueZ 02/11] audio: Remove AudioSource interface Luiz Augusto von Dentz
` (10 more replies)
0 siblings, 11 replies; 12+ messages in thread
From: Luiz Augusto von Dentz @ 2012-11-26 13:09 UTC (permalink / raw)
To: linux-bluetooth
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This interface is no longer needed as Device interface can now connect
the profiles and the state can be tracked using MediaTransport interface.
---
doc/audio-api.txt | 53 -------------------
profiles/audio/sink.c | 141 ++------------------------------------------------
2 files changed, 3 insertions(+), 191 deletions(-)
diff --git a/doc/audio-api.txt b/doc/audio-api.txt
index 9ace681..47ea4b6 100644
--- a/doc/audio-api.txt
+++ b/doc/audio-api.txt
@@ -51,59 +51,6 @@ Properties string State
Disconnected from the remote device
-AudioSink hierarchy
-===================
-
-Service org.bluez
-Interface org.bluez.AudioSink
-Object path [variable prefix]/{hci0,hci1,...}/dev_XX_XX_XX_XX_XX_XX
-
-Methods void Connect()
-
- Connect and setup a stream to a A2DP sink on the
- remote device.
-
- void Disconnect()
-
- Disconnect from the remote device.
-
- dict GetProperties()
-
- Returns all properties for the interface. See the
- properties section for available properties.
-
- Possible Errors: org.bluez.Error.InvalidArguments
-
-Signals PropertyChanged(string name, variant value)
-
- This signal indicates a changed value of the given
- property.
-
-properties string State [readonly]
-
- Possible values: "disconnected", "connecting",
- "connected", "playing"
-
- "disconnected" -> "connecting"
- Either an incoming or outgoing connection
- attempt ongoing.
-
- "connecting" -> "disconnected"
- Connection attempt failed
-
- "connecting" -> "connected"
- Successfully connected
-
- "connected" -> "playing"
- Audio stream active
-
- "playing" -> "connected"
- Audio stream suspended
-
- "connected" -> "disconnected"
- "playing" -> "disconnected"
- Disconnected from the remote device
-
AudioSource hierarchy
=====================
diff --git a/profiles/audio/sink.c b/profiles/audio/sink.c
index 257cb2f..466c0a8 100644
--- a/profiles/audio/sink.c
+++ b/profiles/audio/sink.c
@@ -87,38 +87,14 @@ static char *str_state[] = {
"SINK_STATE_PLAYING",
};
-static const char *state2str(sink_state_t state)
-{
- switch (state) {
- case SINK_STATE_DISCONNECTED:
- return "disconnected";
- case SINK_STATE_CONNECTING:
- return "connecting";
- case SINK_STATE_CONNECTED:
- return "connected";
- case SINK_STATE_PLAYING:
- return "playing";
- default:
- error("Invalid sink state %d", state);
- return NULL;
- }
-}
-
static void sink_set_state(struct audio_device *dev, sink_state_t new_state)
{
struct sink *sink = dev->sink;
- const char *state_str;
sink_state_t old_state = sink->state;
GSList *l;
sink->state = new_state;
- state_str = state2str(new_state);
- if (state_str)
- emit_property_changed(device_get_path(dev->btd_dev),
- AUDIO_SINK_INTERFACE, "State",
- DBUS_TYPE_STRING, &state_str);
-
DBG("State changed %s: %s -> %s", device_get_path(dev->btd_dev),
str_state[old_state], str_state[new_state]);
@@ -366,38 +342,6 @@ gboolean sink_setup_stream(struct sink *sink, struct avdtp *session)
return TRUE;
}
-static void generic_cb(struct audio_device *dev, int err, void *data)
-{
- DBusMessage *msg = data;
- DBusMessage *reply;
-
- if (err < 0) {
- reply = btd_error_failed(msg, strerror(-err));
- g_dbus_send_message(btd_get_dbus_connection(), reply);
- dbus_message_unref(msg);
- return;
- }
-
- g_dbus_send_reply(btd_get_dbus_connection(), msg, DBUS_TYPE_INVALID);
-
- dbus_message_unref(msg);
-}
-
-static DBusMessage *connect_sink(DBusConnection *conn,
- DBusMessage *msg, void *data)
-{
- struct audio_device *dev = data;
- int err;
-
- err = sink_connect(dev, generic_cb, msg);
- if (err < 0)
- return btd_error_failed(msg, strerror(-err));
-
- dbus_message_ref(msg);
-
- return NULL;
-}
-
int sink_connect(struct audio_device *dev, audio_device_cb cb, void *data)
{
struct sink *sink = dev->sink;
@@ -434,67 +378,6 @@ int sink_connect(struct audio_device *dev, audio_device_cb cb, void *data)
return 0;
}
-static DBusMessage *disconnect_sink(DBusConnection *conn,
- DBusMessage *msg, void *data)
-{
- struct audio_device *dev = data;
- int err;
-
- err = sink_disconnect(dev, FALSE, generic_cb, msg);
- if (err < 0)
- return btd_error_failed(msg, strerror(-err));
-
- dbus_message_ref(msg);
-
- return NULL;
-}
-
-static DBusMessage *sink_get_properties(DBusConnection *conn,
- DBusMessage *msg, void *data)
-{
- struct audio_device *device = data;
- struct sink *sink = device->sink;
- DBusMessage *reply;
- DBusMessageIter iter;
- DBusMessageIter dict;
- const char *state;
-
- reply = dbus_message_new_method_return(msg);
- if (!reply)
- return NULL;
-
- dbus_message_iter_init_append(reply, &iter);
-
- dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY,
- DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING
- DBUS_TYPE_STRING_AS_STRING DBUS_TYPE_VARIANT_AS_STRING
- DBUS_DICT_ENTRY_END_CHAR_AS_STRING, &dict);
-
- /* State */
- state = state2str(sink->state);
- if (state)
- dict_append_entry(&dict, "State", DBUS_TYPE_STRING, &state);
-
- dbus_message_iter_close_container(&iter, &dict);
-
- return reply;
-}
-
-static const GDBusMethodTable sink_methods[] = {
- { GDBUS_ASYNC_METHOD("Connect", NULL, NULL, connect_sink) },
- { GDBUS_ASYNC_METHOD("Disconnect", NULL, NULL, disconnect_sink) },
- { GDBUS_METHOD("GetProperties",
- NULL, GDBUS_ARGS({ "properties", "a{sv}" }),
- sink_get_properties) },
- { }
-};
-
-static const GDBusSignalTable sink_signals[] = {
- { GDBUS_SIGNAL("PropertyChanged",
- GDBUS_ARGS({ "name", "s" }, { "value", "v" })) },
- { }
-};
-
static void sink_free(struct audio_device *dev)
{
struct sink *sink = dev->sink;
@@ -519,35 +402,17 @@ static void sink_free(struct audio_device *dev)
dev->sink = NULL;
}
-static void path_unregister(void *data)
-{
- struct audio_device *dev = data;
-
- DBG("Unregistered interface %s on path %s",
- AUDIO_SINK_INTERFACE, device_get_path(dev->btd_dev));
-
- sink_free(dev);
-}
-
void sink_unregister(struct audio_device *dev)
{
- g_dbus_unregister_interface(btd_get_dbus_connection(),
- device_get_path(dev->btd_dev), AUDIO_SINK_INTERFACE);
+ DBG("%s", device_get_path(dev->btd_dev));
+ sink_free(dev);
}
struct sink *sink_init(struct audio_device *dev)
{
struct sink *sink;
- if (!g_dbus_register_interface(btd_get_dbus_connection(),
- device_get_path(dev->btd_dev),
- AUDIO_SINK_INTERFACE,
- sink_methods, sink_signals, NULL,
- dev, path_unregister))
- return NULL;
-
- DBG("Registered interface %s on path %s",
- AUDIO_SINK_INTERFACE, device_get_path(dev->btd_dev));
+ DBG("%s", device_get_path(dev->btd_dev));
if (avdtp_callback_id == 0)
avdtp_callback_id = avdtp_add_state_cb(avdtp_state_callback,
--
1.7.11.7
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH BlueZ 02/11] audio: Remove AudioSource interface
2012-11-26 13:09 [PATCH BlueZ 01/11] audio: Remove AudioSink interface Luiz Augusto von Dentz
@ 2012-11-26 13:09 ` Luiz Augusto von Dentz
2012-11-26 13:09 ` [PATCH BlueZ 03/11] audio: Remove Audio interface Luiz Augusto von Dentz
` (9 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Luiz Augusto von Dentz @ 2012-11-26 13:09 UTC (permalink / raw)
To: linux-bluetooth
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This interface is no longer needed as Device interface can now connect
the profiles and the state can be tracked using MediaTransport interface.
---
doc/audio-api.txt | 54 ------------------
profiles/audio/source.c | 146 ++++--------------------------------------------
2 files changed, 11 insertions(+), 189 deletions(-)
diff --git a/doc/audio-api.txt b/doc/audio-api.txt
index 47ea4b6..6fd8dfc 100644
--- a/doc/audio-api.txt
+++ b/doc/audio-api.txt
@@ -49,57 +49,3 @@ Properties string State
"connected" -> "disconnected"
Disconnected from the remote device
-
-
-AudioSource hierarchy
-=====================
-
-Service org.bluez
-Interface org.bluez.AudioSource
-Object path [variable prefix]/{hci0,hci1,...}/dev_XX_XX_XX_XX_XX_XX
-
-Methods void Connect()
-
- Connect and setup a stream to a A2DP source on the
- remote device.
-
- void Disconnect()
-
- Disconnect from the remote device.
-
- dict GetProperties()
-
- Returns all properties for the interface. See the
- properties section for available properties.
-
- Possible Errors: org.bluez.Error.InvalidArguments
-
-Signals PropertyChanged(string name, variant value)
-
- This signal indicates a changed value of the given
- property.
-
-properties string State [readonly]
-
- Possible values: "disconnected", "connecting",
- "connected", "playing"
-
- "disconnected" -> "connecting"
- Either an incoming or outgoing connection
- attempt ongoing.
-
- "connecting" -> "disconnected"
- Connection attempt failed
-
- "connecting" -> "connected"
- Successfully connected
-
- "connected" -> "playing"
- Audio stream active
-
- "playing" -> "connected"
- Audio stream suspended
-
- "connected" -> "disconnected"
- "playing" -> "disconnected"
- Disconnected from the remote device
diff --git a/profiles/audio/source.c b/profiles/audio/source.c
index 902b4d4..157a4e8 100644
--- a/profiles/audio/source.c
+++ b/profiles/audio/source.c
@@ -81,37 +81,23 @@ static GSList *source_callbacks = NULL;
static unsigned int avdtp_callback_id = 0;
-static const char *state2str(source_state_t state)
-{
- switch (state) {
- case SOURCE_STATE_DISCONNECTED:
- return "disconnected";
- case SOURCE_STATE_CONNECTING:
- return "connecting";
- case SOURCE_STATE_CONNECTED:
- return "connected";
- case SOURCE_STATE_PLAYING:
- return "playing";
- default:
- error("Invalid source state %d", state);
- return NULL;
- }
-}
+static char *str_state[] = {
+ "SOURCE_STATE_DISCONNECTED",
+ "SOURCE_STATE_CONNECTING",
+ "SOURCE_STATE_CONNECTED",
+ "SOURCE_STATE_PLAYING",
+};
static void source_set_state(struct audio_device *dev, source_state_t new_state)
{
struct source *source = dev->source;
- const char *state_str;
source_state_t old_state = source->state;
GSList *l;
source->state = new_state;
- state_str = state2str(new_state);
- if (state_str)
- emit_property_changed(device_get_path(dev->btd_dev),
- AUDIO_SOURCE_INTERFACE, "State",
- DBUS_TYPE_STRING, &state_str);
+ DBG("State changed %s: %s -> %s", device_get_path(dev->btd_dev),
+ str_state[old_state], str_state[new_state]);
for (l = source_callbacks; l != NULL; l = l->next) {
struct source_state_callback *cb = l->data;
@@ -356,38 +342,6 @@ gboolean source_setup_stream(struct source *source, struct avdtp *session)
return TRUE;
}
-static void generic_cb(struct audio_device *dev, int err, void *data)
-{
- DBusMessage *msg = data;
- DBusMessage *reply;
-
- if (err < 0) {
- reply = btd_error_failed(msg, strerror(-err));
- g_dbus_send_message(btd_get_dbus_connection(), reply);
- dbus_message_unref(msg);
- return;
- }
-
- g_dbus_send_reply(btd_get_dbus_connection(), msg, DBUS_TYPE_INVALID);
-
- dbus_message_unref(msg);
-}
-
-static DBusMessage *connect_source(DBusConnection *conn,
- DBusMessage *msg, void *data)
-{
- struct audio_device *dev = data;
- int err;
-
- err = source_connect(dev, generic_cb, msg);
- if (err < 0)
- return btd_error_failed(msg, strerror(-err));
-
- dbus_message_ref(msg);
-
- return NULL;
-}
-
int source_connect(struct audio_device *dev, audio_device_cb cb, void *data)
{
struct source *source = dev->source;
@@ -423,67 +377,6 @@ int source_connect(struct audio_device *dev, audio_device_cb cb, void *data)
return 0;
}
-static DBusMessage *disconnect_source(DBusConnection *conn,
- DBusMessage *msg, void *data)
-{
- struct audio_device *dev = data;
- int err;
-
- err = source_disconnect(dev, FALSE, generic_cb, msg);
- if (err < 0)
- return btd_error_failed(msg, strerror(-err));
-
- dbus_message_ref(msg);
-
- return NULL;
-}
-
-static DBusMessage *source_get_properties(DBusConnection *conn,
- DBusMessage *msg, void *data)
-{
- struct audio_device *device = data;
- struct source *source = device->source;
- DBusMessage *reply;
- DBusMessageIter iter;
- DBusMessageIter dict;
- const char *state;
-
- reply = dbus_message_new_method_return(msg);
- if (!reply)
- return NULL;
-
- dbus_message_iter_init_append(reply, &iter);
-
- dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY,
- DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING
- DBUS_TYPE_STRING_AS_STRING DBUS_TYPE_VARIANT_AS_STRING
- DBUS_DICT_ENTRY_END_CHAR_AS_STRING, &dict);
-
- /* State */
- state = state2str(source->state);
- if (state)
- dict_append_entry(&dict, "State", DBUS_TYPE_STRING, &state);
-
- dbus_message_iter_close_container(&iter, &dict);
-
- return reply;
-}
-
-static const GDBusMethodTable source_methods[] = {
- { GDBUS_ASYNC_METHOD("Connect", NULL, NULL, connect_source) },
- { GDBUS_ASYNC_METHOD("Disconnect", NULL, NULL, disconnect_source) },
- { GDBUS_METHOD("GetProperties",
- NULL, GDBUS_ARGS({ "properties", "a{sv}" }),
- source_get_properties) },
- { }
-};
-
-static const GDBusSignalTable source_signals[] = {
- { GDBUS_SIGNAL("PropertyChanged",
- GDBUS_ARGS({ "name", "s" }, { "value", "v" })) },
- { }
-};
-
static void source_free(struct audio_device *dev)
{
struct source *source = dev->source;
@@ -508,35 +401,18 @@ static void source_free(struct audio_device *dev)
dev->source = NULL;
}
-static void path_unregister(void *data)
+void source_unregister(struct audio_device *dev)
{
- struct audio_device *dev = data;
-
- DBG("Unregistered interface %s on path %s",
- AUDIO_SOURCE_INTERFACE, device_get_path(dev->btd_dev));
+ DBG("%s", device_get_path(dev->btd_dev));
source_free(dev);
}
-void source_unregister(struct audio_device *dev)
-{
- g_dbus_unregister_interface(btd_get_dbus_connection(),
- device_get_path(dev->btd_dev), AUDIO_SOURCE_INTERFACE);
-}
-
struct source *source_init(struct audio_device *dev)
{
struct source *source;
- if (!g_dbus_register_interface(btd_get_dbus_connection(),
- device_get_path(dev->btd_dev),
- AUDIO_SOURCE_INTERFACE,
- source_methods, source_signals, NULL,
- dev, path_unregister))
- return NULL;
-
- DBG("Registered interface %s on path %s",
- AUDIO_SOURCE_INTERFACE, device_get_path(dev->btd_dev));
+ DBG("%s", device_get_path(dev->btd_dev));
if (avdtp_callback_id == 0)
avdtp_callback_id = avdtp_add_state_cb(avdtp_state_callback,
--
1.7.11.7
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH BlueZ 03/11] audio: Remove Audio interface
2012-11-26 13:09 [PATCH BlueZ 01/11] audio: Remove AudioSink interface Luiz Augusto von Dentz
2012-11-26 13:09 ` [PATCH BlueZ 02/11] audio: Remove AudioSource interface Luiz Augusto von Dentz
@ 2012-11-26 13:09 ` Luiz Augusto von Dentz
2012-11-26 13:09 ` [PATCH BlueZ 04/11] audio: Remove Control.Connect and Control.Disconnect Luiz Augusto von Dentz
` (8 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Luiz Augusto von Dentz @ 2012-11-26 13:09 UTC (permalink / raw)
To: linux-bluetooth
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This interface is no longer needed as Device interface can now connect
the profiles and the state can be tracked using MediaTransport interface.
---
doc/audio-api.txt | 51 ---------------
profiles/audio/device.c | 160 +-----------------------------------------------
2 files changed, 2 insertions(+), 209 deletions(-)
delete mode 100644 doc/audio-api.txt
diff --git a/doc/audio-api.txt b/doc/audio-api.txt
deleted file mode 100644
index 6fd8dfc..0000000
--- a/doc/audio-api.txt
+++ /dev/null
@@ -1,51 +0,0 @@
-BlueZ D-Bus Audio API description
-*********************************
-
-Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org>
-Copyright (C) 2005-2007 Johan Hedberg <johan.hedberg@nokia.com>
-Copyright (C) 2005-2006 Brad Midgley <bmidgley@xmission.com>
-
-Audio hierarchy
-===============
-
-Service org.bluez
-Interface org.bluez.Audio
-Object path [variable prefix]/{hci0,hci1,...}/dev_XX_XX_XX_XX_XX_XX
-
-This is a generic audio interface that abstracts the different audio profiles.
-
-Methods void Connect()
-
- Connect all supported audio profiles on the device.
-
- void Disconnect()
-
- Disconnect all audio profiles on the device
-
- dict GetProperties()
-
- Returns all properties for the interface. See the
- properties section for available properties.
-
-Signals void PropertyChanged(string name, variant value)
-
- This signal indicates a changed value of the given
- property.
-
-Properties string State
-
- Possible values: "disconnected", "connecting",
- "connected"
-
- "disconnected" -> "connecting"
- Either an incoming or outgoing connection
- attempt ongoing.
-
- "connecting" -> "disconnected"
- Connection attempt failed
-
- "connecting" -> "connected"
- Successfully connected
-
- "connected" -> "disconnected"
- Disconnected from the remote device
diff --git a/profiles/audio/device.c b/profiles/audio/device.c
index 4cce6ba..b14f75b 100644
--- a/profiles/audio/device.c
+++ b/profiles/audio/device.c
@@ -74,9 +74,6 @@ struct dev_priv {
sink_state_t sink_state;
avctp_state_t avctp_state;
- DBusMessage *conn_req;
- DBusMessage *dc_req;
-
guint control_timer;
guint avdtp_timer;
guint dc_id;
@@ -97,10 +94,6 @@ static void device_free(struct audio_device *dev)
g_source_remove(priv->control_timer);
if (priv->avdtp_timer)
g_source_remove(priv->avdtp_timer);
- if (priv->dc_req)
- dbus_message_unref(priv->dc_req);
- if (priv->conn_req)
- dbus_message_unref(priv->conn_req);
if (priv->dc_id)
device_remove_disconnect_watch(dev->btd_dev,
priv->dc_id);
@@ -198,10 +191,8 @@ static void disconnect_cb(struct btd_device *btd_dev, gboolean removal,
static void device_set_state(struct audio_device *dev, audio_state_t new_state)
{
- DBusConnection *conn = btd_get_dbus_connection();
struct dev_priv *priv = dev->priv;
const char *state_str;
- DBusMessage *reply = NULL;
state_str = state2str(new_state);
if (!state_str)
@@ -225,31 +216,8 @@ static void device_set_state(struct audio_device *dev, audio_state_t new_state)
dev->priv->state = new_state;
- if (new_state == AUDIO_STATE_DISCONNECTED) {
- if (priv->dc_req) {
- reply = dbus_message_new_method_return(priv->dc_req);
- dbus_message_unref(priv->dc_req);
- priv->dc_req = NULL;
- g_dbus_send_message(conn, reply);
- }
+ if (new_state == AUDIO_STATE_DISCONNECTED)
priv->disconnecting = FALSE;
- }
-
- if (priv->conn_req && new_state != AUDIO_STATE_CONNECTING) {
- if (new_state == AUDIO_STATE_CONNECTED)
- reply = dbus_message_new_method_return(priv->conn_req);
- else
- reply = btd_error_failed(priv->conn_req,
- "Connect Failed");
-
- dbus_message_unref(priv->conn_req);
- priv->conn_req = NULL;
- g_dbus_send_message(conn, reply);
- }
-
- emit_property_changed(device_get_path(dev->btd_dev),
- AUDIO_INTERFACE, "State",
- DBUS_TYPE_STRING, &state_str);
}
static void device_avdtp_cb(struct audio_device *dev, struct avdtp *session,
@@ -324,115 +292,6 @@ static void device_avctp_cb(struct audio_device *dev,
}
}
-static DBusMessage *dev_connect(DBusConnection *conn, DBusMessage *msg,
- void *data)
-{
- struct audio_device *dev = data;
- struct dev_priv *priv = dev->priv;
-
- if (priv->state == AUDIO_STATE_CONNECTING)
- return btd_error_in_progress(msg);
- else if (priv->state == AUDIO_STATE_CONNECTED)
- return btd_error_already_connected(msg);
-
- dev->auto_connect = TRUE;
-
- if (priv->state != AUDIO_STATE_CONNECTING && dev->sink) {
- struct avdtp *session = avdtp_get(&dev->src, &dev->dst);
-
- if (!session)
- return btd_error_failed(msg,
- "Failed to get AVDTP session");
-
- sink_setup_stream(dev->sink, session);
- avdtp_unref(session);
- }
-
- /* The previous calls should cause a call to the state callback to
- * indicate AUDIO_STATE_CONNECTING */
- if (priv->state != AUDIO_STATE_CONNECTING)
- return btd_error_failed(msg, "Connect Failed");
-
- priv->conn_req = dbus_message_ref(msg);
-
- return NULL;
-}
-
-static DBusMessage *dev_disconnect(DBusConnection *conn, DBusMessage *msg,
- void *data)
-{
- struct audio_device *dev = data;
- struct dev_priv *priv = dev->priv;
-
- if (priv->state == AUDIO_STATE_DISCONNECTED)
- return btd_error_not_connected(msg);
-
- if (priv->dc_req)
- return dbus_message_new_method_return(msg);
-
- priv->dc_req = dbus_message_ref(msg);
-
- if (dev->control) {
- device_remove_control_timer(dev);
- avrcp_disconnect(dev);
- }
-
- if (dev->sink && priv->sink_state != SINK_STATE_DISCONNECTED)
- sink_disconnect(dev, TRUE, NULL, NULL);
- else {
- dbus_message_unref(priv->dc_req);
- priv->dc_req = NULL;
- return dbus_message_new_method_return(msg);
- }
-
- return NULL;
-}
-
-static DBusMessage *dev_get_properties(DBusConnection *conn, DBusMessage *msg,
- void *data)
-{
- struct audio_device *device = data;
- DBusMessage *reply;
- DBusMessageIter iter;
- DBusMessageIter dict;
- const char *state;
-
- reply = dbus_message_new_method_return(msg);
- if (!reply)
- return NULL;
-
- dbus_message_iter_init_append(reply, &iter);
-
- dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY,
- DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING
- DBUS_TYPE_STRING_AS_STRING DBUS_TYPE_VARIANT_AS_STRING
- DBUS_DICT_ENTRY_END_CHAR_AS_STRING, &dict);
-
- /* State */
- state = state2str(device->priv->state);
- if (state)
- dict_append_entry(&dict, "State", DBUS_TYPE_STRING, &state);
-
- dbus_message_iter_close_container(&iter, &dict);
-
- return reply;
-}
-
-static const GDBusMethodTable dev_methods[] = {
- { GDBUS_ASYNC_METHOD("Connect", NULL, NULL, dev_connect) },
- { GDBUS_METHOD("Disconnect", NULL, NULL, dev_disconnect) },
- { GDBUS_METHOD("GetProperties",
- NULL, GDBUS_ARGS({ "properties", "a{sv}" }),
- dev_get_properties) },
- { }
-};
-
-static const GDBusSignalTable dev_signals[] = {
- { GDBUS_SIGNAL("PropertyChanged",
- GDBUS_ARGS({ "name", "s" }, { "value", "v" })) },
- { }
-};
-
struct audio_device *audio_device_register(struct btd_device *device,
const bdaddr_t *src,
const bdaddr_t *dst)
@@ -447,18 +306,7 @@ struct audio_device *audio_device_register(struct btd_device *device,
dev->priv = g_new0(struct dev_priv, 1);
dev->priv->state = AUDIO_STATE_DISCONNECTED;
- if (!g_dbus_register_interface(btd_get_dbus_connection(),
- device_get_path(dev->btd_dev),
- AUDIO_INTERFACE, dev_methods,
- dev_signals, NULL, dev, NULL)) {
- error("Unable to register %s on %s", AUDIO_INTERFACE,
- device_get_path(dev->btd_dev));
- device_free(dev);
- return NULL;
- }
-
- DBG("Registered interface %s on path %s", AUDIO_INTERFACE,
- device_get_path(dev->btd_dev));
+ DBG("%s", device_get_path(dev->btd_dev));
if (sink_callback_id == 0)
sink_callback_id = sink_add_state_cb(device_sink_cb, NULL);
@@ -507,9 +355,5 @@ void audio_device_unregister(struct audio_device *device)
if (device->control)
control_unregister(device);
- g_dbus_unregister_interface(btd_get_dbus_connection(),
- device_get_path(device->btd_dev),
- AUDIO_INTERFACE);
-
device_free(device);
}
--
1.7.11.7
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH BlueZ 04/11] audio: Remove Control.Connect and Control.Disconnect
2012-11-26 13:09 [PATCH BlueZ 01/11] audio: Remove AudioSink interface Luiz Augusto von Dentz
2012-11-26 13:09 ` [PATCH BlueZ 02/11] audio: Remove AudioSource interface Luiz Augusto von Dentz
2012-11-26 13:09 ` [PATCH BlueZ 03/11] audio: Remove Audio interface Luiz Augusto von Dentz
@ 2012-11-26 13:09 ` Luiz Augusto von Dentz
2012-11-26 13:09 ` [PATCH BlueZ 05/11] input: Remove Input interface Luiz Augusto von Dentz
` (7 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Luiz Augusto von Dentz @ 2012-11-26 13:09 UTC (permalink / raw)
To: linux-bluetooth
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
These method are no longer necessary as Device interface has similar
functionality.
---
doc/control-api.txt | 10 +---------
profiles/audio/control.c | 47 -----------------------------------------------
profiles/audio/device.c | 6 ++++--
3 files changed, 5 insertions(+), 58 deletions(-)
diff --git a/doc/control-api.txt b/doc/control-api.txt
index 0d25512..a16ee7d 100644
--- a/doc/control-api.txt
+++ b/doc/control-api.txt
@@ -12,15 +12,7 @@ Service org.bluez
Interface org.bluez.Control
Object path [variable prefix]/{hci0,hci1,...}/dev_XX_XX_XX_XX_XX_XX
-Methods void Connect()
-
- Connect to remote device.
-
- void Disconnect()
-
- Disconnect from remote device.
-
- void Play()
+Methods void Play()
Resume playback.
diff --git a/profiles/audio/control.c b/profiles/audio/control.c
index 29cf3bb..0013f8d 100644
--- a/profiles/audio/control.c
+++ b/profiles/audio/control.c
@@ -153,38 +153,6 @@ int control_connect(struct audio_device *dev, audio_device_cb cb, void *data)
return 0;
}
-static void generic_cb(struct audio_device *dev, int err, void *data)
-{
- DBusMessage *msg = data;
- DBusMessage *reply;
-
- if (err < 0) {
- reply = btd_error_failed(msg, strerror(-err));
- g_dbus_send_message(btd_get_dbus_connection(), reply);
- dbus_message_unref(msg);
- return;
- }
-
- g_dbus_send_reply(btd_get_dbus_connection(), msg, DBUS_TYPE_INVALID);
-
- dbus_message_unref(msg);
-}
-
-static DBusMessage *connect_control(DBusConnection *conn, DBusMessage *msg,
- void *data)
-{
- struct audio_device *device = data;
- int err;
-
- err = control_connect(device, generic_cb, msg);
- if (err < 0)
- return btd_error_failed(msg, strerror(-err));
-
- dbus_message_ref(msg);
-
- return NULL;
-}
-
int control_disconnect(struct audio_device *dev, audio_device_cb cb,
void *data)
{
@@ -208,19 +176,6 @@ int control_disconnect(struct audio_device *dev, audio_device_cb cb,
}
-static DBusMessage *disconnect_control(DBusConnection *conn, DBusMessage *msg,
- void *data)
-{
- struct audio_device *device = data;
- int err;
-
- err = control_disconnect(device, NULL, NULL);
- if (err < 0)
- return btd_error_failed(msg, strerror(-err));
-
- return dbus_message_new_method_return(msg);
-}
-
static DBusMessage *key_pressed(DBusConnection *conn, DBusMessage *msg,
uint8_t op, void *data)
{
@@ -296,8 +251,6 @@ static gboolean control_property_get_connected(
}
static const GDBusMethodTable control_methods[] = {
- { GDBUS_ASYNC_METHOD("Connect", NULL, NULL, connect_control) },
- { GDBUS_METHOD("Disconnect", NULL, NULL, disconnect_control) },
{ GDBUS_METHOD("Play", NULL, NULL, control_play) },
{ GDBUS_METHOD("Pause", NULL, NULL, control_pause) },
{ GDBUS_METHOD("Stop", NULL, NULL, control_stop) },
diff --git a/profiles/audio/device.c b/profiles/audio/device.c
index b14f75b..fef2bea 100644
--- a/profiles/audio/device.c
+++ b/profiles/audio/device.c
@@ -298,6 +298,8 @@ struct audio_device *audio_device_register(struct btd_device *device,
{
struct audio_device *dev;
+ DBG("%s", device_get_path(device));
+
dev = g_new0(struct audio_device, 1);
dev->btd_dev = btd_device_ref(device);
@@ -306,8 +308,6 @@ struct audio_device *audio_device_register(struct btd_device *device,
dev->priv = g_new0(struct dev_priv, 1);
dev->priv->state = AUDIO_STATE_DISCONNECTED;
- DBG("%s", device_get_path(dev->btd_dev));
-
if (sink_callback_id == 0)
sink_callback_id = sink_add_state_cb(device_sink_cb, NULL);
@@ -341,6 +341,8 @@ gboolean audio_device_is_active(struct audio_device *dev,
void audio_device_unregister(struct audio_device *device)
{
+ DBG("%s", device_get_path(device->btd_dev));
+
if (device->hs_preauth_id) {
g_source_remove(device->hs_preauth_id);
device->hs_preauth_id = 0;
--
1.7.11.7
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH BlueZ 05/11] input: Remove Input interface
2012-11-26 13:09 [PATCH BlueZ 01/11] audio: Remove AudioSink interface Luiz Augusto von Dentz
` (2 preceding siblings ...)
2012-11-26 13:09 ` [PATCH BlueZ 04/11] audio: Remove Control.Connect and Control.Disconnect Luiz Augusto von Dentz
@ 2012-11-26 13:09 ` Luiz Augusto von Dentz
2012-11-26 13:09 ` [PATCH BlueZ 06/11] network: Make use of D-Bus Properties interface Luiz Augusto von Dentz
` (6 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Luiz Augusto von Dentz @ 2012-11-26 13:09 UTC (permalink / raw)
To: linux-bluetooth
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This interface is no longer needed as Device interface can now connect
the profiles.
---
doc/input-api.txt | 44 -----------------------
profiles/input/device.c | 93 ++++---------------------------------------------
2 files changed, 6 insertions(+), 131 deletions(-)
delete mode 100644 doc/input-api.txt
diff --git a/doc/input-api.txt b/doc/input-api.txt
deleted file mode 100644
index 7c3a4b2..0000000
--- a/doc/input-api.txt
+++ /dev/null
@@ -1,44 +0,0 @@
-BlueZ D-Bus Input API description
-*********************************
-
-Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org>
-
-
-Input hierarchy
-===============
-
-Service org.bluez
-Interface org.bluez.Input
-Object path [variable prefix]/{hci0,hci1,...}/dev_XX_XX_XX_XX_XX_XX
-
-Methods void Connect()
-
- Connect to the input device.
-
- Possible errors: org.bluez.Error.AlreadyConnected
- org.bluez.Error.ConnectionAttemptFailed
-
- void Disconnect()
-
- Disconnect from the input device.
-
- To abort a connection attempt in case of errors or
- timeouts in the client it is fine to call this method.
-
- Possible errors: org.bluez.Error.Failed
-
- dict GetProperties()
-
- Returns all properties for the interface. See the
- properties section for available properties.
-
- Possible Errors: org.bluez.Error.InvalidArguments
-
-Signals PropertyChanged(string name, variant value)
-
- This signal indicates a changed value of the given
- property.
-
-Properties boolean Connected [readonly]
-
- Indicates if the device is connected.
diff --git a/profiles/input/device.c b/profiles/input/device.c
index 108be39..2871cc3 100644
--- a/profiles/input/device.c
+++ b/profiles/input/device.c
@@ -680,26 +680,6 @@ int input_device_connect(struct btd_device *dev, struct btd_profile *profile,
return dev_connect(idev);
}
-static DBusMessage *local_connect(DBusConnection *conn, DBusMessage *msg,
- void *data)
-{
- struct input_device *idev = data;
-
- if (idev->pending)
- return btd_error_in_progress(msg);
-
- if (is_connected(idev))
- return btd_error_already_connected(msg);
-
- idev->pending = g_new0(struct pending_connect, 1);
- idev->pending->local = true;
- idev->pending->msg = dbus_message_ref(msg);
-
- dev_connect(idev);
-
- return NULL;
-}
-
int input_device_disconnect(struct btd_device *dev, struct btd_profile *profile,
btd_profile_cb cb)
{
@@ -720,57 +700,6 @@ int input_device_disconnect(struct btd_device *dev, struct btd_profile *profile,
return 0;
}
-static DBusMessage *local_disconnect(DBusConnection *conn,
- DBusMessage *msg, void *data)
-{
- struct input_device *idev = data;
- int err;
-
- err = connection_disconnect(idev, 0);
- if (err < 0)
- return btd_error_failed(msg, strerror(-err));
-
- return g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
-}
-
-static void device_unregister(void *data)
-{
- struct input_device *idev = data;
-
- DBG("Unregistered interface %s on path %s", INPUT_DEVICE_INTERFACE,
- idev->path);
-
- devices = g_slist_remove(devices, idev);
- input_device_free(idev);
-}
-
-
-
-static gboolean input_device_property_get_connected(
- const GDBusPropertyTable *property,
- DBusMessageIter *iter, void *data)
-{
- struct input_device *idev = data;
- dbus_bool_t connected = is_connected(idev);
-
- dbus_message_iter_append_basic(iter, DBUS_TYPE_BOOLEAN, &connected);
-
- return TRUE;
-}
-
-static const GDBusMethodTable device_methods[] = {
- { GDBUS_ASYNC_METHOD("Connect",
- NULL, NULL, local_connect) },
- { GDBUS_METHOD("Disconnect",
- NULL, NULL, local_disconnect) },
- { }
-};
-
-static const GDBusPropertyTable device_properties[] = {
- { "Connected", "b", input_device_property_get_connected },
- { }
-};
-
static struct input_device *input_device_new(struct btd_device *device,
const char *path, const uint32_t handle,
gboolean disable_sdp)
@@ -791,20 +720,6 @@ static struct input_device *input_device_new(struct btd_device *device,
if (strlen(name) > 0)
idev->name = g_strdup(name);
- if (g_dbus_register_interface(btd_get_dbus_connection(),
- idev->path, INPUT_DEVICE_INTERFACE,
- device_methods, NULL,
- device_properties, idev,
- device_unregister) == FALSE) {
- error("Failed to register interface %s on path %s",
- INPUT_DEVICE_INTERFACE, path);
- input_device_free(idev);
- return NULL;
- }
-
- DBG("Registered interface %s on path %s",
- INPUT_DEVICE_INTERFACE, idev->path);
-
return idev;
}
@@ -823,6 +738,8 @@ int input_device_register(struct btd_device *device,
{
struct input_device *idev;
+ DBG("%s", path);
+
idev = find_device_by_path(devices, path);
if (idev)
return -EEXIST;
@@ -859,6 +776,8 @@ int input_device_unregister(const char *path, const char *uuid)
{
struct input_device *idev;
+ DBG("%s", path);
+
idev = find_device_by_path(devices, path);
if (idev == NULL)
return -EINVAL;
@@ -868,8 +787,8 @@ int input_device_unregister(const char *path, const char *uuid)
return -EBUSY;
}
- g_dbus_unregister_interface(btd_get_dbus_connection(),
- path, INPUT_DEVICE_INTERFACE);
+ devices = g_slist_remove(devices, idev);
+ input_device_free(idev);
return 0;
}
--
1.7.11.7
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH BlueZ 06/11] network: Make use of D-Bus Properties interface
2012-11-26 13:09 [PATCH BlueZ 01/11] audio: Remove AudioSink interface Luiz Augusto von Dentz
` (3 preceding siblings ...)
2012-11-26 13:09 ` [PATCH BlueZ 05/11] input: Remove Input interface Luiz Augusto von Dentz
@ 2012-11-26 13:09 ` Luiz Augusto von Dentz
2012-11-26 13:09 ` [PATCH BlueZ 07/11] network: Remove Network.Connect and Network.Disconnect Luiz Augusto von Dentz
` (5 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Luiz Augusto von Dentz @ 2012-11-26 13:09 UTC (permalink / raw)
To: linux-bluetooth
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
---
profiles/network/connection.c | 133 +++++++++++++++++++++---------------------
1 file changed, 68 insertions(+), 65 deletions(-)
diff --git a/profiles/network/connection.c b/profiles/network/connection.c
index 57451b9..d9961f8 100644
--- a/profiles/network/connection.c
+++ b/profiles/network/connection.c
@@ -113,19 +113,15 @@ static gboolean bnep_watchdog_cb(GIOChannel *chan, GIOCondition cond,
gpointer data)
{
struct network_conn *nc = data;
- gboolean connected = FALSE;
- const char *property = "";
+ DBusConnection *conn = btd_get_dbus_connection();
const char *path = device_get_path(nc->peer->device);
- emit_property_changed(path,
- NETWORK_PEER_INTERFACE, "Connected",
- DBUS_TYPE_BOOLEAN, &connected);
- emit_property_changed(path,
- NETWORK_PEER_INTERFACE, "Interface",
- DBUS_TYPE_STRING, &property);
- emit_property_changed(path,
- NETWORK_PEER_INTERFACE, "UUID",
- DBUS_TYPE_STRING, &property);
+ g_dbus_emit_property_changed(conn, path,
+ NETWORK_PEER_INTERFACE, "Connected");
+ g_dbus_emit_property_changed(conn, path,
+ NETWORK_PEER_INTERFACE, "Interface");
+ g_dbus_emit_property_changed(conn, path,
+ NETWORK_PEER_INTERFACE, "UUID");
device_remove_disconnect_watch(nc->peer->device, nc->dc_id);
nc->dc_id = 0;
if (nc->watch) {
@@ -200,9 +196,8 @@ static gboolean bnep_setup_cb(GIOChannel *chan, GIOCondition cond,
char pkt[BNEP_MTU];
ssize_t r;
int sk;
- const char *pdev, *uuid;
- gboolean connected;
const char *path;
+ DBusConnection *conn;
if (cond & G_IO_NVAL)
return FALSE;
@@ -265,24 +260,19 @@ static gboolean bnep_setup_cb(GIOChannel *chan, GIOCondition cond,
}
bnep_if_up(nc->dev);
- pdev = nc->dev;
- uuid = bnep_uuid(nc->id);
if (nc->cb)
- nc->cb(nc->peer->device, 0, pdev, nc->cb_data);
+ nc->cb(nc->peer->device, 0, nc->dev, nc->cb_data);
+ conn = btd_get_dbus_connection();
path = device_get_path(nc->peer->device);
- connected = TRUE;
- emit_property_changed(path,
- NETWORK_PEER_INTERFACE, "Connected",
- DBUS_TYPE_BOOLEAN, &connected);
- emit_property_changed(path,
- NETWORK_PEER_INTERFACE, "Interface",
- DBUS_TYPE_STRING, &pdev);
- emit_property_changed(path,
- NETWORK_PEER_INTERFACE, "UUID",
- DBUS_TYPE_STRING, &uuid);
+ g_dbus_emit_property_changed(conn, path,
+ NETWORK_PEER_INTERFACE, "Connected");
+ g_dbus_emit_property_changed(conn, path,
+ NETWORK_PEER_INTERFACE, "Interface");
+ g_dbus_emit_property_changed(conn, path,
+ NETWORK_PEER_INTERFACE, "UUID");
nc->state = CONNECTED;
nc->dc_id = device_add_disconnect_watch(nc->peer->device, disconnect_cb,
@@ -530,54 +520,69 @@ static DBusMessage *local_disconnect(DBusConnection *conn,
return btd_error_not_connected(msg);
}
-static DBusMessage *local_get_properties(DBusConnection *conn,
- DBusMessage *msg, void *data)
+static gboolean
+network_property_get_connected(const GDBusPropertyTable *property,
+ DBusMessageIter *iter, void *data)
{
struct network_peer *peer = data;
- struct network_conn *nc = NULL;
- DBusMessage *reply;
- DBusMessageIter iter;
- DBusMessageIter dict;
- dbus_bool_t connected;
- const char *property;
+ dbus_bool_t value = FALSE;
GSList *l;
- reply = dbus_message_new_method_return(msg);
- if (!reply)
- return NULL;
+ for (l = peer->connections; l; l = l->next) {
+ struct network_conn *tmp = l->data;
+
+ if (tmp->state == CONNECTED) {
+ value = TRUE;
+ break;
+ }
+ }
+
+ dbus_message_iter_append_basic(iter, DBUS_TYPE_BOOLEAN, &value);
- dbus_message_iter_init_append(reply, &iter);
+ return TRUE;
+}
- dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY,
- DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING
- DBUS_TYPE_STRING_AS_STRING DBUS_TYPE_VARIANT_AS_STRING
- DBUS_DICT_ENTRY_END_CHAR_AS_STRING, &dict);
+static gboolean
+network_property_get_interface(const GDBusPropertyTable *property,
+ DBusMessageIter *iter, void *data)
+{
+ struct network_peer *peer = data;
+ const char *value = "";
+ GSList *l;
- /* Connected */
for (l = peer->connections; l; l = l->next) {
struct network_conn *tmp = l->data;
- if (tmp->state != CONNECTED)
- continue;
-
- nc = tmp;
- break;
+ if (tmp->state == CONNECTED) {
+ value = tmp->dev;
+ break;
+ }
}
- connected = nc ? TRUE : FALSE;
- dict_append_entry(&dict, "Connected", DBUS_TYPE_BOOLEAN, &connected);
+ dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, &value);
- /* Interface */
- property = nc ? nc->dev : "";
- dict_append_entry(&dict, "Interface", DBUS_TYPE_STRING, &property);
+ return TRUE;
+}
- /* UUID */
- property = nc ? bnep_uuid(nc->id) : "";
- dict_append_entry(&dict, "UUID", DBUS_TYPE_STRING, &property);
+static gboolean network_property_get_uuid(const GDBusPropertyTable *property,
+ DBusMessageIter *iter, void *data)
+{
+ struct network_peer *peer = data;
+ const char *value = "";
+ GSList *l;
+
+ for (l = peer->connections; l; l = l->next) {
+ struct network_conn *tmp = l->data;
+
+ if (tmp->state == CONNECTED) {
+ value = bnep_uuid(tmp->id);
+ break;
+ }
+ }
- dbus_message_iter_close_container(&iter, &dict);
+ dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, &value);
- return reply;
+ return TRUE;
}
static void connection_free(void *data)
@@ -618,15 +623,13 @@ static const GDBusMethodTable connection_methods[] = {
local_connect) },
{ GDBUS_METHOD("Disconnect",
NULL, NULL, local_disconnect) },
- { GDBUS_METHOD("GetProperties",
- NULL, GDBUS_ARGS({ "properties", "a{sv}" }),
- local_get_properties) },
{ }
};
-static const GDBusSignalTable connection_signals[] = {
- { GDBUS_SIGNAL("PropertyChanged",
- GDBUS_ARGS({ "name", "s" }, { "value", "v" })) },
+static const GDBusPropertyTable connection_properties[] = {
+ { "Connected", "b", network_property_get_connected },
+ { "Interface", "s", network_property_get_interface },
+ { "UUID", "s", network_property_get_uuid },
{ }
};
@@ -659,7 +662,7 @@ static struct network_peer *create_peer(struct btd_device *device)
if (g_dbus_register_interface(btd_get_dbus_connection(), path,
NETWORK_PEER_INTERFACE,
connection_methods,
- connection_signals, NULL,
+ NULL, connection_properties,
peer, path_unregister) == FALSE) {
error("D-Bus failed to register %s interface",
NETWORK_PEER_INTERFACE);
--
1.7.11.7
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH BlueZ 07/11] network: Remove Network.Connect and Network.Disconnect
2012-11-26 13:09 [PATCH BlueZ 01/11] audio: Remove AudioSink interface Luiz Augusto von Dentz
` (4 preceding siblings ...)
2012-11-26 13:09 ` [PATCH BlueZ 06/11] network: Make use of D-Bus Properties interface Luiz Augusto von Dentz
@ 2012-11-26 13:09 ` Luiz Augusto von Dentz
2012-11-26 13:09 ` [PATCH BlueZ 08/11] network: Fix not responding to Device.ConnectProfile Luiz Augusto von Dentz
` (4 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Luiz Augusto von Dentz @ 2012-11-26 13:09 UTC (permalink / raw)
To: linux-bluetooth
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
These method are no longer necessary as Device interface has similar
functionality.
---
doc/network-api.txt | 36 -------------------
profiles/network/connection.c | 81 +------------------------------------------
2 files changed, 1 insertion(+), 116 deletions(-)
diff --git a/doc/network-api.txt b/doc/network-api.txt
index 4dd3e58..b640b9a 100644
--- a/doc/network-api.txt
+++ b/doc/network-api.txt
@@ -11,42 +11,6 @@ Service org.bluez
Interface org.bluez.Network
Object path [variable prefix]/{hci0,hci1,...}/dev_XX_XX_XX_XX_XX_XX
-Methods string Connect(string uuid)
-
- Connect to the network device and return the network
- interface name. Examples of the interface name are
- bnep0, bnep1 etc.
-
- uuid can be either one of "gn", "panu" or "nap" (case
- insensitive) or a traditional string representation of
- UUID or a hexadecimal number.
-
- The connection will be closed and network device
- released either upon calling Disconnect() or when
- the client disappears from the message bus.
-
- Possible errors: org.bluez.Error.AlreadyConnected
- org.bluez.Error.ConnectionAttemptFailed
-
- void Disconnect()
-
- Disconnect from the network device.
-
- To abort a connection attempt in case of errors or
- timeouts in the client it is fine to call this method.
-
- Possible errors: org.bluez.Error.Failed
-
- dict GetProperties()
-
- Returns all properties for the interface. See the
- properties section for available properties.
-
-Signals PropertyChanged(string name, variant value)
-
- This signal indicates a changed value of the given
- property.
-
Properties boolean Connected [readonly]
Indicates if the device is connected.
diff --git a/profiles/network/connection.c b/profiles/network/connection.c
index d9961f8..231164b 100644
--- a/profiles/network/connection.c
+++ b/profiles/network/connection.c
@@ -378,50 +378,6 @@ failed:
cancel_connection(nc, -EIO);
}
-static void local_connect_cb(struct btd_device *device, int err,
- const char *pdev, void *data)
-{
- DBusMessage *msg = data;
- DBusMessage *reply;
-
- if (err < 0) {
- reply = btd_error_failed(msg, strerror(-err));
- g_dbus_send_message(btd_get_dbus_connection(), reply);
- dbus_message_unref(msg);
- return;
- }
-
- g_dbus_send_reply(btd_get_dbus_connection(), msg,
- DBUS_TYPE_STRING, &pdev,
- DBUS_TYPE_INVALID);
-
- dbus_message_unref(msg);
-}
-
-static DBusMessage *local_connect(DBusConnection *conn,
- DBusMessage *msg, void *data)
-{
- struct network_peer *peer = data;
- const char *svc;
- uint16_t id;
- int err;
-
- if (dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &svc,
- DBUS_TYPE_INVALID) == FALSE)
- return btd_error_invalid_args(msg);
-
- id = bnep_service_id(svc);
-
- err = connection_connect(peer->device, id, dbus_message_get_sender(msg),
- local_connect_cb, msg);
- if (err < 0)
- return btd_error_failed(msg, strerror(-err));
-
- dbus_message_ref(msg);
-
- return NULL;
-}
-
/* Connect and initiate BNEP session */
int connection_connect(struct btd_device *device, uint16_t id,
const char *owner,
@@ -496,30 +452,6 @@ int connection_disconnect(struct btd_device *device, uint16_t id,
return 0;
}
-static DBusMessage *local_disconnect(DBusConnection *conn,
- DBusMessage *msg, void *data)
-{
- struct network_peer *peer = data;
- const char *caller = dbus_message_get_sender(msg);
- GSList *l;
-
- for (l = peer->connections; l; l = l->next) {
- struct network_conn *nc = l->data;
- int err;
-
- if (nc->state == DISCONNECTED)
- continue;
-
- err = connection_disconnect(peer->device, nc->id, caller);
- if (err < 0)
- return btd_error_failed(msg, strerror(-err));
-
- return g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
- }
-
- return btd_error_not_connected(msg);
-}
-
static gboolean
network_property_get_connected(const GDBusPropertyTable *property,
DBusMessageIter *iter, void *data)
@@ -616,16 +548,6 @@ static void path_unregister(void *data)
peer_free(peer);
}
-static const GDBusMethodTable connection_methods[] = {
- { GDBUS_ASYNC_METHOD("Connect",
- GDBUS_ARGS({"uuid", "s"}),
- GDBUS_ARGS({"interface", "s"}),
- local_connect) },
- { GDBUS_METHOD("Disconnect",
- NULL, NULL, local_disconnect) },
- { }
-};
-
static const GDBusPropertyTable connection_properties[] = {
{ "Connected", "b", network_property_get_connected },
{ "Interface", "s", network_property_get_interface },
@@ -661,8 +583,7 @@ static struct network_peer *create_peer(struct btd_device *device)
if (g_dbus_register_interface(btd_get_dbus_connection(), path,
NETWORK_PEER_INTERFACE,
- connection_methods,
- NULL, connection_properties,
+ NULL, NULL, connection_properties,
peer, path_unregister) == FALSE) {
error("D-Bus failed to register %s interface",
NETWORK_PEER_INTERFACE);
--
1.7.11.7
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH BlueZ 08/11] network: Fix not responding to Device.ConnectProfile
2012-11-26 13:09 [PATCH BlueZ 01/11] audio: Remove AudioSink interface Luiz Augusto von Dentz
` (5 preceding siblings ...)
2012-11-26 13:09 ` [PATCH BlueZ 07/11] network: Remove Network.Connect and Network.Disconnect Luiz Augusto von Dentz
@ 2012-11-26 13:09 ` Luiz Augusto von Dentz
2012-11-26 13:09 ` [PATCH BlueZ 09/11] network: Fix trying to register NetworkServer interface multiple times Luiz Augusto von Dentz
` (3 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Luiz Augusto von Dentz @ 2012-11-26 13:09 UTC (permalink / raw)
To: linux-bluetooth
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
The callback passed to connection_connect has to be used to respond when
the connection completes.
---
profiles/network/connection.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/profiles/network/connection.c b/profiles/network/connection.c
index 231164b..912e5b4 100644
--- a/profiles/network/connection.c
+++ b/profiles/network/connection.c
@@ -417,6 +417,8 @@ int connection_connect(struct btd_device *device, uint16_t id,
nc->state = CONNECTING;
nc->owner = g_strdup(owner);
+ nc->cb = cb;
+ nc->cb_data = data;
if (owner)
nc->watch = g_dbus_add_disconnect_watch(
--
1.7.11.7
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH BlueZ 09/11] network: Fix trying to register NetworkServer interface multiple times
2012-11-26 13:09 [PATCH BlueZ 01/11] audio: Remove AudioSink interface Luiz Augusto von Dentz
` (6 preceding siblings ...)
2012-11-26 13:09 ` [PATCH BlueZ 08/11] network: Fix not responding to Device.ConnectProfile Luiz Augusto von Dentz
@ 2012-11-26 13:09 ` Luiz Augusto von Dentz
2012-11-26 13:09 ` [PATCH BlueZ 10/11] network: Fix always attempting to connect to PANU service Luiz Augusto von Dentz
` (2 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Luiz Augusto von Dentz @ 2012-11-26 13:09 UTC (permalink / raw)
To: linux-bluetooth
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This also removes the limitation of only accepting nap as UUID, now all
PAN UUID are supported including their friendly names.
---
profiles/network/server.c | 64 ++++++++++++++++++++++++++++++++---------------
1 file changed, 44 insertions(+), 20 deletions(-)
diff --git a/profiles/network/server.c b/profiles/network/server.c
index 1a485ca..2c3c72e 100644
--- a/profiles/network/server.c
+++ b/profiles/network/server.c
@@ -72,7 +72,6 @@ struct network_adapter {
/* Main server structure */
struct network_server {
bdaddr_t src; /* Bluetooth Local Address */
- char *iface; /* DBus interface */
char *name; /* Server service name */
char *bridge; /* Bridge name */
uint32_t record_id; /* Service record id */
@@ -110,6 +109,22 @@ static struct network_server *find_server(GSList *list, uint16_t id)
return NULL;
}
+static struct network_server *find_server_by_uuid(GSList *list,
+ const char *uuid)
+{
+ for (; list; list = list->next) {
+ struct network_server *ns = list->data;
+
+ if (strcasecmp(uuid, bnep_uuid(ns->id)) == 0)
+ return ns;
+
+ if (strcasecmp(uuid, bnep_name(ns->id)) == 0)
+ return ns;
+ }
+
+ return NULL;
+}
+
static sdp_record_t *server_record_new(const char *name, uint16_t id)
{
sdp_list_t *svclass, *pfseq, *apseq, *root, *aproto;
@@ -624,7 +639,8 @@ static void server_disconnect(DBusConnection *conn, void *user_data)
static DBusMessage *register_server(DBusConnection *conn,
DBusMessage *msg, void *data)
{
- struct network_server *ns = data;
+ struct network_adapter *na = data;
+ struct network_server *ns;
DBusMessage *reply;
const char *uuid, *bridge;
@@ -632,7 +648,8 @@ static DBusMessage *register_server(DBusConnection *conn,
DBUS_TYPE_STRING, &bridge, DBUS_TYPE_INVALID))
return btd_error_invalid_args(msg);
- if (g_strcmp0(uuid, "nap"))
+ ns = find_server_by_uuid(na->servers, uuid);
+ if (ns == NULL)
return btd_error_failed(msg, "Invalid UUID");
if (ns->record_id)
@@ -693,8 +710,10 @@ static void adapter_free(struct network_adapter *na)
g_free(na);
}
-static void server_free(struct network_server *ns)
+static void server_free(void *data)
{
+ struct network_server *ns = data;
+
if (!ns)
return;
@@ -703,7 +722,6 @@ static void server_free(struct network_server *ns)
if (ns->record_id)
remove_record_from_server(ns->record_id);
- g_free(ns->iface);
g_free(ns->name);
g_free(ns->bridge);
@@ -712,17 +730,12 @@ static void server_free(struct network_server *ns)
static void path_unregister(void *data)
{
- struct network_server *ns = data;
- struct network_adapter *na = ns->na;
+ struct network_adapter *na = data;
DBG("Unregistered interface %s on path %s",
- ns->iface, adapter_get_path(na->adapter));
-
- na->servers = g_slist_remove(na->servers, ns);
- server_free(ns);
+ NETWORK_SERVER_INTERFACE, adapter_get_path(na->adapter));
- if (na->servers)
- return;
+ g_slist_free_full(na->servers, server_free);
adapters = g_slist_remove(adapters, na);
adapter_free(na);
@@ -786,29 +799,33 @@ int server_register(struct btd_adapter *adapter, uint16_t id)
ns = g_new0(struct network_server, 1);
- ns->iface = g_strdup(NETWORK_SERVER_INTERFACE);
ns->name = g_strdup("Network service");
path = adapter_get_path(adapter);
+ if (g_slist_length(na->servers) > 0)
+ goto done;
+
if (!g_dbus_register_interface(btd_get_dbus_connection(),
- path, ns->iface,
+ path, NETWORK_SERVER_INTERFACE,
server_methods, NULL, NULL,
- ns, path_unregister)) {
+ na, path_unregister)) {
error("D-Bus failed to register %s interface",
- ns->iface);
+ NETWORK_SERVER_INTERFACE);
server_free(ns);
return -1;
}
+ DBG("Registered interface %s on path %s", NETWORK_SERVER_INTERFACE,
+ path);
+
+done:
bacpy(&ns->src, adapter_get_address(adapter));
ns->id = id;
ns->na = na;
ns->record_id = 0;
na->servers = g_slist_append(na->servers, ns);
- DBG("Registered interface %s on path %s", ns->iface, path);
-
return 0;
}
@@ -825,8 +842,15 @@ int server_unregister(struct btd_adapter *adapter, uint16_t id)
if (!ns)
return -EINVAL;
+ na->servers = g_slist_remove(na->servers, ns);
+ server_free(ns);
+
+ if (g_slist_length(na->servers) > 0)
+ return 0;
+
g_dbus_unregister_interface(btd_get_dbus_connection(),
- adapter_get_path(adapter), ns->iface);
+ adapter_get_path(adapter),
+ NETWORK_SERVER_INTERFACE);
return 0;
}
--
1.7.11.7
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH BlueZ 10/11] network: Fix always attempting to connect to PANU service
2012-11-26 13:09 [PATCH BlueZ 01/11] audio: Remove AudioSink interface Luiz Augusto von Dentz
` (7 preceding siblings ...)
2012-11-26 13:09 ` [PATCH BlueZ 09/11] network: Fix trying to register NetworkServer interface multiple times Luiz Augusto von Dentz
@ 2012-11-26 13:09 ` Luiz Augusto von Dentz
2012-11-26 13:09 ` [PATCH BlueZ 11/11] network: Fix invalid read on exit Luiz Augusto von Dentz
2012-11-26 14:43 ` [PATCH BlueZ 01/11] audio: Remove AudioSink interface Johan Hedberg
10 siblings, 0 replies; 12+ messages in thread
From: Luiz Augusto von Dentz @ 2012-11-26 13:09 UTC (permalink / raw)
To: linux-bluetooth
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
connection_connect takes the remote role as parameter not the local one.
---
profiles/network/manager.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/profiles/network/manager.c b/profiles/network/manager.c
index 06abe1b..06ef9fc 100644
--- a/profiles/network/manager.c
+++ b/profiles/network/manager.c
@@ -100,8 +100,7 @@ static int connect_profile(struct btd_device *dev, struct btd_profile *profile,
req->profile = profile;
req->cb = cb;
- err = connection_connect(dev, BNEP_SVC_PANU, NULL, connect_profile_cb,
- req);
+ err = connection_connect(dev, id, NULL, connect_profile_cb, req);
if (err < 0) {
g_free(req);
return err;
--
1.7.11.7
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH BlueZ 11/11] network: Fix invalid read on exit
2012-11-26 13:09 [PATCH BlueZ 01/11] audio: Remove AudioSink interface Luiz Augusto von Dentz
` (8 preceding siblings ...)
2012-11-26 13:09 ` [PATCH BlueZ 10/11] network: Fix always attempting to connect to PANU service Luiz Augusto von Dentz
@ 2012-11-26 13:09 ` Luiz Augusto von Dentz
2012-11-26 14:43 ` [PATCH BlueZ 01/11] audio: Remove AudioSink interface Johan Hedberg
10 siblings, 0 replies; 12+ messages in thread
From: Luiz Augusto von Dentz @ 2012-11-26 13:09 UTC (permalink / raw)
To: linux-bluetooth
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Invalid read of size 1
at 0x4A09D91: strcmp (mc_replace_strmem.c:729)
by 0x4C6C768: g_str_equal (in /usr/lib64/libglib-2.0.so.0.3200.4)
by 0x1446B7: connection_disconnect (connection.c:451)
by 0x141DEA: disconnect_profile (manager.c:120)
by 0x4C96C5C: g_slist_foreach (in /usr/lib64/libglib-2.0.so.0.3200.4)
by 0x182B2D: device_remove (device.c:2034)
by 0x178809: adapter_remove (adapter.c:2902)
by 0x173902: manager_cleanup (manager.c:256)
by 0x1217B9: main (main.c:550)
Address 0x0 is not stack'd, malloc'd or (recently) free'd
In addition remove owner since it is no longer possible to track the
owner as this is done in the core.
---
profiles/network/connection.c | 26 --------------------------
1 file changed, 26 deletions(-)
diff --git a/profiles/network/connection.c b/profiles/network/connection.c
index 912e5b4..a7e45e6 100644
--- a/profiles/network/connection.c
+++ b/profiles/network/connection.c
@@ -70,8 +70,6 @@ struct network_conn {
uint16_t id; /* Role: Service Class Identifier */
conn_state state;
GIOChannel *io;
- char *owner; /* Connection initiator D-Bus client */
- guint watch; /* Disconnect watch */
guint dc_id;
struct network_peer *peer;
guint attempt_cnt;
@@ -124,10 +122,6 @@ static gboolean bnep_watchdog_cb(GIOChannel *chan, GIOCondition cond,
NETWORK_PEER_INTERFACE, "UUID");
device_remove_disconnect_watch(nc->peer->device, nc->dc_id);
nc->dc_id = 0;
- if (nc->watch) {
- g_dbus_remove_watch(nc->watch);
- nc->watch = 0;
- }
info("%s disconnected", nc->dev);
@@ -146,11 +140,6 @@ static void cancel_connection(struct network_conn *nc, int err)
nc->timeout_source = 0;
}
- if (nc->watch) {
- g_dbus_remove_watch(nc->watch);
- nc->watch = 0;
- }
-
if (nc->cb)
nc->cb(nc->peer->device, err, NULL, nc->cb_data);
@@ -170,11 +159,6 @@ static void connection_destroy(DBusConnection *conn, void *user_data)
bnep_kill_connection(device_get_address(nc->peer->device));
} else if (nc->io)
cancel_connection(nc, -EIO);
-
- if (nc->owner) {
- g_free(nc->owner);
- nc->owner = NULL;
- }
}
static void disconnect_cb(struct btd_device *device, gboolean removal,
@@ -416,16 +400,9 @@ int connection_connect(struct btd_device *device, uint16_t id,
return -EIO;
nc->state = CONNECTING;
- nc->owner = g_strdup(owner);
nc->cb = cb;
nc->cb_data = data;
- if (owner)
- nc->watch = g_dbus_add_disconnect_watch(
- btd_get_dbus_connection(),
- owner, connection_destroy,
- nc, NULL);
-
return 0;
}
@@ -446,9 +423,6 @@ int connection_disconnect(struct btd_device *device, uint16_t id,
if (nc->state == DISCONNECTED)
return 0;
- if (!g_str_equal(nc->owner, caller))
- return -EPERM;
-
connection_destroy(NULL, nc);
return 0;
--
1.7.11.7
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH BlueZ 01/11] audio: Remove AudioSink interface
2012-11-26 13:09 [PATCH BlueZ 01/11] audio: Remove AudioSink interface Luiz Augusto von Dentz
` (9 preceding siblings ...)
2012-11-26 13:09 ` [PATCH BlueZ 11/11] network: Fix invalid read on exit Luiz Augusto von Dentz
@ 2012-11-26 14:43 ` Johan Hedberg
10 siblings, 0 replies; 12+ messages in thread
From: Johan Hedberg @ 2012-11-26 14:43 UTC (permalink / raw)
To: Luiz Augusto von Dentz; +Cc: linux-bluetooth
Hi Luiz,
On Mon, Nov 26, 2012, Luiz Augusto von Dentz wrote:
> This interface is no longer needed as Device interface can now connect
> the profiles and the state can be tracked using MediaTransport interface.
> ---
> doc/audio-api.txt | 53 -------------------
> profiles/audio/sink.c | 141 ++------------------------------------------------
> 2 files changed, 3 insertions(+), 191 deletions(-)
All patches in this set have been applied. Thanks.
Johan
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2012-11-26 14:43 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-11-26 13:09 [PATCH BlueZ 01/11] audio: Remove AudioSink interface Luiz Augusto von Dentz
2012-11-26 13:09 ` [PATCH BlueZ 02/11] audio: Remove AudioSource interface Luiz Augusto von Dentz
2012-11-26 13:09 ` [PATCH BlueZ 03/11] audio: Remove Audio interface Luiz Augusto von Dentz
2012-11-26 13:09 ` [PATCH BlueZ 04/11] audio: Remove Control.Connect and Control.Disconnect Luiz Augusto von Dentz
2012-11-26 13:09 ` [PATCH BlueZ 05/11] input: Remove Input interface Luiz Augusto von Dentz
2012-11-26 13:09 ` [PATCH BlueZ 06/11] network: Make use of D-Bus Properties interface Luiz Augusto von Dentz
2012-11-26 13:09 ` [PATCH BlueZ 07/11] network: Remove Network.Connect and Network.Disconnect Luiz Augusto von Dentz
2012-11-26 13:09 ` [PATCH BlueZ 08/11] network: Fix not responding to Device.ConnectProfile Luiz Augusto von Dentz
2012-11-26 13:09 ` [PATCH BlueZ 09/11] network: Fix trying to register NetworkServer interface multiple times Luiz Augusto von Dentz
2012-11-26 13:09 ` [PATCH BlueZ 10/11] network: Fix always attempting to connect to PANU service Luiz Augusto von Dentz
2012-11-26 13:09 ` [PATCH BlueZ 11/11] network: Fix invalid read on exit Luiz Augusto von Dentz
2012-11-26 14:43 ` [PATCH BlueZ 01/11] audio: Remove AudioSink interface Johan Hedberg
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).