[gnome-bluetooth] lib: Trust devices paired from the remote device



commit 94ffe58c009ca053cef37c04d302f9cfb43e46c9
Author: Bastien Nocera <hadess hadess net>
Date:   Thu Mar 10 12:50:11 2016 +0100

    lib: Trust devices paired from the remote device
    
    When pairing a device initiated from the remote device (a phone for
    example), we don't receive any feedback that the pairing occurred. That
    means that we won't get the option of setting the device as Trusted as
    we would for a pairing initiated from this GNOME computer.
    
    When a device is paired but not trusted and tries to connect to us,
    assume that the device can connect to this service, otherwise we
    wouldn't have paired it, right?
    
    https://bugzilla.gnome.org/show_bug.cgi?id=763389

 lib/bluetooth-settings-widget.c |   25 +++++++++++++++++--------
 1 files changed, 17 insertions(+), 8 deletions(-)
---
diff --git a/lib/bluetooth-settings-widget.c b/lib/bluetooth-settings-widget.c
index ed067cd..a98da5e 100644
--- a/lib/bluetooth-settings-widget.c
+++ b/lib/bluetooth-settings-widget.c
@@ -742,6 +742,23 @@ authorize_service_callback (GDBusMethodInvocation *invocation,
 
        g_debug ("authorize_service_callback (%s, %s)", g_dbus_proxy_get_object_path (device), uuid);
 
+       value = g_dbus_proxy_get_cached_property (device, "Paired");
+       paired = g_variant_get_boolean (value);
+       g_variant_unref (value);
+
+       value = g_dbus_proxy_get_cached_property (device, "Trusted");
+       trusted = g_variant_get_boolean (value);
+       g_variant_unref (value);
+
+       /* Device was paired, initiated from the remote device,
+        * so we didn't get the opportunity to set the trusted bit */
+       if (paired && !trusted) {
+               bluetooth_client_set_trusted (priv->client,
+                                             g_dbus_proxy_get_object_path (device), TRUE);
+               g_dbus_method_invocation_return_value (invocation, NULL);
+               return;
+       }
+
        if (g_strcmp0 (bluetooth_uuid_to_string (uuid), "HumanInterfaceDeviceService") != 0) {
                msg = g_strdup_printf ("Rejecting service auth (%s) for %s: not HID",
                                       uuid, g_dbus_proxy_get_object_path (device));
@@ -751,14 +768,6 @@ authorize_service_callback (GDBusMethodInvocation *invocation,
        }
 
        /* We shouldn't get asked, but shizzle happens */
-       value = g_dbus_proxy_get_cached_property (device, "Paired");
-       paired = g_variant_get_boolean (value);
-       g_variant_unref (value);
-
-       value = g_dbus_proxy_get_cached_property (device, "Trusted");
-       trusted = g_variant_get_boolean (value);
-       g_variant_unref (value);
-
        if (paired || trusted) {
                g_dbus_method_invocation_return_value (invocation, NULL);
        } else {


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