From 2df1a1f36a1c156a3fbbcfbf52e3304c1dc1bfd6 Mon Sep 17 00:00:00 2001 From: michael starke Date: Fri, 7 Feb 2014 19:08:56 +0100 Subject: [PATCH] Reverted to unsigned applications. Added public certificate for signed Sparkle updates Removed non-working AutoType code fragments for now --- KeePassKit | 2 +- MacPass.xcodeproj/project.pbxproj | 26 +++++---- MacPass/MPAutotypeCommand.h | 18 ------- MacPass/MPAutotypeCommand.m | 77 ++------------------------- MacPass/MPAutotypePaste.m | 6 +++ MacPass/MPKeyMapper.h | 31 +++++++++++ MacPass/MPKeyMapper.m | 87 +++++++++++++++++++++++++++++++ MacPass/MacPass-Info.plist | 2 + MacPass/dsa_sparkle_pub.pem | 12 +++++ 9 files changed, 157 insertions(+), 104 deletions(-) create mode 100644 MacPass/MPKeyMapper.h create mode 100644 MacPass/MPKeyMapper.m create mode 100644 MacPass/dsa_sparkle_pub.pem diff --git a/KeePassKit b/KeePassKit index 01c0baf9..e8edef9f 160000 --- a/KeePassKit +++ b/KeePassKit @@ -1 +1 @@ -Subproject commit 01c0baf945db2dfb169bc0d2d1df3f3c054073ff +Subproject commit e8edef9f2d3877e918ea010a5e0126287bd2cb84 diff --git a/MacPass.xcodeproj/project.pbxproj b/MacPass.xcodeproj/project.pbxproj index d96dbf50..ceb437fe 100644 --- a/MacPass.xcodeproj/project.pbxproj +++ b/MacPass.xcodeproj/project.pbxproj @@ -13,7 +13,6 @@ 4C0104BE17C37DA400173EF3 /* KPKXmlUtilities.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C0104BD17C37DA400173EF3 /* KPKXmlUtilities.m */; }; 4C01C2421764D8980016D5D0 /* MPContextMenuHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C01C2411764D8980016D5D0 /* MPContextMenuHelper.m */; }; 4C01C245176500C40016D5D0 /* HNHLevelIndicatorCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C01C244176500C40016D5D0 /* HNHLevelIndicatorCell.m */; }; - 4C055E74179620BF00BD2BAB /* NSString+Reference.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C055E73179620BF00BD2BAB /* NSString+Reference.m */; }; 4C0728BA17B5B7A4005A7DD9 /* PasswordEditWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4C0728B917B5B7A4005A7DD9 /* PasswordEditWindow.xib */; }; 4C0728BD17B5B7F7005A7DD9 /* MPPasswordEditWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C0728BC17B5B7F7005A7DD9 /* MPPasswordEditWindowController.m */; }; 4C0728BF17B68ED0005A7DD9 /* SavePanelAccessoryView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4C0728BE17B68ED0005A7DD9 /* SavePanelAccessoryView.xib */; }; @@ -205,6 +204,8 @@ 4CA0B2FC15BCAF8600654E32 /* MPSettingsWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CA0B2FB15BCAF8600654E32 /* MPSettingsWindowController.m */; }; 4CA0E3A7176FAF99004D18CB /* MPDocumentQueryService.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CA0E3A6176FAF99004D18CB /* MPDocumentQueryService.m */; }; 4CA2335A176DBFE100F0B6AC /* MPLockDaemon.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CA23359176DBFE100F0B6AC /* MPLockDaemon.m */; }; + 4CA3530B18A53CB800839B0F /* MPKeyMapper.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CA3530A18A53CB800839B0F /* MPKeyMapper.m */; }; + 4CA3531218A5577300839B0F /* dsa_sparkle_pub.pem in Resources */ = {isa = PBXBuildFile; fileRef = 4CA3531118A5577300839B0F /* dsa_sparkle_pub.pem */; }; 4CAC614317AD319200023F9E /* KPKTestXmlParsing.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CAC614217AD319200023F9E /* KPKTestXmlParsing.m */; }; 4CAD747B15B887FD00104512 /* DDXMLElementAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CAD745715B887FD00104512 /* DDXMLElementAdditions.m */; }; 4CAD747C15B887FD00104512 /* NSString+DDXML.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CAD745A15B887FD00104512 /* NSString+DDXML.m */; }; @@ -349,8 +350,6 @@ 4C01C2411764D8980016D5D0 /* MPContextMenuHelper.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPContextMenuHelper.m; sourceTree = ""; }; 4C01C243176500C40016D5D0 /* HNHLevelIndicatorCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HNHLevelIndicatorCell.h; sourceTree = ""; }; 4C01C244176500C40016D5D0 /* HNHLevelIndicatorCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HNHLevelIndicatorCell.m; sourceTree = ""; }; - 4C055E72179620BF00BD2BAB /* NSString+Reference.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSString+Reference.h"; sourceTree = ""; }; - 4C055E73179620BF00BD2BAB /* NSString+Reference.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSString+Reference.m"; sourceTree = ""; }; 4C0728B917B5B7A4005A7DD9 /* PasswordEditWindow.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = PasswordEditWindow.xib; sourceTree = ""; }; 4C0728BB17B5B7F7005A7DD9 /* MPPasswordEditWindowController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPPasswordEditWindowController.h; sourceTree = ""; }; 4C0728BC17B5B7F7005A7DD9 /* MPPasswordEditWindowController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPPasswordEditWindowController.m; sourceTree = ""; }; @@ -705,6 +704,9 @@ 4CA0E3A6176FAF99004D18CB /* MPDocumentQueryService.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPDocumentQueryService.m; sourceTree = ""; }; 4CA23358176DBFE100F0B6AC /* MPLockDaemon.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPLockDaemon.h; sourceTree = ""; }; 4CA23359176DBFE100F0B6AC /* MPLockDaemon.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPLockDaemon.m; sourceTree = ""; }; + 4CA3530918A53CB800839B0F /* MPKeyMapper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPKeyMapper.h; sourceTree = ""; }; + 4CA3530A18A53CB800839B0F /* MPKeyMapper.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPKeyMapper.m; sourceTree = ""; }; + 4CA3531118A5577300839B0F /* dsa_sparkle_pub.pem */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = dsa_sparkle_pub.pem; sourceTree = ""; }; 4CAAFDD51787AED60013FCF9 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/MainMenu.strings; sourceTree = ""; }; 4CAC614117AD319200023F9E /* KPKTestXmlParsing.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KPKTestXmlParsing.h; sourceTree = ""; }; 4CAC614217AD319200023F9E /* KPKTestXmlParsing.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KPKTestXmlParsing.m; sourceTree = ""; }; @@ -1399,6 +1401,7 @@ 4C77E36D15B84A240093A587 /* Supporting Files */ = { isa = PBXGroup; children = ( + 4CA3531118A5577300839B0F /* dsa_sparkle_pub.pem */, 4C6D1D2A17858A250014C5A5 /* MacPass.icns */, 4C888C8E16EB6C91003D34A1 /* Localizable.strings */, 4CB9339716D3A0DD00A13B5D /* Credits.rtf */, @@ -1421,6 +1424,8 @@ 4CC87EA21847FDDA005AA18D /* MPAutotypeParser.m */, 4CD2B9041849424B0051B395 /* MPAutotypeContext.h */, 4CD2B9051849424B0051B395 /* MPAutotypeContext.m */, + 4CA3530918A53CB800839B0F /* MPKeyMapper.h */, + 4CA3530A18A53CB800839B0F /* MPKeyMapper.m */, ); name = Autotype; sourceTree = ""; @@ -1621,8 +1626,6 @@ 4C2724D61778FF1A00FD8456 /* NSUUID+KeePassKit.m */, 4C8A173B1790AA41008B5C17 /* NSData+Keyfile.h */, 4C8A173C1790AA41008B5C17 /* NSData+Keyfile.m */, - 4C055E72179620BF00BD2BAB /* NSString+Reference.h */, - 4C055E73179620BF00BD2BAB /* NSString+Reference.m */, 4C1842C1179B69E600E2F5BC /* NSData+HashedData.h */, 4C1842C2179B69E700E2F5BC /* NSData+HashedData.m */, 4C6366AA17AF1E0100AAF17D /* NSColor+KeePassKit.h */, @@ -1990,6 +1993,7 @@ 4C7714AA176C998F00549F2A /* 43_TrashTemplate.pdf in Resources */, 4C7714AC176C9D4600549F2A /* 99_InfoTemplate.pdf in Resources */, 4CF7805F176E75110032EE71 /* ServerSettings.xib in Resources */, + 4CA3531218A5577300839B0F /* dsa_sparkle_pub.pem in Resources */, 4CD5D702177A5EE400100649 /* DatabaseSettingsWindow.xib in Resources */, 4C6D1D25178579570014C5A5 /* 48_FolderTemplate.pdf in Resources */, 4C6D1D27178586CA0014C5A5 /* 99_AddFolderTemplate.pdf in Resources */, @@ -2048,7 +2052,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "LOCATION=\"${BUILT_PRODUCTS_DIR}\"/\"${FRAMEWORKS_FOLDER_PATH}\"\nIDENTITY=\"Mac Developer: Michael Starke\"\n#IDENTITY=\"Developer ID Application: The Iconfactory\"\ncodesign --verbose --force --sign \"$IDENTITY\" \"$LOCATION/Sparkle.framework/Versions/A\""; + shellScript = "LOCATION=\"${BUILT_PRODUCTS_DIR}\"/\"${FRAMEWORKS_FOLDER_PATH}\"\nIDENTITY=\"Mac Developer: Michael Starke\"\n#IDENTITY=\"Developer ID Application: The Iconfactory\"\n#codesign --verbose --force --sign \"$IDENTITY\" \"$LOCATION/Sparkle.framework/Versions/A\""; }; /* End PBXShellScriptBuildPhase section */ @@ -2183,6 +2187,7 @@ 4CD3ABC2178F72720073F5C5 /* KPKGroup.m in Sources */, 4C591B57178F897A0080B16B /* KPKBinary.m in Sources */, 4CEE46DD181C301D006BF1E5 /* MPAutotypeDaemon.m in Sources */, + 4CA3530B18A53CB800839B0F /* MPKeyMapper.m in Sources */, 4C39B3F5178FEFAE0027DC7C /* KPKNode.m in Sources */, 4C70D100179092F200652EE9 /* KPKCompositeKey.m in Sources */, 4C8A173D1790AA41008B5C17 /* NSData+Keyfile.m in Sources */, @@ -2193,7 +2198,6 @@ 4CDB5C421794AA4F0017667E /* KPKTree+Serializing.m in Sources */, 4C5AA591179549A1008ECAD7 /* KPKXmlTreeWriter.m in Sources */, 4CE298EB1795FC2A00DF7BDB /* MPEntryContextMenuDelegate.m in Sources */, - 4C055E74179620BF00BD2BAB /* NSString+Reference.m in Sources */, 4CC0D2CE17974A47000B4BDA /* MPCustomFieldTableViewDelegate.m in Sources */, 4CC0D2D117974A5A000B4BDA /* MPAttachmentTableViewDelegate.m in Sources */, 4C67D33017981A2B00A7BDFC /* HNHTokenField.m in Sources */, @@ -2469,8 +2473,8 @@ isa = XCBuildConfiguration; buildSettings = { CLANG_ENABLE_OBJC_ARC = YES; - CODE_SIGN_IDENTITY = "Developer ID Application"; - "CODE_SIGN_IDENTITY[sdk=macosx*]" = "Developer ID Application"; + CODE_SIGN_IDENTITY = ""; + "CODE_SIGN_IDENTITY[sdk=macosx*]" = ""; COMBINE_HIDPI_IMAGES = YES; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "MacPass/MacPass-Prefix.pch"; @@ -2486,8 +2490,8 @@ isa = XCBuildConfiguration; buildSettings = { CLANG_ENABLE_OBJC_ARC = YES; - CODE_SIGN_IDENTITY = "Developer ID Application"; - "CODE_SIGN_IDENTITY[sdk=macosx*]" = "Developer ID Application"; + CODE_SIGN_IDENTITY = ""; + "CODE_SIGN_IDENTITY[sdk=macosx*]" = ""; COMBINE_HIDPI_IMAGES = YES; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "MacPass/MacPass-Prefix.pch"; diff --git a/MacPass/MPAutotypeCommand.h b/MacPass/MPAutotypeCommand.h index 364ec28a..db5fc5ca 100644 --- a/MacPass/MPAutotypeCommand.h +++ b/MacPass/MPAutotypeCommand.h @@ -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 diff --git a/MacPass/MPAutotypeCommand.m b/MacPass/MPAutotypeCommand.m index 26656fbb..04c9e11a 100644 --- a/MacPass/MPAutotypeCommand.m +++ b/MacPass/MPAutotypeCommand.m @@ -9,6 +9,8 @@ #import "MPAutotypeCommand.h" #import "NSString+Commands.h" +#import "MPKeyMapper.h" + #import 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" } diff --git a/MacPass/MPAutotypePaste.m b/MacPass/MPAutotypePaste.m index 4ecdd694..1b217336 100644 --- a/MacPass/MPAutotypePaste.m +++ b/MacPass/MPAutotypePaste.m @@ -11,6 +11,12 @@ #import "NSString+Commands.h" +@interface MPAutotypePaste () + +@property (retain) NSString *commandString; + +@end + @implementation MPAutotypePaste /** diff --git a/MacPass/MPKeyMapper.h b/MacPass/MPKeyMapper.h new file mode 100644 index 00000000..b7b825cc --- /dev/null +++ b/MacPass/MPKeyMapper.h @@ -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 + +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 diff --git a/MacPass/MPKeyMapper.m b/MacPass/MPKeyMapper.m new file mode 100644 index 00000000..7868ecb9 --- /dev/null +++ b/MacPass/MPKeyMapper.m @@ -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 + +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 diff --git a/MacPass/MacPass-Info.plist b/MacPass/MacPass-Info.plist index a03f4fc8..ab7f9f4d 100644 --- a/MacPass/MacPass-Info.plist +++ b/MacPass/MacPass-Info.plist @@ -2,6 +2,8 @@ + SUPublicDSAKeyFile + dsa_sparkle_pub.pem CFBundleDevelopmentRegion en CFBundleDocumentTypes diff --git a/MacPass/dsa_sparkle_pub.pem b/MacPass/dsa_sparkle_pub.pem new file mode 100644 index 00000000..bc0e9218 --- /dev/null +++ b/MacPass/dsa_sparkle_pub.pem @@ -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-----