From 131ac802ba0975a047c72f010657f3200b9a2be5 Mon Sep 17 00:00:00 2001 From: Justin Anderson Date: Wed, 29 Oct 2008 21:58:56 +0000 Subject: [PATCH] KerberosAgent now saves successfully authenticated identities to favorites automatically when they were acquired through the Enter Identity dialog ticket: 6222 git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@20940 dc483132-0cff-0310-8789-dd5450dbe970 --- src/kim/agent/mac/IPCClient.h | 2 ++ src/kim/agent/mac/IPCClient.m | 23 +++++++++++++++++++++++ src/kim/agent/mac/Identities.m | 2 +- 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/src/kim/agent/mac/IPCClient.h b/src/kim/agent/mac/IPCClient.h index 361c4283a..0bea6000b 100644 --- a/src/kim/agent/mac/IPCClient.h +++ b/src/kim/agent/mac/IPCClient.h @@ -28,6 +28,7 @@ @class SelectIdentityController; @class AuthenticationController; +@class Identities; @interface IPCClient : NSObject { mach_port_t port; @@ -49,6 +50,7 @@ @property (readonly, retain) AuthenticationController *authController; - (void) cleanup; +- (void) saveIdentityToFavoritesIfSuccessful; - (kim_error) selectIdentity: (NSDictionary *) info; - (kim_error) enterIdentity: (NSDictionary *) info; diff --git a/src/kim/agent/mac/IPCClient.m b/src/kim/agent/mac/IPCClient.m index 53a7fe540..d4ac8a699 100644 --- a/src/kim/agent/mac/IPCClient.m +++ b/src/kim/agent/mac/IPCClient.m @@ -27,6 +27,7 @@ #import "SelectIdentityController.h" #import "AuthenticationController.h" #import "KerberosAgentListener.h" +#import "Identities.h" enum krb_agent_client_state { ipc_client_state_idle, @@ -105,6 +106,9 @@ enum krb_agent_client_state { - (void) cleanup { + if (![[self.selectController window] isVisible]) { + [self saveIdentityToFavoritesIfSuccessful]; + } [self.selectController close]; [self.authController close]; self.selectController = nil; @@ -112,6 +116,25 @@ enum krb_agent_client_state { self.currentInfo = nil; } +- (void) saveIdentityToFavoritesIfSuccessful +{ + NSString *identityString = [self.currentInfo valueForKeyPath:@"identity_string"]; + NSDictionary *options = [self.currentInfo valueForKeyPath:@"options"]; + + Identities *identities = [[Identities alloc] init]; + Identity *theIdentity = [[Identity alloc] initWithIdentity:identityString + options:options]; + for (Identity *anIdentity in [identities identities]) { + if ([anIdentity isEqual:theIdentity]) { + if (!anIdentity.favorite) { + anIdentity.favorite = YES; + [identities synchronizePreferences]; + } + break; + } + } +} + - (void) didCancel { kim_error err = KIM_USER_CANCELED_ERR; diff --git a/src/kim/agent/mac/Identities.m b/src/kim/agent/mac/Identities.m index 13c7578f7..1fa7e6ef4 100644 --- a/src/kim/agent/mac/Identities.m +++ b/src/kim/agent/mac/Identities.m @@ -477,7 +477,7 @@ } //NSLog(@"waited %@", [[NSThread currentThread] description]); - [(Identities *) [connection rootProxy] update]; + [(Identities *) [connection rootProxy] reload]; sleep (1); } -- 2.26.2