[folks] _add_persona_from_contact: always return the persona



commit 8f26cd581c1afd14e98247789abe1b3b40f397ed
Author: Guillaume Desmottes <guillaume desmottes collabora co uk>
Date:   Thu Mar 22 15:32:02 2012 +0100

    _add_persona_from_contact: always return the persona
    
    In some case we may be interested by using the persona even if it was already
    existing.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=671714

 backends/telepathy/lib/tpf-persona-store.vala |   28 +++++++++++++++---------
 1 files changed, 17 insertions(+), 11 deletions(-)
---
diff --git a/backends/telepathy/lib/tpf-persona-store.vala b/backends/telepathy/lib/tpf-persona-store.vala
index b79577b..e755fee 100644
--- a/backends/telepathy/lib/tpf-persona-store.vala
+++ b/backends/telepathy/lib/tpf-persona-store.vala
@@ -1172,10 +1172,11 @@ public class Tpf.PersonaStore : Folks.PersonaStore
 
               /* Add the local user */
               Contact contact = contacts[0];
-              Persona persona = this._add_persona_from_contact (contact, false);
+              bool added;
+              Persona persona = this._add_persona_from_contact (contact, false, out added);
 
               var personas = new HashSet<Persona> ();
-              if (persona != null)
+              if (added)
                 personas.add (persona);
 
               this._self_contact = contact;
@@ -1969,8 +1970,9 @@ public class Tpf.PersonaStore : Folks.PersonaStore
 
           debug ("Creating persona from contact '%s'", contact.identifier);
 
-          var persona = this._add_persona_from_contact (contact, true);
-          if (persona != null)
+          bool added;
+          var persona = this._add_persona_from_contact (contact, true, out added);
+          if (added)
             personas.add (persona);
         }
 
@@ -2021,9 +2023,10 @@ public class Tpf.PersonaStore : Folks.PersonaStore
        * other than the TpChannels which are associated with this store, we only
        * hold a weak reference to it and remove it from the store as soon as
        * it's destroyed. */
-      persona = this._add_persona_from_contact (contact, false);
+      bool added;
+      persona = this._add_persona_from_contact (contact, false, out added);
 
-      if (persona == null)
+      if (!added)
         {
           return null;
         }
@@ -2040,7 +2043,8 @@ public class Tpf.PersonaStore : Folks.PersonaStore
     }
 
   private Tpf.Persona? _add_persona_from_contact (Contact contact,
-      bool from_contact_list)
+      bool from_contact_list,
+      out bool added)
     {
       var h = contact.get_handle ();
       Persona? persona = null;
@@ -2071,7 +2075,7 @@ public class Tpf.PersonaStore : Folks.PersonaStore
 
           persona.is_in_contact_list = from_contact_list;
 
-          return persona;
+          added = true;
         }
       else
         {
@@ -2089,8 +2093,9 @@ public class Tpf.PersonaStore : Folks.PersonaStore
               persona.is_in_contact_list = true;
             }
 
-          return null;
+          added = false;
         }
+      return persona;
     }
 
   private void _add_new_personas_from_contacts (Contact[] contacts)
@@ -2099,8 +2104,9 @@ public class Tpf.PersonaStore : Folks.PersonaStore
 
       foreach (Contact contact in contacts)
         {
-          var persona = this._add_persona_from_contact (contact, true);
-          if (persona != null)
+          bool added;
+          var persona = this._add_persona_from_contact (contact, true, out added);
+          if (added)
             personas.add (persona);
         }
 



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