[gnome-bluetooth] settings: Implement authorise service for HID devices
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-bluetooth] settings: Implement authorise service for HID devices
- Date: Mon, 9 Dec 2013 17:39:32 +0000 (UTC)
commit 5f3fff02ca9860236227b28459536f0a6c89388f
Author: Bastien Nocera <hadess hadess net>
Date: Mon Dec 9 15:54:49 2013 +0100
settings: Implement authorise service for HID devices
If they're paired or trusted, allow the remote device to connect.
This can happen if we didn't know that the remote device actually
did input (like, if it got removed after the reverse SDP), so
hack around that.
lib/bluetooth-settings-widget.c | 31 +++++++++++++++++++++++++++----
1 files changed, 27 insertions(+), 4 deletions(-)
---
diff --git a/lib/bluetooth-settings-widget.c b/lib/bluetooth-settings-widget.c
index 565c5db..3d7584a 100644
--- a/lib/bluetooth-settings-widget.c
+++ b/lib/bluetooth-settings-widget.c
@@ -598,13 +598,36 @@ authorize_service_callback (GDBusMethodInvocation *invocation,
gpointer user_data)
{
char *msg;
+ GVariant *value;
+ gboolean paired, trusted;
g_debug ("authorize_service_callback (%s, %s)", g_dbus_proxy_get_object_path (device), uuid);
- msg = g_strdup_printf ("Rejecting service auth (%s) for %s",
- uuid, g_dbus_proxy_get_object_path (device));
- g_dbus_method_invocation_return_dbus_error (invocation, "org.bluez.Error.Rejected", msg);
- g_free (msg);
+ 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));
+ g_dbus_method_invocation_return_dbus_error (invocation, "org.bluez.Error.Rejected", msg);
+ g_free (msg);
+ return;
+ }
+
+ /* 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 {
+ msg = g_strdup_printf ("Rejecting service auth (%s) for %s: not paired or trusted",
+ uuid, g_dbus_proxy_get_object_path (device));
+ g_dbus_method_invocation_return_dbus_error (invocation, "org.bluez.Error.Rejected", msg);
+ g_free (msg);
+ }
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]