[folks] Only add available properties when linking Personas



commit 4a8b46e6b7afd314807865586a60995dfe52896f
Author: Raul Gutierrez Segales <raul gutierrez segales collabora co uk>
Date:   Fri Apr 8 16:03:11 2011 +0100

    Only add available properties when linking Personas

 folks/individual-aggregator.vala |   41 ++++++++++++++++++++-----------------
 1 files changed, 22 insertions(+), 19 deletions(-)
---
diff --git a/folks/individual-aggregator.vala b/folks/individual-aggregator.vala
index e3c0332..16f653f 100644
--- a/folks/individual-aggregator.vala
+++ b/folks/individual-aggregator.vala
@@ -921,16 +921,14 @@ public class Folks.IndividualAggregator : Object
                   unowned string protocol = (string) k;
                   unowned LinkedHashSet<string> addresses =
                     (LinkedHashSet<string>) v;
-    
+
                   var address_set = protocols_addrs_set.lookup (protocol);
-    
                   if (address_set == null)
                     {
                       address_set = new LinkedHashSet<string> ();
-    
                       protocols_addrs_set.insert (protocol, address_set);
                     }
-    
+
                   address_set.add_all (addresses);
                 });
             }
@@ -943,35 +941,40 @@ public class Folks.IndividualAggregator : Object
                   unowned string web_service = (string) entry.key;
                   unowned LinkedHashSet<string> addresses =
                     (LinkedHashSet<string>) entry.value;
-    
+
                   var address_set = web_service_addrs_set.get (web_service);
-    
                   if (address_set == null)
                     {
                       address_set = new LinkedHashSet<string> ();
-    
                       web_service_addrs_set.set (web_service, address_set);
                     }
-    
+
                   address_set.add_all (addresses);
                 }
             }
         }
 
-      var im_addresses_value = Value (typeof (HashTable));
-      im_addresses_value.set_boxed (protocols_addrs_set);
+      var details = new HashTable<string, Value?> (str_hash, str_equal);
 
-      var web_service_addresses_value = Value (typeof (HashMap));
-      web_service_addresses_value.set_object (web_service_addrs_set);
+      if (protocols_addrs_set.size () > 0)
+        {
+          var im_addresses_value = Value (typeof (HashTable));
+          im_addresses_value.set_boxed (protocols_addrs_set);
+          details.insert (PersonaStore.detail_key (PersonaDetail.IM_ADDRESSES),
+              im_addresses_value);
+        }
 
-      var details = new HashTable<string, Value?> (str_hash, str_equal);
-      details.insert (PersonaStore.detail_key (PersonaDetail.IM_ADDRESSES),
-          im_addresses_value);
-      details.insert (PersonaStore.detail_key
-          (PersonaDetail.WEB_SERVICE_ADDRESSES), web_service_addresses_value);
+      if (web_service_addrs_set.size > 0)
+        {
+          var web_service_addresses_value = Value (typeof (HashMap));
+          web_service_addresses_value.set_object (web_service_addrs_set);
+          details.insert (PersonaStore.detail_key
+              (PersonaDetail.WEB_SERVICE_ADDRESSES),
+              web_service_addresses_value);
+        }
 
-      yield this.add_persona_from_details (null, this._writeable_store,
-          details);
+      yield this.add_persona_from_details (null,
+          this._writeable_store, details);
     }
 
   /**



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