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

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