From 870da55b26764076d657ef9625e8798f538304cd Mon Sep 17 00:00:00 2001 From: rowanbeentje Date: Mon, 10 Jan 2011 00:51:27 +0000 Subject: - Track the keychain ID of the favourite in the connection controller, fixing errors when amending favourites in the connection view and thereafter saving as .spf or duplicating connections --- Source/SPConnectionController.h | 1 + Source/SPConnectionController.m | 9 ++++++--- 2 files changed, 7 insertions(+), 3 deletions(-) (limited to 'Source') diff --git a/Source/SPConnectionController.h b/Source/SPConnectionController.h index 672e983f..5d9a21a1 100644 --- a/Source/SPConnectionController.h +++ b/Source/SPConnectionController.h @@ -82,6 +82,7 @@ NSString *sshPort; @private NSString *favoritesPBoardType; + NSString *connectionKeychainID; NSString *connectionKeychainItemName; NSString *connectionKeychainItemAccount; NSString *connectionSSHKeychainItemName; diff --git a/Source/SPConnectionController.m b/Source/SPConnectionController.m index 3558d484..c521213c 100644 --- a/Source/SPConnectionController.m +++ b/Source/SPConnectionController.m @@ -89,6 +89,7 @@ tableDocument = theTableDocument; databaseConnectionSuperview = [tableDocument databaseView]; databaseConnectionView = [tableDocument valueForKey:@"contentViewSplitter"]; + connectionKeychainID = nil; connectionKeychainItemName = nil; connectionKeychainItemAccount = nil; connectionSSHKeychainItemName = nil; @@ -173,6 +174,7 @@ if (favorites) [favorites release]; if (mySQLConnection) [mySQLConnection release]; if (sshTunnel) [sshTunnel setConnectionStateChangeSelector:nil delegate:nil], [sshTunnel disconnect], [sshTunnel release]; + if (connectionKeychainID) [connectionKeychainID release]; if (connectionKeychainItemName) [connectionKeychainItemName release]; if (connectionKeychainItemAccount) [connectionKeychainItemAccount release]; if (connectionSSHKeychainItemName) [connectionSSHKeychainItemName release]; @@ -512,9 +514,7 @@ for (NSInteger i = 0; i < [toolbarItems count]; i++) [[toolbarItems objectAtIndex:i] setEnabled:YES]; // Set keychain id for saving SPF files - if ([self valueForKeyPath:@"selectedFavorite.id"]) { - [tableDocument setKeychainID:[[self valueForKeyPath:@"selectedFavorite.id"] stringValue]]; - } + if (connectionKeychainID) [tableDocument setKeychainID:connectionKeychainID]; // Pass the connection to the table document, allowing it to set // up the other classes and the rest of the interface. @@ -884,6 +884,7 @@ automaticFavoriteSelection = YES; // Clear the keychain referral items as appropriate + if (connectionKeychainID) [connectionKeychainID release], connectionKeychainID = nil; if (connectionKeychainItemName) [connectionKeychainItemName release], connectionKeychainItemName = nil; if (connectionKeychainItemAccount) [connectionKeychainItemAccount release], connectionKeychainItemAccount = nil; if (connectionSSHKeychainItemName) [connectionSSHKeychainItemName release], connectionSSHKeychainItemName = nil; @@ -933,6 +934,8 @@ [connectionKeychainItemAccount release], connectionKeychainItemAccount = nil; } + if ([self valueForKeyPath:@"selectedFavorite.id"]) connectionKeychainID = [[[self valueForKeyPath:@"selectedFavorite.id"] stringValue] retain]; + // And the same for the SSH password connectionSSHKeychainItemName = [[keychain nameForSSHForFavoriteName:[self valueForKeyPath:@"selectedFavorite.name"] id:[self valueForKeyPath:@"selectedFavorite.id"]] retain]; connectionSSHKeychainItemAccount = [[keychain accountForSSHUser:[self valueForKeyPath:@"selectedFavorite.sshUser"] sshHost:[self valueForKeyPath:@"selectedFavorite.sshHost"]] retain]; -- cgit v1.2.3