diff options
Diffstat (limited to 'MainController.m')
-rw-r--r-- | MainController.m | 930 |
1 files changed, 465 insertions, 465 deletions
diff --git a/MainController.m b/MainController.m index 548c0434..d0f0a181 100644 --- a/MainController.m +++ b/MainController.m @@ -35,60 +35,60 @@ opens the preferences window */ { //get favorites if they exist - [favorites release]; - if ( [prefs objectForKey:@"favorites"] != nil ) { - favorites = [[NSMutableArray alloc] initWithArray:[prefs objectForKey:@"favorites"]]; - } else { - favorites = [[NSMutableArray array] retain]; - } - [tableView reloadData]; - - if ( [prefs boolForKey:@"reloadAfterAdding"] ) { - [reloadAfterAddingSwitch setState:NSOnState]; - } else { - [reloadAfterAddingSwitch setState:NSOffState]; - } - if ( [prefs boolForKey:@"reloadAfterEditing"] ) { - [reloadAfterEditingSwitch setState:NSOnState]; - } else { - [reloadAfterEditingSwitch setState:NSOffState]; - } - if ( [prefs boolForKey:@"reloadAfterRemoving"] ) { - [reloadAfterRemovingSwitch setState:NSOnState]; - } else { - [reloadAfterRemovingSwitch setState:NSOffState]; - } - if ( [prefs boolForKey:@"showError"] ) { - [showErrorSwitch setState:NSOnState]; - } else { - [showErrorSwitch setState:NSOffState]; - } - if ( [prefs boolForKey:@"dontShowBlob"] ) { - [dontShowBlobSwitch setState:NSOnState]; - } else { - [dontShowBlobSwitch setState:NSOffState]; - } - if ( [prefs boolForKey:@"limitRows"] ) { - [limitRowsSwitch setState:NSOnState]; - } else { - [limitRowsSwitch setState:NSOffState]; - } - if ( [prefs boolForKey:@"useMonospacedFonts"] ) { - [useMonospacedFontsSwitch setState:NSOnState]; - } else { - [useMonospacedFontsSwitch setState:NSOffState]; - } - if ( [prefs boolForKey:@"fetchRowCount"] ) { - [fetchRowCountSwitch setState:NSOnState]; - } else { - [fetchRowCountSwitch setState:NSOffState]; - } - [nullValueField setStringValue:[prefs stringForKey:@"nullValue"]]; - [limitRowsField setStringValue:[prefs stringForKey:@"limitRowsValue"]]; - [self chooseLimitRows:self]; - [encodingPopUpButton selectItemWithTitle:[prefs stringForKey:@"encoding"]]; - - [preferencesWindow makeKeyAndOrderFront:self]; + [favorites release]; + if ( [prefs objectForKey:@"favorites"] != nil ) { + favorites = [[NSMutableArray alloc] initWithArray:[prefs objectForKey:@"favorites"]]; + } else { + favorites = [[NSMutableArray array] retain]; + } + [tableView reloadData]; + + if ( [prefs boolForKey:@"reloadAfterAdding"] ) { + [reloadAfterAddingSwitch setState:NSOnState]; + } else { + [reloadAfterAddingSwitch setState:NSOffState]; + } + if ( [prefs boolForKey:@"reloadAfterEditing"] ) { + [reloadAfterEditingSwitch setState:NSOnState]; + } else { + [reloadAfterEditingSwitch setState:NSOffState]; + } + if ( [prefs boolForKey:@"reloadAfterRemoving"] ) { + [reloadAfterRemovingSwitch setState:NSOnState]; + } else { + [reloadAfterRemovingSwitch setState:NSOffState]; + } + if ( [prefs boolForKey:@"showError"] ) { + [showErrorSwitch setState:NSOnState]; + } else { + [showErrorSwitch setState:NSOffState]; + } + if ( [prefs boolForKey:@"dontShowBlob"] ) { + [dontShowBlobSwitch setState:NSOnState]; + } else { + [dontShowBlobSwitch setState:NSOffState]; + } + if ( [prefs boolForKey:@"limitRows"] ) { + [limitRowsSwitch setState:NSOnState]; + } else { + [limitRowsSwitch setState:NSOffState]; + } + if ( [prefs boolForKey:@"useMonospacedFonts"] ) { + [useMonospacedFontsSwitch setState:NSOnState]; + } else { + [useMonospacedFontsSwitch setState:NSOffState]; + } + if ( [prefs boolForKey:@"fetchRowCount"] ) { + [fetchRowCountSwitch setState:NSOnState]; + } else { + [fetchRowCountSwitch setState:NSOffState]; + } + [nullValueField setStringValue:[prefs stringForKey:@"nullValue"]]; + [limitRowsField setStringValue:[prefs stringForKey:@"limitRowsValue"]]; + [self chooseLimitRows:self]; + [encodingPopUpButton selectItemWithTitle:[prefs stringForKey:@"encoding"]]; + + [preferencesWindow makeKeyAndOrderFront:self]; } - (IBAction)addFavorite:(id)sender @@ -96,40 +96,40 @@ opens the preferences window adds a favorite */ { - int code; + int code; - isNewFavorite = YES; + isNewFavorite = YES; - [nameField setStringValue:@""]; - [hostField setStringValue:@""]; - [socketField setStringValue:@""]; - [userField setStringValue:@""]; - [passwordField setStringValue:@""]; - [portField setStringValue:@""]; - [databaseField setStringValue:@""]; + [nameField setStringValue:@""]; + [hostField setStringValue:@""]; + [socketField setStringValue:@""]; + [userField setStringValue:@""]; + [passwordField setStringValue:@""]; + [portField setStringValue:@""]; + [databaseField setStringValue:@""]; [sshCheckbox setState:NSOffState]; [sshUserField setEnabled:NO]; [sshPasswordField setEnabled:NO]; [sshHostField setEnabled:NO]; [sshPortField setEnabled:NO]; - [sshHostField setStringValue:@""]; - [sshUserField setStringValue:@""]; - [sshPortField setStringValue:@"8888"]; - [sshPasswordField setStringValue:@""]; - - [NSApp beginSheet:favoriteSheet - modalForWindow:preferencesWindow modalDelegate:self - didEndSelector:nil contextInfo:nil]; - code = [NSApp runModalForWindow:favoriteSheet]; - - [NSApp endSheet:favoriteSheet]; - [favoriteSheet orderOut:nil]; - - if ( code == 1 ) { - if ( ![[socketField stringValue] isEqualToString:@""] ) { - //set host to localhost if socket is used - [hostField setStringValue:@"localhost"]; - } + [sshHostField setStringValue:@""]; + [sshUserField setStringValue:@""]; + [sshPortField setStringValue:@"8888"]; + [sshPasswordField setStringValue:@""]; + + [NSApp beginSheet:favoriteSheet + modalForWindow:preferencesWindow modalDelegate:self + didEndSelector:nil contextInfo:nil]; + code = [NSApp runModalForWindow:favoriteSheet]; + + [NSApp endSheet:favoriteSheet]; + [favoriteSheet orderOut:nil]; + + if ( code == 1 ) { + if ( ![[socketField stringValue] isEqualToString:@""] ) { + //set host to localhost if socket is used + [hostField setStringValue:@"localhost"]; + } // get ssh settings NSString *sshHost, *sshUser, *sshPassword, *sshPort; NSNumber *ssh; @@ -162,25 +162,25 @@ adds a favorite sshPort = @""; ssh = [NSNumber numberWithInt:0]; } - NSDictionary *favorite = [NSDictionary - dictionaryWithObjects:[NSArray arrayWithObjects:[nameField stringValue], [hostField stringValue], [socketField stringValue], [userField stringValue], [portField stringValue], [databaseField stringValue], ssh, sshHost, sshUser, sshPort, nil] - forKeys:[NSArray arrayWithObjects:@"name", @"host", @"socket", @"user", @"port", @"database", @"useSSH", @"sshHost", @"sshUser", @"sshPort", nil]]; - [favorites addObject:favorite]; - if ( ![[passwordField stringValue] isEqualToString:@""] ) - [keyChainInstance addPassword:[passwordField stringValue] - forName:[NSString stringWithFormat:@"Sequel Pro : %@", [nameField stringValue]] - account:[NSString stringWithFormat:@"%@@%@/%@", [userField stringValue], [hostField stringValue], - [databaseField stringValue]]]; - if ( ![sshPassword isEqualToString:@""] ) - [keyChainInstance addPassword:sshPassword - forName:[NSString stringWithFormat:@"Sequel Pro SSHTunnel : %@", [nameField stringValue]] - account:[NSString stringWithFormat:@"%@@%@/%@", [userField stringValue], [hostField stringValue], - [databaseField stringValue]]]; - [tableView reloadData]; - [tableView selectRow:[tableView numberOfRows]-1 byExtendingSelection:NO]; - } - - isNewFavorite = NO; + NSDictionary *favorite = [NSDictionary + dictionaryWithObjects:[NSArray arrayWithObjects:[nameField stringValue], [hostField stringValue], [socketField stringValue], [userField stringValue], [portField stringValue], [databaseField stringValue], ssh, sshHost, sshUser, sshPort, nil] + forKeys:[NSArray arrayWithObjects:@"name", @"host", @"socket", @"user", @"port", @"database", @"useSSH", @"sshHost", @"sshUser", @"sshPort", nil]]; + [favorites addObject:favorite]; + if ( ![[passwordField stringValue] isEqualToString:@""] ) + [keyChainInstance addPassword:[passwordField stringValue] + forName:[NSString stringWithFormat:@"Sequel Pro : %@", [nameField stringValue]] + account:[NSString stringWithFormat:@"%@@%@/%@", [userField stringValue], [hostField stringValue], + [databaseField stringValue]]]; + if ( ![sshPassword isEqualToString:@""] ) + [keyChainInstance addPassword:sshPassword + forName:[NSString stringWithFormat:@"Sequel Pro SSHTunnel : %@", [nameField stringValue]] + account:[NSString stringWithFormat:@"%@@%@/%@", [userField stringValue], [hostField stringValue], + [databaseField stringValue]]]; + [tableView reloadData]; + [tableView selectRow:[tableView numberOfRows]-1 byExtendingSelection:NO]; + } + + isNewFavorite = NO; } - (IBAction)removeFavorite:(id)sender @@ -188,19 +188,19 @@ adds a favorite removes a favorite */ { - if ( ![tableView numberOfSelectedRows] ) - return; - - NSString *name = [[favorites objectAtIndex:[tableView selectedRow]] objectForKey:@"name"]; - NSString *user = [[favorites objectAtIndex:[tableView selectedRow]] objectForKey:@"user"]; - NSString *host = [[favorites objectAtIndex:[tableView selectedRow]] objectForKey:@"host"]; - NSString *database = [[favorites objectAtIndex:[tableView selectedRow]] objectForKey:@"database"]; - [keyChainInstance deletePasswordForName:[NSString stringWithFormat:@"Sequel Pro : %@", name] - account:[NSString stringWithFormat:@"%@@%@/%@", user, host, database]]; - [keyChainInstance deletePasswordForName:[NSString stringWithFormat:@"Sequel Pro SSHTunnel : %@", name] - account:[NSString stringWithFormat:@"%@@%@/%@", user, host, database]]; - [favorites removeObjectAtIndex:[tableView selectedRow]]; - [tableView reloadData]; + if ( ![tableView numberOfSelectedRows] ) + return; + + NSString *name = [[favorites objectAtIndex:[tableView selectedRow]] objectForKey:@"name"]; + NSString *user = [[favorites objectAtIndex:[tableView selectedRow]] objectForKey:@"user"]; + NSString *host = [[favorites objectAtIndex:[tableView selectedRow]] objectForKey:@"host"]; + NSString *database = [[favorites objectAtIndex:[tableView selectedRow]] objectForKey:@"database"]; + [keyChainInstance deletePasswordForName:[NSString stringWithFormat:@"Sequel Pro : %@", name] + account:[NSString stringWithFormat:@"%@@%@/%@", user, host, database]]; + [keyChainInstance deletePasswordForName:[NSString stringWithFormat:@"Sequel Pro SSHTunnel : %@", name] + account:[NSString stringWithFormat:@"%@@%@/%@", user, host, database]]; + [favorites removeObjectAtIndex:[tableView selectedRow]]; + [tableView reloadData]; } - (IBAction)copyFavorite:(id)sender @@ -208,17 +208,17 @@ removes a favorite copies a favorite */ { - if ( ![tableView numberOfSelectedRows] ) - return; - - NSMutableDictionary *tempDictionary = [NSMutableDictionary dictionaryWithDictionary:[favorites objectAtIndex:[tableView selectedRow]]]; - [tempDictionary setObject:[NSString stringWithFormat:@"%@Copy", [tempDictionary objectForKey:@"name"]] forKey:@"name"]; -// [tempDictionary setObject:[NSString stringWithFormat:@"%@Copy", [tempDictionary objectForKey:@"user"]] forKey:@"user"]; + if ( ![tableView numberOfSelectedRows] ) + return; + + NSMutableDictionary *tempDictionary = [NSMutableDictionary dictionaryWithDictionary:[favorites objectAtIndex:[tableView selectedRow]]]; + [tempDictionary setObject:[NSString stringWithFormat:@"%@Copy", [tempDictionary objectForKey:@"name"]] forKey:@"name"]; +// [tempDictionary setObject:[NSString stringWithFormat:@"%@Copy", [tempDictionary objectForKey:@"user"]] forKey:@"user"]; - [favorites insertObject:tempDictionary atIndex:[tableView selectedRow]+1]; - [tableView selectRow:[tableView selectedRow]+1 byExtendingSelection:NO]; + [favorites insertObject:tempDictionary atIndex:[tableView selectedRow]+1]; + [tableView selectRow:[tableView selectedRow]+1 byExtendingSelection:NO]; - [tableView reloadData]; + [tableView reloadData]; } - (IBAction)chooseLimitRows:(id)sender @@ -226,12 +226,12 @@ copies a favorite enables or disables limitRowsField (depending on the state of limitRowsSwitch) */ { - if ( [limitRowsSwitch state] == NSOnState ) { - [limitRowsField setEnabled:YES]; - [limitRowsField selectText:self]; - } else { - [limitRowsField setEnabled:NO]; - } + if ( [limitRowsSwitch state] == NSOnState ) { + [limitRowsField setEnabled:YES]; + [limitRowsField selectText:self]; + } else { + [limitRowsField setEnabled:NO]; + } } - (IBAction)closeFavoriteSheet:(id)sender @@ -239,44 +239,44 @@ enables or disables limitRowsField (depending on the state of limitRowsSwitch) close the favoriteSheet and save favorite if user hit save */ { - NSEnumerator *enumerator = [favorites objectEnumerator]; - id favorite; - int count; + NSEnumerator *enumerator = [favorites objectEnumerator]; + id favorite; + int count; //test if user has entered at least name and host/socket - if ( [sender tag] && - ([[nameField stringValue] isEqualToString:@""] || - ([[hostField stringValue] isEqualToString:@""] && [[socketField stringValue] isEqualToString:@""])) ) { - NSRunAlertPanel(NSLocalizedString(@"Error", @"error"), NSLocalizedString(@"Please enter at least name and host or socket!", @"message of panel when name/host/socket are missing"), NSLocalizedString(@"OK", @"OK button"), nil, nil); - return; - } - + if ( [sender tag] && + ([[nameField stringValue] isEqualToString:@""] || + ([[hostField stringValue] isEqualToString:@""] && [[socketField stringValue] isEqualToString:@""])) ) { + NSRunAlertPanel(NSLocalizedString(@"Error", @"error"), NSLocalizedString(@"Please enter at least name and host or socket!", @"message of panel when name/host/socket are missing"), NSLocalizedString(@"OK", @"OK button"), nil, nil); + return; + } + //test if favorite name isn't used by another favorite - count = 0; - if ( [sender tag] ) { - while ( (favorite = [enumerator nextObject]) ) { - if ( [[favorite objectForKey:@"name"] isEqualToString:[nameField stringValue]] ) - { - if ( isNewFavorite || (!isNewFavorite && (count != [tableView selectedRow])) ) { - NSRunAlertPanel(NSLocalizedString(@"Error", @"error"), [NSString stringWithFormat:NSLocalizedString(@"Favorite %@ has already been saved!\nPlease specify another name.", @"message of panel when favorite name has already been used"), [nameField stringValue]], NSLocalizedString(@"OK", @"OK button"), nil, nil); - return; - } - } + count = 0; + if ( [sender tag] ) { + while ( (favorite = [enumerator nextObject]) ) { + if ( [[favorite objectForKey:@"name"] isEqualToString:[nameField stringValue]] ) + { + if ( isNewFavorite || (!isNewFavorite && (count != [tableView selectedRow])) ) { + NSRunAlertPanel(NSLocalizedString(@"Error", @"error"), [NSString stringWithFormat:NSLocalizedString(@"Favorite %@ has already been saved!\nPlease specify another name.", @"message of panel when favorite name has already been used"), [nameField stringValue]], NSLocalizedString(@"OK", @"OK button"), nil, nil); + return; + } + } /* - if ( [[favorite objectForKey:@"host"] isEqualToString:[hostField stringValue]] && - [[favorite objectForKey:@"user"] isEqualToString:[userField stringValue]] && - [[favorite objectForKey:@"database"] isEqualToString:[databaseField stringValue]] ) { - if ( isNewFavorite || (!isNewFavorite && (count != [tableView selectedRow])) ) { - NSRunAlertPanel(@"Error", @"There is already a favorite with the same host, user and database!", @"OK", nil, nil); - return; - } - } + if ( [[favorite objectForKey:@"host"] isEqualToString:[hostField stringValue]] && + [[favorite objectForKey:@"user"] isEqualToString:[userField stringValue]] && + [[favorite objectForKey:@"database"] isEqualToString:[databaseField stringValue]] ) { + if ( isNewFavorite || (!isNewFavorite && (count != [tableView selectedRow])) ) { + NSRunAlertPanel(@"Error", @"There is already a favorite with the same host, user and database!", @"OK", nil, nil); + return; + } + } */ - count++; - } - } + count++; + } + } - [NSApp stopModalWithCode:[sender tag]]; + [NSApp stopModalWithCode:[sender tag]]; } - (IBAction)toggleUseSSH:(id)sender @@ -284,7 +284,7 @@ close the favoriteSheet and save favorite if user hit save enables/disables ssh tunneling */ { - if ( [sshCheckbox state] == NSOnState ) { + if ( [sshCheckbox state] == NSOnState ) { [sshUserField setEnabled:YES]; [sshPasswordField setEnabled:YES]; [sshHostField setEnabled:YES]; @@ -303,27 +303,27 @@ enables/disables ssh tunneling passes the query to the last created document */ { - NSString *pboardString; - NSArray *types; + NSString *pboardString; + NSArray *types; - types = [pboard types]; + types = [pboard types]; - if (![types containsObject:NSStringPboardType] || !(pboardString = [pboard stringForType:NSStringPboardType])) { - *error = @"Pasteboard couldn't give string."; - return; - } + if (![types containsObject:NSStringPboardType] || !(pboardString = [pboard stringForType:NSStringPboardType])) { + *error = @"Pasteboard couldn't give string."; + return; + } //check if there exists a document - if ( ![[[NSDocumentController sharedDocumentController] documents] count] ) { - *error = @"No Documents open!"; - return; - } + if ( ![[[NSDocumentController sharedDocumentController] documents] count] ) { + *error = @"No Documents open!"; + return; + } //pass query to last created document -// [[[NSDocumentController sharedDocumentController] currentDocument] doPerformQueryService:pboardString]; - [[[[NSDocumentController sharedDocumentController] documents] objectAtIndex:[[[NSDocumentController sharedDocumentController] documents] count]-1] doPerformQueryService:pboardString]; +// [[[NSDocumentController sharedDocumentController] currentDocument] doPerformQueryService:pboardString]; + [[[[NSDocumentController sharedDocumentController] documents] objectAtIndex:[[[NSDocumentController sharedDocumentController] documents] count]-1] doPerformQueryService:pboardString]; - return; + return; } @@ -333,7 +333,7 @@ passes the query to the last created document opens donate link in default browser */ { - [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"http://code.google.com/p/sequel-pro/wiki/Donations"]]; + [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"http://code.google.com/p/sequel-pro/wiki/Donations"]]; } //menu methods @@ -342,7 +342,7 @@ opens donate link in default browser opens donate link in default browser */ { - [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"http://code.google.com/p/sequel-pro"]]; + [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"http://code.google.com/p/sequel-pro"]]; } - (IBAction)visitHelpWebsite:(id)sender @@ -350,7 +350,7 @@ opens donate link in default browser opens donate link in default browser */ { - [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"http://code.google.com/p/sequel-pro/wiki/FAQ"]]; + [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"http://code.google.com/p/sequel-pro/wiki/FAQ"]]; } - (IBAction)checkForUpdates:(id)sender @@ -359,58 +359,58 @@ checks for updates and opens download page in default browser */ { NSLog(@"[MainController checkForUpdates:] is not currently functional."); -// CMMCPConnection *tempConnection = [[CMMCPConnection alloc] initToHost:@"com.google.code.sequel-pro" -// withLogin:@"sequel-pro" -// password:@"" -// usingPort:nil]; -// CMMCPResult *tempResult; -// NSString *version; -// int code; +// CMMCPConnection *tempConnection = [[CMMCPConnection alloc] initToHost:@"com.google.code.sequel-pro" +// withLogin:@"sequel-pro" +// password:@"" +// usingPort:nil]; +// CMMCPResult *tempResult; +// NSString *version; +// int code; // // //connect to db -// if ( ![tempConnection isConnected] ) { -// //no connection -// NSRunAlertPanel(NSLocalizedString(@"Error", @"error"), NSLocalizedString(@"Error while trying to get the current version number!\nBe sure that you are connected to the internet and try again later.", @"message of panel when check for current version number failed"), NSLocalizedString(@"OK", @"OK button"), nil, nil); -// return; -// } -// if ( ![tempConnection selectDB:@"usr_web8_1"] ) { -// //db not found -// NSRunAlertPanel(NSLocalizedString(@"Error", @"error"), NSLocalizedString(@"Error while trying to get the current version number!\nBe sure that you are connected to the internet and try again later.", @"message of panel when check for current version number failed"), NSLocalizedString(@"OK", @"OK button"), nil, nil); -// return; -// } +// if ( ![tempConnection isConnected] ) { +// //no connection +// NSRunAlertPanel(NSLocalizedString(@"Error", @"error"), NSLocalizedString(@"Error while trying to get the current version number!\nBe sure that you are connected to the internet and try again later.", @"message of panel when check for current version number failed"), NSLocalizedString(@"OK", @"OK button"), nil, nil); +// return; +// } +// if ( ![tempConnection selectDB:@"usr_web8_1"] ) { +// //db not found +// NSRunAlertPanel(NSLocalizedString(@"Error", @"error"), NSLocalizedString(@"Error while trying to get the current version number!\nBe sure that you are connected to the internet and try again later.", @"message of panel when check for current version number failed"), NSLocalizedString(@"OK", @"OK button"), nil, nil); +// return; +// } // //get current version -// tempResult = [tempConnection queryString:@"SELECT * FROM sequel-pro"]; -// if ( ![tempResult numOfRows] ) { -// //error in query -// NSRunAlertPanel(NSLocalizedString(@"Error", @"error"), NSLocalizedString(@"Error while trying to get the current version number!\nBe sure that you are connected to the internet and try again later.", @"message of panel when check for current version number failed"), NSLocalizedString(@"OK", @"OK button"), nil, nil); -// return; -// } -// version = [[tempResult fetchRowAsArray] objectAtIndex:0]; +// tempResult = [tempConnection queryString:@"SELECT * FROM sequel-pro"]; +// if ( ![tempResult numOfRows] ) { +// //error in query +// NSRunAlertPanel(NSLocalizedString(@"Error", @"error"), NSLocalizedString(@"Error while trying to get the current version number!\nBe sure that you are connected to the internet and try again later.", @"message of panel when check for current version number failed"), NSLocalizedString(@"OK", @"OK button"), nil, nil); +// return; +// } +// version = [[tempResult fetchRowAsArray] objectAtIndex:0]; // //check versions -// if ( [version isEqualToString:[[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleVersion"]] ) { -// //no new version -// NSRunInformationalAlertPanel(NSLocalizedString(@"No update available", @"title of panel when no update is available"), NSLocalizedString(@"There is no newer version available!", @"message of panel when no update is available"), NSLocalizedString(@"OK", @"OK button"), nil, nil); -// } else { -// //new version available -// code = NSRunInformationalAlertPanel(NSLocalizedString(@"Update available", @"title of panel when update is available"), [NSString stringWithFormat:NSLocalizedString(@"There is a newer version available (version %@)!\nClick OK to open the download site.", @"message of panel when update is available"), version], NSLocalizedString(@"OK", @"OK button"), NSLocalizedString(@"Cancel", @"cancel button"), nil); -// if ( code == NSAlertDefaultReturn ) { -// [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"http://code.google.com/p/sequel-pro/download.php"]]; -// } -// } -// [tempConnection disconnect]; -// [tempConnection release]; +// if ( [version isEqualToString:[[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleVersion"]] ) { +// //no new version +// NSRunInformationalAlertPanel(NSLocalizedString(@"No update available", @"title of panel when no update is available"), NSLocalizedString(@"There is no newer version available!", @"message of panel when no update is available"), NSLocalizedString(@"OK", @"OK button"), nil, nil); +// } else { +// //new version available +// code = NSRunInformationalAlertPanel(NSLocalizedString(@"Update available", @"title of panel when update is available"), [NSString stringWithFormat:NSLocalizedString(@"There is a newer version available (version %@)!\nClick OK to open the download site.", @"message of panel when update is available"), version], NSLocalizedString(@"OK", @"OK button"), NSLocalizedString(@"Cancel", @"cancel button"), nil); +// if ( code == NSAlertDefaultReturn ) { +// [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"http://code.google.com/p/sequel-pro/download.php"]]; +// } +// } +// [tempConnection disconnect]; +// [tempConnection release]; } //tableView datasource methods - (int)numberOfRowsInTableView:(NSTableView *)aTableView { - return [favorites count]; + return [favorites count]; } - (id)tableView:(NSTableView *)aTableView - objectValueForTableColumn:(NSTableColumn *)aTableColumn - row:(int)rowIndex + objectValueForTableColumn:(NSTableColumn *)aTableColumn + row:(int)rowIndex { return [[favorites objectAtIndex:rowIndex] objectForKey:[aTableColumn identifier]]; } @@ -419,64 +419,64 @@ checks for updates and opens download page in default browser //tableView drag&drop datasource methods - (BOOL)tableView:(NSTableView *)tv writeRows:(NSArray*)rows toPasteboard:(NSPasteboard*)pboard { - int originalRow; - NSArray *pboardTypes; + int originalRow; + NSArray *pboardTypes; - if ( [rows count] == 1 ) { - pboardTypes=[NSArray arrayWithObjects:@"SequelProPreferencesPasteboard", nil]; - originalRow = [[rows objectAtIndex:0] intValue]; + if ( [rows count] == 1 ) { + pboardTypes=[NSArray arrayWithObjects:@"SequelProPreferencesPasteboard", nil]; + originalRow = [[rows objectAtIndex:0] intValue]; [pboard declareTypes:pboardTypes owner:nil]; [pboard setString:[[NSNumber numberWithInt:originalRow] stringValue] forType:@"SequelProPreferencesPasteboard"]; - return YES; - } else { - return NO; - } + return YES; + } else { + return NO; + } } - (NSDragOperation)tableView:(NSTableView*)tv validateDrop:(id <NSDraggingInfo>)info proposedRow:(int)row - proposedDropOperation:(NSTableViewDropOperation)operation + proposedDropOperation:(NSTableViewDropOperation)operation { - NSArray *pboardTypes = [[info draggingPasteboard] types]; - int originalRow; - - if ([pboardTypes count] == 1 && row != -1) - { - if ([[pboardTypes objectAtIndex:0] isEqualToString:@"SequelProPreferencesPasteboard"]==YES && operation==NSTableViewDropAbove) - { - originalRow = [[[info draggingPasteboard] stringForType:@"SequelProPreferencesPasteboard"] intValue]; - - if (row != originalRow && row != (originalRow+1)) - { - return NSDragOperationMove; - } - } - } - - return NSDragOperationNone; + NSArray *pboardTypes = [[info draggingPasteboard] types]; + int originalRow; + + if ([pboardTypes count] == 1 && row != -1) + { + if ([[pboardTypes objectAtIndex:0] isEqualToString:@"SequelProPreferencesPasteboard"]==YES && operation==NSTableViewDropAbove) + { + originalRow = [[[info draggingPasteboard] stringForType:@"SequelProPreferencesPasteboard"] intValue]; + + if (row != originalRow && row != (originalRow+1)) + { + return NSDragOperationMove; + } + } + } + + return NSDragOperationNone; } - (BOOL)tableView:(NSTableView*)tv acceptDrop:(id <NSDraggingInfo>)info row:(int)row dropOperation:(NSTableViewDropOperation)operation { - int originalRow; - int destinationRow; - NSMutableDictionary *draggedRow; + int originalRow; + int destinationRow; + NSMutableDictionary *draggedRow; - originalRow = [[[info draggingPasteboard] stringForType:@"SequelProPreferencesPasteboard"] intValue]; - destinationRow = row; + originalRow = [[[info draggingPasteboard] stringForType:@"SequelProPreferencesPasteboard"] intValue]; + destinationRow = row; - if ( destinationRow > originalRow ) - destinationRow--; + if ( destinationRow > originalRow ) + destinationRow--; - draggedRow = [NSMutableDictionary dictionaryWithDictionary:[favorites objectAtIndex:originalRow]]; - [favorites removeObjectAtIndex:originalRow]; - [favorites insertObject:draggedRow atIndex:destinationRow]; - - [tableView reloadData]; - [tableView selectRow:destinationRow byExtendingSelection:NO]; + draggedRow = [NSMutableDictionary dictionaryWithDictionary:[favorites objectAtIndex:originalRow]]; + [favorites removeObjectAtIndex:originalRow]; + [favorites insertObject:draggedRow atIndex:destinationRow]; + + [tableView reloadData]; + [tableView selectRow:destinationRow byExtendingSelection:NO]; - return YES; + return YES; } - (BOOL)tableView:(NSTableView *)aTableView shouldEditTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex @@ -484,20 +484,20 @@ checks for updates and opens download page in default browser opens sheet to edit favorite and saves favorite if user hit OK */ { - int code; - NSDictionary *favorite = [favorites objectAtIndex:rowIndex]; + int code; + NSDictionary *favorite = [favorites objectAtIndex:rowIndex]; // set up fields - [nameField setStringValue:[favorite objectForKey:@"name"]]; - [hostField setStringValue:[favorite objectForKey:@"host"]]; - [socketField setStringValue:[favorite objectForKey:@"socket"]]; - [userField setStringValue:[favorite objectForKey:@"user"]]; - [portField setStringValue:[favorite objectForKey:@"port"]]; - [databaseField setStringValue:[favorite objectForKey:@"database"]]; - [passwordField setStringValue:[keyChainInstance - getPasswordForName:[NSString stringWithFormat:@"Sequel Pro : %@", [nameField stringValue]] - account:[NSString stringWithFormat:@"%@@%@/%@", [userField stringValue], [hostField stringValue], - [databaseField stringValue]]]]; + [nameField setStringValue:[favorite objectForKey:@"name"]]; + [hostField setStringValue:[favorite objectForKey:@"host"]]; + [socketField setStringValue:[favorite objectForKey:@"socket"]]; + [userField setStringValue:[favorite objectForKey:@"user"]]; + [portField setStringValue:[favorite objectForKey:@"port"]]; + [databaseField setStringValue:[favorite objectForKey:@"database"]]; + [passwordField setStringValue:[keyChainInstance + getPasswordForName:[NSString stringWithFormat:@"Sequel Pro : %@", [nameField stringValue]] + account:[NSString stringWithFormat:@"%@@%@/%@", [userField stringValue], [hostField stringValue], + [databaseField stringValue]]]]; // set up ssh fields if ( [[favorite objectForKey:@"useSSH"] intValue] == 1 ) { [sshCheckbox setState:NSOnState]; @@ -526,19 +526,19 @@ opens sheet to edit favorite and saves favorite if user hit OK // run sheet - [NSApp beginSheet:favoriteSheet - modalForWindow:preferencesWindow modalDelegate:self - didEndSelector:nil contextInfo:nil]; - code = [NSApp runModalForWindow:favoriteSheet]; - - [NSApp endSheet:favoriteSheet]; - [favoriteSheet orderOut:nil]; - - if ( code == 1 ) { - if ( ![[socketField stringValue] isEqualToString:@""] ) { - //set host to localhost if socket is used - [hostField setStringValue:@"localhost"]; - } + [NSApp beginSheet:favoriteSheet + modalForWindow:preferencesWindow modalDelegate:self + didEndSelector:nil contextInfo:nil]; + code = [NSApp runModalForWindow:favoriteSheet]; + + [NSApp endSheet:favoriteSheet]; + [favoriteSheet orderOut:nil]; + + if ( code == 1 ) { + if ( ![[socketField stringValue] isEqualToString:@""] ) { + //set host to localhost if socket is used + [hostField setStringValue:@"localhost"]; + } //get ssh settings NSString *sshHost, *sshUser, *sshPassword, *sshPort; NSNumber *ssh; @@ -572,14 +572,14 @@ opens sheet to edit favorite and saves favorite if user hit OK ssh = [NSNumber numberWithInt:0]; } //replace password - [keyChainInstance deletePasswordForName:[NSString stringWithFormat:@"Sequel Pro : %@", [favorite objectForKey:@"name"]] - account:[NSString stringWithFormat:@"%@@%@/%@", [favorite objectForKey:@"user"], - [favorite objectForKey:@"host"], [favorite objectForKey:@"database"]]]; - if ( ![[passwordField stringValue] isEqualToString:@""] ) - [keyChainInstance addPassword:[passwordField stringValue] - forName:[NSString stringWithFormat:@"Sequel Pro : %@", [nameField stringValue]] - account:[NSString stringWithFormat:@"%@@%@/%@", [userField stringValue], [hostField stringValue], - [databaseField stringValue]]]; + [keyChainInstance deletePasswordForName:[NSString stringWithFormat:@"Sequel Pro : %@", [favorite objectForKey:@"name"]] + account:[NSString stringWithFormat:@"%@@%@/%@", [favorite objectForKey:@"user"], + [favorite objectForKey:@"host"], [favorite objectForKey:@"database"]]]; + if ( ![[passwordField stringValue] isEqualToString:@""] ) + [keyChainInstance addPassword:[passwordField stringValue] + forName:[NSString stringWithFormat:@"Sequel Pro : %@", [nameField stringValue]] + account:[NSString stringWithFormat:@"%@@%@/%@", [userField stringValue], [hostField stringValue], + [databaseField stringValue]]]; //replace ssh password [keyChainInstance deletePasswordForName:[NSString stringWithFormat:@"Sequel Pro SSHTunnel : %@", [favorite objectForKey:@"name"]] account:[NSString stringWithFormat:@"%@@%@/%@", [favorite objectForKey:@"user"], @@ -591,14 +591,14 @@ opens sheet to edit favorite and saves favorite if user hit OK [databaseField stringValue]]]; } //replace favorite - favorite = [NSDictionary - dictionaryWithObjects:[NSArray arrayWithObjects:[nameField stringValue], [hostField stringValue], [socketField stringValue], [userField stringValue], [portField stringValue], [databaseField stringValue], ssh, sshHost, sshUser, sshPort, nil] - forKeys:[NSArray arrayWithObjects:@"name", @"host", @"socket", @"user", @"port", @"database", @"useSSH", @"sshHost", @"sshUser", @"sshPort", nil]]; - [favorites replaceObjectAtIndex:rowIndex withObject:favorite]; - [tableView reloadData]; - } - - return NO; + favorite = [NSDictionary + dictionaryWithObjects:[NSArray arrayWithObjects:[nameField stringValue], [hostField stringValue], [socketField stringValue], [userField stringValue], [portField stringValue], [databaseField stringValue], ssh, sshHost, sshUser, sshPort, nil] + forKeys:[NSArray arrayWithObjects:@"name", @"host", @"socket", @"user", @"port", @"database", @"useSSH", @"sshHost", @"sshUser", @"sshPort", nil]]; + [favorites replaceObjectAtIndex:rowIndex withObject:favorite]; + [tableView reloadData]; + } + + return NO; } @@ -608,58 +608,58 @@ opens sheet to edit favorite and saves favorite if user hit OK saves the preferences */ { - if ( sender == preferencesWindow ) { - if ( [reloadAfterAddingSwitch state] == NSOnState ) { - [prefs setBool:YES forKey:@"reloadAfterAdding"]; - } else { - [prefs setBool:NO forKey:@"reloadAfterAdding"]; - } - if ( [reloadAfterEditingSwitch state] == NSOnState ) { - [prefs setBool:YES forKey:@"reloadAfterEditing"]; - } else { - [prefs setBool:NO forKey:@"reloadAfterEditing"]; - } - if ( [reloadAfterRemovingSwitch state] == NSOnState ) { - [prefs setBool:YES forKey:@"reloadAfterRemoving"]; - } else { - [prefs setBool:NO forKey:@"reloadAfterRemoving"]; - } - if ( [showErrorSwitch state] == NSOnState ) { - [prefs setBool:YES forKey:@"showError"]; - } else { - [prefs setBool:NO forKey:@"showError"]; - } - if ( [dontShowBlobSwitch state] == NSOnState ) { - [prefs setBool:YES forKey:@"dontShowBlob"]; - } else { - [prefs setBool:NO forKey:@"dontShowBlob"]; - } - if ( [limitRowsSwitch state] == NSOnState ) { - [prefs setBool:YES forKey:@"limitRows"]; - } else { - [prefs setBool:NO forKey:@"limitRows"]; - } - if ( [useMonospacedFontsSwitch state] == NSOnState ) { - [prefs setBool:YES forKey:@"useMonospacedFonts"]; - } else { - [prefs setBool:NO forKey:@"useMonospacedFonts"]; - } - if ( [fetchRowCountSwitch state] == NSOnState ) { - [prefs setBool:YES forKey:@"fetchRowCount"]; - } else { - [prefs setBool:NO forKey:@"fetchRowCount"]; - } - [prefs setObject:[nullValueField stringValue] forKey:@"nullValue"]; - if ( [limitRowsField intValue] > 0 ) { - [prefs setInteger:[limitRowsField intValue] forKey:@"limitRowsValue"]; - } else { - [prefs setInteger:1 forKey:@"limitRowsValue"]; - } - [prefs setObject:[encodingPopUpButton titleOfSelectedItem] forKey:@"encoding"]; - - [prefs setObject:favorites forKey:@"favorites"]; - } - return YES; + if ( sender == preferencesWindow ) { + if ( [reloadAfterAddingSwitch state] == NSOnState ) { + [prefs setBool:YES forKey:@"reloadAfterAdding"]; + } else { + [prefs setBool:NO forKey:@"reloadAfterAdding"]; + } + if ( [reloadAfterEditingSwitch state] == NSOnState ) { + [prefs setBool:YES forKey:@"reloadAfterEditing"]; + } else { + [prefs setBool:NO forKey:@"reloadAfterEditing"]; + } + if ( [reloadAfterRemovingSwitch state] == NSOnState ) { + [prefs setBool:YES forKey:@"reloadAfterRemoving"]; + } else { + [prefs setBool:NO forKey:@"reloadAfterRemoving"]; + } + if ( [showErrorSwitch state] == NSOnState ) { + [prefs setBool:YES forKey:@"showError"]; + } else { + [prefs setBool:NO forKey:@"showError"]; + } + if ( [dontShowBlobSwitch state] == NSOnState ) { + [prefs setBool:YES forKey:@"dontShowBlob"]; + } else { + [prefs setBool:NO forKey:@"dontShowBlob"]; + } + if ( [limitRowsSwitch state] == NSOnState ) { + [prefs setBool:YES forKey:@"limitRows"]; + } else { + [prefs setBool:NO forKey:@"limitRows"]; + } + if ( [useMonospacedFontsSwitch state] == NSOnState ) { + [prefs setBool:YES forKey:@"useMonospacedFonts"]; + } else { + [prefs setBool:NO forKey:@"useMonospacedFonts"]; + } + if ( [fetchRowCountSwitch state] == NSOnState ) { + [prefs setBool:YES forKey:@"fetchRowCount"]; + } else { + [prefs setBool:NO forKey:@"fetchRowCount"]; + } + [prefs setObject:[nullValueField stringValue] forKey:@"nullValue"]; + if ( [limitRowsField intValue] > 0 ) { + [prefs setInteger:[limitRowsField intValue] forKey:@"limitRowsValue"]; + } else { + [prefs setInteger:1 forKey:@"limitRowsValue"]; + } + [prefs setObject:[encodingPopUpButton titleOfSelectedItem] forKey:@"encoding"]; + + [prefs setObject:favorites forKey:@"favorites"]; + } + return YES; } @@ -669,13 +669,13 @@ saves the preferences code that need to be executed when the nib file is loaded */ { - NSEnumerator *enumerator; - id favorite; - NSString *name, *host, *user, *database, *password; + NSEnumerator *enumerator; + id favorite; + NSString *name, *host, *user, *database, *password; // int code; //register MainController as services provider - [NSApp setServicesProvider:self]; + [NSApp setServicesProvider:self]; //register MainController for AppleScript events [[ NSScriptExecutionContext sharedScriptExecutionContext] setTopLevelObject: self ]; @@ -685,145 +685,145 @@ code that need to be executed when the nib file is loaded prefs = [[NSUserDefaults standardUserDefaults] retain]; isNewFavorite = NO; [prefs registerDefaults:[NSDictionary dictionaryWithObjectsAndKeys: - [NSNumber numberWithBool:YES], @"limitRows", - [NSNumber numberWithInt:1000], @"limitRowsValue", - nil]]; + [NSNumber numberWithBool:YES], @"limitRows", + [NSNumber numberWithInt:1000], @"limitRowsValue", + nil]]; //set standard preferences if no preferences are found - if ( [prefs objectForKey:@"reloadAfterAdding"] == nil ) - { - [prefs setObject:@"0.3" forKey:@"version"]; - [prefs setBool:YES forKey:@"reloadAfterAdding"]; - [prefs setBool:YES forKey:@"reloadAfterEditing"]; - [prefs setBool:NO forKey:@"reloadAfterRemoving"]; - [prefs setObject:@"NULL" forKey:@"nullValue"]; -// [prefs setBool:YES forKey:@"showError"]; -// [prefs setBool:NO forKey:@"dontShowBlob"]; -// [prefs setBool:NO forKey:@"limitRows"]; -// [prefs setInteger:100 forKey:@"limitRowsValue"]; -// [prefs setObject:[NSString stringWithString:NSHomeDirectory()] forKey:@"savePath"]; -// [prefs setObject:[NSString stringWithString:NSHomeDirectory()] forKey:@"openPath"]; - } + if ( [prefs objectForKey:@"reloadAfterAdding"] == nil ) + { + [prefs setObject:@"0.3" forKey:@"version"]; + [prefs setBool:YES forKey:@"reloadAfterAdding"]; + [prefs setBool:YES forKey:@"reloadAfterEditing"]; + [prefs setBool:NO forKey:@"reloadAfterRemoving"]; + [prefs setObject:@"NULL" forKey:@"nullValue"]; +// [prefs setBool:YES forKey:@"showError"]; +// [prefs setBool:NO forKey:@"dontShowBlob"]; +// [prefs setBool:NO forKey:@"limitRows"]; +// [prefs setInteger:100 forKey:@"limitRowsValue"]; +// [prefs setObject:[NSString stringWithString:NSHomeDirectory()] forKey:@"savePath"]; +// [prefs setObject:[NSString stringWithString:NSHomeDirectory()] forKey:@"openPath"]; + } //new preferences and changes in v0.4 - if ( [prefs objectForKey:@"showError"] == nil ) - { - [prefs setObject:@"0.4" forKey:@"version"]; - //set standard values for new preferences - [prefs setBool:YES forKey:@"showError"]; - [prefs setBool:NO forKey:@"dontShowBlob"]; -// [prefs setBool:NO forKey:@"limitRows"]; -// [prefs setInteger:100 forKey:@"limitRowsValue"]; - [prefs setObject:[NSString stringWithString:NSHomeDirectory()] forKey:@"savePath"]; - [prefs setObject:[NSString stringWithString:NSHomeDirectory()] forKey:@"openPath"]; - //remove old preferences - [prefs removeObjectForKey:@"allowDragAndDropReordering"]; - //rewrite passwords to keychain (with new format) - if ( [prefs objectForKey:@"favorites"] ) { - NSRunAlertPanel(NSLocalizedString(@"Warning", @"warning"), NSLocalizedString(@"With version 0.4 Sequel Pro has introduced a new format to save passwords in the Keychain.\nPlease allow Sequel Pro to decrypt all passwords of your favorites. Otherwise you have to reenter all passwords of your saved favorites in the Preferences.", @"message of panel when passwords have to be updated for v0.4"), NSLocalizedString(@"OK", @"OK button"), nil, nil); - enumerator = [[prefs objectForKey:@"favorites"] objectEnumerator]; - while ( (favorite = [enumerator nextObject]) ) { - //replace password - name = [favorite objectForKey:@"name"]; - host = [favorite objectForKey:@"host"]; - user = [favorite objectForKey:@"user"]; - database = [favorite objectForKey:@"database"]; - password = [keyChainInstance getPasswordForName:[NSString stringWithFormat:@"%@/%@", host, database] - account:user]; - [keyChainInstance deletePasswordForName:[NSString stringWithFormat:@"%@/%@", host, database] account:user]; - if ( ![password isEqualToString:@""] ) - [keyChainInstance addPassword:password - forName:[NSString stringWithFormat:@"Sequel Pro : %@", name] - account:[NSString stringWithFormat:@"%@@%@/%@", user, host, database]]; - } - } - } + if ( [prefs objectForKey:@"showError"] == nil ) + { + [prefs setObject:@"0.4" forKey:@"version"]; + //set standard values for new preferences + [prefs setBool:YES forKey:@"showError"]; + [prefs setBool:NO forKey:@"dontShowBlob"]; +// [prefs setBool:NO forKey:@"limitRows"]; +// [prefs setInteger:100 forKey:@"limitRowsValue"]; + [prefs setObject:[NSString stringWithString:NSHomeDirectory()] forKey:@"savePath"]; + [prefs setObject:[NSString stringWithString:NSHomeDirectory()] forKey:@"openPath"]; + //remove old preferences + [prefs removeObjectForKey:@"allowDragAndDropReordering"]; + //rewrite passwords to keychain (with new format) + if ( [prefs objectForKey:@"favorites"] ) { + NSRunAlertPanel(NSLocalizedString(@"Warning", @"warning"), NSLocalizedString(@"With version 0.4 Sequel Pro has introduced a new format to save passwords in the Keychain.\nPlease allow Sequel Pro to decrypt all passwords of your favorites. Otherwise you have to reenter all passwords of your saved favorites in the Preferences.", @"message of panel when passwords have to be updated for v0.4"), NSLocalizedString(@"OK", @"OK button"), nil, nil); + enumerator = [[prefs objectForKey:@"favorites"] objectEnumerator]; + while ( (favorite = [enumerator nextObject]) ) { + //replace password + name = [favorite objectForKey:@"name"]; + host = [favorite objectForKey:@"host"]; + user = [favorite objectForKey:@"user"]; + database = [favorite objectForKey:@"database"]; + password = [keyChainInstance getPasswordForName:[NSString stringWithFormat:@"%@/%@", host, database] + account:user]; + [keyChainInstance deletePasswordForName:[NSString stringWithFormat:@"%@/%@", host, database] account:user]; + if ( ![password isEqualToString:@""] ) + [keyChainInstance addPassword:password + forName:[NSString stringWithFormat:@"Sequel Pro : %@", name] + account:[NSString stringWithFormat:@"%@@%@/%@", user, host, database]]; + } + } + } //new preferences and changes in v0.5 - if ( [[prefs objectForKey:@"version"] isEqualToString:@"0.4"] ) - { - [prefs setObject:@"0.5" forKey:@"version"]; - //set standard values for new preferences - [prefs setObject:@"ISO Latin 1" forKey:@"encoding"]; - [prefs setBool:NO forKey:@"useMonospacedFonts"]; - //add socket field to favorites - if ( [prefs objectForKey:@"favorites"] ) { - NSMutableArray *tempFavorites = [NSMutableArray array]; - NSMutableDictionary *tempFavorite; - enumerator = [[prefs objectForKey:@"favorites"] objectEnumerator]; - while ( (favorite = [enumerator nextObject]) ) { - tempFavorite = [NSMutableDictionary dictionaryWithDictionary:favorite]; - [tempFavorite setObject:@"" forKey:@"socket"]; - [tempFavorites addObject:[NSDictionary dictionaryWithDictionary:tempFavorite]]; - } - [prefs setObject:tempFavorites forKey:@"favorites"]; - } - } + if ( [[prefs objectForKey:@"version"] isEqualToString:@"0.4"] ) + { + [prefs setObject:@"0.5" forKey:@"version"]; + //set standard values for new preferences + [prefs setObject:@"ISO Latin 1" forKey:@"encoding"]; + [prefs setBool:NO forKey:@"useMonospacedFonts"]; + //add socket field to favorites + if ( [prefs objectForKey:@"favorites"] ) { + NSMutableArray *tempFavorites = [NSMutableArray array]; + NSMutableDictionary *tempFavorite; + enumerator = [[prefs objectForKey:@"favorites"] objectEnumerator]; + while ( (favorite = [enumerator nextObject]) ) { + tempFavorite = [NSMutableDictionary dictionaryWithDictionary:favorite]; + [tempFavorite setObject:@"" forKey:@"socket"]; + [tempFavorites addObject:[NSDictionary dictionaryWithDictionary:tempFavorite]]; + } + [prefs setObject:tempFavorites forKey:@"favorites"]; + } + } //new preferences and changes in v0.7 - if ( [[prefs objectForKey:@"version"] isEqualToString:@"0.5"] || + if ( [[prefs objectForKey:@"version"] isEqualToString:@"0.5"] || [[prefs objectForKey:@"version"] isEqualToString:@"0.6beta"] || [[prefs objectForKey:@"version"] isEqualToString:@"0.7b2"] ) - { - [prefs setObject:@"0.7b3" forKey:@"version"]; - [prefs setObject:@"Autodetect" forKey:@"encoding"]; - [prefs setBool:YES forKey:@"fetchRowCount"]; + { + [prefs setObject:@"0.7b3" forKey:@"version"]; + [prefs setObject:@"Autodetect" forKey:@"encoding"]; + [prefs setBool:YES forKey:@"fetchRowCount"]; } //set up interface /* - enumerator = [tableColumns objectEnumerator]; - while ( (column = [enumerator nextObject]) ) - { - [[column dataCell] setFont:[NSFont systemFontOfSize:[NSFont smallSystemFontSize]]]; - } + enumerator = [tableColumns objectEnumerator]; + while ( (column = [enumerator nextObject]) ) + { + [[column dataCell] setFont:[NSFont systemFontOfSize:[NSFont smallSystemFontSize]]]; + } */ - [tableView registerForDraggedTypes:[NSArray arrayWithObjects:@"SequelProPreferencesPasteboard", nil]]; - [tableView reloadData]; + [tableView registerForDraggedTypes:[NSArray arrayWithObjects:@"SequelProPreferencesPasteboard", nil]]; + [tableView reloadData]; } // SSHTunnel methods - (id)authenticate:(NSScriptCommand *)command { - NSDictionary *args = [command evaluatedArguments]; - NSString *givenQuery = [ args objectForKey:@"query"]; - NSString *tunnelName = [ args objectForKey:@"tunnelName"]; - NSString *fifo = [ args objectForKey:@"fifo"]; + NSDictionary *args = [command evaluatedArguments]; + NSString *givenQuery = [ args objectForKey:@"query"]; + NSString *tunnelName = [ args objectForKey:@"tunnelName"]; + NSString *fifo = [ args objectForKey:@"fifo"]; NSLog(@"tunnel: %@ / query: %@ / fifo: %@",tunnelName,givenQuery,fifo); - NSFileHandle *fh = [ NSFileHandle fileHandleForWritingAtPath: fifo ]; - [ fh writeData: [ @"xy" dataUsingEncoding: NSASCIIStringEncoding]]; - [ fh closeFile ]; + NSFileHandle *fh = [ NSFileHandle fileHandleForWritingAtPath: fifo ]; + [ fh writeData: [ @"xy" dataUsingEncoding: NSASCIIStringEncoding]]; + [ fh closeFile ]; NSLog(@"password written"); return @"OK"; /* - [ query setStringValue: givenQuery ]; - [NSApp beginSheet: alertSheet - modalForWindow: mainWindow - modalDelegate: nil - didEndSelector: nil - contextInfo: nil]; - [NSApp runModalForWindow: alertSheet]; - // Sheet is up here. - [NSApp endSheet: alertSheet]; - [alertSheet orderOut: self]; - if ( sheetStatus == 0) - { - password = [ passwd stringValue ]; - [ passwd setStringValue: @"" ]; - return password ; - } - else - { - [[tunnelTask objectForKey: @"task" ] terminate ]; - } - sheetStatus = nil; - return @""; + [ query setStringValue: givenQuery ]; + [NSApp beginSheet: alertSheet + modalForWindow: mainWindow + modalDelegate: nil + didEndSelector: nil + contextInfo: nil]; + [NSApp runModalForWindow: alertSheet]; + // Sheet is up here. + [NSApp endSheet: alertSheet]; + [alertSheet orderOut: self]; + if ( sheetStatus == 0) + { + password = [ passwd stringValue ]; + [ passwd setStringValue: @"" ]; + return password ; + } + else + { + [[tunnelTask objectForKey: @"task" ] terminate ]; + } + sheetStatus = nil; + return @""; */ } - (id)handleQuitScriptCommand:(NSScriptCommand *)command /* what exactly is this for? */ { - [ NSApp terminate: self ]; + [ NSApp terminate: self ]; } @end |