From fcb696ae383149f0abfb88a9d4b2ae21d91f3c3b Mon Sep 17 00:00:00 2001 From: Max Date: Fri, 23 Feb 2018 00:52:44 +0100 Subject: Replace getter/setter glue with property --- Source/SPDatabaseDocument.h | 5 ++--- Source/SPDatabaseDocument.m | 26 ++++++-------------------- 2 files changed, 8 insertions(+), 23 deletions(-) (limited to 'Source') diff --git a/Source/SPDatabaseDocument.h b/Source/SPDatabaseDocument.h index de7dd55e..36269e73 100644 --- a/Source/SPDatabaseDocument.h +++ b/Source/SPDatabaseDocument.h @@ -262,7 +262,7 @@ NSMutableArray *runningActivitiesArray; #endif - NSString *keyChainID; + NSString *keychainID; #ifndef SP_CODA /* ivars */ NSThread *printThread; @@ -342,7 +342,7 @@ #endif - (void)setConnection:(SPMySQLConnection *)theConnection; - (SPMySQLConnection *)getConnection; -- (void)setKeychainID:(NSString *)theID; +@property(readwrite, copy, nonatomic) NSString *keychainID; // Database methods - (IBAction)setDatabases:(id)sender; @@ -451,7 +451,6 @@ - (NSString *)port; - (NSString *)mySQLVersion; - (NSString *)user; -- (NSString *)keyChainID; - (NSString *)connectionID; #ifndef SP_CODA /* method decls */ - (NSString *)tabTitleForTooltip; diff --git a/Source/SPDatabaseDocument.m b/Source/SPDatabaseDocument.m index 7b1d51de..ccf1cb34 100644 --- a/Source/SPDatabaseDocument.m +++ b/Source/SPDatabaseDocument.m @@ -136,6 +136,7 @@ static int64_t SPDatabaseDocumentInstanceCounter = 0; @synthesize processID; @synthesize instanceId; @synthesize dbTablesTableView = dbTablesTableView; +@synthesize keychainID = keychainID; #pragma mark - @@ -218,8 +219,6 @@ static int64_t SPDatabaseDocumentInstanceCounter = 0; alterDatabaseCharsetHelper = nil; //init in awakeFromNib addDatabaseCharsetHelper = nil; - keyChainID = nil; - #ifndef SP_CODA /* init ivars */ statusValues = nil; printThread = nil; @@ -613,14 +612,6 @@ static int64_t SPDatabaseDocumentInstanceCounter = 0; return mySQLConnection; } -/** - * Sets this connection's Keychain ID. - */ -- (void)setKeychainID:(NSString *)theId -{ - keyChainID = [[NSString stringWithString:theId] retain]; -} - #pragma mark - #pragma mark Database methods @@ -2863,11 +2854,6 @@ static int64_t SPDatabaseDocumentInstanceCounter = 0; return thePort; } -- (NSString *)keyChainID -{ - return keyChainID; -} - - (BOOL)isSaveInBundle { return _isSavedInBundle; @@ -4674,7 +4660,7 @@ static int64_t SPDatabaseDocumentInstanceCounter = 0; } [connection setObject:connectionType forKey:@"type"]; - if ([[self keyChainID] length]) [connection setObject:[self keyChainID] forKey:@"kcid"]; + if ([[self keychainID] length]) [connection setObject:[self keychainID] forKey:@"kcid"]; [connection setObject:[self name] forKey:@"name"]; [connection setObject:[self host] forKey:@"host"]; [connection setObject:[self user] forKey:@"user"]; @@ -4877,7 +4863,7 @@ static int64_t SPDatabaseDocumentInstanceCounter = 0; // Set the keychain details if available if ([connection objectForKey:@"kcid"] && [(NSString *)[connection objectForKey:@"kcid"] length]) { [self setKeychainID:[connection objectForKey:@"kcid"]]; - [connectionController setConnectionKeychainItemName:[keychain nameForFavoriteName:[connectionController name] id:[self keyChainID]]]; + [connectionController setConnectionKeychainItemName:[keychain nameForFavoriteName:[connectionController name] id:[self keychainID]]]; [connectionController setConnectionKeychainItemAccount:[keychain accountForUser:[connectionController user] host:[connectionController host] database:[connection objectForKey:@"database"]]]; } @@ -4910,7 +4896,7 @@ static int64_t SPDatabaseDocumentInstanceCounter = 0; [connectionController setSshPassword:[connection objectForKey:@"ssh_password"]]; else { if ([connection objectForKey:@"kcid"] && [(NSString *)[connection objectForKey:@"kcid"] length]) { - [connectionController setConnectionSSHKeychainItemName:[keychain nameForSSHForFavoriteName:[connectionController name] id:[self keyChainID]]]; + [connectionController setConnectionSSHKeychainItemName:[keychain nameForSSHForFavoriteName:[connectionController name] id:[self keychainID]]]; [connectionController setConnectionSSHKeychainItemAccount:[keychain accountForSSHUser:[connectionController sshUser] sshHost:[connectionController sshHost]]]; } NSString *sshpw = [self keychainPasswordForSSHConnection:nil]; @@ -7184,7 +7170,7 @@ static int64_t SPDatabaseDocumentInstanceCounter = 0; // Otherwise, pull the password from the keychain using the details from this connection SPKeychain *keychain = [[SPKeychain alloc] init]; - NSString *connectionSSHKeychainItemName = [[keychain nameForSSHForFavoriteName:[connectionController name] id:[self keyChainID]] retain]; + NSString *connectionSSHKeychainItemName = [[keychain nameForSSHForFavoriteName:[connectionController name] id:[self keychainID]] retain]; NSString *connectionSSHKeychainItemAccount = [[keychain accountForSSHUser:[connectionController sshUser] sshHost:[connectionController sshHost]] retain]; NSString *sshPassword = [keychain getPasswordForName:connectionSSHKeychainItemName account:connectionSSHKeychainItemAccount]; @@ -7760,7 +7746,7 @@ static int64_t SPDatabaseDocumentInstanceCounter = 0; if (spfPreferences) SPClear(spfPreferences); if (spfSession) SPClear(spfSession); if (spfDocData) SPClear(spfDocData); - if (keyChainID) SPClear(keyChainID); + [self setKeychainID:nil]; if (mainToolbar) SPClear(mainToolbar); if (titleAccessoryView) SPClear(titleAccessoryView); if (taskProgressWindow) SPClear(taskProgressWindow); -- cgit v1.2.3