Fix service association/dissasociacion and storage per id
authorAlberto Ruiz <aruiz@gnome.org>
Wed, 20 Jul 2011 15:48:59 +0000 (16:48 +0100)
committerAlberto Ruiz <aruiz@gnome.org>
Wed, 20 Jul 2011 15:48:59 +0000 (16:48 +0100)
examples/service-selection.c
src/moonshot-window.vala

index a6217f6..2acb743 100644 (file)
@@ -15,7 +15,7 @@ int main (int argc, char *argv[])
 
     success = moonshot_get_identity ("",
                                      "",
-                                     "imap@project-moonshot.org",
+                                     "email@project-moonshot.org",
                                      &nai,
                                      &password,
                                      &server_certificate_hash,
index 371e904..55cd289 100644 (file)
@@ -491,12 +491,20 @@ class MainWindow : Window
                 {
                     int i = 0;
                     SList<string> services_list = null;
+                    bool has_service = false;
+
                     foreach (string srv in id.services)
                     {
                         if (srv == request.service)
+                        {
+                            has_service = true;
                             continue;
+                        }
                         services_list.append (srv);
                     }
+                    
+                    if (!has_service)
+                        continue;
 
                     if (services_list.length () == 0)
                     {
@@ -515,6 +523,8 @@ class MainWindow : Window
                 }
             }
 
+            identities_manager.store_id_cards ();
+
             /* If there are no candidates we use the service matching rules */
             if (candidates.length () == 0)
             {
@@ -544,10 +554,8 @@ class MainWindow : Window
                     confirm = true;
             }
             else
-            {
                 identity = candidates.nth_data (0);
-                confirm = false;
-            }
+                
             
             /* TODO: If candidate list empty return fail */
             
@@ -577,6 +585,20 @@ class MainWindow : Window
 
         var request = this.request_queue.pop_head ();
         bool reset_password = false;
+    
+        if (request.service != null && request.service != "")
+        {
+            string[] services = new string[identity.services.length + 1];
+            
+            for (int i = 0; i < identity.services.length; i++)
+                services[i] = identity.services[i];
+
+            services[identity.services.length] = request.service;
+            
+            identity.services = services;
+            
+            identities_manager.store_id_cards();
+        }
 
         if (identity.password == null)
         {