All of lore.kernel.org
 help / color / mirror / Atom feed
From: Michael Terry <michael.terry@canonical.com>
To: BlueZ development <bluez-devel@lists.sourceforge.net>
Subject: Re: [Bluez-devel] Wizard patch
Date: Mon, 30 Jun 2008 14:53:55 -0400	[thread overview]
Message-ID: <1214852035.6764.40.camel@bongo> (raw)
In-Reply-To: <1214841780.11537.48.camel@violet.holtmann.net>


[-- Attachment #1.1.1: Type: text/plain, Size: 451 bytes --]

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

[-- Attachment #1.1.2: callback2.diff --]
[-- Type: text/x-patch, Size: 10249 bytes --]

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);

[-- Attachment #1.2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

[-- Attachment #2: Type: text/plain, Size: 247 bytes --]

-------------------------------------------------------------------------
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

[-- Attachment #3: Type: text/plain, Size: 164 bytes --]

_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel

  reply	other threads:[~2008-06-30 18:53 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-06-27 19:05 [Bluez-devel] Wizard patch Michael Terry
2008-06-27 19:18 ` Michael Terry
2008-06-27 19:38 ` David Stockwell
2008-06-27 19:42   ` Michael Terry
2008-06-27 22:24     ` Marcel Holtmann
2008-06-27 22:23 ` Marcel Holtmann
2008-06-30 12:51   ` Michael Terry
2008-06-30 12:57     ` Marcel Holtmann
2008-06-30 13:20       ` Michael Terry
2008-06-30 14:07         ` Marcel Holtmann
2008-06-30 13:15   ` Michael Terry
2008-06-30 14:06     ` Marcel Holtmann
2008-06-30 15:57       ` Michael Terry
2008-06-30 16:03         ` Marcel Holtmann
2008-06-30 18:53           ` Michael Terry [this message]
2008-07-01  1:10             ` Marcel Holtmann
2008-07-09 14:28               ` Michael Terry
2008-08-19 17:33                 ` Michael Terry
2008-06-30 13:51   ` Michael Terry
2008-06-30 19:58     ` Michael Terry
2008-06-30 20:01       ` Michael Terry
2008-06-30 20:38         ` Bastien Nocera
2008-06-30 20:42         ` Mario Limonciello
2008-07-01  1:16     ` Marcel Holtmann
2008-06-30 15:48   ` Michael Terry
2008-07-01  1:24     ` Marcel Holtmann
2008-06-27 22:44 ` Bastien Nocera
     [not found]   ` <031301c8da4d$0bce3720$6701a8c0@freqonedev>
     [not found]     ` <1214813891.4435.149.camel@cookie.hadess.net>
2008-06-30 13:15       ` David Stockwell
2008-06-30 22:27         ` Luiz Augusto von Dentz
2008-07-01 18:56           ` David Stockwell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1214852035.6764.40.camel@bongo \
    --to=michael.terry@canonical.com \
    --cc=bluez-devel@lists.sourceforge.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.