Added export to XML action for Version2 Databases

Small updates to Database Settings window
This commit is contained in:
michael starke
2013-07-15 22:10:27 +02:00
parent f4c67ea603
commit c0051f852e
9 changed files with 532 additions and 374 deletions

View File

@@ -262,6 +262,15 @@
<reference key="NSOnImage" ref="35465992"/>
<reference key="NSMixedImage" ref="502551668"/>
</object>
<object class="NSMenuItem" id="438377242">
<reference key="NSMenu" ref="720053764"/>
<string key="NSTitle">Export As XML…</string>
<string key="NSKeyEquiv">E</string>
<int key="NSKeyEquivModMask">1048576</int>
<int key="NSMnemonicLoc">2147483647</int>
<reference key="NSOnImage" ref="35465992"/>
<reference key="NSMixedImage" ref="502551668"/>
</object>
<object class="NSMenuItem" id="579971712">
<reference key="NSMenu" ref="720053764"/>
<string key="NSTitle">Revert to Saved</string>
@@ -811,6 +820,14 @@
</object>
<int key="connectionID">1255</int>
</object>
<object class="IBConnectionRecord">
<object class="IBActionConnection" key="connection">
<string key="label">exportDatabase:</string>
<reference key="source" ref="1014"/>
<reference key="destination" ref="438377242"/>
</object>
<int key="connectionID">1260</int>
</object>
<object class="IBConnectionRecord">
<object class="IBActionConnection" key="connection">
<string key="label">showPreferences:</string>
@@ -914,6 +931,7 @@
<reference ref="915918141"/>
<reference ref="544639599"/>
<reference ref="663106531"/>
<reference ref="438377242"/>
</array>
<reference key="parent" ref="379814623"/>
</object>
@@ -1249,6 +1267,11 @@
<reference key="object" ref="663106531"/>
<reference key="parent" ref="720053764"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">1259</int>
<reference key="object" ref="438377242"/>
<reference key="parent" ref="720053764"/>
</object>
</array>
</object>
<dictionary class="NSMutableDictionary" key="flattenedProperties">
@@ -1266,6 +1289,7 @@
<string key="124.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="1243.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="125.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="1259.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="126.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="129.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="130.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
@@ -1322,7 +1346,7 @@
<nil key="activeLocalization"/>
<dictionary class="NSMutableDictionary" key="localizations"/>
<nil key="sourceID"/>
<int key="maxID">1258</int>
<int key="maxID">1260</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<array class="NSMutableArray" key="referencedPartialClassDescriptions">
@@ -1382,6 +1406,7 @@
<string key="superclassName">NSWindowController</string>
<dictionary class="NSMutableDictionary" key="actions">
<string key="editPassword:">id</string>
<string key="exportDatabase:">id</string>
<string key="showDatabaseSettings:">id</string>
</dictionary>
<dictionary class="NSMutableDictionary" key="actionInfosByName">
@@ -1389,6 +1414,10 @@
<string key="name">editPassword:</string>
<string key="candidateClassName">id</string>
</object>
<object class="IBActionInfo" key="exportDatabase:">
<string key="name">exportDatabase:</string>
<string key="candidateClassName">id</string>
</object>
<object class="IBActionInfo" key="showDatabaseSettings:">
<string key="name">showDatabaseSettings:</string>
<string key="candidateClassName">id</string>

File diff suppressed because it is too large Load Diff

View File

@@ -67,6 +67,8 @@ APPKIT_EXTERN NSString *const MPDocumentGroupKey;
- (void)useGroupAsTrash:(KdbGroup *)group;
#pragma mark Export
- (void)writeXMLToURL:(NSURL *)url;
#pragma mark Undo Data Manipulation
/* Undoable Intiialization of elements */

View File

@@ -17,6 +17,7 @@
#import "KdbLib.h"
#import "Kdb3Node.h"
#import "Kdb4Node.h"
#import "Kdb4Persist.h"
#import "KdbPassword.h"
#import "KdbGroup+Undo.h"
#import "KdbGroup+KVOAdditions.h"
@@ -27,6 +28,8 @@
#import "Kdb3Tree+NewTree.h"
#import "Kdb4Tree+NewTree.h"
#import "DataOutputStream.h"
NSString *const MPDocumentDidAddGroupNotification = @"com.hicknhack.macpass.MPDocumentDidAddGroupNotification";
NSString *const MPDocumentWillDelteGroupNotification = @"com.hicknhack.macpass.MPDocumentDidDelteGroupNotification";
NSString *const MPDocumentDidAddEntryNotification = @"com.hicknhack.macpass.MPDocumentDidAddEntryNotification";
@@ -160,6 +163,13 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGroupKey";
[super close];
}
- (void)writeXMLToURL:(NSURL *)url {
DataOutputStream *outputStream = [[DataOutputStream alloc] init];
Kdb4Persist *persist = [[Kdb4Persist alloc] initWithTree:self.treeV4 outputStream:outputStream randomStream:nil];
[persist persist];
[outputStream.data writeToURL:url atomically:YES];
}
#pragma mark Lock/Unlock/Decrypt
- (BOOL)unlockWithPassword:(NSString *)password keyFileURL:(NSURL *)keyFileURL {

View File

@@ -38,6 +38,7 @@ APPKIT_EXTERN NSString *const MPCurrentItemChangedNotification;
- (void)performFindPanelAction:(id)sender;
- (IBAction)editPassword:(id)sender;
- (IBAction)showDatabaseSettings:(id)sender;
- (IBAction)exportDatabase:(id)sender;
- (void)lock:(id)sender;

View File

@@ -162,13 +162,27 @@ NSString *const MPCurrentItemChangedNotification = @"com.hicknhack.macpass.MPCur
}
#pragma mark Actions
- (void)exportDatabase:(id)sender {
NSSavePanel *savePanel = [NSSavePanel savePanel];
[savePanel setAllowsOtherFileTypes:YES];
[savePanel beginSheetModalForWindow:self.window completionHandler:^(NSInteger result) {
if(result == NSFileHandlingPanelOKButton) {
[[self document] writeXMLToURL:savePanel.URL];
}
}];
}
- (void)performFindPanelAction:(id)sender {
[self.entryViewController showFilter:sender];
}
- (BOOL)validateMenuItem:(NSMenuItem *)menuItem {
BOOL enabled = YES;
MPDocument *document = [self document];
return !( document.isLocked || document.isReadOnly );
if([menuItem action] == @selector(exportDatabase:)) {
enabled = (nil != document.treeV4);
}
enabled &= !( document.isLocked || document.isReadOnly );
return enabled;
}
- (BOOL)validateToolbarItem:(NSToolbarItem *)theItem {