aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorabhibeckert <abhi@abhibeckert.com>2008-04-20 01:33:56 +0000
committerabhibeckert <abhi@abhibeckert.com>2008-04-20 01:33:56 +0000
commit385af2eacdcceb9160d787539380d921919f3d99 (patch)
tree03f64eba62f5b6494c052c694e65fc67d434bd53
parent42f0345b621e534dcf87451bff703535eff44017 (diff)
downloadsequelpro-385af2eacdcceb9160d787539380d921919f3d99.tar.gz
sequelpro-385af2eacdcceb9160d787539380d921919f3d99.tar.bz2
sequelpro-385af2eacdcceb9160d787539380d921919f3d99.zip
refactor favorites
-rw-r--r--English.lproj/DBView.nib/classes.nib84
-rw-r--r--English.lproj/DBView.nib/info.nib2
-rw-r--r--English.lproj/DBView.nib/keyedobjects.nibbin168338 -> 168350 bytes
-rw-r--r--English.lproj/MainMenu.nib/info.nib4
-rw-r--r--English.lproj/MainMenu.nib/keyedobjects.nibbin50190 -> 50276 bytes
-rw-r--r--TableDocument.h2
-rw-r--r--TableDocument.m56
7 files changed, 84 insertions, 64 deletions
diff --git a/English.lproj/DBView.nib/classes.nib b/English.lproj/DBView.nib/classes.nib
index 30a1f5c9..7991a45c 100644
--- a/English.lproj/DBView.nib/classes.nib
+++ b/English.lproj/DBView.nib/classes.nib
@@ -76,6 +76,48 @@
<dict>
<key>ACTIONS</key>
<dict>
+ <key>reloadTable</key>
+ <string>id</string>
+ </dict>
+ <key>CLASS</key>
+ <string>TableStatus</string>
+ <key>LANGUAGE</key>
+ <string>ObjC</string>
+ <key>OUTLETS</key>
+ <dict>
+ <key>commentsBox</key>
+ <string>id</string>
+ <key>rowsAutoIncrement</key>
+ <string>id</string>
+ <key>rowsAvgLength</key>
+ <string>id</string>
+ <key>rowsFormat</key>
+ <string>id</string>
+ <key>rowsNumber</key>
+ <string>id</string>
+ <key>sizeData</key>
+ <string>id</string>
+ <key>sizeFree</key>
+ <string>id</string>
+ <key>sizeIndex</key>
+ <string>id</string>
+ <key>sizeMaxData</key>
+ <string>id</string>
+ <key>tableCreatedAt</key>
+ <string>id</string>
+ <key>tableName</key>
+ <string>id</string>
+ <key>tableType</key>
+ <string>id</string>
+ <key>tableUpdatedAt</key>
+ <string>id</string>
+ </dict>
+ <key>SUPERCLASS</key>
+ <string>NSObject</string>
+ </dict>
+ <dict>
+ <key>ACTIONS</key>
+ <dict>
<key>addRow</key>
<string>id</string>
<key>closeEditSheet</key>
@@ -162,48 +204,6 @@
<string>NSObject</string>
</dict>
<dict>
- <key>ACTIONS</key>
- <dict>
- <key>reloadTable</key>
- <string>id</string>
- </dict>
- <key>CLASS</key>
- <string>TableStatus</string>
- <key>LANGUAGE</key>
- <string>ObjC</string>
- <key>OUTLETS</key>
- <dict>
- <key>commentsBox</key>
- <string>id</string>
- <key>rowsAutoIncrement</key>
- <string>id</string>
- <key>rowsAvgLength</key>
- <string>id</string>
- <key>rowsFormat</key>
- <string>id</string>
- <key>rowsNumber</key>
- <string>id</string>
- <key>sizeData</key>
- <string>id</string>
- <key>sizeFree</key>
- <string>id</string>
- <key>sizeIndex</key>
- <string>id</string>
- <key>sizeMaxData</key>
- <string>id</string>
- <key>tableCreatedAt</key>
- <string>id</string>
- <key>tableName</key>
- <string>id</string>
- <key>tableType</key>
- <string>id</string>
- <key>tableUpdatedAt</key>
- <string>id</string>
- </dict>
- <key>SUPERCLASS</key>
- <string>NSObject</string>
- </dict>
- <dict>
<key>CLASS</key>
<string>FirstResponder</string>
<key>LANGUAGE</key>
diff --git a/English.lproj/DBView.nib/info.nib b/English.lproj/DBView.nib/info.nib
index 8f6ec530..b1d2945b 100644
--- a/English.lproj/DBView.nib/info.nib
+++ b/English.lproj/DBView.nib/info.nib
@@ -10,7 +10,7 @@
<integer>5</integer>
<key>IBOpenObjects</key>
<array>
- <integer>40</integer>
+ <integer>2268</integer>
</array>
<key>IBSystem Version</key>
<string>9C7010</string>
diff --git a/English.lproj/DBView.nib/keyedobjects.nib b/English.lproj/DBView.nib/keyedobjects.nib
index 54867ab1..88cb1cf1 100644
--- a/English.lproj/DBView.nib/keyedobjects.nib
+++ b/English.lproj/DBView.nib/keyedobjects.nib
Binary files differ
diff --git a/English.lproj/MainMenu.nib/info.nib b/English.lproj/MainMenu.nib/info.nib
index 286ec235..928e8da9 100644
--- a/English.lproj/MainMenu.nib/info.nib
+++ b/English.lproj/MainMenu.nib/info.nib
@@ -9,9 +9,7 @@
<key>IBOldestOS</key>
<integer>5</integer>
<key>IBOpenObjects</key>
- <array>
- <integer>370</integer>
- </array>
+ <array/>
<key>IBSystem Version</key>
<string>9C7010</string>
<key>targetFramework</key>
diff --git a/English.lproj/MainMenu.nib/keyedobjects.nib b/English.lproj/MainMenu.nib/keyedobjects.nib
index bd498204..c896d03b 100644
--- a/English.lproj/MainMenu.nib/keyedobjects.nib
+++ b/English.lproj/MainMenu.nib/keyedobjects.nib
Binary files differ
diff --git a/TableDocument.h b/TableDocument.h
index a532706c..64081d92 100644
--- a/TableDocument.h
+++ b/TableDocument.h
@@ -82,6 +82,8 @@
- (IBAction)connect:(id)sender;
- (IBAction)closeSheet:(id)sender;
- (IBAction)chooseFavorite:(id)sender;
+- (id)selectedFavorite;
+- (NSString *)selectedFavoritePassword;
- (void)setFavorites;
- (void)addToFavoritesHost:(NSString *)host socket:(NSString *)socket
user:(NSString *)user password:(NSString *)password
diff --git a/TableDocument.m b/TableDocument.m
index 686bf8a0..9623bdb2 100644
--- a/TableDocument.m
+++ b/TableDocument.m
@@ -198,25 +198,15 @@ reused when user hits the close button of the variablseSheet or of the createTab
*/
- (IBAction)chooseFavorite:(id)sender
{
- if ([[prefs objectForKey:@"favorites"] count] == 0)
- return;
+ if (![self selectedFavorite])
+ return;
- NSDictionary *favorite = [[prefs objectForKey:@"favorites"] objectAtIndex:[favoritesController selectionIndex]];
- NSString *name = [favorite objectForKey:@"name"];
- NSString *host = [favorite objectForKey:@"host"];
- NSString *socket = [favorite objectForKey:@"socket"];
- NSString *user = [favorite objectForKey:@"user"];
- NSString *port = [favorite objectForKey:@"port"];
- NSString *database = [favorite objectForKey:@"database"];
-
- [hostField setStringValue:host];
- [socketField setStringValue:socket];
- [userField setStringValue:user];
- [portField setStringValue:port];
- [databaseField setStringValue:database];
- [passwordField setStringValue:[keyChainInstance
- getPasswordForName:[NSString stringWithFormat:@"Sequel Pro : %@", name]
- account:[NSString stringWithFormat:@"%@@%@/%@", user, host, database]]];
+ [hostField setStringValue:[self valueForKeyPath:@"selectedFavorite.host"]];
+ [socketField setStringValue:[self valueForKeyPath:@"selectedFavorite.socket"]];
+ [userField setStringValue:[self valueForKeyPath:@"selectedFavorite.user"]];
+ [portField setStringValue:[self valueForKeyPath:@"selectedFavorite.port"]];
+ [databaseField setStringValue:[self valueForKeyPath:@"selectedFavorite.database"]];
+ [passwordField setStringValue:[self selectedFavoritePassword]];
[selectedFavorite release];
selectedFavorite = [[favoritesButton titleOfSelectedItem] retain];
@@ -237,6 +227,36 @@ reused when user hits the close button of the variablseSheet or of the createTab
}
/**
+ * returns a KVC-compliant proxy to the currently selected favorite, or nil if nothing selected.
+ *
+ * see [NSObjectController selection]
+ */
+- (id)selectedFavorite
+{
+ if ([favoritesController selectionIndex] == NSNotFound)
+ return nil;
+
+ return [favoritesController selection];
+}
+
+/**
+ * fetches the password [self selectedFavorite] from the keychain, returns nil if no selection.
+ */
+- (NSString *)selectedFavoritePassword
+{
+ if (![self selectedFavorite])
+ return nil;
+
+ NSString *keychainName = [NSString stringWithFormat:@"Sequel Pro : %@", [self valueForKeyPath:@"selectedFavorite.name"]];
+ NSString *keychainAccount = [NSString stringWithFormat:@"%@@%@/%@",
+ [self valueForKeyPath:@"selectedFavorite.user"],
+ [self valueForKeyPath:@"selectedFavorite.host"],
+ [self valueForKeyPath:@"selectedFavorite.database"]];
+
+ return [keyChainInstance getPasswordForName:keychainName account:keychainAccount];
+}
+
+/**
* add actual connection to favorites
*/
- (void)addToFavoritesHost:(NSString *)host socket:(NSString *)socket