Skip to contentSkip to conversation

Make BluetoothClient work on all adapters

PATCH In review Bastien Nocera 2 participants 14 messages Jul 24, 2007 – Jul 25, 2007 Bluetooth drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Make BluetoothClient work on all adapters

With this patch, we can now pass a NULL as the adapter to work with all the adapters. This is for use in the upcoming patch for the selector widget.

Signature · 1 line
Bastien Nocera <[email protected]> 

Index: common/client.c
===================================================================
RCS file: /cvsroot/bluez/gnome/common/client.c,v
retrieving revision 1.16

client.c +20 -18
diff -u -p -r1.16 client.c
@@ -59,7 +59,7 @@ static void bluetooth_client_init(Blueto
 
 static void bluetooth_client_finalize(GObject *object)
 {
-	//BluetoothClientPrivate *priv = BLUETOOTH_CLIENT_GET_PRIVATE(object);
+	bluetooth_client_cancel_discovery(BLUETOOTH_CLIENT (object), NULL);
 }
 
 static void bluetooth_client_set_property(GObject *object, guint prop_id,
@@ -351,9 +351,7 @@ static void update_adapter(DBusGProxy *o
 	gtk_tree_store_set(store, iter, COLUMN_ADDRESS, address,
 						COLUMN_NAME, name, -1);
 
-	//adapter_list_remote_devices(object, &array, &error);
-
-	adapter_list_bondings(object, &array, &error);
+	adapter_list_remote_devices(object, &array, &error);
 
 	if (error == NULL) {
 		while (*array) {
@@ -587,11 +585,6 @@ BluetoothClient *bluetooth_client_new(vo
 	return BLUETOOTH_CLIENT(g_object_new(BLUETOOTH_TYPE_CLIENT, NULL));
 }
 
-void bluetooth_client_destroy(BluetoothClient *self)
-{
-	g_object_unref(self);
-}
-
 gboolean bluetooth_client_register_passkey_agent(BluetoothClient *self,
 		const char *path, const char *address, const void *info)
 {
@@ -652,8 +645,9 @@ gboolean bluetooth_client_create_bonding
 gboolean bluetooth_client_discover_devices(BluetoothClient *self, gchar *adapter)
 {
 	GtkTreeIter iter;
-	gboolean cont;
+	gboolean cont, retval;
 
+	retval = FALSE;
 	cont = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(store), &iter);
 
 	while (cont == TRUE) {
@@ -664,23 +658,27 @@ gboolean bluetooth_client_discover_devic
 						COLUMN_PATH, &path,
 						COLUMN_OBJECT, &object, -1);
 
-		if (g_ascii_strcasecmp(path, adapter) == 0) {
+		if ((adapter == NULL && path != NULL)
+		    || g_ascii_strcasecmp(path, adapter) == 0) {
 			dbus_g_proxy_call(object, "DiscoverDevices",
 							NULL, G_TYPE_INVALID);
-			return TRUE;
+			if (adapter != NULL)
+				return TRUE;
+			retval = TRUE;
 		}
 
 		cont = gtk_tree_model_iter_next(GTK_TREE_MODEL(store), &iter);
 	}
 
-	return FALSE;
+	return retval;
 }
 
 gboolean bluetooth_client_cancel_discovery(BluetoothClient *self, gchar *adapter)
 {
 	GtkTreeIter iter;
-	gboolean cont;
+	gboolean cont, retval;
 
+	retval = FALSE;
 	cont = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(store), &iter);
 
 	while (cont == TRUE) {
@@ -691,16 +689,19 @@ gboolean bluetooth_client_cancel_discove
 						COLUMN_PATH, &path,
 						COLUMN_OBJECT, &object, -1);
 
-		if (g_ascii_strcasecmp(path, adapter) == 0) {
+		if ((adapter == NULL && path != NULL)
+		    || g_ascii_strcasecmp(path, adapter) == 0) {
 			dbus_g_proxy_call(object, "CancelDiscovery",
 							NULL, G_TYPE_INVALID);
-			return TRUE;
+			if (adapter != NULL)
+				return TRUE;
+			retval = TRUE;
 		}
 
 		cont = gtk_tree_model_iter_next(GTK_TREE_MODEL(store), &iter);
 	}
 
-	return FALSE;
+	return retval;
 }
 
 GtkTreeModel *bluetooth_client_get_model(BluetoothClient *self)
@@ -803,7 +804,8 @@ GtkTreeModel *bluetooth_client_get_model
 		gtk_tree_model_get(GTK_TREE_MODEL(store), &iter,
 						COLUMN_PATH, &path, -1);
 
-		if (!g_ascii_strcasecmp(path, adapter)) {
+		if ((adapter == NULL && path != NULL)
+		    || !g_ascii_strcasecmp(path, adapter)) {
 			GtkTreePath *path;
 
 			path = gtk_tree_model_get_path(GTK_TREE_MODEL(store), &iter);

Index: common/client.h
===================================================================
RCS file: /cvsroot/bluez/gnome/common/client.h,v
retrieving revision 1.11

client.h +0 -2
diff -u -p -r1.11 client.h
@@ -57,8 +57,6 @@ GType bluetooth_client_get_type(void);
 
 BluetoothClient *bluetooth_client_new(void);
 
-void bluetooth_client_destroy(BluetoothClient *self);
-
 enum {
 	COLUMN_PATH,
 	COLUMN_ACTIVE,

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/

_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

#1 lore raw
Quoted 3 lines · Bastien Nocera

With this patch, we can now pass a NULL as the adapter to work with all the adapters. This is for use in the upcoming patch for the selector widget.

And a tiny patch to fix the test-client's compilation.

Signature · 1 line
Bastien Nocera <[email protected]> 
common/test-client.c +1 -1
index ac32e80..68e8a82 100644
@@ -144,7 +144,7 @@ int main(int argc, char *argv[])
 
 	gtk_main();
 
-	bluetooth_client_destroy(client);
+	g_object_unref(client);
 
 	return 0;
 }

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/

_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

maintainer
#2 lore raw

Hi Bastien,

Quoted 5 lines
Quoted 3 lines

With this patch, we can now pass a NULL as the adapter to work with all the adapters. This is for use in the upcoming patch for the selector widget.

And a tiny patch to fix the test-client's compilation.

what is wrong with providing a convenience wrapper around the GObject unref function?

Regards

Marcel

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

#3 lore raw
Quoted 10 lines · Marcel Holtmann

Hi Bastien,

Quoted 5 lines
Quoted 3 lines

With this patch, we can now pass a NULL as the adapter to work with all the adapters. This is for use in the upcoming patch for the selector widget.

And a tiny patch to fix the test-client's compilation.

what is wrong with providing a convenience wrapper around the GObject unref function?

unref isn't destroy.

Destroy, as used in GTK+ for widgets (it's not used in glib) means you destroy the widget, drop the refcount to 0, clean up, free the memory, etc.

Unref means you reduce the refcount by 1. If you have > 1 reference before running the command, then nothing happens apart from the refcount being updates.

Wrapping a _destroy() function to call _unref() means you're mixing two semantics. When you call _destroy() the object isn't destroyed, it's refcount is reduced...

Signature · 12 lines
Bastien Nocera <[email protected]> 


-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel
maintainer
#5 lore raw
In reply to Bastien Nocera

Hi Bastien,

Quoted 3 lines

With this patch, we can now pass a NULL as the adapter to work with all the adapters. This is for use in the upcoming patch for the selector widget.

I don't like it. We should not wildly use all attached adapters. Passing a NULL to the client creation should use the default adapter.

Actually in case of multiple adapters we need to provide one extra step to let the user select the appropriate adapter.

Main reason, why I don't wanna start an inquiry on all adapters is that it can happen that you see a remote device with one adapter, but then the actual connection or device discovery is done via another one. That is not good. We should always use the default adapter and if (and only if) more adapters are present, then present a way to select a different adapter.

However this includes that we have to monitor if the default adapter changes or one adapter gets removed while being in the adapter selector widget or device selector widget.

Regards

Marcel

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

maintainer
#4 lore raw
In reply to Bastien Nocera

Hi Bastien,

Quoted 15 lines
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

With this patch, we can now pass a NULL as the adapter to work with all the adapters. This is for use in the upcoming patch for the selector widget.

And a tiny patch to fix the test-client's compilation.

what is wrong with providing a convenience wrapper around the GObject unref function?

unref isn't destroy.

Destroy, as used in GTK+ for widgets (it's not used in glib) means you destroy the widget, drop the refcount to 0, clean up, free the memory, etc.

Quoted 7 lines

Unref means you reduce the refcount by 1. If you have > 1 reference before running the command, then nothing happens apart from the refcount being updates.

Wrapping a _destroy() function to call _unref() means you're mixing two semantics. When you call _destroy() the object isn't destroyed, it's refcount is reduced...

okay. Point taken. I removed the _destroy() function form the code, but I didn't apply the rest of the patch.

Regards

Marcel

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

#6 lore raw
In reply to Marcel Holtmann
Quoted 19 lines · Marcel Holtmann

Hi Bastien,

Quoted 3 lines

With this patch, we can now pass a NULL as the adapter to work with all the adapters. This is for use in the upcoming patch for the selector widget.

I don't like it. We should not wildly use all attached adapters. Passing a NULL to the client creation should use the default adapter.

Actually in case of multiple adapters we need to provide one extra step to let the user select the appropriate adapter.

Main reason, why I don't wanna start an inquiry on all adapters is that it can happen that you see a remote device with one adapter, but then the actual connection or device discovery is done via another one. That is not good. We should always use the default adapter and if (and only if) more adapters are present, then present a way to select a different adapter.

Quoted 3 lines

However this includes that we have to monitor if the default adapter changes or one adapter gets removed while being in the adapter selector widget or device selector widget.

Fair enough, I knew this would be a sticky point. I'm trying to fix it up so that we use the default adapter by default with "NULL" passed as the adapter.

Signature · 12 lines
Bastien Nocera <[email protected]> 


-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel
#7 lore raw
Quoted 1 line · Bastien Nocera

On Tue, 2007-07-24 at 23:14 +0200, Marcel Holtmann wrote:

<snip>

Quoted 7 lines
Quoted 3 lines

However this includes that we have to monitor if the default adapter changes or one adapter gets removed while being in the adapter selector widget or device selector widget.

Fair enough, I knew this would be a sticky point. I'm trying to fix it up so that we use the default adapter by default with "NULL" passed as the adapter.

Here goes. This should correctly kill the disco on the old default adapter and re-enable it on the new default adapter, when the default adapter changes.

If the default adapter changes but we didn't start a discovery using the default adapter, then it's up to the application to start/stop it anyway.

It will also make all the functions taking an adapter use the default adapter when NULL is passed.

We should also kill discovery on all the devices when the object goes away, and move the treestore, and dbus connection to the class, rather than using statics. But that's for another patch.

That should allow the rest of the wizard cleanups getting in, as well as the device selector, and then the browse menu implementation.

Cheers

Signature · 1 line
Bastien Nocera <[email protected]> 

Index: client.c
===================================================================
RCS file: /cvsroot/bluez/gnome/common/client.c,v
retrieving revision 1.17

client.c +69 -12
diff -u -p -r1.17 client.c
@@ -35,9 +35,9 @@
 
 #include "dbus-glue.h"
 
-static DBusGConnection *conn;
+static DBusGConnection *conn = NULL;
 
-static GtkTreeStore *store;
+static GtkTreeStore *store = NULL;
 
 #define BLUETOOTH_CLIENT_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), \
 				BLUETOOTH_TYPE_CLIENT, BluetoothClientPrivate))
@@ -46,20 +46,44 @@ typedef struct _BluetoothClientPrivate B
 
 struct _BluetoothClientPrivate {
 	gboolean registered;
+	gchar *default_adapter;
+	gboolean discovery_on_default;
 };
 
+static void default_adapter_changed(DBusGProxy *object,
+					const char *path, BluetoothClient *self);
+
 G_DEFINE_TYPE(BluetoothClient, bluetooth_client, G_TYPE_OBJECT)
 
 static void bluetooth_client_init(BluetoothClient *self)
 {
 	BluetoothClientPrivate *priv = BLUETOOTH_CLIENT_GET_PRIVATE(self);
+	DBusGProxy *object;
+
+	object = dbus_g_proxy_new_for_name(conn, "org.bluez",
+					"/org/bluez", "org.bluez.Manager");
+
+	dbus_g_proxy_add_signal(object, "DefaultAdapterChanged",
+				G_TYPE_STRING, G_TYPE_INVALID);
+
+	dbus_g_proxy_connect_signal(object, "DefaultAdapterChanged",
+				G_CALLBACK(default_adapter_changed), conn, NULL);
+
+	manager_default_adapter(object, &priv->default_adapter, NULL);
 
 	priv->registered = FALSE;
 }
 
 static void bluetooth_client_finalize(GObject *object)
 {
-	//BluetoothClientPrivate *priv = BLUETOOTH_CLIENT_GET_PRIVATE(object);
+	BluetoothClient *self = BLUETOOTH_CLIENT (object);
+	BluetoothClientPrivate *priv = BLUETOOTH_CLIENT_GET_PRIVATE(self);
+
+	g_free(priv->default_adapter);
+	priv->default_adapter = NULL;
+
+	//FIXME cancel disco on _all_ devices
+	//bluetooth_client_cancel_discovery(self, NULL);
 }
 
 static void bluetooth_client_set_property(GObject *object, guint prop_id,
@@ -351,9 +375,7 @@ static void update_adapter(DBusGProxy *o
 	gtk_tree_store_set(store, iter, COLUMN_ADDRESS, address,
 						COLUMN_NAME, name, -1);
 
-	//adapter_list_remote_devices(object, &array, &error);
-
-	adapter_list_bondings(object, &array, &error);
+	adapter_list_remote_devices(object, &array, &error);
 
 	if (error == NULL) {
 		while (*array) {
@@ -488,11 +510,30 @@ static void adapter_removed(DBusGProxy *
 	remove_adapter(path);
 }
 
+static void default_adapter_changed(DBusGProxy *object,
+					const char *path, BluetoothClient *self)
+{
+	BluetoothClientPrivate *priv = BLUETOOTH_CLIENT_GET_PRIVATE(self);
+	gboolean discovery_on_default;
+
+	discovery_on_default = priv->discovery_on_default;
+
+	/* If we started a discovery on the default adapter, cancel it
+	 * and restart a new one on the new default adapter */
+	if (discovery_on_default)
+		bluetooth_client_cancel_discovery(self, NULL);
+
+	g_free(priv->default_adapter);
+	priv->default_adapter = g_strdup(path);
+
+	if (discovery_on_default)
+		bluetooth_client_discover_devices(self, NULL);
+}
+
 static void setup_manager(void)
 {
 	DBusGProxy *object;
 	GError *error = NULL;
-	char *default_adapter = NULL;
 	char **array = NULL;
 
 	object = dbus_g_proxy_new_for_name(conn, "org.bluez",
@@ -510,8 +551,6 @@ static void setup_manager(void)
 	dbus_g_proxy_connect_signal(object, "AdapterRemoved",
 				G_CALLBACK(adapter_removed), conn, NULL);
 
-	manager_default_adapter(object, &default_adapter, NULL);
-
 	manager_list_adapters(object, &array, &error);
 
 	if (error == NULL) {
@@ -646,11 +685,15 @@ gboolean bluetooth_client_create_bonding
 
 gboolean bluetooth_client_discover_devices(BluetoothClient *self, gchar *adapter)
 {
+	BluetoothClientPrivate *priv = BLUETOOTH_CLIENT_GET_PRIVATE(self);
 	GtkTreeIter iter;
 	gboolean cont;
 
 	cont = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(store), &iter);
 
+	if (!adapter && !priv->default_adapter)
+		return FALSE;
+
 	while (cont == TRUE) {
 		DBusGProxy *object;
 		gchar *path;
@@ -659,9 +702,12 @@ gboolean bluetooth_client_discover_devic
 						COLUMN_PATH, &path,
 						COLUMN_OBJECT, &object, -1);
 
-		if (g_ascii_strcasecmp(path, adapter) == 0) {
+		if ((adapter == NULL && g_ascii_strcasecmp(path, priv->default_adapter) == 0)
+		    || g_ascii_strcasecmp(path, adapter) == 0) {
 			dbus_g_proxy_call(object, "DiscoverDevices",
 							NULL, G_TYPE_INVALID);
+			if (!adapter)
+				priv->discovery_on_default = TRUE;
 			return TRUE;
 		}
 
@@ -673,10 +719,13 @@ gboolean bluetooth_client_discover_devic
 
 gboolean bluetooth_client_cancel_discovery(BluetoothClient *self, gchar *adapter)
 {
+	BluetoothClientPrivate *priv = BLUETOOTH_CLIENT_GET_PRIVATE(self);
 	GtkTreeIter iter;
 	gboolean cont;
 
 	cont = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(store), &iter);
+	if (!adapter && !priv->default_adapter)
+		return FALSE;
 
 	while (cont == TRUE) {
 		DBusGProxy *object;
@@ -686,9 +735,12 @@ gboolean bluetooth_client_cancel_discove
 						COLUMN_PATH, &path,
 						COLUMN_OBJECT, &object, -1);
 
-		if (g_ascii_strcasecmp(path, adapter) == 0) {
+		if ((adapter == NULL && g_ascii_strcasecmp(path, priv->default_adapter) == 0)
+		    || g_ascii_strcasecmp(path, adapter) == 0) {
 			dbus_g_proxy_call(object, "CancelDiscovery",
 							NULL, G_TYPE_INVALID);
+			if (!adapter)
+				priv->discovery_on_default = FALSE;
 			return TRUE;
 		}
 
@@ -786,19 +838,24 @@ static gboolean device_active_filter(Gtk
 GtkTreeModel *bluetooth_client_get_model_for_adapter(BluetoothClient *self,
 								gchar *adapter)
 {
+	BluetoothClientPrivate *priv = BLUETOOTH_CLIENT_GET_PRIVATE(self);
 	GtkTreeModel *model;
 	GtkTreeIter iter;
 	gboolean cont;
 
 	cont = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(store), &iter);
 
+	if (!adapter && !priv->default_adapter)
+		return FALSE;
+
 	while (cont == TRUE) {
 		gchar *path;
 
 		gtk_tree_model_get(GTK_TREE_MODEL(store), &iter,
 						COLUMN_PATH, &path, -1);
 
-		if (!g_ascii_strcasecmp(path, adapter)) {
+		if ((adapter == NULL && !g_ascii_strcasecmp(path, priv->default_adapter))
+		    || !g_ascii_strcasecmp(path, adapter)) {
 			GtkTreePath *path;
 
 			path = gtk_tree_model_get_path(GTK_TREE_MODEL(store), &iter);

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/

_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

maintainer
#8 lore raw

Hi Bastien,

Quoted 16 lines
Quoted 7 lines
Quoted 3 lines

However this includes that we have to monitor if the default adapter changes or one adapter gets removed while being in the adapter selector widget or device selector widget.

Fair enough, I knew this would be a sticky point. I'm trying to fix it up so that we use the default adapter by default with "NULL" passed as the adapter.

Here goes. This should correctly kill the disco on the old default adapter and re-enable it on the new default adapter, when the default adapter changes.

If the default adapter changes but we didn't start a discovery using the default adapter, then it's up to the application to start/stop it anyway.

Quoted 6 lines

It will also make all the functions taking an adapter use the default adapter when NULL is passed.

We should also kill discovery on all the devices when the object goes away, and move the treestore, and dbus connection to the class, rather than using statics. But that's for another patch.

when the object goes away, then we can disconnect from the system bus and kill our D-Bus connection. This means that hcid will detect that our application is no longer in control and cancel everything that is still running. Only exception is periodic inquiry, but that is meant to be like it and we don't have to worry.

Regards

Marcel

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

maintainer
#9 lore raw
In reply to Bastien Nocera

Hi Bastien,

Quoted 11 lines
Quoted 7 lines
Quoted 3 lines

However this includes that we have to monitor if the default adapter changes or one adapter gets removed while being in the adapter selector widget or device selector widget.

Fair enough, I knew this would be a sticky point. I'm trying to fix it up so that we use the default adapter by default with "NULL" passed as the adapter.

Here goes. This should correctly kill the disco on the old default adapter and re-enable it on the new default adapter, when the default adapter changes.

you patch is wrong. You are messing up a DBusConnection object with the BluetoothClient object in the callbacks of the DefaultAdapterChanged signal.

Actually I also don't like this way, we should store the default path globally since that is what really counts. The tree storing all information should be fully valid as long as we have an instance of the BluetoothClient object and it can store the information about the default adapter for us.

Regards

Marcel

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

#10 lore raw
Quoted 18 lines · Marcel Holtmann

Hi Bastien,

Quoted 11 lines
Quoted 7 lines
Quoted 3 lines

However this includes that we have to monitor if the default adapter changes or one adapter gets removed while being in the adapter selector widget or device selector widget.

Fair enough, I knew this would be a sticky point. I'm trying to fix it up so that we use the default adapter by default with "NULL" passed as the adapter.

Here goes. This should correctly kill the disco on the old default adapter and re-enable it on the new default adapter, when the default adapter changes.

you patch is wrong. You are messing up a DBusConnection object with the BluetoothClient object in the callbacks of the DefaultAdapterChanged signal.

Quoted 5 lines

Actually I also don't like this way, we should store the default path globally since that is what really counts. The tree storing all information should be fully valid as long as we have an instance of the BluetoothClient object and it can store the information about the default adapter for us.

The tree storing all information is still valid, there's no information there as to which is the default adapter.

And to be able to use the default_adapter in the instances, you need to connect to the signal in the instances.

If you're not interested in stopping the existing discoveries on the default adapter when the default adapter changes, or transferring those discoveries to other devices, then it will be much easier.

I'm not sure why we would carry on discovering devices if the model showing the devices is going away though.

So, the only thing I'm supposed to do, is change the model automatically, so that when we get the model for the default adapter, the model should change automatically. That will require the DefaultAdapterChanged signal to live in the instance, as in my patch, as globally, we don't have any knownledge of the instances.

Signature · 12 lines
Bastien Nocera <[email protected]> 


-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel
maintainer
#11 lore raw

Hi Bastien,

Quoted 22 lines
Quoted 16 lines
Quoted 11 lines
Quoted 7 lines
Quoted 3 lines

However this includes that we have to monitor if the default adapter changes or one adapter gets removed while being in the adapter selector widget or device selector widget.

Fair enough, I knew this would be a sticky point. I'm trying to fix it up so that we use the default adapter by default with "NULL" passed as the adapter.

Here goes. This should correctly kill the disco on the old default adapter and re-enable it on the new default adapter, when the default adapter changes.

you patch is wrong. You are messing up a DBusConnection object with the BluetoothClient object in the callbacks of the DefaultAdapterChanged signal.

Quoted 5 lines

Actually I also don't like this way, we should store the default path globally since that is what really counts. The tree storing all information should be fully valid as long as we have an instance of the BluetoothClient object and it can store the information about the default adapter for us.

Quoted 5 lines

The tree storing all information is still valid, there's no information there as to which is the default adapter.

And to be able to use the default_adapter in the instances, you need to connect to the signal in the instances.

actually no. The information about the default adapter is global. I used a global variable for now. If we need more specific information later or wanna do some advanced magic, then we can fix that. For now storing the default adapter in a global variable is fine.

Quoted 6 lines

If you're not interested in stopping the existing discoveries on the default adapter when the default adapter changes, or transferring those discoveries to other devices, then it will be much easier.

I'm not sure why we would carry on discovering devices if the model showing the devices is going away though.

I think that we should not. If the adapter goes away, then the discovery should stop. However lets think about that later.

Quoted 5 lines

So, the only thing I'm supposed to do, is change the model automatically, so that when we get the model for the default adapter, the model should change automatically. That will require the DefaultAdapterChanged signal to live in the instance, as in my patch, as globally, we don't have any knownledge of the instances.

We can have that in the model if we connect the proper signals to the rows. That is the way I prefer, because the rest is messy and would need DBusProxy for every instance. We don't since the model should be global and actually valid for the lifetime of the application. However don't worry. We can fix this up in the background. Once we have proper widgets available, we don't have to expose the model to the applications anymore (or at least less).

Regards

Marcel

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

#12 lore raw
Quoted 27 lines · Marcel Holtmann

Hi Bastien,

Quoted 25 lines
Quoted 16 lines
Quoted 11 lines
Quoted 7 lines
Quoted 3 lines

However this includes that we have to monitor if the default adapter changes or one adapter gets removed while being in the adapter selector widget or device selector widget.

Fair enough, I knew this would be a sticky point. I'm trying to fix it up so that we use the default adapter by default with "NULL" passed as the adapter.

Here goes. This should correctly kill the disco on the old default adapter and re-enable it on the new default adapter, when the default adapter changes.

you patch is wrong. You are messing up a DBusConnection object with the BluetoothClient object in the callbacks of the DefaultAdapterChanged signal.

Quoted 5 lines

Actually I also don't like this way, we should store the default path globally since that is what really counts. The tree storing all information should be fully valid as long as we have an instance of the BluetoothClient object and it can store the information about the default adapter for us.

The tree storing all information is still valid, there's no information there as to which is the default adapter.

Quoted 7 lines
Quoted 2 lines

And to be able to use the default_adapter in the instances, you need to connect to the signal in the instances.

actually no. The information about the default adapter is global. I used a global variable for now. If we need more specific information later or wanna do some advanced magic, then we can fix that. For now storing the default adapter in a global variable is fine.

Ok.

Quoted 9 lines
Quoted 6 lines

If you're not interested in stopping the existing discoveries on the default adapter when the default adapter changes, or transferring those discoveries to other devices, then it will be much easier.

I'm not sure why we would carry on discovering devices if the model showing the devices is going away though.

I think that we should not. If the adapter goes away, then the discovery should stop. However lets think about that later.

I didn't think of that particular case.

Quoted 6 lines
Quoted 5 lines

So, the only thing I'm supposed to do, is change the model automatically, so that when we get the model for the default adapter, the model should change automatically. That will require the DefaultAdapterChanged signal to live in the instance, as in my patch, as globally, we don't have any knownledge of the instances.

Quoted 7 lines

We can have that in the model if we connect the proper signals to the rows. That is the way I prefer, because the rest is messy and would need DBusProxy for every instance. We don't since the model should be global and actually valid for the lifetime of the application. However don't worry. We can fix this up in the background. Once we have proper widgets available, we don't have to expose the model to the applications anymore (or at least less).

What's needed for the patch to go in then? Should we just make sure that we use the default adapter when NULL is passed to those few functions, and that's it? Even easier...

Signature · 12 lines
Bastien Nocera <[email protected]> 


-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel
maintainer
#13 lore raw

Hi Bastien,

Quoted 14 lines
Quoted 6 lines
Quoted 5 lines

So, the only thing I'm supposed to do, is change the model automatically, so that when we get the model for the default adapter, the model should change automatically. That will require the DefaultAdapterChanged signal to live in the instance, as in my patch, as globally, we don't have any knownledge of the instances.

Quoted 7 lines

We can have that in the model if we connect the proper signals to the rows. That is the way I prefer, because the rest is messy and would need DBusProxy for every instance. We don't since the model should be global and actually valid for the lifetime of the application. However don't worry. We can fix this up in the background. Once we have proper widgets available, we don't have to expose the model to the applications anymore (or at least less).

Quoted 3 lines

What's needed for the patch to go in then? Should we just make sure that we use the default adapter when NULL is passed to those few functions, and that's it? Even easier...

patch for that is in the CVS now. Including the changes to the wizard.

Regards

Marcel

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel