[folks] Improve the IDs stored in the key file



commit e71262c61afcac251cbe15442c4c9757fabdc321
Author: Philip Withnall <philip withnall collabora co uk>
Date:   Tue Aug 10 16:56:31 2010 +0100

    Improve the IDs stored in the key file
    
    Instead of storing the full Persona.UID in the key file, only store the
    display ID (the number). The IID then becomes the key file filename plus the
    display ID, to prevent unwanted linking of Kf.Personas from different key
    files.

 backends/key-file/kf-persona-store.vala |    8 ++++----
 backends/key-file/kf-persona.vala       |   13 +++++++------
 2 files changed, 11 insertions(+), 10 deletions(-)
---
diff --git a/backends/key-file/kf-persona-store.vala b/backends/key-file/kf-persona-store.vala
index 831a186..ae8c929 100644
--- a/backends/key-file/kf-persona-store.vala
+++ b/backends/key-file/kf-persona-store.vala
@@ -138,12 +138,12 @@ public class Folks.Backends.Kf.PersonaStore : Folks.PersonaStore
       /* We've loaded or created a key file by now, so cycle through the groups:
        * each group is a persona which we have to create and emit */
       string[] groups = this.key_file.get_groups ();
-      foreach (string persona_uid in groups)
+      foreach (string persona_id in groups)
         {
-          if (persona_uid.to_int () == this.first_unused_id)
+          if (persona_id.to_int () == this.first_unused_id)
             this.first_unused_id++;
 
-          Persona persona = new Kf.Persona (this.key_file, persona_uid, this);
+          Persona persona = new Kf.Persona (this.key_file, persona_id, this);
           this._personas.insert (persona.iid, persona);
         }
 
@@ -162,7 +162,7 @@ public class Folks.Backends.Kf.PersonaStore : Folks.PersonaStore
     {
       try
         {
-          this.key_file.remove_group (persona.uid);
+          this.key_file.remove_group (persona.display_id);
           yield this.save_key_file ();
         }
       catch (KeyFileError e)
diff --git a/backends/key-file/kf-persona.vala b/backends/key-file/kf-persona.vala
index c3133d5..f610f43 100644
--- a/backends/key-file/kf-persona.vala
+++ b/backends/key-file/kf-persona.vala
@@ -50,7 +50,7 @@ public class Folks.Backends.Kf.Persona : Folks.Persona,
               try
                 {
                   unowned string protocol = (string) k;
-                  this.key_file.remove_key (this.uid, protocol);
+                  this.key_file.remove_key (this.display_id, protocol);
                 }
               catch (KeyFileError e)
                 {
@@ -68,7 +68,8 @@ public class Folks.Backends.Kf.Persona : Folks.Persona,
               unowned PtrArray addresses = (PtrArray) v;
               unowned string[] _addresses = (string[]) addresses.pdata;
               _addresses.length = (int) addresses.len;
-              this.key_file.set_string_list (this.uid, protocol, _addresses);
+              this.key_file.set_string_list (this.display_id, protocol,
+                  _addresses);
             });
 
           /* Get the PersonaStore to save the key file */
@@ -87,7 +88,7 @@ public class Folks.Backends.Kf.Persona : Folks.Persona,
       string[] linkable_properties = { "im-addresses" };
 
       Object (display_id: id,
-              iid: id,
+              iid: store.id + ":" + id,
               uid: this.build_uid ("key-file", store.id, id),
               store: store,
               linkable_properties: linkable_properties);
@@ -101,11 +102,11 @@ public class Folks.Backends.Kf.Persona : Folks.Persona,
       /* Load the IM addresses from the key file */
       try
         {
-          string[] keys = this.key_file.get_keys (id);
+          string[] keys = this.key_file.get_keys (this.display_id);
           foreach (string protocol in keys)
             {
-              string[] im_addresses = this.key_file.get_string_list (id,
-                  protocol);
+              string[] im_addresses = this.key_file.get_string_list (
+                  this.display_id, protocol);
 
               /* FIXME: We have to convert our nice efficient string[] to a
                * GenericArray<string> because Vala doesn't like null-terminated



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