[folks] Change IndividualAggregator.link_personas() to take a Set<Persona>



commit 2d66369e4196c71aa390405ee82c67dd4af980ca
Author: Philip Withnall <philip withnall collabora co uk>
Date:   Wed Apr 20 00:58:00 2011 +0100

    Change IndividualAggregator.link_personas() to take a Set<Persona>
    
    Helps: bgo#640092

 NEWS                                           |    1 +
 folks/individual-aggregator.vala               |   12 ++++--------
 tests/libsocialweb/aggregation.vala            |    8 ++++----
 tests/tracker/link-personas-via-local-ids.vala |   10 +++++-----
 tests/tracker/link-personas.vala               |   10 +++++-----
 5 files changed, 19 insertions(+), 22 deletions(-)
---
diff --git a/NEWS b/NEWS
index d828ae5..64d7212 100644
--- a/NEWS
+++ b/NEWS
@@ -34,6 +34,7 @@ API changes:
 * PersonaStore.personas_changed now uses Set<Persona>-typed parameters
 * IndividualAggregator.individuals_changed now uses
   Set<Individual>-typed parameters
+* IndividualAggregator.link_personas() now takes a Set<Persona>
 
 Overview of changes from libfolks 0.4.0 to libfolks 0.5.0
 =========================================================
diff --git a/folks/individual-aggregator.vala b/folks/individual-aggregator.vala
index 11b3364..97819cc 100644
--- a/folks/individual-aggregator.vala
+++ b/folks/individual-aggregator.vala
@@ -928,16 +928,12 @@ public class Folks.IndividualAggregator : Object
    * before is signalled by { link IndividualAggregator.individuals_changed} and
    * { link Individual.removed}.
    *
-   * @param personas_in the { link Persona}s to be linked
-   * @since 0.1.13
+   * @param personas the { link Persona}s to be linked
+   * @since UNRELEASED
    */
-  public async void link_personas (void *personas_in)
+  public async void link_personas (Set<Persona> personas)
       throws IndividualAggregatorError
     {
-      /* FIXME: personas_in should be GLib.List<Persona>, but Vala won't allow
-       * it */
-      unowned GLib.List<Persona> personas = (GLib.List<Persona>) personas_in;
-
       if (this._writeable_store == null)
         {
           throw new IndividualAggregatorError.NO_WRITEABLE_STORE (
@@ -945,7 +941,7 @@ public class Folks.IndividualAggregator : Object
         }
 
       /* Don't bother linking if it's just one Persona */
-      if (personas.next == null)
+      if (personas.size <= 1)
         return;
 
       /* Disallow linking if it's disabled */
diff --git a/tests/libsocialweb/aggregation.vala b/tests/libsocialweb/aggregation.vala
index 2d109ea..8cf147d 100644
--- a/tests/libsocialweb/aggregation.vala
+++ b/tests/libsocialweb/aggregation.vala
@@ -222,23 +222,23 @@ public class AggregationTests : Folks.TestCase
         });
 
       /* Link personas */
-      var personas = new GLib.List<unowned Persona>();
+      var personas = new HashSet<Persona> ();
 
       var personas1 = new GLib.List<unowned Persona> ();
       foreach (var p1 in individual_gathered[0].personas)
         {
-          personas.append (p1);
+          personas.add (p1);
           personas1.append (p1);
         }
 
       var personas2 = new GLib.List<unowned Persona> ();
       foreach (var p2 in individual_gathered[1].personas)
         {
-          personas.append (p2);
+          personas.add (p2);
           personas2.append (p2);
         }
 
