[folks/folks-0-2] Consolidate persona link removal code



commit c11b9b9a1cfa14d303cea42644098e8ed5d58049
Author: Philip Withnall <philip withnall collabora co uk>
Date:   Sun Nov 7 21:56:42 2010 +0000

    Consolidate persona link removal code

 folks/individual-aggregator.vala |   93 +++++++++++++++-----------------------
 1 files changed, 36 insertions(+), 57 deletions(-)
---
diff --git a/folks/individual-aggregator.vala b/folks/individual-aggregator.vala
index cc79a09..4870a33 100644
--- a/folks/individual-aggregator.vala
+++ b/folks/individual-aggregator.vala
@@ -396,6 +396,38 @@ public class Folks.IndividualAggregator : Object
         }
     }
 
+  private void remove_persona_from_link_map (Persona persona)
+    {
+      this.link_map.remove (persona.iid);
+
+      if (persona.store.trust_level == PersonaStoreTrust.FULL)
+        {
+          debug ("    Removing links to %s:", persona.uid);
+
+          /* Remove maps from the Persona's linkable properties to
+           * Individuals. Add the Individuals to a list of Individuals to be
+           * removed. */
+          foreach (string prop_name in persona.linkable_properties)
+            {
+              unowned ObjectClass pclass = persona.get_class ();
+              if (pclass.find_property (prop_name) == null)
+                {
+                  warning ("Unknown property '%s' in linkable property list.",
+                      prop_name);
+                  continue;
+                }
+
+              persona.linkable_property_to_links (prop_name, (l) =>
+                {
+                  string prop_linking_value = (string) l;
+
+                  debug ("        %s", prop_linking_value);
+                  this.link_map.remove (prop_linking_value);
+                });
+            }
+        }
+    }
+
   private void personas_changed_cb (PersonaStore store,
       GLib.List<Persona>? added,
       GLib.List<Persona>? removed,
@@ -422,7 +454,6 @@ public class Folks.IndividualAggregator : Object
       removed.foreach ((p) =>
         {
           unowned Persona persona = (Persona) p;
-          PersonaStoreTrust trust_level = persona.store.trust_level;
 
           debug ("    %s (%s)", persona.uid, persona.iid);
 
@@ -436,34 +467,9 @@ public class Folks.IndividualAggregator : Object
           Individual ind = this.link_map.lookup (persona.iid);
           if (ind != null)
             removed_individuals.prepend (ind);
-          this.link_map.remove (persona.iid);
 
-          if (trust_level == PersonaStoreTrust.FULL)
-            {
-              debug ("    Removing links:");
-
-              /* Remove maps from the Persona's linkable properties to
-               * Individuals. Add the Individuals to a list of Individuals to be
-               * removed. */
-              foreach (string prop_name in persona.linkable_properties)
-                {
-                  unowned ObjectClass pclass = persona.get_class ();
-                  if (pclass.find_property (prop_name) == null)
-                    {
-                      warning ("Unknown property '%s' in linkable property " +
-                          "list.", prop_name);
-                      continue;
-                    }
-
-                  persona.linkable_property_to_links (prop_name, (l) =>
-                    {
-                      string prop_linking_value = (string) l;
-
-                      debug ("        %s", prop_linking_value);
-                      this.link_map.remove (prop_linking_value);
-                    });
-                }
-            }
+          /* Remove the Persona's links from the link map */
+          this.remove_persona_from_link_map (persona);
         });
 
       /* Remove the Individuals which were pointed to by the linkable properties
@@ -491,35 +497,8 @@ public class Folks.IndividualAggregator : Object
 
               relinked_personas.prepend (persona);
 
-              /* Remove links to the persona */
-              this.link_map.remove (persona.iid);
-
-              if (persona.store.trust_level == PersonaStoreTrust.FULL)
-                {
-                  debug ("    Removing links:");
-
-                  /* Remove maps from the Persona's linkable properties to
-                   * Individuals. Add the Individuals to a list of Individuals
-                   * to be removed. */
-                 foreach (string prop_name in persona.linkable_properties)
-                    {
-                     unowned ObjectClass pclass = persona.get_class ();
-                      if (pclass.find_property (prop_name) == null)
-                        {
-                          warning ("Unknown property '%s' in linkable " +
-                              "property list.", prop_name);
-                          continue;
-                        }
-
-                      persona.linkable_property_to_links (prop_name, (l) =>
-                        {
-                          string prop_linking_value = (string) l;
-
-                          debug ("        %s", prop_linking_value);
-                          this.link_map.remove (prop_linking_value);
-                        });
-                    }
-                }
+              /* Remove links to the Persona */
+              this.remove_persona_from_link_map (persona);
             }
 
           this.individuals.remove (individual.id);



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