gnome-bluetooth r530 - trunk/common



Author: hadess
Date: Mon Mar 23 16:30:50 2009
New Revision: 530
URL: http://svn.gnome.org/viewvc/gnome-bluetooth?rev=530&view=rev

Log:
Add a disconnect function, which disconnects all the services on a device


Modified:
   trunk/common/bluetooth-client.c
   trunk/common/bluetooth-client.h

Modified: trunk/common/bluetooth-client.c
==============================================================================
--- trunk/common/bluetooth-client.c	(original)
+++ trunk/common/bluetooth-client.c	Mon Mar 23 16:30:50 2009
@@ -1447,3 +1447,60 @@
 	return TRUE;
 }
 
+static void disconnect_callback(DBusGProxy *proxy,
+				DBusGProxyCall *call,
+				void *user_data)
+{
+	ConnectData *conndata = user_data;
+	GError *error = NULL;
+
+	dbus_g_proxy_end_call(proxy, call, &error, G_TYPE_INVALID);
+
+	if (error != NULL)
+		g_error_free(error);
+
+	if (conndata->func)
+		conndata->func(conndata->data);
+
+	g_object_unref(proxy);
+}
+
+gboolean bluetooth_client_disconnect_service (BluetoothClient *client,
+					      const char *device,
+					      BluetoothClientConnectFunc func,
+					      gpointer data)
+{
+	BluetoothClientPrivate *priv = BLUETOOTH_CLIENT_GET_PRIVATE(client);
+	ConnectData *conndata;
+	DBusGProxy *proxy;
+	DBusGProxyCall *call;
+	GHashTable *table;
+	GtkTreeIter iter;
+
+	DBG("client %p", client);
+
+	if (get_iter_from_path (priv->store, &iter, device) == FALSE)
+		return FALSE;
+
+	gtk_tree_model_get(GTK_TREE_MODEL (priv->store), &iter,
+			   BLUETOOTH_COLUMN_PROXY, &proxy,
+			   BLUETOOTH_COLUMN_SERVICES, &table,
+			   -1);
+	if (table == NULL || proxy == NULL) {
+		if (proxy != NULL)
+			g_object_unref (proxy);
+		return FALSE;
+	}
+
+	conndata = g_new0 (ConnectData, 1);
+
+	conndata->func = func;
+	conndata->data = data;
+
+	call = dbus_g_proxy_begin_call(proxy, "Disconnect",
+				       disconnect_callback, conndata, g_free,
+				       G_TYPE_INVALID);
+
+	return TRUE;
+}
+

Modified: trunk/common/bluetooth-client.h
==============================================================================
--- trunk/common/bluetooth-client.h	(original)
+++ trunk/common/bluetooth-client.h	Mon Mar 23 16:30:50 2009
@@ -107,6 +107,10 @@
 					  const char *device,
 					  BluetoothClientConnectFunc func,
 					  gpointer data);
+gboolean bluetooth_client_disconnect_service (BluetoothClient *client,
+					      const char *device,
+					      BluetoothClientConnectFunc func,
+					      gpointer data);
 
 const gchar *bluetooth_type_to_string(guint type);
 gboolean bluetooth_verify_address (const char *bdaddr);



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