-      assert (personas.length () == 2);
+      assert (personas.size == 2);
 
       Idle.add (() =>
         {
diff --git a/tests/tracker/link-personas-via-local-ids.vala b/tests/tracker/link-personas-via-local-ids.vala
index b196df5..f8d9767 100644
--- a/tests/tracker/link-personas-via-local-ids.vala
+++ b/tests/tracker/link-personas-via-local-ids.vala
@@ -35,7 +35,7 @@ public class LinkPersonasViaLocalIDsTests : Folks.TestCase
   private bool _persona_found_2;
   private string _persona_uid_1 = "";
   private string _persona_uid_2 = "";
-  private GLib.List<Persona> _personas;
+  private HashSet<Persona> _personas;
   private int _removed_individuals = 0;
   private string _folks_config_key = "/system/folks/backends/primary_store";
   private unowned GConf.Client _gconf_client;
@@ -96,7 +96,7 @@ public class LinkPersonasViaLocalIDsTests : Folks.TestCase
       this._main_loop = new GLib.MainLoop (null, false);
       this._persona_fullname_1 = "persona #1";
       this._persona_fullname_2 = "persona #2";
-      this._personas = new GLib.List<Persona> ();
+      this._personas = new HashSet<Persona> ();
 
       this._persona_found_1 = false;
       this._persona_found_2 = false;
@@ -240,14 +240,14 @@ public class LinkPersonasViaLocalIDsTests : Folks.TestCase
           this._persona_uid_1 == "")
         {
           this._persona_uid_1 = first_persona.uid;
-          this._personas.prepend (first_persona);
+          this._personas.add (first_persona);
           this._local_ids.add (this._persona_uid_1);
         }
       else if (i.full_name == this._persona_fullname_2 &&
           this._persona_uid_2 == "")
         {
           this._persona_uid_2 = first_persona.uid;
-          this._personas.prepend (first_persona);
+          this._personas.add (first_persona);
           this._local_ids.add (this._persona_uid_2);
         }
       else if (i.personas.size > 1)
@@ -269,7 +269,7 @@ public class LinkPersonasViaLocalIDsTests : Folks.TestCase
 
       /* We can try linking the personas only once we've got the
        * 2 initially created personas. */
-      if (this._personas.length () == 2 &&
+      if (this._personas.size == 2 &&
           this._linking_fired == false)
         {
           this._linking_fired = true;
diff --git a/tests/tracker/link-personas.vala b/tests/tracker/link-personas.vala
index f857c8f..9f30701 100644
--- a/tests/tracker/link-personas.vala
+++ b/tests/tracker/link-personas.vala
@@ -38,7 +38,7 @@ public class LinkPersonasTests : Folks.TestCase
   private bool _persona_found_2;
   private string _persona_iid_1 = "";
   private string _persona_iid_2 = "";
-  private GLib.List<Persona> _personas;
+  private HashSet<Persona> _personas;
   private int _removed_individuals = 0;
   private string _folks_config_key = "/system/folks/backends/primary_store";
   private unowned GConf.Client _gconf_client;
@@ -98,7 +98,7 @@ public class LinkPersonasTests : Folks.TestCase
       this._main_loop = new GLib.MainLoop (null, false);
       this._persona_fullname_1 = "persona #1";
       this._persona_fullname_2 = "persona #2";
-      this._personas = new GLib.List<Persona> ();
+      this._personas = new HashSet<Persona> ();
 
       this._persona_found_1 = false;
       this._persona_found_2 = false;
@@ -256,13 +256,13 @@ public class LinkPersonasTests : Folks.TestCase
           this._persona_iid_1 == "")
         {
           this._persona_iid_1 = first_persona.iid;
-          this._personas.prepend (first_persona);
+          this._personas.add (first_persona);
         }
       else if (i.full_name == this._persona_fullname_2 &&
           this._persona_iid_2 == "")
         {
           this._persona_iid_2 = first_persona.iid;
-          this._personas.prepend (first_persona);
+          this._personas.add (first_persona);
         }
       else if (i.personas.size > 1)
         {
@@ -291,7 +291,7 @@ public class LinkPersonasTests : Folks.TestCase
 
       /* We can try linking the personas only once we've got the
        * 2 initially created personas. */
-      if (this._personas.length () == 2 &&
+      if (this._personas.size == 2 &&
           this._linking_fired == false)
         {
           this._linking_fired = true;



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