[folks] bluez: Handle the optional Filename property of BlueZ



commit 8a5f2890f4a60a9605de5624bc57a0344633684e
Author: Philip Withnall <philip withnall collabora co uk>
Date:   Wed Nov 13 16:20:19 2013 +0000

    bluez: Handle the optional Filename property of BlueZ
    
    Previously the code assumed that Filename was always set, but it’s
    actually an optional property. Gracefully handle it not existing.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=712274

 backends/bluez/bluez-persona-store.vala |   19 ++++++++++++++++---
 1 files changed, 16 insertions(+), 3 deletions(-)
---
diff --git a/backends/bluez/bluez-persona-store.vala b/backends/bluez/bluez-persona-store.vala
index 2789be1..e1be0ab 100644
--- a/backends/bluez/bluez-persona-store.vala
+++ b/backends/bluez/bluez-persona-store.vala
@@ -628,11 +628,24 @@ public class Folks.Backends.BlueZ.PersonaStore : Folks.PersonaStore
           /* Process the results: either success or error. */
           if (transfer_status == "complete")
             {
-              string filename = transfer.filename;
-              var file = File.new_for_path (filename);
+              string? filename = transfer.filename;
+              if (filename == null)
+                {
+                  /* The Filename property is optional, so bail if it’s not
+                   * available for whatever reason. */
+                  throw new PersonaStoreError.STORE_OFFLINE (
+                      /* Translators: the first parameter is the name of the
+                       * failed transfer, and the second is a Bluetooth device
+                       * alias. */
+                      _("Error during transfer of the address book ‘%s’ from " +
+                        "Bluetooth device ‘%s’."),
+                      transfer.name, this._display_name);
+                }
+
+              var file = File.new_for_path ((!) filename);
 
               debug ("vCard’s filename for device ‘%s’ (%s): %s",
-                  this._display_name, this.id, filename);
+                  this._display_name, this.id, (!) filename);
 
               yield this._update_contacts_from_file (file);
             }


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