From d3e2bb1e0146cae283dcd4f1c473084884e7c654 Mon Sep 17 00:00:00 2001 From: Justin Anderson Date: Sun, 28 Sep 2008 23:51:09 +0000 Subject: [PATCH] Actually make [Identity -componentsString] use kim_identity_get_components_string Also, better error handling in Identity and Identities classes. ticket: 6055 git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@20774 dc483132-0cff-0310-8789-dd5450dbe970 --- src/kim/agent/mac/Identities.m | 38 ++++++++++++-------- src/kim/agent/mac/KIMUtilities.h | 5 +++ src/kim/agent/mac/KIMUtilities.m | 1 - src/kim/agent/mac/SelectIdentityController.m | 4 +-- 4 files changed, 30 insertions(+), 18 deletions(-) diff --git a/src/kim/agent/mac/Identities.m b/src/kim/agent/mac/Identities.m index 4e5586787..54a4947dc 100644 --- a/src/kim/agent/mac/Identities.m +++ b/src/kim/agent/mac/Identities.m @@ -296,7 +296,7 @@ } if (err) { - NSLog(@"%s got error %s", _cmd, error_message(err)); + log_kim_error_to_console(err); } } @@ -496,7 +496,7 @@ } if (err) { - NSLog(@"%s got error %s", _cmd, error_message(err)); + log_kim_error_to_console(err); } kim_string_free(&display_string); @@ -512,14 +512,16 @@ kim_string display_string = NULL; NSString *result = @""; - err = kim_identity_get_components_string(kimIdentity, &display_string); + if (self.kimIdentity) { + err = kim_identity_get_components_string(self.kimIdentity, &display_string); + } - if (!err) { - NSRange atRange; - + if (!err && display_string) { result = [NSString stringWithUTF8String:display_string]; - atRange = [result rangeOfString:@"@" options:NSBackwardsSearch]; - result = [result substringToIndex:atRange.location]; + } + + if (err) { + log_kim_error_to_console(err); } kim_string_free(&display_string); @@ -535,12 +537,18 @@ kim_string display_string = NULL; NSString *result = @""; - err = kim_identity_get_realm(kimIdentity, &display_string); + if (self.kimIdentity) { + err = kim_identity_get_realm(self.kimIdentity, &display_string); + } - if (!err) { + if (!err && display_string) { result = [NSString stringWithUTF8String:display_string]; } + if (err) { + log_kim_error_to_console(err); + } + kim_string_free(&display_string); return result; @@ -689,7 +697,7 @@ if (!err) { NSLog (@"%s thread noticed update", __FUNCTION__); } else { - NSLog (@"%s thread got error %d (%s)", __FUNCTION__, err, error_message (err)); + NSLog (@"%s thread got error %d (%s)", __FUNCTION__, err, [NSString stringForLastKIMError:err]); err = 0; /* The server quit unexpectedly -- just try again */ } @@ -904,7 +912,7 @@ } if (err) { - NSLog(@"%s got error %s", _cmd, error_message(err)); + log_kim_error_to_console(err); } kim_options_free (&kimOptions); @@ -935,7 +943,7 @@ self.identities = [[newIdentities allObjects] sortedArrayUsingSelector:@selector(compare:)]; if (!identities) { err = ENOMEM; } } else { - NSLog (@"Got error %s", error_message (err)); + log_kim_error_to_console(err); } return err; @@ -988,9 +996,9 @@ kim_preferences_free(&prefs); if (err) { - NSLog(@"%s received error %s", _cmd, error_message(err)); + log_kim_error_to_console(err); } - + if (!err) { [self reload]; } diff --git a/src/kim/agent/mac/KIMUtilities.h b/src/kim/agent/mac/KIMUtilities.h index 790d238e6..68774952c 100644 --- a/src/kim/agent/mac/KIMUtilities.h +++ b/src/kim/agent/mac/KIMUtilities.h @@ -9,6 +9,11 @@ #import #import +#define log_kim_error_to_console(err)\ +{\ +NSLog(@"%s got error %@", _cmd, [NSString stringForLastKIMError:err]);\ +} while (0); + @interface NSString (KIMUtilities) + (NSString *) stringForLastKIMError: (kim_error) in_err; diff --git a/src/kim/agent/mac/KIMUtilities.m b/src/kim/agent/mac/KIMUtilities.m index f8c7b8508..07c85e8e8 100644 --- a/src/kim/agent/mac/KIMUtilities.m +++ b/src/kim/agent/mac/KIMUtilities.m @@ -8,7 +8,6 @@ #import "KIMUtilities.h" - @implementation NSString (KIMUtilities) + (NSString *) stringForLastKIMError: (kim_error) in_err diff --git a/src/kim/agent/mac/SelectIdentityController.m b/src/kim/agent/mac/SelectIdentityController.m index b26eaaa00..e70189d68 100644 --- a/src/kim/agent/mac/SelectIdentityController.m +++ b/src/kim/agent/mac/SelectIdentityController.m @@ -185,8 +185,8 @@ //[window center]; [self showWindow: self]; - [NSApp run]; - [self close]; +// [NSApp run]; +// [self close]; //[[NSApp delegate] removeActiveWindow: [self window]]; -- 2.26.2