diff --git a/MacPass/FixAutotypeWindow.xib b/MacPass/FixAutotypeWindow.xib index a4853e2c..9a273801 100644 --- a/MacPass/FixAutotypeWindow.xib +++ b/MacPass/FixAutotypeWindow.xib @@ -16,27 +16,27 @@ - - + + - + - + - + - + - + @@ -49,7 +49,7 @@ - + @@ -62,7 +62,7 @@ - + @@ -85,31 +85,34 @@ - + + + + + + Below is a list of all entries, groups and window associations for the database. Normally you should see most of the entries marked as default (YES) and with a keystroke sequence {USERNAME}{TAB}{ENTER}. If the sequence however is {TAB}{USERNAME}{TAB}{ENTER} and default is NO it's highly likely that MacPass (0.4 or 0.4.1) did fuck this up. +To fix this, you can select entries and clear their sequence. You may also customize any sequence to your liking. Inputs are NOT validated. + + + + + + - + + diff --git a/MacPass/MPAppDelegate.h b/MacPass/MPAppDelegate.h index 1bc4d8ea..4a90b065 100644 --- a/MacPass/MPAppDelegate.h +++ b/MacPass/MPAppDelegate.h @@ -35,7 +35,6 @@ FOUNDATION_EXTERN NSString *const MPDidChangeStoredKeyFilesSettings; - (IBAction)showPasswordCreator:(id)sender; - (IBAction)createNewDatabase:(id)sender; - (IBAction)openDatabase:(id)sender; -- (IBAction)fixAutotype:(id)sender; /** * Clears the stored key files for any documents. * @param sender sender of this action diff --git a/MacPass/MPAppDelegate.m b/MacPass/MPAppDelegate.m index 0bd01d0c..befc1be7 100644 --- a/MacPass/MPAppDelegate.m +++ b/MacPass/MPAppDelegate.m @@ -31,7 +31,6 @@ #import "MPLockDaemon.h" #import "MPAutotypeDaemon.h" #import "MPDocumentWindowController.h" -#import "MPFixAutotypeWindowController.h" #import "MPDockTileHelper.h" #import "MPTemporaryFileStorageCenter.h" @@ -52,7 +51,6 @@ NSString *const MPDidChangeStoredKeyFilesSettings = @"com.hicknhack.macpass.MPDi @property (strong, nonatomic) MPSettingsWindowController *settingsController; @property (strong, nonatomic) MPPasswordCreatorViewController *passwordCreatorController; -@property (strong) MPFixAutotypeWindowController *fixAutotypeWindowController; @end @@ -213,14 +211,6 @@ NSString *const MPDidChangeStoredKeyFilesSettings = @"com.hicknhack.macpass.MPDi [[NSUserDefaults standardUserDefaults] removeObjectForKey:kMPSettingsKeyRememeberdKeysForDatabases]; } -- (void)fixAutotype:(id)sender { - if(!self.fixAutotypeWindowController) { - self.fixAutotypeWindowController = [[MPFixAutotypeWindowController alloc] init]; - } - [self.fixAutotypeWindowController reset]; - [self.fixAutotypeWindowController setDocument:[[NSDocumentController sharedDocumentController] currentDocument]]; - [[self.fixAutotypeWindowController window] makeKeyAndOrderFront:sender]; -} #pragma mark - #pragma mark Private Helper diff --git a/MacPass/MPDocumentWindowController.h b/MacPass/MPDocumentWindowController.h index 76507bca..37397876 100644 --- a/MacPass/MPDocumentWindowController.h +++ b/MacPass/MPDocumentWindowController.h @@ -49,12 +49,16 @@ - (IBAction)pickIcon:(id)sender; - (IBAction)pickExpiryDate:(id)sender; +#pragma mark Helper +- (void)fixAutotype:(id)sender; + #pragma mark View Actions - (IBAction)toggleInspector:(id)sender; - (IBAction)focusGroups:(id)sender; - (IBAction)focusEntries:(id)sender; - (IBAction)focusInspector:(id)sender; + #pragma mark MPPasswordEditWindowDelegater - (void)didFinishPasswordEditing:(BOOL)changedPasswordOrKey; diff --git a/MacPass/MPDocumentWindowController.m b/MacPass/MPDocumentWindowController.m index ffa6521d..339eeac4 100644 --- a/MacPass/MPDocumentWindowController.m +++ b/MacPass/MPDocumentWindowController.m @@ -20,6 +20,7 @@ #import "MPConstants.h" #import "MPSettingsHelper.h" #import "MPDocumentWindowDelegate.h" +#import "MPFixAutotypeWindowController.h" #import "MPContextToolbarButton.h" #import "KPKTree.h" @@ -48,6 +49,7 @@ typedef void (^MPPasswordChangedBlock)(void); @property (strong) MPDocumentWindowDelegate *documentWindowDelegate; @property (strong) MPPasswordEditWindowController *passwordEditWindowController; @property (strong) MPToolbarDelegate *toolbarDelegate; +@property (strong) MPFixAutotypeWindowController *fixAutotypeWindowController; @property (nonatomic, copy) MPPasswordChangedBlock passwordChangedBlock; @@ -238,6 +240,14 @@ typedef void (^MPPasswordChangedBlock)(void); }]; } +- (void)fixAutotype:(id)sender { + if(!self.fixAutotypeWindowController) { + self.fixAutotypeWindowController = [[MPFixAutotypeWindowController alloc] init]; + } + self.fixAutotypeWindowController.workingDocument = [self document]; + [[self.fixAutotypeWindowController window] makeKeyAndOrderFront:sender]; +} + - (void)showPasswordInput { if(!self.passwordInputController) { self.passwordInputController = [[MPPasswordInputController alloc] init]; diff --git a/MacPass/MPFixAutotypeWindowController.h b/MacPass/MPFixAutotypeWindowController.h index bf2a6211..c1d0326a 100644 --- a/MacPass/MPFixAutotypeWindowController.h +++ b/MacPass/MPFixAutotypeWindowController.h @@ -13,6 +13,7 @@ @interface MPFixAutotypeWindowController : NSWindowController @property (weak) IBOutlet NSTableView *tableView; +@property (nonatomic, weak) MPDocument *workingDocument; /** * Clears the autotype sequences for the selected entries @@ -21,6 +22,4 @@ */ - (IBAction)clearAutotype:(id)sender; -- (void)reset; - @end diff --git a/MacPass/MPFixAutotypeWindowController.m b/MacPass/MPFixAutotypeWindowController.m index d92ef73b..46a45953 100644 --- a/MacPass/MPFixAutotypeWindowController.m +++ b/MacPass/MPFixAutotypeWindowController.m @@ -12,18 +12,15 @@ #import "KPKEntry.h" #import "KPKGroup.h" #import "KPKAutotype.h" +#import "KPKWindowAssociation.h" NSString *const kMPAutotypeCell = @"AutotypeCell"; NSString *const kMPTitleCell = @"TitleCell"; NSString *const kMPIsDefaultCell = @"IsDefaultCell"; -@interface KPKGroup (Breadcrumb) +/* Helper Categries */ -- (NSString *)breadcrumb; - -@end - -@implementation KPKGroup (Breadcrumb) +@implementation KPKGroup (MPFixAutotypeWindowControllerBreadCrumb) - (NSString *)breadcrumb { if(self.parent) { @@ -34,12 +31,20 @@ NSString *const kMPIsDefaultCell = @"IsDefaultCell"; @end -@interface MPFixAutotypeWindowController () { - NSMutableArray *_elements; +@implementation KPKWindowAssociation (MPFixAutotypeWindowControllerQualifedName) + +- (NSString *)qualifedName { + return [[NSString alloc] initWithFormat:@"%@ (%@)", self.windowTitle, self.autotype.entry.title ]; } @end +@interface MPFixAutotypeWindowController () { + NSMutableArray *_elements; +} +@end + + @implementation MPFixAutotypeWindowController - (instancetype)init { @@ -58,32 +63,39 @@ NSString *const kMPIsDefaultCell = @"IsDefaultCell"; [super windowDidLoad]; } -- (void)reset { + +#pragma mark - +#pragma mark Properties + +- (void)setWorkingDocument:(MPDocument *)workingDocument { + if(_workingDocument != workingDocument) { + _workingDocument = workingDocument; + } _elements = nil; [self.tableView reloadData]; } - #pragma mark - #pragma mark Actions - (void)clearAutotype:(id)sender { - - MPDocument *document = [self document]; - [[document undoManager] beginUndoGrouping]; + [[self.workingDocument undoManager] beginUndoGrouping]; NSIndexSet *indexes = [self.tableView selectedRowIndexes]; MPFixAutotypeWindowController __weak *weakSelf = self; [indexes enumerateIndexesUsingBlock:^(NSUInteger idx, BOOL *stop) { id item = [weakSelf entriesAndGroups][idx]; - if([item respondsToSelector:@selector(defaultAutoTypeSequence)]) { + if([item isKindOfClass:[KPKEntry class]]){ + [item autotype].defaultKeystrokeSequence = nil; + } + else if([item isKindOfClass:[KPKGroup class]]) { [item setDefaultAutoTypeSequence:nil]; } else { - [item autotype].defaultKeystrokeSequence = nil; + [item setKeystrokeSequence:nil]; } }]; - [[document undoManager] endUndoGrouping]; - [[document undoManager] setActionName:@"Clear Autotype"]; + [[self.workingDocument undoManager] endUndoGrouping]; + [[self.workingDocument undoManager] setActionName:@"Clear Autotype"]; [self.tableView reloadDataForRowIndexes:indexes columnIndexes:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0,2)]]; } @@ -95,26 +107,48 @@ NSString *const kMPIsDefaultCell = @"IsDefaultCell"; } - (id)tableView:(NSTableView *)tableView objectValueForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row { - id node = [self entriesAndGroups][row]; + id item = [self entriesAndGroups][row]; + KPKGroup *group; + KPKEntry *entry; + KPKWindowAssociation *association; + if([item isKindOfClass:[KPKEntry class]]) { + entry = item; + } + else if([item isKindOfClass:[KPKGroup class]]) { + group = item; + } + else if([item isKindOfClass:[KPKWindowAssociation class]]) { + association = item; + } + if([[tableColumn identifier] isEqualToString:kMPTitleCell]) { - if( [node respondsToSelector:@selector(title)]) { - return [node title]; + if(entry) { + return entry.title; } - return [node breadcrumb]; + if(group) { + return [group breadcrumb]; + } + return [association qualifedName]; } else if ([[tableColumn identifier] isEqualToString:kMPAutotypeCell]) { - if([node respondsToSelector:@selector(defaultAutoTypeSequence)]) { - return [node defaultAutoTypeSequence]; + if(entry) { + return entry.autotype.defaultKeystrokeSequence; } - return [[node autotype] defaultKeystrokeSequence]; + if(group) { + return group.defaultAutoTypeSequence; + } + return association.keystrokeSequence; } else if([[tableColumn identifier] isEqualToString:kMPIsDefaultCell]) { BOOL isDefault = NO; - if([node respondsToSelector:@selector(hasDefaultAutotypeSequence)]) { - isDefault = [node hasDefaultAutotypeSequence]; + if(entry) { + isDefault = entry.autotype.hasDefaultKeystrokeSequence; + } + else if( group ) { + isDefault = group.hasDefaultAutotypeSequence; } else { - isDefault = [[node autotype] hasDefaultKeystrokeSequence]; + isDefault = association.hasDefaultKeystrokeSequence; } return isDefault ? @"Yes" : @"No"; } @@ -124,12 +158,16 @@ NSString *const kMPIsDefaultCell = @"IsDefaultCell"; - (void)tableView:(NSTableView *)tableView setObjectValue:(id)object forTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row { id item = [self entriesAndGroups][row]; - if([item respondsToSelector:@selector(defaultAutoTypeSequence)]) { - [item setDefaultAutoTypeSequence:object]; - } - else { + + if([item isKindOfClass:[KPKEntry class]]) { [[item autotype] setDefaultKeystrokeSequence:object]; } + else if([item isKindOfClass:[KPKGroup class]]) { + [item setDefaultKeystrokeSequence:object]; + } + else if([item isKindOfClass:[KPKWindowAssociation class]]) { + [item setKeystrokeSequence:object]; + } } #pragma mark - @@ -150,8 +188,7 @@ NSString *const kMPIsDefaultCell = @"IsDefaultCell"; - (NSArray *)entriesAndGroups { if(nil == _elements) { _elements = [[NSMutableArray alloc] init]; - MPDocument *document = [self document]; - [self flattenGroup:document.root toArray:_elements]; + [self flattenGroup:self.workingDocument.root toArray:_elements]; } return _elements; } @@ -159,7 +196,10 @@ NSString *const kMPIsDefaultCell = @"IsDefaultCell"; - (void)flattenGroup:(KPKGroup *)group toArray:(NSMutableArray *)array { [array addObject:group]; - [array addObjectsFromArray:group.entries]; + for(KPKEntry *entry in group.entries) { + [array addObject:entry]; + [array addObjectsFromArray:entry.autotype.associations]; + } for(KPKGroup *childGroup in group.groups) { [self flattenGroup:childGroup toArray:array]; }