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 ;) )
This commit is contained in:
michael starke
2013-12-04 21:22:29 +01:00
parent fa52de144c
commit 4d9aa8cc02
6 changed files with 28 additions and 14 deletions

View File

@@ -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;
}

View File

@@ -28,8 +28,6 @@ typedef NS_ENUM( NSUInteger, MPCopyContentTypeTag) {
@interface MPEntryViewController : MPViewController <NSTableViewDelegate>
@property (readonly, weak, nonatomic) KPKEntry *selectedEntry;
@property (weak,readonly) NSTableView *entryTable;
@property (readonly, strong) NSArrayController *entryArrayController;
@property (nonatomic, strong) NSString *filter;

View File

@@ -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

View File

@@ -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,

View File

@@ -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
};
}