aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Interfaces/English.lproj/ConnectionView.xib156
-rw-r--r--Source/SPConnectionController.m94
-rw-r--r--Source/SPConnectionControllerDataSource.m2
3 files changed, 209 insertions, 43 deletions
diff --git a/Interfaces/English.lproj/ConnectionView.xib b/Interfaces/English.lproj/ConnectionView.xib
index f657096a..168081e7 100644
--- a/Interfaces/English.lproj/ConnectionView.xib
+++ b/Interfaces/English.lproj/ConnectionView.xib
@@ -13,6 +13,7 @@
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
<bool key="EncodedWithXMLCoder">YES</bool>
<integer value="5743"/>
+ <integer value="5788"/>
</object>
<object class="NSArray" key="IBDocument.PluginDependencies">
<bool key="EncodedWithXMLCoder">YES</bool>
@@ -188,6 +189,60 @@
<object class="NSMutableArray" key="NSMenuItems">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference ref="797961582"/>
+ <object class="NSMenuItem" id="755096979">
+ <reference key="NSMenu" ref="167853330"/>
+ <string key="NSTitle">Rename</string>
+ <string key="NSKeyEquiv"/>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="955092474"/>
+ <reference key="NSMixedImage" ref="913188683"/>
+ <string key="NSAction">_popUpItemAction:</string>
+ <reference key="NSTarget" ref="970960222"/>
+ </object>
+ <object class="NSMenuItem" id="645814925">
+ <reference key="NSMenu" ref="167853330"/>
+ <string key="NSTitle">Remove</string>
+ <string key="NSKeyEquiv"/>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="955092474"/>
+ <reference key="NSMixedImage" ref="913188683"/>
+ <string key="NSAction">_popUpItemAction:</string>
+ <reference key="NSTarget" ref="970960222"/>
+ </object>
+ <object class="NSMenuItem" id="612600535">
+ <reference key="NSMenu" ref="167853330"/>
+ <bool key="NSIsDisabled">YES</bool>
+ <bool key="NSIsSeparator">YES</bool>
+ <string key="NSTitle"/>
+ <string key="NSKeyEquiv"/>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="955092474"/>
+ <reference key="NSMixedImage" ref="913188683"/>
+ <string key="NSAction">_popUpItemAction:</string>
+ <reference key="NSTarget" ref="970960222"/>
+ </object>
+ <object class="NSMenuItem" id="78866147">
+ <reference key="NSMenu" ref="167853330"/>
+ <string key="NSTitle">Duplicate</string>
+ <string key="NSKeyEquiv"/>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="955092474"/>
+ <reference key="NSMixedImage" ref="913188683"/>
+ <string key="NSAction">_popUpItemAction:</string>
+ <reference key="NSTarget" ref="970960222"/>
+ </object>
+ <object class="NSMenuItem" id="1068847855">
+ <reference key="NSMenu" ref="167853330"/>
+ <bool key="NSIsDisabled">YES</bool>
+ <bool key="NSIsSeparator">YES</bool>
+ <string key="NSTitle"/>
+ <string key="NSKeyEquiv"/>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="955092474"/>
+ <reference key="NSMixedImage" ref="913188683"/>
+ <string key="NSAction">_popUpItemAction:</string>
+ <reference key="NSTarget" ref="970960222"/>
+ </object>
<object class="NSMenuItem" id="217054518">
<reference key="NSMenu" ref="167853330"/>
<string key="NSTitle">Import...</string>
@@ -220,6 +275,16 @@
<string key="NSAction">_popUpItemAction:</string>
<reference key="NSTarget" ref="970960222"/>
</object>
+ <object class="NSMenuItem" id="505774202">
+ <reference key="NSMenu" ref="167853330"/>
+ <string key="NSTitle">Make Default</string>
+ <string key="NSKeyEquiv"/>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="955092474"/>
+ <reference key="NSMixedImage" ref="913188683"/>
+ <string key="NSAction">_popUpItemAction:</string>
+ <reference key="NSTarget" ref="970960222"/>
+ </object>
<object class="NSMenuItem" id="788191870">
<reference key="NSMenu" ref="167853330"/>
<string key="NSTitle">Sort By</string>
@@ -292,6 +357,7 @@
</object>
<reference key="NSMenuFont" ref="807120225"/>
</object>
+ <int key="NSSelectedIndex">9</int>
<bool key="NSPullDown">YES</bool>
<int key="NSPreferredEdge">1</int>
<bool key="NSUsesItemFromMenu">YES</bool>
@@ -4995,6 +5061,38 @@
</object>
<int key="connectionID">5882</int>
</object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">duplicateFavorite:</string>
+ <reference key="source" ref="545410097"/>
+ <reference key="destination" ref="78866147"/>
+ </object>
+ <int key="connectionID">5888</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">makeSelectedFavoriteDefault:</string>
+ <reference key="source" ref="545410097"/>
+ <reference key="destination" ref="505774202"/>
+ </object>
+ <int key="connectionID">5889</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">renameNode:</string>
+ <reference key="source" ref="545410097"/>
+ <reference key="destination" ref="755096979"/>
+ </object>
+ <int key="connectionID">5890</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">removeNode:</string>
+ <reference key="source" ref="545410097"/>
+ <reference key="destination" ref="645814925"/>
+ </object>
+ <int key="connectionID">5891</int>
+ </object>
</object>
<object class="IBMutableOrderedSet" key="objectRecords">
<object class="NSArray" key="orderedObjects">
@@ -6623,6 +6721,12 @@
<reference ref="567127977"/>
<reference ref="214273320"/>
<reference ref="788191870"/>
+ <reference ref="755096979"/>
+ <reference ref="645814925"/>
+ <reference ref="612600535"/>
+ <reference ref="78866147"/>
+ <reference ref="1068847855"/>
+ <reference ref="505774202"/>
</object>
<reference key="parent" ref="970960222"/>
</object>
@@ -6788,6 +6892,36 @@
<reference key="object" ref="1020482049"/>
<reference key="parent" ref="148626614"/>
</object>
+ <object class="IBObjectRecord">
+ <int key="objectID">5883</int>
+ <reference key="object" ref="755096979"/>
+ <reference key="parent" ref="167853330"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">5884</int>
+ <reference key="object" ref="645814925"/>
+ <reference key="parent" ref="167853330"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">5885</int>
+ <reference key="object" ref="612600535"/>
+ <reference key="parent" ref="167853330"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">5886</int>
+ <reference key="object" ref="78866147"/>
+ <reference key="parent" ref="167853330"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">5887</int>
+ <reference key="object" ref="505774202"/>
+ <reference key="parent" ref="167853330"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">5892</int>
+ <reference key="object" ref="1068847855"/>
+ <reference key="parent" ref="167853330"/>
+ </object>
</object>
</object>
<object class="NSMutableDictionary" key="flattenedProperties">
@@ -7108,6 +7242,12 @@
<string>5866.IBPluginDependency</string>
<string>5869.IBPluginDependency</string>
<string>5870.IBPluginDependency</string>
+ <string>5883.IBPluginDependency</string>
+ <string>5884.IBPluginDependency</string>
+ <string>5885.IBPluginDependency</string>
+ <string>5886.IBPluginDependency</string>
+ <string>5887.IBPluginDependency</string>
+ <string>5892.IBPluginDependency</string>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
@@ -7605,7 +7745,7 @@
<bytes key="NSTransformStruct">P4AAAL+AAABDGQAAwgAAAA</bytes>
</object>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string>{{461, 362}, {142, 123}}</string>
+ <string>{{64, 53}, {142, 123}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
@@ -7631,7 +7771,7 @@
<bytes key="NSTransformStruct">P4AAAL+AAABB8AAAwbAAAA</bytes>
</object>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string>{{146, 300}, {116, 89}}</string>
+ <string>{{146, 175}, {131, 177}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
@@ -7690,6 +7830,12 @@
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
</object>
</object>
<object class="NSMutableDictionary" key="unlocalizedProperties">
@@ -7708,7 +7854,7 @@
</object>
</object>
<nil key="sourceID"/>
- <int key="maxID">5882</int>
+ <int key="maxID">5892</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
@@ -9338,8 +9484,8 @@
<string>{32, 23}</string>
<string>{15, 23}</string>
<string>{10, 23}</string>
- <string>{16, 8}</string>
- <string>{16, 8}</string>
+ <string>{16, 9}</string>
+ <string>{16, 9}</string>
</object>
</object>
</data>
diff --git a/Source/SPConnectionController.m b/Source/SPConnectionController.m
index 12ead317..15e68f41 100644
--- a/Source/SPConnectionController.m
+++ b/Source/SPConnectionController.m
@@ -71,7 +71,7 @@ static NSString *SPExportFavoritesFilename = @"SequelProFavorites.plist";
// Privately redeclare as read/write to get the synthesized setter
@property (readwrite, assign) BOOL isEditingConnection;
-- (void)_saveCurrentDetailsCreatingNewFavorite:(BOOL)createNewFavorite;
+- (void)_saveCurrentDetailsCreatingNewFavorite:(BOOL)createNewFavorite validateDetails:(BOOL)validateDetails;
- (BOOL)_checkHost;
#ifndef SP_REFACTOR
- (void)_sortFavorites;
@@ -83,6 +83,7 @@ static NSString *SPExportFavoritesFilename = @"SequelProFavorites.plist";
- (void)_selectNode:(SPTreeNode *)node;
- (void)_scrollToSelectedNode;
- (void)_removeNode:(SPTreeNode *)node;
+- (void)_removeAllPasswordsForNode:(SPTreeNode *)node;
- (NSNumber *)_createNewFavoriteID;
- (SPTreeNode *)_favoriteNodeForFavoriteID:(NSInteger)favoriteID;
@@ -676,7 +677,7 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2,
*/
- (IBAction)saveFavorite:(id)sender
{
- [self _saveCurrentDetailsCreatingNewFavorite:NO];
+ [self _saveCurrentDetailsCreatingNewFavorite:NO validateDetails:YES];
}
/**
@@ -742,7 +743,7 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2,
*/
- (IBAction)addFavoriteUsingCurrentDetails:(id)sender
{
- [self _saveCurrentDetailsCreatingNewFavorite:YES];
+ [self _saveCurrentDetailsCreatingNewFavorite:YES validateDetails:YES];
}
/**
@@ -1073,7 +1074,7 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2,
* If creating a new favourite, also select it and ensure the selected
* favourite is visible.
*/
-- (void)_saveCurrentDetailsCreatingNewFavorite:(BOOL)createNewFavorite
+- (void)_saveCurrentDetailsCreatingNewFavorite:(BOOL)createNewFavorite validateDetails:(BOOL)validateDetails
{
// Complete any active editing
@@ -1083,7 +1084,7 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2,
// Ensure that host is not empty if this is a TCP/IP or SSH connection
- if (([self type] == SPTCPIPConnection || [self type] == SPSSHTunnelConnection) && ![[self host] length]) {
+ if (validateDetails && ([self type] == SPTCPIPConnection || [self type] == SPSSHTunnelConnection) && ![[self host] length]) {
SPBeginAlertSheet(NSLocalizedString(@"Insufficient connection details", @"insufficient details message"),
NSLocalizedString(@"OK", @"OK button"), nil, nil, [dbDocument parentWindow], nil, nil, nil,
NSLocalizedString(@"Insufficient details provided to establish a connection. Please provide at least a host.", @"insufficient details informative message"));
@@ -1091,7 +1092,7 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2,
}
// If SSH is enabled, ensure that the SSH host is not nil
- if ([self type] == SPSSHTunnelConnection && ![[self sshHost] length]) {
+ if (validateDetails && [self type] == SPSSHTunnelConnection && ![[self sshHost] length]) {
SPBeginAlertSheet(NSLocalizedString(@"Insufficient connection details", @"insufficient details message"),
NSLocalizedString(@"OK", @"OK button"), nil, nil, [dbDocument parentWindow], nil, nil, nil,
NSLocalizedString(@"Please enter the hostname for the SSH Tunnel, or disable the SSH Tunnel.", @"message of panel when ssh details are incomplete"));
@@ -1574,35 +1575,8 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2,
*/
- (void)_removeNode:(SPTreeNode *)node
{
- if (![node isGroup]) {
- NSDictionary *favorite = [[node representedObject] nodeFavorite];
-
- // Get selected favorite's details
- NSString *favoriteName = [favorite objectForKey:SPFavoriteNameKey];
- NSString *favoriteUser = [favorite objectForKey:SPFavoriteUserKey];
- NSString *favoriteHost = [favorite objectForKey:SPFavoriteHostKey];
- NSString *favoriteDatabase = [favorite objectForKey:SPFavoriteDatabaseKey];
- NSString *favoriteSSHUser = [favorite objectForKey:SPFavoriteSSHUserKey];
- NSString *favoriteSSHHost = [favorite objectForKey:SPFavoriteSSHHostKey];
- NSString *favoriteID = [favorite objectForKey:SPFavoriteIDKey];
-
- // Remove passwords from the Keychain
- [keychain deletePasswordForName:[keychain nameForFavoriteName:favoriteName id:favoriteID]
- account:[keychain accountForUser:favoriteUser host:((type == SPSocketConnection) ? @"localhost" : favoriteHost) database:favoriteDatabase]];
- [keychain deletePasswordForName:[keychain nameForSSHForFavoriteName:favoriteName id:favoriteID]
- account:[keychain accountForSSHUser:favoriteSSHUser sshHost:favoriteSSHHost]];
-
- // Reset last used favorite
- if ([[favorite objectForKey:SPFavoriteIDKey] integerValue] == [prefs integerForKey:SPLastFavoriteID]) {
- [prefs setInteger:0 forKey:SPLastFavoriteID];
- }
-
- // If required, reset the default favorite
- if ([[favorite objectForKey:SPFavoriteIDKey] integerValue] == [prefs integerForKey:SPDefaultFavorite]) {
- [prefs setInteger:[prefs integerForKey:SPLastFavoriteID] forKey:SPDefaultFavorite];
- }
- }
-
+ [self _removeAllPasswordsForNode:node];
+
[favoritesController removeFavoriteNode:node];
[self _reloadFavoritesViewData];
@@ -1618,6 +1592,52 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2,
}
/**
+ * Removes all passwords for the supplied tree node and any child nodes.
+ *
+ * @param node The node to remove all passwords within and for.
+ */
+- (void)_removeAllPasswordsForNode:(SPTreeNode *)node
+{
+
+ // If the supplied node is a group node, remove all passwords for any children
+ if ([node isGroup]) {
+ for (SPTreeNode *childNode in [node childNodes]) {
+ [self _removeAllPasswordsForNode:childNode];
+ }
+ return;
+ }
+
+ // Otherwise, remove details for the supplied node.
+
+ NSDictionary *favorite = [[node representedObject] nodeFavorite];
+
+ // Get selected favorite's details
+ NSString *favoriteName = [favorite objectForKey:SPFavoriteNameKey];
+ NSString *favoriteUser = [favorite objectForKey:SPFavoriteUserKey];
+ NSString *favoriteHost = [favorite objectForKey:SPFavoriteHostKey];
+ NSString *favoriteDatabase = [favorite objectForKey:SPFavoriteDatabaseKey];
+ NSString *favoriteSSHUser = [favorite objectForKey:SPFavoriteSSHUserKey];
+ NSString *favoriteSSHHost = [favorite objectForKey:SPFavoriteSSHHostKey];
+ NSString *favoriteID = [favorite objectForKey:SPFavoriteIDKey];
+
+ // Remove passwords from the Keychain
+ [keychain deletePasswordForName:[keychain nameForFavoriteName:favoriteName id:favoriteID]
+ account:[keychain accountForUser:favoriteUser host:((type == SPSocketConnection) ? @"localhost" : favoriteHost) database:favoriteDatabase]];
+ [keychain deletePasswordForName:[keychain nameForSSHForFavoriteName:favoriteName id:favoriteID]
+ account:[keychain accountForSSHUser:favoriteSSHUser sshHost:favoriteSSHHost]];
+
+ // Reset last used favorite
+ if ([[favorite objectForKey:SPFavoriteIDKey] integerValue] == [prefs integerForKey:SPLastFavoriteID]) {
+ [prefs setInteger:0 forKey:SPLastFavoriteID];
+ }
+
+ // If required, reset the default favorite
+ if ([[favorite objectForKey:SPFavoriteIDKey] integerValue] == [prefs integerForKey:SPDefaultFavorite]) {
+ [prefs setInteger:[prefs integerForKey:SPLastFavoriteID] forKey:SPDefaultFavorite];
+ }
+}
+
+/**
* Creates a new favorite ID based on the UNIX epoch time.
*/
- (NSNumber *)_createNewFavoriteID
@@ -1698,8 +1718,8 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2,
// Fade and move the edit button area in
[editButtonsView setAlphaValue:0.0];
[editButtonsView setHidden:NO];
- [editButtonsView setFrameOrigin:NSMakePoint([editButtonsView frame].origin.x, [editButtonsView frame].origin.y - 40)];
- [[editButtonsView animator] setFrameOrigin:NSMakePoint([editButtonsView frame].origin.x, [editButtonsView frame].origin.y + 40)];
+ [editButtonsView setFrameOrigin:NSMakePoint([editButtonsView frame].origin.x, [editButtonsView frame].origin.y - 30)];
+ [[editButtonsView animator] setFrameOrigin:NSMakePoint([editButtonsView frame].origin.x, [editButtonsView frame].origin.y + 30)];
[[editButtonsView animator] setAlphaValue:1.0];
// Update the "Save" button state as appropriate
diff --git a/Source/SPConnectionControllerDataSource.m b/Source/SPConnectionControllerDataSource.m
index d7f3d235..a318db85 100644
--- a/Source/SPConnectionControllerDataSource.m
+++ b/Source/SPConnectionControllerDataSource.m
@@ -111,7 +111,7 @@
// Updating the name triggers a KVO update
[self setName:newName];
- [self saveFavorite:self];
+ [self _saveCurrentDetailsCreatingNewFavorite:NO validateDetails:NO];
}
else {
[[node representedObject] setNodeName:newName];