[gnome-bluetooth] Make the timeout to bluetooth_client_set_discoverable an argument
- From: Ross Burton <rburton src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-bluetooth] Make the timeout to bluetooth_client_set_discoverable an argument
- Date: Thu, 15 Apr 2010 15:41:16 +0000 (UTC)
commit c28470c9d76f62c235dfbb339998c8b47182abdf
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 5655a75..ecab2ed 100644
--- a/applet/main.c
+++ b/applet/main.c
@@ -275,7 +275,7 @@ bluetooth_discoverable_callback (GtkToggleAction *toggleaction, gpointer user_da
discoverable = gtk_toggle_action_get_active (toggleaction);
discover_lock = TRUE;
- bluetooth_client_set_discoverable (client, discoverable);
+ bluetooth_client_set_discoverable (client, discoverable, 0);
discover_lock = FALSE;
}
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 06fd7be..74a9d8e 100644
--- a/lib/bluetooth-client.c
+++ b/lib/bluetooth-client.c
@@ -1579,6 +1579,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.
*
@@ -1586,11 +1587,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);
@@ -1602,10 +1604,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",
@@ -1614,14 +1625,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]