[folks] Consolidate persona link removal code



commit 9a211f440e9b252fd4aede713052b2e01fe4aced
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 |  100 ++++++++++++++-----------------------
 1 files changed, 38 insertions(+), 62 deletions(-)
---
diff --git a/folks/individual-aggregator.vala b/folks/individual-aggregator.vala
index 7c9cc22..1326f14 100644
--- a/folks/individual-aggregator.vala
+++ b/folks/individual-aggregator.vala
@@ -493,6 +493,40 @@ 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 (
+                      /* Translators: the parameter is a property name. */
+                      _("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,
@@ -524,7 +558,6 @@ public class Folks.IndividualAggregator : Object
       removed.foreach ((p) =>
         {
           unowned Persona persona = (Persona) p;
-          PersonaStoreTrust trust_level = persona.store.trust_level;
 
           debug ("    %s (is user: %s, IID: %s)", persona.uid,
               persona.is_user ? "yes" : "no", persona.iid);
@@ -539,36 +572,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 (
-                          /* Translators: the parameter is a property name. */
-                          _("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
@@ -596,38 +602,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 (
-                              /* Translators: the parameter is a property
-                               * name. */
-                              _("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);
             }
 
           if (user == individual)



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