All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH BlueZ 1/5] core: Fix registering '/org/bluez' path before '/'
@ 2012-11-15 14:05 Luiz Augusto von Dentz
  2012-11-15 14:05 ` [PATCH BlueZ 2/5] core: Make exit sequence consistent with init Luiz Augusto von Dentz
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Luiz Augusto von Dentz @ 2012-11-15 14:05 UTC (permalink / raw)
  To: linux-bluetooth

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

This cause problems with ObjectManager being exported in both paths
---
 src/manager.c | 13 ++++++++-----
 src/manager.h |  2 +-
 2 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/src/manager.c b/src/manager.c
index 07f9482..3088dd9 100644
--- a/src/manager.c
+++ b/src/manager.c
@@ -181,14 +181,17 @@ static const GDBusPropertyTable manager_properties[] = {
 	{ }
 };
 
-dbus_bool_t manager_init(const char *path)
+bool manager_init(const char *path)
 {
-	btd_profile_init();
-
-	return g_dbus_register_interface(btd_get_dbus_connection(),
+	if (!g_dbus_register_interface(btd_get_dbus_connection(),
 					"/", MANAGER_INTERFACE,
 					manager_methods, manager_signals,
-					manager_properties, NULL, NULL);
+					manager_properties, NULL, NULL))
+		return false;
+
+	btd_profile_init();
+
+	return true;
 }
 
 static void manager_set_default_adapter(int id)
diff --git a/src/manager.h b/src/manager.h
index 0bb8b2c..4d094b6 100644
--- a/src/manager.h
+++ b/src/manager.h
@@ -29,7 +29,7 @@
 
 typedef void (*adapter_cb) (struct btd_adapter *adapter, gpointer user_data);
 
-dbus_bool_t manager_init(const char *path);
+bool manager_init(const char *path);
 void manager_cleanup(const char *path);
 
 const char *manager_get_base_path(void);
-- 
1.7.11.7


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

* [PATCH BlueZ 2/5] core: Make exit sequence consistent with init
  2012-11-15 14:05 [PATCH BlueZ 1/5] core: Fix registering '/org/bluez' path before '/' Luiz Augusto von Dentz
@ 2012-11-15 14:05 ` Luiz Augusto von Dentz
  2012-11-15 14:15   ` Johan Hedberg
  2012-11-15 14:05 ` [PATCH BlueZ 3/5] gdbus: Fix having multiple path exporting ObjectManager Luiz Augusto von Dentz
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 6+ messages in thread
From: Luiz Augusto von Dentz @ 2012-11-15 14:05 UTC (permalink / raw)
  To: linux-bluetooth

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

manager_cleanup should be called after plugin_cleanup on exit as
manager_init is called before plugin_init on the init sequence.
---
 src/main.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/main.c b/src/main.c
index 9ea12df..414849a 100644
--- a/src/main.c
+++ b/src/main.c
@@ -545,12 +545,12 @@ int main(int argc, char *argv[])
 
 	g_source_remove(signal);
 
+	plugin_cleanup();
+
 	manager_cleanup("/");
 
 	rfkill_exit();
 
-	plugin_cleanup();
-
 	stop_sdp_server();
 
 	g_main_loop_unref(event_loop);
-- 
1.7.11.7


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

* [PATCH BlueZ 3/5] gdbus: Fix having multiple path exporting ObjectManager
  2012-11-15 14:05 [PATCH BlueZ 1/5] core: Fix registering '/org/bluez' path before '/' Luiz Augusto von Dentz
  2012-11-15 14:05 ` [PATCH BlueZ 2/5] core: Make exit sequence consistent with init Luiz Augusto von Dentz
@ 2012-11-15 14:05 ` Luiz Augusto von Dentz
  2012-11-15 14:05 ` [PATCH BlueZ 4/5] gdbus: Automatically register '/' path Luiz Augusto von Dentz
  2012-11-15 14:05 ` [PATCH BlueZ 5/5] core: Make use of g_dbus_disconnect Luiz Augusto von Dentz
  3 siblings, 0 replies; 6+ messages in thread
From: Luiz Augusto von Dentz @ 2012-11-15 14:05 UTC (permalink / raw)
  To: linux-bluetooth

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

ObjectManager should only be available on the root path so if the
current is a child of the object being registered the root should be
changed.
---
 gdbus/object.c | 35 ++++++++++++++++++++++-------------
 1 file changed, 22 insertions(+), 13 deletions(-)

diff --git a/gdbus/object.c b/gdbus/object.c
index 214fd84..1f0ea39 100644
--- a/gdbus/object.c
+++ b/gdbus/object.c
@@ -84,6 +84,8 @@ struct property_data {
 	DBusMessage *message;
 };
 
