IBOutlet NSWindow *ticketOptionsSheet;
IBOutlet NSObjectController *ticketOptionsController;
+ BOOL visibleAsSheet;
IBOutlet NSSlider *validLifetimeSlider;
IBOutlet NSSlider *renewableLifetimeSlider;
- (void) setContent: (NSMutableDictionary *) newContent;
-- (void) showEnterIdentity;
-- (void) showAuthPrompt;
-- (void) showEnterPassword;
-- (void) showSAM;
+- (void) showEnterIdentity: (NSWindow *) parentWindow;
+- (void) showAuthPrompt: (NSWindow *) parentWindow;
+- (void) showEnterPassword: (NSWindow *) parentWindow;
+- (void) showSAM: (NSWindow *) parentWindow;
- (void) showChangePassword: (NSWindow *) parentWindow;
-- (void) showError;
+- (void) showError: (NSWindow *) parentWindow;
- (IBAction) cancel: (id) sender;
- (IBAction) enterIdentity: (id) sender;
- (IBAction) cancelTicketOptions: (id) sender;
- (IBAction) saveTicketOptions: (id) sender;
-- (void) changePasswordSheetDidEnd: (NSWindow *) sheet
- returnCode: (int) returnCode
- contextInfo: (void *) contextInfo;
+- (void) authSheetDidEnd: (NSWindow *) sheet
+ returnCode: (int) returnCode
+ contextInfo: (void *) contextInfo;
- (void) ticketOptionsSheetDidEnd: (NSWindow *) sheet
returnCode: (int) returnCode
contextInfo: (void *) contextInfo;
// We need to float over the loginwindow and SecurityAgent so use its hardcoded level.
[[self window] setLevel:NSScreenSaverWindowLevel];
+ visibleAsSheet = NO;
+
lifetimeFormatter.displaySeconds = NO;
lifetimeFormatter.displayShortFormat = NO;
[super showWindow:sender];
}
+- (void) showWithParent: (NSWindow *) parentWindow
+{
+ // attach as sheet if given a parentWindow
+ if (parentWindow && !visibleAsSheet) {
+ [NSApp beginSheet:[self window]
+ modalForWindow:parentWindow
+ modalDelegate:self
+ didEndSelector:@selector(authSheetDidEnd:returnCode:contextInfo:)
+ contextInfo:NULL];
+ }
+ // else, display as normal
+ else {
+ [self showWindow:nil];
+ }
+}
+
+- (void) windowWillBeginSheet: (NSNotification *) notification
+{
+ visibleAsSheet = YES;
+}
+
+- (void) windowDidEndSheet: (NSNotification *) notification
+{
+ visibleAsSheet = NO;
+}
+
- (void) setContent: (NSMutableDictionary *) newContent
{
[self window]; // wake up the nib connections
[glueController setContent:newContent];
}
-- (void) showEnterIdentity
+- (void) swapView: (NSView *) aView
+{
+ NSWindow *theWindow = [self window];
+ NSRect windowFrame;
+ NSRect viewFrame;
+
+ [[containerView subviews] makeObjectsPerformSelector:@selector(removeFromSuperview)];
+
+ windowFrame = [theWindow frame];
+ viewFrame = [theWindow frameRectForContentRect:[aView frame]];
+ windowFrame.origin.y -= viewFrame.size.height - windowFrame.size.height;
+
+ windowFrame.size.width = viewFrame.size.width;
+ windowFrame.size.height = viewFrame.size.height;
+
+ [theWindow setFrame:windowFrame display:YES animate:YES];
+
+ [containerView addSubview:aView];
+
+}
+
+- (void) showSpinny
+{
+ [enterSpinny startAnimation: nil];
+ [passwordSpinny startAnimation: nil];
+ [samSpinny startAnimation: nil];
+ [changePasswordSpinny startAnimation: nil];
+ [glueController setValue:[NSNumber numberWithBool:NO]
+ forKeyPath:accepting_input_keypath];
+}
+
+- (void) hideSpinny
+{
+ [enterSpinny stopAnimation: nil];
+ [passwordSpinny stopAnimation: nil];
+ [samSpinny stopAnimation: nil];
+ [changePasswordSpinny stopAnimation: nil];
+ [glueController setValue:[NSNumber numberWithBool:YES]
+ forKeyPath:accepting_input_keypath];
+}
+
+- (void) showEnterIdentity: (NSWindow *) parentWindow
{
kim_error err = KIM_NO_ERROR;
NSWindow *theWindow = [self window];
[theWindow makeFirstResponder:identityField];
- [[self window] makeKeyAndOrderFront:nil];
+ [self showWithParent: parentWindow];
}
-- (void) showAuthPrompt
+- (void) showAuthPrompt: (NSWindow *) parentWindow
{
uint32_t type = [[glueController valueForKeyPath:@"content.prompt_type"] unsignedIntegerValue];
switch (type) {
case kim_prompt_type_password :
- [self showEnterPassword]; break;
+ [self showEnterPassword: parentWindow]; break;
case kim_prompt_type_preauth :
default :
- [self showSAM]; break;
+ [self showSAM: parentWindow]; break;
}
}
-- (void) showEnterPassword
+- (void) showEnterPassword: (NSWindow *) parentWindow
{
CGFloat shrinkBy;
NSRect frame;
[self swapView:passwordView];
[theWindow makeFirstResponder:passwordField];
- [self showWindow:nil];
-}
-
-- (void) swapView: (NSView *) aView
-{
- NSWindow *theWindow = [self window];
- NSRect windowFrame;
- NSRect viewFrame;
-
- [[containerView subviews] makeObjectsPerformSelector:@selector(removeFromSuperview)];
-
- windowFrame = [theWindow frame];
- viewFrame = [theWindow frameRectForContentRect:[aView frame]];
- windowFrame.origin.y -= viewFrame.size.height - windowFrame.size.height;
-
- windowFrame.size.width = viewFrame.size.width;
- windowFrame.size.height = viewFrame.size.height;
-
- [theWindow setFrame:windowFrame display:YES animate:YES];
-
- [containerView addSubview:aView];
-
+ [self showWithParent:parentWindow];
}
-- (void) showSpinny
-{
- [enterSpinny startAnimation: nil];
- [passwordSpinny startAnimation: nil];
- [samSpinny startAnimation: nil];
- [changePasswordSpinny startAnimation: nil];
- [glueController setValue:[NSNumber numberWithBool:NO]
- forKeyPath:accepting_input_keypath];
-}
-
-- (void) hideSpinny
-{
- [enterSpinny stopAnimation: nil];
- [passwordSpinny stopAnimation: nil];
- [samSpinny stopAnimation: nil];
- [changePasswordSpinny stopAnimation: nil];
- [glueController setValue:[NSNumber numberWithBool:YES]
- forKeyPath:accepting_input_keypath];
-}
-
-- (void) showSAM
+- (void) showSAM: (NSWindow *) parentWindow
{
// set badge
[samBadge setBadgePath:associatedClient.path];
[self swapView:samView];
- [self showWindow:nil];
[[self window] makeFirstResponder:samPromptField];
+ [self showWithParent:parentWindow];
}
- (void) showChangePassword: (NSWindow *) parentWindow
[self swapView:changePasswordView];
- // 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];
- }
+ [self showWithParent:parentWindow];
+
[theWindow makeFirstResponder:oldPasswordField];
}
-- (void) showError
+- (void) showError: (NSWindow *) parentWindow
{
// wake up the nib connections and adjust window size
[self window];
[self hideSpinny];
[self swapView:errorView];
- [self showWindow:nil];
+ [self showWithParent:parentWindow];
}
- (IBAction) checkboxDidChange: (id) sender
[NSApp endSheet:ticketOptionsSheet];
}
-- (void) changePasswordSheetDidEnd: (NSWindow *) sheet
- returnCode: (int) returnCode
- contextInfo: (void *) contextInfo
+- (void) authSheetDidEnd: (NSWindow *) sheet
+ returnCode: (int) returnCode
+ contextInfo: (void *) contextInfo
{
[sheet orderOut:nil];
}
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,
else if (self.state == ipc_client_state_auth_prompt) {
[KerberosAgentListener didPromptForAuth:self.currentInfo error:err];
}
- else if (self.state == ipc_client_state_change_password ||
- self.state == ipc_client_state_select_change_password) {
+ else if (self.state == ipc_client_state_change_password) {
[KerberosAgentListener didChangePassword:self.currentInfo error:err];
}
- if (self.state == ipc_client_state_select_change_password) {
+ if ([[self.selectController window] isVisible]) {
self.state = ipc_client_state_select;
}
else {
- (kim_error) enterIdentity: (NSDictionary *) info
{
+ NSWindow *parentWindow = nil;
+
[self.currentInfo addEntriesFromDictionary:info];
+
+ if ([[self.selectController window] isVisible]) {
+ parentWindow = [selectController window];
+ }
+
self.state = ipc_client_state_enter;
[self.authController setContent:self.currentInfo];
- [self.authController showEnterIdentity];
+ [self.authController showEnterIdentity:parentWindow];
return 0;
}
[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) {
+ if ([[self.selectController window] isVisible]) {
self.state = ipc_client_state_select;
}
else {
- (kim_error) promptForAuth: (NSDictionary *) info
{
+ NSWindow *parentWindow = nil;
+
[self.currentInfo addEntriesFromDictionary:info];
+
+ if ([[self.selectController window] isVisible]) {
+ parentWindow = [selectController window];
+ }
+
self.state = ipc_client_state_auth_prompt;
[self.authController setContent:self.currentInfo];
- [self.authController showAuthPrompt];
+ [self.authController showAuthPrompt:parentWindow];
return 0;
}
[self.currentInfo setObject:responseString forKey:@"prompt_response"];
[self.currentInfo setObject:saveResponse forKey:@"save_response"];
[KerberosAgentListener didPromptForAuth:self.currentInfo error:0];
+
+ if ([[self.selectController window] isVisible]) {
+ self.state = ipc_client_state_select;
+ }
+ else {
+ self.state = ipc_client_state_idle;
+ }
}
- (kim_error) changePassword: (NSDictionary *) info
[self.currentInfo addEntriesFromDictionary:info];
- if (self.state == ipc_client_state_select) {
- self.state = ipc_client_state_select_change_password;
+ if ([[self.selectController window] isVisible]) {
parentWindow = [selectController window];
}
- else {
- self.state = ipc_client_state_change_password;
- }
+
+ self.state = ipc_client_state_change_password;
[self.authController setContent:self.currentInfo];
[self.authController showChangePassword:parentWindow];
[self.currentInfo setObject:oldPassword forKey:@"old_password"];
[self.currentInfo setObject:newPassword forKey:@"new_password"];
[self.currentInfo setObject:verifyPassword forKey:@"verify_password"];
+
+ if ([[self.selectController window] isVisible]) {
+ self.state = ipc_client_state_select;
+ }
+ else {
+ self.state = ipc_client_state_idle;
+ }
+
[KerberosAgentListener didChangePassword:self.currentInfo error:0];
}
- (kim_error) handleError: (NSDictionary *) info
{
+ NSWindow *parentWindow = nil;
+
[self.currentInfo addEntriesFromDictionary:info];
+
+ if ([[self.selectController window] isVisible]) {
+ parentWindow = [selectController window];
+ }
+
self.state = ipc_client_state_handle_error;
[self.authController setContent:self.currentInfo];
- [self.authController showError];
+ [self.authController showError:parentWindow];
return 0;
}
- (void) didHandleError
{
+ if ([[self.selectController window] isVisible]) {
+ self.state = ipc_client_state_select;
+ }
+ else {
+ self.state = ipc_client_state_idle;
+ }
+
[KerberosAgentListener didHandleError:self.currentInfo error:0];
}