diff options
-rw-r--r-- | Interfaces/English.lproj/DBView.xib | 307 | ||||
-rw-r--r-- | Interfaces/English.lproj/MainMenu.xib | 56 | ||||
-rw-r--r-- | Interfaces/English.lproj/SaveSPFAccessory.xib | 338 | ||||
-rw-r--r-- | Source/CustomQuery.h | 28 | ||||
-rw-r--r-- | Source/CustomQuery.m | 23 | ||||
-rw-r--r-- | Source/TableDocument.h | 6 | ||||
-rw-r--r-- | Source/TableDocument.m | 505 | ||||
-rw-r--r-- | Source/TablesList.m | 23 |
8 files changed, 733 insertions, 553 deletions
diff --git a/Interfaces/English.lproj/DBView.xib b/Interfaces/English.lproj/DBView.xib index 1c594cd5..0066449f 100644 --- a/Interfaces/English.lproj/DBView.xib +++ b/Interfaces/English.lproj/DBView.xib @@ -8981,8 +8981,9 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string> <string key="NSWindowTitle">Secure Text Input Sheet</string> <string key="NSWindowClass">NSPanel</string> <nil key="NSViewClass"/> + <string key="NSWindowContentMaxSize">{3.40282e+38, 3.40282e+38}</string> <object class="NSView" key="NSWindowView" id="978976687"> - <reference key="NSNextResponder"/> + <nil key="NSNextResponder"/> <int key="NSvFlags">256</int> <object class="NSMutableArray" key="NSSubviews"> <bool key="EncodedWithXMLCoder">YES</bool> @@ -8991,7 +8992,6 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string> <int key="NSvFlags">268</int> <string key="NSFrame">{{228, 12}, {96, 32}}</string> <reference key="NSSuperview" ref="978976687"/> - <reference key="NSWindow"/> <int key="NSTag">1</int> <bool key="NSEnabled">YES</bool> <object class="NSButtonCell" key="NSCell" id="137468004"> @@ -9013,7 +9013,6 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string> <int key="NSvFlags">268</int> <string key="NSFrame">{{132, 12}, {96, 32}}</string> <reference key="NSSuperview" ref="978976687"/> - <reference key="NSWindow"/> <bool key="NSEnabled">YES</bool> <object class="NSButtonCell" key="NSCell" id="680933316"> <int key="NSCellFlags">67239424</int> @@ -9034,7 +9033,6 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string> <int key="NSvFlags">268</int> <string key="NSFrame">{{20, 48}, {298, 22}}</string> <reference key="NSSuperview" ref="978976687"/> - <reference key="NSWindow"/> <bool key="NSEnabled">YES</bool> <object class="NSSecureTextFieldCell" key="NSCell" id="973880651"> <int key="NSCellFlags">343014976</int> @@ -9056,7 +9054,6 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string> <int key="NSvFlags">268</int> <string key="NSFrame">{{17, 101}, {304, 17}}</string> <reference key="NSSuperview" ref="978976687"/> - <reference key="NSWindow"/> <bool key="NSEnabled">YES</bool> <object class="NSTextFieldCell" key="NSCell" id="696861397"> <int key="NSCellFlags">68288064</int> @@ -9073,7 +9070,6 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string> <int key="NSvFlags">268</int> <string key="NSFrame">{{17, 78}, {304, 14}}</string> <reference key="NSSuperview" ref="978976687"/> - <reference key="NSWindow"/> <bool key="NSEnabled">YES</bool> <object class="NSTextFieldCell" key="NSCell" id="332003389"> <int key="NSCellFlags">68288064</int> @@ -9087,8 +9083,6 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string> </object> </object> <string key="NSFrameSize">{338, 138}</string> - <reference key="NSSuperview"/> - <reference key="NSWindow"/> </object> <string key="NSScreenRect">{{0, 0}, {1280, 778}}</string> <string key="NSMaxSize">{3.40282e+38, 3.40282e+38}</string> @@ -11380,102 +11374,6 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string> <string key="NSFrameSize">{110, 20}</string> <string key="NSClassName">NSView</string> </object> - <object class="NSCustomView" id="721763950"> - <nil key="NSNextResponder"/> - <int key="NSvFlags">268</int> - <object class="NSMutableArray" key="NSSubviews"> - <bool key="EncodedWithXMLCoder">YES</bool> - <object class="NSButton" id="612342309"> - <reference key="NSNextResponder" ref="721763950"/> - <int key="NSvFlags">268</int> - <string key="NSFrame">{{18, 57}, {151, 18}}</string> - <reference key="NSSuperview" ref="721763950"/> - <bool key="NSEnabled">YES</bool> - <object class="NSButtonCell" key="NSCell" id="557172944"> - <int key="NSCellFlags">-2080244224</int> - <int key="NSCellFlags2">0</int> - <string key="NSContents">Include session data</string> - <reference key="NSSupport" ref="244931163"/> - <reference key="NSControlView" ref="612342309"/> - <int key="NSButtonFlags">1211912703</int> - <int key="NSButtonFlags2">130</int> - <reference key="NSNormalImage" ref="653588312"/> - <reference key="NSAlternateImage" ref="386686735"/> - <string key="NSAlternateContents"/> - <string key="NSKeyEquivalent"/> - <int key="NSPeriodicDelay">200</int> - <int key="NSPeriodicInterval">25</int> - </object> - </object> - <object class="NSButton" id="33459578"> - <reference key="NSNextResponder" ref="721763950"/> - <int key="NSvFlags">268</int> - <string key="NSFrame">{{18, 32}, {121, 18}}</string> - <reference key="NSSuperview" ref="721763950"/> - <bool key="NSEnabled">YES</bool> - <object class="NSButtonCell" key="NSCell" id="735841378"> - <int key="NSCellFlags">67239424</int> - <int key="NSCellFlags2">0</int> - <string key="NSContents">Save passwords</string> - <reference key="NSSupport" ref="244931163"/> - <reference key="NSControlView" ref="33459578"/> - <int key="NSButtonFlags">1211912703</int> - <int key="NSButtonFlags2">130</int> - <reference key="NSNormalImage" ref="653588312"/> - <reference key="NSAlternateImage" ref="386686735"/> - <string key="NSAlternateContents"/> - <string key="NSKeyEquivalent"/> - <int key="NSPeriodicDelay">200</int> - <int key="NSPeriodicInterval">25</int> - </object> - </object> - <object class="NSButton" id="842051747"> - <reference key="NSNextResponder" ref="721763950"/> - <int key="NSvFlags">268</int> - <string key="NSFrame">{{47, 7}, {166, 18}}</string> - <reference key="NSSuperview" ref="721763950"/> - <bool key="NSEnabled">YES</bool> - <object class="NSButtonCell" key="NSCell" id="256201367"> - <int key="NSCellFlags">-1543373312</int> - <int key="NSCellFlags2">131072</int> - <string key="NSContents">Encrypt file with password:</string> - <reference key="NSSupport" ref="26"/> - <reference key="NSControlView" ref="842051747"/> - <int key="NSButtonFlags">1211912703</int> - <int key="NSButtonFlags2">130</int> - <reference key="NSNormalImage" ref="653588312"/> - <reference key="NSAlternateImage" ref="386686735"/> - <string key="NSAlternateContents"/> - <string key="NSKeyEquivalent"/> - <int key="NSPeriodicDelay">200</int> - <int key="NSPeriodicInterval">25</int> - </object> - </object> - <object class="NSSecureTextField" id="953813003"> - <reference key="NSNextResponder" ref="721763950"/> - <int key="NSvFlags">268</int> - <string key="NSFrame">{{215, 7}, {117, 19}}</string> - <reference key="NSSuperview" ref="721763950"/> - <bool key="NSEnabled">YES</bool> - <object class="NSSecureTextFieldCell" key="NSCell" id="856645815"> - <int key="NSCellFlags">879885888</int> - <int key="NSCellFlags2">272761856</int> - <string key="NSContents"/> - <reference key="NSSupport" ref="26"/> - <reference key="NSControlView" ref="953813003"/> - <bool key="NSDrawsBackground">YES</bool> - <reference key="NSBackgroundColor" ref="480189472"/> - <reference key="NSTextColor" ref="690893883"/> - <object class="NSArray" key="NSAllowedInputLocales"> - <bool key="EncodedWithXMLCoder">YES</bool> - <string>NSAllRomanInputSourcesLocaleIdentifier</string> - </object> - </object> - </object> - </object> - <string key="NSFrameSize">{352, 84}</string> - <string key="NSClassName">NSView</string> - </object> <object class="NSCustomView" id="532635418"> <nil key="NSNextResponder"/> <int key="NSvFlags">4364</int> @@ -11623,10 +11521,6 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string> <string key="NSClassName">NSView</string> </object> <object class="NSUserDefaultsController" id="461189245"> - <object class="NSMutableArray" key="NSDeclaredKeys"> - <bool key="EncodedWithXMLCoder">YES</bool> - <string>_dummy</string> - </object> <bool key="NSSharedInstance">YES</bool> </object> <object class="NSCustomObject" id="601471102"> @@ -15255,94 +15149,6 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string> </object> <object class="IBConnectionRecord"> <object class="IBOutletConnection" key="connection"> - <string key="label">saveConnectionAccessory</string> - <reference key="source" ref="427689665"/> - <reference key="destination" ref="721763950"/> - </object> - <int key="connectionID">6387</int> - </object> - <object class="IBConnectionRecord"> - <object class="IBOutletConnection" key="connection"> - <string key="label">saveConnectionIncludeData</string> - <reference key="source" ref="427689665"/> - <reference key="destination" ref="612342309"/> - </object> - <int key="connectionID">6388</int> - </object> - <object class="IBConnectionRecord"> - <object class="IBOutletConnection" key="connection"> - <string key="label">saveConnectionSavePassword</string> - <reference key="source" ref="427689665"/> - <reference key="destination" ref="33459578"/> - </object> - <int key="connectionID">6389</int> - </object> - <object class="IBConnectionRecord"> - <object class="IBOutletConnection" key="connection"> - <string key="label">saveConnectionEncrypt</string> - <reference key="source" ref="427689665"/> - <reference key="destination" ref="842051747"/> - </object> - <int key="connectionID">6390</int> - </object> - <object class="IBConnectionRecord"> - <object class="IBOutletConnection" key="connection"> - <string key="label">saveConnectionEncryptString</string> - <reference key="source" ref="427689665"/> - <reference key="destination" ref="953813003"/> - </object> - <int key="connectionID">6391</int> - </object> - <object class="IBConnectionRecord"> - <object class="IBOutletConnection" key="connection"> - <string key="label">nextKeyView</string> - <reference key="source" ref="612342309"/> - <reference key="destination" ref="33459578"/> - </object> - <int key="connectionID">6392</int> - </object> - <object class="IBConnectionRecord"> - <object class="IBOutletConnection" key="connection"> - <string key="label">nextKeyView</string> - <reference key="source" ref="33459578"/> - <reference key="destination" ref="842051747"/> - </object> - <int key="connectionID">6393</int> - </object> - <object class="IBConnectionRecord"> - <object class="IBOutletConnection" key="connection"> - <string key="label">nextKeyView</string> - <reference key="source" ref="842051747"/> - <reference key="destination" ref="953813003"/> - </object> - <int key="connectionID">6394</int> - </object> - <object class="IBConnectionRecord"> - <object class="IBActionConnection" key="connection"> - <string key="label">saveConnectionAccessoryPasswordButton:</string> - <reference key="source" ref="427689665"/> - <reference key="destination" ref="33459578"/> - </object> - <int key="connectionID">6401</int> - </object> - <object class="IBConnectionRecord"> - <object class="IBActionConnection" key="connection"> - <string key="label">saveConnectionAccessoryPasswordButton:</string> - <reference key="source" ref="427689665"/> - <reference key="destination" ref="842051747"/> - </object> - <int key="connectionID">6402</int> - </object> - <object class="IBConnectionRecord"> - <object class="IBOutletConnection" key="connection"> - <string key="label">delegate</string> - <reference key="source" ref="953813003"/> - <reference key="destination" ref="427689665"/> - </object> - <int key="connectionID">6404</int> - </object> - <object class="IBConnectionRecord"> - <object class="IBOutletConnection" key="connection"> <string key="label">queryFavoritesSheet</string> <reference key="source" ref="601471102"/> <reference key="destination" ref="434046103"/> @@ -21663,75 +21469,6 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string> <reference key="parent" ref="538700903"/> </object> <object class="IBObjectRecord"> - <int key="objectID">6375</int> - <reference key="object" ref="721763950"/> - <object class="NSMutableArray" key="children"> - <bool key="EncodedWithXMLCoder">YES</bool> - <reference ref="33459578"/> - <reference ref="612342309"/> - <reference ref="842051747"/> - <reference ref="953813003"/> - </object> - <reference key="parent" ref="1043842561"/> - <string key="objectName">Save SPF Accessory</string> - </object> - <object class="IBObjectRecord"> - <int key="objectID">6376</int> - <reference key="object" ref="612342309"/> - <object class="NSMutableArray" key="children"> - <bool key="EncodedWithXMLCoder">YES</bool> - <reference ref="557172944"/> - </object> - <reference key="parent" ref="721763950"/> - </object> - <object class="IBObjectRecord"> - <int key="objectID">6377</int> - <reference key="object" ref="557172944"/> - <reference key="parent" ref="612342309"/> - </object> - <object class="IBObjectRecord"> - <int key="objectID">6378</int> - <reference key="object" ref="33459578"/> - <object class="NSMutableArray" key="children"> - <bool key="EncodedWithXMLCoder">YES</bool> - <reference ref="735841378"/> - </object> - <reference key="parent" ref="721763950"/> - </object> - <object class="IBObjectRecord"> - <int key="objectID">6379</int> - <reference key="object" ref="735841378"/> - <reference key="parent" ref="33459578"/> - </object> - <object class="IBObjectRecord"> - <int key="objectID">6380</int> - <reference key="object" ref="842051747"/> - <object class="NSMutableArray" key="children"> - <bool key="EncodedWithXMLCoder">YES</bool> - <reference ref="256201367"/> - </object> - <reference key="parent" ref="721763950"/> - </object> - <object class="IBObjectRecord"> - <int key="objectID">6381</int> - <reference key="object" ref="256201367"/> - <reference key="parent" ref="842051747"/> - </object> - <object class="IBObjectRecord"> - <int key="objectID">6384</int> - <reference key="object" ref="953813003"/> - <object class="NSMutableArray" key="children"> - <bool key="EncodedWithXMLCoder">YES</bool> - <reference ref="856645815"/> - </object> - <reference key="parent" ref="721763950"/> - </object> - <object class="IBObjectRecord"> - <int key="objectID">6385</int> - <reference key="object" ref="856645815"/> - <reference key="parent" ref="953813003"/> - </object> - <object class="IBObjectRecord"> <int key="objectID">6405</int> <reference key="object" ref="434046103"/> <object class="NSMutableArray" key="children"> @@ -23228,18 +22965,6 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string> <string>6370.IBPluginDependency</string> <string>6371.IBPluginDependency</string> <string>6372.IBPluginDependency</string> - <string>6375.IBEditorWindowLastContentRect</string> - <string>6375.IBPluginDependency</string> - <string>6376.IBAttributePlaceholdersKey</string> - <string>6376.IBPluginDependency</string> - <string>6377.IBPluginDependency</string> - <string>6378.IBAttributePlaceholdersKey</string> - <string>6378.IBPluginDependency</string> - <string>6379.IBPluginDependency</string> - <string>6380.IBPluginDependency</string> - <string>6381.IBPluginDependency</string> - <string>6384.IBPluginDependency</string> - <string>6385.IBPluginDependency</string> <string>6405.IBEditorWindowLastContentRect</string> <string>6405.IBWindowTemplateEditedContentRect</string> <string>6405.ImportedFromIB2</string> @@ -23280,7 +23005,6 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string> <string>6466.IBAttributePlaceholdersKey</string> <string>6466.IBPluginDependency</string> <string>6492.IBEditorWindowLastContentRect</string> - <string>6492.IBPluginDependency</string> <string>6492.IBWindowTemplateEditedContentRect</string> <string>6492.NSWindowTemplate.visibleAtLaunch</string> <string>6493.IBPluginDependency</string> @@ -25083,32 +24807,6 @@ aGUgYWN0aXZlIHNlbGVjdGlvbiAo4oyl4oyYUik</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <string>{{275, 661}, {352, 84}}</string> - <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <object class="NSMutableDictionary"> - <string key="NS.key.0">ToolTip</string> - <object class="IBToolTipAttribute" key="NS.object.0"> - <string key="name">ToolTip</string> - <reference key="object" ref="612342309"/> - <string key="toolTip">Save current selected table, view status, and queries</string> - </object> - </object> - <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <object class="NSMutableDictionary"> - <string key="NS.key.0">ToolTip</string> - <object class="IBToolTipAttribute" key="NS.object.0"> - <string key="name">ToolTip</string> - <reference key="object" ref="33459578"/> - <string key="toolTip">ATTENTION: All passwords will be saved in the file! For safety reasons it is recommended to encrypt the file.</string> - </object> - </object> - <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>{{719, 432}, {260, 112}}</string> <string>{{719, 432}, {260, 112}}</string> <reference ref="9"/> @@ -25173,7 +24871,6 @@ dXJyZW50IHF1ZXJ5IG9yIHNlbGVjdGlvbi4</string> </object> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>{{370, 428}, {338, 138}}</string> - <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>{{370, 428}, {338, 138}}</string> <reference ref="6"/> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> diff --git a/Interfaces/English.lproj/MainMenu.xib b/Interfaces/English.lproj/MainMenu.xib index 7689dbae..33e98b33 100644 --- a/Interfaces/English.lproj/MainMenu.xib +++ b/Interfaces/English.lproj/MainMenu.xib @@ -233,12 +233,13 @@ <bool key="EncodedWithXMLCoder">YES</bool> <object class="NSMenuItem" id="617509313"> <reference key="NSMenu" ref="709725194"/> - <string key="NSTitle">New Connection</string> + <string type="base64-UTF8" key="NSTitle">TmV34oCmA</string> <string key="NSKeyEquiv">n</string> <int key="NSKeyEquivModMask">1048576</int> <int key="NSMnemonicLoc">2147483647</int> <reference key="NSOnImage" ref="625762401"/> <reference key="NSMixedImage" ref="315854375"/> + <int key="NSTag">1000</int> </object> <object class="NSMenuItem" id="320151386"> <reference key="NSMenu" ref="709725194"/> @@ -248,6 +249,7 @@ <int key="NSMnemonicLoc">2147483647</int> <reference key="NSOnImage" ref="625762401"/> <reference key="NSMixedImage" ref="315854375"/> + <int key="NSTag">1001</int> </object> <object class="NSMenuItem" id="849728981"> <reference key="NSMenu" ref="709725194"/> @@ -257,6 +259,7 @@ <int key="NSMnemonicLoc">2147483647</int> <reference key="NSOnImage" ref="625762401"/> <reference key="NSMixedImage" ref="315854375"/> + <int key="NSTag">1002</int> </object> <object class="NSMenuItem" id="3878246"> <reference key="NSMenu" ref="709725194"/> @@ -277,25 +280,37 @@ <int key="NSMnemonicLoc">2147483647</int> <reference key="NSOnImage" ref="625762401"/> <reference key="NSMixedImage" ref="315854375"/> + <int key="NSTag">1003</int> </object> - <object class="NSMenuItem" id="256715652"> + <object class="NSMenuItem" id="759865633"> <reference key="NSMenu" ref="709725194"/> - <string type="base64-UTF8" key="NSTitle">U2F2ZSBRdWVyeeKApg</string> + <string key="NSTitle">Save</string> <string key="NSKeyEquiv">s</string> <int key="NSKeyEquivModMask">1048576</int> <int key="NSMnemonicLoc">2147483647</int> <reference key="NSOnImage" ref="625762401"/> <reference key="NSMixedImage" ref="315854375"/> + <int key="NSTag">1004</int> </object> - <object class="NSMenuItem" id="759865633"> + <object class="NSMenuItem" id="643339783"> <reference key="NSMenu" ref="709725194"/> - <string type="base64-UTF8" key="NSTitle">U2F2ZSBDb25uZWN0aW9u4oCmA</string> + <string type="base64-UTF8" key="NSTitle">U2F2ZSBBc+KApg</string> <string key="NSKeyEquiv">S</string> <int key="NSKeyEquivModMask">1048576</int> <int key="NSMnemonicLoc">2147483647</int> <reference key="NSOnImage" ref="625762401"/> <reference key="NSMixedImage" ref="315854375"/> - <int key="NSTag">1</int> + <int key="NSTag">1005</int> + </object> + <object class="NSMenuItem" id="256715652"> + <reference key="NSMenu" ref="709725194"/> + <string type="base64-UTF8" key="NSTitle">U2F2ZSBRdWVyeeKApg</string> + <string key="NSKeyEquiv">s</string> + <int key="NSKeyEquivModMask">1310720</int> + <int key="NSMnemonicLoc">2147483647</int> + <reference key="NSOnImage" ref="625762401"/> + <reference key="NSMixedImage" ref="315854375"/> + <int key="NSTag">1006</int> </object> <object class="NSMenuItem" id="985746359"> <reference key="NSMenu" ref="709725194"/> @@ -316,6 +331,7 @@ <int key="NSMnemonicLoc">2147483647</int> <reference key="NSOnImage" ref="625762401"/> <reference key="NSMixedImage" ref="315854375"/> + <int key="NSTag">1007</int> </object> <object class="NSMenuItem" id="934534577"> <reference key="NSMenu" ref="709725194"/> @@ -540,6 +556,7 @@ <int key="NSMnemonicLoc">2147483647</int> <reference key="NSOnImage" ref="625762401"/> <reference key="NSMixedImage" ref="315854375"/> + <int key="NSTag">1009</int> </object> <object class="NSMenuItem" id="197057557"> <reference key="NSMenu" ref="709725194"/> @@ -549,6 +566,7 @@ <int key="NSMnemonicLoc">2147483647</int> <reference key="NSOnImage" ref="625762401"/> <reference key="NSMixedImage" ref="315854375"/> + <int key="NSTag">1010</int> </object> </object> </object> @@ -2601,6 +2619,14 @@ </object> <int key="connectionID">964</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">966</int> + </object> </object> <object class="IBMutableOrderedSet" key="objectRecords"> <object class="NSArray" key="orderedObjects"> @@ -2825,8 +2851,9 @@ <reference ref="934534577"/> <reference ref="849728981"/> <reference ref="320151386"/> - <reference ref="256715652"/> <reference ref="759865633"/> + <reference ref="256715652"/> + <reference ref="643339783"/> </object> <reference key="parent" ref="86447006"/> </object> @@ -3869,6 +3896,11 @@ <reference key="object" ref="759865633"/> <reference key="parent" ref="709725194"/> </object> + <object class="IBObjectRecord"> + <int key="objectID">965</int> + <reference key="object" ref="643339783"/> + <reference key="parent" ref="709725194"/> + </object> </object> </object> <object class="NSMutableDictionary" key="flattenedProperties"> @@ -4220,6 +4252,7 @@ <string>956.IBPluginDependency</string> <string>960.IBPluginDependency</string> <string>963.IBPluginDependency</string> + <string>965.IBPluginDependency</string> </object> <object class="NSMutableArray" key="dict.values"> <bool key="EncodedWithXMLCoder">YES</bool> @@ -4323,7 +4356,7 @@ <reference ref="9"/> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <reference ref="9"/> - <string>{{570, 390}, {213, 133}}</string> + <string>{{570, 370}, {213, 133}}</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <reference ref="9"/> <string>{{399, 465}, {213, 93}}</string> @@ -4333,7 +4366,7 @@ <reference ref="9"/> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <reference ref="9"/> - <string>{{783, 430}, {136, 43}}</string> + <string>{{783, 410}, {136, 43}}</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <reference ref="9"/> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> @@ -4490,7 +4523,7 @@ <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <string>{{350, 450}, {220, 253}}</string> + <string>{{350, 430}, {220, 273}}</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <reference ref="9"/> <string>{{180, 535}, {182, 253}}</string> @@ -4618,6 +4651,7 @@ w6gg4oaSIGZhY2FkZV0</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"> @@ -4640,7 +4674,7 @@ w6gg4oaSIGZhY2FkZV0</string> </object> </object> <nil key="sourceID"/> - <int key="maxID">964</int> + <int key="maxID">966</int> </object> <object class="IBClassDescriber" key="IBDocument.Classes"> <object class="NSMutableArray" key="referencedPartialClassDescriptions"> diff --git a/Interfaces/English.lproj/SaveSPFAccessory.xib b/Interfaces/English.lproj/SaveSPFAccessory.xib index 91704d63..579fe9af 100644 --- a/Interfaces/English.lproj/SaveSPFAccessory.xib +++ b/Interfaces/English.lproj/SaveSPFAccessory.xib @@ -8,6 +8,7 @@ <string key="IBDocument.HIToolboxVersion">353.00</string> <object class="NSMutableArray" key="IBDocument.EditedObjectIDs"> <bool key="EncodedWithXMLCoder">YES</bool> + <integer value="1" id="9"/> </object> <object class="NSArray" key="IBDocument.PluginDependencies"> <bool key="EncodedWithXMLCoder">YES</bool> @@ -43,7 +44,6 @@ <int key="NSvFlags">268</int> <string key="NSFrame">{{18, 33}, {177, 18}}</string> <reference key="NSSuperview" ref="920946966"/> - <reference key="NSWindow"/> <bool key="NSEnabled">YES</bool> <object class="NSButtonCell" key="NSCell" id="916395634"> <int key="NSCellFlags">-2080244224</int> @@ -75,7 +75,6 @@ <int key="NSvFlags">268</int> <string key="NSFrame">{{18, 8}, {225, 18}}</string> <reference key="NSSuperview" ref="920946966"/> - <reference key="NSWindow"/> <bool key="NSEnabled">YES</bool> <object class="NSButtonCell" key="NSCell" id="1023988499"> <int key="NSCellFlags">67239424</int> @@ -98,7 +97,6 @@ <int key="NSvFlags">268</int> <string key="NSFrame">{{18, 113}, {139, 18}}</string> <reference key="NSSuperview" ref="920946966"/> - <reference key="NSWindow"/> <bool key="NSEnabled">YES</bool> <object class="NSButtonCell" key="NSCell" id="54680337"> <int key="NSCellFlags">67239424</int> @@ -121,7 +119,6 @@ <int key="NSvFlags">268</int> <string key="NSFrame">{{18, 60}, {176, 18}}</string> <reference key="NSSuperview" ref="920946966"/> - <reference key="NSWindow"/> <bool key="NSEnabled">YES</bool> <object class="NSButtonCell" key="NSCell" id="793938016"> <int key="NSCellFlags">67239424</int> @@ -144,7 +141,6 @@ <int key="NSvFlags">268</int> <string key="NSFrame">{{193, 59}, {138, 19}}</string> <reference key="NSSuperview" ref="920946966"/> - <reference key="NSWindow"/> <bool key="NSEnabled">YES</bool> <object class="NSSecureTextFieldCell" key="NSCell" id="23878540"> <int key="NSCellFlags">343014976</int> @@ -177,7 +173,251 @@ </object> <object class="NSArray" key="NSAllowedInputLocales"> <bool key="EncodedWithXMLCoder">YES</bool> - <string>NSAllRomanInputSourcesLocaleIdentifier</string> + <string>ti_ER</string> + <string>ar_LY</string> + <string>kok_IN</string> + <string>mk_MK</string> + <string>eo</string> + <string>fr_CH</string> + <string>sw</string> + <string>so_ET</string> + <string>gv</string> + <string>ar_BH</string> + <string>hy_AM_REVISED</string> + <string>it_IT</string> + <string>bg_BG</string> + <string>ro</string> + <string>es_HN</string> + <string>en_BE</string> + <string>is</string> + <string>kw_GB</string> + <string>kl</string> + <string>ga_IE</string> + <string>nl_NL</string> + <string>uk</string> + <string>fr_CA</string> + <string>sk_SK</string> + <string>es_AR</string> + <string>en_MT</string> + <string>fr_BE</string> + <string>ca</string> + <string>cs_CZ</string> + <string>fr_FR</string> + <string>en_ZA</string> + <string>sl</string> + <string>fa</string> + <string>so</string> + <string>pt</string> + <string>et_EE</string> + <string>eu_ES</string> + <string>fi</string> + <string>de_CH</string> + <string>or</string> + <string>gu_IN</string> + <string>mt_MT</string> + <string>nb</string> + <string>ms</string> + <string>es_CR</string> + <string>as_IN</string> + <string>ar_SA</string> + <string>am</string> + <string>pl</string> + <string>hu</string> + <string>lv</string> + <string>ar_DZ</string> + <string>ur</string> + <string>pt_PT</string> + <string>eu</string> + <string>so_DJ</string> + <string>de</string> + <string>en_IN</string> + <string>hr_HR</string> + <string>ar_AE</string> + <string>gu</string> + <string>lt</string> + <string>te_IN</string> + <string>ar_KW</string> + <string>sr_Latn</string> + <string>de_AT</string> + <string>en_US</string> + <string>es_PR</string> + <string>pl_PL</string> + <string>uz_Cyrl_UZ</string> + <string>ar_EG</string> + <string>it_CH</string> + <string>nl</string> + <string>haw_US</string> + <string>is_IS</string> + <string>en_IE</string> + <string>kl_GL</string> + <string>ps</string> + <string>zh_Hans_CN</string> + <string>ar</string> + <string>ru_UA</string> + <string>th_TH</string> + <string>fr_LU</string> + <string>uz_Latn_UZ</string> + <string>az</string> + <string>bn_IN</string> + <string>es_MX</string> + <string>kk_KZ</string> + <string>en_US_POSIX</string> + <string>el_GR</string> + <string>he</string> + <string>es_UY</string> + <string>nn_NO</string> + <string>sr</string> + <string>sk</string> + <string>ur_PK</string> + <string>es_PA</string> + <string>sv_FI</string> + <string>zh</string> + <string>es_DO</string> + <string>en_CA</string> + <string>en_BW</string> + <string>de_DE</string> + <string>haw</string> + <string>pa_IN</string> + <string>sq</string> + <string>kw</string> + <string>ga</string> + <string>ml</string> + <string>mt</string> + <string>af_ZA</string> + <string>az_Latn</string> + <string>ko_KR</string> + <string>fa_AF</string> + <string>ps_AF</string> + <string>be_BY</string> + <string>bn</string> + <string>it</string> + <string>sr_Latn_CS</string> + <string>zh_Hans</string> + <string>as</string> + <string>ms_MY</string> + <string>be</string> + <string>sl_SI</string> + <string>fa_IR</string> + <string>es_EC</string> + <string>kok</string> + <string>es_PY</string> + <string>ta_IN</string> + <string>am_ET</string> + <string>es_CO</string> + <string>uz_Latn</string> + <string>el</string> + <string>zh_Hant_MO</string> + <string>kk</string> + <string>kn</string> + <string>zh_Hant</string> + <string>en</string> + <string>es_PE</string> + <string>pt_BR</string> + <string>ar_LB</string> + <string>en_NZ</string> + <string>es_ES</string> + <string>en_HK</string> + <string>es_BO</string> + <string>hu_HU</string> + <string>sr_Cyrl</string> + <string>nb_NO</string> + <string>sv</string> + <string>vi</string> + <string>ti_ET</string> + <string>bg</string> + <string>om</string> + <string>de_LU</string> + <string>en_SG</string> + <string>id_ID</string> + <string>ur_IN</string> + <string>uz</string> + <string>da</string> + <string>ru_RU</string> + <string>es_US</string> + <string>es_VE</string> + <string>ko</string> + <string>ja</string> + <string>af</string> + <string>ar_YE</string> + <string>lt_LT</string> + <string>om_KE</string> + <string>zh_Hans_SG</string> + <string>es_NI</string> + <string>he_IL</string> + <string>en_PK</string> + <string>en_PH</string> + <string>az_Cyrl_AZ</string> + <string>en_AU</string> + <string>az_Cyrl</string> + <string>ta</string> + <string>ar_MA</string> + <string>sw_KE</string> + <string>tr_TR</string> + <string>zh_Hant_HK</string> + <string>en_ZW</string> + <string>de_BE</string> + <string>mk</string> + <string>pa</string> + <string>da_DK</string> + <string>es_GT</string> + <string>es</string> + <string>ar_IQ</string> + <string>az_Latn_AZ</string> + <string>so_SO</string> + <string>lv_LV</string> + <string>mr</string> + <string>te</string> + <string>sq_AL</string> + <string>ml_IN</string> + <string>uk_UA</string> + <string>hi_IN</string> + <string>ca_ES</string> + <string>ar_TN</string> + <string>id</string> + <string>om_ET</string> + <string>cs</string> + <string>fo_FO</string> + <string>hy_AM</string> + <string>en_GB</string> + <string>sr_Cyrl_CS</string> + <string>gl_ES</string> + <string>sw_TZ</string> + <string>ro_RO</string> + <string>cy</string> + <string>fr</string> + <string>ms_BN</string> + <string>so_KE</string> + <string>tr</string> + <string>gl</string> + <string>cy_GB</string> + <string>ar_OM</string> + <string>fo</string> + <string>es_CL</string> + <string>sv_SE</string> + <string>ar_JO</string> + <string>uz_Cyrl</string> + <string>zh_Hant_TW</string> + <string>et</string> + <string>hi</string> + <string>fi_FI</string> + <string>nn</string> + <string>th</string> + <string>ar_SY</string> + <string>ja_JP</string> + <string>gv_GB</string> + <string>hy</string> + <string>en_VI</string> + <string>kn_IN</string> + <string>ti</string> + <string>ar_QA</string> + <string>es_SV</string> + <string>hr</string> + <string>ru</string> + <string>ar_SD</string> + <string>mr_IN</string> + <string>vi_VN</string> + <string>nl_BE</string> + <string>or_IN</string> </object> </object> </object> @@ -186,7 +426,6 @@ <int key="NSvFlags">268</int> <string key="NSFrame">{{40, 86}, {199, 18}}</string> <reference key="NSSuperview" ref="920946966"/> - <reference key="NSWindow"/> <bool key="NSEnabled">YES</bool> <object class="NSButtonCell" key="NSCell" id="739923402"> <int key="NSCellFlags">-1543373312</int> @@ -209,7 +448,6 @@ <int key="NSvFlags">268</int> <string key="NSFrame">{{181, 102}, {163, 33}}</string> <reference key="NSSuperview" ref="920946966"/> - <reference key="NSWindow"/> <bool key="NSEnabled">YES</bool> <object class="NSTextFieldCell" key="NSCell" id="767039719"> <int key="NSCellFlags">67239424</int> @@ -237,14 +475,9 @@ </object> <string key="NSFrameSize">{350, 139}</string> <reference key="NSSuperview"/> - <reference key="NSWindow"/> <string key="NSClassName">NSView</string> </object> <object class="NSUserDefaultsController" id="425440671"> - <object class="NSMutableArray" key="NSDeclaredKeys"> - <bool key="EncodedWithXMLCoder">YES</bool> - <string>_dummy</string> - </object> <bool key="NSSharedInstance">YES</bool> </object> </object> @@ -329,7 +562,7 @@ </object> <object class="NSMutableArray" key="dict.values"> <bool key="EncodedWithXMLCoder">YES</bool> - <integer value="1" id="9"/> + <reference ref="9"/> <reference ref="9"/> <reference ref="9"/> <reference ref="9"/> @@ -341,14 +574,6 @@ <int key="connectionID">42</int> </object> <object class="IBConnectionRecord"> - <object class="IBActionConnection" key="connection"> - <string key="label">saveConnectionAccessoryPasswordButton:</string> - <reference key="source" ref="1001"/> - <reference key="destination" ref="84390822"/> - </object> - <int key="connectionID">43</int> - </object> - <object class="IBConnectionRecord"> <object class="IBOutletConnection" key="connection"> <string key="label">saveConnectionSavePasswordAlert</string> <reference key="source" ref="1001"/> @@ -357,12 +582,44 @@ <int key="connectionID">44</int> </object> <object class="IBConnectionRecord"> + <object class="IBOutletConnection" key="connection"> + <string key="label">nextKeyView</string> + <reference key="source" ref="844460307"/> + <reference key="destination" ref="438732615"/> + </object> + <int key="connectionID">51</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBOutletConnection" key="connection"> + <string key="label">delegate</string> + <reference key="source" ref="844460307"/> + <reference key="destination" ref="1001"/> + </object> + <int key="connectionID">52</int> + </object> + <object class="IBConnectionRecord"> <object class="IBActionConnection" key="connection"> - <string key="label">saveConnectionAccessoryPasswordButton:</string> + <string key="label">validateSaveConnectionAccessory:</string> <reference key="source" ref="1001"/> <reference key="destination" ref="251605173"/> </object> - <int key="connectionID">45</int> + <int key="connectionID">54</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBOutletConnection" key="connection"> + <string key="label">saveConnectionAccessory</string> + <reference key="source" ref="1004"/> + <reference key="destination" ref="920946966"/> + </object> + <int key="connectionID">55</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBActionConnection" key="connection"> + <string key="label">validateSaveConnectionAccessory:</string> + <reference key="source" ref="1001"/> + <reference key="destination" ref="84390822"/> + </object> + <int key="connectionID">57</int> </object> </object> <object class="IBMutableOrderedSet" key="objectRecords"> @@ -411,15 +668,6 @@ <string key="objectName">Save SPF Accessory</string> </object> <object class="IBObjectRecord"> - <int key="objectID">2</int> - <reference key="object" ref="844460307"/> - <object class="NSMutableArray" key="children"> - <bool key="EncodedWithXMLCoder">YES</bool> - <reference ref="23878540"/> - </object> - <reference key="parent" ref="920946966"/> - </object> - <object class="IBObjectRecord"> <int key="objectID">3</int> <reference key="object" ref="251605173"/> <object class="NSMutableArray" key="children"> @@ -462,11 +710,6 @@ <reference key="parent" ref="251605173"/> </object> <object class="IBObjectRecord"> - <int key="objectID">9</int> - <reference key="object" ref="23878540"/> - <reference key="parent" ref="844460307"/> - </object> - <object class="IBObjectRecord"> <int key="objectID">13</int> <reference key="object" ref="216845609"/> <object class="NSMutableArray" key="children"> @@ -513,6 +756,20 @@ <reference key="object" ref="425440671"/> <reference key="parent" ref="1002"/> </object> + <object class="IBObjectRecord"> + <int key="objectID">2</int> + <reference key="object" ref="844460307"/> + <object class="NSMutableArray" key="children"> + <bool key="EncodedWithXMLCoder">YES</bool> + <reference ref="23878540"/> + </object> + <reference key="parent" ref="920946966"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">9</int> + <reference key="object" ref="23878540"/> + <reference key="parent" ref="844460307"/> + </object> </object> </object> <object class="NSMutableDictionary" key="flattenedProperties"> @@ -619,7 +876,7 @@ </object> </object> <nil key="sourceID"/> - <int key="maxID">45</int> + <int key="maxID">57</int> </object> <object class="IBClassDescriber" key="IBDocument.Classes"> <object class="NSMutableArray" key="referencedPartialClassDescriptions"> @@ -656,6 +913,7 @@ </object> <object class="IBPartialClassDescription"> <string key="className">NSView</string> + <string key="superclassName">NSResponder</string> <object class="IBClassDescriptionSource" key="sourceIdentifier"> <string key="majorKey">IBUserSource</string> <string key="minorKey"/> @@ -692,7 +950,6 @@ <string>optimizeTable:</string> <string>removeDatabase:</string> <string>repairTable:</string> - <string>saveConnectionAccessoryPasswordButton:</string> <string>saveConnectionSheet:</string> <string>saveServerVariables:</string> <string>setDatabases:</string> @@ -700,6 +957,7 @@ <string>showMySQLHelp:</string> <string>showUserManager:</string> <string>showVariables:</string> + <string>validateSaveConnectionAccessory:</string> <string>viewContent:</string> <string>viewQuery:</string> <string>viewRelations:</string> diff --git a/Source/CustomQuery.h b/Source/CustomQuery.h index 0e6d2bc6..e6c9ad43 100644 --- a/Source/CustomQuery.h +++ b/Source/CustomQuery.h @@ -36,10 +36,10 @@ @class SPQueryFavoriteManager; @interface CustomQuery : NSObject -{ +{ IBOutlet id tableDocumentInstance; IBOutlet id tableWindow; - + IBOutlet id queryFavoritesButton; IBOutlet NSMenuItem *queryFavoritesSearchMenuItem; IBOutlet NSMenuItem *queryFavoritesSaveAsMenuItem; @@ -49,7 +49,7 @@ IBOutlet NSMenuItem *queryHistorySearchMenuItem; IBOutlet id queryHistorySearchFieldView; IBOutlet NSSearchField *queryHistorySearchField; - + IBOutlet CMTextView *textView; IBOutlet CMCopyTable *customQueryView; IBOutlet id errorText; @@ -76,43 +76,47 @@ IBOutlet NSWindow *queryFavoritesSheet; IBOutlet NSButton *saveQueryFavoriteButton; IBOutlet NSTextField *queryFavoriteNameTextField; - + IBOutlet NSWindow *helpWebViewWindow; IBOutlet WebView *helpWebView; IBOutlet NSSearchField *helpSearchField; IBOutlet NSSearchFieldCell *helpSearchFieldCell; IBOutlet NSSegmentedControl *helpNavigator; IBOutlet NSSegmentedControl *helpTargetSelector; - + SPQueryFavoriteManager *favoritesManager; NSUserDefaults *prefs; MCPConnection *mySQLConnection; - + NSString *usedQuery; NSRange currentQueryRange; NSArray *currentQueryRanges; BOOL hasBackgroundAttribute; NSString *mySQLversion; - + int queryStartPosition; - + int helpTarget; WebHistory *helpHistory; NSString *helpHTMLTemplate; - + NSMutableArray *fullResult; NSArray *cqColumnDefinition; NSString *lastExecutedQuery; - + BOOL tableReloadAfterEditing; BOOL queryIsTableSorter; BOOL isDesc; NSNumber *sortField; NSString *fieldIDQueryString; - + unsigned int numberOfQueries; + + NSMutableArray *localFavorites; + NSMutableArray *localHistoryItems; + } // IBAction methods @@ -143,6 +147,8 @@ // Accessors - (NSArray *)currentResult; - (void)processResultIntoDataStorage:(MCPStreamingResult *)theResult; +- (NSArray *)localFavorites; +- (NSArray *)localHistoryItems; // MySQL Help - (NSString *)getHTMLformattedMySQLHelpFor:(NSString *)aString; diff --git a/Source/CustomQuery.m b/Source/CustomQuery.m index 2088642f..441144aa 100644 --- a/Source/CustomQuery.m +++ b/Source/CustomQuery.m @@ -1057,6 +1057,22 @@ return currentResult; } +/* + * Return the document-based favourites + */ +- (NSArray *)localFavorites +{ + return localFavorites; +} + +/* + * Return the document-based history items + */ +- (NSArray *)localHistoryItems +{ + return localHistoryItems; +} + #pragma mark - #pragma mark Additional methods @@ -2559,6 +2575,10 @@ // init tableView's data source fullResult = [[NSMutableArray alloc] init]; + // init local favorite and history item array + localHistoryItems = [[NSMutableArray alloc] init]; + localFavorites = [[NSMutableArray alloc] init]; + prefs = [NSUserDefaults standardUserDefaults]; } @@ -2607,7 +2627,8 @@ [usedQuery release]; [fullResult release]; [favoritesManager release]; - + if (localFavorites) [localFavorites release]; + if (localHistoryItems) [localHistoryItems release]; if (sortField) [sortField release]; [super dealloc]; diff --git a/Source/TableDocument.h b/Source/TableDocument.h index 0ad2638f..fc99bf23 100644 --- a/Source/TableDocument.h +++ b/Source/TableDocument.h @@ -143,6 +143,8 @@ enum sp_current_query_mode NSString *queryEditorInitString; NSDictionary *spfSession; + NSMutableDictionary *spfDocData; + } - (NSString *)getHTMLforPrint; @@ -200,8 +202,8 @@ enum sp_current_query_mode - (NSWindow *)getCreateTableSyntaxWindow; - (void)refreshCurrentDatabase; - (void)saveConnectionPanelDidEnd:(NSSavePanel *)panel returnCode:(int)returnCode contextInfo:(void *)contextInfo; -- (IBAction)saveConnectionAccessoryPasswordButton:(id)sender; -- (void)saveSPFtoFile:(NSString *)fileName; +- (IBAction)validateSaveConnectionAccessory:(id)sender; +- (void)saveSPFtoFile:(NSString *)fileName saveInBackground:(BOOL)saveInBackground saveOnlyPreferences:(BOOL)saveOnlyPreferences; - (IBAction)closePasswordSheet:(id)sender; // Getter methods diff --git a/Source/TableDocument.m b/Source/TableDocument.m index c58c21bf..946031a7 100644 --- a/Source/TableDocument.m +++ b/Source/TableDocument.m @@ -85,11 +85,9 @@ prefs = [NSUserDefaults standardUserDefaults]; queryEditorInitString = nil; - [saveConnectionEncryptString setStringValue:@""]; - saveConnectionAccessory = nil; - saveConnectionAutoConnect = nil; spfSession = nil; + spfDocData = [[NSMutableDictionary alloc] init]; } @@ -111,7 +109,7 @@ topLeftPoint.y += previousFrame.size.height; [tableWindow setFrameTopLeftPoint:[tableWindow cascadeTopLeftFromPoint:topLeftPoint]]; - // iTry to check if new frame fits into the screen + // Try to check if new frame fits into the screen NSRect screenFrame = [[NSScreen mainScreen] frame]; NSScreen* candidate; for(candidate in [NSScreen screens]) @@ -181,10 +179,6 @@ if (![NSBundle loadNibNamed:@"ConnectionErrorDialog" owner:self]) { NSLog(@"Connection error dialog could not be loaded; connection failure handling will not function correctly."); } - if(![NSBundle loadNibNamed:@"SaveSPFAccessory" owner:self]) { - NSLog(@"SaveSPFAccessory accessory dialog could not be loaded."); - return; - } } - (void)initWithConnectionFile:(NSString *)path @@ -202,7 +196,7 @@ int connectionType; // Inform about the data source in the window title bar - [tableWindow setTitle:[NSString stringWithFormat:NSLocalizedString(@"‘%@’ – Connecting…",@"‘%@’ – Connecting…"), [path lastPathComponent]]]; + [tableWindow setTitle:[self displayName]]; // Clean fields [connectionController setName:@""]; @@ -336,7 +330,6 @@ return; } - encryptpw = nil; if(![data objectForKey:@"connection"]) { NSAlert *alert = [NSAlert alertWithMessageText:[NSString stringWithFormat:NSLocalizedString(@"Error while reading connection data file", @"error while reading connection data file")] @@ -351,6 +344,13 @@ return; } + [spfDocData setObject:[NSNumber numberWithBool:NO] forKey:@"encrypted"]; + if(encryptpw != nil) { + [spfDocData setObject:[NSNumber numberWithBool:YES] forKey:@"encrypted"]; + [spfDocData setObject:encryptpw forKey:@"e_string"]; + } + encryptpw = nil; + connection = [NSDictionary dictionaryWithDictionary:[data objectForKey:@"connection"]]; if([connection objectForKey:@"type"]) { @@ -394,17 +394,26 @@ if([connection objectForKey:@"database"]) [connectionController setDatabase:[connection objectForKey:@"database"]]; - if([data objectForKey:@"session"]) + if([data objectForKey:@"session"]) { spfSession = [[NSDictionary dictionaryWithDictionary:[data objectForKey:@"session"]] retain]; + [spfDocData setObject:[NSNumber numberWithBool:YES] forKey:@"include_session"]; + } + [spfDocData setObject:[NSNumber numberWithBool:YES] forKey:@"save_password"]; if(![connection objectForKey:@"password"]) { // TODO How to set the focus to standardPasswordField in the connection nib? // [[connectionController valueForKeyPath:@"standardPasswordField"] selectText:connectionController]; + [spfDocData setObject:[NSNumber numberWithBool:NO] forKey:@"save_password"]; return; } + + [self setFileURL:[NSURL URLWithString:path]]; - if([connection objectForKey:@"auto_connect"] && [[connection valueForKey:@"auto_connect"] boolValue]) + [spfDocData setObject:[NSNumber numberWithBool:NO] forKey:@"auto_connect"]; + if([spf objectForKey:@"auto_connect"] && [[spf valueForKey:@"auto_connect"] boolValue]) { + [spfDocData setObject:[NSNumber numberWithBool:YES] forKey:@"auto_connect"]; [connectionController initiateConnection:self]; + } } @@ -459,9 +468,12 @@ [[tablesListInstance valueForKeyPath:@"tablesListView"] scrollRowToVisible:[tables indexOfObject:[spfSession objectForKey:@"selectedTable"]]]; + [tableWindow setTitle:[self displayName]]; + // dealloc spfSession data [spfSession release]; spfSession = nil; + } /* @@ -541,7 +553,7 @@ // Set the cutom query editor's MySQL version [customQueryInstance setMySQLversion:mySQLVersion]; - [tableWindow setTitle:[NSString stringWithFormat:@"(MySQL %@) %@/%@", mySQLVersion, [self name], ([self database]?[self database]:@"")]]; + [tableWindow setTitle:[self displayName]]; [self viewStructure:self]; // Connected Growl notification @@ -551,7 +563,9 @@ // Init Custom Query editor with the stored queries in a spf file if given. + [spfDocData setObject:[NSNumber numberWithBool:NO] forKey:@"save_editor_content"]; if(spfSession != nil && [spfSession objectForKey:@"queries"]) { + [spfDocData setObject:[NSNumber numberWithBool:YES] forKey:@"save_editor_content"]; if([[spfSession objectForKey:@"queries"] isKindOfClass:[NSData class]]) { NSString *q = [[NSString alloc] initWithData:[[spfSession objectForKey:@"queries"] decompress] encoding:NSUTF8StringEncoding]; [self initQueryEditorWithString:q]; @@ -806,7 +820,8 @@ selectedDatabase = [[NSString alloc] initWithString:[chooseDatabaseButton titleOfSelectedItem]]; [tablesListInstance setConnection:mySQLConnection]; [tableDumpInstance setConnection:mySQLConnection]; - [tableWindow setTitle:[NSString stringWithFormat:@"(MySQL %@) %@/%@", mySQLVersion, [self name], [self database]]]; + + [tableWindow setTitle:[self displayName]]; // Add a history entry if (!historyStateChanging) { @@ -888,7 +903,8 @@ [self setDatabases:self]; [tablesListInstance setConnection:mySQLConnection]; [tableDumpInstance setConnection:mySQLConnection]; - [tableWindow setTitle:[NSString stringWithFormat:@"(MySQL %@) %@/%@", mySQLVersion, [self name], selectedDatabase]]; + + [tableWindow setTitle:[self displayName]]; } /** @@ -963,7 +979,8 @@ [self setDatabases:self]; [tablesListInstance setConnection:mySQLConnection]; [tableDumpInstance setConnection:mySQLConnection]; - [tableWindow setTitle:[NSString stringWithFormat:@"(MySQL %@) %@/", mySQLVersion, [self name]]]; + + [tableWindow setTitle:[self displayName]]; } } @@ -1003,12 +1020,12 @@ if (selectedDatabase) [selectedDatabase release], selectedDatabase = nil; selectedDatabase = [[NSString alloc] initWithString:dbName]; [chooseDatabaseButton selectItemWithTitle:selectedDatabase]; - [tableWindow setTitle:[NSString stringWithFormat:@"(MySQL %@) %@/%@", mySQLVersion, [self name], selectedDatabase]]; + [tableWindow setTitle:[self displayName]]; } } else { if (selectedDatabase) [selectedDatabase release], selectedDatabase = nil; [chooseDatabaseButton selectItemAtIndex:0]; - [tableWindow setTitle:[NSString stringWithFormat:@"(MySQL %@) %@/", mySQLVersion, [self name]]]; + [tableWindow setTitle:[self displayName]]; } } @@ -1895,6 +1912,10 @@ */ - (void)applicationWillTerminate:(NSNotification *)notification { + // Auto-save spf file based connection + if([self fileURL] && [[[self fileURL] absoluteString] length]) + [self saveSPFtoFile:[[self fileURL] absoluteString] saveInBackground:YES saveOnlyPreferences:YES]; + [tablesListInstance selectionShouldChangeInTableView:nil]; } @@ -1915,7 +1936,8 @@ [panel setAllowsOtherFileTypes:NO]; [panel setCanSelectHiddenExtension:YES]; - if( [sender tag] == 0 ) { + // Save Query… + if( [sender tag] == 1006 ) { // Save the editor's content as SQL file [panel setAccessoryView:[SPEncodingPopupAccessory encodingAccessory:[prefs integerForKey:@"lastSqlFileEncoding"] @@ -1938,21 +1960,53 @@ [encodingPopUp setEnabled:YES]; - } else if([sender tag] == 1){ + // Save As… or Save + } else if([sender tag] == 1005 || [sender tag] == 1004) { + + // If Save was invoked check for fileURL and save the spf file without save panel + // otherwise ask for file name + if([sender tag] == 1004 && [[[self fileURL] absoluteString] length]) { + [self saveSPFtoFile:[[self fileURL] absoluteString] saveInBackground:YES saveOnlyPreferences:NO]; + return; + } + + // Load accessory nib each time + if(![NSBundle loadNibNamed:@"SaveSPFAccessory" owner:self]) { + NSLog(@"SaveSPFAccessory accessory dialog could not be loaded."); + return; + } // Save current session (open connection windows as SPF file) [panel setAllowedFileTypes:[NSArray arrayWithObjects:@"spf", nil]]; - [saveConnectionEncryptString setStringValue:@""]; + //Restore accessory view settings if possible + if([spfDocData objectForKey:@"save_password"]) + [saveConnectionSavePassword setState:[[spfDocData objectForKey:@"save_password"] boolValue]]; + if([spfDocData objectForKey:@"auto_connect"]) + [saveConnectionAutoConnect setState:[[spfDocData objectForKey:@"auto_connect"] boolValue]]; + if([spfDocData objectForKey:@"encrypted"]) + [saveConnectionEncrypt setState:[[spfDocData objectForKey:@"encrypted"] boolValue]]; + if([spfDocData objectForKey:@"include_session"]) + [saveConnectionIncludeData setState:[[spfDocData objectForKey:@"include_session"] boolValue]]; + if([spfDocData objectForKey:@"include_session"]) + [saveConnectionIncludeQuery setState:[[spfDocData objectForKey:@"save_editor_content"] boolValue]]; + [saveConnectionIncludeQuery setEnabled:([[[[customQueryInstance valueForKeyPath:@"textView"] textStorage] string] length])]; // Update accessory button states - [self saveConnectionAccessoryPasswordButton:nil]; - + [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]; - filename = [NSString stringWithFormat:@"%@", [self name]]; + + // Set file name + if([[[self fileURL] absoluteString] length]) + filename = [[[self fileURL] absoluteString] lastPathComponent]; + else + filename = [NSString stringWithFormat:@"%@", [self name]]; + contextInfo = @"saveSPFfile"; } else { @@ -1969,11 +2023,13 @@ /** * Control the save connection panel's accessory view */ -- (IBAction)saveConnectionAccessoryPasswordButton:(id)sender +- (IBAction)validateSaveConnectionAccessory:(id)sender { [saveConnectionAutoConnect setEnabled:([saveConnectionSavePassword state] == NSOnState)]; [saveConnectionSavePasswordAlert setHidden:([saveConnectionSavePassword state] == NSOffState)]; + + // If user checks the Encrypt check box set focus to password field if(sender == saveConnectionEncrypt && [saveConnectionEncrypt state] == NSOnState) [saveConnectionEncryptString selectText:sender]; @@ -1981,18 +2037,8 @@ if(sender == saveConnectionEncrypt && [saveConnectionEncrypt state] == NSOffState) { // [saveConnectionEncryptString setStringValue:[saveConnectionEncryptString stringValue]]; // TODO how can one make it better ? - [saveConnectionEncryptString setHidden:YES]; - [saveConnectionEncryptString setHidden:NO]; - } - - // Enforce to clear the password string after invoking NSSavePanel - // TODO Why I cannot set it in saveConnectionSheet ? - if(sender == NULL) { - [saveConnectionEncryptString selectText:sender]; - [saveConnectionEncryptString setHidden:YES]; - [saveConnectionEncryptString setHidden:NO]; + [[saveConnectionEncryptString window] makeFirstResponder:[[saveConnectionEncryptString window] initialFirstResponder]]; } - } @@ -2026,154 +2072,83 @@ // Save connection and session as SPF file else if(contextInfo == @"saveSPFfile") { - // Abort editing of saveConnectionEncryptString - // TODO How can one make it better? - [saveConnectionEncryptString abortEditing]; - [saveConnectionEncryptString setStringValue:[saveConnectionEncryptString stringValue]]; + // Save changes of saveConnectionEncryptString + [[saveConnectionEncryptString window] makeFirstResponder:[[saveConnectionEncryptString window] initialFirstResponder]]; - [self saveSPFtoFile:fileName]; + [self saveSPFtoFile:fileName saveInBackground:NO saveOnlyPreferences:NO]; } } } -- (void)saveSPFtoFile:(NSString *)fileName +- (void)saveSPFtoFile:(NSString *)fileName saveInBackground:(BOOL)saveInBackground saveOnlyPreferences:(BOOL)saveOnlyPreferences { - NSString *aString; - - NSMutableDictionary *spfdata = [NSMutableDictionary dictionary]; - NSMutableDictionary *connection = [NSMutableDictionary dictionary]; - NSMutableDictionary *session = nil; - NSMutableDictionary *data = [NSMutableDictionary dictionary]; - - NSIndexSet *contentSelectedIndexSet = [tableContentInstance selectedRowIndexes]; - - [spfdata setObject:[NSNumber numberWithInt:1] forKey:@"version"]; - [spfdata setObject:@"connection" forKey:@"format"]; - if([saveConnectionEncrypt isEnabled]) - [spfdata setObject:[NSNumber numberWithBool:([saveConnectionEncrypt state]==NSOnState) ? YES : NO ] forKey:@"encrypted"]; - - if([saveConnectionSavePassword state] == NSOnState) - [connection setObject:[NSNumber numberWithBool:([saveConnectionAutoConnect state]==NSOnState) ? YES : NO ] forKey:@"auto_connect"]; - - [connection setObject:[self name] forKey:@"name"]; - [connection setObject:[self host] forKey:@"host"]; - [connection setObject:[self user] forKey:@"user"]; + // Do not save if no connection is/was available + if(saveInBackground && ([self mySQLVersion] == nil || ![[self mySQLVersion] length])) + return; - switch([connectionController type]) { - case SP_CONNECTION_TCPIP: - aString = @"SP_CONNECTION_TCPIP"; - break; - case SP_CONNECTION_SOCKET: - aString = @"SP_CONNECTION_SOCKET"; - [connection setObject:[connectionController socket] forKey:@"socket"]; - break; - case SP_CONNECTION_SSHTUNNEL: - aString = @"SP_CONNECTION_SSHTUNNEL"; - [connection setObject:[connectionController sshHost] forKey:@"ssh_host"]; - [connection setObject:[connectionController sshUser] forKey:@"ssh_user"]; - if([connectionController port] && [[connectionController port] length]) - [connection setObject:[NSNumber numberWithInt:[[connectionController sshPort] intValue]] forKey:@"ssh_port"]; - break; - default: - aString = @"SP_CONNECTION_TCPIP"; - } - [connection setObject:aString forKey:@"type"]; + NSMutableDictionary *spfDocData_temp = [NSMutableDictionary dictionary]; + + // Store save panel settings or take them from spfDocData + if(!saveInBackground) { + [spfDocData_temp setObject:[NSNumber numberWithBool:([saveConnectionEncrypt state]==NSOnState) ? YES : NO ] forKey:@"encrypted"]; + if([[spfDocData_temp objectForKey:@"encrypted"] boolValue]) + [spfDocData_temp setObject:[saveConnectionEncryptString stringValue] forKey:@"e_string"]; + [spfDocData_temp setObject:[NSNumber numberWithBool:([saveConnectionAutoConnect state]==NSOnState) ? YES : NO ] forKey:@"auto_connect"]; + [spfDocData_temp setObject:[NSNumber numberWithBool:([saveConnectionSavePassword state]==NSOnState) ? YES : NO ] forKey:@"save_password"]; + [spfDocData_temp setObject:[NSNumber numberWithBool:([saveConnectionIncludeData state]==NSOnState) ? YES : NO ] forKey:@"include_session"]; + [spfDocData_temp setObject:[NSNumber numberWithBool:NO] forKey:@"save_editor_content"]; + if([[[[customQueryInstance valueForKeyPath:@"textView"] textStorage] string] length]) + [spfDocData_temp setObject:[NSNumber numberWithBool:([saveConnectionIncludeQuery state]==NSOnState) ? YES : NO ] forKey:@"save_editor_content"]; + } else { + [spfDocData_temp addEntriesFromDictionary:spfDocData]; + } - if([saveConnectionSavePassword state] == NSOnState) { - NSString *pw = [self keychainPasswordForConnection:nil]; - if(![pw length]) pw = [connectionController password]; - [connection setObject:pw forKey:@"password"]; - if([connectionController type] == SP_CONNECTION_SSHTUNNEL) - [connection setObject:[connectionController sshPassword] forKey:@"ssh_password"]; - } - - if([connectionController port] && [[connectionController port] length]) - [connection setObject:[NSNumber numberWithInt:[[connectionController port] intValue]] forKey:@"port"]; + // Update only query favourites, history, etc. by reading the file again + if(saveOnlyPreferences) { + + // Check for save file URL + // TODO maybe alert ? + if(![[[self fileURL] absoluteString] length]) return; + + NSError *readError = nil; + NSString *convError = nil; + NSPropertyListFormat format; + NSMutableDictionary *spf = [[NSMutableDictionary alloc] init]; + + NSData *pData = [NSData dataWithContentsOfFile:[[self fileURL] absoluteString] options:NSUncachedRead error:&readError]; - if([[self database] length]) - [connection setObject:[self database] forKey:@"database"]; + [spf addEntriesFromDictionary:[NSPropertyListSerialization propertyListFromData:pData + mutabilityOption:NSPropertyListImmutable format:&format errorDescription:&convError]]; - // Include session data like selected table, view etc. ? - if([saveConnectionIncludeData state] == NSOnState) { - - session = [NSMutableDictionary dictionary]; - - if([[self table] length]) - [session setObject:[self table] forKey:@"table"]; - if([tableContentInstance sortColumnName]) - [session setObject:[tableContentInstance sortColumnName] forKey:@"contentSortCol"]; - - switch([spHistoryControllerInstance currentlySelectedView]){ - case SP_VIEW_STRUCTURE: - aString = @"SP_VIEW_STRUCTURE"; - break; - case SP_VIEW_CONTENT: - aString = @"SP_VIEW_CONTENT"; - break; - case SP_VIEW_CUSTOMQUERY: - aString = @"SP_VIEW_CUSTOMQUERY"; - break; - case SP_VIEW_STATUS: - aString = @"SP_VIEW_STATUS"; - break; - case SP_VIEW_RELATIONS: - aString = @"SP_VIEW_RELATIONS"; - break; - default: - aString = @"SP_VIEW_STRUCTURE"; - } - [session setObject:aString forKey:@"view"]; - - [session setObject:[NSNumber numberWithBool:[tableContentInstance sortColumnIsAscending]] forKey:@"contentSortColIsAsc"]; - [session setObject:[NSNumber numberWithInt:[tableContentInstance limitStart]] forKey:@"contentLimitStartPosition"]; - [session setObject:NSStringFromRect([tableContentInstance viewport]) forKey:@"contentViewport"]; - if([tableContentInstance filterSettings]) - [session setObject:[tableContentInstance filterSettings] forKey:@"contentFilter"]; - - if (contentSelectedIndexSet && [contentSelectedIndexSet count]) { - NSMutableArray *indices = [NSMutableArray array]; - unsigned indexBuffer[[contentSelectedIndexSet count]]; - unsigned limit = [contentSelectedIndexSet getIndexes:indexBuffer maxCount:[contentSelectedIndexSet count] inIndexRange:NULL]; - unsigned idx; - for (idx = 0; idx < limit; idx++) { - [indices addObject:[NSNumber numberWithInt:indexBuffer[idx]]]; - } - [session setObject:indices forKey:@"contentSelectedIndexSet"]; - } - } + if(!spf || ![spf count] || readError != nil || [convError length] || !(format == NSPropertyListXMLFormat_v1_0 || format == NSPropertyListBinaryFormat_v1_0)) { + NSAlert *alert = [NSAlert alertWithMessageText:[NSString stringWithFormat:NSLocalizedString(@"Error while reading connection data file", @"error while reading connection data file")] + defaultButton:NSLocalizedString(@"OK", @"OK button") + alternateButton:nil + otherButton:nil + informativeTextWithFormat:NSLocalizedString(@"Connection data file couldn't be read.", @"error while reading connection data file")]; - if([[[[customQueryInstance valueForKeyPath:@"textView"] textStorage] string] length] - && [saveConnectionIncludeQuery state] == NSOnState) { - - if(session == nil) - session = [NSMutableDictionary dictionary]; - - if([[[[customQueryInstance valueForKeyPath:@"textView"] textStorage] string] length] > 50000) - [session setObject:[[[[[customQueryInstance valueForKeyPath:@"textView"] textStorage] string] dataUsingEncoding:NSUTF8StringEncoding] compress] forKey:@"queries"]; - else - [session setObject:[[[customQueryInstance valueForKeyPath:@"textView"] textStorage] string] forKey:@"queries"]; + [alert setAlertStyle:NSCriticalAlertStyle]; + [alert runModal]; + [self close]; + return; } - [data setObject:connection forKey:@"connection"]; - if(session != nil) - [data setObject:session forKey:@"session"]; - - if([saveConnectionEncrypt state] == NSOffState) { - [spfdata setObject:data forKey:@"data"]; - } else { - NSMutableData *encryptdata = [[[NSMutableData alloc] init] autorelease]; - NSKeyedArchiver *archiver = [[[NSKeyedArchiver alloc] initForWritingWithMutableData:encryptdata] autorelease]; - [archiver encodeObject:data forKey:@"data"]; - [archiver finishEncoding]; - [spfdata setObject:[encryptdata dataEncryptedWithPassword:[saveConnectionEncryptString stringValue]] forKey:@"data"]; + // For dispatching later + if(![[spf objectForKey:@"format"] isEqualToString:@"connection"]) { + NSLog(@"SPF file format is not 'connection'."); + [self close]; + return; } - // NSLog(@"%@", spfdata); + // Update the keys + [spf setObject:[customQueryInstance localFavorites] forKey:@"queryFavorites"]; + [spf setObject:[customQueryInstance localHistoryItems] forKey:@"queryHistory"]; + // Save it again NSString *err = nil; - NSData *plist = [NSPropertyListSerialization dataFromPropertyList:spfdata + NSData *plist = [NSPropertyListSerialization dataFromPropertyList:spf format:NSPropertyListXMLFormat_v1_0 errorDescription:&err]; @@ -2190,12 +2165,185 @@ } NSError *error = nil; - [plist writeToFile:fileName options:NSAtomicWrite error:&error]; + [plist writeToFile:[[self fileURL] absoluteString] options:NSAtomicWrite error:&error]; if(error != nil){ NSAlert *errorAlert = [NSAlert alertWithError:error]; [errorAlert runModal]; } + return; + + } + + NSString *aString; + + NSMutableDictionary *spfdata = [NSMutableDictionary dictionary]; + NSMutableDictionary *connection = [NSMutableDictionary dictionary]; + NSMutableDictionary *session = nil; + NSMutableDictionary *data = [NSMutableDictionary dictionary]; + + NSIndexSet *contentSelectedIndexSet = [tableContentInstance selectedRowIndexes]; + + [spfdata setObject:[NSNumber numberWithInt:1] forKey:@"version"]; + [spfdata setObject:@"connection" forKey:@"format"]; + [spfdata setObject:@"mysql" forKey:@"rdbms_type"]; + [spfdata setObject:[self mySQLVersion] forKey:@"rdbms_version"]; + + // Store the preferences + [spfdata setObject:[customQueryInstance localFavorites] forKey:@"queryFavorites"]; + [spfdata setObject:[customQueryInstance localHistoryItems] forKey:@"queryHistory"]; + + [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"]; + + [connection setObject:[self name] forKey:@"name"]; + [connection setObject:[self host] forKey:@"host"]; + [connection setObject:[self user] forKey:@"user"]; + + switch([connectionController type]) { + case SP_CONNECTION_TCPIP: + aString = @"SP_CONNECTION_TCPIP"; + break; + case SP_CONNECTION_SOCKET: + aString = @"SP_CONNECTION_SOCKET"; + [connection setObject:[connectionController socket] forKey:@"socket"]; + break; + case SP_CONNECTION_SSHTUNNEL: + aString = @"SP_CONNECTION_SSHTUNNEL"; + [connection setObject:[connectionController sshHost] forKey:@"ssh_host"]; + [connection setObject:[connectionController sshUser] forKey:@"ssh_user"]; + if([connectionController port] && [[connectionController port] length]) + [connection setObject:[NSNumber numberWithInt:[[connectionController sshPort] intValue]] forKey:@"ssh_port"]; + break; + default: + aString = @"SP_CONNECTION_TCPIP"; + } + [connection setObject:aString forKey:@"type"]; + + + if([[spfDocData_temp objectForKey:@"save_password"] boolValue]) { + NSString *pw = [self keychainPasswordForConnection:nil]; + if(![pw length]) pw = [connectionController password]; + [connection setObject:pw forKey:@"password"]; + if([connectionController type] == SP_CONNECTION_SSHTUNNEL) + [connection setObject:[connectionController sshPassword] forKey:@"ssh_password"]; + } + + if([connectionController port] && [[connectionController port] length]) + [connection setObject:[NSNumber numberWithInt:[[connectionController port] intValue]] forKey:@"port"]; + + if([[self database] length]) + [connection setObject:[self database] forKey:@"database"]; + + // Include session data like selected table, view etc. ? + if([[spfDocData_temp objectForKey:@"include_session"] boolValue]) { + + session = [NSMutableDictionary dictionary]; + + if([[self table] length]) + [session setObject:[self table] forKey:@"table"]; + if([tableContentInstance sortColumnName]) + [session setObject:[tableContentInstance sortColumnName] forKey:@"contentSortCol"]; + + switch([spHistoryControllerInstance currentlySelectedView]){ + case SP_VIEW_STRUCTURE: + aString = @"SP_VIEW_STRUCTURE"; + break; + case SP_VIEW_CONTENT: + aString = @"SP_VIEW_CONTENT"; + break; + case SP_VIEW_CUSTOMQUERY: + aString = @"SP_VIEW_CUSTOMQUERY"; + break; + case SP_VIEW_STATUS: + aString = @"SP_VIEW_STATUS"; + break; + case SP_VIEW_RELATIONS: + aString = @"SP_VIEW_RELATIONS"; + break; + default: + aString = @"SP_VIEW_STRUCTURE"; + } + [session setObject:aString forKey:@"view"]; + + [session setObject:[NSNumber numberWithBool:[tableContentInstance sortColumnIsAscending]] forKey:@"contentSortColIsAsc"]; + [session setObject:[NSNumber numberWithInt:[tableContentInstance limitStart]] forKey:@"contentLimitStartPosition"]; + [session setObject:NSStringFromRect([tableContentInstance viewport]) forKey:@"contentViewport"]; + if([tableContentInstance filterSettings]) + [session setObject:[tableContentInstance filterSettings] forKey:@"contentFilter"]; + + if (contentSelectedIndexSet && [contentSelectedIndexSet count]) { + NSMutableArray *indices = [NSMutableArray array]; + unsigned indexBuffer[[contentSelectedIndexSet count]]; + unsigned limit = [contentSelectedIndexSet getIndexes:indexBuffer maxCount:[contentSelectedIndexSet count] inIndexRange:NULL]; + unsigned idx; + for (idx = 0; idx < limit; idx++) { + [indices addObject:[NSNumber numberWithInt:indexBuffer[idx]]]; + } + [session setObject:indices forKey:@"contentSelectedIndexSet"]; + } + } + + if([[spfDocData_temp objectForKey:@"save_editor_content"] boolValue]) { + if(session == nil) + session = [NSMutableDictionary dictionary]; + + if([[[[customQueryInstance valueForKeyPath:@"textView"] textStorage] string] length] > 50000) + [session setObject:[[[[[customQueryInstance valueForKeyPath:@"textView"] textStorage] string] dataUsingEncoding:NSUTF8StringEncoding] compress] forKey:@"queries"]; + else + [session setObject:[[[customQueryInstance valueForKeyPath:@"textView"] textStorage] string] forKey:@"queries"]; + } + + [data setObject:connection forKey:@"connection"]; + if(session != nil) + [data setObject:session forKey:@"session"]; + + if(![[spfDocData_temp objectForKey:@"encrypted"] boolValue]) { + [spfdata setObject:data forKey:@"data"]; + } else { + NSMutableData *encryptdata = [[[NSMutableData alloc] init] autorelease]; + NSKeyedArchiver *archiver = [[[NSKeyedArchiver alloc] initForWritingWithMutableData:encryptdata] autorelease]; + [archiver encodeObject:data forKey:@"data"]; + [archiver finishEncoding]; + [spfdata setObject:[encryptdata dataEncryptedWithPassword:[spfDocData_temp objectForKey:@"e_string"]] forKey:@"data"]; + } + + // NSLog(@"%@", spfdata); + + NSString *err = nil; + NSData *plist = [NSPropertyListSerialization dataFromPropertyList:spfdata + format:NSPropertyListXMLFormat_v1_0 + errorDescription:&err]; + + if(err != nil) { + NSAlert *alert = [NSAlert alertWithMessageText:[NSString stringWithFormat:NSLocalizedString(@"Error while converting connection data", @"error while converting connection data")] + defaultButton:NSLocalizedString(@"OK", @"OK button") + alternateButton:nil + otherButton:nil + informativeTextWithFormat:err]; + + [alert setAlertStyle:NSCriticalAlertStyle]; + [alert runModal]; + return; + } + + NSError *error = nil; + [plist writeToFile:fileName options:NSAtomicWrite error:&error]; + if(error != nil){ + NSAlert *errorAlert = [NSAlert alertWithError:error]; + [errorAlert runModal]; + } + + [self setFileURL:[NSURL URLWithString:fileName]]; + + [tableWindow setTitle:[self displayName]]; + + // Store doc data permanently + [spfDocData removeAllObjects]; + [spfDocData addEntriesFromDictionary:spfDocData_temp]; + } /** @@ -2794,8 +2942,11 @@ if ( ![tablesListInstance selectionShouldChangeInTableView:nil] ) { return NO; } else { - return YES; + // Auto-save spf file based connection + if([self fileURL] && [[[self fileURL] absoluteString] length]) + [self saveSPFtoFile:[[self fileURL] absoluteString] saveInBackground:YES saveOnlyPreferences:YES]; } + return YES; } /** @@ -2812,9 +2963,16 @@ */ - (NSString *)displayName { - if (!_isConnected) return @"Connecting..."; + if (!_isConnected) return [NSString stringWithFormat:@"%@%@", + ([[[self fileURL] absoluteString] length]) ? [NSString stringWithFormat:@"%@ – ",[[[self fileURL] absoluteString] lastPathComponent]] : @"", + NSLocalizedString(@"Connecting…", @"window title string indicating that sp is connecting")]; - return [NSString stringWithFormat:@"(MySQL %@) %@/%@", mySQLVersion, [self name], ([self database]?[self database]:@"")]; + return [NSString stringWithFormat:@"%@(MySQL %@) %@%@%@", + ([[[self fileURL] absoluteString] length]) ? [NSString stringWithFormat:@"%@ – ",[[[self fileURL] absoluteString] lastPathComponent]] : @"", + mySQLVersion, + [self name], + ([self database]?[NSString stringWithFormat:@"/%@",[self database]]:@""), + ([[self table] length]?[NSString stringWithFormat:@"/%@",[self table]]:@"")]; } @@ -2916,9 +3074,14 @@ [addDatabaseButton setEnabled:([[databaseNameField stringValue] length] > 0)]; } - if (object == variablesSearchField) { + else if (object == variablesSearchField) { [self _updateServerVariablesFilterForFilterString:[object stringValue]]; } + + else if (object == saveConnectionEncryptString) { + [saveConnectionEncryptString setStringValue:[saveConnectionEncryptString stringValue]]; + } + } #pragma mark - @@ -2995,6 +3158,7 @@ - (void)dealloc { + [_encoding release]; [printWebView release]; if (connectionController) [connectionController release]; @@ -3006,6 +3170,7 @@ if(queryEditorInitString) [queryEditorInitString release]; if(spfSession) [spfSession release]; if(userManagerInstance) [userManagerInstance release]; + if(spfDocData) [spfDocData release]; [super dealloc]; } diff --git a/Source/TablesList.m b/Source/TablesList.m index 6e34c295..ef308ae7 100644 --- a/Source/TablesList.m +++ b/Source/TablesList.m @@ -783,9 +783,9 @@ [removeTableContextMenuItem setTitle:NSLocalizedString(@"Remove Function", @"remove func menu title")]; } + // set window title - [tableWindow setTitle:[NSString stringWithFormat:@"(MySQL %@) %@/%@/%@", [tableDocumentInstance mySQLVersion], - [tableDocumentInstance name], [tableDocumentInstance database], selectedTableName]]; + [tableWindow setTitle:[tableDocumentInstance displayName]]; // Update the "Show Create Syntax" window if it's already opened // according to the selected table/view/proc/func @@ -874,8 +874,8 @@ [separatorTableContextMenuItem setHidden:YES]; // set window title - [tableWindow setTitle:[NSString stringWithFormat:@"(MySQL %@) %@/%@", [tableDocumentInstance mySQLVersion], - [tableDocumentInstance name], [tableDocumentInstance database]]]; + [tableWindow setTitle:[tableDocumentInstance displayName]]; + } [spHistoryControllerInstance updateHistoryEntries]; @@ -1207,8 +1207,8 @@ } // Set window title - [tableWindow setTitle:[NSString stringWithFormat:@"(MySQL %@) %@/%@/%@", [tableDocumentInstance mySQLVersion], - [tableDocumentInstance name], [tableDocumentInstance database], anObject]]; + [tableWindow setTitle:[tableDocumentInstance displayName]]; + } else { // Error while renaming @@ -1665,8 +1665,7 @@ [tablesListView reloadData]; // set window title - [tableWindow setTitle:[NSString stringWithFormat:@"(MySQL %@) %@/%@", [tableDocumentInstance mySQLVersion], - [tableDocumentInstance name], [tableDocumentInstance database]]]; + [tableWindow setTitle:[tableDocumentInstance displayName]]; if ( error ) { NSBeginAlertSheet(NSLocalizedString(@"Error", @"error"), NSLocalizedString(@"OK", @"OK button"), nil, nil, tableWindow, self, nil, nil, nil, @@ -1774,7 +1773,7 @@ else if (selectedIndex == 3) { [extendedTableInfoInstance loadTable:tableName]; structureLoaded = NO; - contentLoaded = NO; + contentLoaded = NO; statusLoaded = YES; } else { @@ -1784,8 +1783,7 @@ } // Set window title - [tableWindow setTitle:[NSString stringWithFormat:@"(MySQL %@) %@/%@/%@", [tableDocumentInstance mySQLVersion], - [tableDocumentInstance name], [tableDocumentInstance database], tableName]]; + [tableWindow setTitle:[tableDocumentInstance displayName]]; } else { // Error while creating new table @@ -2059,8 +2057,7 @@ } // Set window title - [tableWindow setTitle:[NSString stringWithFormat:@"(MySQL %@) %@/%@/%@", [tableDocumentInstance mySQLVersion], - [tableDocumentInstance name], [tableDocumentInstance database], [tableRenameField stringValue]]]; + [tableWindow setTitle:[tableDocumentInstance displayName]]; } @end |