diff --git a/KeePassKit b/KeePassKit index fcb5063c..275e6e3e 160000 --- a/KeePassKit +++ b/KeePassKit @@ -1 +1 @@ -Subproject commit fcb5063c788865e0c02bf1cc9edf24f72b785ec3 +Subproject commit 275e6e3e1be61bea09dfe1ef9a7f33d392f93888 diff --git a/MacPass/MPDocument.m b/MacPass/MPDocument.m index 8ff206ac..6ec8f755 100644 --- a/MacPass/MPDocument.m +++ b/MacPass/MPDocument.m @@ -680,17 +680,6 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGroupKey } [self.trash clear]; } -# pragma mark Expiration updates -- (void)_updateExpirationState { - dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(60*60*6* NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ - /* TODO: find better way to do this! Test for alle entries if expired */ - [[self.tree allEntries] enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { - KPKEntry *entry = obj; - [entry.timeInfo willChangeValueForKey:NSStringFromSelector(@selector(isExpired))]; - [entry.timeInfo didChangeValueForKey:NSStringFromSelector(@selector(isExpired))]; - }]; - }); -} # pragma mark File Watching - (void) _watchForFileChanges:(BOOL)watch { diff --git a/MacPass/MPEntryViewController.m b/MacPass/MPEntryViewController.m index d0c6987a..4bfb62bb 100644 --- a/MacPass/MPEntryViewController.m +++ b/MacPass/MPEntryViewController.m @@ -37,6 +37,7 @@ #import "KPKNode+IconImage.h" #import "KPKAttribute.h" #import "KPKTimeInfo.h" +#import "KPKMetaData.h" #import "HNHTableHeaderCell.h" #import "HNHGradientView.h" @@ -46,6 +47,7 @@ #import "NSString+Commands.h" #define STATUS_BAR_ANIMATION_TIME 0.15 +#define EXPIRED_ENTRY_REFRESH_SECONDS 60 typedef NS_ENUM(NSUInteger,MPOVerlayInfoType) { MPOverlayInfoPassword, @@ -115,6 +117,7 @@ NSString *const _MPTAbleSecurCellView = @"PasswordCell"; _dataSource.viewController = self; _menuDelegate = [[MPEntryContextMenuDelegate alloc] init]; _contextBarViewController = [[MPContextBarViewController alloc] init]; + [self _updateExpirationDisplay]; } return self; } @@ -728,4 +731,12 @@ NSString *const _MPTAbleSecurCellView = @"PasswordCell"; break; } } +- (void)_updateExpirationDisplay { + /* items are all entries */ + [[self.entryArrayController arrangedObjects] enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { + [[obj timeInfo] isExpired]; + }]; + [self performSelector:@selector(_updateExpirationDisplay) withObject:nil afterDelay:EXPIRED_ENTRY_REFRESH_SECONDS]; +} + @end diff --git a/MacPass/MPGroupInspectorViewController.m b/MacPass/MPGroupInspectorViewController.m index 289b02a7..e6b7712d 100644 --- a/MacPass/MPGroupInspectorViewController.m +++ b/MacPass/MPGroupInspectorViewController.m @@ -81,18 +81,15 @@ [self.titleTextField bind:NSValueBinding toObject:self.group withKeyPath:NSStringFromSelector(@selector(name)) options:nil]; [self.expiresCheckButton bind:NSValueBinding toObject:self.group.timeInfo withKeyPath:NSStringFromSelector(@selector(expires)) options:nil]; [self.expiresCheckButton bind:NSTitleBinding toObject:self.group.timeInfo withKeyPath:NSStringFromSelector(@selector(expiryTime)) options:@{ NSValueTransformerNameBindingOption:MPExpiryDateValueTransformer }]; - [self.expireDateSelectButton bind:NSHiddenBinding toObject:self.group.timeInfo withKeyPath:NSStringFromSelector(@selector(expires)) options:@{ NSValueTransformerNameBindingOption : NSNegateBooleanTransformerName }]; [self.autotypePopupButton bind:NSSelectedTagBinding toObject:self.group withKeyPath:NSStringFromSelector(@selector(isAutoTypeEnabled)) options:nil]; [self.autotypeSequenceTextField bind:NSValueBinding toObject:self.group withKeyPath:NSStringFromSelector(@selector(defaultAutoTypeSequence)) options:nil]; [self.searchPopupButton bind:NSSelectedTagBinding toObject:self.group withKeyPath:NSStringFromSelector(@selector(isSearchEnabled)) options:nil]; } else { [self.titleTextField unbind:NSValueBinding]; - [self.expiresCheckButton unbind:NSValueBinding]; [self.expiresCheckButton unbind:NSTitleBinding]; [self.expiresCheckButton setTitle:NSLocalizedString(@"EXPIRES", "")]; - [self.expireDateSelectButton unbind:NSHiddenBinding]; [self.searchPopupButton unbind:NSSelectedTagBinding]; [self.autotypePopupButton unbind:NSSelectedTagBinding]; [self.autotypeSequenceTextField unbind:NSValueBinding]; diff --git a/MacPass/MPOutlineViewController.m b/MacPass/MPOutlineViewController.m index 66ac9714..ed17e505 100644 --- a/MacPass/MPOutlineViewController.m +++ b/MacPass/MPOutlineViewController.m @@ -18,6 +18,8 @@ #import "MPOutlineContextMenuDelegate.h" #import "KPKTree.h" +#import "KPKNode.h" +#import "KPKTimeInfo.h" #import "KPKGroup.h" #import "KPKNode+IconImage.h" #import "KPKMetaData.h" @@ -25,6 +27,8 @@ #import "HNHGradientView.h" +#define EXPIRED_GROUP_REFRESH_SECONDS 60 + NSString *const MPOutlineViewDidChangeGroupSelection = @"com.macpass.MPOutlineViewDidChangeGroupSelection"; NSString *const _MPOutlineViewDataViewIdentifier = @"DataCell"; @@ -104,6 +108,8 @@ NSString *const _MPOutlinveViewHeaderViewIdentifier = @"HeaderCell"; [self bind:NSStringFromSelector(@selector(databaseNameWrapper)) toObject:document.tree.metaData withKeyPath:NSStringFromSelector(@selector(databaseName)) options:nil]; [_outlineView setDataSource:self.datasource]; _bindingEstablished = YES; + [self _updateExpirationDisplay]; + } NSTreeNode *node = [_outlineView itemAtRow:0]; [self _expandItems:node]; @@ -301,4 +307,13 @@ NSString *const _MPOutlinveViewHeaderViewIdentifier = @"HeaderCell"; return [node isKindOfClass:[KPKTree class]]; } +- (void)_updateExpirationDisplay { + MPDocument *document = [[self windowController] document]; + [document.root.timeInfo isExpired]; + [[document.tree allGroups] enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { + [[obj timeInfo] isExpired]; + }]; + [self performSelector:@selector(_updateExpirationDisplay) withObject:nil afterDelay:EXPIRED_GROUP_REFRESH_SECONDS]; +} + @end