[folks] eds: Ensure the default role is non-empty



commit e5a2b01dceb57acad6104fa75e13623be10231a5
Author: Philip Withnall <philip tecnocode co uk>
Date:   Sun Dec 25 10:58:38 2011 +0000

    eds: Ensure the default role is non-empty
    
    If the default role is empty (e.g. because EDS returns empty strings as the
    contact's title, org or role; rather than null), don't add it to the
    Persona.
    
    Helps: bgo#666540

 backends/eds/lib/edsf-persona.vala |   24 ++++++++++++++----------
 1 files changed, 14 insertions(+), 10 deletions(-)
---
diff --git a/backends/eds/lib/edsf-persona.vala b/backends/eds/lib/edsf-persona.vala
index 8d68b0b..bd807d4 100644
--- a/backends/eds/lib/edsf-persona.vala
+++ b/backends/eds/lib/edsf-persona.vala
@@ -1016,22 +1016,26 @@ public class Edsf.Persona : Folks.Persona,
           assistant != null)
         {
           var new_role = new Role (title, org);
-          if (role != null)
+          if (role != null && role != "")
             new_role.role = role;
 
-          default_role = new RoleFieldDetails (new_role);
+          /* Check if it's non-empty. */
+          if (!new_role.is_empty ())
+            {
+              default_role = new RoleFieldDetails (new_role);
 
-          if (org_unit != null && org_unit != "")
-            default_role.set_parameter ("org_unit", org_unit);
+              if (org_unit != null && org_unit != "")
+                default_role.set_parameter ("org_unit", org_unit);
 
-          if (office != null && office != "")
-            default_role.set_parameter ("office", office);
+              if (office != null && office != "")
+                default_role.set_parameter ("office", office);
 
-          if (manager != null && manager != "")
-            default_role.set_parameter ("manager", manager);
+              if (manager != null && manager != "")
+                default_role.set_parameter ("manager", manager);
 
-          if (assistant != null && manager != "")
-            default_role.set_parameter ("assistant", assistant);
+              if (assistant != null && manager != "")
+                default_role.set_parameter ("assistant", assistant);
+            }
         }
 
       return default_role;



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