From 0315254e3e0c24002d0a0fcd02a6ab4acb268c81 Mon Sep 17 00:00:00 2001 From: michael starke Date: Thu, 30 Oct 2014 20:11:50 +0100 Subject: [PATCH] Fix Autotype window now displays content again --- MacPass/MPEntryInspectorViewController.m | 2 +- MacPass/MPFixAutotypeWindowController.m | 29 +++++++++--------------- 2 files changed, 12 insertions(+), 19 deletions(-) diff --git a/MacPass/MPEntryInspectorViewController.m b/MacPass/MPEntryInspectorViewController.m index a6394364..c2624d43 100644 --- a/MacPass/MPEntryInspectorViewController.m +++ b/MacPass/MPEntryInspectorViewController.m @@ -420,7 +420,7 @@ typedef NS_ENUM(NSUInteger, MPEntryTab) { [self.enableAutotypeCheckButton bind:NSValueBinding toObject:self.entry.autotype withKeyPath:NSStringFromSelector(@selector(isEnabled)) options:nil]; [self.obfuscateAutotypeCheckButton bind:NSValueBinding toObject:self.entry.autotype withKeyPath:NSStringFromSelector(@selector(obfuscateDataTransfer)) options:nil]; [self.customEntrySequenceTextField bind:NSEnabledBinding toObject:self.entry.autotype withKeyPath:NSStringFromSelector(@selector(isEnabled)) options:nil]; - [self.customEntrySequenceTextField bind:NSValueBinding toObject:self.entry.autotype withKeyPath:NSStringFromSelector(@selector(defaultKeystrokeSequence)) options:nil]; + [self.customEntrySequenceTextField bind:NSValueBinding toObject:self.entry.autotype withKeyPath:NSStringFromSelector(@selector(defaultKeystrokeSequence)) options:@{ NSValidatesImmediatelyBindingOption: @(YES) }]; [_windowAssociationsController bind:NSContentArrayBinding toObject:self.entry.autotype withKeyPath:NSStringFromSelector(@selector(associations)) options:nil]; } else { diff --git a/MacPass/MPFixAutotypeWindowController.m b/MacPass/MPFixAutotypeWindowController.m index b27f02b5..499f7ac0 100644 --- a/MacPass/MPFixAutotypeWindowController.m +++ b/MacPass/MPFixAutotypeWindowController.m @@ -25,6 +25,13 @@ NSString *const kMPIsDefaultCell = @"IsDefaultCell"; NSString *const kMPIconCell = @"IconCell"; +@interface KPKWindowAssociation (MPFixAutotypeWindowControllerQualifedName) + +@property (nonatomic, readonly) NSString *qualifedName; + +@end + + @implementation KPKWindowAssociation (MPFixAutotypeWindowControllerQualifedName) - (NSString *)qualifedName { @@ -119,7 +126,7 @@ NSString *const kMPIconCell = @"IconCell"; association = item; } - if(nil == entry || nil == group || nil == association) { + if(nil == entry && nil == group && nil == association) { return nil; } @@ -142,26 +149,12 @@ NSString *const kMPIconCell = @"IconCell"; return association.keystrokeSequence; } 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; - } + BOOL isMalformed = [MPDocument isCandidateForMalformedAutotype:item]; if([[tableColumn identifier] isEqualToString:kMPIsDefaultCell]) { - return isDefault ? @"Yes" : @"No"; + return isMalformed ? @"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 isMalformed ? [MPIconHelper icon:MPIconWarning] : nil; } } return nil;