=?utf-8?q?=5Bfolks=5D_Bug_686695_=E2=80=94_support_nickname_in_add=5Fpers?= =?utf-8?q?ona=5Ffrom=5Fdetails?=



commit a39f2b2e9d20342db9650c432e0b708a50c42de7
Author: Philip Withnall <philip tecnocode co uk>
Date:   Sun Dec 30 18:53:08 2012 +0000

    Bug 686695 â support nickname in add_persona_from_details
    
    Support nicknames in add_persona_from_details() in the EDS backend. This
    adds a test case (which passes).
    
    Closes: https://bugzilla.gnome.org/show_bug.cgi?id=686695

 NEWS                                     |    1 +
 backends/eds/lib/edsf-persona-store.vala |   12 ++++++++++++
 tests/eds/add-persona.vala               |   15 +++++++++++++++
 3 files changed, 28 insertions(+), 0 deletions(-)
---
diff --git a/NEWS b/NEWS
index 44e1e15..277a89a 100644
--- a/NEWS
+++ b/NEWS
@@ -29,6 +29,7 @@ Bugs fixed:
 â Bug 690990 â Add tests/README
 â Bug 690876 â eds: fix various test failures
 â Bug 691167 â Build failure: key-file tests built before dependencies
+â Bug 686695 â support nickname in add_persona_from_details
 
 API changes:
 â Add Backend.enable_persona_store and disable_persona_store.
diff --git a/backends/eds/lib/edsf-persona-store.vala b/backends/eds/lib/edsf-persona-store.vala
index b943085..c4652c4 100644
--- a/backends/eds/lib/edsf-persona-store.vala
+++ b/backends/eds/lib/edsf-persona-store.vala
@@ -379,6 +379,7 @@ public class Edsf.PersonaStore : Folks.PersonaStore
    * - PersonaStore.detail_key (PersonaDetail.GENDER)
    * - PersonaStore.detail_key (PersonaDetail.IM_ADDRESSES)
    * - PersonaStore.detail_key (PersonaDetail.IS_FAVOURITE)
+   * - PersonaStore.detail_key (PersonaDetail.NICKNAME)
    * - PersonaStore.detail_key (PersonaDetail.PHONE_NUMBERS)
    * - PersonaStore.detail_key (PersonaDetail.POSTAL_ADDRESSES)
    * - PersonaStore.detail_key (PersonaDetail.ROLES)
@@ -433,6 +434,17 @@ public class Edsf.PersonaStore : Folks.PersonaStore
               contact.set (E.Contact.field_id ("full_name"), full_name);
             }
           else if (k == Folks.PersonaStore.detail_key (
+                PersonaDetail.NICKNAME))
+            {
+              string? nickname = v.get_string ();
+              if (nickname != null && (!) nickname == "")
+                {
+                  nickname = null;
+                }
+
+              contact.set (E.Contact.field_id ("nickname"), nickname);
+            }
+          else if (k == Folks.PersonaStore.detail_key (
                 PersonaDetail.EMAIL_ADDRESSES))
             {
               Set<EmailFieldDetails> email_addresses =
diff --git a/tests/eds/add-persona.vala b/tests/eds/add-persona.vala
index d742afa..1f3178e 100644
--- a/tests/eds/add-persona.vala
+++ b/tests/eds/add-persona.vala
@@ -27,6 +27,7 @@ public class AddPersonaTests : Folks.TestCase
   private EdsTest.Backend _eds_backend;
   private IndividualAggregator _aggregator;
   private string _persona_fullname;
+  private string _persona_nickname;
   private string _email_1;
   private Edsf.PersonaStore _pstore;
   private bool _added_persona = false;
@@ -77,6 +78,7 @@ public class AddPersonaTests : Folks.TestCase
     {
       this._main_loop = new GLib.MainLoop (null, false);
       this._persona_fullname = "persona #1";
+      this._persona_nickname = "Jo";
       this._email_1 = "someone-1 example org";
       this._avatar_path = Environment.get_variable ("AVATAR_FILE_PATH");
       this._im_addr_1 = "someone-1 jabber example org";
@@ -98,6 +100,7 @@ public class AddPersonaTests : Folks.TestCase
       this._properties_found = new HashTable<string, bool>
           (str_hash, str_equal);
       this._properties_found.insert ("full_name", false);
+      this._properties_found.insert ("nickname", false);
       this._properties_found.insert ("email-1", false);
       this._properties_found.insert ("avatar", false);
       this._properties_found.insert ("im-addr-1", false);
@@ -272,6 +275,11 @@ public class AddPersonaTests : Folks.TestCase
           Folks.PersonaStore.detail_key (PersonaDetail.IS_FAVOURITE),
           (owned) v11);
 
+      Value? v12 = Value (typeof (string));
+      v12.set_string (this._persona_nickname);
+      details.insert (Folks.PersonaStore.detail_key (PersonaDetail.NICKNAME),
+          (owned) v12);
+
       try
         {
           yield this._aggregator.add_persona_from_details (null,
@@ -320,6 +328,7 @@ public class AddPersonaTests : Folks.TestCase
           if (this._individual_received != null)
             {
               i.notify["full-name"].disconnect (this._notify_cb);
+              i.notify["nickname"].disconnect (this._notify_cb);
               i.notify["email-addresses"].disconnect (this._notify_cb);
               i.notify["avatar"].disconnect (this._notify_cb);
               i.notify["im-addresses"].disconnect (this._notify_cb);
@@ -338,6 +347,7 @@ public class AddPersonaTests : Folks.TestCase
           retval++;
 
           i.notify["full-name"].connect (this._notify_cb);
+          i.notify["nickname"].connect (this._notify_cb);
           i.notify["email-addresses"].connect (this._notify_cb);
           i.notify["avatar"].connect (this._notify_cb);
           i.notify["im-addresses"].connect (this._notify_cb);
@@ -384,6 +394,11 @@ public class AddPersonaTests : Folks.TestCase
       if (i.full_name == this._persona_fullname)
         this._properties_found.replace ("full_name", true);
 
+      if (i.nickname == this._persona_nickname)
+        {
+          this._properties_found.replace ("nickname", true);
+        }
+
       foreach (var e in i.email_addresses)
         {
           if (e.value == this._email_1)



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