Fix candidate filtering
authorAlberto Ruiz <aruiz@gnome.org>
Wed, 20 Jul 2011 15:02:42 +0000 (16:02 +0100)
committerAlberto Ruiz <aruiz@gnome.org>
Wed, 20 Jul 2011 15:02:42 +0000 (16:02 +0100)
examples/service-selection.c
src/moonshot-identities-manager.vala
src/moonshot-window.vala
webprovisioning/complex-test.msht

index 1a08cfc..a6217f6 100644 (file)
@@ -13,9 +13,9 @@ int main (int argc, char *argv[])
          *subject_name_constraint,
          *subject_alt_name_constraint;
 
-    success = moonshot_get_identity ("user1@foo.baz",
-                                     "",
+    success = moonshot_get_identity ("",
                                      "",
+                                     "imap@project-moonshot.org",
                                      &nai,
                                      &password,
                                      &server_certificate_hash,
@@ -27,6 +27,7 @@ int main (int argc, char *argv[])
     if (success)
         g_debug ("Got id: %s %s\n", nai, password);
 
+
     moonshot_free (nai);
     moonshot_free (password);
     moonshot_free (server_certificate_hash);
index 7803816..90bbec9 100644 (file)
@@ -50,6 +50,7 @@ class IdentitiesManager : Object {
                       {
                         rules[i] = {rules_patterns[i], rules_always_conf[i]};
                       }
+                      id_card.rules = rules;
                     }
                 }
                 // Trust anchor 
index eda06bf..371e904 100644 (file)
@@ -80,14 +80,20 @@ class MainWindow : Window
 
         model.get (iter,
                    Columns.IDCARD_COL, out id_card);
+
         if (id_card == null)
             return false;
-
-        foreach (IdCard candidate in candidates)
+        
+        if (candidates != null)
         {
-            debug ("candidates -- %s", candidate.display_name);
-            if (candidate != id_card)
-                return true;
+            bool is_candidate = false;
+            foreach (IdCard candidate in candidates)
+            {
+                if (candidate == id_card)
+                    is_candidate = true;
+            }
+            if (!is_candidate)
+                return false;
         }
         
         string entry_text = search_entry.get_text ();
@@ -518,7 +524,7 @@ class MainWindow : Window
                     {
                         if (!match_service_pattern (request.service, rule.pattern))
                             continue;
-                       
+
                         candidates.append (id);
 
                         if (rule.always_confirm == "true")
@@ -538,8 +544,12 @@ class MainWindow : Window
                     confirm = true;
             }
             else
+            {
                 identity = candidates.nth_data (0);
+                confirm = false;
+            }
             
+            /* TODO: If candidate list empty return fail */
             
             if (confirm)
             {
@@ -597,7 +607,7 @@ class MainWindow : Window
         if (reset_password)
             identity.password = null;
 
-        candidates = new SList<IdCard>();
+        candidates = null;
     }
 
     private void label_make_bold (Label label)
index 32d03ea..2c11172 100644 (file)
         <always-confirm>true</always-confirm>
       </rule>
       <rule>
-      <rule>
         <pattern>imap@*moonshot.org</pattern>
         <always-confirm>false</always-confirm>
       </rule>
-      </rule>
     </selection-rules>
     <trust-anchor>
       <ca-cert>ABCDEFGHIJKLMNOPQRSTUVWXYZ123455678910</ca-cert>