Pre-populate new clients with default client identity if that is set, as found by...
authorJustin Anderson <jander@mit.edu>
Tue, 14 Oct 2008 19:49:27 +0000 (19:49 +0000)
committerJustin Anderson <jander@mit.edu>
Tue, 14 Oct 2008 19:49:27 +0000 (19:49 +0000)
ticket:6183

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

src/kim/agent/mac/IPCClient.m

index e42ef9965ffd31f73d0f92ea3e392c910e5b3d0e..e422dc64d1f21187361d39a9f79356714d1f679f 100644 (file)
@@ -71,12 +71,34 @@ enum krb_agent_client_state {
 {
     self = [super init];
     if (self != nil) {
+        kim_error err = KIM_NO_ERROR;
+        kim_preferences prefs = NULL;
+        kim_identity identity = NULL;
+        kim_string identity_string = NULL;
+        
         self.state = ipc_client_state_init;
         self.selectController = [[[SelectIdentityController alloc] init] autorelease];
         self.authController = [[[AuthenticationController alloc] init] autorelease];
         self.selectController.associatedClient = self;
         self.authController.associatedClient = self;
         self.currentInfo = [NSMutableDictionary dictionary];
+        
+        // pre-populate the identity_string if there's a default identity
+        err = kim_preferences_create(&prefs);
+        if (!err && prefs) {
+            err = kim_preferences_get_client_identity(prefs, &identity);
+        }
+        if (!err && identity) {
+            err = kim_identity_get_display_string(identity, &identity_string);
+        }
+        if (!err && identity_string) {
+            [self.currentInfo setObject:[NSString stringWithUTF8String:identity_string]
+                                 forKey:@"identity_string"];
+        }
+        
+        kim_string_free(&identity_string);
+        kim_identity_free(&identity);
+        kim_preferences_free(&prefs);
     }
     return self;
 }