diff options
author | Philip Withnall <philip.withnall@collabora.co.uk> | 2013-11-13 16:20:19 +0000 |
---|---|---|
committer | Philip Withnall <philip@tecnocode.co.uk> | 2014-02-16 23:52:31 +0000 |
commit | 8a5f2890f4a60a9605de5624bc57a0344633684e (patch) | |
tree | 073d10013135d1fa2a9341891f96bb78db2e959e | |
parent | d1fe72ace7171f208e3886c319f5c9d84cc94835 (diff) |
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
-rw-r--r-- | 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 2789be1c..e1be0abc 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); } |