[folks/folks-0-4] Fix Tpf.Persona to use its store's ID in persona UIDs



commit 8cc9064a2516b82e984e098c48568e6cf4613fe0
Author: Philip Withnall <philip withnall collabora co uk>
Date:   Sat Jan 22 11:34:53 2011 +0000

    Fix Tpf.Persona to use its store's ID in persona UIDs
    
    It was previously (incorrectly) not using the PersonaStore's ID as the middle
    component in its UID, which meant that the same IM address as added on two
    different accounts using the same protocol would have the same UID,
    undermining the concept of a UID as a globally unique identifier for a
    Persona.
    
    Closes: bgo#647121

 backends/telepathy/lib/tpf-persona.vala    |    2 +-
 tests/folks/aggregation.vala               |   15 ++++++++++-----
 tests/telepathy/individual-properties.vala |    3 ++-
 tests/telepathy/individual-retrieval.vala  |    3 ++-
 4 files changed, 15 insertions(+), 8 deletions(-)
---
diff --git a/backends/telepathy/lib/tpf-persona.vala b/backends/telepathy/lib/tpf-persona.vala
index b3bc8ae..1168788 100644
--- a/backends/telepathy/lib/tpf-persona.vala
+++ b/backends/telepathy/lib/tpf-persona.vala
@@ -227,7 +227,7 @@ public class Tpf.Persona : Folks.Persona,
       unowned string id = contact.get_identifier ();
       unowned Connection connection = contact.connection;
       var account = this._account_for_connection (connection);
-      var uid = this.build_uid (store.type_id, account.get_protocol (), id);
+      var uid = this.build_uid (store.type_id, store.id, id);
 
       Object (alias: contact.get_alias (),
               contact: contact,
diff --git a/tests/folks/aggregation.vala b/tests/folks/aggregation.vala
index 10ab3df..8e29cbf 100644
--- a/tests/folks/aggregation.vala
+++ b/tests/folks/aggregation.vala
@@ -7,7 +7,6 @@ public class AggregationTests : Folks.TestCase
   private KfTest.Backend _kf_backend;
   private TpTest.Backend _tp_backend;
   private HashSet<string> _default_individuals;
-  private string _individual_id_prefix = "telepathy:protocol:";
   private int _test_timeout = 3;
 
   public AggregationTests ()
@@ -81,7 +80,7 @@ public class AggregationTests : Folks.TestCase
       HashSet<string> expected_individuals = new HashSet<string> ();
       foreach (var id in this._default_individuals)
         {
-          expected_individuals.add (this._individual_id_prefix + id);
+          expected_individuals.add (id);
         }
 
       /* Set up the aggregator */
@@ -92,11 +91,14 @@ public class AggregationTests : Folks.TestCase
            * individuals (if they were originally on it) */
           foreach (Individual i in removed)
             {
+              var parts = i.id.split (":");
+              var id = parts[2];
+
               if (!i.is_user &&
                   i.personas.length () == 2 &&
-                  this._default_individuals.contains (i.id))
+                  this._default_individuals.contains (id))
                 {
-                  expected_individuals.add (i.id);
+                  expected_individuals.add (id);
                 }
             }
 
@@ -104,12 +106,15 @@ public class AggregationTests : Folks.TestCase
            * from the set of expected individuals. */
           foreach (Individual i in added)
             {
+              var parts = i.id.split (":");
+              var id = parts[2];
+
               unowned GLib.List<Persona> personas = i.personas;
 
               /* We're not testing the user here */
               if (!i.is_user && personas.length () == 2)
                 {
-                  assert (expected_individuals.remove (i.id));
+                  assert (expected_individuals.remove (id));
                   assert (personas.data.iid == personas.next.data.iid);
                 }
             }
diff --git a/tests/telepathy/individual-properties.vala b/tests/telepathy/individual-properties.vala
index a63e176..20a4c77 100644
--- a/tests/telepathy/individual-properties.vala
+++ b/tests/telepathy/individual-properties.vala
@@ -9,7 +9,8 @@ public class IndividualPropertiesTests : Folks.TestCase
 {
   private TpTest.Backend tp_backend;
   private void* _account_handle;
-  private string individual_id_prefix = "telepathy:protocol:";
+  private string individual_id_prefix =
+      "telepathy:/org/freedesktop/Telepathy/Account/cm/protocol/account:";
   private int _test_timeout = 3;
 
   public IndividualPropertiesTests ()
diff --git a/tests/telepathy/individual-retrieval.vala b/tests/telepathy/individual-retrieval.vala
index 5e652b1..31d6955 100644
--- a/tests/telepathy/individual-retrieval.vala
+++ b/tests/telepathy/individual-retrieval.vala
@@ -10,7 +10,8 @@ public class IndividualRetrievalTests : Folks.TestCase
   private TpTest.Backend tp_backend;
   private void* _account_handle;
   private HashSet<string> default_individuals;
-  private string individual_id_prefix = "telepathy:protocol:";
+  private string individual_id_prefix =
+      "telepathy:/org/freedesktop/Telepathy/Account/cm/protocol/account:";
   private int _test_timeout = 3;
 
   public IndividualRetrievalTests ()



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