summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Nocera <hadess@hadess.net>2016-03-10 12:50:11 +0100
committerBastien Nocera <hadess@hadess.net>2016-03-10 12:50:11 +0100
commit94ffe58c009ca053cef37c04d302f9cfb43e46c9 (patch)
tree3d22137f4c2de35e7a7ef64b6a1d5b3048b3e7d2
parentc0777608db5426f9b53ac4224f438d960e1ccd05 (diff)
downloadgnome-bluetooth-94ffe58c009ca053cef37c04d302f9cfb43e46c9.tar.gz
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
-rw-r--r--lib/bluetooth-settings-widget.c25
1 files changed, 17 insertions, 8 deletions
diff --git a/lib/bluetooth-settings-widget.c b/lib/bluetooth-settings-widget.c
index ed067cd7..a98da5e3 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 {