diff --git a/KeePassKit b/KeePassKit index 3d2592c7..c385bd72 160000 --- a/KeePassKit +++ b/KeePassKit @@ -1 +1 @@ -Subproject commit 3d2592c7b14f4ab2f851fb72c865261a4913251e +Subproject commit c385bd725c1c71c3e986a24131e52625959c8084 diff --git a/MacPass/MPAppDelegate.m b/MacPass/MPAppDelegate.m index 27b16534..ebb1d240 100644 --- a/MacPass/MPAppDelegate.m +++ b/MacPass/MPAppDelegate.m @@ -66,10 +66,10 @@ NSString *const MPDidChangeStoredKeyFilesSettings = @"com.hicknhack.macpass.MPDi self = [super init]; if(self) { /* We know that we do not use the varibale after instancation */ - #pragma clang diagnostic push - #pragma clang diagnostic ignored "-Wunused-variable" +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wunused-variable" MPDocumentController *documentController = [[MPDocumentController alloc] init]; - #pragma clang diagnostic pop +#pragma clang diagnostic pop } return self; } @@ -212,10 +212,11 @@ NSString *const MPDidChangeStoredKeyFilesSettings = @"com.hicknhack.macpass.MPDi } - (void)lockAllDocuments { - for(NSDocument *document in [[NSDocumentController sharedDocumentController] documents]) { - NSArray *windowControllers = [document windowControllers]; - if([windowControllers count] > 0) { - [windowControllers[0] lock:nil]; + for(NSDocument *document in ((NSDocumentController *)[NSDocumentController sharedDocumentController]).documents) { + for(id windowController in document.windowControllers) { + if([windowController respondsToSelector:@selector(lock)]) { + [windowController lock]; + } } } } @@ -235,6 +236,12 @@ NSString *const MPDidChangeStoredKeyFilesSettings = @"com.hicknhack.macpass.MPDi NSArray *documents = [documentController documents]; BOOL restoredWindows = [documents count] > 0; + for(NSDocument *document in documents) { + for(NSWindowController *windowController in [document windowControllers]) { + [windowController.window.contentView layout]; + } + } + BOOL reopen = [[NSUserDefaults standardUserDefaults] boolForKey:kMPSettingsKeyReopenLastDatabaseOnLaunch]; BOOL showWelcomeScreen = !restoredWindows && !_shouldOpenFile; if(reopen && !restoredWindows && !_shouldOpenFile) { diff --git a/MacPass/MPDocument.m b/MacPass/MPDocument.m index 33cc8f2a..23638ddc 100644 --- a/MacPass/MPDocument.m +++ b/MacPass/MPDocument.m @@ -126,8 +126,6 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGroupKey if(self) { _didLockFile = NO; _readOnly = NO; - self.tree = [KPKTree allocTemplateTree]; - self.tree.metaData.rounds = [[NSUserDefaults standardUserDefaults] integerForKey:kMPSettingsKeyDefaultPasswordRounds]; } return self; } @@ -136,6 +134,15 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGroupKey [self _cleanupLock]; } +- (instancetype)initWithType:(NSString *)typeName error:(NSError *__autoreleasing *)outError { + self = [self init]; + if(self) { + self.tree = [[KPKTree alloc] initWithTemplateContents]; + self.tree.metaData.rounds = [[NSUserDefaults standardUserDefaults] integerForKey:kMPSettingsKeyDefaultPasswordRounds]; + } + return self; +} + - (void)makeWindowControllers { MPDocumentWindowController *windowController = [[MPDocumentWindowController alloc] init]; [self addWindowController:windowController]; @@ -234,6 +241,7 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGroupKey if([[self fileURL] isFileURL]) { [[NSUserDefaults standardUserDefaults] setObject:[self.fileURL absoluteString] forKey:kMPSettingsKeyLastDatabasePath]; } + self.tree = nil; [super close]; } @@ -410,16 +418,16 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGroupKey [[NSNotificationCenter defaultCenter] postNotificationName:MPDocumentCurrentItemChangedNotification object:self]; } } -- (void)setTree:(KPKTree *)tree { - if(_tree != tree) { - _tree = tree; - _tree.undoManager = [self undoManager]; - if(nil == _treeDelgate) { - _treeDelgate = [[MPTreeDelegate alloc] initWithDocument:self]; - } - _tree.delegate = _treeDelgate; - } -} +//- (void)setTree:(KPKTree *)tree { +// if(_tree != tree) { +// _tree = tree; +// _tree.undoManager = [self undoManager]; +// if(nil == _treeDelgate) { +// _treeDelgate = [[MPTreeDelegate alloc] initWithDocument:self]; +// } +// _tree.delegate = _treeDelgate; +// } +//} #pragma mark Data Accesors @@ -682,26 +690,26 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGroupKey id nodeResolver = [NSApp targetForAction:@selector(currentTargetNode)]; /* - NSLog(@"entryResolver:%@", [entryResolver class]); - NSLog(@"groupResolver:%@", [groupResolver class]); - NSLog(@"nodeResolver:%@", [nodeResolver class]); - */ + NSLog(@"entryResolver:%@", [entryResolver class]); + NSLog(@"groupResolver:%@", [groupResolver class]); + NSLog(@"nodeResolver:%@", [nodeResolver class]); + */ KPKNode *targetNode = [nodeResolver currentTargetNode]; KPKEntry *targetEntry = [entryResolver currentTargetEntry]; KPKGroup *targetGroup = [groupResolver currentTargetGroup]; /* - if([targetNode asGroup]) { - NSLog(@"targetNode:%@", ((KPKGroup *)targetNode).name); - } - else if([targetNode asEntry]) { - NSLog(@"targetNode:%@", ((KPKEntry *)targetNode).title); - } - - NSLog(@"targetGroup:%@", targetGroup.name); - NSLog(@"tagetEntry:%@", targetEntry.title ); - */ + if([targetNode asGroup]) { + NSLog(@"targetNode:%@", ((KPKGroup *)targetNode).name); + } + else if([targetNode asEntry]) { + NSLog(@"targetNode:%@", ((KPKEntry *)targetNode).title); + } + + NSLog(@"targetGroup:%@", targetGroup.name); + NSLog(@"tagetEntry:%@", targetEntry.title ); + */ if(self.encrypted || self.isReadOnly) { return NO; } diff --git a/MacPass/MPEntryViewController.m b/MacPass/MPEntryViewController.m index 60f47519..817b2d7f 100644 --- a/MacPass/MPEntryViewController.m +++ b/MacPass/MPEntryViewController.m @@ -124,6 +124,8 @@ NSString *const _MPTableSecurCellView = @"PasswordCell"; } - (void)dealloc { + [self.entryTable unbind:NSContentArrayBinding]; + [self.entryArrayController unbind:NSContentArrayBinding]; [[NSNotificationCenter defaultCenter] removeObserver:self]; } @@ -387,6 +389,7 @@ NSString *const _MPTableSecurCellView = @"PasswordCell"; return; // we are showing the correct object right now. } } + [self.entryArrayController unbind:NSContentArrayBinding]; [self.entryArrayController bind:NSContentArrayBinding toObject:document.selectedGroup withKeyPath:NSStringFromSelector(@selector(entries)) options:nil]; } [self _updateContextBar]; @@ -423,7 +426,7 @@ NSString *const _MPTableSecurCellView = @"PasswordCell"; NSAssert(result != nil, @"Resutls should never be nil"); self.filteredEntries = result; [self.entryArrayController unbind:NSContentArrayBinding]; - [self.entryArrayController setContent:self.filteredEntries]; + [self.entryArrayController bind:NSContentArrayBinding toObject:self withKeyPath:NSStringFromSelector(@selector(filteredEntries)) options:nil]; [[self.entryTable tableColumnWithIdentifier:MPEntryTableParentColumnIdentifier] setHidden:NO]; } @@ -432,6 +435,7 @@ NSString *const _MPTableSecurCellView = @"PasswordCell"; [[self.entryTable tableColumnWithIdentifier:MPEntryTableParentColumnIdentifier] setHidden:YES]; MPDocument *document = [[self windowController] document]; document.selectedItem = document.selectedGroup; + // TODO: really necessary? if( nil == document.selectedItem && nil == document.selectedGroup ) { [self.entryArrayController unbind:NSContentArrayBinding]; [self.entryArrayController setContent:nil]; @@ -737,6 +741,7 @@ NSString *const _MPTableSecurCellView = @"PasswordCell"; #pragma mark periodic UI Update - (void)_updateExpirationDisplay { + return; /* items are all entries */ [[self.entryArrayController arrangedObjects] enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { [[obj timeInfo] isExpired]; diff --git a/MacPass/MPOutlineViewController.m b/MacPass/MPOutlineViewController.m index 20cbd7b5..86a2dcd0 100644 --- a/MacPass/MPOutlineViewController.m +++ b/MacPass/MPOutlineViewController.m @@ -72,6 +72,8 @@ NSString *const _MPOutlinveViewHeaderViewIdentifier = @"HeaderCell"; } - (void)dealloc { + [self.outlineView unbind:NSContentBinding]; + [self.treeController unbind:NSContentBinding]; [[NSNotificationCenter defaultCenter] removeObserver:self]; [self.outlineView setDelegate:nil]; } @@ -299,6 +301,7 @@ NSString *const _MPOutlinveViewHeaderViewIdentifier = @"HeaderCell"; } - (void)_updateExpirationDisplay { + return; MPDocument *document = [[self windowController] document]; [document.root.timeInfo isExpired]; [[document.tree allGroups] enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {