When change password is called from the Select Identity dialog, it appears as a sheet...
authorJustin Anderson <jander@mit.edu>
Thu, 16 Oct 2008 21:41:38 +0000 (21:41 +0000)
committerJustin Anderson <jander@mit.edu>
Thu, 16 Oct 2008 21:41:38 +0000 (21:41 +0000)
ticket:6145

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

src/kim/agent/mac/AuthenticationController.h
src/kim/agent/mac/AuthenticationController.m
src/kim/agent/mac/IPCClient.m

index 0881f3fc166fda8f15c65a3aea740ca1ff694244..2ee82b93a1687206fd3d2464bbf4fdda02c83d46 100644 (file)
@@ -83,7 +83,7 @@
 - (void) showAuthPrompt;
 - (void) showEnterPassword;
 - (void) showSAM;
-- (void) showChangePassword;
+- (void) showChangePassword: (NSWindow *) parentWindow;
 - (void) showError;
 
 - (IBAction) cancel: (id) sender;
 - (IBAction) cancelTicketOptions: (id) sender;
 - (IBAction) saveTicketOptions: (id) sender;
 
-- (void) sheetDidEnd: (NSWindow *) sheet 
+- (void) changePasswordSheetDidEnd: (NSWindow *) sheet 
+                        returnCode: (int) returnCode 
+                       contextInfo: (void *) contextInfo;
+- (void) ticketOptionsSheetDidEnd: (NSWindow *) sheet 
           returnCode: (int) returnCode 
          contextInfo: (void *) contextInfo;
 
index eeae53c8fba6f88f499cd27fc96785a7ea384b2f..0887ab5cec33d193ecdeeb842f109215aea6c359 100644 (file)
     [[self window] makeFirstResponder:samPromptField];
 }
 
-- (void) showChangePassword
+- (void) showChangePassword: (NSWindow *) parentWindow
 {
     NSString *key = ([glueController valueForKeyPath:password_expired_keypath]) ? ACAppPrincReqKey : ACPrincReqKey;
     NSString *message = [NSString stringWithFormat:
     [self hideSpinny];
     
     [self swapView:changePasswordView];
-    
-    [self showWindow:nil];
+
+    // attach as sheet if given a parentWindow
+    if (parentWindow) {
+        [NSApp beginSheet:theWindow 
+           modalForWindow:parentWindow
+            modalDelegate:self
+           didEndSelector:@selector(changePasswordSheetDidEnd:returnCode:contextInfo:)
+              contextInfo:NULL];
+    }
+    // else, display as normal
+    else {
+        [self showWindow:nil];
+    }
     [theWindow makeFirstResponder:oldPasswordField];
 }
 
     [NSApp beginSheet:ticketOptionsSheet
        modalForWindow:[self window]
         modalDelegate:self 
-       didEndSelector:@selector(sheetDidEnd:returnCode:contextInfo:)
+       didEndSelector:@selector(ticketOptionsSheetDidEnd:returnCode:contextInfo:)
           contextInfo:NULL];
 }
 
     [NSApp endSheet:ticketOptionsSheet];
 }
 
-- (void) sheetDidEnd: (NSWindow *) sheet 
-          returnCode: (int) returnCode 
-         contextInfo: (void *) contextInfo
+- (void) changePasswordSheetDidEnd: (NSWindow *) sheet 
+                        returnCode: (int) returnCode 
+                       contextInfo: (void *) contextInfo
+{
+    [sheet orderOut:nil];
+}
+        
+        
+- (void) ticketOptionsSheetDidEnd: (NSWindow *) sheet 
+                       returnCode: (int) returnCode 
+                      contextInfo: (void *) contextInfo
 {
     if (returnCode == NSUserCancelledError) {
         // discard new options
 
 - (IBAction) cancel: (id) sender
 {
+    [NSApp endSheet:[self window]];
     [associatedClient didCancel];
 }
 
     [associatedClient didChangePassword:oldString
                             newPassword:newString
                          verifyPassword:verifyString];
+    [NSApp endSheet:[self window]];
 }
 
 - (IBAction) showedError: (id) sender
index e422dc64d1f21187361d39a9f79356714d1f679f..51bbf02ddfa7775c848282451e4fb0251d7dc6d1 100644 (file)
@@ -33,6 +33,7 @@ enum krb_agent_client_state {
     ipc_client_state_init,
     ipc_client_state_enter,
     ipc_client_state_select,
+    ipc_client_state_select_change_password,
     ipc_client_state_auth_prompt,
     ipc_client_state_change_password,
     ipc_client_state_handle_error,
@@ -127,10 +128,17 @@ enum krb_agent_client_state {
     else if (self.state == ipc_client_state_auth_prompt) {
         [KerberosAgentListener didPromptForAuth:self.currentInfo error:err];
     }
-    else if (self.state == ipc_client_state_change_password) {
+    else if (self.state == ipc_client_state_change_password ||
+             self.state == ipc_client_state_select_change_password) {
         [KerberosAgentListener didChangePassword:self.currentInfo error:err];
     }
-    self.state = ipc_client_state_idle;
+    
+    if (self.state == ipc_client_state_select_change_password) {
+        self.state = ipc_client_state_select;
+    }
+    else {
+        self.state = ipc_client_state_idle;
+    }
 }
 
 - (kim_error) selectIdentity: (NSDictionary *) info
@@ -163,7 +171,9 @@ enum krb_agent_client_state {
     [KerberosAgentListener didSelectIdentity:self.currentInfo error:0];
     
     // clean up state
-    self.state = ipc_client_state_idle;
+    if (!wantsChangePassword) {
+        self.state = ipc_client_state_idle;
+    }
 }
 
 - (kim_error) enterIdentity: (NSDictionary *) info
@@ -185,6 +195,13 @@ enum krb_agent_client_state {
     [self.currentInfo setObject:options forKey:@"options"];
     [self.currentInfo setObject:[NSNumber numberWithBool:wantsChangePassword] forKey:@"wants_change_password"];
     [KerberosAgentListener didEnterIdentity:self.currentInfo error:0];
+    
+    if (self.state == ipc_client_state_select_change_password) {
+        self.state = ipc_client_state_select;
+    }
+    else {
+        self.state = ipc_client_state_idle;
+    }
 }
 
 - (kim_error) promptForAuth: (NSDictionary *) info
@@ -207,11 +224,20 @@ enum krb_agent_client_state {
 
 - (kim_error) changePassword: (NSDictionary *) info
 {
+    NSWindow *parentWindow = nil;
+    
     [self.currentInfo addEntriesFromDictionary:info];
-    self.state = ipc_client_state_change_password;
+    
+    if (self.state == ipc_client_state_select) {
+        self.state = ipc_client_state_select_change_password;
+        parentWindow = [selectController window];
+    }
+    else {
+        self.state = ipc_client_state_change_password;
+    }
     
     [self.authController setContent:self.currentInfo];
-    [self.authController showChangePassword];
+    [self.authController showChangePassword:parentWindow];
     
     return 0;
 }