diff --git a/MacPass.xcodeproj/project.pbxproj b/MacPass.xcodeproj/project.pbxproj index 8b73c84c..70cccf18 100644 --- a/MacPass.xcodeproj/project.pbxproj +++ b/MacPass.xcodeproj/project.pbxproj @@ -233,6 +233,7 @@ 4CAD748E15B88AC100104512 /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 4CAD748D15B88AC100104512 /* libz.dylib */; }; 4CAF62FC1763604000CD7084 /* HNHBadgedTextFieldCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CAF62FB1763604000CD7084 /* HNHBadgedTextFieldCell.m */; }; 4CB4AA0D17C2274200454CAD /* KeePass1_native_test.kdb in Resources */ = {isa = PBXBuildFile; fileRef = 4CB4AA0C17C2274200454CAD /* KeePass1_native_test.kdb */; }; + 4CB4ED891997DA1800582DBB /* MPAutotypeHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CB4ED881997DA1800582DBB /* MPAutotypeHelper.m */; }; 4CB9339916D3A0DD00A13B5D /* Credits.rtf in Resources */ = {isa = PBXBuildFile; fileRef = 4CB9339716D3A0DD00A13B5D /* Credits.rtf */; }; 4CBA2ABA17074C07006D8139 /* MPSettingsHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CBA2AB917074C07006D8139 /* MPSettingsHelper.m */; }; 4CBA561617C2EA4900CE13D3 /* KPKTestXmlWriting.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CBA561517C2EA4900CE13D3 /* KPKTestXmlWriting.m */; }; @@ -781,6 +782,8 @@ 4CAF62FA1763604000CD7084 /* HNHBadgedTextFieldCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HNHBadgedTextFieldCell.h; sourceTree = ""; }; 4CAF62FB1763604000CD7084 /* HNHBadgedTextFieldCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HNHBadgedTextFieldCell.m; sourceTree = ""; }; 4CB4AA0C17C2274200454CAD /* KeePass1_native_test.kdb */ = {isa = PBXFileReference; lastKnownFileType = file; name = KeePass1_native_test.kdb; path = Databases/KeePass1_native_test.kdb; sourceTree = ""; }; + 4CB4ED871997DA1800582DBB /* MPAutotypeHelper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPAutotypeHelper.h; sourceTree = ""; }; + 4CB4ED881997DA1800582DBB /* MPAutotypeHelper.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPAutotypeHelper.m; sourceTree = ""; }; 4CB63A6018986530002DEC4C /* MPFlagsHelper.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MPFlagsHelper.h; sourceTree = ""; }; 4CB9339816D3A0DD00A13B5D /* en */ = {isa = PBXFileReference; lastKnownFileType = text.rtf; name = en; path = en.lproj/Credits.rtf; sourceTree = ""; }; 4CBA2AB617074B59006D8139 /* MPSettingsHelper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPSettingsHelper.h; sourceTree = ""; }; @@ -1597,6 +1600,8 @@ 4CD2B9051849424B0051B395 /* MPAutotypeContext.m */, 4CA3530918A53CB800839B0F /* MPKeyMapper.h */, 4CA3530A18A53CB800839B0F /* MPKeyMapper.m */, + 4CB4ED871997DA1800582DBB /* MPAutotypeHelper.h */, + 4CB4ED881997DA1800582DBB /* MPAutotypeHelper.m */, ); name = Autotype; sourceTree = ""; @@ -2394,6 +2399,7 @@ 4CE298EB1795FC2A00DF7BDB /* MPEntryContextMenuDelegate.m in Sources */, 4CC0D2CE17974A47000B4BDA /* MPCustomFieldTableViewDelegate.m in Sources */, 4CF5CF7418B7C81600B0C026 /* NSWindow+Shake.m in Sources */, + 4CB4ED891997DA1800582DBB /* MPAutotypeHelper.m in Sources */, 4CC0D2D117974A5A000B4BDA /* MPAttachmentTableViewDelegate.m in Sources */, 4C67D33017981A2B00A7BDFC /* HNHTokenField.m in Sources */, 4C67D33317981ABA00A7BDFC /* HNHTokenFieldCell.m in Sources */, diff --git a/MacPass/MPAutotypeHelper.h b/MacPass/MPAutotypeHelper.h new file mode 100644 index 00000000..540266fa --- /dev/null +++ b/MacPass/MPAutotypeHelper.h @@ -0,0 +1,23 @@ +// +// MPAutotypeHelper.h +// MacPass +// +// Created by Michael Starke on 10/08/14. +// Copyright (c) 2014 HicknHack Software GmbH. All rights reserved. +// + +#import + +@interface MPAutotypeHelper : NSObject + +/** + * Tests the given item for a possible wrong autotype format + * MacPass 0.4 and 0.4.1 did store wrong Autotype sequences and thus mangled database files + * + * @param item Item to test for malformation. Allowed Items are KPKNode, KPKEntry, KPKGroup and KPKAutotype + * + * @return YES if the given item is considered a possible candiate. NO in all other cases + */ ++ (BOOL)isCandidateForMalformedAutotype:(id)item; + +@end diff --git a/MacPass/MPAutotypeHelper.m b/MacPass/MPAutotypeHelper.m new file mode 100644 index 00000000..e5dcb53f --- /dev/null +++ b/MacPass/MPAutotypeHelper.m @@ -0,0 +1,35 @@ +// +// MPAutotypeHelper.m +// MacPass +// +// Created by Michael Starke on 10/08/14. +// Copyright (c) 2014 HicknHack Software GmbH. All rights reserved. +// + +#import "MPAutotypeHelper.h" + +#import "KPKGroup.h" +#import "KPKEntry.h" + +#import "KPKAutotype.h" +#import "KPKWindowAssociation.h" + +@implementation MPAutotypeHelper + ++ (BOOL)isCandidateForMalformedAutotype:(id)item { + + NSString *keystrokeSequence; + if([item isKindOfClass:[KPKEntry class]] && ![((KPKEntry *)item).autotype hasDefaultKeystrokeSequence]) { + keystrokeSequence = ((KPKEntry *)item).autotype.defaultKeystrokeSequence; + } + else if( [item isKindOfClass:[KPKGroup class]] && ![item hasDefaultAutotypeSequence]) { + keystrokeSequence = ((KPKGroup *)item).defaultAutoTypeSequence; + } + else if( [item isKindOfClass:[KPKWindowAssociation class]] && ![item hasDefaultKeystrokeSequence]){ + keystrokeSequence = ((KPKWindowAssociation *)item).keystrokeSequence; + } + /* if nothing is true, keystrokeSequence is nil an hence return is NO */ + return (NSOrderedSame == [@"{TAB}{USERNAME}{TAB}{PASSWORD}{ENTER}" compare:keystrokeSequence options:NSCaseInsensitiveSearch]); +} + +@end diff --git a/MacPass/MPIntegrationSettingsController.m b/MacPass/MPIntegrationSettingsController.m index 974782bb..07d5e006 100644 --- a/MacPass/MPIntegrationSettingsController.m +++ b/MacPass/MPIntegrationSettingsController.m @@ -12,6 +12,8 @@ @interface MPIntegrationSettingsController () +@property (copy) NSData *globalAutotypeKeyData; + @end @implementation MPIntegrationSettingsController @@ -38,10 +40,12 @@ NSString *serverKeyPath = [MPSettingsHelper defaultControllerPathForKey:kMPSettingsKeyEnableHttpServer]; NSString *globalAutotypeKeyPath = [MPSettingsHelper defaultControllerPathForKey:kMPSettingsKeyEnableGlobalAutotype]; NSString *quicklookKeyPath = [MPSettingsHelper defaultControllerPathForKey:kMPSettingsKeyEnableQuicklookPreview]; + NSString *globalAutotypeDataKeyPath = [MPSettingsHelper defaultControllerPathForKey:kMPSettingsKeyGlobalAutotypeKeyDataKey]; [self.enableServerCheckbutton bind:NSValueBinding toObject:defaultsController withKeyPath:serverKeyPath options:nil]; [self.enableServerCheckbutton setEnabled:NO]; [self.enableGlobalAutotypeCheckbutton bind:NSValueBinding toObject:defaultsController withKeyPath:globalAutotypeKeyPath options:nil]; [self.enableQuicklookCheckbutton bind:NSValueBinding toObject:defaultsController withKeyPath:quicklookKeyPath options:nil]; + [self.globalAutotypeKeyData bind:NSValueBinding toObject:defaultsController withKeyPath:globalAutotypeDataKeyPath options:nil]; } diff --git a/MacPass/MPSettingsHelper.h b/MacPass/MPSettingsHelper.h index 6c650029..0c68db09 100644 --- a/MacPass/MPSettingsHelper.h +++ b/MacPass/MPSettingsHelper.h @@ -47,10 +47,10 @@ APPKIT_EXTERN NSString *const kMPSettingsKeyRememeberdKeysForDatabases; APPKIT_EXTERN NSString *const kMPSettingsKeyRememberKeyFilesForDatabases; /* Autotype */ -APPKIT_EXTERN NSString *const kMPSettingsKeySendCommandForControlKey; -APPKIT_EXTERN NSString *const kMPSettingsKeyEnableGlobalAutotype; -APPKIT_EXTERN NSString *const kMPSettingsKeyGlobalAutotypeKeyDataKey; -APPKIT_EXTERN NSString *const kMPSettingsKeyDocumentsAutotypeFixNoteWasShown; +APPKIT_EXTERN NSString *const kMPSettingsKeySendCommandForControlKey; // Should MacPass swap control for command. This is usefull in a cross plattform environment +APPKIT_EXTERN NSString *const kMPSettingsKeyEnableGlobalAutotype; // Is Global Autotype enabled? +APPKIT_EXTERN NSString *const kMPSettingsKeyGlobalAutotypeKeyDataKey; // The stored Data for the useder defined global autotype key +APPKIT_EXTERN NSString *const kMPSettingsKeyDocumentsAutotypeFixNoteWasShown; // /* Search */ APPKIT_EXTERN NSString *const kMPSettingsKeyEntrySearchFilterMode;