Re: Wizard patch
Michael Terry <[email protected]> Mon, 30 Jun 2008 14:53:55 -0400
| Newsgroups | gmane.linux.bluez.devel |
|---|---|
| Message-ID | <1214852035.6764.40.camel@bongo> |
On Mon, 2008-06-30 at 18:03 +0200, Marcel Holtmann wrote: > > 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 ------------------------------------------------------------------------- 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
callback2.diff
(text/x-patch, 10 KB)
Index: common/client.c
===================================================================
RCS file: /cvsroot/bluez/gnome/common/client.c,v
retrieving revision 1.44
diff -u -p -r1.44 client.c
--- common/client.c 12 Mar 2008 21:03:38 -0000 1.44
+++ common/client.c 30 Jun 2008 18:53:08 -0000
@@ -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
diff -u -p -r1.24 client.h
--- common/client.h 6 Mar 2008 10:54:29 -0000 1.24
+++ common/client.h 30 Jun 2008 18:53:08 -0000
@@ -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
diff -u -p -r1.22 adapter.c
--- properties/adapter.c 11 Feb 2008 14:34:37 -0000 1.22
+++ properties/adapter.c 30 Jun 2008 18:53:08 -0000
@@ -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
diff -u -p -r1.31 main.c
--- wizard/main.c 6 Jun 2008 15:08:32 -0000 1.31
+++ wizard/main.c 30 Jun 2008 18:53:08 -0000
@@ -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);
signature.asc
(application/pgp-signature, 189 B)
-----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) iD8DBQBIaSvD53i2YxNrdi0RAngNAJ9zXS8jSWd4L2GUEnXYZ7I2lMk0KACgrGLi uz3FWvsqsx1GSV31OPG5DKA= =I08/ -----END PGP SIGNATURE-----