Removed AutotypeParser as this is now handled by an NSString Cateogriy in KeePassKit

This commit is contained in:
michael starke
2014-02-19 01:53:14 +01:00
parent 81bcd15d80
commit 9575777cc7
14 changed files with 77 additions and 199 deletions

View File

@@ -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 = "<group>"; };
4C08C3AF17B3036500BBBC95 /* KPKLegacyFormat.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = KPKLegacyFormat.h; path = Format/KPKLegacyFormat.h; sourceTree = "<group>"; };
4C0C59EF18B17F10009C7B76 /* DDHotKeyUtilities.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = DDHotKeyUtilities.m; path = DDHotKey/DDHotKeyUtilities.m; sourceTree = "<group>"; };
4C0C59F018B17F10009C7B76 /* DDHotKeyUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DDHotKeyUtilities.h; path = DDHotKey/DDHotKeyUtilities.h; sourceTree = "<group>"; };
4C0C59F018B17F10009C7B76 /* DDHotKeyUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; name = DDHotKeyUtilities.h; path = DDHotKey/DDHotKeyUtilities.h; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
4C0DD6C518B2A44700FCB193 /* AutotypeCandidateSelectionWindow.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = AutotypeCandidateSelectionWindow.xib; sourceTree = "<group>"; };
4C0F647617B6B65E00D9522A /* MPSheetWindowController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPSheetWindowController.h; sourceTree = "<group>"; };
4C0F647717B6B65E00D9522A /* MPSheetWindowController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPSheetWindowController.m; sourceTree = "<group>"; };
@@ -452,15 +452,15 @@
4C245B60176E1E3D0086100E /* GCDAsyncSocket.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GCDAsyncSocket.h; sourceTree = "<group>"; };
4C245B61176E1E3D0086100E /* GCDAsyncSocket.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GCDAsyncSocket.m; sourceTree = "<group>"; };
4C245B64176E1E3D0086100E /* DDAbstractDatabaseLogger.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DDAbstractDatabaseLogger.h; sourceTree = "<group>"; };
4C245B65176E1E3D0086100E /* DDAbstractDatabaseLogger.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DDAbstractDatabaseLogger.m; sourceTree = "<group>"; };
4C245B65176E1E3D0086100E /* DDAbstractDatabaseLogger.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = DDAbstractDatabaseLogger.m; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objc; };
4C245B66176E1E3D0086100E /* DDASLLogger.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DDASLLogger.h; sourceTree = "<group>"; };
4C245B67176E1E3D0086100E /* DDASLLogger.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DDASLLogger.m; sourceTree = "<group>"; };
4C245B68176E1E3D0086100E /* DDFileLogger.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DDFileLogger.h; sourceTree = "<group>"; };
4C245B69176E1E3D0086100E /* DDFileLogger.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DDFileLogger.m; sourceTree = "<group>"; };
4C245B69176E1E3D0086100E /* DDFileLogger.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = DDFileLogger.m; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objc; };
4C245B6A176E1E3D0086100E /* DDLog.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DDLog.h; sourceTree = "<group>"; };
4C245B6B176E1E3D0086100E /* DDLog.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DDLog.m; sourceTree = "<group>"; };
4C245B6B176E1E3D0086100E /* DDLog.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = DDLog.m; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objc; };
4C245B6C176E1E3D0086100E /* DDTTYLogger.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DDTTYLogger.h; sourceTree = "<group>"; };
4C245B6D176E1E3D0086100E /* DDTTYLogger.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DDTTYLogger.m; sourceTree = "<group>"; };
4C245B6D176E1E3D0086100E /* DDTTYLogger.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = DDTTYLogger.m; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objc; };
4C245B6F176E1E3D0086100E /* ContextFilterLogFormatter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ContextFilterLogFormatter.h; sourceTree = "<group>"; };
4C245B70176E1E3D0086100E /* ContextFilterLogFormatter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ContextFilterLogFormatter.m; sourceTree = "<group>"; };
4C245B71176E1E3D0086100E /* DispatchQueueLogFormatter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DispatchQueueLogFormatter.h; sourceTree = "<group>"; };
@@ -552,6 +552,7 @@
4C58BD4E176370B100B8178C /* HNHBadgedTextField.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HNHBadgedTextField.m; sourceTree = "<group>"; };
4C591B55178F897A0080B16B /* KPKBinary.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KPKBinary.h; sourceTree = "<group>"; };
4C591B56178F897A0080B16B /* KPKBinary.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KPKBinary.m; sourceTree = "<group>"; };
4C59745018B3CE7200C8EBD1 /* KPKTestAutotypeNormalization.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KPKTestAutotypeNormalization.m; sourceTree = "<group>"; };
4C5A11FB1708DE8700223D8A /* MPPasswordCreatorViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPPasswordCreatorViewController.h; sourceTree = "<group>"; };
4C5A11FC1708DE8700223D8A /* MPPasswordCreatorViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPPasswordCreatorViewController.m; sourceTree = "<group>"; };
4C5A11FD1708DE8700223D8A /* PasswordCreatorView.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = PasswordCreatorView.xib; sourceTree = "<group>"; };
@@ -751,8 +752,6 @@
4CC6DB7C17D23DCE002C6091 /* KPKUTIs.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KPKUTIs.m; sourceTree = "<group>"; };
4CC7EA1917807E7E0089D4F3 /* HNHRoundedTextFieldCellHelper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HNHRoundedTextFieldCellHelper.h; sourceTree = "<group>"; };
4CC7EA1A17807E7E0089D4F3 /* HNHRoundedTextFieldCellHelper.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HNHRoundedTextFieldCellHelper.m; sourceTree = "<group>"; };
4CC87EA11847FDDA005AA18D /* MPAutotypeParser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPAutotypeParser.h; sourceTree = "<group>"; };
4CC87EA21847FDDA005AA18D /* MPAutotypeParser.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPAutotypeParser.m; sourceTree = "<group>"; };
4CCA7EEC1797866F00B0B55E /* de */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = de; path = de.lproj/GeneralSettings.strings; sourceTree = "<group>"; };
4CCA7EEE1797867200B0B55E /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/GeneralSettings.strings; sourceTree = "<group>"; };
4CCEDE28179F203B008402BE /* MPOutlineView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPOutlineView.h; sourceTree = "<group>"; };
@@ -1248,6 +1247,7 @@
4CBA561517C2EA4900CE13D3 /* KPKTestXmlWriting.m */,
4C473A7E18AFD6340073FD2E /* KPKTestReference.m */,
4CD25F9218B17A17006098E9 /* KPKTestUUIDAdditions.m */,
4C59745018B3CE7200C8EBD1 /* KPKTestAutotypeNormalization.m */,
);
path = MacPassTests;
sourceTree = "<group>";
@@ -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 */,

