diff options
-rw-r--r-- | Source/SPConnectionController.h | 3 | ||||
-rw-r--r-- | Source/SPConnectionController.m | 32 | ||||
-rw-r--r-- | Source/SPConnectionControllerDelegate.m | 6 | ||||
-rw-r--r-- | Source/SPConnectionControllerInitializer.m | 5 | ||||
-rw-r--r-- | Source/SPDatabaseDocument.m | 10 |
5 files changed, 31 insertions, 25 deletions
diff --git a/Source/SPConnectionController.h b/Source/SPConnectionController.h index eeb7f2d0..456f8383 100644 --- a/Source/SPConnectionController.h +++ b/Source/SPConnectionController.h @@ -67,7 +67,6 @@ NSOpenPanel *keySelectionPanel; #endif NSUserDefaults *prefs; - NSMutableArray *favorites; #ifndef SP_REFACTOR /* ivars */ BOOL automaticFavoriteSelection; @@ -174,7 +173,7 @@ SPTreeNode *favoritesRoot; SPFavoriteNode *currentFavorite; SPFavoritesController *favoritesController; - SPFavoritesSortItem previousSortItem, currentSortItem; + SPFavoritesSortItem currentSortItem; #endif } diff --git a/Source/SPConnectionController.m b/Source/SPConnectionController.m index a2b3c06c..e40cb80a 100644 --- a/Source/SPConnectionController.m +++ b/Source/SPConnectionController.m @@ -291,7 +291,7 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2, /** * Opens the SSH/SSL key selection window, ready to select a key file. */ -- (IBAction)chooseKeyLocation:(id)sender +- (IBAction)chooseKeyLocation:(NSButton *)sender { [favoritesOutlineView deselectAll:self]; NSString *directoryPath = nil; @@ -433,7 +433,7 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2, */ - (void)sortFavorites:(id)sender { - previousSortItem = currentSortItem; + SPFavoritesSortItem previousSortItem = currentSortItem; currentSortItem = [[sender menu] indexOfItem:sender]; [prefs setInteger:currentSortItem forKey:SPFavoritesSortedBy]; @@ -449,7 +449,7 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2, /** * Reverses the favorites table view sorting based on the selected criteria. */ -- (void)reverseSortFavorites:(id)sender +- (void)reverseSortFavorites:(NSMenuItem *)sender { reverseFavoritesSort = (![sender state]); @@ -469,6 +469,7 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2, 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; @@ -481,8 +482,7 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2, // Keep a copy of the favorite as it currently stands if (currentFavorite) [currentFavorite release], currentFavorite = nil; - - currentFavorite = [[node representedObject] copy]; + currentFavorite = [fav copy]; [connectionResizeContainer setHidden:NO]; @@ -526,7 +526,10 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2, [connectionKeychainItemName release], connectionKeychainItemName = nil; [connectionKeychainItemAccount release], connectionKeychainItemAccount = nil; } - + + // Store the selected favorite ID for use with the document on connection + if ([fav objectForKey:SPFavoriteIDKey]) connectionKeychainID = [[fav objectForKey:SPFavoriteIDKey] copy]; + // And the same for the SSH password connectionSSHKeychainItemName = [[keychain nameForSSHForFavoriteName:[fav objectForKey:SPFavoriteNameKey] id:[fav objectForKey:SPFavoriteIDKey]] retain]; connectionSSHKeychainItemAccount = [[keychain accountForSSHUser:[fav objectForKey:SPFavoriteSSHUserKey] sshHost:[fav objectForKey:SPFavoriteSSHHostKey]] retain]; @@ -694,19 +697,19 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2, if ([self database]) [newFavorite setObject:[self database] forKey:SPFavoriteDatabaseKey]; // SSL details - if ([self useSSL]) [newFavorite setObject:[NSNumber numberWithInt:[self useSSL]] forKey:SPFavoriteUseSSLKey]; - [newFavorite setObject:[NSNumber numberWithInt:[self sslKeyFileLocationEnabled]] forKey:SPFavoriteSSLKeyFileLocationEnabledKey]; + if ([self useSSL]) [newFavorite setObject:[NSNumber numberWithInteger:[self useSSL]] forKey:SPFavoriteUseSSLKey]; + [newFavorite setObject:[NSNumber numberWithInteger:[self sslKeyFileLocationEnabled]] forKey:SPFavoriteSSLKeyFileLocationEnabledKey]; if ([self sslKeyFileLocation]) [newFavorite setObject:[self sslKeyFileLocation] forKey:SPFavoriteSSLKeyFileLocationKey]; - [newFavorite setObject:[NSNumber numberWithInt:[self sslCertificateFileLocationEnabled]] forKey:SPFavoriteSSLCertificateFileLocationEnabledKey]; + [newFavorite setObject:[NSNumber numberWithInteger:[self sslCertificateFileLocationEnabled]] forKey:SPFavoriteSSLCertificateFileLocationEnabledKey]; if ([self sslCertificateFileLocation]) [newFavorite setObject:[self sslCertificateFileLocation] forKey:SPFavoriteSSLCertificateFileLocationKey]; - [newFavorite setObject:[NSNumber numberWithInt:[self sslCACertFileLocationEnabled]] forKey:SPFavoriteSSLCACertFileLocationEnabledKey]; + [newFavorite setObject:[NSNumber numberWithInteger:[self sslCACertFileLocationEnabled]] forKey:SPFavoriteSSLCACertFileLocationEnabledKey]; if ([self sslCACertFileLocation]) [newFavorite setObject:[self sslCACertFileLocation] forKey:SPFavoriteSSLCACertFileLocationKey]; // SSH details if ([self sshHost]) [newFavorite setObject:[self sshHost] forKey:SPFavoriteSSHHostKey]; if ([self sshUser]) [newFavorite setObject:[self sshUser] forKey:SPFavoriteSSHUserKey]; if ([self sshPort]) [newFavorite setObject:[self sshPort] forKey:SPFavoriteSSHPortKey]; - [newFavorite setObject:[NSNumber numberWithInt:[self sshKeyLocationEnabled]] forKey:SPFavoriteSSHKeyLocationEnabledKey]; + [newFavorite setObject:[NSNumber numberWithInteger:[self sshKeyLocationEnabled]] forKey:SPFavoriteSSHKeyLocationEnabledKey]; if ([self sshKeyLocation]) [newFavorite setObject:[self sshKeyLocation] forKey:SPFavoriteSSHKeyLocationKey]; // Add the password to keychain as appropriate @@ -1366,7 +1369,7 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2, { if (!currentFavorite) return; - NSDictionary *oldFavorite = [currentFavorite nodeFavorite]; + NSDictionary *oldFavorite = currentFavorite; NSDictionary *newFavorite = [[[self selectedFavoriteNode] representedObject] nodeFavorite]; NSString *passwordValue; @@ -1445,7 +1448,7 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2, if (currentFavorite) [currentFavorite release], currentFavorite = nil; if ([[favoritesOutlineView selectedRowIndexes] count]) { - currentFavorite = [[[self selectedFavoriteNode] representedObject] copy]; + currentFavorite = [[[[self selectedFavoriteNode] representedObject] nodeFavorite] copy]; } } @@ -1464,10 +1467,13 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2, 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]; if (connectionSSHKeychainItemAccount) [connectionSSHKeychainItemAccount release]; + if (currentFavorite) [currentFavorite release], currentFavorite = nil; if (favoritesRoot) [favoritesRoot release], favoritesRoot = nil; diff --git a/Source/SPConnectionControllerDelegate.m b/Source/SPConnectionControllerDelegate.m index 352836e3..389bd46c 100644 --- a/Source/SPConnectionControllerDelegate.m +++ b/Source/SPConnectionControllerDelegate.m @@ -216,9 +216,7 @@ static NSString *SPDatabaseImage = @"database-small"; [menuItem setState:NSOffState]; } - NSArray *nodes = draggedNodes; - - if (![nodes count]) return acceptedDrop; + if (![draggedNodes count]) return acceptedDrop; if ([node isGroup]) { if (index == NSOutlineViewDropOnItemIndex) { @@ -237,7 +235,7 @@ static NSString *SPDatabaseImage = @"database-small"; NSMutableArray *childNodeArray = [node mutableChildNodes]; - for (SPTreeNode *treeNode in nodes) + for (SPTreeNode *treeNode in draggedNodes) { // Remove the node from its old location NSInteger oldIndex = [childNodeArray indexOfObject:treeNode]; diff --git a/Source/SPConnectionControllerInitializer.m b/Source/SPConnectionControllerInitializer.m index 34f9ca40..a9aa6ca8 100644 --- a/Source/SPConnectionControllerInitializer.m +++ b/Source/SPConnectionControllerInitializer.m @@ -56,6 +56,7 @@ static NSString *SPConnectionViewNibName = @"ConnectionView"; databaseConnectionView = [dbDocument valueForKey:@"contentViewSplitter"]; // Keychain references + connectionKeychainID = nil; connectionKeychainItemName = nil; connectionKeychainItemAccount = nil; connectionSSHKeychainItemName = nil; @@ -68,6 +69,7 @@ static NSString *SPConnectionViewNibName = @"ConnectionView"; cancellingConnection = NO; mySQLConnectionCancelled = NO; favoriteNameFieldWasTouched = YES; + automaticFavoriteSelection = NO; [self loadNib]; [self registerForNotifications]; @@ -92,8 +94,9 @@ static NSString *SPConnectionViewNibName = @"ConnectionView"; // and the tree to be constructed. favoritesController = [SPFavoritesController sharedFavoritesController]; - // Tree reference + // Tree references favoritesRoot = [favoritesController favoritesTree]; + currentFavorite = nil; // Update the UI [self _reloadFavoritesViewData]; diff --git a/Source/SPDatabaseDocument.m b/Source/SPDatabaseDocument.m index 53dfb908..2f2d8f1b 100644 --- a/Source/SPDatabaseDocument.m +++ b/Source/SPDatabaseDocument.m @@ -4246,7 +4246,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; connectionType = @"SPSSHTunnelConnection"; [connection setObject:[connectionController sshHost] forKey:@"ssh_host"]; [connection setObject:[connectionController sshUser] forKey:@"ssh_user"]; - [connection setObject:[NSNumber numberWithInt:[connectionController sshKeyLocationEnabled]] forKey:@"ssh_keyLocationEnabled"]; + [connection setObject:[NSNumber numberWithInteger:[connectionController sshKeyLocationEnabled]] forKey:@"ssh_keyLocationEnabled"]; if ([connectionController sshKeyLocation]) [connection setObject:[connectionController sshKeyLocation] forKey:@"ssh_keyLocation"]; if ([connectionController sshPort] && [[connectionController sshPort] length]) @@ -4281,12 +4281,12 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; } } - [connection setObject:[NSNumber numberWithInt:[connectionController useSSL]] forKey:@"useSSL"]; - [connection setObject:[NSNumber numberWithInt:[connectionController sslKeyFileLocationEnabled]] forKey:@"sslKeyFileLocationEnabled"]; + [connection setObject:[NSNumber numberWithInteger:[connectionController useSSL]] forKey:@"useSSL"]; + [connection setObject:[NSNumber numberWithInteger:[connectionController sslKeyFileLocationEnabled]] forKey:@"sslKeyFileLocationEnabled"]; if ([connectionController sslKeyFileLocation]) [connection setObject:[connectionController sslKeyFileLocation] forKey:@"sslKeyFileLocation"]; - [connection setObject:[NSNumber numberWithInt:[connectionController sslCertificateFileLocationEnabled]] forKey:@"sslCertificateFileLocationEnabled"]; + [connection setObject:[NSNumber numberWithInteger:[connectionController sslCertificateFileLocationEnabled]] forKey:@"sslCertificateFileLocationEnabled"]; if ([connectionController sslCertificateFileLocation]) [connection setObject:[connectionController sslCertificateFileLocation] forKey:@"sslCertificateFileLocation"]; - [connection setObject:[NSNumber numberWithInt:[connectionController sslCACertFileLocationEnabled]] forKey:@"sslCACertFileLocationEnabled"]; + [connection setObject:[NSNumber numberWithInteger:[connectionController sslCACertFileLocationEnabled]] forKey:@"sslCACertFileLocationEnabled"]; if ([connectionController sslCACertFileLocation]) [connection setObject:[connectionController sslCACertFileLocation] forKey:@"sslCACertFileLocation"]; [stateDetails setObject:[NSDictionary dictionaryWithDictionary:connection] forKey:@"connection"]; |