aboutsummaryrefslogtreecommitdiffstats
path: root/TableDocument.m
diff options
context:
space:
mode:
authorstuconnolly <stuart02@gmail.com>2008-12-02 18:10:26 +0000
committerstuconnolly <stuart02@gmail.com>2008-12-02 18:10:26 +0000
commitce3f6e3017607cfd58a8af6f17b906f5d8b60f4b (patch)
treeab099957650e7650600e22da42a804c429da8e47 /TableDocument.m
parent7864bf91a63ad879ef1c6edc6a10b9dc1f932e12 (diff)
downloadsequelpro-ce3f6e3017607cfd58a8af6f17b906f5d8b60f4b.tar.gz
sequelpro-ce3f6e3017607cfd58a8af6f17b906f5d8b60f4b.tar.bz2
sequelpro-ce3f6e3017607cfd58a8af6f17b906f5d8b60f4b.zip
Fixed various Keychain issues regarding already existing passwords by checking if an item of the same name and account already exists. This revision also fixes issue #94 by removing the Keychain password first and then the favourite from the array controller.
Diffstat (limited to 'TableDocument.m')
-rw-r--r--TableDocument.m28
1 files changed, 28 insertions, 0 deletions
diff --git a/TableDocument.m b/TableDocument.m
index f3fe760a..d380b681 100644
--- a/TableDocument.m
+++ b/TableDocument.m
@@ -265,6 +265,34 @@ NSString *TableDocumentFavoritesControllerFavoritesDidChange = @"TableDocumentFa
selectedFavorite = [[favoritesButton titleOfSelectedItem] retain];
}
+/**
+ * Remove the selected favourite. Instead of calling the remove: method of the Favorites NSArrayController
+ * directly in the XIB we do it here because we also need to remove the keychain password.
+ */
+- (IBAction)removeFavorite:(id)sender
+{
+ if (![self selectedFavorite]) {
+ return;
+ }
+
+ NSString *name = [self valueForKeyPath:@"selectedFavorite.name"];
+ NSString *user = [self valueForKeyPath:@"selectedFavorite.user"];
+ NSString *host = [self valueForKeyPath:@"selectedFavorite.host"];
+ NSString *database = [self valueForKeyPath:@"selectedFavorite.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]];
+
+ // Remove from favorites array controller
+ [favoritesController remove:[self selectedFavorite]];
+
+}
+
+/**
+ * Return the favorites array.
+ */
- (NSMutableArray *)favorites
{
// if no favorites, load from user defaults