From 4d9aa8cc0294d88230863e970271f1f9adb28e13 Mon Sep 17 00:00:00 2001 From: michael starke Date: Wed, 4 Dec 2013 21:22:29 +0100 Subject: [PATCH] Fixed issue with composite key storing not updating the MasterKeyChanged date (this should be moved to KeePassKit) Fixed #120 (at least that's what I hope ;) ) --- KeePassKit | 2 +- MacPass/MPDocument.m | 8 +++++++- MacPass/MPEntryViewController.h | 2 -- MacPass/MPEntryViewController.m | 22 +++++++++++++--------- MacPass/MPSettingsHelper.h | 3 +++ MacPass/MPSettingsHelper.m | 5 ++++- 6 files changed, 28 insertions(+), 14 deletions(-) diff --git a/KeePassKit b/KeePassKit index 04a7747b..b7c4851c 160000 --- a/KeePassKit +++ b/KeePassKit @@ -1 +1 @@ -Subproject commit 04a7747bd991704a1c18ec2d20798c6347a3803f +Subproject commit b7c4851c50d7b45ada5e57160df37cb5b276b2a0 diff --git a/MacPass/MPDocument.m b/MacPass/MPDocument.m index 9dafe88f..67bd3d5b 100644 --- a/MacPass/MPDocument.m +++ b/MacPass/MPDocument.m @@ -278,7 +278,13 @@ typedef NS_ENUM(NSUInteger, MPAlertType) { if([password length] == 0 && keyFileURL == nil) { return NO; } - [self.compositeKey setPassword:password andKeyfile:keyFileURL]; + if(!self.compositeKey) { + self.compositeKey = [[KPKCompositeKey alloc] initWithPassword:password key:keyFileURL]; + } + else { + [self.compositeKey setPassword:password andKeyfile:keyFileURL]; + } + self.tree.metaData.masterKeyChanged = [NSDate date]; /* We need to store the key file once the user actually writes the database */ return YES; } diff --git a/MacPass/MPEntryViewController.h b/MacPass/MPEntryViewController.h index c7afc9d6..2b229baf 100644 --- a/MacPass/MPEntryViewController.h +++ b/MacPass/MPEntryViewController.h @@ -28,8 +28,6 @@ typedef NS_ENUM( NSUInteger, MPCopyContentTypeTag) { @interface MPEntryViewController : MPViewController -@property (readonly, weak, nonatomic) KPKEntry *selectedEntry; - @property (weak,readonly) NSTableView *entryTable; @property (readonly, strong) NSArrayController *entryArrayController; @property (nonatomic, strong) NSString *filter; diff --git a/MacPass/MPEntryViewController.m b/MacPass/MPEntryViewController.m index 86a87c37..bc7ef400 100644 --- a/MacPass/MPEntryViewController.m +++ b/MacPass/MPEntryViewController.m @@ -88,9 +88,6 @@ NSString *const _MPTAbleSecurCellView = @"PasswordCell"; @property (weak) IBOutlet NSButton *addEntryButton; @property (weak) IBOutlet NSTextField *entryCountTextField; - -@property (weak) KPKEntry *selectedEntry; - @property (nonatomic, strong) MPEntryTableDataSource *dataSource; @property (assign, nonatomic) MPFilterModeType filterMode; @@ -112,13 +109,13 @@ NSString *const _MPTAbleSecurCellView = @"PasswordCell"; _dataSource = [[MPEntryTableDataSource alloc] init]; _dataSource.viewController = self; _menuDelegate = [[MPEntryContextMenuDelegate alloc] init]; - _selectedEntry = nil; } return self; } - (void)dealloc { [[NSNotificationCenter defaultCenter] removeObserver:self]; + [self unbind:@"filterMode"]; } @@ -176,7 +173,7 @@ NSString *const _MPTAbleSecurCellView = @"PasswordCell"; [urlColumn setSortDescriptorPrototype:urlSortDescriptor]; [parentColumn setSortDescriptorPrototype:groupnameSortDescriptor]; [modifiedColumn setSortDescriptorPrototype:dateSortDescriptor]; - + [[parentColumn headerCell] setStringValue:NSLocalizedString(@"GROUP", "")]; [[titleColumn headerCell] setStringValue:NSLocalizedString(@"TITLE", "")]; [[userNameColumn headerCell] setStringValue:NSLocalizedString(@"USERNAME", "")]; @@ -189,14 +186,14 @@ NSString *const _MPTAbleSecurCellView = @"PasswordCell"; [self.entryTable bind:NSContentBinding toObject:self.entryArrayController withKeyPath:@"arrangedObjects" options:nil]; [self.entryTable bind:NSSortDescriptorsBinding toObject:self.entryArrayController withKeyPath:@"sortDescriptors" options:nil]; [self.entryTable setDataSource:_dataSource]; - + // bind NSArrayController sorting so that sort order gets auto-saved // see: http://simx.me/technonova/software_development/sort_descriptors_nstableview_bindings_a.html [self.entryArrayController bind:NSSortDescriptorsBinding toObject:[NSUserDefaultsController sharedUserDefaultsController] withKeyPath:[MPSettingsHelper defaultControllerPathForKey:kMPSettingsKeyEntryTableSortDescriptors] options:@{ NSValueTransformerNameBindingOption: NSUnarchiveFromDataTransformerName }]; - + [self _setupHeaderMenu]; [parentColumn setHidden:YES]; } @@ -413,8 +410,15 @@ NSString *const _MPTAbleSecurCellView = @"PasswordCell"; self.filter = [self.filterSearchField stringValue]; } -- (void)setupFilterBar { +- (void)_setupFilterBar { if(!self.filterBar) { + /* + [[NSUserDefaultsController sharedUserDefaultsController] bind:[MPSettingsHelper defaultControllerPathForKey:kMPSettingsKeyEntrySearchFilterMode] + toObject:self + withKeyPath:@"filterMode" + options:nil]; + */ + [[NSBundle mainBundle] loadNibNamed:@"FilterBar" owner:self topLevelObjects:nil]; [self.filterURLButton setTag:MPFilterUrls]; [self.filterUsernameButton setTag:MPFilterUsernames]; @@ -438,7 +442,7 @@ NSString *const _MPTAbleSecurCellView = @"PasswordCell"; - (void)_showFilterBarAnimated { if(!self.filterBar) { - [self setupFilterBar]; + [self _setupFilterBar]; } /* Make sure the buttons are set correctyl every time diff --git a/MacPass/MPSettingsHelper.h b/MacPass/MPSettingsHelper.h index d1c2e5d4..a66ce191 100644 --- a/MacPass/MPSettingsHelper.h +++ b/MacPass/MPSettingsHelper.h @@ -49,6 +49,9 @@ APPKIT_EXTERN NSString *const kMPSettingsKeyRememberKeyFilesForDatabases; /* Autotype */ APPKIT_EXTERN NSString *const kMPSettingsKeySendCommandForControlKey; +/* Search */ +APPKIT_EXTERN NSString *const kMPSettingsKeyEntrySearchFilterMode; + typedef NS_ENUM(NSUInteger, MPPasswordEncoding) { MPPasswordEncodingUTF8, MPPasswordEncodingASCII, diff --git a/MacPass/MPSettingsHelper.m b/MacPass/MPSettingsHelper.m index 3f1a3440..d91f26c8 100644 --- a/MacPass/MPSettingsHelper.m +++ b/MacPass/MPSettingsHelper.m @@ -34,6 +34,8 @@ NSString *const kMPSettingsKeyRememberKeyFilesForDatabases = @"RememberKeyFiles NSString *const kMPSettingsKeySendCommandForControlKey = @"SendCommandKeyForControlKey"; +NSString *const kMPSettingsKeyEntrySearchFilterMode = @"EntrySearchFilterMode"; + @implementation MPSettingsHelper + (void)setupDefaults { @@ -63,7 +65,8 @@ NSString *const kMPSettingsKeySendCommandForControlKey = @"SendCommandKeyFo kMPSettingsKeyLegacyHideURL: @NO, kMPSettingsKeyLegacyHideUsername: @NO, kMPSettingsKeyRememberKeyFilesForDatabases: @NO, - kMPSettingsKeySendCommandForControlKey: @YES + kMPSettingsKeySendCommandForControlKey: @YES, + kMPSettingsKeyEntrySearchFilterMode: @0 }; }