[gnome-bluetooth/moblin-dev] Make the timeout to bluetooth_client_set_discoverable an argument



commit 1b5c8f876b1cff53c6da997c12db2dfd83a8090f
Author: Ross Burton <ross linux intel com>
Date:   Mon Feb 22 08:02:38 2010 +0000

    Make the timeout to bluetooth_client_set_discoverable an argument

 applet/main.c                  |    2 +-
 lib/bluetooth-client-private.h |    3 ++-
 lib/bluetooth-client.c         |   26 ++++++++++++++++----------
 properties/adapter.c           |    2 +-
 4 files changed, 20 insertions(+), 13 deletions(-)
---
diff --git a/applet/main.c b/applet/main.c
index 3261d03..c566a61 100644
--- a/applet/main.c
+++ b/applet/main.c
@@ -273,7 +273,7 @@ bluetooth_discoverable_callback (GtkToggleAction *toggleaction, gpointer user_da
 	gboolean discoverable;
 
 	discoverable = gtk_toggle_action_get_active (toggleaction);
-	bluetooth_client_set_discoverable (client, discoverable);
+	bluetooth_client_set_discoverable (client, discoverable, 0);
 }
 
 static gboolean program_available(const char *program)
diff --git a/lib/bluetooth-client-private.h b/lib/bluetooth-client-private.h
index 8a47ddf..07d1501 100644
--- a/lib/bluetooth-client-private.h
+++ b/lib/bluetooth-client-private.h
@@ -38,7 +38,8 @@ DBusGProxy *bluetooth_client_get_default_adapter(BluetoothClient *client);
 gboolean bluetooth_client_start_discovery(BluetoothClient *client);
 gboolean bluetooth_client_stop_discovery(BluetoothClient *client);
 gboolean bluetooth_client_set_discoverable (BluetoothClient *client,
-					    gboolean discoverable);
+					    gboolean discoverable,
+                                            guint timeout);
 
 typedef void (*BluetoothClientCreateDeviceFunc) (BluetoothClient *client,
 						 const char *path,
diff --git a/lib/bluetooth-client.c b/lib/bluetooth-client.c
index 967c113..87818e6 100644
--- a/lib/bluetooth-client.c
+++ b/lib/bluetooth-client.c
@@ -1609,6 +1609,7 @@ gboolean bluetooth_client_stop_discovery(BluetoothClient *client)
  * bluetooth_client_set_discoverable:
  * @client: a #BluetoothClient object
  * @discoverable: whether the device should be discoverable
+ * @timeout: timeout in seconds for making undiscoverable, or 0 for never.
  *
  * Sets the default adapter's discoverable status.
  *
@@ -1616,11 +1617,12 @@ gboolean bluetooth_client_stop_discovery(BluetoothClient *client)
  **/
 gboolean
 bluetooth_client_set_discoverable (BluetoothClient *client,
-				   gboolean discoverable)
+				   gboolean discoverable,
+                                   guint timeout)
 {
 	DBusGProxy *adapter;
 	GValue disco = { 0 };
-	GValue timeout = { 0 };
+	GValue timeoutv = { 0 };
 	gboolean ret;
 
 	g_return_val_if_fail (BLUETOOTH_IS_CLIENT (client), FALSE);
@@ -1632,10 +1634,19 @@ bluetooth_client_set_discoverable (BluetoothClient *client,
 		return FALSE;
 
 	g_value_init (&disco, G_TYPE_BOOLEAN);
-	g_value_init (&timeout, G_TYPE_UINT);
+	g_value_init (&timeoutv, G_TYPE_UINT);
 
 	g_value_set_boolean (&disco, discoverable);
-	g_value_set_uint (&timeout, 0);
+	g_value_set_uint (&timeoutv, timeout);
+
+        if (discoverable) {
+		ret = dbus_g_proxy_call (adapter, "SetProperty", NULL,
+					 G_TYPE_STRING, "DiscoverableTimeout",
+					 G_TYPE_VALUE, &timeoutv,
+					 G_TYPE_INVALID, G_TYPE_INVALID);
+		if (ret == FALSE)
+			goto bail;
+	}
 
 	ret = dbus_g_proxy_call (adapter, "SetProperty", NULL,
 				 G_TYPE_STRING, "Discoverable",
@@ -1644,14 +1655,9 @@ bluetooth_client_set_discoverable (BluetoothClient *client,
 	if (ret == FALSE)
 		goto bail;
 
-	ret = dbus_g_proxy_call (adapter, "SetProperty", NULL,
-				 G_TYPE_STRING, "DiscoverableTimeout",
-				 G_TYPE_VALUE, &timeout,
-				 G_TYPE_INVALID, G_TYPE_INVALID);
-
 bail:
 	g_value_unset (&disco);
-	g_value_unset (&timeout);
+	g_value_unset (&timeoutv);
 
 	g_object_unref(adapter);
 
diff --git a/properties/adapter.c b/properties/adapter.c
index 54620d3..5237bad 100644
--- a/properties/adapter.c
+++ b/properties/adapter.c
@@ -87,7 +87,7 @@ static void discoverable_changed_cb(GtkWidget *button, gpointer user_data)
 	/* Note that this would be broken if we showed more than
 	 * one adapter, but we don't care */
 	gtk_toggle_button_set_inconsistent (GTK_TOGGLE_BUTTON (button), FALSE);
-	bluetooth_client_set_discoverable (client, gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)));
+	bluetooth_client_set_discoverable (client, gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)), 0);
 }
 
 static void name_callback(GtkWidget *editable, gpointer user_data)



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