[folks] bluez: Prevent blocked Bluetooth devices from becoming persona stores



commit c2b005182b114769a768890642d6302bd669f981
Author: Philip Withnall <philip withnall collabora co uk>
Date:   Mon Nov 4 14:09:34 2013 +0000

    bluez: Prevent blocked Bluetooth devices from becoming persona stores
    
    If the user has explicitly blocked a Bluetooth phone from their laptop, they
    don’t want to try downloading contacts from it.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=711406

 NEWS                              |    1 +
 backends/bluez/bluez-backend.vala |   21 +++++++++++++++++----
 2 files changed, 18 insertions(+), 4 deletions(-)
---
diff --git a/NEWS b/NEWS
index afbdb12..e380084 100644
--- a/NEWS
+++ b/NEWS
@@ -30,6 +30,7 @@ Bugs fixed:
   directory
 • Bug 685848 — Add a folks backend for bluez phonebook access
 • Bug 711403 — Tidy up error handling in oFono backend
+• Bug 711406 — Don’t expose blocked BlueZ devices as persona stores
 
 API changes:
 
diff --git a/backends/bluez/bluez-backend.vala b/backends/bluez/bluez-backend.vala
index 251bf1e..96620d4 100644
--- a/backends/bluez/bluez-backend.vala
+++ b/backends/bluez/bluez-backend.vala
@@ -78,6 +78,10 @@ extern const string BACKEND_NAME;
  * will set the PersonaStore’s trust level appropriately, fully trusting devices
  * marked as trusted, and only partially trusting others.
  *
+ * Each device can also be advertised by BlueZ as being blocked or non-blocked.
+ * Blocked devices are not made available as persona stores, even if they are
+ * paired with the laptop.
+ *
  * @since UNRELEASED
  */
 public class Folks.Backends.BlueZ.Backend : Folks.Backend
@@ -226,15 +230,18 @@ public class Folks.Backends.BlueZ.Backend : Folks.Backend
 
       var device = (Device) iface_proxy;
 
-      /* UUIDs and Paired properties. Both affect whether we add or remove a
-       * device/persona store. */
+      /* UUIDs, Paired and Blocked properties. All affect whether we add or
+       * remove a device/persona store. */
       var uuids = changed.lookup_value ("UUIDs", null);
       var paired = changed.lookup_value ("Paired", VariantType.BOOLEAN);
-      if (uuids != null || paired != null)
+      var blocked = changed.lookup_value ("Blocked", VariantType.BOOLEAN);
+
+      if (uuids != null || paired != null || blocked != null)
         {
           /* Sometimes the UUIDs property only changes a second or two after
            * the device first appears, so try adding the device again. */
-          if (device.paired == true && this._device_supports_pbap_pse (device))
+          if (device.paired == true && device.blocked == false &&
+              this._device_supports_pbap_pse (device))
             {
               this._add_device.begin (obj_proxy, (o, r) =>
                 {
@@ -395,6 +402,12 @@ public class Folks.Backends.BlueZ.Backend : Folks.Backend
           return;
         }
 
+      if (device.blocked == true)
+        {
+          debug ("    Device is blocked. Ignoring.");
+          return;
+        }
+
       if (!this._device_supports_pbap_pse (device))
         {
           debug ("    Doesn’t support PBAP PSE. Ignoring.");


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