diff --git a/KeePassKit b/KeePassKit index 82474805..6465dd35 160000 --- a/KeePassKit +++ b/KeePassKit @@ -1 +1 @@ -Subproject commit 824748058c205c242aeb966851b0706293f70743 +Subproject commit 6465dd35327de9c2d68365dac8de98e7ed15a7d4 diff --git a/MacPass.xcodeproj/project.pbxproj b/MacPass.xcodeproj/project.pbxproj index 42335bbe..990cf472 100644 --- a/MacPass.xcodeproj/project.pbxproj +++ b/MacPass.xcodeproj/project.pbxproj @@ -125,6 +125,7 @@ 4C586FA216D07F6A00E7DB57 /* 02_MessageBoxWarningTemplate.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 4C586FA116D07F6A00E7DB57 /* 02_MessageBoxWarningTemplate.pdf */; }; 4C58BD4F176370B100B8178C /* HNHBadgedTextField.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C58BD4E176370B100B8178C /* HNHBadgedTextField.m */; }; 4C591B57178F897A0080B16B /* KPKBinary.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C591B56178F897A0080B16B /* KPKBinary.m */; }; + 4C59745118B3CE7200C8EBD1 /* KPKTestAutotypeNormalization.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C59745018B3CE7200C8EBD1 /* KPKTestAutotypeNormalization.m */; }; 4C5A11FE1708DE8700223D8A /* MPPasswordCreatorViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C5A11FC1708DE8700223D8A /* MPPasswordCreatorViewController.m */; }; 4C5A11FF1708DE8800223D8A /* PasswordCreatorView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4C5A11FD1708DE8700223D8A /* PasswordCreatorView.xib */; }; 4C5AA591179549A1008ECAD7 /* KPKXmlTreeWriter.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C5AA590179549A1008ECAD7 /* KPKXmlTreeWriter.m */; }; @@ -233,7 +234,6 @@ 4CC6DB7A17D23719002C6091 /* KPKNode+IconImage.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CC6DB7917D23719002C6091 /* KPKNode+IconImage.m */; }; 4CC6DB7D17D23DCE002C6091 /* KPKUTIs.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CC6DB7C17D23DCE002C6091 /* KPKUTIs.m */; }; 4CC7EA1B17807E7E0089D4F3 /* HNHRoundedTextFieldCellHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CC7EA1A17807E7E0089D4F3 /* HNHRoundedTextFieldCellHelper.m */; }; - 4CC87EA31847FDDA005AA18D /* MPAutotypeParser.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CC87EA21847FDDA005AA18D /* MPAutotypeParser.m */; }; 4CCEDE2A179F203B008402BE /* MPOutlineView.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CCEDE29179F203B008402BE /* MPOutlineView.m */; }; 4CCEDE2E179F213B008402BE /* MPNotifications.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CCEDE2D179F213B008402BE /* MPNotifications.m */; }; 4CCEDE32179F5B6C008402BE /* KPKDataStreamReader.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CCEDE31179F5B6C008402BE /* KPKDataStreamReader.m */; }; @@ -364,7 +364,7 @@ 4C08C3AD17B3022400BBBC95 /* KPKLegacyHeaderWriter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KPKLegacyHeaderWriter.m; sourceTree = ""; }; 4C08C3AF17B3036500BBBC95 /* KPKLegacyFormat.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = KPKLegacyFormat.h; path = Format/KPKLegacyFormat.h; sourceTree = ""; }; 4C0C59EF18B17F10009C7B76 /* DDHotKeyUtilities.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = DDHotKeyUtilities.m; path = DDHotKey/DDHotKeyUtilities.m; sourceTree = ""; }; - 4C0C59F018B17F10009C7B76 /* DDHotKeyUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DDHotKeyUtilities.h; path = DDHotKey/DDHotKeyUtilities.h; sourceTree = ""; }; + 4C0C59F018B17F10009C7B76 /* DDHotKeyUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; name = DDHotKeyUtilities.h; path = DDHotKey/DDHotKeyUtilities.h; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; }; 4C0DD6C518B2A44700FCB193 /* AutotypeCandidateSelectionWindow.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = AutotypeCandidateSelectionWindow.xib; sourceTree = ""; }; 4C0F647617B6B65E00D9522A /* MPSheetWindowController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPSheetWindowController.h; sourceTree = ""; }; 4C0F647717B6B65E00D9522A /* MPSheetWindowController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPSheetWindowController.m; sourceTree = ""; }; @@ -452,15 +452,15 @@ 4C245B60176E1E3D0086100E /* GCDAsyncSocket.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GCDAsyncSocket.h; sourceTree = ""; }; 4C245B61176E1E3D0086100E /* GCDAsyncSocket.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GCDAsyncSocket.m; sourceTree = ""; }; 4C245B64176E1E3D0086100E /* DDAbstractDatabaseLogger.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DDAbstractDatabaseLogger.h; sourceTree = ""; }; - 4C245B65176E1E3D0086100E /* DDAbstractDatabaseLogger.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DDAbstractDatabaseLogger.m; sourceTree = ""; }; + 4C245B65176E1E3D0086100E /* DDAbstractDatabaseLogger.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = DDAbstractDatabaseLogger.m; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objc; }; 4C245B66176E1E3D0086100E /* DDASLLogger.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DDASLLogger.h; sourceTree = ""; }; 4C245B67176E1E3D0086100E /* DDASLLogger.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DDASLLogger.m; sourceTree = ""; }; 4C245B68176E1E3D0086100E /* DDFileLogger.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DDFileLogger.h; sourceTree = ""; }; - 4C245B69176E1E3D0086100E /* DDFileLogger.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DDFileLogger.m; sourceTree = ""; }; + 4C245B69176E1E3D0086100E /* DDFileLogger.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = DDFileLogger.m; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objc; }; 4C245B6A176E1E3D0086100E /* DDLog.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DDLog.h; sourceTree = ""; }; - 4C245B6B176E1E3D0086100E /* DDLog.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DDLog.m; sourceTree = ""; }; + 4C245B6B176E1E3D0086100E /* DDLog.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = DDLog.m; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objc; }; 4C245B6C176E1E3D0086100E /* DDTTYLogger.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DDTTYLogger.h; sourceTree = ""; }; - 4C245B6D176E1E3D0086100E /* DDTTYLogger.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DDTTYLogger.m; sourceTree = ""; }; + 4C245B6D176E1E3D0086100E /* DDTTYLogger.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = DDTTYLogger.m; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objc; }; 4C245B6F176E1E3D0086100E /* ContextFilterLogFormatter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ContextFilterLogFormatter.h; sourceTree = ""; }; 4C245B70176E1E3D0086100E /* ContextFilterLogFormatter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ContextFilterLogFormatter.m; sourceTree = ""; }; 4C245B71176E1E3D0086100E /* DispatchQueueLogFormatter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DispatchQueueLogFormatter.h; sourceTree = ""; }; @@ -552,6 +552,7 @@ 4C58BD4E176370B100B8178C /* HNHBadgedTextField.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HNHBadgedTextField.m; sourceTree = ""; }; 4C591B55178F897A0080B16B /* KPKBinary.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KPKBinary.h; sourceTree = ""; }; 4C591B56178F897A0080B16B /* KPKBinary.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KPKBinary.m; sourceTree = ""; }; + 4C59745018B3CE7200C8EBD1 /* KPKTestAutotypeNormalization.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KPKTestAutotypeNormalization.m; sourceTree = ""; }; 4C5A11FB1708DE8700223D8A /* MPPasswordCreatorViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPPasswordCreatorViewController.h; sourceTree = ""; }; 4C5A11FC1708DE8700223D8A /* MPPasswordCreatorViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPPasswordCreatorViewController.m; sourceTree = ""; }; 4C5A11FD1708DE8700223D8A /* PasswordCreatorView.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = PasswordCreatorView.xib; sourceTree = ""; }; @@ -751,8 +752,6 @@ 4CC6DB7C17D23DCE002C6091 /* KPKUTIs.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KPKUTIs.m; sourceTree = ""; }; 4CC7EA1917807E7E0089D4F3 /* HNHRoundedTextFieldCellHelper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HNHRoundedTextFieldCellHelper.h; sourceTree = ""; }; 4CC7EA1A17807E7E0089D4F3 /* HNHRoundedTextFieldCellHelper.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HNHRoundedTextFieldCellHelper.m; sourceTree = ""; }; - 4CC87EA11847FDDA005AA18D /* MPAutotypeParser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPAutotypeParser.h; sourceTree = ""; }; - 4CC87EA21847FDDA005AA18D /* MPAutotypeParser.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPAutotypeParser.m; sourceTree = ""; }; 4CCA7EEC1797866F00B0B55E /* de */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = de; path = de.lproj/GeneralSettings.strings; sourceTree = ""; }; 4CCA7EEE1797867200B0B55E /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/GeneralSettings.strings; sourceTree = ""; }; 4CCEDE28179F203B008402BE /* MPOutlineView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPOutlineView.h; sourceTree = ""; }; @@ -1248,6 +1247,7 @@ 4CBA561517C2EA4900CE13D3 /* KPKTestXmlWriting.m */, 4C473A7E18AFD6340073FD2E /* KPKTestReference.m */, 4CD25F9218B17A17006098E9 /* KPKTestUUIDAdditions.m */, + 4C59745018B3CE7200C8EBD1 /* KPKTestAutotypeNormalization.m */, ); path = MacPassTests; sourceTree = ""; @@ -1428,8 +1428,6 @@ 4C90757B18A42E7A00E598DA /* Commands */, 4CEE46DB181C301D006BF1E5 /* MPAutotypeDaemon.h */, 4CEE46DC181C301D006BF1E5 /* MPAutotypeDaemon.m */, - 4CC87EA11847FDDA005AA18D /* MPAutotypeParser.h */, - 4CC87EA21847FDDA005AA18D /* MPAutotypeParser.m */, 4CD2B9041849424B0051B395 /* MPAutotypeContext.h */, 4CD2B9051849424B0051B395 /* MPAutotypeContext.m */, 4CA3530918A53CB800839B0F /* MPKeyMapper.h */, @@ -2065,6 +2063,7 @@ 4C6366AF17AF207600AAF17D /* KPKTestHexColor.m in Sources */, 4CE76DAD17B3AD010043B82B /* KPKHashedDataTest.m in Sources */, 4CEAF85B17BA9B44001307A6 /* KPKTestKeyfileParsing.m in Sources */, + 4C59745118B3CE7200C8EBD1 /* KPKTestAutotypeNormalization.m in Sources */, 4C6FDD2117BC4F4C004AEEC8 /* KPKTestPlaceholder.m in Sources */, 4CBA561617C2EA4900CE13D3 /* KPKTestXmlWriting.m in Sources */, ); @@ -2095,7 +2094,6 @@ 4C61EA0316D2FD0800AC519E /* MPOutlineViewController.m in Sources */, 4C69A73A16D589DF00EC1B1A /* HNHGradientView.m in Sources */, 4C65C79C16DD283900E32CFF /* MPToolbarButton.m in Sources */, - 4CC87EA31847FDDA005AA18D /* MPAutotypeParser.m in Sources */, 4C431BCD16E2A82800700A81 /* MPPasteBoardController.m in Sources */, 4CE8246F16E2E93400573141 /* MPOverlayWindowController.m in Sources */, 4CE8247516E2F2B900573141 /* MPOverlayView.m in Sources */, diff --git a/MacPass/MPAppDelegate.h b/MacPass/MPAppDelegate.h index f5f87874..4a90b065 100644 --- a/MacPass/MPAppDelegate.h +++ b/MacPass/MPAppDelegate.h @@ -22,7 +22,7 @@ #import -extern NSString *const MPDidChangeStoredKeyFilesSettings; +FOUNDATION_EXTERN NSString *const MPDidChangeStoredKeyFilesSettings; @interface MPAppDelegate : NSObject diff --git a/MacPass/MPAutotypeCommand.h b/MacPass/MPAutotypeCommand.h index b4f5a3a6..9e8a24c2 100644 --- a/MacPass/MPAutotypeCommand.h +++ b/MacPass/MPAutotypeCommand.h @@ -19,6 +19,8 @@ @property (readonly, strong) MPAutotypeContext *context; + ++ (NSArray *)commandsForContext:(MPAutotypeContext *)context; /** * Sends a KeyPress Event with the supplied modifier flags and Keycode * Any existing modifiers will be disabled for this event. If the user diff --git a/MacPass/MPAutotypeCommand.m b/MacPass/MPAutotypeCommand.m index e8fdaafd..6b3604f9 100644 --- a/MacPass/MPAutotypeCommand.m +++ b/MacPass/MPAutotypeCommand.m @@ -15,6 +15,12 @@ @implementation MPAutotypeCommand ++ (NSArray *)commandsForContext:(MPAutotypeContext *)context { + NSError *error; + NSRegularExpression *regularExpression = [[NSRegularExpression alloc] initWithPattern:@"" options:0 error:&error]; + return nil; +} + - (void)sendPressKey:(CGKeyCode)keyCode modifierFlags:(CGEventFlags)flags { CGEventRef pressKey = CGEventCreateKeyboardEvent (NULL, keyCode, YES); CGEventRef releaseKey = CGEventCreateKeyboardEvent (NULL, keyCode, NO); diff --git a/MacPass/MPAutotypeContext.h b/MacPass/MPAutotypeContext.h index dca05f68..2c61ae74 100644 --- a/MacPass/MPAutotypeContext.h +++ b/MacPass/MPAutotypeContext.h @@ -11,12 +11,20 @@ @class KPKEntry; @class KPKWindowAssociation; +/** + * Context for a autotype command run. + * It stores the Entry and corresponding sequence to use for autotyping + */ @interface MPAutotypeContext : NSObject +/** + * The entry associated with the command sequence. + */ @property (nonatomic, strong) KPKEntry *entry; +/** + * The command in normalized (see NSString+Commands) + */ @property (nonatomic, copy) NSString *command; -@property (nonatomic, assign, readonly) BOOL isCommand; -@property (nonatomic, assign) NSInteger value; /** * Designated initializer diff --git a/MacPass/MPAutotypeContext.m b/MacPass/MPAutotypeContext.m index aae4fdeb..0e920a72 100644 --- a/MacPass/MPAutotypeContext.m +++ b/MacPass/MPAutotypeContext.m @@ -11,12 +11,7 @@ #import "KPKAutotype.h" #import "KPKEntry.h" #import "KPKWindowAssociation.h" - -@interface MPAutotypeContext () - -@property (nonatomic, assign) BOOL isCommand; - -@end +#import "NSString+Commands.h" @implementation MPAutotypeContext @@ -32,41 +27,9 @@ - (instancetype)initWithEntry:(KPKEntry *)entry andSequence:(NSString *)sequence { self = [super init]; - /* - Parse the sequence to determine a possible Value? - DELAY - TAB - VKEY - */ if(self) { - if(entry == nil || sequence == nil) { - self = nil; - } - else { - self.entry = entry; - NSError *error; - NSRegularExpression *regexp = [[NSRegularExpression alloc] initWithPattern:@"\\{([a-z]+)?([0-9]*)\\}" options:NSRegularExpressionCaseInsensitive error:&error]; - if(regexp) { - [regexp enumerateMatchesInString:sequence options:0 range:NSMakeRange(0, [sequence length]) usingBlock:^(NSTextCheckingResult *result, NSMatchingFlags flags, BOOL *stop) { - NSRange commandRange = [result rangeAtIndex:1]; - NSRange valueRange = [result rangeAtIndex:2]; - if(commandRange.location != NSNotFound && commandRange.length != 0) { - self.command = [sequence substringWithRange:commandRange]; - self.isCommand = YES; - } - if(valueRange.location != NSNotFound && valueRange.length != 0) { - self.value = [[sequence substringWithRange:valueRange] integerValue]; - } - else { - self.value = NSNotFound; - } - }]; - } - else { - NSLog(@"Error while trying to parse Autotype sequence: %@", [error localizedDescription]); - } - - } + _command = [[sequence normalizedCommand] copy]; + _entry = entry; } return self; } diff --git a/MacPass/MPAutotypeParser.h b/MacPass/MPAutotypeParser.h deleted file mode 100644 index fa4dd61f..00000000 --- a/MacPass/MPAutotypeParser.h +++ /dev/null @@ -1,15 +0,0 @@ -// -// MPAutotypeParser.h -// MacPass -// -// Created by Michael Starke on 28/11/13. -// Copyright (c) 2013 HicknHack Software GmbH. All rights reserved. -// - -#import - -@interface MPAutotypeParser : NSObject - -+ (NSArray *)commandsForCommandString:(NSString *)commands; - -@end diff --git a/MacPass/MPAutotypeParser.m b/MacPass/MPAutotypeParser.m deleted file mode 100644 index 66c1f8ea..00000000 --- a/MacPass/MPAutotypeParser.m +++ /dev/null @@ -1,110 +0,0 @@ -// -// MPAutotypeParser.m -// MacPass -// -// Created by Michael Starke on 28/11/13. -// Copyright (c) 2013 HicknHack Software GmbH. All rights reserved. -// - -#import "MPAutotypeParser.h" - -#import "KPKAutotypeCommands.h" - -@implementation MPAutotypeParser - -+ (NSArray *)commandsForCommandString:(NSString *)commands { - NSUInteger commandIndex = 0; - CGEventFlags modiferKeys = 0; - while(commandIndex <= [commands length]) { - /* Modifier Keys - Shift + - Ctrl ^ - Alt % - */ - NSString *currentCommands = [commands substringFromIndex:commandIndex]; - NSCharacterSet *modifierKeySet = [NSCharacterSet characterSetWithCharactersInString:@"+^%"]; - NSRange modifierRange = [currentCommands rangeOfCharacterFromSet:modifierKeySet options:NSCaseInsensitiveSearch range:NSMakeRange(0, 1)]; - if(modifierRange.length != 0 && modifierRange.location == 0) { - /* starts with a special key */ - if([currentCommands hasPrefix:kMPAutotypeShortShift]) { - modiferKeys |= kCGEventFlagMaskAlphaShift; - } - if([currentCommands hasPrefix:kMPAutotypeShortControl]) { - modiferKeys |= kCGEventFlagMaskControl; - } - if([currentCommands hasPrefix:kMPAutotypeShortAlt]) { - modiferKeys = kCGEventFlagMaskAlternate; - } - /* move the index and continue */ - commandIndex++; - continue; - } - if([currentCommands hasPrefix:@"{"]) { - /* Commands reset the modifiers */ - modiferKeys = 0; - NSRange closeBracket = [currentCommands rangeOfString:@"}"]; - if(closeBracket.length == 0) { - NSLog(@"Syntax error in Autotype Sequence %@ at index: %ld", commands, commandIndex); - return nil; - } - NSString *singleCommand = [currentCommands substringWithRange:NSMakeRange(0, closeBracket.location)]; - - } - else { - - } - /* Search on to another bracket or a special key */ - - /* Command Keys - Tab {TAB} - Enter {ENTER} or ~ - Arrow Up {UP} - Arrow Down {DOWN} - Arrow Left {LEFT} - Arrow Right {RIGHT} - Insert {INSERT} or {INS} - Delete {DELETE} or {DEL} - Home {HOME} - End {END} - Page Up {PGUP} - Page Down {PGDN} - Backspace {BACKSPACE}, {BS} or {BKSP} - Break {BREAK} - Caps-Lock {CAPSLOCK} - Escape {ESC} - Windows Key {WIN} (equ. to {LWIN}) - Windows Key: left, right {LWIN}, {RWIN} - Apps / Menu {APPS} - Help {HELP} - Numlock {NUMLOCK} - Print Screen {PRTSC} - Scroll Lock {SCROLLLOCK} - F1 - F16 {F1} - {F16} - Numeric Keypad + {ADD} - Numeric Keypad - {SUBTRACT} - Numeric Keypad * {MULTIPLY} - Numeric Keypad / {DIVIDE} - Numeric Keypad 0 to 9 {NUMPAD0} to {NUMPAD9} - + {+} - ^ {^} - % {%} - ~ {~} - (, ) {(}, {)} - [, ] {[}, {]} - {, } {{}, {}} {LCURL}, {RCURL} - - */ - } - return nil; -} - -+ (NSString *)_normalizeCommands:(NSString *)commandString { - /* Cache normalized Commands? */ - NSMutableString *mutableCommand = [commandString mutableCopy]; - [mutableCommand replaceOccurrencesOfString:kMPAutotypeShortEnter withString:kMPAutotypeEnter options:NSCaseInsensitiveSearch range:NSMakeRange(0, [mutableCommand length])]; - [mutableCommand replaceOccurrencesOfString:@"{{}" withString:@"{LCURL}" options:NSCaseInsensitiveSearch range:NSMakeRange(0, [mutableCommand length])]; - [mutableCommand replaceOccurrencesOfString:@"{}}" withString:@"{RCURL}" options:NSCaseInsensitiveSearch range:NSMakeRange(0, [mutableCommand length])]; - return nil; -} - -@end diff --git a/MacPass/MPIconSelectViewController.h b/MacPass/MPIconSelectViewController.h index 900a9166..a3d3b230 100644 --- a/MacPass/MPIconSelectViewController.h +++ b/MacPass/MPIconSelectViewController.h @@ -8,7 +8,7 @@ #import "MPViewController.h" -extern NSInteger const kMPDefaultIcon; +FOUNDATION_EXTERN NSInteger const kMPDefaultIcon; @interface MPIconSelectViewController : MPViewController diff --git a/MacPass/MPKeyMapper.h b/MacPass/MPKeyMapper.h index 045a2298..8428c581 100644 --- a/MacPass/MPKeyMapper.h +++ b/MacPass/MPKeyMapper.h @@ -8,7 +8,7 @@ #import -extern uint16_t const kMPUnknownKeyCode; +FOUNDATION_EXTERN uint16_t const kMPUnknownKeyCode; @interface MPKeyMapper : NSObject diff --git a/MacPass/MPKeyMapper.m b/MacPass/MPKeyMapper.m index 7868ecb9..32ccc292 100644 --- a/MacPass/MPKeyMapper.m +++ b/MacPass/MPKeyMapper.m @@ -5,6 +5,19 @@ // Created by Michael Starke on 07.02.14. // Copyright (c) 2014 HicknHack Software GmbH. All rights reserved. // +// Uses Code from: +// SRKeyCodeTransformer.h +// ShortcutRecorder +// +// Copyright 2006-2007 Contributors. All rights reserved. +// +// License: BSD +// +// Contributors: +// David Dauer +// Jesper +// Jamie Kirkpatrick + #import "MPKeyMapper.h" @@ -17,20 +30,14 @@ uint16_t const kMPUnknownKeyCode = UINT16_MAX; + (NSString *)stringForKey:(CGKeyCode)keyCode { TISInputSourceRef currentKeyboard = TISCopyCurrentKeyboardInputSource(); CFDataRef layoutData = TISGetInputSourceProperty(currentKeyboard,kTISPropertyUnicodeKeyLayoutData); + + if(!layoutData) { + currentKeyboard = TISCopyCurrentASCIICapableKeyboardLayoutInputSource(); + layoutData = (CFDataRef)TISGetInputSourceProperty(currentKeyboard, kTISPropertyUnicodeKeyLayoutData); + } CFRelease(currentKeyboard); const UCKeyboardLayout *keyboardLayout = (const UCKeyboardLayout *)CFDataGetBytePtr(layoutData); - /* - Fallback for non-unicode Keyboards taken from to SRKeyCodeTransformer.m - Copyright 2006-2007 Contributors. All rights reserved. - License: BSD - Contributors: David Dauer, Jesper, Jamie Kirkpatrick - */ - if(!keyboardLayout) { - currentKeyboard = TISCopyCurrentASCIICapableKeyboardLayoutInputSource(); - layoutData = (CFDataRef)TISGetInputSourceProperty(currentKeyboard, kTISPropertyUnicodeKeyLayoutData); - CFRelease(currentKeyboard); - } UInt32 keysDown = 0; UniChar chars[4]; diff --git a/MacPassTests/KPKTestAutotypeNormalization.m b/MacPassTests/KPKTestAutotypeNormalization.m new file mode 100644 index 00000000..48d61f0e --- /dev/null +++ b/MacPassTests/KPKTestAutotypeNormalization.m @@ -0,0 +1,22 @@ +// +// KPKTestAutotypeNormalization.m +// MacPass +// +// Created by Michael Starke on 18.02.14. +// Copyright (c) 2014 HicknHack Software GmbH. All rights reserved. +// + +#import +#import "NSString+Commands.h" + +@interface KPKTestAutotypeNormalization : XCTestCase + +@end + +@implementation KPKTestAutotypeNormalization + +- (void)testNormalization { + @"Whoo {%}"; +} + +@end diff --git a/MacPassTests/KPKTestReference.m b/MacPassTests/KPKTestReference.m index dd463655..f2e3c529 100644 --- a/MacPassTests/KPKTestReference.m +++ b/MacPassTests/KPKTestReference.m @@ -25,8 +25,7 @@ KPKEntry *entry1 = [[KPKEntry alloc] init]; KPKEntry *entry2 = [[KPKEntry alloc] init]; entry1.title = @"-Entry1Title-"; - NSString *title2 = [[NSString alloc] initWithFormat:@"Nothing{REF:T@I:%@}Changed", entry1.uuid.UUIDString]; - entry2.title = title2; + entry2.title = [[NSString alloc] initWithFormat:@"Nothing{REF:T@I:%@}Changed", entry1.uuid.UUIDString];; entry2.url = @"-Entry2URL-"; [group addEntry:entry1]; @@ -42,10 +41,8 @@ KPKGroup *group = [[KPKGroup alloc] init]; KPKEntry *entry1 = [[KPKEntry alloc] init]; KPKEntry *entry2 = [[KPKEntry alloc] init]; - NSString *title1 = [[NSString alloc] initWithFormat:@"Title1{REF:A@I:%@}", entry2.uuid.UUIDString]; - entry1.title = title1; // References URL of entry 2 - NSString *title2 = [[NSString alloc] initWithFormat:@"Nothing{REF:T@I:%@}Changed", entry1.uuid.UUIDString]; - entry2.title = title2; // Refernces Title of entry 1 + entry1.title = [[NSString alloc] initWithFormat:@"Title1{REF:A@I:%@}", entry2.uuid.UUIDString]; + entry2.title = [[NSString alloc] initWithFormat:@"Nothing{REF:T@I:%@}Changed", entry1.uuid.UUIDString]; entry2.url = @"-Entry2URL-"; [group addEntry:entry1];