Reverted to unsigned applications.

Added public certificate for signed Sparkle updates
Removed non-working AutoType code fragments for now
This commit is contained in:
michael starke
2014-02-07 19:08:56 +01:00
parent d6dcb96ba5
commit 2df1a1f36a
9 changed files with 157 additions and 104 deletions

View File

@@ -14,8 +14,6 @@ extern NSString *const kMPAutotypeSymbolAlt;
extern NSString *const kMPAutotypeSymbolEnter;
extern NSString *const kMPAutptypeCommandEnter;
extern uint16_t const kMPUnknownKeyCode;
@class MPAutotypeContext;
/**
@@ -26,23 +24,7 @@ extern uint16_t const kMPUnknownKeyCode;
@interface MPAutotypeCommand : NSObject
@property (readonly, strong) MPAutotypeContext *context;
/**
* Retrieves the string representation with the current keyboard mapping for the keycode
*
* @param keyCode The virutal keycode to be pressed
* @return NSString containing the current mapping for the keyCode
*/
+ (NSString *)stringForKey:(CGKeyCode)keyCode;
/**
* Determines the keyCode (if possible) for the charater
*
* @param character NSString with a single character to be transformed
* @return virtual Keycode for the supplied string. If none is found, kMPUnkonwKeyCode is returned
*/
+ (CGKeyCode)keyCodeForCharacter:(NSString *)character;
- (id)initWithContext:(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

@@ -9,6 +9,8 @@
#import "MPAutotypeCommand.h"
#import "NSString+Commands.h"
#import "MPKeyMapper.h"
#import <Carbon/Carbon.h>
NSString *const kMPAutotypeSymbolShift = @"+";
@@ -41,9 +43,6 @@ NSString *const kMPAutotypeCommandNumlock = @"{NUMLOCK}";
NSString *const kMPAutotypeCommandPrintScreen = @"{PRTSC}";
NSString *const kMPAutotypeCommandScrollLock = @"{SCROLLLOCK}";
NSString *const kMPAutotypeCommandF1 = @"{F1}";
uint16_t const kMPUnknownKeyCode = UINT16_MAX;
/*
Tab {TAB}
Enter {ENTER} or ~
@@ -89,76 +88,6 @@ uint16_t const kMPUnknownKeyCode = UINT16_MAX;
@implementation MPAutotypeCommand
+ (NSString *)stringForKey:(CGKeyCode)keyCode {
TISInputSourceRef currentKeyboard = TISCopyCurrentKeyboardInputSource();
CFDataRef layoutData = 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];
UniCharCount realLength;
UCKeyTranslate(keyboardLayout,
keyCode,
kUCKeyActionDisplay,
0,
LMGetKbdType(),
kUCKeyTranslateNoDeadKeysBit,
&keysDown,
sizeof(chars) / sizeof(chars[0]),
&realLength,
chars);
return CFBridgingRelease(CFStringCreateWithCharacters(kCFAllocatorDefault, chars, 1));
}
+ (CGKeyCode)keyCodeForCharacter:(NSString *)character {
static NSMutableDictionary *keyboardCodeDictionary;
TISInputSourceRef currentKeyboard = TISCopyCurrentKeyboardInputSource();
NSString *localizedName = CFBridgingRelease(TISGetInputSourceProperty(currentKeyboard, kTISPropertyLocalizedName));
if(keyboardCodeDictionary == nil) {
/* Input source should not change that much while we are running */
keyboardCodeDictionary = [[NSMutableDictionary alloc] initWithCapacity:2];
}
NSDictionary *charToCodeDict = keyboardCodeDictionary[localizedName];
if(nil == keyboardCodeDictionary[localizedName]) {
/* We need 128 places for this dict */
charToCodeDict = [[NSMutableDictionary alloc] initWithCapacity:128];
/* Loop through every keycode (0 - 127) to find its current mapping. */
for(CGKeyCode keyCode = 0; keyCode < 128; ++keyCode) {
NSString *string = [self stringForKey:keyCode];
if(string != nil) {
((NSMutableDictionary *)charToCodeDict)[string] = @(keyCode);
}
}
keyboardCodeDictionary[localizedName] = [[NSDictionary alloc] initWithDictionary:charToCodeDict];
}
/* Add mapping */
/* Generate table of keycodes and characters. */
NSString *singleCharacter = [[character substringToIndex:1] lowercaseString];
if(charToCodeDict[singleCharacter]) {
return [charToCodeDict[singleCharacter] integerValue];
}
return kMPUnknownKeyCode;
}
- (void)sendPressKey:(CGKeyCode)keyCode modifierFlags:(CGEventFlags)flags {
CGEventRef pressKey = CGEventCreateKeyboardEvent (NULL, keyCode, YES);
CGEventRef releaseKey = CGEventCreateKeyboardEvent (NULL, keyCode, NO);
@@ -179,7 +108,7 @@ uint16_t const kMPUnknownKeyCode = UINT16_MAX;
}
- (void)sendPasteKeyCode {
CGKeyCode keyCode = [MPAutotypeCommand keyCodeForCharacter:@"V"];
CGKeyCode keyCode = [MPKeyMapper keyCodeForCharacter:@"V"];
if(keyCode == kMPUnknownKeyCode) {
return; // We did not find a mapping for "V"
}

View File

@@ -11,6 +11,12 @@
#import "NSString+Commands.h"
@interface MPAutotypePaste ()
@property (retain) NSString *commandString;
@end
@implementation MPAutotypePaste
/**

31
MacPass/MPKeyMapper.h Normal file
View File

@@ -0,0 +1,31 @@
//
// MPKeyMapper.h
// MacPass
//
// Created by Michael Starke on 07.02.14.
// Copyright (c) 2014 HicknHack Software GmbH. All rights reserved.
//
#import <Foundation/Foundation.h>
extern uint16_t const kMPUnknownKeyCode;
@interface MPKeyMapper : NSObject
/**
* Retrieves the string representation with the current keyboard mapping for the keycode
*
* @param keyCode The virutal keycode to be pressed
* @return NSString containing the current mapping for the keyCode
*/
+ (NSString *)stringForKey:(CGKeyCode)keyCode;
/**
* Determines the keyCode (if possible) for the charater
*
* @param character NSString with a single character to be transformed
* @return virtual Keycode for the supplied string. If none is found, kMPUnkonwKeyCode is returned
*/
+ (CGKeyCode)keyCodeForCharacter:(NSString *)character;
@end

87
MacPass/MPKeyMapper.m Normal file
View File

@@ -0,0 +1,87 @@
//
// MPKeyMapper.m
// MacPass
//
// Created by Michael Starke on 07.02.14.
// Copyright (c) 2014 HicknHack Software GmbH. All rights reserved.
//
#import "MPKeyMapper.h"
#import <Carbon/Carbon.h>
uint16_t const kMPUnknownKeyCode = UINT16_MAX;
@implementation MPKeyMapper
+ (NSString *)stringForKey:(CGKeyCode)keyCode {
TISInputSourceRef currentKeyboard = TISCopyCurrentKeyboardInputSource();
CFDataRef layoutData = 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];
UniCharCount realLength;
UCKeyTranslate(keyboardLayout,
keyCode,
kUCKeyActionDisplay,
0,
LMGetKbdType(),
kUCKeyTranslateNoDeadKeysBit,
&keysDown,
sizeof(chars) / sizeof(chars[0]),
&realLength,
chars);
return CFBridgingRelease(CFStringCreateWithCharacters(kCFAllocatorDefault, chars, 1));
}
+ (CGKeyCode)keyCodeForCharacter:(NSString *)character {
static NSMutableDictionary *keyboardCodeDictionary;
TISInputSourceRef currentKeyboard = TISCopyCurrentKeyboardInputSource();
NSString *localizedName = CFBridgingRelease(TISGetInputSourceProperty(currentKeyboard, kTISPropertyLocalizedName));
if(keyboardCodeDictionary == nil) {
/* Input source should not change that much while we are running */
keyboardCodeDictionary = [[NSMutableDictionary alloc] initWithCapacity:2];
}
NSDictionary *charToCodeDict = keyboardCodeDictionary[localizedName];
if(nil == keyboardCodeDictionary[localizedName]) {
/* We need 128 places for this dict */
charToCodeDict = [[NSMutableDictionary alloc] initWithCapacity:128];
/* Loop through every keycode (0 - 127) to find its current mapping. */
for(CGKeyCode keyCode = 0; keyCode < 128; ++keyCode) {
NSString *string = [self stringForKey:keyCode];
if(string != nil) {
((NSMutableDictionary *)charToCodeDict)[string] = @(keyCode);
}
}
keyboardCodeDictionary[localizedName] = [[NSDictionary alloc] initWithDictionary:charToCodeDict];
}
/* Add mapping */
/* Generate table of keycodes and characters. */
NSString *singleCharacter = [[character substringToIndex:1] lowercaseString];
if(charToCodeDict[singleCharacter]) {
return [charToCodeDict[singleCharacter] integerValue];
}
return kMPUnknownKeyCode;
}
@end

