Skip to contentSkip to conversation

Wizard patch

Bluez-devel Michael Terry 6 participants 30 messages Jun 27, 2008 – Aug 19, 2008 2 messages not in the archive Bluetooth drivers

lore
Share & tools
lore
#0 lore raw

Hello, all!

I have attached a patch against 0.27 (it applies cleanly against CVS) to complete the wizard in the bluez-gnome source tree.

Here's what my patch does in summary, details below:
Wizard dialog shows list of device types we know how to handle (only mouse/keyboard/headset right now). Then, it tries to connect to the appropriate bluetooth dbus service and trust the device. Basically the same code steps the Properties -> Services tab does, but more wizardy. :)

I made changes to cleanup the wizard interface (removed a couple of pages that had low signal/noise ratio) and made several of the bluetooth_client capable of giving feedback about the operation via a callback.

Details of changes:

applet/main.c:
Uncomments code to add a menu item for the wizard.

common/bluetooth-device-selection.c:
Fixes broken code to set current filter programmatically.

common/client.[ch]:
setup_services():
Note presence of audio and input services on startup

bluetooth_client_get_name():
Gets user-visible device name for a path

bluetooth_client_available_services():
Returns a mask of the device types supported by services the client
knows about. Not actually used by the rest of my code, but it seemed possibly useful to one day not show unsupported device types in the wizard if we wanted to.

bluetooth_client_cancel_call():
Cancels an async call for a particular adapter/address combo. This is
slightly janky because it only allows for one call at a time per pair, but that's all that we ever need right now.

connect_to_service():
Handles service-specific calls to initiate a device connection. Stuff
like CreateSecureDevice or CreateHeadset.

bluetooth_client_connect():
Kicks off a call to connect_to_service

bluetooth_client_create_bonding():
bluetooth_client_remove_bonding():
bluetooth_client_set_trusted():
bluetooth_client_remove_trust():
Modified to allow callbacks

common/dbus.xml:
Add input.CreateSecureDevice and audio.CreateHeadset

properties/adapter.c:
Update a few calls to client functions do to above prototype changes

wizard/agent.[ch]:
Mostly a copy of applet/agent.c, except:
it only holds passkey code (no auth code) it shows dialogs immediately wrt a parent window

wizard/main.c:
Comment out intro and info pages -- I think the intro page just gets in
the user's way and there was no content in info page, and even if there was, it would probably also just get in user's way.

I added a pulsing progress bar to the pairing page to give some
feedback.

I changed wording from 'setup' and 'pair' to 'connect'. I figure that
is more user-friendly (since no real setting up is done by user and they probably think in terms of connecting to devices not pairing with them).

Pairing process is two-step: bluetooth_client_connect followed by
bluetooth_client_set_trusted.

Show an error if either step fails.

Connect to agent code to display a password prompt immediately in front
of user instead of via bluetooth applet.

wizard/Makefile.am:
Install bluetooth-wizard and add agent.[ch]

Thanks!
-mt

applet/main.c +1 -5
diff -rupN bluez-gnome-0.27.orig/applet/main.c bluez-gnome-0.27/applet/main.c
@@ -625,7 +625,6 @@ static void sendto_callback(GObject *wid
 		g_printerr("Couldn't execute command: %s\n", command);
 }
 
-#if 0
 static void wizard_callback(GObject *widget, gpointer user_data)
 {
 	const char *command = "bluetooth-wizard --singleton";
@@ -633,7 +632,6 @@ static void wizard_callback(GObject *wid
 	if (!g_spawn_command_line_async(command, NULL))
 		g_printerr("Couldn't execute command: %s\n", command);
 }
-#endif
 
 static void activate_callback(GObject *widget, gpointer user_data)
 {
@@ -697,17 +695,15 @@ static GtkWidget *create_popupmenu(void)
 
 	menuitem_browse = item;
 
-#if 0
 	item = gtk_separator_menu_item_new();
 	gtk_widget_show(item);
 	gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
 
-	item = gtk_menu_item_new_with_label(_("Setup New Device"));
+	item = gtk_menu_item_new_with_label(_("Connect New Device..."));
 	g_signal_connect(item, "activate",
 				G_CALLBACK(wizard_callback), NULL);
 	gtk_widget_show(item);
 	gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
-#endif
 
 	return menu;
 }
common/bluetooth-device-selection.c +12 -3
diff -rupN bluez-gnome-0.27.orig/common/bluetooth-device-selection.c bluez-gnome-0.27/common/bluetooth-device-selection.c
@@ -90,6 +90,15 @@ bluetooth_device_category_to_string (int
 	}
 }
 
+static int
+int_log2(int v)
+{
+	unsigned rv = 0;
+	while (v >>= 1)
+	  rv++;
+	return rv;
+}
+
 static void
 name_to_text (GtkTreeViewColumn *column, GtkCellRenderer *cell,
 	      GtkTreeModel *model, GtkTreeIter *iter, gpointer data)
@@ -591,7 +600,7 @@ bluetooth_device_selection_init(Bluetoot
 	}
 	g_signal_connect (G_OBJECT (priv->device_type), "changed",
 			  G_CALLBACK(filter_type_changed_cb), self);
-	gtk_combo_box_set_active (GTK_COMBO_BOX(priv->device_type), priv->device_type_filter);
+	gtk_combo_box_set_active (GTK_COMBO_BOX(priv->device_type), int_log2(priv->device_type_filter));
 	if (priv->show_device_type) {
 		gtk_widget_show (priv->device_type_label);
 		gtk_widget_show (priv->device_type);
@@ -665,7 +674,7 @@ bluetooth_device_selection_set_property 
 		break;
 	case PROP_DEVICE_TYPE_FILTER:
 		priv->device_type_filter = g_value_get_int (value);
-		gtk_combo_box_set_active (GTK_COMBO_BOX(priv->device_type), priv->device_type_filter >> 1);
+		gtk_combo_box_set_active (GTK_COMBO_BOX(priv->device_type), int_log2(priv->device_type_filter));
 		break;
 	case PROP_DEVICE_CATEGORY_FILTER:
 		priv->device_category_filter = g_value_get_int (value);
@@ -751,7 +760,7 @@ bluetooth_device_selection_class_init (B
 											  NULL, NULL, TRUE, G_PARAM_READWRITE));
 	g_object_class_install_property (G_OBJECT_CLASS(klass),
 					 PROP_DEVICE_TYPE_FILTER, g_param_spec_int ("device-type-filter", NULL, NULL,
-										    0, BLUETOOTH_TYPE_NUM_TYPES, 0, G_PARAM_READWRITE));
+										    1, 1 << (BLUETOOTH_TYPE_NUM_TYPES-1), 1, G_PARAM_READWRITE));
 	g_object_class_install_property (G_OBJECT_CLASS(klass),
 					 PROP_DEVICE_CATEGORY_FILTER, g_param_spec_int ("device-category-filter", NULL, NULL,
 					 						0, BLUETOOTH_CATEGORY_NUM_CATEGORIES, 0, G_PARAM_READWRITE));
common/client.c +258 -31

377 lines not on this page · raw message

common/client.h +24 -4
diff -rupN bluez-gnome-0.27.orig/common/client.h bluez-gnome-0.27/common/client.h
@@ -99,14 +99,34 @@ const gchar *bluetooth_type_to_string(gu
 gboolean bluetooth_client_register_passkey_agent(BluetoothClient *self,
 		const char *path, const char *address, const void *info);
 
-gboolean bluetooth_client_create_bonding(BluetoothClient *self,
+typedef void (*bluetooth_client_call_reply) (GError *error, gpointer data);
+
+int bluetooth_client_available_services(BluetoothClient *self);
+
+gboolean bluetooth_client_cancel_call(BluetoothClient *self,
 					gchar *adapter, const gchar *address);
+gboolean bluetooth_client_connect(BluetoothClient *self, guint type, // set to non-ANY to force a certain type connection -- useful for dumb devices
+					gchar *adapter, const gchar *address,
+					bluetooth_client_call_reply callback,
+					gpointer data);
+gboolean bluetooth_client_create_bonding(BluetoothClient *self,
+					gchar *adapter, const gchar *address,
+					bluetooth_client_call_reply callback,
+					gpointer data);
 gboolean bluetooth_client_remove_bonding(BluetoothClient *self,
-					gchar *adapter, const gchar *address);
+					gchar *adapter, const gchar *address,
+					bluetooth_client_call_reply callback,
+					gpointer data);
 gboolean bluetooth_client_set_trusted(BluetoothClient *self,
-					gchar *adapter, const gchar *address);
+					gchar *adapter, const gchar *address,
+					bluetooth_client_call_reply callback,
+					gpointer data);
 gboolean bluetooth_client_remove_trust(BluetoothClient *self,
-					gchar *adapter, const gchar *address);
+					gchar *adapter, const gchar *address,
+					bluetooth_client_call_reply callback,
+					gpointer data);
+
+const gchar *bluetooth_client_get_name(BluetoothClient *self, const gchar *adapter);
 
 gboolean bluetooth_client_disconnect(BluetoothClient *self,
 					gchar *adapter, const gchar *address);
common/dbus.xml +16 -0
diff -rupN bluez-gnome-0.27.orig/common/dbus.xml bluez-gnome-0.27/common/dbus.xml
@@ -98,4 +98,20 @@
       <arg type="s" name="address"/>
     </method>
   </interface>
+  
+  <interface name="input">
+    <method name="CreateSecureDevice">
+      <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+      <arg type="s" name="address"/>
+      <arg type="s" direction="out"/>
+    </method>
+  </interface>
+
+  <interface name="audio">
+    <method name="CreateHeadset">
+      <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+      <arg type="s" name="address"/>
+      <arg type="s" direction="out"/>
+    </method>
+  </interface>
 </node>
properties/adapter.c +3 -3
diff -rupN bluez-gnome-0.27.orig/properties/adapter.c bluez-gnome-0.27/properties/adapter.c
@@ -317,7 +317,7 @@ static void delete_callback(GtkWidget *b
 	gtk_tree_model_get(model, &iter, COLUMN_ADDRESS, &address, -1);
 
 	if (show_confirm_dialog() == TRUE)
-		bluetooth_client_remove_bonding(client, adapter->path, address);
+		bluetooth_client_remove_bonding(client, adapter->path, address, NULL, NULL);
 
 	g_free(address);
 }
@@ -338,9 +338,9 @@ static void trusted_callback(GtkWidget *
 					COLUMN_TRUSTED, &trusted, -1);
 
 	if (trusted == FALSE)
-		bluetooth_client_set_trusted(client, adapter->path, address);
+		bluetooth_client_set_trusted(client, adapter->path, address, NULL, NULL);
 	else
-		bluetooth_client_remove_trust(client, adapter->path, address);
+		bluetooth_client_remove_trust(client, adapter->path, address, NULL, NULL);
 
 	g_free(address);
 }
wizard/agent.c +504 -0

504 lines not on this page · raw message

wizard/agent.h +30 -0
diff -rupN bluez-gnome-0.27.orig/wizard/agent.h bluez-gnome-0.27/wizard/agent.h
@@ -0,0 +1,30 @@
+/*
+ *
+ *  BlueZ - Bluetooth protocol stack for Linux
+ *
+ *  Copyright (C) 2005-2008  Marcel Holtmann <[email protected]>
+ *  Copyright (C) 2006-2007  Bastien Nocera <[email protected]>
+ *
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ */
+
+#include <gtk/gtk.h>
+#include "client.h"
+
+void set_agent_parent_window(GtkWidget *window);
+int register_agent(BluetoothClient *client, const char *path, const char *address);
+
wizard/main.c +132 -95

344 lines not on this page · raw message

wizard/Makefile.am +1 -1
diff -rupN bluez-gnome-0.27.orig/wizard/Makefile.am bluez-gnome-0.27/wizard/Makefile.am
@@ -1,7 +1,7 @@
 
 noinst_PROGRAMS = bluetooth-wizard
 
-bluetooth_wizard_SOURCES = main.c
+bluetooth_wizard_SOURCES = main.c agent.c agent.h
 
 bluetooth_wizard_LDADD = @GTK_LIBS@ @DBUS_LIBS@ \
 		$(top_builddir)/common/libcommon.a

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php

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

#1 lore raw

Whoops, here's a fixed patch that actually installs the binary.

-mt

applet/main.c +1 -5
diff -rupN bluez-gnome-0.27.orig/applet/main.c bluez-gnome-0.27/applet/main.c
@@ -625,7 +625,6 @@ static void sendto_callback(GObject *wid
 		g_printerr("Couldn't execute command: %s\n", command);
 }
 
-#if 0
 static void wizard_callback(GObject *widget, gpointer user_data)
 {
 	const char *command = "bluetooth-wizard --singleton";
@@ -633,7 +632,6 @@ static void wizard_callback(GObject *wid
 	if (!g_spawn_command_line_async(command, NULL))
 		g_printerr("Couldn't execute command: %s\n", command);
 }
-#endif
 
 static void activate_callback(GObject *widget, gpointer user_data)
 {
@@ -697,17 +695,15 @@ static GtkWidget *create_popupmenu(void)
 
 	menuitem_browse = item;
 
-#if 0
 	item = gtk_separator_menu_item_new();
 	gtk_widget_show(item);
 	gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
 
-	item = gtk_menu_item_new_with_label(_("Setup New Device"));
+	item = gtk_menu_item_new_with_label(_("Connect New Device..."));
 	g_signal_connect(item, "activate",
 				G_CALLBACK(wizard_callback), NULL);
 	gtk_widget_show(item);
 	gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
-#endif
 
 	return menu;
 }
common/bluetooth-device-selection.c +12 -3
diff -rupN bluez-gnome-0.27.orig/common/bluetooth-device-selection.c bluez-gnome-0.27/common/bluetooth-device-selection.c
@@ -90,6 +90,15 @@ bluetooth_device_category_to_string (int
 	}
 }
 
+static int
+int_log2(int v)
+{
+	unsigned rv = 0;
+	while (v >>= 1)
+	  rv++;
+	return rv;
+}
+
 static void
 name_to_text (GtkTreeViewColumn *column, GtkCellRenderer *cell,
 	      GtkTreeModel *model, GtkTreeIter *iter, gpointer data)
@@ -591,7 +600,7 @@ bluetooth_device_selection_init(Bluetoot
 	}
 	g_signal_connect (G_OBJECT (priv->device_type), "changed",
 			  G_CALLBACK(filter_type_changed_cb), self);
-	gtk_combo_box_set_active (GTK_COMBO_BOX(priv->device_type), priv->device_type_filter);
+	gtk_combo_box_set_active (GTK_COMBO_BOX(priv->device_type), int_log2(priv->device_type_filter));
 	if (priv->show_device_type) {
 		gtk_widget_show (priv->device_type_label);
 		gtk_widget_show (priv->device_type);
@@ -665,7 +674,7 @@ bluetooth_device_selection_set_property 
 		break;
 	case PROP_DEVICE_TYPE_FILTER:
 		priv->device_type_filter = g_value_get_int (value);
-		gtk_combo_box_set_active (GTK_COMBO_BOX(priv->device_type), priv->device_type_filter >> 1);
+		gtk_combo_box_set_active (GTK_COMBO_BOX(priv->device_type), int_log2(priv->device_type_filter));
 		break;
 	case PROP_DEVICE_CATEGORY_FILTER:
 		priv->device_category_filter = g_value_get_int (value);
@@ -751,7 +760,7 @@ bluetooth_device_selection_class_init (B
 											  NULL, NULL, TRUE, G_PARAM_READWRITE));
 	g_object_class_install_property (G_OBJECT_CLASS(klass),
 					 PROP_DEVICE_TYPE_FILTER, g_param_spec_int ("device-type-filter", NULL, NULL,
-										    0, BLUETOOTH_TYPE_NUM_TYPES, 0, G_PARAM_READWRITE));
+										    1, 1 << (BLUETOOTH_TYPE_NUM_TYPES-1), 1, G_PARAM_READWRITE));
 	g_object_class_install_property (G_OBJECT_CLASS(klass),
 					 PROP_DEVICE_CATEGORY_FILTER, g_param_spec_int ("device-category-filter", NULL, NULL,
 					 						0, BLUETOOTH_CATEGORY_NUM_CATEGORIES, 0, G_PARAM_READWRITE));
common/client.c +258 -31

377 lines not on this page · raw message

common/client.h +24 -4
diff -rupN bluez-gnome-0.27.orig/common/client.h bluez-gnome-0.27/common/client.h
@@ -99,14 +99,34 @@ const gchar *bluetooth_type_to_string(gu
 gboolean bluetooth_client_register_passkey_agent(BluetoothClient *self,
 		const char *path, const char *address, const void *info);
 
-gboolean bluetooth_client_create_bonding(BluetoothClient *self,
+typedef void (*bluetooth_client_call_reply) (GError *error, gpointer data);
+
+int bluetooth_client_available_services(BluetoothClient *self);
+
+gboolean bluetooth_client_cancel_call(BluetoothClient *self,
 					gchar *adapter, const gchar *address);
+gboolean bluetooth_client_connect(BluetoothClient *self, guint type, // set to non-ANY to force a certain type connection -- useful for dumb devices
+					gchar *adapter, const gchar *address,
+					bluetooth_client_call_reply callback,
+					gpointer data);
+gboolean bluetooth_client_create_bonding(BluetoothClient *self,
+					gchar *adapter, const gchar *address,
+					bluetooth_client_call_reply callback,
+					gpointer data);
 gboolean bluetooth_client_remove_bonding(BluetoothClient *self,
-					gchar *adapter, const gchar *address);
+					gchar *adapter, const gchar *address,
+					bluetooth_client_call_reply callback,
+					gpointer data);
 gboolean bluetooth_client_set_trusted(BluetoothClient *self,
-					gchar *adapter, const gchar *address);
+					gchar *adapter, const gchar *address,
+					bluetooth_client_call_reply callback,
+					gpointer data);
 gboolean bluetooth_client_remove_trust(BluetoothClient *self,
-					gchar *adapter, const gchar *address);
+					gchar *adapter, const gchar *address,
+					bluetooth_client_call_reply callback,
+					gpointer data);
+
+const gchar *bluetooth_client_get_name(BluetoothClient *self, const gchar *adapter);
 
 gboolean bluetooth_client_disconnect(BluetoothClient *self,
 					gchar *adapter, const gchar *address);
common/dbus.xml +16 -0
diff -rupN bluez-gnome-0.27.orig/common/dbus.xml bluez-gnome-0.27/common/dbus.xml
@@ -98,4 +98,20 @@
       <arg type="s" name="address"/>
     </method>
   </interface>
+  
+  <interface name="input">
+    <method name="CreateSecureDevice">
+      <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+      <arg type="s" name="address"/>
+      <arg type="s" direction="out"/>
+    </method>
+  </interface>
+
+  <interface name="audio">
+    <method name="CreateHeadset">
+      <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+      <arg type="s" name="address"/>
+      <arg type="s" direction="out"/>
+    </method>
+  </interface>
 </node>
properties/adapter.c +3 -3
diff -rupN bluez-gnome-0.27.orig/properties/adapter.c bluez-gnome-0.27/properties/adapter.c
@@ -317,7 +317,7 @@ static void delete_callback(GtkWidget *b
 	gtk_tree_model_get(model, &iter, COLUMN_ADDRESS, &address, -1);
 
 	if (show_confirm_dialog() == TRUE)
-		bluetooth_client_remove_bonding(client, adapter->path, address);
+		bluetooth_client_remove_bonding(client, adapter->path, address, NULL, NULL);
 
 	g_free(address);
 }
@@ -338,9 +338,9 @@ static void trusted_callback(GtkWidget *
 					COLUMN_TRUSTED, &trusted, -1);
 
 	if (trusted == FALSE)
-		bluetooth_client_set_trusted(client, adapter->path, address);
+		bluetooth_client_set_trusted(client, adapter->path, address, NULL, NULL);
 	else
-		bluetooth_client_remove_trust(client, adapter->path, address);
+		bluetooth_client_remove_trust(client, adapter->path, address, NULL, NULL);
 
 	g_free(address);
 }
wizard/agent.c +504 -0

504 lines not on this page · raw message

wizard/agent.h +30 -0
diff -rupN bluez-gnome-0.27.orig/wizard/agent.h bluez-gnome-0.27/wizard/agent.h
@@ -0,0 +1,30 @@
+/*
+ *
+ *  BlueZ - Bluetooth protocol stack for Linux
+ *
+ *  Copyright (C) 2005-2008  Marcel Holtmann <[email protected]>
+ *  Copyright (C) 2006-2007  Bastien Nocera <[email protected]>
+ *
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ */
+
+#include <gtk/gtk.h>
+#include "client.h"
+
+void set_agent_parent_window(GtkWidget *window);
+int register_agent(BluetoothClient *client, const char *path, const char *address);
+
wizard/main.c +132 -95

344 lines not on this page · raw message

wizard/Makefile.am +3 -3
diff -rupN bluez-gnome-0.27.orig/wizard/Makefile.am bluez-gnome-0.27/wizard/Makefile.am
@@ -1,7 +1,7 @@
 
-noinst_PROGRAMS = bluetooth-wizard
+bin_PROGRAMS = bluetooth-wizard
 
-bluetooth_wizard_SOURCES = main.c
+bluetooth_wizard_SOURCES = main.c agent.c agent.h
 
 bluetooth_wizard_LDADD = @GTK_LIBS@ @DBUS_LIBS@ \
 		$(top_builddir)/common/libcommon.a
@@ -13,7 +13,7 @@ AM_CFLAGS = @DBUS_CFLAGS@ @GTK_CFLAGS@
 
 INCLUDES = -I$(top_srcdir)/common -I$(top_builddir)/common
 
-noinst_MANS = bluetooth-wizard.1
+man_MANS = bluetooth-wizard.1
 
 EXTRA_DIST = $(noinst_MANS)
 

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php

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

#2 lore raw
In reply to Michael Terry

Is this version working against the old DBus interface, the new, experimental interface, or does it matter?

DS
----- Original Message -----
From: "Michael Terry" <[email protected]>
To: <[email protected]>
Sent: Friday, June 27, 2008 2:05 PM
Subject: [Bluez-devel] Wizard patch

Hello, all!

I have attached a patch against 0.27 (it applies cleanly against CVS) to complete the wizard in the bluez-gnome source tree.

Here's what my patch does in summary, details below:
Wizard dialog shows list of device types we know how to handle (only mouse/keyboard/headset right now). Then, it tries to connect to the appropriate bluetooth dbus service and trust the device. Basically the same code steps the Properties -> Services tab does, but more wizardy. :)

I made changes to cleanup the wizard interface (removed a couple of pages that had low signal/noise ratio) and made several of the bluetooth_client capable of giving feedback about the operation via a callback.

Details of changes:

applet/main.c:
Uncomments code to add a menu item for the wizard.

common/bluetooth-device-selection.c:
Fixes broken code to set current filter programmatically.

common/client.[ch]:
setup_services():
Note presence of audio and input services on startup

bluetooth_client_get_name():
Gets user-visible device name for a path

bluetooth_client_available_services():
Returns a mask of the device types supported by services the client knows about. Not actually used by the rest of my code, but it seemed possibly useful to one day not show unsupported device types in the wizard if we wanted to.

bluetooth_client_cancel_call():
Cancels an async call for a particular adapter/address combo. This is slightly janky because it only allows for one call at a time per pair, but that's all that we ever need right now.

connect_to_service():
Handles service-specific calls to initiate a device connection. Stuff like CreateSecureDevice or CreateHeadset.

bluetooth_client_connect():
Kicks off a call to connect_to_service

bluetooth_client_create_bonding():
bluetooth_client_remove_bonding():
bluetooth_client_set_trusted():
bluetooth_client_remove_trust():
Modified to allow callbacks

common/dbus.xml:
Add input.CreateSecureDevice and audio.CreateHeadset

properties/adapter.c:
Update a few calls to client functions do to above prototype changes

wizard/agent.[ch]:
Mostly a copy of applet/agent.c, except:
it only holds passkey code (no auth code)
it shows dialogs immediately wrt a parent window

wizard/main.c:
Comment out intro and info pages -- I think the intro page just gets in the user's way and there was no content in info page, and even if there was, it would probably also just get in user's way.

I added a pulsing progress bar to the pairing page to give some feedback.

I changed wording from 'setup' and 'pair' to 'connect'. I figure that is more user-friendly (since no real setting up is done by user and they probably think in terms of connecting to devices not pairing with them).

Pairing process is two-step: bluetooth_client_connect followed by bluetooth_client_set_trusted.

Show an error if either step fails.

Connect to agent code to display a password prompt immediately in front of user instead of via bluetooth applet.

wizard/Makefile.am:
Install bluetooth-wizard and add agent.[ch]

Thanks!
-mt

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

#3 lore raw
Quoted 1 line · David Stockwell

Is this version working against the old DBus interface, the new, experimental interface, or does it matter?

The old DBus interface. I don't know about the new interface.

It shouldn't matter much. The important stuff was UI changes. The new dbus stuff was added in common/client, so if and when that gets ported to our new interface overlords, my changes will too.

-mt

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php

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

maintainer
#4 lore raw

Hi Michael,

Quoted 7 lines
Quoted 1 line

Is this version working against the old DBus interface, the new, experimental interface, or does it matter?

The old DBus interface. I don't know about the new interface.

It shouldn't matter much. The important stuff was UI changes. The new dbus stuff was added in common/client, so if and when that gets ported to our new interface overlords, my changes will too.

it is not that simple, but I will look into that at some point.

Regards

Marcel

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

maintainer
#5 lore raw
In reply to Michael Terry

Hi Michael,

Quoted 10 lines

I have attached a patch against 0.27 (it applies cleanly against CVS) to complete the wizard in the bluez-gnome source tree.

Here's what my patch does in summary, details below:
Wizard dialog shows list of device types we know how to handle (only mouse/keyboard/headset right now). Then, it tries to connect to the appropriate bluetooth dbus service and trust the device. Basically the same code steps the Properties -> Services tab does, but more wizardy. :)

Quoted 4 lines

I made changes to cleanup the wizard interface (removed a couple of pages that had low signal/noise ratio) and made several of the bluetooth_client capable of giving feedback about the operation via a callback.

looks nice. However you have to break this up into pieces for. Sent small patches and I can quickly review and commit them.

Regards

Marcel

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

#6 lore raw

Hi, Marcel!

Quoted 2 lines · Marcel Holtmann

looks nice. However you have to break this up into pieces for. Sent small patches and I can quickly review and commit them.

Here's one such piece of my wizard patch. It simply fixes the "device-type-filter" property to do something reasonable when set (namely, you give it a BLUETOOTH_TYPE and it sets the right index in the combo).

More patches coming.

-mt

common/bluetooth-device-selection.c +12 -3
diff -rupN bluez-gnome-0.27.orig/common/bluetooth-device-selection.c bluez-gnome-0.27/common/bluetooth-device-selection.c
@@ -90,6 +90,15 @@ bluetooth_device_category_to_string (int
 	}
 }
 
+static int
+int_log2(int v)
+{
+	unsigned rv = 0;
+	while (v >>= 1)
+	  rv++;
+	return rv;
+}
+
 static void
 name_to_text (GtkTreeViewColumn *column, GtkCellRenderer *cell,
 	      GtkTreeModel *model, GtkTreeIter *iter, gpointer data)
@@ -591,7 +600,7 @@ bluetooth_device_selection_init(Bluetoot
 	}
 	g_signal_connect (G_OBJECT (priv->device_type), "changed",
 			  G_CALLBACK(filter_type_changed_cb), self);
-	gtk_combo_box_set_active (GTK_COMBO_BOX(priv->device_type), priv->device_type_filter);
+	gtk_combo_box_set_active (GTK_COMBO_BOX(priv->device_type), int_log2(priv->device_type_filter));
 	if (priv->show_device_type) {
 		gtk_widget_show (priv->device_type_label);
 		gtk_widget_show (priv->device_type);
@@ -665,7 +674,7 @@ bluetooth_device_selection_set_property 
 		break;
 	case PROP_DEVICE_TYPE_FILTER:
 		priv->device_type_filter = g_value_get_int (value);
-		gtk_combo_box_set_active (GTK_COMBO_BOX(priv->device_type), priv->device_type_filter >> 1);
+		gtk_combo_box_set_active (GTK_COMBO_BOX(priv->device_type), int_log2(priv->device_type_filter));
 		break;
 	case PROP_DEVICE_CATEGORY_FILTER:
 		priv->device_category_filter = g_value_get_int (value);
@@ -751,7 +760,7 @@ bluetooth_device_selection_class_init (B
 											  NULL, NULL, TRUE, G_PARAM_READWRITE));
 	g_object_class_install_property (G_OBJECT_CLASS(klass),
 					 PROP_DEVICE_TYPE_FILTER, g_param_spec_int ("device-type-filter", NULL, NULL,
-										    0, BLUETOOTH_TYPE_NUM_TYPES, 0, G_PARAM_READWRITE));
+										    1, 1 << (BLUETOOTH_TYPE_NUM_TYPES-1), 1, G_PARAM_READWRITE));
 	g_object_class_install_property (G_OBJECT_CLASS(klass),
 					 PROP_DEVICE_CATEGORY_FILTER, g_param_spec_int ("device-category-filter", NULL, NULL,
 					 						0, BLUETOOTH_CATEGORY_NUM_CATEGORIES, 0, G_PARAM_READWRITE));

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php

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

maintainer
#7 lore raw

Hi Michael,

Quoted 5 lines · Marcel Holtmann
Quoted 2 lines

looks nice. However you have to break this up into pieces for. Sent small patches and I can quickly review and commit them.

Here's one such piece of my wizard patch. It simply fixes the "device-type-filter" property to do something reasonable when set (namely, you give it a BLUETOOTH_TYPE and it sets the right index in the combo).

please use the coding style that is present in the file you are working on. This includes whitespaces and indentation.

Quoted 1 line

More patches coming.

Send them over.

Regards

Marcel

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

#8 lore raw
Quoted 3 lines · Marcel Holtmann

please use the coding style that is present in the file you are working
on. This includes whitespaces and indentation.

Sure. I thought I did, but I missed a tab, which is what I assume you were referring to?

Tab-complete patch attached.

-mt

Index: common/bluetooth-device-selection.c
===================================================================
RCS file: /cvsroot/bluez/gnome/common/bluetooth-device-selection.c,v retrieving revision 1.23

bluetooth-device-selection.c +12 -3
diff -u -p -r1.23 bluetooth-device-selection.c
@@ -91,6 +91,15 @@ bluetooth_device_category_to_string (int
 	}
 }
 
+static int
+int_log2(int v)
+{
+	int rv = 0;
+	while (v >>= 1)
+		rv++;
+	return rv;
+}
+
 static void
 name_to_text (GtkTreeViewColumn *column, GtkCellRenderer *cell,
 	      GtkTreeModel *model, GtkTreeIter *iter, gpointer data)
@@ -609,7 +618,7 @@ bluetooth_device_selection_init(Bluetoot
 	}
 	g_signal_connect (G_OBJECT (priv->device_type), "changed",
 			  G_CALLBACK(filter_type_changed_cb), self);
-	gtk_combo_box_set_active (GTK_COMBO_BOX(priv->device_type), priv->device_type_filter);
+	gtk_combo_box_set_active (GTK_COMBO_BOX(priv->device_type), int_log2(priv->device_type_filter));
 	if (priv->show_device_type) {
 		gtk_widget_show (priv->device_type_label);
 		gtk_widget_show (priv->device_type);
@@ -696,7 +705,7 @@ bluetooth_device_selection_set_property 
 		break;
 	case PROP_DEVICE_TYPE_FILTER:
 		priv->device_type_filter = g_value_get_int (value);
-		gtk_combo_box_set_active (GTK_COMBO_BOX(priv->device_type), priv->device_type_filter >> 1);
+		gtk_combo_box_set_active (GTK_COMBO_BOX(priv->device_type), int_log2(priv->device_type_filter));
 		break;
 	case PROP_DEVICE_CATEGORY_FILTER:
 		priv->device_category_filter = g_value_get_int (value);
@@ -788,7 +797,7 @@ bluetooth_device_selection_class_init (B
 											  NULL, NULL, TRUE, G_PARAM_READWRITE));
 	g_object_class_install_property (G_OBJECT_CLASS(klass),
 					 PROP_DEVICE_TYPE_FILTER, g_param_spec_int ("device-type-filter", NULL, NULL,
-										    0, BLUETOOTH_TYPE_NUM_TYPES, 0, G_PARAM_READWRITE));
+										    1, 1 << (BLUETOOTH_TYPE_NUM_TYPES-1), 1, G_PARAM_READWRITE));
 	g_object_class_install_property (G_OBJECT_CLASS(klass),
 					 PROP_DEVICE_CATEGORY_FILTER, g_param_spec_int ("device-category-filter", NULL, NULL,
 					 						0, BLUETOOTH_CATEGORY_NUM_CATEGORIES, 0, G_PARAM_READWRITE));

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php

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

maintainer
#9 lore raw

Hi Michael,

Quoted 8 lines
Quoted 3 lines

please use the coding style that is present in the file you are working
on. This includes whitespaces and indentation.

Sure. I thought I did, but I missed a tab, which is what I assume you were referring to?

Tab-complete patch attached.

there was one SOMETHING-1 where you should have done SOMETHING - 1. I fixed that and the patch has been committed.

Regards

Marcel

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

#10 lore raw
In reply to Marcel Holtmann
Quoted 2 lines · Marcel Holtmann

looks nice. However you have to break this up into pieces for. Sent small patches and I can quickly review and commit them.

Here's a patch to add callback support to many of the common/client calls.

It also adds a new function: bluetooth_client_cancel_call(). This cancels the last client call made for the given adapter/address.

Admittedly, it would be fancier if, for example, bluetooth_client_create_bonding() gave back a handle which could be used to cancel its call, rather than just keeping track of the last one.

But the cancel-last-call style was simpler and sufficient for the wizard's purposes and presumably sufficient for others' purposes (by virtue of the lack of canceling before).

-mt

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

client.c +100 -33
diff -u -p -r1.44 client.c
@@ -1112,14 +1112,29 @@ gboolean bluetooth_client_register_passk
 	return TRUE;
 }
 
-static void create_bonding_reply(DBusGProxy *proxy,
+static void call_reply(DBusGProxy *proxy,
 					GError *error, gpointer userdata)
 {
-	//g_printf("create bonding reply\n");
+	DBusGAsyncData *data = (DBusGAsyncData*) userdata;
+	g_object_set_data(G_OBJECT(proxy), "call", NULL);
+	if (data) {
+		(*(bluetooth_client_call_reply)data->cb) (error, data->userdata);
+		g_free(data);
+	}
+	if (error)
+		g_error_free(error);
+}
+
+static void call_reply_s(DBusGProxy *proxy, char *s,
+					GError *error, gpointer userdata)
+{
+	call_reply(proxy, error, userdata);
 }
 
 gboolean bluetooth_client_create_bonding(BluetoothClient *client,
-					gchar *adapter, const gchar *address)
+					gchar *adapter, const gchar *address,
+					bluetooth_client_call_reply callback,
+					gpointer userdata)
 {
 	BluetoothClientPrivate *priv = BLUETOOTH_CLIENT_GET_PRIVATE(client);
 	GtkTreeIter iter;
@@ -1142,9 +1157,15 @@ gboolean bluetooth_client_create_bonding
 						COLUMN_OBJECT, &object, -1);
 
 		if (g_ascii_strcasecmp(path, adapter) == 0) {
-			adapter_create_bonding_async(object, address,
-						create_bonding_reply, NULL);
-			return TRUE;
+			DBusGProxyCall *call;
+			DBusGAsyncData *stuff;
+			stuff = g_new (DBusGAsyncData, 1);
+			stuff->cb = G_CALLBACK (callback);
+			stuff->userdata = userdata;
+			call = adapter_create_bonding_async(object, address,
+						call_reply, stuff);
+			g_object_set_data(G_OBJECT(object), "call", call);
+			return call != NULL;
 		}
 
 		cont = gtk_tree_model_iter_next(GTK_TREE_MODEL(priv->store), &iter);
@@ -1153,14 +1174,10 @@ gboolean bluetooth_client_create_bonding
 	return FALSE;
 }
 
-static void remove_bonding_reply(DBusGProxy *proxy,
-					GError *error, gpointer userdata)
-{
-	//g_printf("remove bonding reply\n");
-}
-
 gboolean bluetooth_client_remove_bonding(BluetoothClient *client,
-					gchar *adapter, const gchar *address)
+					gchar *adapter, const gchar *address,
+					bluetooth_client_call_reply callback,
+					gpointer userdata)
 {
 	BluetoothClientPrivate *priv = BLUETOOTH_CLIENT_GET_PRIVATE(client);
 	GtkTreeIter iter;
@@ -1183,8 +1200,14 @@ gboolean bluetooth_client_remove_bonding
 						COLUMN_OBJECT, &object, -1);
 
 		if (g_ascii_strcasecmp(path, adapter) == 0) {
-			adapter_remove_bonding_async(object, address,
-						remove_bonding_reply, NULL);
+			DBusGProxyCall *call;
+			DBusGAsyncData *stuff;
+			stuff = g_new (DBusGAsyncData, 1);
+			stuff->cb = G_CALLBACK (callback);
+			stuff->userdata = userdata;
+			call = adapter_remove_bonding_async(object, address,
+						call_reply, stuff);
+			g_object_set_data(G_OBJECT(object), "call", call);
 			return TRUE;
 		}
 
@@ -1194,14 +1217,10 @@ gboolean bluetooth_client_remove_bonding
 	return FALSE;
 }
 
-static void set_trusted_reply(DBusGProxy *proxy,
-					GError *error, gpointer userdata)
-{
-	//g_printf("set trusted reply\n");
-}
-
 gboolean bluetooth_client_set_trusted(BluetoothClient *client,
-					gchar *adapter, const gchar *address)
+					gchar *adapter, const gchar *address,
+					bluetooth_client_call_reply callback,
+					gpointer userdata)
 {
 	BluetoothClientPrivate *priv = BLUETOOTH_CLIENT_GET_PRIVATE(client);
 	GtkTreeIter iter;
@@ -1224,8 +1243,14 @@ gboolean bluetooth_client_set_trusted(Bl
 						COLUMN_OBJECT, &object, -1);
 
 		if (g_ascii_strcasecmp(path, adapter) == 0) {
-			adapter_set_trusted_async(object, address,
-						set_trusted_reply, NULL);
+			DBusGProxyCall *call;
+			DBusGAsyncData *stuff;
+			stuff = g_new (DBusGAsyncData, 1);
+			stuff->cb = G_CALLBACK (callback);
+			stuff->userdata = userdata;
+			call = adapter_set_trusted_async(object, address,
+						call_reply, stuff);
+			g_object_set_data(G_OBJECT(object), "call", call);
 			return TRUE;
 		}
 
@@ -1235,14 +1260,10 @@ gboolean bluetooth_client_set_trusted(Bl
 	return FALSE;
 }
 
-static void remove_trust_reply(DBusGProxy *proxy,
-					GError *error, gpointer userdata)
-{
-	//g_printf("remove trust reply\n");
-}
-
 gboolean bluetooth_client_remove_trust(BluetoothClient *client,
-					gchar *adapter, const gchar *address)
+					gchar *adapter, const gchar *address,
+					bluetooth_client_call_reply callback,
+					gpointer userdata)
 {
 	BluetoothClientPrivate *priv = BLUETOOTH_CLIENT_GET_PRIVATE(client);
 	GtkTreeIter iter;
@@ -1265,8 +1286,14 @@ gboolean bluetooth_client_remove_trust(B
 						COLUMN_OBJECT, &object, -1);
 
 		if (g_ascii_strcasecmp(path, adapter) == 0) {
-			adapter_remove_trust_async(object, address,
-						remove_trust_reply, NULL);
+			DBusGProxyCall *call;
+			DBusGAsyncData *stuff;
+			stuff = g_new (DBusGAsyncData, 1);
+			stuff->cb = G_CALLBACK (callback);
+			stuff->userdata = userdata;
+			call = adapter_remove_trust_async(object, address,
+						call_reply, stuff);
+			g_object_set_data(G_OBJECT(object), "call", call);
 			return TRUE;
 		}
 
@@ -1386,6 +1413,46 @@ gboolean bluetooth_client_cancel_discove
 	return FALSE;
 }
 
+gboolean bluetooth_client_cancel_call(BluetoothClient *client,
+					gchar *adapter, const gchar *address)
+{
+	BluetoothClientPrivate *priv = BLUETOOTH_CLIENT_GET_PRIVATE(client);
+	GtkTreeIter iter;
+	gboolean cont;
+
+	if (adapter == NULL)
+		adapter = priv->default_adapter;
+
+	if (adapter == NULL)
+		return FALSE;
+
+	cont = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(priv->store), &iter);
+
+	while (cont == TRUE) {
+		DBusGProxy *object;
+		gchar *path;
+
+		gtk_tree_model_get(GTK_TREE_MODEL(priv->store), &iter,
+						COLUMN_PATH, &path,
+						COLUMN_OBJECT, &object, -1);
+
+		if (g_ascii_strcasecmp(path, adapter) == 0) {
+			DBusGProxyCall *call;
+			call = (DBusGProxyCall *)g_object_get_data(G_OBJECT(object), "call");
+			if (call != NULL) {
+				dbus_g_proxy_cancel_call(object, call);
+				g_object_set_data(G_OBJECT(object), "call", NULL);
+				return TRUE;
+			}
+			return FALSE;
+		}
+
+		cont = gtk_tree_model_iter_next(GTK_TREE_MODEL(priv->store), &iter);
+	}
+
+	return FALSE;
+}
+
 GtkTreeModel *bluetooth_client_get_model(BluetoothClient *client)
 {
 	BluetoothClientPrivate *priv = BLUETOOTH_CLIENT_GET_PRIVATE(client);

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

client.h +16 -4
diff -u -p -r1.24 client.h
@@ -99,14 +99,26 @@ const gchar *bluetooth_type_to_string(gu
 gboolean bluetooth_client_register_passkey_agent(BluetoothClient *self,
 		const char *path, const char *address, const void *info);
 
-gboolean bluetooth_client_create_bonding(BluetoothClient *self,
+typedef void (*bluetooth_client_call_reply) (GError *error, gpointer data);
+
+gboolean bluetooth_client_cancel_call(BluetoothClient *self,
 					gchar *adapter, const gchar *address);
+gboolean bluetooth_client_create_bonding(BluetoothClient *self,
+					gchar *adapter, const gchar *address,
+					bluetooth_client_call_reply callback,
+					gpointer data);
 gboolean bluetooth_client_remove_bonding(BluetoothClient *self,
-					gchar *adapter, const gchar *address);
+					gchar *adapter, const gchar *address,
+					bluetooth_client_call_reply callback,
+					gpointer data);
 gboolean bluetooth_client_set_trusted(BluetoothClient *self,
-					gchar *adapter, const gchar *address);
+					gchar *adapter, const gchar *address,
+					bluetooth_client_call_reply callback,
+					gpointer data);
 gboolean bluetooth_client_remove_trust(BluetoothClient *self,
-					gchar *adapter, const gchar *address);
+					gchar *adapter, const gchar *address,
+					bluetooth_client_call_reply callback,
+					gpointer data);
 
 gboolean bluetooth_client_disconnect(BluetoothClient *self,
 					gchar *adapter, const gchar *address);

Index: properties/adapter.c
===================================================================
RCS file: /cvsroot/bluez/gnome/properties/adapter.c,v retrieving revision 1.22

adapter.c +3 -3
diff -u -p -r1.22 adapter.c
@@ -317,7 +317,7 @@ static void delete_callback(GtkWidget *b
 	gtk_tree_model_get(model, &iter, COLUMN_ADDRESS, &address, -1);
 
 	if (show_confirm_dialog() == TRUE)
-		bluetooth_client_remove_bonding(client, adapter->path, address);
+		bluetooth_client_remove_bonding(client, adapter->path, address, NULL, NULL);
 
 	g_free(address);
 }
@@ -338,9 +338,9 @@ static void trusted_callback(GtkWidget *
 					COLUMN_TRUSTED, &trusted, -1);
 
 	if (trusted == FALSE)
-		bluetooth_client_set_trusted(client, adapter->path, address);
+		bluetooth_client_set_trusted(client, adapter->path, address, NULL, NULL);
 	else
-		bluetooth_client_remove_trust(client, adapter->path, address);
+		bluetooth_client_remove_trust(client, adapter->path, address, NULL, NULL);
 
 	g_free(address);
 }

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php

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

maintainer
#11 lore raw

Hi Michael,

Quoted 6 lines
Quoted 2 lines

looks nice. However you have to break this up into pieces for. Sent small patches and I can quickly review and commit them.

Here's a patch to add callback support to many of the common/client calls.

Quoted 6 lines

It also adds a new function: bluetooth_client_cancel_call(). This cancels the last client call made for the given adapter/address.

Admittedly, it would be fancier if, for example, bluetooth_client_create_bonding() gave back a handle which could be used to cancel its call, rather than just keeping track of the last one.

it only makes sense for the create bonding call, because the others can't really be canceled. So my proposal is to leave the others out of this change and implement create_bonding and cancel_bonding.

Regards

Marcel

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

#12 lore raw
Quoted 2 lines · Marcel Holtmann
Quoted 2 lines

It also adds a new function: bluetooth_client_cancel_call(). This cancels the last client call made for the given adapter/address.

[snip]

Quoted 3 lines

it only makes sense for the create bonding call, because the others can't really be canceled. So my proposal is to leave the others out of this change and implement create_bonding and cancel_bonding.

Except that one of my other patches adds a new cancelable function _connect(). So we would need maybe specific cancel_bonding and cancel_connect functions.

But why can't the others be canceled? Just on the assumption that the DBus communication will be so fast as to not really allow time for canceling? Or that by the time you send the message, it's all said and done anyway? I don't understand the nitty gritty details of dbus async communication.

I figured that as a matter of principle, if you have an async API like this, it ought to allow for canceling because the very nature of async suggests a period of time in which your program is doing other things, one of which could conceivably trigger a cancel.

But I agree it's largely a moot case for something like _remove_trust(). I just figured it would be cleaner to do the set of them.

-mt

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php

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

maintainer
#13 lore raw

Hi Michael,

Quoted 10 lines
Quoted 2 lines
Quoted 2 lines

It also adds a new function: bluetooth_client_cancel_call(). This cancels the last client call made for the given adapter/address.

[snip]

Quoted 3 lines

it only makes sense for the create bonding call, because the others can't really be canceled. So my proposal is to leave the others out of this change and implement create_bonding and cancel_bonding.

Except that one of my other patches adds a new cancelable function _connect(). So we would need maybe specific cancel_bonding and cancel_connect functions.

sounds good to me. The bonding case is special since it can only do one at a time.

Quoted 10 lines

But why can't the others be canceled? Just on the assumption that the DBus communication will be so fast as to not really allow time for canceling? Or that by the time you send the message, it's all said and done anyway? I don't understand the nitty gritty details of dbus async communication.

I figured that as a matter of principle, if you have an async API like this, it ought to allow for canceling because the very nature of async suggests a period of time in which your program is doing other things, one of which could conceivably trigger a cancel.

It will give you no advantage whatsoever. So not worth it.

Regards

Marcel

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

#14 lore raw
Quoted 6 lines · Marcel Holtmann
Quoted 3 lines

Except that one of my other patches adds a new cancelable function _connect(). So we would need maybe specific cancel_bonding and cancel_connect functions.

sounds good to me. The bonding case is special since it can only do one at a time.

OK, attached is callback2.diff, which only allows canceling a create_bonding call. Updated other patches to follow.

-mt

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

client.c +99 -35
diff -u -p -r1.44 client.c
@@ -1112,14 +1112,29 @@ gboolean bluetooth_client_register_passk
 	return TRUE;
 }
 
+static void call_reply(DBusGProxy *proxy,
+					GError *error, gpointer userdata)
+{
+	DBusGAsyncData *data = (DBusGAsyncData*) userdata;
+	if (data) {
+		(*(bluetooth_client_call_reply)data->cb) (error, data->userdata);
+		g_free(data);
+	}
+	if (error)
+		g_error_free(error);
+}
+
 static void create_bonding_reply(DBusGProxy *proxy,
 					GError *error, gpointer userdata)
 {
-	//g_printf("create bonding reply\n");
+	g_object_set_data(G_OBJECT(proxy), "bonding-call", NULL);
+	call_reply(proxy, error, userdata);
 }
 
 gboolean bluetooth_client_create_bonding(BluetoothClient *client,
-					gchar *adapter, const gchar *address)
+					gchar *adapter, const gchar *address,
+					bluetooth_client_call_reply callback,
+					gpointer userdata)
 {
 	BluetoothClientPrivate *priv = BLUETOOTH_CLIENT_GET_PRIVATE(client);
 	GtkTreeIter iter;
@@ -1142,9 +1157,15 @@ gboolean bluetooth_client_create_bonding
 						COLUMN_OBJECT, &object, -1);
 
 		if (g_ascii_strcasecmp(path, adapter) == 0) {
-			adapter_create_bonding_async(object, address,
-						create_bonding_reply, NULL);
-			return TRUE;
+			DBusGProxyCall *call;
+			DBusGAsyncData *stuff;
+			stuff = g_new (DBusGAsyncData, 1);
+			stuff->cb = G_CALLBACK (callback);
+			stuff->userdata = userdata;
+			call = adapter_create_bonding_async(object, address,
+						create_bonding_reply, stuff);
+			g_object_set_data(G_OBJECT(object), "bonding-call", call);
+			return call != NULL;
 		}
 
 		cont = gtk_tree_model_iter_next(GTK_TREE_MODEL(priv->store), &iter);
@@ -1153,14 +1174,10 @@ gboolean bluetooth_client_create_bonding
 	return FALSE;
 }
 
-static void remove_bonding_reply(DBusGProxy *proxy,
-					GError *error, gpointer userdata)
-{
-	//g_printf("remove bonding reply\n");
-}
-
 gboolean bluetooth_client_remove_bonding(BluetoothClient *client,
-					gchar *adapter, const gchar *address)
+					gchar *adapter, const gchar *address,
+					bluetooth_client_call_reply callback,
+					gpointer userdata)
 {
 	BluetoothClientPrivate *priv = BLUETOOTH_CLIENT_GET_PRIVATE(client);
 	GtkTreeIter iter;
@@ -1183,9 +1200,14 @@ gboolean bluetooth_client_remove_bonding
 						COLUMN_OBJECT, &object, -1);
 
 		if (g_ascii_strcasecmp(path, adapter) == 0) {
-			adapter_remove_bonding_async(object, address,
-						remove_bonding_reply, NULL);
-			return TRUE;
+			DBusGProxyCall *call;
+			DBusGAsyncData *stuff;
+			stuff = g_new (DBusGAsyncData, 1);
+			stuff->cb = G_CALLBACK (callback);
+			stuff->userdata = userdata;
+			call = adapter_remove_bonding_async(object, address,
+						call_reply, stuff);
+			return call != NULL;
 		}
 
 		cont = gtk_tree_model_iter_next(GTK_TREE_MODEL(priv->store), &iter);
@@ -1194,14 +1216,10 @@ gboolean bluetooth_client_remove_bonding
 	return FALSE;
 }
 
-static void set_trusted_reply(DBusGProxy *proxy,
-					GError *error, gpointer userdata)
-{
-	//g_printf("set trusted reply\n");
-}
-
 gboolean bluetooth_client_set_trusted(BluetoothClient *client,
-					gchar *adapter, const gchar *address)
+					gchar *adapter, const gchar *address,
+					bluetooth_client_call_reply callback,
+					gpointer userdata)
 {
 	BluetoothClientPrivate *priv = BLUETOOTH_CLIENT_GET_PRIVATE(client);
 	GtkTreeIter iter;
@@ -1224,9 +1242,14 @@ gboolean bluetooth_client_set_trusted(Bl
 						COLUMN_OBJECT, &object, -1);
 
 		if (g_ascii_strcasecmp(path, adapter) == 0) {
-			adapter_set_trusted_async(object, address,
-						set_trusted_reply, NULL);
-			return TRUE;
+			DBusGProxyCall *call;
+			DBusGAsyncData *stuff;
+			stuff = g_new (DBusGAsyncData, 1);
+			stuff->cb = G_CALLBACK (callback);
+			stuff->userdata = userdata;
+			call = adapter_set_trusted_async(object, address,
+						call_reply, stuff);
+			return call != NULL;
 		}
 
 		cont = gtk_tree_model_iter_next(GTK_TREE_MODEL(priv->store), &iter);
@@ -1235,14 +1258,10 @@ gboolean bluetooth_client_set_trusted(Bl
 	return FALSE;
 }
 
-static void remove_trust_reply(DBusGProxy *proxy,
-					GError *error, gpointer userdata)
-{
-	//g_printf("remove trust reply\n");
-}
-
 gboolean bluetooth_client_remove_trust(BluetoothClient *client,
-					gchar *adapter, const gchar *address)
+					gchar *adapter, const gchar *address,
+					bluetooth_client_call_reply callback,
+					gpointer userdata)
 {
 	BluetoothClientPrivate *priv = BLUETOOTH_CLIENT_GET_PRIVATE(client);
 	GtkTreeIter iter;
@@ -1265,9 +1284,14 @@ gboolean bluetooth_client_remove_trust(B
 						COLUMN_OBJECT, &object, -1);
 
 		if (g_ascii_strcasecmp(path, adapter) == 0) {
-			adapter_remove_trust_async(object, address,
-						remove_trust_reply, NULL);
-			return TRUE;
+			DBusGProxyCall *call;
+			DBusGAsyncData *stuff;
+			stuff = g_new (DBusGAsyncData, 1);
+			stuff->cb = G_CALLBACK (callback);
+			stuff->userdata = userdata;
+			call = adapter_remove_trust_async(object, address,
+						call_reply, stuff);
+			return call != NULL;
 		}
 
 		cont = gtk_tree_model_iter_next(GTK_TREE_MODEL(priv->store), &iter);
@@ -1386,6 +1410,46 @@ gboolean bluetooth_client_cancel_discove
 	return FALSE;
 }
 
+gboolean bluetooth_client_cancel_bonding(BluetoothClient *client,
+					gchar *adapter, const gchar *address)
+{
+	BluetoothClientPrivate *priv = BLUETOOTH_CLIENT_GET_PRIVATE(client);
+	GtkTreeIter iter;
+	gboolean cont;
+
+	if (adapter == NULL)
+		adapter = priv->default_adapter;
+
+	if (adapter == NULL)
+		return FALSE;
+
+	cont = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(priv->store), &iter);
+
+	while (cont == TRUE) {
+		DBusGProxy *object;
+		gchar *path;
+
+		gtk_tree_model_get(GTK_TREE_MODEL(priv->store), &iter,
+						COLUMN_PATH, &path,
+						COLUMN_OBJECT, &object, -1);
+
+		if (g_ascii_strcasecmp(path, adapter) == 0) {
+			DBusGProxyCall *call;
+			call = (DBusGProxyCall *)g_object_get_data(G_OBJECT(object), "bonding-call");
+			if (call != NULL) {
+				dbus_g_proxy_cancel_call(object, call);
+				g_object_set_data(G_OBJECT(object), "bonding-call", NULL);
+				return TRUE;
+			}
+			return FALSE;
+		}
+
+		cont = gtk_tree_model_iter_next(GTK_TREE_MODEL(priv->store), &iter);
+	}
+
+	return FALSE;
+}
+
 GtkTreeModel *bluetooth_client_get_model(BluetoothClient *client)
 {
 	BluetoothClientPrivate *priv = BLUETOOTH_CLIENT_GET_PRIVATE(client);

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

client.h +15 -3
diff -u -p -r1.24 client.h
@@ -99,14 +99,26 @@ const gchar *bluetooth_type_to_string(gu
 gboolean bluetooth_client_register_passkey_agent(BluetoothClient *self,
 		const char *path, const char *address, const void *info);
 
+typedef void (*bluetooth_client_call_reply) (GError *error, gpointer data);
+
 gboolean bluetooth_client_create_bonding(BluetoothClient *self,
+					gchar *adapter, const gchar *address,
+					bluetooth_client_call_reply callback,
+					gpointer data);
+gboolean bluetooth_client_cancel_bonding(BluetoothClient *self,
 					gchar *adapter, const gchar *address);
 gboolean bluetooth_client_remove_bonding(BluetoothClient *self,
-					gchar *adapter, const gchar *address);
+					gchar *adapter, const gchar *address,
+					bluetooth_client_call_reply callback,
+					gpointer data);
 gboolean bluetooth_client_set_trusted(BluetoothClient *self,
-					gchar *adapter, const gchar *address);
+					gchar *adapter, const gchar *address,
+					bluetooth_client_call_reply callback,
+					gpointer data);
 gboolean bluetooth_client_remove_trust(BluetoothClient *self,
-					gchar *adapter, const gchar *address);
+					gchar *adapter, const gchar *address,
+					bluetooth_client_call_reply callback,
+					gpointer data);
 
 gboolean bluetooth_client_disconnect(BluetoothClient *self,
 					gchar *adapter, const gchar *address);

Index: properties/adapter.c
===================================================================
RCS file: /cvsroot/bluez/gnome/properties/adapter.c,v retrieving revision 1.22

adapter.c +3 -3
diff -u -p -r1.22 adapter.c
@@ -317,7 +317,7 @@ static void delete_callback(GtkWidget *b
 	gtk_tree_model_get(model, &iter, COLUMN_ADDRESS, &address, -1);
 
 	if (show_confirm_dialog() == TRUE)
-		bluetooth_client_remove_bonding(client, adapter->path, address);
+		bluetooth_client_remove_bonding(client, adapter->path, address, NULL, NULL);
 
 	g_free(address);
 }
@@ -338,9 +338,9 @@ static void trusted_callback(GtkWidget *
 					COLUMN_TRUSTED, &trusted, -1);
 
 	if (trusted == FALSE)
-		bluetooth_client_set_trusted(client, adapter->path, address);
+		bluetooth_client_set_trusted(client, adapter->path, address, NULL, NULL);
 	else
-		bluetooth_client_remove_trust(client, adapter->path, address);
+		bluetooth_client_remove_trust(client, adapter->path, address, NULL, NULL);
 
 	g_free(address);
 }

Index: wizard/main.c
===================================================================
RCS file: /cvsroot/bluez/gnome/wizard/main.c,v
retrieving revision 1.31

main.c +1 -1
diff -u -p -r1.31 main.c
@@ -120,7 +120,7 @@ static void prepare_callback(GtkWidget *
 					"/org/bluez/applet", address,
 					&dbus_glib_passkey_agent_object_info);
 
-		bluetooth_client_create_bonding(client, NULL, address);
+		bluetooth_client_create_bonding(client, NULL, address, NULL, NULL);
 
 		gtk_label_set_markup(GTK_LABEL(label_pairing), address);
 		gtk_label_set_markup(GTK_LABEL(label_passkey), passkey);

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php

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

maintainer
#15 lore raw

Hi Michael,

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines

Except that one of my other patches adds a new cancelable function _connect(). So we would need maybe specific cancel_bonding and cancel_connect functions.

sounds good to me. The bonding case is special since it can only do one at a time.

OK, attached is callback2.diff, which only allows canceling a create_bonding call. Updated other patches to follow.

please only change create_bonding and leave the others alone. Also you cast a little bit too much for my taste. For example void pointers need to extra cast.

Regards

Marcel

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

#16 lore raw

Hello, Marcel.

Quoted 4 lines · Marcel Holtmann

please only change create_bonding and leave the others alone. Also you cast a little bit too much for my taste. For example void pointers need
to extra cast.

Attached is callback3.diff which only modifies create_bonding.

I'm not sure which casts you felt were unnecessary. I don't think I cast any void pointers.

-mt

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

client.c +60 -5
diff -u -p -r1.44 client.c
@@ -1115,11 +1115,20 @@ gboolean bluetooth_client_register_passk
 static void create_bonding_reply(DBusGProxy *proxy,
 					GError *error, gpointer userdata)
 {
-	//g_printf("create bonding reply\n");
+	DBusGAsyncData *data = (DBusGAsyncData*) userdata;
+	g_object_set_data(G_OBJECT(proxy), "bonding-call", NULL);
+	if (data && data->cb) {
+		(*(bluetooth_client_call_reply)data->cb) (error, data->userdata);
+		g_free(data);
+	}
+	if (error)
+		g_error_free(error);
 }
 
 gboolean bluetooth_client_create_bonding(BluetoothClient *client,
-					gchar *adapter, const gchar *address)
+					gchar *adapter, const gchar *address,
+					bluetooth_client_call_reply callback,
+					gpointer userdata)
 {
 	BluetoothClientPrivate *priv = BLUETOOTH_CLIENT_GET_PRIVATE(client);
 	GtkTreeIter iter;
@@ -1142,9 +1151,15 @@ gboolean bluetooth_client_create_bonding
 						COLUMN_OBJECT, &object, -1);
 
 		if (g_ascii_strcasecmp(path, adapter) == 0) {
-			adapter_create_bonding_async(object, address,
-						create_bonding_reply, NULL);
-			return TRUE;
+			DBusGProxyCall *call;
+			DBusGAsyncData *stuff;
+			stuff = g_new(DBusGAsyncData, 1);
+			stuff->cb = G_CALLBACK(callback);
+			stuff->userdata = userdata;
+			call = adapter_create_bonding_async(object, address,
+						create_bonding_reply, stuff);
+			g_object_set_data(G_OBJECT(object), "bonding-call", call);
+			return call != NULL;
 		}
 
 		cont = gtk_tree_model_iter_next(GTK_TREE_MODEL(priv->store), &iter);
@@ -1386,6 +1401,46 @@ gboolean bluetooth_client_cancel_discove
 	return FALSE;
 }
 
+gboolean bluetooth_client_cancel_bonding(BluetoothClient *client,
+					gchar *adapter, const gchar *address)
+{
+	BluetoothClientPrivate *priv = BLUETOOTH_CLIENT_GET_PRIVATE(client);
+	GtkTreeIter iter;
+	gboolean cont;
+
+	if (adapter == NULL)
+		adapter = priv->default_adapter;
+
+	if (adapter == NULL)
+		return FALSE;
+
+	cont = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(priv->store), &iter);
+
+	while (cont == TRUE) {
+		DBusGProxy *object;
+		gchar *path;
+
+		gtk_tree_model_get(GTK_TREE_MODEL(priv->store), &iter,
+						COLUMN_PATH, &path,
+						COLUMN_OBJECT, &object, -1);
+
+		if (g_ascii_strcasecmp(path, adapter) == 0) {
+			DBusGProxyCall *call;
+			call = (DBusGProxyCall *)g_object_get_data(G_OBJECT(object), "bonding-call");
+			if (call != NULL) {
+				dbus_g_proxy_cancel_call(object, call);
+				g_object_set_data(G_OBJECT(object), "bonding-call", NULL);
+				return TRUE;
+			}
+			return FALSE;
+		}
+
+		cont = gtk_tree_model_iter_next(GTK_TREE_MODEL(priv->store), &iter);
+	}
+
+	return FALSE;
+}
+
 GtkTreeModel *bluetooth_client_get_model(BluetoothClient *client)
 {
 	BluetoothClientPrivate *priv = BLUETOOTH_CLIENT_GET_PRIVATE(client);

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

client.h +6 -0
diff -u -p -r1.24 client.h
@@ -99,7 +99,13 @@ const gchar *bluetooth_type_to_string(gu
 gboolean bluetooth_client_register_passkey_agent(BluetoothClient *self,
 		const char *path, const char *address, const void *info);
 
+typedef void (*bluetooth_client_call_reply) (GError *error, gpointer data);
+
 gboolean bluetooth_client_create_bonding(BluetoothClient *self,
+					gchar *adapter, const gchar *address,
+					bluetooth_client_call_reply callback,
+					gpointer data);
+gboolean bluetooth_client_cancel_bonding(BluetoothClient *self,
 					gchar *adapter, const gchar *address);
 gboolean bluetooth_client_remove_bonding(BluetoothClient *self,
 					gchar *adapter, const gchar *address);

Index: wizard/main.c
===================================================================
RCS file: /cvsroot/bluez/gnome/wizard/main.c,v
retrieving revision 1.31

main.c +1 -1
diff -u -p -r1.31 main.c
@@ -120,7 +120,7 @@ static void prepare_callback(GtkWidget *
 					"/org/bluez/applet", address,
 					&dbus_glib_passkey_agent_object_info);
 
-		bluetooth_client_create_bonding(client, NULL, address);
+		bluetooth_client_create_bonding(client, NULL, address, NULL, NULL);
 
 		gtk_label_set_markup(GTK_LABEL(label_pairing), address);
 		gtk_label_set_markup(GTK_LABEL(label_passkey), passkey);

-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW! Studies have shown that voting for your favorite open source project, along with a healthy diet, reduces your potential for chronic lameness and boredom. Vote Now at http://www.sourceforge.net/community/cca08

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

#17 lore raw

Poke!

This has been languishing here for a over a month. Could it please get reviewed, so I can post the rest of the wizard patches?

-mt

Quoted 13 lines · Michael Terry

Hello, Marcel.

Quoted 4 lines · Marcel Holtmann

please only change create_bonding and leave the others alone. Also you cast a little bit too much for my taste. For example void pointers need
to extra cast.

Attached is callback3.diff which only modifies create_bonding.

I'm not sure which casts you felt were unnecessary. I don't think I cast any void pointers.

Quoted 7 lines

-mt
-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
_______________________________________________ Bluez-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/bluez-devel

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/

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

#18 lore raw
In reply to Marcel Holtmann
Quoted 2 lines · Marcel Holtmann

looks nice. However you have to break this up into pieces for. Sent small patches and I can quickly review and commit them.

Here's a patch to add support for connecting to devices via the client code. This patch depends on the callback patch.

It finds known services on startup (in setup_services()). Bastien suggested that we don't need to call setup_services() since those services are enabled by default, but I'm not quite sure what he meant. We need to call it to get the service bus IDs so that we can then get DBusGProxies for them.

It adds the function bluetooth_client_available_services() which gives back a type mask for services that were detected. Basically which devices are likely to succeed from a bluetooth_client_connect() call.

bluetooth_client_connect() does device-specific connection handling. It only handles a few types right now (input and headset).

-mt

common/client.c renamed from bluez-gnome-callback/common/client.c +129 -0
diff -upr ../bluez-gnome-callback/common/client.c ./common/client.c
@@ -48,6 +48,8 @@ struct _BluetoothClientPrivate {
 
 	DBusGConnection *conn;
 	DBusGProxy *manager_object;
+	DBusGProxy *input_service;
+	DBusGProxy *audio_service;
 	GtkTreeStore *store;
 	gchar *default_adapter;
 };
@@ -935,6 +937,33 @@ static void setup_manager(BluetoothClien
 		g_error_free(error);
 }
 
+static void setup_services(BluetoothClient *client)
+{
+	BluetoothClientPrivate *priv = BLUETOOTH_CLIENT_GET_PRIVATE(client);
+	gchar *busname = NULL;
+
+	priv->input_service = NULL;
+	priv->audio_service = NULL;
+
+	if (dbus_g_proxy_call(priv->manager_object, "ActivateService", NULL,
+	                      G_TYPE_STRING, "input", G_TYPE_INVALID,
+	                      G_TYPE_STRING, &busname, G_TYPE_INVALID)) {
+		priv->input_service = dbus_g_proxy_new_for_name(priv->conn, busname,
+		                                                "/org/bluez/input",
+		                                                "org.bluez.input.Manager");
+		g_free(busname);
+	}
+
+	if (dbus_g_proxy_call(priv->manager_object, "ActivateService", NULL,
+	                      G_TYPE_STRING, "audio", G_TYPE_INVALID,
+	                      G_TYPE_STRING, &busname, G_TYPE_INVALID)) {
+		priv->audio_service = dbus_g_proxy_new_for_name(priv->conn, busname,
+		                                                "/org/bluez/audio",
+		                                                "org.bluez.audio.Manager");
+		g_free(busname);
+	}
+}
+
 static void name_owner_changed(DBusGProxy *object, const char *name,
 			const char *prev, const char *new, gpointer user_data)
 {
@@ -984,6 +1013,8 @@ static void bluetooth_client_finalize(GO
 	g_free(priv->default_adapter);
 	g_object_unref(G_OBJECT(priv->store));
 	g_object_unref (priv->manager_object);
+	g_object_unref (priv->input_service);
+	g_object_unref (priv->audio_service);
 }
 
 static void bluetooth_client_init(BluetoothClient *client)
@@ -1000,6 +1031,8 @@ static void bluetooth_client_init(Blueto
 	setup_dbus(client);
 
 	setup_manager(client);
+
+	setup_services(client);
 }
 
 static void bluetooth_client_set_property(GObject *object, guint prop_id,
@@ -1085,6 +1118,19 @@ BluetoothClient *bluetooth_client_new(vo
 	}
 }
 
+int bluetooth_client_available_services(BluetoothClient *client)
+{
+	BluetoothClientPrivate *priv = BLUETOOTH_CLIENT_GET_PRIVATE(client);
+	int rv = 0;
+
+	if (priv->input_service)
+		rv |= BLUETOOTH_TYPE_INPUT;
+	if (priv->audio_service)
+		rv |= BLUETOOTH_TYPE_HEADSET;
+
+	return rv;
+}
+
 gboolean bluetooth_client_register_passkey_agent(BluetoothClient *client,
 		const char *path, const char *address, const void *info)
 {
@@ -1131,6 +1177,89 @@ static void call_reply_s(DBusGProxy *pro
 	call_reply(proxy, error, userdata);
 }
 
+static gboolean connect_to_service(BluetoothClient *client, DBusGProxy *object,
+						const gchar *address, guint type,
+						gpointer userdata)
+{
+	BluetoothClientPrivate *priv = BLUETOOTH_CLIENT_GET_PRIVATE(client);
+	DBusGProxyCall *call = NULL;
+
+	/* Special case the few types we can handle */
+	if (type & BLUETOOTH_TYPE_INPUT)
+		call = input_create_secure_device_async(priv->input_service, address,
+					call_reply_s, userdata);
+	else if (type & BLUETOOTH_TYPE_HEADSET)
+		call = audio_create_headset_async(priv->audio_service, address,
+					call_reply_s, userdata);
+
+	g_object_set_data(G_OBJECT(object), "call", call);
+	return call != NULL;
+}
+
+gboolean bluetooth_client_connect(BluetoothClient *client, guint type,
+					gchar *adapter, const gchar *address,
+					bluetooth_client_call_reply callback,
+					gpointer userdata)
+{
+	BluetoothClientPrivate *priv = BLUETOOTH_CLIENT_GET_PRIVATE(client);
+	GtkTreeIter iter;
+	gboolean cont;
+
+	if (adapter == NULL)
+		adapter = priv->default_adapter;
+
+	if (adapter == NULL)
+		return FALSE;
+
+	cont = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(priv->store), &iter);
+
+	while (cont == TRUE) {
+		DBusGProxy *object;
+		gchar *path;
+
+		gtk_tree_model_get(GTK_TREE_MODEL(priv->store), &iter,
+						COLUMN_PATH, &path,
+						COLUMN_OBJECT, &object, -1);
+
+		if (g_ascii_strcasecmp(path, adapter) == 0) {
+			DBusGAsyncData *stuff;
+			gboolean cont;
+			GtkTreeIter child;
+
+			stuff = g_new (DBusGAsyncData, 1);
+			stuff->cb = G_CALLBACK (callback);
+			stuff->userdata = userdata;
+
+			/* If caller didn't specify a forced type, determine it from device info */
+			if (type == 0 || type == BLUETOOTH_TYPE_ANY) {
+				cont = gtk_tree_model_iter_children(GTK_TREE_MODEL(priv->store),
+										&child, &iter);
+
+				while (cont == TRUE) {
+					gchar *value;
+
+					gtk_tree_model_get(GTK_TREE_MODEL(priv->store), &child,
+									COLUMN_ADDRESS, &value, -1);
+
+					if (g_ascii_strcasecmp(address, value) == 0) {
+						gtk_tree_model_get(GTK_TREE_MODEL(priv->store), &child,
+									COLUMN_TYPE, &type, -1);
+						break;
+					}
+
+					cont = gtk_tree_model_iter_next(GTK_TREE_MODEL(priv->store), &child);
+				}
+			}
+
+			return connect_to_service(client, object, address, type, stuff);
+		}
+
+		cont = gtk_tree_model_iter_next(GTK_TREE_MODEL(priv->store), &iter);
+	}
+
+	return FALSE;
+}
+
 gboolean bluetooth_client_create_bonding(BluetoothClient *client,
 					gchar *adapter, const gchar *address,
 					bluetooth_client_call_reply callback,
common/client.h renamed from bluez-gnome-callback/common/client.h +8 -0
diff -upr ../bluez-gnome-callback/common/client.h ./common/client.h
@@ -101,8 +101,16 @@ gboolean bluetooth_client_register_passk
 
 typedef void (*bluetooth_client_call_reply) (GError *error, gpointer data);
 
+int bluetooth_client_available_services(BluetoothClient *self);
+
 gboolean bluetooth_client_cancel_call(BluetoothClient *self,
 					gchar *adapter, const gchar *address);
+
+/* Set 'type' to non-zero to force a certain type connection -- useful for dumb devices */
+gboolean bluetooth_client_connect(BluetoothClient *self, guint type,
+					gchar *adapter, const gchar *address,
+					bluetooth_client_call_reply callback,
+					gpointer data);
 gboolean bluetooth_client_create_bonding(BluetoothClient *self,
 					gchar *adapter, const gchar *address,
 					bluetooth_client_call_reply callback,
common/dbus.xml renamed from bluez-gnome-callback/common/dbus.xml +16 -0
diff -upr ../bluez-gnome-callback/common/dbus.xml ./common/dbus.xml
@@ -98,4 +98,20 @@
       <arg type="s" name="address"/>
     </method>
   </interface>
+
+  <interface name="input">
+    <method name="CreateSecureDevice">
+      <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+      <arg type="s" name="address"/>
+      <arg type="s" direction="out"/>
+    </method>
+  </interface>
+
+  <interface name="audio">
+    <method name="CreateHeadset">
+      <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+      <arg type="s" name="address"/>
+      <arg type="s" direction="out"/>
+    </method>
+  </interface>
 </node>

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php

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

#19 lore raw
Quoted 5 lines · Michael Terry
Quoted 2 lines · Marcel Holtmann

looks nice. However you have to break this up into pieces for. Sent small patches and I can quickly review and commit them.

Here's a patch to add support for connecting to devices via the client code. This patch depends on the callback patch.

Here's an updated services patch, to go along with the changes in callback2.diff. I'll wait to provide an updated wizard-ui.diff until I get feedback.

-mt

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php

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

#20 lore raw
Quoted 1 line · Michael Terry

Here's an updated services patch, to go along with the changes in callback2.diff. I'll wait to provide an updated wizard-ui.diff until I get feedback.

Guh, I need that plugin that warns me about not attaching files. :)

Actually attached now.

-mt

common/client.c renamed from bluez-gnome-callback/common/client.c +152 -4
diff -rup ../bluez-gnome-callback/common/client.c ./common/client.c
@@ -48,6 +48,8 @@ struct _BluetoothClientPrivate {
 
 	DBusGConnection *conn;
 	DBusGProxy *manager_object;
+	DBusGProxy *input_service;
+	DBusGProxy *audio_service;
 	GtkTreeStore *store;
 	gchar *default_adapter;
 };
@@ -935,6 +937,33 @@ static void setup_manager(BluetoothClien
 		g_error_free(error);
 }
 
+static void setup_services(BluetoothClient *client)
+{
+	BluetoothClientPrivate *priv = BLUETOOTH_CLIENT_GET_PRIVATE(client);
+	gchar *busname = NULL;
+
+	priv->input_service = NULL;
+	priv->audio_service = NULL;
+
+	if (dbus_g_proxy_call(priv->manager_object, "FindService", NULL,
+	                      G_TYPE_STRING, "input", G_TYPE_INVALID,
+	                      G_TYPE_STRING, &busname, G_TYPE_INVALID)) {
+		priv->input_service = dbus_g_proxy_new_for_name(priv->conn, busname,
+		                                                "/org/bluez/input",
+		                                                "org.bluez.input.Manager");
+		g_free(busname);
+	}
+
+	if (dbus_g_proxy_call(priv->manager_object, "FindService", NULL,
+	                      G_TYPE_STRING, "audio", G_TYPE_INVALID,
+	                      G_TYPE_STRING, &busname, G_TYPE_INVALID)) {
+		priv->audio_service = dbus_g_proxy_new_for_name(priv->conn, busname,
+		                                                "/org/bluez/audio",
+		                                                "org.bluez.audio.Manager");
+		g_free(busname);
+	}
+}
+
 static void name_owner_changed(DBusGProxy *object, const char *name,
 			const char *prev, const char *new, gpointer user_data)
 {
@@ -984,6 +1013,8 @@ static void bluetooth_client_finalize(GO
 	g_free(priv->default_adapter);
 	g_object_unref(G_OBJECT(priv->store));
 	g_object_unref (priv->manager_object);
+	g_object_unref (priv->input_service);
+	g_object_unref (priv->audio_service);
 }
 
 static void bluetooth_client_init(BluetoothClient *client)
@@ -1000,6 +1031,8 @@ static void bluetooth_client_init(Blueto
 	setup_dbus(client);
 
 	setup_manager(client);
+
+	setup_services(client);
 }
 
 static void bluetooth_client_set_property(GObject *object, guint prop_id,
@@ -1085,6 +1118,19 @@ BluetoothClient *bluetooth_client_new(vo
 	}
 }
 
+int bluetooth_client_available_services(BluetoothClient *client)
+{
+	BluetoothClientPrivate *priv = BLUETOOTH_CLIENT_GET_PRIVATE(client);
+	int rv = 0;
+
+	if (priv->input_service)
+		rv |= BLUETOOTH_TYPE_INPUT;
+	if (priv->audio_service)
+		rv |= BLUETOOTH_TYPE_HEADSET;
+
+	return rv;
+}
+
 gboolean bluetooth_client_register_passkey_agent(BluetoothClient *client,
 		const char *path, const char *address, const void *info)
 {
@@ -1124,6 +1170,13 @@ static void call_reply(DBusGProxy *proxy
 		g_error_free(error);
 }
 
+static void connect_reply(DBusGProxy *proxy, char *s,
+					GError *error, gpointer userdata)
+{
+	g_object_set_data(G_OBJECT(proxy), "connect-call", NULL);
+	call_reply(proxy, error, userdata);
+}
+
 static void create_bonding_reply(DBusGProxy *proxy,
 					GError *error, gpointer userdata)
 {
@@ -1131,6 +1184,89 @@ static void create_bonding_reply(DBusGPr
 	call_reply(proxy, error, userdata);
 }
 
+static gboolean connect_to_service(BluetoothClient *client, DBusGProxy *object,
+						const gchar *address, guint type,
+						gpointer userdata)
+{
+	BluetoothClientPrivate *priv = BLUETOOTH_CLIENT_GET_PRIVATE(client);
+	DBusGProxyCall *call = NULL;
+
+	/* Special case the few types we can handle */
+	if (type & BLUETOOTH_TYPE_INPUT)
+		call = input_create_secure_device_async(priv->input_service, address,
+					connect_reply, userdata);
+	else if (type & BLUETOOTH_TYPE_HEADSET)
+		call = audio_create_headset_async(priv->audio_service, address,
+					connect_reply, userdata);
+
+	g_object_set_data(G_OBJECT(object), "connect-call", call);
+	return call != NULL;
+}
+
+gboolean bluetooth_client_connect(BluetoothClient *client, guint type,
+					gchar *adapter, const gchar *address,
+					bluetooth_client_call_reply callback,
+					gpointer userdata)
+{
+	BluetoothClientPrivate *priv = BLUETOOTH_CLIENT_GET_PRIVATE(client);
+	GtkTreeIter iter;
+	gboolean cont;
+
+	if (adapter == NULL)
+		adapter = priv->default_adapter;
+
+	if (adapter == NULL)
+		return FALSE;
+
+	cont = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(priv->store), &iter);
+
+	while (cont == TRUE) {
+		DBusGProxy *object;
+		gchar *path;
+
+		gtk_tree_model_get(GTK_TREE_MODEL(priv->store), &iter,
+						COLUMN_PATH, &path,
+						COLUMN_OBJECT, &object, -1);
+
+		if (g_ascii_strcasecmp(path, adapter) == 0) {
+			DBusGAsyncData *stuff;
+			gboolean cont;
+			GtkTreeIter child;
+
+			stuff = g_new (DBusGAsyncData, 1);
+			stuff->cb = G_CALLBACK (callback);
+			stuff->userdata = userdata;
+
+			/* If caller didn't specify a forced type, determine it from device info */
+			if (type == 0 || type == BLUETOOTH_TYPE_ANY) {
+				cont = gtk_tree_model_iter_children(GTK_TREE_MODEL(priv->store),
+										&child, &iter);
+
+				while (cont == TRUE) {
+					gchar *value;
+
+					gtk_tree_model_get(GTK_TREE_MODEL(priv->store), &child,
+									COLUMN_ADDRESS, &value, -1);
+
+					if (g_ascii_strcasecmp(address, value) == 0) {
+						gtk_tree_model_get(GTK_TREE_MODEL(priv->store), &child,
+									COLUMN_TYPE, &type, -1);
+						break;
+					}
+
+					cont = gtk_tree_model_iter_next(GTK_TREE_MODEL(priv->store), &child);
+				}
+			}
+
+			return connect_to_service(client, object, address, type, stuff);
+		}
+
+		cont = gtk_tree_model_iter_next(GTK_TREE_MODEL(priv->store), &iter);
+	}
+
+	return FALSE;
+}
+
 gboolean bluetooth_client_create_bonding(BluetoothClient *client,
 					gchar *adapter, const gchar *address,
 					bluetooth_client_call_reply callback,
@@ -1410,8 +1546,8 @@ gboolean bluetooth_client_cancel_discove
 	return FALSE;
 }
 
-gboolean bluetooth_client_cancel_bonding(BluetoothClient *client,
-					gchar *adapter, const gchar *address)
+static gboolean bluetooth_client_cancel_call(BluetoothClient *client,
+					gchar *adapter, const gchar *address, const gchar *call_id)
 {
 	BluetoothClientPrivate *priv = BLUETOOTH_CLIENT_GET_PRIVATE(client);
 	GtkTreeIter iter;
@@ -1435,10 +1571,10 @@ gboolean bluetooth_client_cancel_bonding
 
 		if (g_ascii_strcasecmp(path, adapter) == 0) {
 			DBusGProxyCall *call;
-			call = (DBusGProxyCall *)g_object_get_data(G_OBJECT(object), "bonding-call");
+			call = (DBusGProxyCall *)g_object_get_data(G_OBJECT(object), call_id);
 			if (call != NULL) {
 				dbus_g_proxy_cancel_call(object, call);
-				g_object_set_data(G_OBJECT(object), "bonding-call", NULL);
+				g_object_set_data(G_OBJECT(object), call_id, NULL);
 				return TRUE;
 			}
 			return FALSE;
@@ -1450,6 +1586,18 @@ gboolean bluetooth_client_cancel_bonding
 	return FALSE;
 }
 
+gboolean bluetooth_client_cancel_bonding(BluetoothClient *client,
+					gchar *adapter, const gchar *address)
+{
+	return bluetooth_client_cancel_call(client, adapter, address, "bonding-call");
+}
+
+gboolean bluetooth_client_cancel_connect(BluetoothClient *client,
+					gchar *adapter, const gchar *address)
+{
+	return bluetooth_client_cancel_call(client, adapter, address, "connect-call");
+}
+
 GtkTreeModel *bluetooth_client_get_model(BluetoothClient *client)
 {
 	BluetoothClientPrivate *priv = BLUETOOTH_CLIENT_GET_PRIVATE(client);
common/client.h renamed from bluez-gnome-callback/common/client.h +9 -0
diff -rup ../bluez-gnome-callback/common/client.h ./common/client.h
@@ -107,6 +107,15 @@ gboolean bluetooth_client_create_bonding
 					gpointer data);
 gboolean bluetooth_client_cancel_bonding(BluetoothClient *self,
 					gchar *adapter, const gchar *address);
+
+/* Set 'type' to non-zero to force a certain type connection -- useful for dumb devices */
+gboolean bluetooth_client_connect(BluetoothClient *self, guint type,
+					gchar *adapter, const gchar *address,
+					bluetooth_client_call_reply callback,
+					gpointer data);
+gboolean bluetooth_client_cancel_connect(BluetoothClient *self,
+					gchar *adapter, const gchar *address);
+
 gboolean bluetooth_client_remove_bonding(BluetoothClient *self,
 					gchar *adapter, const gchar *address,
 					bluetooth_client_call_reply callback,
common/dbus.xml renamed from bluez-gnome-callback/common/dbus.xml +16 -0
diff -rup ../bluez-gnome-callback/common/dbus.xml ./common/dbus.xml
@@ -98,4 +98,20 @@
       <arg type="s" name="address"/>
     </method>
   </interface>
+
+  <interface name="input">
+    <method name="CreateSecureDevice">
+      <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+      <arg type="s" name="address"/>
+      <arg type="s" direction="out"/>
+    </method>
+  </interface>
+
+  <interface name="audio">
+    <method name="CreateHeadset">
+      <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+      <arg type="s" name="address"/>
+      <arg type="s" direction="out"/>
+    </method>
+  </interface>
 </node>

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php

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

#21 lore raw
Quoted 6 lines · Michael Terry
Quoted 1 line · Michael Terry

Here's an updated services patch, to go along with the changes in

callback2.diff. I'll wait to provide an updated wizard-ui.diff until I get feedback.

Guh, I need that plugin that warns me about not attaching files. :)

Edit->Plugins->Attachment Reminder in Evo.

Quoted 1 line

Actually attached now.

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

#22 lore raw
In reply to Michael Terry

Michael:

If you decide to move away from evolution, here's for t-bird:

https://addons.mozilla.org/en-US/thunderbird/addon/5759

Regards

Quoted 24 lines · Michael Terry
Quoted 2 lines · Michael Terry

Here's an updated services patch, to go along with the changes in callback2.diff. I'll wait to provide an updated wizard-ui.diff until I get feedback.

Guh, I need that plugin that warns me about not attaching files. :)

Actually attached now.

-mt

------------------------------------------------------------------------

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
------------------------------------------------------------------------

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

Signature · 3 lines
Mario Limonciello
*Dell | Linux Engineering*
[email protected]

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php

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

maintainer
#23 lore raw
In reply to Michael Terry

SGkgTWljaGFlbCwKCj4gPiBsb29rcyBuaWNlLiBIb3dldmVyIHlvdSBoYXZlIHRvIGJyZWFrIHRo aXMgdXAgaW50byBwaWVjZXMgZm9yLiBTZW50Cj4gPiBzbWFsbCBwYXRjaGVzIGFuZCBJIGNhbiBx dWlja2x5IHJldmlldyBhbmQgY29tbWl0IHRoZW0uCj4gCj4gSGVyZSdzIGEgcGF0Y2ggdG8gYWRk IHN1cHBvcnQgZm9yIGNvbm5lY3RpbmcgdG8gZGV2aWNlcyB2aWEgdGhlIGNsaWVudCBjb2RlLiAg VGhpcyBwYXRjaCBkZXBlbmRzIG9uIHRoZSBjYWxsYmFjayBwYXRjaC4KPiAKPiBJdCBmaW5kcyBr bm93biBzZXJ2aWNlcyBvbiBzdGFydHVwIChpbiBzZXR1cF9zZXJ2aWNlcygpKS4gIEJhc3RpZW4K PiBzdWdnZXN0ZWQgdGhhdCB3ZSBkb24ndCBuZWVkIHRvIGNhbGwgc2V0dXBfc2VydmljZXMoKSBz aW5jZSB0aG9zZQo+IHNlcnZpY2VzIGFyZSBlbmFibGVkIGJ5IGRlZmF1bHQsIGJ1dCBJJ20gbm90 IHF1aXRlIHN1cmUgd2hhdCBoZSBtZWFudC4KPiBXZSBuZWVkIHRvIGNhbGwgaXQgdG8gZ2V0IHRo ZSBzZXJ2aWNlIGJ1cyBJRHMgc28gdGhhdCB3ZSBjYW4gdGhlbiBnZXQKPiBEQnVzR1Byb3hpZXMg Zm9yIHRoZW0uCgpzbyBzdGFydGluZyB3aXRoIGJsdWV6LXV0aWxzLTMuMzMgZXZlcnl0aGluZyBp cyBhIHBsdWdpbiBhbmQgd2lsbCBiZQphdmFpbGFibGUgdW5kZXIgdGhlIG9yZy5ibHVleiBzZXJ2 aWNlIG5hbWUuIFNvIHdlIGNvdWxkIHNpbXBseSBpZ25vcmUKdGhpcyBhbmQgZmFpbCB0aGUgb3Ro ZXIgY2FzZXMuCgpJZiB5b3Ugd2FubmEgY2hlY2sgYXZhaWxhYmxlIHNlcnZpY2VzIHRoZW4geW91 IHNob3VsZCB1c2UgTGlzdFNlcnZpY2VzCmFuZCByZXRyaWV2ZSB0aGUgc2VydmljZSBvYmplY3Rz LiBPbiB0aGVzZSBvYmplY3RzIHlvdSBjYW4gYWxzbyBjYWxsCkdldEJ1c05hbWUgdG8gZ2V0IHRo ZSBidXMgbmFtZSBvZiB0aGUgc2VydmljZS4gVGhpcyB3aWxsIHRoZW4gb25seSB3b3JrCmZvciBh Y3RpdmF0ZWQgc2VydmljZXMsIGJ1dCB0aGF0IGlzIGFjdHVhbGx5IGZpbmUuIFRoZSBkaXN0cm9z IGVuYWJsZQp0aGVtIGJ5IGRlZmF1bHQgYW55d2F5IG9yIHRoZXkgYXJlIHBsdWdpbnMgYW5kIGxv YWRlZCBhbGwgdGhlbS4KCj4gSXQgYWRkcyB0aGUgZnVuY3Rpb24gYmx1ZXRvb3RoX2NsaWVudF9h dmFpbGFibGVfc2VydmljZXMoKSB3aGljaCBnaXZlcwo+IGJhY2sgYSB0eXBlIG1hc2sgZm9yIHNl cnZpY2VzIHRoYXQgd2VyZSBkZXRlY3RlZC4gIEJhc2ljYWxseSB3aGljaAo+IGRldmljZXMgYXJl IGxpa2VseSB0byBzdWNjZWVkIGZyb20gYSBibHVldG9vdGhfY2xpZW50X2Nvbm5lY3QoKSBjYWxs Lgo+IAo+IO+7v2JsdWV0b290aF9jbGllbnRfY29ubmVjdCgpIGRvZXMgZGV2aWNlLXNwZWNpZmlj IGNvbm5lY3Rpb24gaGFuZGxpbmcuCj4gSXQgb25seSBoYW5kbGVzIGEgZmV3IHR5cGVzIHJpZ2h0 IG5vdyAoaW5wdXQgYW5kIGhlYWRzZXQpLgoKUGxlYXNlIHN0b3AgdXNpbmcgdGhlIHZhcmlhYmxl IG5hbWUgcnYgZm9yIHJldHVybiB2YWx1ZS4gRWl0aGVyIHVzZSBlcnIKb3IgY2FsbCBpdCByZXN1 bHQgb3Igc29tZXRoaW5nLgoKUmVnYXJkcwoKTWFyY2VsCgoKCi0tLS0tLS0tLS0tLS0tLS0tLS0t LS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0KQ2hl Y2sgb3V0IHRoZSBuZXcgU291cmNlRm9yZ2UubmV0IE1hcmtldHBsYWNlLgpJdCdzIHRoZSBiZXN0 IHBsYWNlIHRvIGJ1eSBvciBzZWxsIHNlcnZpY2VzIGZvcgpqdXN0IGFib3V0IGFueXRoaW5nIE9w ZW4gU291cmNlLgpodHRwOi8vc291cmNlZm9yZ2UubmV0L3NlcnZpY2VzL2J1eS9pbmRleC5waHAK X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KQmx1ZXotZGV2 ZWwgbWFpbGluZyBsaXN0CkJsdWV6LWRldmVsQGxpc3RzLnNvdXJjZWZvcmdlLm5ldApodHRwczov L2xpc3RzLnNvdXJjZWZvcmdlLm5ldC9saXN0cy9saXN0aW5mby9ibHVlei1kZXZlbAo=

#24 lore raw
In reply to Marcel Holtmann
Quoted 2 lines · Marcel Holtmann

looks nice. However you have to break this up into pieces for. Sent small patches and I can quickly review and commit them.

And here's the actual wizard UI patch. It's a bit large, but not terribly break-down-able.

It adds the passkey code for the UI and modifies the UI a bit, as I mentioned in previous emails.

It also adds a call to the client code to get an address's user-visible name from its path.

Bastien suggested that the applet label to launch the wizard should continue to be "Setup" and not "Connect" because we may want to do more setup for certain device types in the future. That may be true, but some of that would be automatic (like the SyncML example he cited) and so wouldn't be visible from the user's perspective.

Even if we did add a page for some sort of device configuration, I maintain that the overriding user metaphor will be connecting not configuring.

-mt

applet/main.c renamed from bluez-gnome-services/applet/main.c +1 -5
diff -uprN ../bluez-gnome-services/applet/main.c ./applet/main.c
@@ -625,7 +625,6 @@ static void sendto_callback(GObject *wid
 		g_printerr("Couldn't execute command: %s\n", command);
 }
 
-#if 0
 static void wizard_callback(GObject *widget, gpointer user_data)
 {
 	const char *command = "bluetooth-wizard --singleton";
@@ -633,7 +632,6 @@ static void wizard_callback(GObject *wid
 	if (!g_spawn_command_line_async(command, NULL))
 		g_printerr("Couldn't execute command: %s\n", command);
 }
-#endif
 
 static void activate_callback(GObject *widget, gpointer user_data)
 {
@@ -697,17 +695,15 @@ static GtkWidget *create_popupmenu(void)
 
 	menuitem_browse = item;
 
-#if 0
 	item = gtk_separator_menu_item_new();
 	gtk_widget_show(item);
 	gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
 
-	item = gtk_menu_item_new_with_label(_("Setup New Device"));
+	item = gtk_menu_item_new_with_label(_("Connect New Device..."));
 	g_signal_connect(item, "activate",
 				G_CALLBACK(wizard_callback), NULL);
 	gtk_widget_show(item);
 	gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
-#endif
 
 	return menu;
 }
common/client.c renamed from bluez-gnome-services/common/client.c +31 -0
diff -uprN ../bluez-gnome-services/common/client.c ./common/client.c
@@ -1118,6 +1118,37 @@ BluetoothClient *bluetooth_client_new(vo
 	}
 }
 
+gchar *bluetooth_client_get_name(BluetoothClient *self, const gchar *adapter)
+{
+	BluetoothClientPrivate *priv = BLUETOOTH_CLIENT_GET_PRIVATE(self);
+	GtkTreeIter iter;
+	gboolean cont;
+
+	if (adapter == NULL)
+		adapter = priv->default_adapter;
+
+	if (adapter == NULL)
+		return NULL;
+
+	cont = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(priv->store), &iter);
+
+	while (cont == TRUE) {
+		gchar *path;
+		gchar *name;
+
+		gtk_tree_model_get(GTK_TREE_MODEL(priv->store), &iter,
+						COLUMN_PATH, &path,
+						COLUMN_NAME, &name, -1);
+
+		if (g_ascii_strcasecmp(path, adapter) == 0)
+			return g_strdup(name);
+
+		cont = gtk_tree_model_iter_next(GTK_TREE_MODEL(priv->store), &iter);
+	}
+
+	return NULL;
+}
+
 int bluetooth_client_available_services(BluetoothClient *client)
 {
 	BluetoothClientPrivate *priv = BLUETOOTH_CLIENT_GET_PRIVATE(client);
common/client.h renamed from bluez-gnome-services/common/client.h +2 -0
diff -uprN ../bluez-gnome-services/common/client.h ./common/client.h
@@ -135,6 +135,8 @@ gboolean bluetooth_client_discover_devic
 
 gboolean bluetooth_client_cancel_discovery(BluetoothClient *self, gchar *adapter);
 
+gchar *bluetooth_client_get_name(BluetoothClient *self, const gchar *adapter);
+
 GtkTreeModel *bluetooth_client_get_model(BluetoothClient *self);
 GtkTreeModel *bluetooth_client_get_model_simple(BluetoothClient *self);
 GtkTreeModel *bluetooth_client_get_model_adapter_list(BluetoothClient *self);
wizard/agent.c renamed from bluez-gnome-services/wizard/agent.c +340 -0

340 lines not on this page · raw message

wizard/agent.h renamed from bluez-gnome-services/wizard/agent.h +30 -0
diff -uprN ../bluez-gnome-services/wizard/agent.h ./wizard/agent.h
@@ -0,0 +1,30 @@
+/*
+ *
+ *  BlueZ - Bluetooth protocol stack for Linux
+ *
+ *  Copyright (C) 2005-2008  Marcel Holtmann <[email protected]>
+ *  Copyright (C) 2006-2007  Bastien Nocera <[email protected]>
+ *
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ */
+
+#include <gtk/gtk.h>
+#include "client.h"
+
+void set_agent_parent_window(GtkWidget *window);
+int register_agent(BluetoothClient *client, const char *path, const char *address);
+
wizard/main.c renamed from bluez-gnome-services/wizard/main.c +119 -170

410 lines not on this page · raw message

wizard/Makefile.am renamed from bluez-gnome-services/wizard/Makefile.am +4 -4
diff -uprN ../bluez-gnome-services/wizard/Makefile.am ./wizard/Makefile.am
@@ -1,7 +1,7 @@
 
-noinst_PROGRAMS = bluetooth-wizard
+bin_PROGRAMS = bluetooth-wizard
 
-bluetooth_wizard_SOURCES = main.c
+bluetooth_wizard_SOURCES = main.c agent.c agent.h
 
 bluetooth_wizard_LDADD = @GTK_LIBS@ @DBUS_LIBS@ \
 		$(top_builddir)/common/libcommon.a
@@ -13,8 +13,8 @@ AM_CFLAGS = @DBUS_CFLAGS@ @GTK_CFLAGS@
 
 INCLUDES = -I$(top_srcdir)/common -I$(top_builddir)/common
 
-noinst_MANS = bluetooth-wizard.1
+man_MANS = bluetooth-wizard.1
 
-EXTRA_DIST = $(noinst_MANS)
+EXTRA_DIST = $(man_MANS)
 
 MAINTAINERCLEANFILES = Makefile.in
po/POTFILES.in renamed from bluez-gnome-services/po/POTFILES.in +2 -0
diff -upr ../bluez-gnome-services/po/POTFILES.in ./po/POTFILES.in
@@ -22,3 +22,5 @@ analyzer/dialog.c
 analyzer/tracer.c
 analyzer/bluetooth-analyzer.desktop.in
 analyzer/bluetooth-manager.xml.in
+wizard/agent.c
+wizard/main.c

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php

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

maintainer
#25 lore raw

Hi Michael,

Quoted 5 lines
Quoted 2 lines

looks nice. However you have to break this up into pieces for. Sent small patches and I can quickly review and commit them.

And here's the actual wizard UI patch. It's a bit large, but not terribly break-down-able.

first of all the bluetooth_client_get_name part should be a separate patch.

Then the modification to the applet code to show the extra entry can be a separate patch, too.

Same goes for the part where you actually enable the installation of the bluetooth-wizard program.

Leave these all out, because I don't bother and we will apply them once the UI change is committed.

Quoted 2 lines

It adds the passkey code for the UI and modifies the UI a bit, as I mentioned in previous emails.

Lets do the UI changes without the passkey stuff. We should get the wizard working. If no device specific passkey is provided, it will fall back to the applet anyway and that is fine for the first step.

I also don't like that you copy the agent.[ch] files. This needs some extra thinking and hence first the UI and then the agent part.

Quoted 5 lines

Bastien suggested that the applet label to launch the wizard should continue to be "Setup" and not "Connect" because we may want to do more setup for certain device types in the future. That may be true, but some of that would be automatic (like the SyncML example he cited) and so wouldn't be visible from the user's perspective.

I am for "Setup. Using "Connect" is wrong here. If you wanna connect to a previously setup device, then we have to add shortcuts to the applet menu to do so.

Regards

Marcel

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

#26 lore raw
In reply to Michael Terry
Quoted 4 lines · Michael Terry

Hello, all!

I have attached a patch against 0.27 (it applies cleanly against CVS) to complete the wizard in the bluez-gnome source tree.

- item = gtk_menu_item_new_with_label(_("Setup New Device"));
+ item = gtk_menu_item_new_with_label(_("Connect New Device..."));

This is wrong, as we'll probably want to plug in more setup for future device types. For example, when adding a phone, we'll want to check whether it supports SyncML, and automatically set it up in the sync program.

The setup_services() service call shouldn't be needed, as all the services are enabled by default.

In bluetooth_client_available_services(), you also need to add joypads, and every other input devices to that list.

+ // If caller didn't specify a forced type, determine it from device
info

Don't use C++-style comments.

I personally don't really like adding setup calls in client.c, which should really only be used for discovery.

The rest looks alright to me, looking over it quickly.

Cheers

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

A message that is not in the archive (sent off-list or not yet received): 031301c8da4d$0bce3720$6701a8c0@freqonedev

A message that is not in the archive (sent off-list or not yet received): [email protected]

#29 lore raw

----- Original Message -----
From: "Bastien Nocera" <[email protected]>
To: "David Stockwell" <[email protected]>
Sent: Monday, June 30, 2008 3:18 AM
Subject: Re: [Bluez-devel] Wizard patch

Quoted 6 lines · David Stockwell
Quoted 2 lines

Out of curiosity, why not use C++ style (//) comments? Do you prefer the older /*...*/ comments? Or is there some other reason.

C++-style comments are for temporary comments. Almost all C codebases refuse to have C++-style comments in permanent code.

Fair enough. Also the case that C-compilers sometimes do not handle // comments.

Quoted 8 lines
Quoted 4 lines

FWIW, it seems to me that most of the code (e.g, the DBus code) is almost completely uncommented...hence very hard to figure out how it actually works, or even how it is intended to work.

There's documentation for D-Bus in */*.txt in bluez-utils. If the documentation isn't good enough, either send questions asking for clarifications, or patches.

I read the docs and when the code works as expected it is good enough. However, I have had a number of problems making the code work (partially implemented "experimental" 4.x features in release 3.33 and before).

Also, figuring out how to handle some of the formats (e.g., the "dict" with variant) are a bit hard to figure out without a code example. SO, I often have to dig into the actual code and figure out just what is going on.

Quoted 6 lines

BTW, could you please: reply to the list, quote properly, not top-post,
and make sure lines are cut to 72 chars in length. I know it's hard using Outlook...

OK, I normally respond to the list (note that I have not contacted you before, and will not again), but had a couple of questions about the stylistic points you raised, which I had not seen before.

I think you will also see that this is plain text, cut to 72 chars. Easy to do.

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

#30 lore raw

Hello David,

Quoted 3 lines

I read the docs and when the code works as expected it is good enough. However, I have had a number of problems making the code work (partially implemented "experimental" 4.x features in release 3.33 and before).

You should first understand that the documentation in doc/ are dbus specifications, they are not normal method calls or gobject signals. You seems to be confused by using dbus-glib and not really knowing what dbus is doing, we don't document how to use the API in terms of language bindings, because it is open to the application developer to choose between the bindings and the binding itself should document how it map the different signatures.

Quoted 4 lines

Also, figuring out how to handle some of the formats (e.g., the "dict" with variant) are a bit hard to figure out without a code example. SO, I often have to dig into the actual code and figure out just what is going on.

See my point here, just because dbus-glib maps the signature a{sv} (that is the real "dict") to a GHashTable using a GValue doesn't mean any other binding will do the same. It's up to the binding to provides this kind of documentation not the dbus API which should not be tied to a single binding.

This tutorial should cover what you want:
http://dbus.freedesktop.org/doc/dbus-tutorial.html

-- =

Luiz Augusto von Dentz
Engenheiro de Computa=E7=E3o

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

#31 lore raw

Hello David,

Quoted 7 lines
Quoted 1 line

Hello Luis

I read the docs and when the code works as expected it is good enough. However, I have had a number of problems making the code work =

(partially
implemented "experimental" 4.x features in release 3.33 and before).

You should first understand that the documentation in doc/ are dbus specifications, they are not normal method calls or gobject signals. You seems to be confused by using dbus-glib and not really knowing what dbus is doing, we don't document how to use the API in terms of language bindings, because it is open to the application developer to choose between the bindings and the binding itself should document how it map the different signatures.

Quoted 30 lines
Quoted 29 lines

REPLY (sorry, but Outlook SUX)

I appreciate that fact. I also recognize that Python does an awful =

lot for the user, and that perhaps I could develop all of this in =

Python...but at this point, I am choosing to use C/C++ and hence, =

must use the GLib binding.

Really, my comment was about the fact that some of the features =

documented in the /doc directory are not quite working, and in fact =

are still coming into existance. As a result, when I run into a =

problem I cannot figure out what is really going on (is it my code, =

or is it something missing in Bluez) without digging through the =

Bluez source. Which has very little documentation (even at the file =

level). Again, when everything is working, the doc files will be =

fine. Just, for now, they are not quite enough.

The question you may be asking is why I do not just develop to the =

3.x API? Why would I do that when in just a few months I would have =

Quoted 8 lines
Quoted 1 line

to throw all of that away? (See: bluez-gnome).

Also, figuring out how to handle some of the formats (e.g., the "dict" with variant) are a bit hard to figure out without a code example. =

SO,
I often have to dig into the actual code and figure out just what is going on.

See my point here, just because dbus-glib maps the signature a{sv} (that is the real "dict") to a GHashTable using a GValue doesn't mean any other binding will do the same. It's up to the binding to provides this kind of documentation not the dbus API which should not be tied to a single binding.

Quoted 9 lines
Quoted 9 lines

Got it, frankly the Glib binding docs are not very complete. As with =

most programs, the documentation handles the most simplistic cases, =

and ignores the fact that someone might Actually Want To Use It. I =

did find the DBUS Test directory and got a lot of help from seeing =

how the validation tests were coded.

This tutorial should cover what you want:
http://dbus.freedesktop.org/doc/dbus-tutorial.html

Quoted 14 lines
Quoted 13 lines

I have read this tutorial in detail and understood it. However, the =

coverage was still inadequate for a{sv} (dict) and array{string} =

({as}). At one point, I also had problems with object paths, but =

again, with Marcel giving me a hint as to the proper incantation, I =

was able to work that out.

That said, after finding a few more-complex code examples (especially =

the validation code), I have now figured the structures out. =

Quoted 7 lines
Quoted 7 lines

Everything I need to do for now is (apparently) working, and now I am =

moving on to getting SSP going between Bluez and my device =

(programmed with the CSR BT stack).

Thanks again for your response.

-- =

Luiz Augusto von Dentz
Engenheiro de Computa=E7=E3o

-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW! Studies have shown that voting for your favorite open source project, along with a healthy diet, reduces your potential for chronic lameness and boredom. Vote Now at http://www.sourceforge.net/community/cca08
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel