Avoid duplicate identical dialogs in KIM
authorAlexandra Ellwood <lxs@mit.edu>
Fri, 31 Oct 2008 17:11:47 +0000 (17:11 +0000)
committerAlexandra Ellwood <lxs@mit.edu>
Fri, 31 Oct 2008 17:11:47 +0000 (17:11 +0000)
Added KIM_DUPLICATE_UI_REQUEST_ERR error so UI can indicate it cancelled
its dialog due to getting multiple identical dialogs at the same time.

ticket: new

git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@20942 dc483132-0cff-0310-8789-dd5450dbe970

src/kim/lib/kim_credential.c
src/kim/lib/kim_errors.et
src/kim/lib/kim_identity.c
src/kim/lib/kim_selection_hints.c

index 7b49c42dc0662fa22321a8b038dbb77bca5cfd03..8d2c1ee608cbe5dbbfea8c3de32050d6f9898bc2 100644 (file)
@@ -309,7 +309,11 @@ kim_error kim_credential_create_new_with_password (kim_credential *out_credentia
                 
                 /* reenter enter_identity so just forget this identity
                  * even if we got an error */
-                if (err == KIM_USER_CANCELED_ERR) { err = KIM_NO_ERROR; }
+                if (err == KIM_USER_CANCELED_ERR || 
+                    err == KIM_DUPLICATE_UI_REQUEST_ERR) { 
+                    err = KIM_NO_ERROR; 
+                }
+                
                 kim_identity_free (&identity);
             }
             
@@ -397,12 +401,31 @@ kim_error kim_credential_create_new_with_password (kim_credential *out_credentia
                 kim_string_free (&new_password);
             }
             
-            if (!err || err == KIM_USER_CANCELED_ERR) {
+            if (!err || err == KIM_USER_CANCELED_ERR || 
+                        err == KIM_DUPLICATE_UI_REQUEST_ERR) {
                 /* new creds obtained or the user gave up */
                 done_with_credentials = 1;
                 
-                /* remember identity and options if the user wanted to */
-                kim_credential_remember_prefs (identity, options);
+                if (!err) {
+                    /* remember identity and options if the user wanted to */
+                    kim_credential_remember_prefs (identity, options);
+                }
+                
+                if (err == KIM_DUPLICATE_UI_REQUEST_ERR) { 
+                    kim_ccache ccache = NULL;
+                    /* credential for this identity was obtained, but via a different 
+                     * dialog.  Find it.  */
+                    
+                    err = kim_ccache_create_from_client_identity (&ccache, 
+                                                                  identity);
+                    
+                    if (!err) {
+                        err = kim_ccache_get_valid_credential (ccache, 
+                                                               &credential);
+                    }
+                    
+                    kim_ccache_free (&ccache);
+                }                
                 
             } else if (prompt_count) {
                 /* User was prompted and might have entered bad info 
index 415751dc5aa1641eadeed531b6294a1daa621637..895d05a0730a885eae127b5dc5f97d86b8ae9428 100644 (file)
@@ -52,6 +52,7 @@ error_code KIM_CAPS_LOCK_ERR,                     "Password Incorrect (check you
 error_code KIM_USER_CANCELED_ERR,                 "The user cancelled the operation"
 error_code KIM_NO_SERVER_ERR,                     "KerberosAgent is not responding"
 error_code KIM_NO_UI_ERR,                         "Unable to display a user interface from this environment"
+error_code KIM_DUPLICATE_UI_REQUEST_ERR,          "UI just handled this request."
 
 index 100
 # Preferences Errors
index 6592d09c8f15f069501f1931431463e65021c710..2a1ad5e3ffa95c5bfdabfb32f33ea7498f86f60f 100644 (file)
@@ -707,7 +707,8 @@ kim_error kim_identity_change_password_common (kim_identity    in_identity,
                                        rejected_message, 
                                        rejected_description);
             
-        } else if (err && err != KIM_USER_CANCELED_ERR) {
+        } else if (err && err != KIM_USER_CANCELED_ERR && 
+                          err != KIM_DUPLICATE_UI_REQUEST_ERR) {
             /* New creds failed, report error to user.
              * Overwrite error so we loop and let the user try again.
              * The user always gets prompted so we always loop. */
@@ -738,6 +739,8 @@ kim_error kim_identity_change_password_common (kim_identity    in_identity,
                 
                 kim_string_free (&saved_password);
             }
+
+            if (err == KIM_DUPLICATE_UI_REQUEST_ERR) { err = KIM_NO_ERROR; }
         }
         
         kim_string_free (&rejected_message);
index 797f70bd5b74c999c3ef15269d9de39629b69d08..2b574283009315de9584c135d174162525a7a8ac 100644 (file)
@@ -480,7 +480,8 @@ kim_error kim_selection_hints_get_identity (kim_selection_hints  in_selection_hi
                 
                 /* reenter select_identity so just forget this identity
                  * even if we got an error */
-                if (err == KIM_USER_CANCELED_ERR) { err = KIM_NO_ERROR; }
+                if (err == KIM_USER_CANCELED_ERR || 
+                    err == KIM_DUPLICATE_UI_REQUEST_ERR) { err = KIM_NO_ERROR; }
                 kim_identity_free (&identity);
             }