aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Interfaces/English.lproj/MainMenu.xib120
-rw-r--r--Resources/Info.plist20
-rw-r--r--Source/SPAppController.h9
-rw-r--r--Source/SPAppController.m23
-rw-r--r--Source/SPDatabaseDocument.m76
5 files changed, 229 insertions, 19 deletions
diff --git a/Interfaces/English.lproj/MainMenu.xib b/Interfaces/English.lproj/MainMenu.xib
index 27b5bfc8..e3bc58af 100644
--- a/Interfaces/English.lproj/MainMenu.xib
+++ b/Interfaces/English.lproj/MainMenu.xib
@@ -12,6 +12,7 @@
</object>
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
<bool key="EncodedWithXMLCoder">YES</bool>
+ <integer value="81"/>
</object>
<object class="NSArray" key="IBDocument.PluginDependencies">
<bool key="EncodedWithXMLCoder">YES</bool>
@@ -362,6 +363,26 @@
<reference key="NSMixedImage" ref="315854375"/>
<int key="NSTag">1005</int>
</object>
+ <object class="NSMenuItem" id="943842666">
+ <reference key="NSMenu" ref="709725194"/>
+ <bool key="NSIsHidden">YES</bool>
+ <string key="NSTitle">Save Session</string>
+ <string key="NSKeyEquiv"/>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="625762401"/>
+ <reference key="NSMixedImage" ref="315854375"/>
+ <int key="NSTag">1020</int>
+ </object>
+ <object class="NSMenuItem" id="473804195">
+ <reference key="NSMenu" ref="709725194"/>
+ <bool key="NSIsHidden">YES</bool>
+ <string key="NSTitle">Save Session As…</string>
+ <string key="NSKeyEquiv"/>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="625762401"/>
+ <reference key="NSMixedImage" ref="315854375"/>
+ <int key="NSTag">1021</int>
+ </object>
<object class="NSMenuItem" id="256715652">
<reference key="NSMenu" ref="709725194"/>
<string key="NSTitle">Save Query…</string>
@@ -2707,14 +2728,6 @@
</object>
<object class="IBConnectionRecord">
<object class="IBActionConnection" key="connection">
- <string key="label">saveConnectionSheet:</string>
- <reference key="source" ref="63651044"/>
- <reference key="destination" ref="643339783"/>
- </object>
- <int key="connectionID">966</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
<string key="label">clearRecentDocuments:</string>
<reference key="source" ref="63651044"/>
<reference key="destination" ref="781874380"/>
@@ -2961,6 +2974,30 @@
</object>
<int key="connectionID">1115</int>
</object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">saveConnectionSheet:</string>
+ <reference key="source" ref="63651044"/>
+ <reference key="destination" ref="643339783"/>
+ </object>
+ <int key="connectionID">1120</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">saveConnectionSheet:</string>
+ <reference key="source" ref="63651044"/>
+ <reference key="destination" ref="943842666"/>
+ </object>
+ <int key="connectionID">1121</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">saveConnectionSheet:</string>
+ <reference key="source" ref="63651044"/>
+ <reference key="destination" ref="473804195"/>
+ </object>
+ <int key="connectionID">1122</int>
+ </object>
</object>
<object class="IBMutableOrderedSet" key="objectRecords">
<object class="NSArray" key="orderedObjects">
@@ -3188,6 +3225,8 @@
<reference ref="284533429"/>
<reference ref="1070661135"/>
<reference ref="363260437"/>
+ <reference ref="943842666"/>
+ <reference ref="473804195"/>
</object>
<reference key="parent" ref="86447006"/>
</object>
@@ -4314,6 +4353,16 @@
<reference key="object" ref="330165099"/>
<reference key="parent" ref="1934"/>
</object>
+ <object class="IBObjectRecord">
+ <int key="objectID">1116</int>
+ <reference key="object" ref="943842666"/>
+ <reference key="parent" ref="709725194"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">1118</int>
+ <reference key="object" ref="473804195"/>
+ <reference key="parent" ref="709725194"/>
+ </object>
</object>
</object>
<object class="NSMutableDictionary" key="flattenedProperties">
@@ -4371,6 +4420,8 @@
<string>111.ImportedFromIB2</string>
<string>1111.IBPluginDependency</string>
<string>1112.IBPluginDependency</string>
+ <string>1116.IBPluginDependency</string>
+ <string>1118.IBPluginDependency</string>
<string>129.IBPluginDependency</string>
<string>129.ImportedFromIB2</string>
<string>130.IBPluginDependency</string>
@@ -4713,6 +4764,8 @@
<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>
<integer value="1"/>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<integer value="1"/>
@@ -4789,7 +4842,7 @@
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<integer value="1"/>
<string>{{449, 1007}, {197, 53}}</string>
- <string>{{106, 685}, {511, 20}}</string>
+ <string>{{228, 546}, {511, 20}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<integer value="1"/>
<string>{{506, 836}, {511, 20}}</string>
@@ -4925,7 +4978,7 @@
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string>{{214, 180}, {287, 383}}</string>
+ <string>{{334, 123}, {287, 423}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<integer value="1"/>
<string>{{180, 535}, {182, 253}}</string>
@@ -5066,7 +5119,7 @@
</object>
</object>
<nil key="sourceID"/>
- <int key="maxID">1115</int>
+ <int key="maxID">1122</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
@@ -6514,6 +6567,51 @@
</object>
</object>
<object class="IBPartialClassDescription">
+ <string key="className">SPAppController</string>
+ <string key="superclassName">NSObject</string>
+ <object class="NSMutableDictionary" key="actions">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="NSArray" key="dict.sortedKeys">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <string>donate:</string>
+ <string>newTab:</string>
+ <string>newWindow:</string>
+ <string>openAboutPanel:</string>
+ <string>openConnectionSheet:</string>
+ <string>openPreferences:</string>
+ <string>provideFeedback:</string>
+ <string>provideTranslationFeedback:</string>
+ <string>viewKeyboardShortcuts:</string>
+ <string>visitFAQWebsite:</string>
+ <string>visitHelpWebsite:</string>
+ <string>visitWebsite:</string>
+ </object>
+ <object class="NSMutableArray" key="dict.values">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <string>id</string>
+ <string>id</string>
+ <string>id</string>
+ <string>id</string>
+ <string>id</string>
+ <string>id</string>
+ <string>id</string>
+ <string>id</string>
+ <string>id</string>
+ <string>id</string>
+ <string>id</string>
+ <string>id</string>
+ </object>
+ </object>
+ <object class="NSMutableDictionary" key="outlets">
+ <string key="NS.key.0">encodingPopUp</string>
+ <string key="NS.object.0">id</string>
+ </object>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBDocumentRelativeSource</string>
+ <string key="minorKey">../../Source/SPAppController.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
<string key="className">SPWindowController</string>
<string key="superclassName">NSWindowController</string>
<object class="NSMutableDictionary" key="actions">
diff --git a/Resources/Info.plist b/Resources/Info.plist
index 8e9d56cc..474ac750 100644
--- a/Resources/Info.plist
+++ b/Resources/Info.plist
@@ -27,6 +27,26 @@
<dict>
<key>CFBundleTypeExtensions</key>
<array>
+ <string>spfs</string>
+ </array>
+ <key>CFBundleTypeIconFile</key>
+ <string>spficon.icns</string>
+ <key>CFBundleTypeName</key>
+ <string>Sequel Pro Connection Bundle</string>
+ <key>CFBundleTypeOSTypes</key>
+ <array>
+ <string>connection</string>
+ </array>
+ <key>CFBundleTypeRole</key>
+ <string>Editor</string>
+ <key>NSDocumentClass</key>
+ <string>SPDocumentController</string>
+ <key>LSTypeIsPackage</key>
+ <integer>1</integer>
+ </dict>
+ <dict>
+ <key>CFBundleTypeExtensions</key>
+ <array>
<string>sql</string>
</array>
<key>CFBundleTypeIconFile</key>
diff --git a/Source/SPAppController.h b/Source/SPAppController.h
index 0ae75b90..9d9a5564 100644
--- a/Source/SPAppController.h
+++ b/Source/SPAppController.h
@@ -36,6 +36,8 @@
SPPreferenceController *prefsController;
id encodingPopUp;
+
+ NSURL *_sessionURL;
}
// Window management
@@ -62,8 +64,11 @@
// Getters
- (SPPreferenceController *)preferenceController;
-- (NSArray *) orderedDatabaseConnectionWindows;
-- (SPDatabaseDocument *) frontDocument;
+- (NSArray *)orderedDatabaseConnectionWindows;
+- (SPDatabaseDocument *)frontDocument;
+- (NSURL *)sessionURL;
+
+- (void)setSessionURL:(NSString *)urlString;
// Feedback controller delegate methods
- (NSMutableDictionary*) anonymizePreferencesForFeedbackReport:(NSMutableDictionary *)preferences;
diff --git a/Source/SPAppController.m b/Source/SPAppController.m
index 7a3ec334..45deeff9 100644
--- a/Source/SPAppController.m
+++ b/Source/SPAppController.m
@@ -43,6 +43,7 @@
- (id)init
{
if ((self = [super init])) {
+ _sessionURL = nil;
[NSApp setDelegate:self];
}
@@ -295,6 +296,9 @@
[[self frontDocument] initWithConnectionFile:filename];
}
+ else if([[[filename pathExtension] lowercaseString] isEqualToString:@"spfs"]) {
+
+ }
else {
NSLog(@"Only files with the extensions ‘spf’ or ‘sql’ are allowed.");
}
@@ -435,6 +439,23 @@
return nil;
}
+/**
+ * Retrieve the session URL. Return nil if no session is opened
+ */
+- (NSURL *)sessionURL
+{
+ return _sessionURL;
+}
+
+/**
+ * Set the global session URL used for Save (As) Session.
+ */
+- (void)setSessionURL:(NSString *)urlString
+{
+ if(_sessionURL) [_sessionURL release], _sessionURL = nil;
+ _sessionURL = [[NSURL fileURLWithPath:urlString] retain];
+}
+
#pragma mark -
#pragma mark Services menu methods
@@ -768,7 +789,7 @@
{
[prefsController release], prefsController = nil;
[aboutController release], aboutController = nil;
-
+ if(_sessionURL) [_sessionURL release], _sessionURL = nil;
[super dealloc];
}
diff --git a/Source/SPDatabaseDocument.m b/Source/SPDatabaseDocument.m
index d76479b3..b463be93 100644
--- a/Source/SPDatabaseDocument.m
+++ b/Source/SPDatabaseDocument.m
@@ -2706,7 +2706,6 @@
#pragma mark -
#pragma mark Menu methods
-
/**
* Saves SP session or if Custom Query tab is active the editor's content as SQL file
* If sender == nil then the call came from [self writeSafelyToURL:ofType:forSaveOperation:error]
@@ -2797,8 +2796,36 @@
contextInfo = @"saveSPFfileAndClose";
else
contextInfo = @"saveSPFfile";
+ }
+ // Save Session or Save Session As…
+ else if (sender == nil || [sender tag] == 1020 || [sender tag] == 1021)
+ {
+ // Load accessory nib each time.
+ // Note that the top-level objects aren't released automatically, but are released when the panel ends.
+ if(![NSBundle loadNibNamed:@"SaveSPFAccessory" owner:self]) {
+ NSLog(@"SaveSPFAccessory accessory dialog could not be loaded.");
+ return;
+ }
- } else {
+ [panel setAllowedFileTypes:[NSArray arrayWithObjects:@"spfs", nil]];
+
+ // Update accessory button states
+ [self validateSaveConnectionAccessory:nil];
+
+ // TODO note: it seems that one has problems with a NSSecureTextField
+ // inside an accessory view - ask HansJB
+ [[saveConnectionEncryptString cell] setControlView:saveConnectionAccessory];
+ [panel setAccessoryView:saveConnectionAccessory];
+
+ // Set file name
+ if([[NSApp delegate] sessionURL])
+ filename = [[[NSApp delegate] sessionURL] description];
+ else
+ filename = [NSString stringWithFormat:@"%@", @"session"];
+
+ contextInfo = @"saveSession";
+ }
+ else {
return;
}
@@ -2874,6 +2901,47 @@
if(contextInfo == @"saveSPFfileAndClose")
[self closeAndDisconnect];
}
+
+ // Save all open windows including all tabs as session
+ else if(contextInfo == @"saveSession") {
+
+ // Sub-folder 'Contents' will contain all untitled connection as single window or tab.
+ // info.plist will contain the opened structure (windows and tabs for each window). Each connection
+ // is linked to a saved spf file either in 'Contents' for unTitled ones or already saved spf files.
+
+ NSFileManager *fileManager = [NSFileManager defaultManager];
+
+ [fileManager createDirectoryAtPath:fileName withIntermediateDirectories:TRUE attributes:nil error:&error];
+
+ if(error != nil) {
+ NSAlert *errorAlert = [NSAlert alertWithError:error];
+ [errorAlert runModal];
+ return;
+ }
+
+ [fileManager createDirectoryAtPath:[NSString stringWithFormat:@"%@/Contents", fileName] withIntermediateDirectories:TRUE attributes:nil error:&error];
+
+ if(error != nil) {
+ NSAlert *errorAlert = [NSAlert alertWithError:error];
+ [errorAlert runModal];
+ return;
+ }
+
+ NSString *content = @"HALLO";
+ [content writeToFile:[NSString stringWithFormat:@"%@/info.plist", fileName]
+ atomically:YES
+ encoding:NSUTF8StringEncoding
+ error:&error];
+
+ if(error != nil) {
+ NSAlert *errorAlert = [NSAlert alertWithError:error];
+ [errorAlert runModal];
+ return;
+ }
+
+ [[NSApp delegate] setSessionURL:fileName];
+
+ }
}
}
@@ -2886,7 +2954,7 @@
NSMutableDictionary *spfDocData_temp = [NSMutableDictionary dictionary];
if(fileName == nil)
- fileName = [[self fileURL] path]; //[[[self fileURL] absoluteString] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
+ fileName = [[self fileURL] path];
// Store save panel settings or take them from spfDocData
if(!saveInBackground) {
@@ -3004,7 +3072,6 @@
[spfdata setObject:[spfDocData_temp objectForKey:@"encrypted"] forKey:@"encrypted"];
- // if([[spfDocData_temp objectForKey:@"save_password"] boolValue])
[spfdata setObject:[spfDocData_temp objectForKey:@"auto_connect"] forKey:@"auto_connect"];
if([[self keyChainID] length])
@@ -3033,7 +3100,6 @@
}
[connection setObject:aString forKey:@"type"];
-
if([[spfDocData_temp objectForKey:@"save_password"] boolValue]) {
NSString *pw = [self keychainPasswordForConnection:nil];
if(![pw length]) pw = [connectionController password];