From 077ccbfee3d205fe354bb1a7504fe8408d81c890 Mon Sep 17 00:00:00 2001 From: Justin Anderson Date: Thu, 16 Oct 2008 21:41:38 +0000 Subject: [PATCH] When change password is called from the Select Identity dialog, it appears as a sheet on that dialog instead of popping up as a separate window ticket:6145 git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@20880 dc483132-0cff-0310-8789-dd5450dbe970 --- src/kim/agent/mac/AuthenticationController.h | 7 ++-- src/kim/agent/mac/AuthenticationController.m | 35 +++++++++++++++---- src/kim/agent/mac/IPCClient.m | 36 +++++++++++++++++--- 3 files changed, 64 insertions(+), 14 deletions(-) diff --git a/src/kim/agent/mac/AuthenticationController.h b/src/kim/agent/mac/AuthenticationController.h index 0881f3fc1..2ee82b93a 100644 --- a/src/kim/agent/mac/AuthenticationController.h +++ b/src/kim/agent/mac/AuthenticationController.h @@ -83,7 +83,7 @@ - (void) showAuthPrompt; - (void) showEnterPassword; - (void) showSAM; -- (void) showChangePassword; +- (void) showChangePassword: (NSWindow *) parentWindow; - (void) showError; - (IBAction) cancel: (id) sender; @@ -99,7 +99,10 @@ - (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; diff --git a/src/kim/agent/mac/AuthenticationController.m b/src/kim/agent/mac/AuthenticationController.m index eeae53c8f..0887ab5ce 100644 --- a/src/kim/agent/mac/AuthenticationController.m +++ b/src/kim/agent/mac/AuthenticationController.m @@ -338,7 +338,7 @@ [[self window] makeFirstResponder:samPromptField]; } -- (void) showChangePassword +- (void) showChangePassword: (NSWindow *) parentWindow { NSString *key = ([glueController valueForKeyPath:password_expired_keypath]) ? ACAppPrincReqKey : ACPrincReqKey; NSString *message = [NSString stringWithFormat: @@ -378,8 +378,19 @@ [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]; } @@ -468,7 +479,7 @@ [NSApp beginSheet:ticketOptionsSheet modalForWindow:[self window] modalDelegate:self - didEndSelector:@selector(sheetDidEnd:returnCode:contextInfo:) + didEndSelector:@selector(ticketOptionsSheetDidEnd:returnCode:contextInfo:) contextInfo:NULL]; } @@ -482,9 +493,17 @@ [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 @@ -551,6 +570,7 @@ - (IBAction) cancel: (id) sender { + [NSApp endSheet:[self window]]; [associatedClient didCancel]; } @@ -594,6 +614,7 @@ [associatedClient didChangePassword:oldString newPassword:newString verifyPassword:verifyString]; + [NSApp endSheet:[self window]]; } - (IBAction) showedError: (id) sender diff --git a/src/kim/agent/mac/IPCClient.m b/src/kim/agent/mac/IPCClient.m index e422dc64d..51bbf02dd 100644 --- a/src/kim/agent/mac/IPCClient.m +++ b/src/kim/agent/mac/IPCClient.m @@ -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; } -- 2.26.2