[folks] Individual: also use phone number for display_name.



commit 4a634c7d866ac674c562f0870abb8efaec7043f7
Author: Niels De Graef <nielsdegraef gmail com>
Date:   Thu Jan 4 13:00:42 2018 +0100

    Individual: also use phone number for display_name.

 folks/individual.vala |   36 ++++++++++++++++++++++++++++++++++++
 1 files changed, 36 insertions(+), 0 deletions(-)
---
diff --git a/folks/individual.vala b/folks/individual.vala
index 3e3aa7d..beee267 100644
--- a/folks/individual.vala
+++ b/folks/individual.vala
@@ -318,6 +318,7 @@ public class Folks.Individual : Object,
    * # Alias
    * # Full name, structured name or nickname
    * # E-mail address
+   * # Phone number
    * # Display ID (e.g. foo example org)
    * # Postal address
    * # _("Unnamed Person")
@@ -1934,6 +1935,23 @@ public class Folks.Individual : Object,
       return "";
     }
 
+  private string _look_up_phone_number_for_display_name (Persona? p)
+    {
+      var e = p as PhoneDetails;
+      if (e != null)
+        {
+          foreach (var phone_fd in ((!) e).phone_numbers)
+            {
+              if (phone_fd.value != null)
+                {
+                  return phone_fd.value;
+                }
+            }
+        }
+
+      return "";
+    }
+
   private string _look_up_display_id_for_display_name (Persona? p)
     {
       if (p != null && p.display_id != null)
@@ -2027,6 +2045,24 @@ public class Folks.Individual : Object,
             }
         }
 
+      /* Now the phone numbers. */
+      if (new_display_name == "")
+        {
+          new_display_name =
+              this._look_up_phone_number_for_display_name (primary_persona);
+
+          foreach (var p in this._persona_set)
+            {
+              if (new_display_name != "")
+                {
+                  break;
+                }
+
+              new_display_name =
+                  this._look_up_phone_number_for_display_name (p);
+            }
+        }
+
       /* Now the display-id. */
       if (new_display_name == "")
         {


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