[folks] Use autogenerated numeric IDs for key file groups



commit e58ae2c4b34f1bf479c3288c9b02e3d2dd187ba9
Author: Philip Withnall <philip withnall collabora co uk>
Date:   Mon Aug 9 14:46:26 2010 +0100

    Use autogenerated numeric IDs for key file groups

 backends/key-file/kf-persona-store.vala |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)
---
diff --git a/backends/key-file/kf-persona-store.vala b/backends/key-file/kf-persona-store.vala
index 425b559..5b046bd 100644
--- a/backends/key-file/kf-persona-store.vala
+++ b/backends/key-file/kf-persona-store.vala
@@ -32,6 +32,7 @@ public class Folks.Backends.Kf.PersonaStore : Folks.PersonaStore
   private HashTable<string, Persona> _personas;
   private File file;
   private GLib.KeyFile key_file;
+  private uint first_unused_id = 0;
 
   /**
    * { inheritDoc}
@@ -139,6 +140,9 @@ public class Folks.Backends.Kf.PersonaStore : Folks.PersonaStore
       string[] groups = this.key_file.get_groups ();
       foreach (string persona_uid in groups)
         {
+          if (persona_uid.to_int () == this.first_unused_id)
+            this.first_unused_id++;
+
           Persona persona = new Kf.Persona (this.key_file, persona_uid, this);
           this._personas.insert (persona.iid, persona);
         }
@@ -187,9 +191,8 @@ public class Folks.Backends.Kf.PersonaStore : Folks.PersonaStore
               this.type_id, this.id, im_address, protocol);
         }
 
-      /* Take the persona ID as the concatenation of the protocol and IM
-       * address, fairly arbitrarily */
-      string persona_id = protocol + ":" + im_address;
+      string persona_id = this.first_unused_id.to_string ();
+      this.first_unused_id++;
 
       /* Insert the new IM details into the key file and create a Persona from
        * them */



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