Re: Wizard patch

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello, Marcel.

On Tue, 2008-07-01 at 03:10 +0200, Marcel Holtmann wrote:
> 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
diff -u -p -r1.44 client.c
--- common/client.c	12 Mar 2008 21:03:38 -0000	1.44
+++ common/client.c	9 Jul 2008 14:23:38 -0000
@@ -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
diff -u -p -r1.24 client.h
--- common/client.h	6 Mar 2008 10:54:29 -0000	1.24
+++ common/client.h	9 Jul 2008 14:23:38 -0000
@@ -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
diff -u -p -r1.31 main.c
--- wizard/main.c	6 Jun 2008 15:08:32 -0000	1.31
+++ wizard/main.c	9 Jul 2008 14:23:38 -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: signature.asc
Description: This is a digitally signed message part

-------------------------------------------------------------------------
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
Bluez-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.sourceforge.net/lists/listinfo/bluez-devel

[Index of Archives]     [Linux Bluetooth Devel]     [Linux USB Devel]     [Network Devel]     [Linux Audio Users]     [Yosemite News]     [Linux SCSI]

  Powered by Linux