From 1490d184c4c3ef4bf76396203d58feece4e4a25d Mon Sep 17 00:00:00 2001 From: Bibiko Date: Mon, 28 Jun 2010 10:54:17 +0000 Subject: =?UTF-8?q?=E2=80=A2=20added=20to=20SPconnectionDelegate=20method?= =?UTF-8?q?=20"keychainPasswordForSSHConnection"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Source/SPDatabaseDocument.m | 48 +++++++++++++++++---------------------------- 1 file changed, 18 insertions(+), 30 deletions(-) (limited to 'Source/SPDatabaseDocument.m') diff --git a/Source/SPDatabaseDocument.m b/Source/SPDatabaseDocument.m index 781df933..32bf62d0 100644 --- a/Source/SPDatabaseDocument.m +++ b/Source/SPDatabaseDocument.m @@ -466,7 +466,7 @@ [connectionController setPassword:[connection objectForKey:@"password"]]; else { NSString *pw = [self keychainPasswordForConnection:nil]; - if([pw length]) + if(pw) [connectionController setPassword:pw]; } @@ -485,15 +485,9 @@ if([connection objectForKey:@"ssh_password"]) [connectionController setSshPassword:[connection objectForKey:@"ssh_password"]]; else { - SPKeychain *keychain = [[SPKeychain alloc] init]; - NSString *connectionSSHKeychainItemName = [[keychain nameForSSHForFavoriteName:[connectionController name] id:[self keyChainID]] retain]; - NSString *connectionSSHKeychainItemAccount = [[keychain accountForSSHUser:[connectionController sshUser] sshHost:[connectionController sshHost]] retain]; - NSString *pw = [keychain getPasswordForName:connectionSSHKeychainItemName account:connectionSSHKeychainItemAccount]; - if ([pw length]) - [connectionController setSshPassword:pw]; - if(connectionSSHKeychainItemName) [connectionSSHKeychainItemName release]; - if(connectionSSHKeychainItemAccount) [connectionSSHKeychainItemAccount release]; - [keychain release]; + NSString *sshpw = [self keychainPasswordForSSHConnection:nil]; + if(sshpw) + [connectionController setSshPassword:sshpw]; } } @@ -549,17 +543,6 @@ if([spfSession objectForKey:@"isToolbarVisible"]) [mainToolbar setVisible:[[spfSession objectForKey:@"isToolbarVisible"] boolValue]]; - // TODO up to now it doesn't work - if([spfSession objectForKey:@"contentSelectedIndexSet"]) { - NSMutableIndexSet *anIndexSet = [NSMutableIndexSet indexSet]; - NSArray *items = [spfSession objectForKey:@"contentSelectedIndexSet"]; - NSUInteger i; - for(i=0; i<[items count]; i++) - [anIndexSet addIndex:(NSUInteger)NSArrayObjectAtIndex(items, i)]; - - [tableContentInstance setSelectedRowIndexesToRestore:anIndexSet]; - } - // Set table content details for restore if([spfSession objectForKey:@"contentSortCol"]) [tableContentInstance setSortColumnNameToRestore:[spfSession objectForKey:@"contentSortCol"] isAscending:[[spfSession objectForKey:@"contentSortCol"] boolValue]]; @@ -570,7 +553,6 @@ if([spfSession objectForKey:@"contentFilter"]) [tableContentInstance setFiltersToRestore:[spfSession objectForKey:@"contentFilter"]]; - // Select table [tablesListInstance selectTableAtIndex:[NSNumber numberWithInteger:[tables indexOfObject:[spfSession objectForKey:@"table"]]]]; @@ -578,6 +560,17 @@ if([spfSession objectForKey:@"connectionEncoding"] && ![[self connectionEncoding] isEqualToString:[spfSession objectForKey:@"connectionEncoding"]]) [self setConnectionEncoding:[spfSession objectForKey:@"connectionEncoding"] reloadingViews:YES]; + // TODO up to now it doesn't work + if([spfSession objectForKey:@"contentSelectedIndexSet"]) { + NSMutableIndexSet *anIndexSet = [NSMutableIndexSet indexSet]; + NSArray *items = [spfSession objectForKey:@"contentSelectedIndexSet"]; + NSUInteger i; + for(i=0; i<[items count]; i++) + [anIndexSet addIndex:(NSUInteger)NSArrayObjectAtIndex(items, i)]; + + [tableContentInstance setSelectedRowIndexesToRestore:anIndexSet]; + } + // Select view if([[spfSession objectForKey:@"view"] isEqualToString:@"SP_VIEW_STRUCTURE"]) [self viewStructure:self]; @@ -3264,17 +3257,12 @@ [connection setObject:@"" forKey:@"password"]; if([connectionController type] == SPSSHTunnelConnection) { - SPKeychain *keychain = [[SPKeychain alloc] init]; - NSString *connectionSSHKeychainItemName = [[keychain nameForSSHForFavoriteName:[connectionController name] id:[self keyChainID]] retain]; - NSString *connectionSSHKeychainItemAccount = [[keychain accountForSSHUser:[connectionController sshUser] sshHost:[connectionController sshHost]] retain]; - NSString *sshpw = [keychain getPasswordForName:connectionSSHKeychainItemName account:connectionSSHKeychainItemAccount]; - if (sshpw && [sshpw length]) + NSString *sshpw = [self keychainPasswordForSSHConnection:nil]; + if(![sshpw length]) sshpw = [connectionController sshPassword]; + if (sshpw) [connection setObject:sshpw forKey:@"ssh_password"]; else [connection setObject:@"" forKey:@"ssh_password"]; - if(connectionSSHKeychainItemName) [connectionSSHKeychainItemName release]; - if(connectionSSHKeychainItemAccount) [connectionSSHKeychainItemAccount release]; - [keychain release]; } } -- cgit v1.2.3