diff --git a/MacPass/EntryInspectorView.xib b/MacPass/EntryInspectorView.xib
index bcf079fe..600bcfd2 100644
--- a/MacPass/EntryInspectorView.xib
+++ b/MacPass/EntryInspectorView.xib
@@ -84,14 +84,14 @@
-
+
-
+
@@ -266,14 +266,14 @@
-
+
-
+
diff --git a/MacPass/MPDocument.h b/MacPass/MPDocument.h
index 97ccd15b..c525b995 100644
--- a/MacPass/MPDocument.h
+++ b/MacPass/MPDocument.h
@@ -12,6 +12,9 @@
APPKIT_EXTERN NSString *const MPDocumentDidAddGroupNotification;
APPKIT_EXTERN NSString *const MPDocumentDidRevertNotifiation;
+APPKIT_EXTERN NSString *const MPDocumentDidLockDatabaseNotification;
+APPKIT_EXTERN NSString *const MPDocumentDidUnlockDatabaseNotification;
+
APPKIT_EXTERN NSString *const MPDocumentEntryKey;
APPKIT_EXTERN NSString *const MPDocumentGroupKey;
diff --git a/MacPass/MPDocument.m b/MacPass/MPDocument.m
index 41a92c94..8301a6df 100644
--- a/MacPass/MPDocument.m
+++ b/MacPass/MPDocument.m
@@ -29,6 +29,9 @@
NSString *const MPDocumentDidAddGroupNotification = @"com.hicknhack.macpass.MPDocumentDidAddGroupNotification";
NSString *const MPDocumentDidRevertNotifiation = @"com.hicknhack.macpass.MPDocumentDidRevertNotifiation";
+NSString *const MPDocumentDidLockDatabaseNotification = @"com.hicknhack.macpass.MPDocumentDidLockDatabaseNotification";
+NSString *const MPDocumentDidUnlockDatabaseNotification = @"com.hicknhack.macpass.MPDocumentDidUnlockDatabaseNotification";
+
NSString *const MPDocumentEntryKey = @"MPDocumentEntryKey";
NSString *const MPDocumentGroupKey = @"MPDocumentGroupKey";
@@ -220,7 +223,11 @@ typedef NS_ENUM(NSUInteger, MPAlertType) {
self.tree = [[KPKTree alloc] initWithData:_encryptedData password:passwordData error:error];
- return (self.tree != nil);
+ BOOL isUnlocked = (nil != self.tree);
+ if(isUnlocked) {
+ [[NSNotificationCenter defaultCenter] postNotificationName:MPDocumentDidUnlockDatabaseNotification object:self];
+ }
+ return isUnlocked;
}
- (void)lockDatabase:(id)sender {
diff --git a/MacPass/MPDocumentQueryService.h b/MacPass/MPDocumentQueryService.h
index 17c294b0..e7bc792e 100644
--- a/MacPass/MPDocumentQueryService.h
+++ b/MacPass/MPDocumentQueryService.h
@@ -9,12 +9,15 @@
#import
@class KPKEntry;
-
+@class MPDocument;
/**
* Service to querey for entries
*/
@interface MPDocumentQueryService : NSObject
+@property (readonly, weak) MPDocument *queryDocument;
+@property (readonly, weak) KPKEntry *configEntry;
+
+ (MPDocumentQueryService *)sharedService;
- (KPKEntry *)configurationEntry;
diff --git a/MacPass/MPDocumentQueryService.m b/MacPass/MPDocumentQueryService.m
index 31cb56ce..3a8985a4 100644
--- a/MacPass/MPDocumentQueryService.m
+++ b/MacPass/MPDocumentQueryService.m
@@ -7,14 +7,18 @@
//
#import "MPDocumentQueryService.h"
+#import "MPDocumentWindowController.h"
#import "MPDocument.h"
+#import "KPKEntry.h"
#import "NSUUID+KeePassKit.h"
-@interface MPDocumentQueryService () {
-@private
- NSUUID *rootUuid;
-}
+static NSUUID *_rootUuid = nil;
+
+@interface MPDocumentQueryService ()
+
+@property (weak) MPDocument *queryDocument;
+@property (weak) KPKEntry *configEntry;
@end
@@ -36,21 +40,28 @@
0x34, 0x69, 0x7a, 0x40, 0x8a, 0x5b, 0x41, 0xc0,
0x9f, 0x36, 0x89, 0x7d, 0x62, 0x3e, 0xcb, 0x31
};
- rootUuid = [[NSUUID alloc] initWithUUIDBytes:uuidBytes];
+ _rootUuid = [[NSUUID alloc] initWithUUIDBytes:uuidBytes];
}
return self;
}
- (KPKEntry *)configurationEntry {
- /*
- We are looking in all documents,
- but only store the key in one.
- */
+ if(nil != _configEntry) {
+ return _configEntry;
+ }
+ /* no config entry there, start looking for it */
NSArray *documents = [[NSDocumentController sharedDocumentController] documents];
for(MPDocument *document in documents) {
- KPKEntry *entry = [document findEntry:rootUuid];
- if(entry) {
- return entry;
+ if(document.encrypted) {
+ NSLog(@"Skipping locked Database: %@", [document displayName]);
+ /* TODO: Show input window and open db with window */
+ continue;
+ }
+ KPKEntry *configEntry = [document findEntry:_rootUuid];
+ if(nil != configEntry) {
+ _configEntry = configEntry;
+ _queryDocument = document;
+ return _configEntry;
}
}
return nil;
diff --git a/MacPass/MPDocumentWindowController.m b/MacPass/MPDocumentWindowController.m
index fdcdcb16..ff53fa06 100644
--- a/MacPass/MPDocumentWindowController.m
+++ b/MacPass/MPDocumentWindowController.m
@@ -79,6 +79,7 @@ typedef NS_ENUM(NSUInteger, MPAlertContext) {
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_didRevertDocument:) name:MPDocumentDidRevertNotifiation object:[self document]];
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(showEntries) name:MPDocumentDidUnlockDatabaseNotification object:[self document]];
[_entryViewController setupNotifications:self];
[_inspectorViewController setupNotifications:self];
diff --git a/MacPass/MPPasswordInputController.m b/MacPass/MPPasswordInputController.m
index d1d50e93..b58eb0ff 100644
--- a/MacPass/MPPasswordInputController.m
+++ b/MacPass/MPPasswordInputController.m
@@ -67,9 +67,6 @@
error:&error]) {
[self _showError:error];
}
- else {
- [windowController showEntries];
- }
}
}
diff --git a/MacPass/ServerSettings.xib b/MacPass/ServerSettings.xib
index 6ab349a2..b4039824 100644
--- a/MacPass/ServerSettings.xib
+++ b/MacPass/ServerSettings.xib
@@ -1,312 +1,37 @@
-
-
-
- 1080
- 12E55
- 3084
- 1187.39
- 626.00
-
-
- IBNSLayoutConstraint
- NSButton
- NSButtonCell
- NSCustomObject
- NSCustomView
-
-
- com.apple.InterfaceBuilder.CocoaPlugin
-
-
-
-
-
-
-
-
-
-
-
-
- enableServerCheckbutton
-
-
-
- 17
-
-
-
- view
-
-
-
- 18
-
-
-
-
-
- 0
-
-
-
-
-
- -2
-
-
- File's Owner
-
-
- -1
-
-
- First Responder
-
-
- -3
-
-
- Application
-
-
- 1
-
-
-
-
-
- 5
- 0
-
- 5
- 1
-
- 20
-
- 1000
-
- 8
- 29
- 3
-
-
-
- 3
- 0
-
- 3
- 1
-
- 20
-
- 1000
-
- 8
- 29
- 3
-
-
-
- 8
- 0
-
- 0
- 1
-
- 54
-
- 1000
-
- 9
- 40
- 1
-
-
-
- 7
- 0
-
- 0
- 1
-
- 400
-
- 1000
-
- 9
- 40
- 1
-
-
-
-
-
- 2
-
-
-
-
-
-
-
- 3
-
-
-
-
- 4
-
-
-
-
- 5
-
-
-
-
- 19
-
-
-
-
- 20
-
-
-
-
-
-
- com.apple.InterfaceBuilder.CocoaPlugin
- com.apple.InterfaceBuilder.CocoaPlugin
- com.apple.InterfaceBuilder.CocoaPlugin
-
-
-
-
-
-
-
-
- com.apple.InterfaceBuilder.CocoaPlugin
- com.apple.InterfaceBuilder.CocoaPlugin
-
- com.apple.InterfaceBuilder.CocoaPlugin
- com.apple.InterfaceBuilder.CocoaPlugin
- com.apple.InterfaceBuilder.CocoaPlugin
- com.apple.InterfaceBuilder.CocoaPlugin
- com.apple.InterfaceBuilder.CocoaPlugin
-
-
-
-
-
- 20
-
-
-
-
- MPServerSettingsController
- MPViewController
-
- enableServerCheckbutton
- NSButton
-
-
- enableServerCheckbutton
-
- enableServerCheckbutton
- NSButton
-
-
-
- IBProjectSource
- ./Classes/MPServerSettingsController.h
-
-
-
- MPViewController
- NSViewController
-
- IBProjectSource
- ./Classes/MPViewController.h
-
-
-
- NSLayoutConstraint
- NSObject
-
- IBProjectSource
- ./Classes/NSLayoutConstraint.h
-
-
-
-
- 0
- IBCocoaFramework
- YES
- 3
-
- NSSwitch
- {15, 15}
-
- YES
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/MacPass/SettingsWindow.xib b/MacPass/SettingsWindow.xib
index bcfd5942..d1a5b579 100644
--- a/MacPass/SettingsWindow.xib
+++ b/MacPass/SettingsWindow.xib
@@ -1,145 +1,25 @@
-
-
-
- 1080
- 12E55
- 3084
- 1187.39
- 626.00
-
- com.apple.InterfaceBuilder.CocoaPlugin
- 3084
-
-
- NSCustomObject
- NSView
- NSWindowTemplate
-
-
- com.apple.InterfaceBuilder.CocoaPlugin
-
-
- PluginDependencyRecalculationVersion
-
-
-
-
- MPSettingsWindowController
-
-
- FirstResponder
-
-
- NSApplication
-
-
- 7
- 2
- {{196, 240}, {400, 300}}
- 544736256
- Window
- NSWindow
-
-
-
-
- 256
-
- {400, 300}
-
-
-
- {{0, 0}, {1680, 1028}}
- {10000000000000, 10000000000000}
- YES
-
-
-
-
-
-
- window
-
-
-
- 3
-
-
-
-
-
- 0
-
-
-
-
-
- -2
-
-
- File's Owner
-
-
- -1
-
-
- First Responder
-
-
- -3
-
-
- Application
-
-
- 1
-
-
-
-
-
-
-
- 2
-
-
-
-
-
-
-
- com.apple.InterfaceBuilder.CocoaPlugin
- com.apple.InterfaceBuilder.CocoaPlugin
- com.apple.InterfaceBuilder.CocoaPlugin
-
-
- com.apple.InterfaceBuilder.CocoaPlugin
- {{357, 418}, {480, 270}}
-
- com.apple.InterfaceBuilder.CocoaPlugin
-
-
-
-
-
- 89
-
-
-
-
- MPSettingsWindowController
- NSWindowController
-
- IBProjectSource
- ./Classes/MPSettingsWindowController.h
-
-
-
-
- 0
- IBCocoaFramework
- YES
- 3
- YES
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file