diff options
author | Bastien Nocera <hadess@hadess.net> | 2010-08-03 10:27:55 +0100 |
---|---|---|
committer | Bastien Nocera <hadess@hadess.net> | 2010-08-03 10:27:55 +0100 |
commit | a9ae8d85cb6b0fbff7078a7d8e4f9496adbd4272 (patch) | |
tree | f35b62ab6091a845e6bf47951fab14038c119cd0 | |
parent | 5d67200565aefeafdabe2de3a447aa80c1f4ef52 (diff) | |
download | gnome-bluetooth-a9ae8d85cb6b0fbff7078a7d8e4f9496adbd4272.tar.gz |
Fix adapter not going powered when coming back from hard-block
1. Soft-kill the adapter
2. Hard-kill the adapter
3. Disable hard-kill
4. Disable soft-kill
At 4., the adapter will be present, unblocked, but still
unpowered. Call SetPower on it to make sure it is revived.
https://bugzilla.redhat.com/show_bug.cgi?id=609291
-rw-r--r-- | applet/main.c | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/applet/main.c b/applet/main.c index 9e7e44c9..c8b66a4f 100644 --- a/applet/main.c +++ b/applet/main.c @@ -249,6 +249,45 @@ void wizard_callback(GObject *widget, gpointer user_data) g_printerr("Couldn't execute command: %s\n", command); } +static gboolean +set_powered_foreach (GtkTreeModel *model, + GtkTreePath *path, + GtkTreeIter *iter, + gpointer data) +{ + DBusGProxy *proxy = NULL; + GValue value = { 0, }; + + gtk_tree_model_get (model, iter, + BLUETOOTH_COLUMN_PROXY, &proxy, -1); + if (proxy == NULL) + return FALSE; + + g_value_init (&value, G_TYPE_BOOLEAN); + g_value_set_boolean (&value, TRUE); + + dbus_g_proxy_call_no_reply (proxy, "SetProperty", + G_TYPE_STRING, "Powered", + G_TYPE_VALUE, &value, + G_TYPE_INVALID, + G_TYPE_INVALID); + + g_value_unset (&value); + g_object_unref (proxy); + + return FALSE; +} + +static void +bluetooth_set_adapter_powered (void) +{ + GtkTreeModel *adapters; + + adapters = bluetooth_client_get_adapter_model (client); + gtk_tree_model_foreach (adapters, set_powered_foreach, NULL); + g_object_unref (adapters); +} + void bluetooth_status_callback (GObject *widget, gpointer user_data) { GObject *object; @@ -260,6 +299,7 @@ void bluetooth_status_callback (GObject *widget, gpointer user_data) bluetooth_killswitch_set_state (killswitch, active ? KILLSWITCH_STATE_UNBLOCKED : KILLSWITCH_STATE_SOFT_BLOCKED); g_object_set_data (object, "bt-active", GINT_TO_POINTER (active)); + bluetooth_set_adapter_powered (); } static gboolean program_available(const char *program) |