From 3d8c0acf64b53425df434db1001034cae0683fa0 Mon Sep 17 00:00:00 2001 From: michael starke Date: Sun, 30 Mar 2014 14:11:26 +0200 Subject: [PATCH] Added warning image to FixAutotypeDialog to indicate possible MacPass corruptions --- MacPass/FixAutotypeWindow.xib | 44 ++++++++++++++++++------- MacPass/MPDocumentWindowController.h | 1 + MacPass/MPDocumentWindowController.m | 22 +++++++++---- MacPass/MPEntryViewController.m | 5 ++- MacPass/MPFixAutotypeWindowController.h | 2 +- MacPass/MPFixAutotypeWindowController.m | 31 +++++++++++++++-- 6 files changed, 83 insertions(+), 22 deletions(-) diff --git a/MacPass/FixAutotypeWindow.xib b/MacPass/FixAutotypeWindow.xib index 9a273801..45cb2e36 100644 --- a/MacPass/FixAutotypeWindow.xib +++ b/MacPass/FixAutotypeWindow.xib @@ -16,26 +16,35 @@ - - + + - + - + - + - + + + + + + + + + + @@ -62,7 +71,7 @@ - + @@ -79,13 +88,14 @@ + - + - + @@ -156,5 +166,15 @@ To fix this, you can select entries and clear their sequence. You may also custo + + + + + + + + + + diff --git a/MacPass/MPDocumentWindowController.h b/MacPass/MPDocumentWindowController.h index 37397876..9ad66d90 100644 --- a/MacPass/MPDocumentWindowController.h +++ b/MacPass/MPDocumentWindowController.h @@ -54,6 +54,7 @@ #pragma mark View Actions - (IBAction)toggleInspector:(id)sender; +- (IBAction)showInspector:(id)sender; - (IBAction)focusGroups:(id)sender; - (IBAction)focusEntries:(id)sender; - (IBAction)focusInspector:(id)sender; diff --git a/MacPass/MPDocumentWindowController.m b/MacPass/MPDocumentWindowController.m index 339eeac4..66a852e6 100644 --- a/MacPass/MPDocumentWindowController.m +++ b/MacPass/MPDocumentWindowController.m @@ -308,14 +308,11 @@ typedef void (^MPPasswordChangedBlock)(void); - (void)toggleInspector:(id)sender { NSView *inspectorView = [_inspectorViewController view]; - BOOL inspectorVisible = NO; - if([inspectorView superview]) { - //[inspectorView animator] + BOOL inspectorWasVisible = [self _isInspectorVisible]; + if(inspectorWasVisible) { [inspectorView removeFromSuperview]; } else { - // Remove contraint on view removal. - inspectorVisible = YES; [_splitView addSubview:inspectorView]; [_splitView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"[inspectorView(>=200)]" options:0 @@ -323,7 +320,11 @@ typedef void (^MPPasswordChangedBlock)(void); views:NSDictionaryOfVariableBindings(inspectorView)]]; [self.inspectorViewController updateResponderChain]; } - [[NSUserDefaults standardUserDefaults] setBool:inspectorVisible forKey:kMPSettingsKeyShowInspector]; + [[NSUserDefaults standardUserDefaults] setBool:!inspectorWasVisible forKey:kMPSettingsKeyShowInspector]; +} + +- (void)showInspector:(id)sender { + // TODO; } - (void)focusEntries:(id)sender { @@ -434,6 +435,10 @@ typedef void (^MPPasswordChangedBlock)(void); return; // Cancel or unknown } } + +#pragma mark - +#pragma mark UI Helper + - (void)_showDatabaseSetting:(MPDatabaseSettingsTab)tab { if(!self.documentSettingsWindowController) { _documentSettingsWindowController = [[MPDatabaseSettingsWindowController alloc] initWithDocument:[self document]]; @@ -447,4 +452,9 @@ typedef void (^MPPasswordChangedBlock)(void); } +- (BOOL)_isInspectorVisible { + NSView *inspectorView = [_inspectorViewController view]; + return (nil != [inspectorView superview]); +} + @end diff --git a/MacPass/MPEntryViewController.m b/MacPass/MPEntryViewController.m index 35fd9028..ed14a221 100644 --- a/MacPass/MPEntryViewController.m +++ b/MacPass/MPEntryViewController.m @@ -613,7 +613,10 @@ NSString *const _MPTAbleSecurCellView = @"PasswordCell"; } NSTableColumn *column = [self.entryTable tableColumns][[self.entryTable clickedColumn]]; NSString *identifier = [column identifier]; - if([identifier isEqualToString:MPEntryTablePasswordColumnIdentifier]) { + if([identifier isEqualToString:MPEntryTableTitleColumnIdentifier]) { + + } + else if([identifier isEqualToString:MPEntryTablePasswordColumnIdentifier]) { [self copyPassword:nil]; } else if([identifier isEqualToString:MPEntryTableUserNameColumnIdentifier]) { diff --git a/MacPass/MPFixAutotypeWindowController.h b/MacPass/MPFixAutotypeWindowController.h index c1d0326a..90d9cfff 100644 --- a/MacPass/MPFixAutotypeWindowController.h +++ b/MacPass/MPFixAutotypeWindowController.h @@ -16,7 +16,7 @@ @property (nonatomic, weak) MPDocument *workingDocument; /** - * Clears the autotype sequences for the selected entries + * Clears the autotype sequences for the selected entries, groups or window associations * * @param sender sender of the action */ diff --git a/MacPass/MPFixAutotypeWindowController.m b/MacPass/MPFixAutotypeWindowController.m index 46a45953..7f5090b9 100644 --- a/MacPass/MPFixAutotypeWindowController.m +++ b/MacPass/MPFixAutotypeWindowController.m @@ -14,9 +14,12 @@ #import "KPKAutotype.h" #import "KPKWindowAssociation.h" +#import "MPIconHelper.h" + NSString *const kMPAutotypeCell = @"AutotypeCell"; NSString *const kMPTitleCell = @"TitleCell"; NSString *const kMPIsDefaultCell = @"IsDefaultCell"; +NSString *const kMPIconCell = @"IconCell"; /* Helper Categries */ @@ -63,6 +66,10 @@ NSString *const kMPIsDefaultCell = @"IsDefaultCell"; [super windowDidLoad]; } +- (void)dealloc { + [self.window orderOut:self]; +} + #pragma mark - #pragma mark Properties @@ -139,18 +146,28 @@ NSString *const kMPIsDefaultCell = @"IsDefaultCell"; } return association.keystrokeSequence; } - else if([[tableColumn identifier] isEqualToString:kMPIsDefaultCell]) { + else { BOOL isDefault = NO; + NSString *keystrokeSequence; if(entry) { isDefault = entry.autotype.hasDefaultKeystrokeSequence; + keystrokeSequence = entry.autotype.defaultKeystrokeSequence; } else if( group ) { isDefault = group.hasDefaultAutotypeSequence; + keystrokeSequence = group.defaultAutoTypeSequence; } else { isDefault = association.hasDefaultKeystrokeSequence; + keystrokeSequence = association.keystrokeSequence; + } + if([[tableColumn identifier] isEqualToString:kMPIsDefaultCell]) { + return isDefault ? @"Yes" : @"No"; + } + else if( [[tableColumn identifier] isEqualToString:kMPIconCell]) { + BOOL isWrongFormat = (NSOrderedSame == [@"{TAB}{USERNAME}{TAB}{PASSWORD}{ENTER}" compare:keystrokeSequence options:NSCaseInsensitiveSearch]); + return (isWrongFormat && !isDefault) ? [MPIconHelper icon:MPIconWarning] : nil; } - return isDefault ? @"Yes" : @"No"; } return nil; } @@ -182,6 +199,16 @@ NSString *const kMPIsDefaultCell = @"IsDefaultCell"; return [item isKindOfClass:[KPKGroup class]]; } +#pragma mark - +#pragma mark MenuItem Validation + +- (BOOL)validateMenuItem:(NSMenuItem *)menuItem { + if(!([menuItem action] == @selector(clearAutotype:))) { + return NO; + } + return ([[self.tableView selectedRowIndexes] count] > 0); +} + #pragma mark - #pragma mark Data accessors