* [Bluez-devel] [PATCH] Make BluetoothClient work on all adapters
@ 2007-07-24 16:16 Bastien Nocera
2007-07-24 16:20 ` Bastien Nocera
2007-07-24 21:14 ` Marcel Holtmann
0 siblings, 2 replies; 14+ messages in thread
From: Bastien Nocera @ 2007-07-24 16:16 UTC (permalink / raw)
To: BlueZ Hackers
[-- Attachment #1: Type: text/plain, Size: 190 bytes --]
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.
--
Bastien Nocera <hadess@hadess.net>
[-- Attachment #2: bluez-gnome-client-handle-all-adapters.patch --]
[-- Type: text/x-patch, Size: 3968 bytes --]
Index: common/client.c
===================================================================
RCS file: /cvsroot/bluez/gnome/common/client.c,v
retrieving revision 1.16
diff -u -p -r1.16 client.c
--- common/client.c 20 May 2007 12:04:32 -0000 1.16
+++ common/client.c 24 Jul 2007 16:12:18 -0000
@@ -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
diff -u -p -r1.11 client.h
--- common/client.h 3 Apr 2007 22:45:08 -0000 1.11
+++ common/client.h 24 Jul 2007 16:12:18 -0000
@@ -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,
[-- Attachment #3: Type: text/plain, Size: 315 bytes --]
-------------------------------------------------------------------------
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/
[-- Attachment #4: Type: text/plain, Size: 164 bytes --]
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [Bluez-devel] [PATCH] Make BluetoothClient work on all adapters
2007-07-24 16:16 [Bluez-devel] [PATCH] Make BluetoothClient work on all adapters Bastien Nocera
@ 2007-07-24 16:20 ` Bastien Nocera
2007-07-24 20:54 ` Marcel Holtmann
2007-07-24 21:14 ` Marcel Holtmann
1 sibling, 1 reply; 14+ messages in thread
From: Bastien Nocera @ 2007-07-24 16:20 UTC (permalink / raw)
To: BlueZ Hackers
[-- Attachment #1: Type: text/plain, Size: 309 bytes --]
On Tue, 2007-07-24 at 17:16 +0100, Bastien Nocera wrote:
> 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.
--
Bastien Nocera <hadess@hadess.net>
[-- Attachment #2: bluez-gnome-fix-test-client.patch --]
[-- Type: text/x-patch, Size: 292 bytes --]
diff --git a/common/test-client.c b/common/test-client.c
index ac32e80..68e8a82 100644
--- a/common/test-client.c
+++ b/common/test-client.c
@@ -144,7 +144,7 @@ int main(int argc, char *argv[])
gtk_main();
- bluetooth_client_destroy(client);
+ g_object_unref(client);
return 0;
}
[-- Attachment #3: Type: text/plain, Size: 315 bytes --]
-------------------------------------------------------------------------
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/
[-- Attachment #4: Type: text/plain, Size: 164 bytes --]
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel
^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [Bluez-devel] [PATCH] Make BluetoothClient work on all adapters
2007-07-24 16:20 ` Bastien Nocera
@ 2007-07-24 20:54 ` Marcel Holtmann
2007-07-24 21:12 ` Bastien Nocera
0 siblings, 1 reply; 14+ messages in thread
From: Marcel Holtmann @ 2007-07-24 20:54 UTC (permalink / raw)
To: BlueZ development
Hi Bastien,
> > 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
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [Bluez-devel] [PATCH] Make BluetoothClient work on all adapters
2007-07-24 20:54 ` Marcel Holtmann
@ 2007-07-24 21:12 ` Bastien Nocera
2007-07-24 21:26 ` Marcel Holtmann
0 siblings, 1 reply; 14+ messages in thread
From: Bastien Nocera @ 2007-07-24 21:12 UTC (permalink / raw)
To: BlueZ development
On Tue, 2007-07-24 at 22:54 +0200, Marcel Holtmann wrote:
> Hi Bastien,
>
> > > 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...
--
Bastien Nocera <hadess@hadess.net>
-------------------------------------------------------------------------
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
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [Bluez-devel] [PATCH] Make BluetoothClient work on all adapters
2007-07-24 16:16 [Bluez-devel] [PATCH] Make BluetoothClient work on all adapters Bastien Nocera
2007-07-24 16:20 ` Bastien Nocera
@ 2007-07-24 21:14 ` Marcel Holtmann
2007-07-24 22:10 ` Bastien Nocera
1 sibling, 1 reply; 14+ messages in thread
From: Marcel Holtmann @ 2007-07-24 21:14 UTC (permalink / raw)
To: BlueZ development
Hi Bastien,
> 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
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [Bluez-devel] [PATCH] Make BluetoothClient work on all adapters
2007-07-24 21:12 ` Bastien Nocera
@ 2007-07-24 21:26 ` Marcel Holtmann
0 siblings, 0 replies; 14+ messages in thread
From: Marcel Holtmann @ 2007-07-24 21:26 UTC (permalink / raw)
To: BlueZ development
Hi Bastien,
> > > > 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...
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
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [Bluez-devel] [PATCH] Make BluetoothClient work on all adapters
2007-07-24 21:14 ` Marcel Holtmann
@ 2007-07-24 22:10 ` Bastien Nocera
2007-07-24 23:09 ` Bastien Nocera
0 siblings, 1 reply; 14+ messages in thread
From: Bastien Nocera @ 2007-07-24 22:10 UTC (permalink / raw)
To: BlueZ development
On Tue, 2007-07-24 at 23:14 +0200, Marcel Holtmann wrote:
> Hi Bastien,
>
> > 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.
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.
--
Bastien Nocera <hadess@hadess.net>
-------------------------------------------------------------------------
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
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [Bluez-devel] [PATCH] Make BluetoothClient work on all adapters
2007-07-24 22:10 ` Bastien Nocera
@ 2007-07-24 23:09 ` Bastien Nocera
2007-07-25 6:51 ` Marcel Holtmann
2007-07-25 7:04 ` Marcel Holtmann
0 siblings, 2 replies; 14+ messages in thread
From: Bastien Nocera @ 2007-07-24 23:09 UTC (permalink / raw)
To: BlueZ development
[-- Attachment #1: Type: text/plain, Size: 1255 bytes --]
On Tue, 2007-07-24 at 23:10 +0100, Bastien Nocera wrote:
> On Tue, 2007-07-24 at 23:14 +0200, Marcel Holtmann wrote:
<snip>
> > 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
--
Bastien Nocera <hadess@hadess.net>
[-- Attachment #2: bluez-gnome-client-handle-default-adapter.patch --]
[-- Type: text/x-patch, Size: 6240 bytes --]
Index: client.c
===================================================================
RCS file: /cvsroot/bluez/gnome/common/client.c,v
retrieving revision 1.17
diff -u -p -r1.17 client.c
--- client.c 24 Jul 2007 21:23:59 -0000 1.17
+++ client.c 24 Jul 2007 23:03:02 -0000
@@ -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);
[-- Attachment #3: Type: text/plain, Size: 315 bytes --]
-------------------------------------------------------------------------
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/
[-- Attachment #4: Type: text/plain, Size: 164 bytes --]
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [Bluez-devel] [PATCH] Make BluetoothClient work on all adapters
2007-07-24 23:09 ` Bastien Nocera
@ 2007-07-25 6:51 ` Marcel Holtmann
2007-07-25 7:04 ` Marcel Holtmann
1 sibling, 0 replies; 14+ messages in thread
From: Marcel Holtmann @ 2007-07-25 6:51 UTC (permalink / raw)
To: BlueZ development
Hi Bastien,
> > > 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.
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
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [Bluez-devel] [PATCH] Make BluetoothClient work on all adapters
2007-07-24 23:09 ` Bastien Nocera
2007-07-25 6:51 ` Marcel Holtmann
@ 2007-07-25 7:04 ` Marcel Holtmann
2007-07-25 7:33 ` Bastien Nocera
1 sibling, 1 reply; 14+ messages in thread
From: Marcel Holtmann @ 2007-07-25 7:04 UTC (permalink / raw)
To: BlueZ development
Hi Bastien,
> > > 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
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [Bluez-devel] [PATCH] Make BluetoothClient work on all adapters
2007-07-25 7:04 ` Marcel Holtmann
@ 2007-07-25 7:33 ` Bastien Nocera
2007-07-25 7:53 ` Marcel Holtmann
0 siblings, 1 reply; 14+ messages in thread
From: Bastien Nocera @ 2007-07-25 7:33 UTC (permalink / raw)
To: BlueZ development
On Wed, 2007-07-25 at 09:04 +0200, Marcel Holtmann wrote:
> Hi Bastien,
>
> > > > 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.
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.
--
Bastien Nocera <hadess@hadess.net>
-------------------------------------------------------------------------
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
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [Bluez-devel] [PATCH] Make BluetoothClient work on all adapters
2007-07-25 7:33 ` Bastien Nocera
@ 2007-07-25 7:53 ` Marcel Holtmann
2007-07-25 7:56 ` Bastien Nocera
0 siblings, 1 reply; 14+ messages in thread
From: Marcel Holtmann @ 2007-07-25 7:53 UTC (permalink / raw)
To: BlueZ development
Hi Bastien,
> > > > > 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.
>
> 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.
> 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.
> 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
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [Bluez-devel] [PATCH] Make BluetoothClient work on all adapters
2007-07-25 7:53 ` Marcel Holtmann
@ 2007-07-25 7:56 ` Bastien Nocera
2007-07-25 8:05 ` Marcel Holtmann
0 siblings, 1 reply; 14+ messages in thread
From: Bastien Nocera @ 2007-07-25 7:56 UTC (permalink / raw)
To: BlueZ development
On Wed, 2007-07-25 at 09:53 +0200, Marcel Holtmann wrote:
> Hi Bastien,
>
> > > > > > 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.
> >
> > 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.
Ok.
> > 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.
> > 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).
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...
--
Bastien Nocera <hadess@hadess.net>
-------------------------------------------------------------------------
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
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [Bluez-devel] [PATCH] Make BluetoothClient work on all adapters
2007-07-25 7:56 ` Bastien Nocera
@ 2007-07-25 8:05 ` Marcel Holtmann
0 siblings, 0 replies; 14+ messages in thread
From: Marcel Holtmann @ 2007-07-25 8:05 UTC (permalink / raw)
To: BlueZ development
Hi Bastien,
> > > 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).
>
> 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
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2007-07-25 8:05 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-07-24 16:16 [Bluez-devel] [PATCH] Make BluetoothClient work on all adapters Bastien Nocera
2007-07-24 16:20 ` Bastien Nocera
2007-07-24 20:54 ` Marcel Holtmann
2007-07-24 21:12 ` Bastien Nocera
2007-07-24 21:26 ` Marcel Holtmann
2007-07-24 21:14 ` Marcel Holtmann
2007-07-24 22:10 ` Bastien Nocera
2007-07-24 23:09 ` Bastien Nocera
2007-07-25 6:51 ` Marcel Holtmann
2007-07-25 7:04 ` Marcel Holtmann
2007-07-25 7:33 ` Bastien Nocera
2007-07-25 7:53 ` Marcel Holtmann
2007-07-25 7:56 ` Bastien Nocera
2007-07-25 8:05 ` Marcel Holtmann
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox