diff options
author | mltownsend <mltownsend@gmail.com> | 2009-10-20 17:19:57 +0000 |
---|---|---|
committer | mltownsend <mltownsend@gmail.com> | 2009-10-20 17:19:57 +0000 |
commit | 53ca17c5bba2d57ecaee3a8ccd005fe4d6a4abe3 (patch) | |
tree | 8a450d7d63a205cb97b30c505131a8637f1e19fa /Source | |
parent | 58b657e70459066b0bbd2e961669e170a2d38520 (diff) | |
download | sequelpro-53ca17c5bba2d57ecaee3a8ccd005fe4d6a4abe3.tar.gz sequelpro-53ca17c5bba2d57ecaee3a8ccd005fe4d6a4abe3.tar.bz2 sequelpro-53ca17c5bba2d57ecaee3a8ccd005fe4d6a4abe3.zip |
Attempt to fix connection problem
Diffstat (limited to 'Source')
-rw-r--r-- | Source/SPUserManager.h | 3 | ||||
-rw-r--r-- | Source/SPUserManager.m | 29 | ||||
-rw-r--r-- | Source/TableDocument.m | 2 |
3 files changed, 15 insertions, 19 deletions
diff --git a/Source/SPUserManager.h b/Source/SPUserManager.h index d673226a..cd397e3d 100644 --- a/Source/SPUserManager.h +++ b/Source/SPUserManager.h @@ -42,14 +42,13 @@ IBOutlet NSTreeController *treeController; IBOutlet NSMutableDictionary *privsSupportedByServer; } +@property (nonatomic, retain) MCPConnection *mySqlConnection; - (NSPersistentStoreCoordinator *)persistentStoreCoordinator; - (NSManagedObjectModel *)managedObjectModel; - (NSManagedObjectContext *)managedObjectContext; - (id)initWithConnection:(MCPConnection *)connection; -- (void)setConnection:(MCPConnection *)connection; -- (MCPConnection *)connection; - (void)show; - (void)initializeChild:(NSManagedObject *)child withItem:(NSDictionary *)item; diff --git a/Source/SPUserManager.m b/Source/SPUserManager.m index aaa56b1a..4b7863e1 100644 --- a/Source/SPUserManager.m +++ b/Source/SPUserManager.m @@ -29,6 +29,7 @@ #import "ImageAndTextCell.h" #import "SPArrayAdditions.h" #import "SPStringAdditions.h" +#import "SPGrowlController.h" #define COLUMNIDNAME @"NameColumn" @@ -44,6 +45,8 @@ @implementation SPUserManager +@synthesize mySqlConnection; + - (id)init { [self dealloc]; @@ -57,7 +60,7 @@ return nil; } - [self setConnection:connection]; + self.mySqlConnection = connection; // When reading privileges from the database, they are converted automatically to a // lowercase key used in the user privileges stores, from which a GRANT syntax @@ -97,10 +100,6 @@ selector:@selector(contextDidSave:) name:NSManagedObjectContextDidSaveNotification object:nil]; - //[[NSNotificationCenter defaultCenter] addObserver:self -// selector:@selector(contextDidChange:) -// name:NSManagedObjectContextObjectsDidChangeNotification -// object:nil]; [tabView selectTabViewItemAtIndex:0]; NSTableColumn *tableColumn = [outlineView tableColumnWithIdentifier:COLUMNIDNAME]; @@ -110,7 +109,6 @@ [tableColumn setDataCell:imageAndTextCell]; [self _initializeUsers]; -// [NSThread detachNewThreadSelector:@selector(_initializeUsers) toTarget:self withObject:nil]; [[self window] makeKeyAndOrderFront:nil]; } @@ -124,7 +122,7 @@ NSMutableArray *resultAsArray = [NSMutableArray array]; NSMutableArray *usersResultArray = [NSMutableArray array]; - MCPResult *result = [[[self connection] queryString:@"SELECT * FROM `mysql`.`user` ORDER BY `user`"] retain]; + MCPResult *result = [[self.mySqlConnection queryString:@"SELECT * FROM `mysql`.`user` ORDER BY `user`"] retain]; int rows = [result numOfRows]; if (rows > 0) { @@ -146,7 +144,7 @@ [privsSupportedByServer removeAllObjects]; // Attempt to use SHOW PRIVILEGES syntax - supported since 4.1.0 - result = [[self connection] queryString:@"SHOW PRIVILEGES"]; + result = [self.mySqlConnection queryString:@"SHOW PRIVILEGES"]; if ([result numOfRows]) { while (privRow = [result fetchRowAsArray]) { privKey = [NSMutableString stringWithString:[[privRow objectAtIndex:0] lowercaseString]]; @@ -157,7 +155,7 @@ // If that fails, base privilege support on the mysql.users columns } else { - result = [[self connection] queryString:@"SHOW COLUMNS FROM `mysql`.`user`"]; + result = [self.mySqlConnection queryString:@"SHOW COLUMNS FROM `mysql`.`user`"]; while (privRow = [result fetchRowAsArray]) { privKey = [NSMutableString stringWithString:[privRow objectAtIndex:0]]; if (![privKey hasSuffix:@"_priv"]) continue; @@ -592,7 +590,7 @@ } droppedUsers = [[droppedUsers substringToIndex:[droppedUsers length]-2] mutableCopy]; - [[self connection] queryString:[NSString stringWithFormat:@"DROP USER %@", droppedUsers]]; + [self.mySqlConnection queryString:[NSString stringWithFormat:@"DROP USER %@", droppedUsers]]; return TRUE; } @@ -607,7 +605,7 @@ [[user valueForKey:@"host"] tickQuotedString], [[[user parent] valueForKey:@"password"] tickQuotedString]]; // Create user in database - [[self connection] queryString:[NSString stringWithFormat:createStatement]]; + [self.mySqlConnection queryString:[NSString stringWithFormat:createStatement]]; if ([self checkAndDisplayMySqlError]) { @@ -615,7 +613,6 @@ } } } - return TRUE; } @@ -654,7 +651,7 @@ [[[user parent] valueForKey:@"user"] tickQuotedString], [[user valueForKey:@"host"] tickQuotedString]]; DLog(@"%@", grantStatement); - [[self connection] queryString:[NSString stringWithFormat:grantStatement]]; + [self.mySqlConnection queryString:[NSString stringWithFormat:grantStatement]]; [self checkAndDisplayMySqlError]; } @@ -666,7 +663,7 @@ [[[user parent] valueForKey:@"user"] tickQuotedString], [[user valueForKey:@"host"] tickQuotedString]]; DLog(@"%@", revokeStatement); - [[self connection] queryString:[NSString stringWithFormat:revokeStatement]]; + [self.mySqlConnection queryString:[NSString stringWithFormat:revokeStatement]]; [self checkAndDisplayMySqlError]; } } @@ -703,9 +700,9 @@ - (BOOL)checkAndDisplayMySqlError { - if (![[[self connection] getLastErrorMessage] isEqualToString:@""]) + if (![[self.mySqlConnection getLastErrorMessage] isEqualToString:@""]) { - NSAlert *alert = [NSAlert alertWithMessageText:@"MySQL Error" defaultButton:@"OK" alternateButton:nil otherButton:nil informativeTextWithFormat:[[self connection] getLastErrorMessage]]; + NSAlert *alert = [NSAlert alertWithMessageText:@"MySQL Error" defaultButton:@"OK" alternateButton:nil otherButton:nil informativeTextWithFormat:[self.mySqlConnection getLastErrorMessage]]; [alert runModal]; return FALSE; diff --git a/Source/TableDocument.m b/Source/TableDocument.m index 82092668..6b9e5eb4 100644 --- a/Source/TableDocument.m +++ b/Source/TableDocument.m @@ -625,7 +625,7 @@ userManagerInstance = [[SPUserManager alloc] initWithConnection:mySQLConnection]; } - [userManagerInstance setConnection:mySQLConnection]; + userManagerInstance.mySqlConnection = mySQLConnection; // Set the cutom query editor's MySQL version [customQueryInstance setMySQLversion:mySQLVersion]; |