View File

@@ -22,7 +22,7 @@
#import <Cocoa/Cocoa.h>
extern NSString *const MPDidChangeStoredKeyFilesSettings;
FOUNDATION_EXTERN NSString *const MPDidChangeStoredKeyFilesSettings;
@interface MPAppDelegate : NSObject <NSApplicationDelegate, NSMenuDelegate>

View File

@@ -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

View File

@@ -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);

View File

@@ -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 <NSCopying>
/**
* 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

View File

@@ -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 <seconds>
TAB <repeat>
VKEY <code>
*/
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;
}

View File

@@ -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 <Foundation/Foundation.h>
@interface MPAutotypeParser : NSObject
+ (NSArray *)commandsForCommandString:(NSString *)commands;
@end

View File

@@ -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

View File

@@ -8,7 +8,7 @@
#import "MPViewController.h"
extern NSInteger const kMPDefaultIcon;
FOUNDATION_EXTERN NSInteger const kMPDefaultIcon;
@interface MPIconSelectViewController : MPViewController <NSCollectionViewDelegate>

View File

@@ -8,7 +8,7 @@
#import <Foundation/Foundation.h>
extern uint16_t const kMPUnknownKeyCode;
FOUNDATION_EXTERN uint16_t const kMPUnknownKeyCode;
@interface MPKeyMapper : NSObject

View File

@@ -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];

View File

@@ -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 <XCTest/XCTest.h>
#import "NSString+Commands.h"
@interface KPKTestAutotypeNormalization : XCTestCase
@end
@implementation KPKTestAutotypeNormalization
- (void)testNormalization {
@"Whoo {%}";
}
@end

View File

@@ -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];