Permalink
Browse files

Replace getter/setter glue with property

  • Loading branch information...
dmoagx committed Feb 22, 2018
1 parent 3a944d7 commit fcb696ae383149f0abfb88a9d4b2ae21d91f3c3b
Showing with 8 additions and 23 deletions.
  1. +2 −3 Source/SPDatabaseDocument.h
  2. +6 −20 Source/SPDatabaseDocument.m
@@ -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;
@@ -136,6 +136,7 @@ @implementation SPDatabaseDocument
@synthesize processID;
@synthesize instanceId;
@synthesize dbTablesTableView = dbTablesTableView;
@synthesize keychainID = keychainID;

#pragma mark -

@@ -218,8 +219,6 @@ - (id)init
alterDatabaseCharsetHelper = nil; //init in awakeFromNib
addDatabaseCharsetHelper = nil;

keyChainID = nil;

#ifndef SP_CODA /* init ivars */
statusValues = nil;
printThread = nil;
@@ -613,14 +612,6 @@ - (SPMySQLConnection *)getConnection
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 @@ - (NSString *)port
return thePort;
}

- (NSString *)keyChainID
{
return keyChainID;
}

- (BOOL)isSaveInBundle
{
return _isSavedInBundle;
@@ -4674,7 +4660,7 @@ - (NSDictionary *) stateIncludingDetails:(NSDictionary *)detailsToReturn
}
[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 @@ - (BOOL)setState:(NSDictionary *)stateDetails fromFile:(BOOL)spfBased
// 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 @@ - (BOOL)setState:(NSDictionary *)stateDetails fromFile:(BOOL)spfBased
[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 @@ - (NSString *)keychainPasswordForSSHConnection:(SPMySQLConnection *)connection
// 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 @@ - (void)dealloc
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);

0 comments on commit fcb696a

Please sign in to comment.