From 30adeb61bdb1918bc712beb275bdecaf5fe15caa Mon Sep 17 00:00:00 2001 From: Tom Bogle Date: Mon, 12 Feb 2018 11:22:57 -0500 Subject: [PATCH] WIP: Non-working explaratory code for associating KMP with Keyman IM --- .../Keyman4MacIM.xcodeproj/project.pbxproj | 6 +++ .../Keyman4MacIM/KMInputController.m | 14 ++++- mac/Keyman4MacIM/Keyman4MacIM/KMPackage.h | 19 +++++++ mac/Keyman4MacIM/Keyman4MacIM/KMPackage.m | 52 +++++++++++++++++++ 4 files changed, 90 insertions(+), 1 deletion(-) create mode 100644 mac/Keyman4MacIM/Keyman4MacIM/KMPackage.h create mode 100644 mac/Keyman4MacIM/Keyman4MacIM/KMPackage.m diff --git a/mac/Keyman4MacIM/Keyman4MacIM.xcodeproj/project.pbxproj b/mac/Keyman4MacIM/Keyman4MacIM.xcodeproj/project.pbxproj index 7c8e7dcc55..129be2825e 100644 --- a/mac/Keyman4MacIM/Keyman4MacIM.xcodeproj/project.pbxproj +++ b/mac/Keyman4MacIM/Keyman4MacIM.xcodeproj/project.pbxproj @@ -50,6 +50,7 @@ 98FE10641B4DEE5600525F54 /* KMInfoWindowController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 98FE10621B4DEE5600525F54 /* KMInfoWindowController.xib */; }; E21799051FC5B7BC00F2D66A /* KMInputMethodEventHandler.m in Sources */ = {isa = PBXBuildFile; fileRef = E21799041FC5B7BC00F2D66A /* KMInputMethodEventHandler.m */; }; E22020F6200506F300B74FAC /* KMInputMethodSafariClientEventHandler.m in Sources */ = {isa = PBXBuildFile; fileRef = E22020F5200506F300B74FAC /* KMInputMethodSafariClientEventHandler.m */; }; + E240F599202DED740000067D /* KMPackage.m in Sources */ = {isa = PBXBuildFile; fileRef = E240F598202DED740000067D /* KMPackage.m */; }; E24C79EA1FFFCC7500D8E46F /* KMInputMethodBrowserClientEventHandler.m in Sources */ = {isa = PBXBuildFile; fileRef = E24C79E91FFFCC7500D8E46F /* KMInputMethodBrowserClientEventHandler.m */; }; E27BA9CE2020322000D273E7 /* OCMock.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E27BA9CD2020322000D273E7 /* OCMock.framework */; }; E27BA9D1202036E200D273E7 /* OCMock.framework.dSYM in CopyFiles */ = {isa = PBXBuildFile; fileRef = E27BA9D0202036E200D273E7 /* OCMock.framework.dSYM */; }; @@ -168,6 +169,8 @@ E22020F3200505EF00B74FAC /* KMInputMethodSafariClientEventHandler.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = KMInputMethodSafariClientEventHandler.h; sourceTree = ""; }; E22020F5200506F300B74FAC /* KMInputMethodSafariClientEventHandler.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KMInputMethodSafariClientEventHandler.m; sourceTree = ""; }; E22020F920050D6300B74FAC /* KMInputMethodBrowserClientEventHandlerProtected.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KMInputMethodBrowserClientEventHandlerProtected.h; sourceTree = ""; }; + E240F597202DED300000067D /* KMPackage.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = KMPackage.h; sourceTree = ""; }; + E240F598202DED740000067D /* KMPackage.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = KMPackage.m; sourceTree = ""; }; E24C79E91FFFCC7500D8E46F /* KMInputMethodBrowserClientEventHandler.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = KMInputMethodBrowserClientEventHandler.m; sourceTree = ""; }; E24C79EB1FFFCE3000D8E46F /* KMInputMethodBrowserClientEventHandler.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = KMInputMethodBrowserClientEventHandler.h; sourceTree = ""; }; E24C79EC1FFFEA6B00D8E46F /* KMInputMethodEventHandlerProtected.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = KMInputMethodEventHandlerProtected.h; sourceTree = ""; }; @@ -324,6 +327,8 @@ 984B8F3E1AF1C2F400E096A8 /* OnScreenKeyboard */, 989C9C0B1A7876DE00A20425 /* Supporting Files */, 9836B3631AE5F11D00780482 /* ZipArchive */, + E240F597202DED300000067D /* KMPackage.h */, + E240F598202DED740000067D /* KMPackage.m */, ); path = Keyman4MacIM; sourceTree = ""; @@ -566,6 +571,7 @@ 98F3C8931A8D739500F675E3 /* KMConfigurationWindowController.m in Sources */, 989C9C111A7876DE00A20425 /* main.m in Sources */, 98BF924F1BF02DC20002126A /* KMBarView.m in Sources */, + E240F599202DED740000067D /* KMPackage.m in Sources */, 984B8F441AF1C3D900E096A8 /* OSKWindowController.m in Sources */, 9836B3711AE5F11D00780482 /* mztools.c in Sources */, 9836B3701AE5F11D00780482 /* ioapi.c in Sources */, diff --git a/mac/Keyman4MacIM/Keyman4MacIM/KMInputController.m b/mac/Keyman4MacIM/Keyman4MacIM/KMInputController.m index 671005a3a2..0e22487647 100644 --- a/mac/Keyman4MacIM/Keyman4MacIM/KMInputController.m +++ b/mac/Keyman4MacIM/Keyman4MacIM/KMInputController.m @@ -56,7 +56,19 @@ KMInputMethodEventHandler* _eventHandler; NSRunningApplication *currApp = [[NSWorkspace sharedWorkspace] frontmostApplication]; NSString *clientAppId = [currApp bundleIdentifier]; if ([self.AppDelegate debugMode]) - NSLog(@"New active app %@", clientAppId); + NSLog(@"New active BLAHHHH app %@", clientAppId); + + NSLog(@"About to try to deal with kmp files."); +// LSRegisterURL((__bridge CFURLRef)[[NSBundle mainBundle] bundleURL], NO); +// FSRef outAppRef; +// if (LSGetApplicationForInfo(kLSUnknownType, kLSUnknownCreator, CFStringCreateWithCString(NULL, "kmp", kCFStringEncodingMacRoman), kLSRolesEditor, &outAppRef, NULL) == kLSApplicationNotFoundErr) +// { +// NSLog(@"Couldn't find an app to open kmp files."); +// } +// else +// { +// NSLog(@"Let's see what app is set to open kmp files..."); +// } // Most things in Safari work well using the normal way, but Google Docs doesn't. if ([clientAppId isEqual: @"com.apple.Safari"]) { diff --git a/mac/Keyman4MacIM/Keyman4MacIM/KMPackage.h b/mac/Keyman4MacIM/Keyman4MacIM/KMPackage.h new file mode 100644 index 0000000000..07f4245b02 --- /dev/null +++ b/mac/Keyman4MacIM/Keyman4MacIM/KMPackage.h @@ -0,0 +1,19 @@ +// +// KMPackage.h +// Keyman +// +// Created by tom on 2/9/18. +// Copyright © 2018 SIL International. All rights reserved. +// + +#ifndef KMPackage_h +#define KMPackage_h + +#import + +@interface KMPackage : NSDocument + + +@end + +#endif /* KMPackage_h */ diff --git a/mac/Keyman4MacIM/Keyman4MacIM/KMPackage.m b/mac/Keyman4MacIM/Keyman4MacIM/KMPackage.m new file mode 100644 index 0000000000..96378dc152 --- /dev/null +++ b/mac/Keyman4MacIM/Keyman4MacIM/KMPackage.m @@ -0,0 +1,52 @@ +// +// KMPackage.m +// Keyman +// +// Created by tom on 2/9/18. +// Copyright © 2018 SIL International. All rights reserved. +// + +#import +#import "KMPackage.h" + + +@implementation KMPackage + +//- (instancetype)init { +// self = [super init]; +// if (self) { +// // Add your subclass-specific initialization here. +// } +// return self; +//} + ++ (BOOL)autosavesInPlace { + return NO; +} + + +- (NSString *)windowNibName { + // Override returning the nib file name of the document + // If you need to use a subclass of NSWindowController or if your document supports multiple NSWindowControllers, you should remove this method and override -makeWindowControllers instead. + + NSLog(@"Stink! We got here!"); + return @"ShouldNotGetHere"; +} + + +- (NSData *)dataOfType:(NSString *)typeName error:(NSError **)outError { + // Insert code here to write your document to data of the specified type. If outError != NULL, ensure that you create and set an appropriate error when returning nil. + // You can also choose to override -fileWrapperOfType:error:, -writeToURL:ofType:error:, or -writeToURL:ofType:forSaveOperation:originalContentsURL:error: instead. + [NSException raise:@"UnimplementedMethod" format:@"%@ is unimplemented", NSStringFromSelector(_cmd)]; + return nil; +} + + +- (BOOL)readFromData:(NSData *)data ofType:(NSString *)typeName error:(NSError **)outError { + // Insert code here to read your document from the given data of the specified type. If outError != NULL, ensure that you create and set an appropriate error when returning NO. + // You can also choose to override -readFromFileWrapper:ofType:error: or -readFromURL:ofType:error: instead. + // If you override either of these, you should also override -isEntireFileLoaded to return NO if the contents are lazily loaded. + NSLog(@"typeName = %@", typeName); + return YES; +} +@end