+static struct generic_data *root = NULL;
+
 static gboolean process_changes(gpointer user_data);
 static void process_properties_from_interface(struct generic_data *data,
 						struct interface_data *iface);
@@ -574,11 +576,7 @@ static void emit_interfaces_added(struct generic_data *data)
 	if (parent == NULL)
 		return;
 
-	/* Find root data */
-	while (parent->parent)
-		parent = parent->parent;
-
-	signal = dbus_message_new_signal(parent->path,
+	signal = dbus_message_new_signal(root->path,
 					DBUS_INTERFACE_OBJECT_MANAGER,
 					"InterfacesAdded");
 	if (signal == NULL)
@@ -948,11 +946,7 @@ static void emit_interfaces_removed(struct generic_data *data)
 	if (parent == NULL)
 		return;
 
-	/* Find root data */
-	while (parent->parent)
-		parent = parent->parent;
-
-	signal = dbus_message_new_signal(parent->path,
+	signal = dbus_message_new_signal(root->path,
 					DBUS_INTERFACE_OBJECT_MANAGER,
 					"InterfacesRemoved");
 	if (signal == NULL)
@@ -1008,6 +1002,9 @@ static void generic_unregister(DBusConnection *connection, void *user_data)
 	g_slist_foreach(data->objects, reset_parent, data->parent);
 	g_slist_free(data->objects);
 
+	if (root == data)
+		root = NULL;
+
 	dbus_connection_unref(data->conn);
 	g_free(data->introspect);
 	g_free(data->path);
@@ -1175,6 +1172,20 @@ static void add_interface(struct generic_data *data,
 	data->process_id = g_idle_add(process_changes, data);
 }
 
+static void set_root(struct generic_data *data)
+{
+	if (root != NULL) {
+		data->objects = g_slist_prepend(data->objects, root);
+		root->parent = data;
+		remove_interface(root, DBUS_INTERFACE_OBJECT_MANAGER);
+	}
+
+	add_interface(data, DBUS_INTERFACE_OBJECT_MANAGER,
+					manager_methods, manager_signals,
+					NULL, data, NULL);
+	root = data;
+}
+
 static struct generic_data *object_path_ref(DBusConnection *connection,
 							const char *path)
 {
@@ -1209,9 +1220,7 @@ static struct generic_data *object_path_ref(DBusConnection *connection,
 
 	/* Only root path export ObjectManager interface */
 	if (data->parent == NULL)
-		add_interface(data, DBUS_INTERFACE_OBJECT_MANAGER,
-					manager_methods, manager_signals,
-					NULL, data, NULL);
+		set_root(data);
 
 	add_interface(data, DBUS_INTERFACE_PROPERTIES, properties_methods,
 					properties_signals, NULL, data, NULL);
-- 
1.7.11.7


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

* [PATCH BlueZ 4/5] gdbus: Automatically register  '/' path
  2012-11-15 14:05 [PATCH BlueZ 1/5] core: Fix registering '/org/bluez' path before '/' Luiz Augusto von Dentz
  2012-11-15 14:05 ` [PATCH BlueZ 2/5] core: Make exit sequence consistent with init Luiz Augusto von Dentz
  2012-11-15 14:05 ` [PATCH BlueZ 3/5] gdbus: Fix having multiple path exporting ObjectManager Luiz Augusto von Dentz
@ 2012-11-15 14:05 ` Luiz Augusto von Dentz
  2012-11-15 14:05 ` [PATCH BlueZ 5/5] core: Make use of g_dbus_disconnect Luiz Augusto von Dentz
  3 siblings, 0 replies; 6+ messages in thread
From: Luiz Augusto von Dentz @ 2012-11-15 14:05 UTC (permalink / raw)
  To: linux-bluetooth

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

This makes g_dbus_setup_bus to automatically register '/' path so
user application that don't export any interface on '/' will have it
registered for ObjectManager.

Note that it is now required to call g_dbus_disconnect before exit.
---
 gdbus/gdbus.h    |  1 +
 gdbus/mainloop.c | 21 +++++++++++++++++----
 gdbus/object.c   |  2 +-
 3 files changed, 19 insertions(+), 5 deletions(-)

diff --git a/gdbus/gdbus.h b/gdbus/gdbus.h
index ba49621..3fbe3bc 100644
--- a/gdbus/gdbus.h
+++ b/gdbus/gdbus.h
@@ -53,6 +53,7 @@ DBusConnection *g_dbus_setup_bus(DBusBusType type, const char *name,
 
 DBusConnection *g_dbus_setup_private(DBusBusType type, const char *name,
 							DBusError *error);
+void g_dbus_disconnect(DBusConnection *connection);
 
 gboolean g_dbus_request_name(DBusConnection *connection, const char *name,
 							DBusError *error);
diff --git a/gdbus/mainloop.c b/gdbus/mainloop.c
index 099b67f..acea308 100644
--- a/gdbus/mainloop.c
+++ b/gdbus/mainloop.c
@@ -301,12 +301,25 @@ DBusConnection *g_dbus_setup_bus(DBusBusType type, const char *name,
 	if (conn == NULL)
 		return NULL;
 
-	if (setup_bus(conn, name, error) == FALSE) {
-		dbus_connection_unref(conn);
-		return NULL;
-	}
+	if (setup_bus(conn, name, error) == FALSE)
+		goto fail;
+
+	if (!g_dbus_register_interface(conn, "/", NULL, NULL, NULL, NULL, NULL,
+									NULL))
+		goto fail;
 
 	return conn;
+
+fail:
+	dbus_connection_unref(conn);
+	return NULL;
+
+}
+
+void g_dbus_disconnect(DBusConnection *connection)
+{
+	g_dbus_unregister_interface(connection, "/", NULL);
+	dbus_connection_unref(connection);
 }
 
 DBusConnection *g_dbus_setup_private(DBusBusType type, const char *name,
diff --git a/gdbus/object.c b/gdbus/object.c
index 1f0ea39..04941c7 100644
--- a/gdbus/object.c
+++ b/gdbus/object.c
@@ -615,7 +615,7 @@ static struct interface_data *find_interface(GSList *interfaces,
 
 	for (list = interfaces; list; list = list->next) {
 		struct interface_data *iface = list->data;
-		if (!strcmp(name, iface->name))
+		if (g_strcmp0(name, iface->name) == 0)
 			return iface;
 	}
 
-- 
1.7.11.7


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

* [PATCH BlueZ 5/5] core: Make use of g_dbus_disconnect
  2012-11-15 14:05 [PATCH BlueZ 1/5] core: Fix registering '/org/bluez' path before '/' Luiz Augusto von Dentz
                   ` (2 preceding siblings ...)
  2012-11-15 14:05 ` [PATCH BlueZ 4/5] gdbus: Automatically register '/' path Luiz Augusto von Dentz
@ 2012-11-15 14:05 ` Luiz Augusto von Dentz
  3 siblings, 0 replies; 6+ messages in thread
From: Luiz Augusto von Dentz @ 2012-11-15 14:05 UTC (permalink / raw)
  To: linux-bluetooth

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

---
 src/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/main.c b/src/main.c
index 414849a..c180e09 100644
--- a/src/main.c
+++ b/src/main.c
@@ -383,7 +383,7 @@ static void disconnect_dbus(void)
 
 	set_dbus_connection(NULL);
 
-	dbus_connection_unref(conn);
+	g_dbus_disconnect(conn);
 }
 
 static void disconnected_dbus(DBusConnection *conn, void *data)
-- 
1.7.11.7


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

* Re: [PATCH BlueZ 2/5] core: Make exit sequence consistent with init
  2012-11-15 14:05 ` [PATCH BlueZ 2/5] core: Make exit sequence consistent with init Luiz Augusto von Dentz
@ 2012-11-15 14:15   ` Johan Hedberg
  0 siblings, 0 replies; 6+ messages in thread
From: Johan Hedberg @ 2012-11-15 14:15 UTC (permalink / raw)
  To: Luiz Augusto von Dentz; +Cc: linux-bluetooth

Hi Luiz,

On Thu, Nov 15, 2012, Luiz Augusto von Dentz wrote:
> manager_cleanup should be called after plugin_cleanup on exit as
> manager_init is called before plugin_init on the init sequence.
> ---
>  src/main.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

Patches 1 and 2 have been applied. For the others I'll wait for some
more feedback (e.g. from Lucas and Marcel).

Johan

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

end of thread, other threads:[~2012-11-15 14:15 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-11-15 14:05 [PATCH BlueZ 1/5] core: Fix registering '/org/bluez' path before '/' Luiz Augusto von Dentz
2012-11-15 14:05 ` [PATCH BlueZ 2/5] core: Make exit sequence consistent with init Luiz Augusto von Dentz
2012-11-15 14:15   ` Johan Hedberg
2012-11-15 14:05 ` [PATCH BlueZ 3/5] gdbus: Fix having multiple path exporting ObjectManager Luiz Augusto von Dentz
2012-11-15 14:05 ` [PATCH BlueZ 4/5] gdbus: Automatically register '/' path Luiz Augusto von Dentz
2012-11-15 14:05 ` [PATCH BlueZ 5/5] core: Make use of g_dbus_disconnect Luiz Augusto von Dentz

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.