[folks] core: Tighten up definition of Persona.display _id to ensure it’s unique
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [folks] core: Tighten up definition of Persona.display _id to ensure it’s unique
- Date: Sat, 4 Jan 2014 15:29:08 +0000 (UTC)
commit 1652c7b5d33791076bbc18a7196ada9fe77784dc
Author: Philip Withnall <philip withnall collabora co uk>
Date: Mon Nov 11 08:17:04 2013 +0000
core: Tighten up definition of Persona.display_id to ensure it’s unique
It is defined as being unique, so cannot be a human-readable full name,
since those can be non-unique. Update the EDS, oFono and Tracker backends to
use their persona IIDs as display IDs, instead full names. This isn’t an
API break, as the API was always documented as being unique.
https://bugzilla.gnome.org/show_bug.cgi?id=711827
backends/bluez/bluez-persona.vala | 19 +++++--------------
backends/eds/lib/edsf-persona.vala | 4 +++-
backends/ofono/ofono-persona.vala | 4 +++-
backends/tracker/lib/trf-persona.vala | 11 +++--------
folks/persona.vala | 4 +++-
5 files changed, 17 insertions(+), 25 deletions(-)
---
diff --git a/backends/bluez/bluez-persona.vala b/backends/bluez/bluez-persona.vala
index 52ad485..9dca903 100644
--- a/backends/bluez/bluez-persona.vala
+++ b/backends/bluez/bluez-persona.vala
@@ -74,17 +74,6 @@ 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
{
@@ -191,7 +180,10 @@ public class Folks.Backends.BlueZ.Persona : Folks.Persona,
var iid = Checksum.compute_for_string (ChecksumType.SHA1, vcard);
var uid = Folks.Persona.build_uid ("bluez", store.id, iid);
- Object (iid: iid,
+ /* Have to use the IID as the display ID, since PBAP vCards provide no
+ * other useful human-readable and unique IDs. */
+ Object (display_id: iid,
+ iid: iid,
uid: uid,
store: store,
is_user: is_user);
@@ -201,8 +193,7 @@ public class Folks.Backends.BlueZ.Persona : Folks.Persona,
construct
{
- debug ("Adding BlueZ Persona '%s' (IID '%s', group '%s')", this.uid,
- this.iid, this.display_id);
+ debug ("Adding BlueZ Persona '%s' (IID '%s')", this.uid, this.iid);
this._phone_numbers = new HashSet<PhoneFieldDetails> ();
this._phone_numbers_ro = this._phone_numbers.read_only_view;
diff --git a/backends/eds/lib/edsf-persona.vala b/backends/eds/lib/edsf-persona.vala
index 0274605..06d363e 100644
--- a/backends/eds/lib/edsf-persona.vala
+++ b/backends/eds/lib/edsf-persona.vala
@@ -956,7 +956,9 @@ public class Edsf.Persona : Folks.Persona,
"full_name");
var full_name = (!) (_full_name ?? "");
- Object (display_id: full_name,
+ /* Use the IID as the display ID since no other suitable identifier is
+ * available which we can guarantee is unique within the store. */
+ Object (display_id: iid,
uid: uid,
iid: iid,
store: store,
diff --git a/backends/ofono/ofono-persona.vala b/backends/ofono/ofono-persona.vala
index c0b720e..8a94fd9 100644
--- a/backends/ofono/ofono-persona.vala
+++ b/backends/ofono/ofono-persona.vala
@@ -133,7 +133,9 @@ public class Folks.Backends.Ofono.Persona : Folks.Persona,
var iid = Checksum.compute_for_string (ChecksumType.SHA1, vcard);
var uid = Folks.Persona.build_uid ("ofono", store.id, iid);
- Object (display_id: uid,
+ /* Use the IID as the display ID since no other suitable identifier is
+ * available which we can guarantee is unique within the store. */
+ Object (display_id: iid,
iid: iid,
uid: uid,
store: store,
diff --git a/backends/tracker/lib/trf-persona.vala b/backends/tracker/lib/trf-persona.vala
index 770e044..e54dfdd 100644
--- a/backends/tracker/lib/trf-persona.vala
+++ b/backends/tracker/lib/trf-persona.vala
@@ -525,16 +525,9 @@ public class Trf.Persona : Folks.Persona,
string uid = Folks.Persona.build_uid (BACKEND_NAME, store.id, tracker_id);
string iid = Trf.Persona.build_iid (store.id, tracker_id);
bool is_user = false;
- string fullname = "";
if (cursor != null)
{
- fullname = cursor.get_string (Trf.Fields.FULL_NAME).dup ();
- if (fullname == null)
- {
- fullname = "";
- }
-
var contact_urn = cursor.get_string (Trf.Fields.CONTACT_URN);
if (contact_urn == Trf.OntologyDefs.DEFAULT_CONTACT_URN)
{
@@ -542,7 +535,9 @@ public class Trf.Persona : Folks.Persona,
}
}
- Object (display_id: fullname,
+ /* Use the IID as the display ID since no other suitable identifier is
+ * available which we can guarantee is unique within the store. */
+ Object (display_id: iid,
uid: uid,
iid: iid,
store: store,
diff --git a/folks/persona.vala b/folks/persona.vala
index f08d237..6c54686 100644
--- a/folks/persona.vala
+++ b/folks/persona.vala
@@ -133,7 +133,9 @@ public abstract class Folks.Persona : Object
* with.
*
* This is not guaranteed to be unique outside of the Persona's
- * { link PersonaStore}.
+ * { link PersonaStore}, but is guaranteed to be unique within it. If a
+ * suitable human-readable ID isn’t available from the backend, the display ID
+ * will be equal to the { link Persona.iid}.
*
* @since 0.1.13
*/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]