From 6e3af144bc812ab80e1ffedf058e0dd152504565 Mon Sep 17 00:00:00 2001 From: michael starke Date: Wed, 30 Sep 2015 15:10:08 +0200 Subject: [PATCH] Adopting new KeePassKit API Signed-off-by: michael starke --- DDHotKey | 2 +- MacPass.xcodeproj/project.pbxproj | 4 ++++ MacPass/MPDocument+Autotype.m | 2 +- MacPass/MPEntryInspectorViewController.m | 11 ++--------- MacPass/MPFixAutotypeWindowController.m | 14 +++++++------- 5 files changed, 15 insertions(+), 18 deletions(-) diff --git a/DDHotKey b/DDHotKey index dfab50eb..e6846463 160000 --- a/DDHotKey +++ b/DDHotKey @@ -1 +1 @@ -Subproject commit dfab50eb22782850ec836a92d56d16bdb6b5912a +Subproject commit e6846463e2fedd6742a5f10633e7cc1069555924 diff --git a/MacPass.xcodeproj/project.pbxproj b/MacPass.xcodeproj/project.pbxproj index ee98ec8b..8441bf65 100644 --- a/MacPass.xcodeproj/project.pbxproj +++ b/MacPass.xcodeproj/project.pbxproj @@ -917,6 +917,8 @@ 4CE39AC316ECE4F7000FE29D /* MPPopupImageView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPPopupImageView.m; sourceTree = ""; }; 4CE3E62417AB0D2D00D9E4B4 /* MPAttachmentTableDataSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPAttachmentTableDataSource.h; sourceTree = ""; }; 4CE3E62517AB0D2D00D9E4B4 /* MPAttachmentTableDataSource.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPAttachmentTableDataSource.m; sourceTree = ""; }; + 4CE5012C1BBC13C100FB819D /* KPKWindowAssociation+Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "KPKWindowAssociation+Private.h"; sourceTree = ""; }; + 4CE5012F1BBC15B600FB819D /* KPKAutotype+Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "KPKAutotype+Private.h"; sourceTree = ""; }; 4CE5B548173AFBA700207B39 /* MPDocument.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPDocument.h; sourceTree = ""; }; 4CE5B549173AFBA700207B39 /* MPDocument.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = MPDocument.m; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objc; }; 4CE76DAC17B3AD010043B82B /* KPKHashedDataTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KPKHashedDataTest.m; sourceTree = ""; }; @@ -1861,8 +1863,10 @@ 4CFC873C179DF200000DFC03 /* KPKTimeInfo.h */, 4CFC873D179DF200000DFC03 /* KPKTimeInfo.m */, 4C68456817BC21DD00FCDBFC /* KPKAutotype.h */, + 4CE5012F1BBC15B600FB819D /* KPKAutotype+Private.h */, 4C68456917BC21DD00FCDBFC /* KPKAutotype.m */, 4C68456B17BC227B00FCDBFC /* KPKWindowAssociation.h */, + 4CE5012C1BBC13C100FB819D /* KPKWindowAssociation+Private.h */, 4C68456C17BC227B00FCDBFC /* KPKWindowAssociation.m */, 4C8EB8BF18D399FD00438B08 /* KPKTag.h */, 4C8EB8C018D399FD00438B08 /* KPKTag.m */, diff --git a/MacPass/MPDocument+Autotype.m b/MacPass/MPDocument+Autotype.m index b43804b7..4549008d 100644 --- a/MacPass/MPDocument+Autotype.m +++ b/MacPass/MPDocument+Autotype.m @@ -108,7 +108,7 @@ } /* Fall back to preferred Entry if no match was found */ - if(contexts.count == 0 && usePreferredEntry) { + if(usePreferredEntry && contexts.count == 0 ) { context = [[MPAutotypeContext alloc] initWithEntry:entry andSequence:entry.autotype.defaultKeystrokeSequence]; if(context.valid) { [contexts addObject:context]; diff --git a/MacPass/MPEntryInspectorViewController.m b/MacPass/MPEntryInspectorViewController.m index b0dca59d..5d626b05 100644 --- a/MacPass/MPEntryInspectorViewController.m +++ b/MacPass/MPEntryInspectorViewController.m @@ -127,6 +127,7 @@ typedef NS_ENUM(NSUInteger, MPEntryTab) { } } + - (void)regsiterNotificationsForDocument:(MPDocument *)document { [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_didAddEntry:) @@ -198,7 +199,7 @@ typedef NS_ENUM(NSUInteger, MPEntryTab) { } - (void)addWindowAssociation:(id)sender { - KPKWindowAssociation *associtation = [[KPKWindowAssociation alloc] initWithWindow:NSLocalizedString(@"DEFAULT_WINDOW_TITLE", "") keystrokeSequence:nil]; + KPKWindowAssociation *associtation = [[KPKWindowAssociation alloc] initWithWindowTitle:NSLocalizedString(@"DEFAULT_WINDOW_TITLE", "") keystrokeSequence:nil]; [self.entry.autotype addAssociation:associtation]; } @@ -225,14 +226,6 @@ typedef NS_ENUM(NSUInteger, MPEntryTab) { } } -- (void)beginEditing { - [self _toggleEditing:YES]; - -} -- (void)endEditing { - [self _toggleEditing:NO]; -} - - (BOOL)validateMenuItem:(NSMenuItem *)menuItem { switch([MPActionHelper typeForAction:[menuItem action]]) { case MPActionToggleQuicklook: { diff --git a/MacPass/MPFixAutotypeWindowController.m b/MacPass/MPFixAutotypeWindowController.m index 7f11de75..d340c778 100644 --- a/MacPass/MPFixAutotypeWindowController.m +++ b/MacPass/MPFixAutotypeWindowController.m @@ -146,7 +146,7 @@ NSString *const kMPIconCell = @"IconCell"; } else { BOOL isMalformed = [MPDocument isCandidateForMalformedAutotype:item]; - BOOL isDefault = [entry.autotype hasDefaultKeystrokeSequence] || [group hasDefaultAutotypeSequence] || [association hasDefaultKeystrokeSequence]; + BOOL isDefault = entry.autotype.hasDefaultKeystrokeSequence || group.hasDefaultAutotypeSequence || association.hasDefaultKeystrokeSequence; if([[tableColumn identifier] isEqualToString:kMPIsDefaultCell]) { return isDefault ? @"Yes" : @"No"; } @@ -162,13 +162,13 @@ NSString *const kMPIconCell = @"IconCell"; id item = [self entriesAndGroups][row]; if([item isKindOfClass:[KPKEntry class]]) { - [[item autotype] setDefaultKeystrokeSequence:object]; + ((KPKEntry *)item).autotype.defaultKeystrokeSequence = object; } else if([item isKindOfClass:[KPKGroup class]]) { - [item setDefaultAutoTypeSequence:object]; + ((KPKGroup *)item).defaultAutoTypeSequence = object; } else if([item isKindOfClass:[KPKWindowAssociation class]]) { - [item setKeystrokeSequence:object]; + ((KPKWindowAssociation *)item).keystrokeSequence = object; } } @@ -176,7 +176,7 @@ NSString *const kMPIconCell = @"IconCell"; #pragma mark NSTableViewDelegate - (BOOL)tableView:(NSTableView *)tableView shouldEditTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row { - return [[tableColumn identifier] isEqualToString:kMPAutotypeCell]; + return [tableColumn.identifier isEqualToString:kMPAutotypeCell]; } - (BOOL)tableView:(NSTableView *)tableView isGroupRow:(NSInteger)row { @@ -188,10 +188,10 @@ NSString *const kMPIconCell = @"IconCell"; #pragma mark MenuItem Validation - (BOOL)validateMenuItem:(NSMenuItem *)menuItem { - if(!([menuItem action] == @selector(clearAutotype:))) { + if(!(menuItem.action == @selector(clearAutotype:))) { return NO; } - return ([[self.tableView selectedRowIndexes] count] > 0); + return (self.tableView.selectedRowIndexes.count > 0); } #pragma mark -