View File

@@ -2,6 +2,8 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>SUPublicDSAKeyFile</key>
<string>dsa_sparkle_pub.pem</string>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleDocumentTypes</key>

View File

@@ -0,0 +1,12 @@
-----BEGIN PUBLIC KEY-----
MIIBuDCCASwGByqGSM44BAEwggEfAoGBAM9fddIHTDtY5tw1Ew78fRI0fBMkpHN8
d4h++WynbyS59tUQ7uJLkGQAtnLhA3orU1ycghvNuFnNe6sANuzPCOjvay0oSZP0
MeGj3cn1vzN61WbZL6wjBmJVkiptLuviTT7tMZOuJM6I1NQZb8AiUXt6E9F0BtT5
FUsLI3vK3w4ZAhUA08MnyUlVf8teUxZ+SJKstKNc28kCgYEAxaKVkiKzWhF81QdB
ugIc1ccx4lgWR/8xFtY/svlN4UjWBj+KyZ6AWfMBXeTJxYWYiTvwyx3NxxdI7mus
ACtL60EFVNACDo8WhFuYQ0X47dQqfcemDd8NylnXuOgwS+/whgtONgC8INswCnt7
N+eFEcbPb1e8KwOjEsxguHycKD4DgYUAAoGBAKBgyULSfUTZeigrw4g8/YtjsHiH
nbqBgYTetL/JcZosx3F/kccdJ18u5y1Xd2ec7WopJpl5Ywc0CvEzGkuHznVlKoyV
wi1MdfqHJEAW1tA442knwO7ydO+9S2d7twfZyN53ncSksZskJGeev1fALgCz1VrF
j6hC6zq/VyhMwybK
-----END PUBLIC KEY-----