[folks] bluez: Remove unnecessary OBEX List() D-Bus call
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [folks] bluez: Remove unnecessary OBEX List() D-Bus call
- Date: Sat, 4 Jan 2014 15:29:03 +0000 (UTC)
commit 0d05c5651fdd5118e3de53de6024d38adac8cb98
Author: Philip Withnall <philip withnall collabora co uk>
Date: Fri Nov 8 13:20:21 2013 +0000
bluez: Remove unnecessary OBEX List() D-Bus call
It returns a mapping of VCF filenames to contact full names, which we
already have from the full VCF file. Minor performance improvement
(although I haven’t profiled it).
https://bugzilla.gnome.org/show_bug.cgi?id=711827
backends/bluez/bluez-persona-store.vala | 54 +++++++-----------------------
backends/bluez/bluez-persona.vala | 22 ++++++++----
2 files changed, 28 insertions(+), 48 deletions(-)
---
diff --git a/backends/bluez/bluez-persona-store.vala b/backends/bluez/bluez-persona-store.vala
index 44d69f4..a95b875 100644
--- a/backends/bluez/bluez-persona-store.vala
+++ b/backends/bluez/bluez-persona-store.vala
@@ -54,7 +54,6 @@ public class Folks.Backends.BlueZ.PersonaStore : Folks.PersonaStore
private static string[] _always_writeable_properties = {};
private org.bluez.obex.Client _obex_client;
- private HashTable<string, Variant> _phonebook_filter;
private string _object_path;
private Device _device;
private string _display_name;
@@ -215,12 +214,6 @@ public class Folks.Backends.BlueZ.PersonaStore : Folks.PersonaStore
{
this._personas = new HashMap<string, Persona> ();
this._personas_ro = this._personas.read_only_view;
- this._phonebook_filter = new HashTable<string, Variant> (null , null);
- this._phonebook_filter.insert ("Format", "Vcard30");
- this._phonebook_filter.insert ("Fields",
- new Variant.strv ({
- "N", "FN", "NICKNAME", "TEL", "URL", "EMAIL", "PHOTO"
- }));
}
/**
@@ -234,29 +227,15 @@ public class Folks.Backends.BlueZ.PersonaStore : Folks.PersonaStore
* unchanged.
*
* @param file the file where the contacts are stored
- * @param obex_pbap the current OBEX PBAP D-Bus proxy
* @throws IOError if there was an error communicating with D-Bus
- * @throws DBusError if an error was returned over the bus
* @throws Error if the given file couldn’t be read
*
* @since 0.9.6
*/
- private async void _update_contacts_from_file (File file,
- org.bluez.obex.PhonebookAccess obex_pbap)
- throws DBusError, IOError
+ private async void _update_contacts_from_file (File file) throws IOError
{
var added_personas = new HashSet<Persona> ();
- /* Get the vCard listing data where every entry
- * consists of a pair of strings containing the vCard
- * handle and the contact name. For example:
- * "0.vcf" : "Me"
- * "1.vcf" : "John"
- *
- * First entry corresponds to the user themselves.
- */
- var entries = obex_pbap.list (this._phonebook_filter);
-
try
{
var dis = new DataInputStream (file.read ());
@@ -275,13 +254,10 @@ public class Folks.Backends.BlueZ.PersonaStore : Folks.PersonaStore
vcard.append_c ('\n');
if (line.strip () == "END:VCARD")
{
- var entry = entries[i];
-
/* The first vCard is always the user themselves. */
var is_user = (i == 0);
- var persona = new Persona (entry.vcard, entry.name,
- vcard.str, this, is_user);
+ var persona = new Persona (vcard.str, this, is_user);
added_personas.add (persona);
i++;
@@ -461,7 +437,6 @@ public class Folks.Backends.BlueZ.PersonaStore : Folks.PersonaStore
* unchanged.
*
* @param path the D-Bus transfer object path to watch.
- * @param obex_pbap an OBEX PBAP proxy object to access the address book from
* @param cancellable an optional { link Cancellable} object to cancel the
* transfer
*
@@ -473,7 +448,6 @@ public class Folks.Backends.BlueZ.PersonaStore : Folks.PersonaStore
* @since 0.9.6
*/
private async void _perform_obex_transfer (string path,
- org.bluez.obex.PhonebookAccess obex_pbap,
Cancellable? cancellable = null)
throws IOError, PersonaStoreError
{
@@ -557,7 +531,7 @@ public class Folks.Backends.BlueZ.PersonaStore : Folks.PersonaStore
debug ("vCard’s filename for device ‘%s’ (%s): %s",
this._display_name, this.id, filename);
- yield this._update_contacts_from_file (file, obex_pbap);
+ yield this._update_contacts_from_file (file);
}
else if (transfer_status == "error")
{
@@ -577,15 +551,6 @@ public class Folks.Backends.BlueZ.PersonaStore : Folks.PersonaStore
assert_not_reached ();
}
}
- catch (DBusError e2)
- {
- throw new PersonaStoreError.STORE_OFFLINE (
- /* Translators: the first parameter is the name of the
- * failed transfer, the second is a Bluetooth device
- * alias, and the third is an error message. */
- _("Error during transfer of the address book ‘%s’ from Bluetooth device ‘%s’: %s"),
- transfer.name, this._display_name, e2.message);
- }
finally
{
/* Reset the OBEX transfer and clear out the temporary file. Do this
@@ -685,8 +650,15 @@ public class Folks.Backends.BlueZ.PersonaStore : Folks.PersonaStore
/* Initiate a phone book transfer from the PSE server using a
* plain string vCard format, transferring to a temporary file. */
- obex_pbap.pull_all ("", this._phonebook_filter, out path,
- out props);
+ var phonebook_filter =
+ new HashTable<string, Variant> (null , null);
+ phonebook_filter.insert ("Format", "Vcard30");
+ phonebook_filter.insert ("Fields",
+ new Variant.strv ({
+ "N", "FN", "NICKNAME", "TEL", "URL", "EMAIL", "PHOTO"
+ }));
+
+ obex_pbap.pull_all ("", phonebook_filter, out path, out props);
}
catch (GLib.Error e2)
{
@@ -699,7 +671,7 @@ public class Folks.Backends.BlueZ.PersonaStore : Folks.PersonaStore
try
{
- yield this._perform_obex_transfer (path, obex_pbap,
+ yield this._perform_obex_transfer (path,
this._update_contacts_cancellable);
}
catch (IOError e3)
diff --git a/backends/bluez/bluez-persona.vala b/backends/bluez/bluez-persona.vala
index f75acc6..52ad485 100644
--- a/backends/bluez/bluez-persona.vala
+++ b/backends/bluez/bluez-persona.vala
@@ -74,6 +74,17 @@ public class Folks.Backends.BlueZ.Persona : Folks.Persona,
*
* @since 0.9.6
*/
+ public new string display_id
+ {
+ get { return this._full_name; }
+ construct { this._full_name = value; }
+ }
+
+ /**
+ * { inheritDoc}
+ *
+ * @since 0.9.6
+ */
[CCode (notify = false)]
public Set<UrlFieldDetails> urls
{
@@ -167,24 +178,20 @@ public class Folks.Backends.BlueZ.Persona : Folks.Persona,
* Create a new persona.
*
* Create a new persona for the { link PersonaStore} ``store``, representing
- * the Persona given by the group ``uid`` in the key file ``key_file``.
+ * the Persona in the given ``vcard``.
*
- * @param vcf the VCard filename reference. For example: 0.vcf.
- * @param name the Persona the contact name or alias.
* @param vcard the Vcard stored as a string.
* @param store the store to which the Persona belongs.
* @param is_user whether the Persona is the user itself or not.
*
* @since 0.9.6
*/
- public Persona (string vcf, string name, string vcard,
- Folks.PersonaStore store, bool is_user)
+ public Persona (string vcard, Folks.PersonaStore store, bool is_user)
{
var iid = Checksum.compute_for_string (ChecksumType.SHA1, vcard);
var uid = Folks.Persona.build_uid ("bluez", store.id, iid);
- Object (display_id: name,
- iid: iid,
+ Object (iid: iid,
uid: uid,
store: store,
is_user: is_user);
@@ -221,6 +228,7 @@ public class Folks.Backends.BlueZ.Persona : Folks.Persona,
attribute = card.get_attribute ("FN");
if (attribute != null)
{
+ /* Also the display-id. */
this._full_name = attribute.get_value_decoded ().str;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]