From 307d540ad653e25c623e23fc4f6e1ee549f777db Mon Sep 17 00:00:00 2001 From: lotem Date: Tue, 23 Dec 2014 04:03:48 +0800 Subject: [PATCH 1/2] fix install issue with activating input mode; remove previous install. --- Info.plist | 9 ++-- Makefile | 13 +++-- Squirrel.xcodeproj/project.pbxproj | 4 ++ input_source.m | 52 ++++++++++++++----- main.m | 10 ++-- package/Package.pmdoc/01squirrel-contents.xml | 3 +- package/Package.pmdoc/01squirrel.xml | 21 +++++--- package/Package.pmdoc/index.xml | 8 +-- preflight | 6 +++ 9 files changed, 87 insertions(+), 39 deletions(-) create mode 100755 preflight diff --git a/Info.plist b/Info.plist index 86fc246f9..8e229ae9d 100644 --- a/Info.plist +++ b/Info.plist @@ -44,10 +44,9 @@ SUPublicDSAKeyFile dsa_pub.pem SUFeedURL - http://rimeime.github.io/release/squirrel/appcast.xml + http://rimeime.github.io/release/squirrel/appcast.xml SUEnableAutomaticChecks - ComponentInputModeDict tsInputModeListKey @@ -55,9 +54,9 @@ com.googlecode.rimeime.inputmethod.Squirrel TISInputSourceID - com.googlecode.rimeime.inputmethod.Squirrel + com.googlecode.rimeime.inputmethod.Squirrel.Rime TISIntendedLanguage - zh-Hans + zh tsInputModeAlternateMenuIconFileKey rime.pdf tsInputModeCharacterRepertoireKey @@ -83,7 +82,7 @@ tsVisibleInputModeOrderedArrayKey - com.googlecode.rimeime.inputmethod.Squirrel + com.googlecode.rimeime.inputmethod.Squirrel.Rime diff --git a/Makefile b/Makefile index e84740c13..c0f1258c5 100644 --- a/Makefile +++ b/Makefile @@ -52,16 +52,19 @@ debug: $(DEPENDS) rm -f build/Squirrel.app cd build ; ln -s Debug/Squirrel.app Squirrel.app +SQUIRREL_APP_PATH = /Library/Input Methods/Squirrel.app + install-debug: - rm -rf "/Library/Input Methods/Squirrel.app/Contents/Frameworks" - rm -rf "/Library/Input Methods/Squirrel.app/Contents/MacOS" + rm -rf "$(SQUIRREL_APP_PATH)/Contents/Frameworks" + rm -rf "$(SQUIRREL_APP_PATH)/Contents/MacOS" + cp -R build/Debug/Squirrel.app "/Library/Input Methods" - "/Library/Input Methods/Squirrel.app/Contents/Resources/postflight" + "$(SQUIRREL_APP_PATH)/Contents/Resources/postflight" install-release: - rm -rf "/Library/Input Methods/Squirrel.app" + rm -rf "$(SQUIRREL_APP_PATH)" cp -R build/Release/Squirrel.app "/Library/Input Methods" - "/Library/Input Methods/Squirrel.app/Contents/Resources/postflight" + "$(SQUIRREL_APP_PATH)/Contents/Resources/postflight" clean: rm -rf build > /dev/null 2>&1 || true diff --git a/Squirrel.xcodeproj/project.pbxproj b/Squirrel.xcodeproj/project.pbxproj index ccc589776..b1537bbc7 100644 --- a/Squirrel.xcodeproj/project.pbxproj +++ b/Squirrel.xcodeproj/project.pbxproj @@ -27,6 +27,7 @@ 44F01538152B2D9300EFDAC3 /* Sparkle.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 44F01492152AF6AF00EFDAC3 /* Sparkle.framework */; }; 44F7708F152B3334005CF491 /* dsa_pub.pem in Resources */ = {isa = PBXBuildFile; fileRef = 44F7708E152B3334005CF491 /* dsa_pub.pem */; }; 44F84AD714E94C490005D70B /* SquirrelPanel.m in Sources */ = {isa = PBXBuildFile; fileRef = 44F84AD614E94C490005D70B /* SquirrelPanel.m */; }; + 44FED9BA1A48502900037B05 /* preflight in Resources */ = {isa = PBXBuildFile; fileRef = 44FED9B91A48502900037B05 /* preflight */; }; 7B53068F1A30104000486AC2 /* double_pinyin_pyjj.schema.yaml in Copy Shared Support Files */ = {isa = PBXBuildFile; fileRef = 7B53068D1A30102D00486AC2 /* double_pinyin_pyjj.schema.yaml */; }; 7BD9C04C1A2C689B008C0913 /* bopomofo_tw.schema.yaml in Copy Shared Support Files */ = {isa = PBXBuildFile; fileRef = 7BD9BFF61A2C686C008C0913 /* bopomofo_tw.schema.yaml */; }; 7BD9C04D1A2C689B008C0913 /* bopomofo.schema.yaml in Copy Shared Support Files */ = {isa = PBXBuildFile; fileRef = 7BD9BFF71A2C686C008C0913 /* bopomofo.schema.yaml */; }; @@ -232,6 +233,7 @@ 44F84AD614E94C490005D70B /* SquirrelPanel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SquirrelPanel.m; sourceTree = ""; }; 44FA4D891685997300116C1F /* zh_CN */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = zh_CN; path = zh_CN.lproj/Localizable.strings; sourceTree = ""; }; 44FA4D8E16859B2900116C1F /* zh_TW */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = zh_TW; path = zh_TW.lproj/Localizable.strings; sourceTree = ""; }; + 44FED9B91A48502900037B05 /* preflight */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = preflight; sourceTree = ""; }; 7B53068D1A30102D00486AC2 /* double_pinyin_pyjj.schema.yaml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = double_pinyin_pyjj.schema.yaml; path = data/brise/double_pinyin_pyjj.schema.yaml; sourceTree = ""; }; 7BD9BF631A2C63AD008C0913 /* HKVariants.ocd */ = {isa = PBXFileReference; lastKnownFileType = file; path = HKVariants.ocd; sourceTree = ""; }; 7BD9BF641A2C63AD008C0913 /* s2t.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = s2t.json; sourceTree = ""; }; @@ -381,6 +383,7 @@ 29B97317FDCFA39411CA2CEA /* Resources */ = { isa = PBXGroup; children = ( + 44FED9B91A48502900037B05 /* preflight */, 44986A93184B421700B3278D /* LICENSE.txt */, 44986A94184B421700B3278D /* README.txt */, 44CD7D9E1828D981006E9222 /* rime.pdf */, @@ -552,6 +555,7 @@ 44986A96184B421700B3278D /* README.txt in Resources */, 44943BB815066A540005EE85 /* postflight in Resources */, 44F7708F152B3334005CF491 /* dsa_pub.pem in Resources */, + 44FED9BA1A48502900037B05 /* preflight in Resources */, 44CD7D9F1828D981006E9222 /* rime.pdf in Resources */, 4493402B158A4ABC0041A35A /* squirrel-app.icns in Resources */, 448CCCDD166B2E0500337E78 /* Growl Registration Ticket.growlRegDict in Resources */, diff --git a/input_source.m b/input_source.m index 7aa20485f..94883ac77 100644 --- a/input_source.m +++ b/input_source.m @@ -4,8 +4,11 @@ "/Library/Input Methods/Squirrel.app"; static NSString *const kSourceID = @"com.googlecode.rimeime.inputmethod.Squirrel"; +static NSString *const kInputModeID = + @"com.googlecode.rimeime.inputmethod.Squirrel.Rime"; void RegisterInputSource() { + NSLog(@"RegisterInputSource."); CFURLRef installedLocationURL = CFURLCreateFromFileSystemRepresentation( NULL, kInstalledLocation, strlen((const char *)kInstalledLocation), NO); if (installedLocationURL) { @@ -14,40 +17,63 @@ void RegisterInputSource() { } void ActivateInputSource() { + NSLog(@"ActivateInputSource."); CFArrayRef sourceList = TISCreateInputSourceList(NULL, true); for (int i = 0; i < CFArrayGetCount(sourceList); ++i) { TISInputSourceRef inputSource = (TISInputSourceRef)(CFArrayGetValueAtIndex( sourceList, i)); NSString *sourceID = (NSString *)(TISGetInputSourceProperty( inputSource, kTISPropertyInputSourceID)); - if ([sourceID isEqualToString:kSourceID]) { + //NSLog(@"examining input source '%@", sourceID); + if ([sourceID isEqualToString:kSourceID] || + [sourceID isEqualToString:kInputModeID]) { TISEnableInputSource(inputSource); - TISSelectInputSource(inputSource); - break; + CFBooleanRef isSelectable = (CFBooleanRef)TISGetInputSourceProperty( + inputSource, kTISPropertyInputSourceIsSelectCapable); + if (CFBooleanGetValue(isSelectable)) { + NSLog(@"selecting input source '%@'.", sourceID); + TISSelectInputSource(inputSource); + } + NSLog(@"'%@' should have been activated.", sourceID); + } + } +} + +void DeactivateInputSource() { + NSLog(@"DeactivateInputSource."); + CFArrayRef sourceList = TISCreateInputSourceList(NULL, true); + for (int i = CFArrayGetCount(sourceList); i > 0; --i) { + TISInputSourceRef inputSource = (TISInputSourceRef)(CFArrayGetValueAtIndex( + sourceList, i - 1)); + NSString *sourceID = (NSString *)(TISGetInputSourceProperty( + inputSource, kTISPropertyInputSourceID)); + //NSLog(@"examining input source '%@", sourceID); + if ([sourceID isEqualToString:kSourceID] || + [sourceID isEqualToString:kInputModeID]) { + TISDisableInputSource(inputSource); + NSLog(@"'%@' should have been deactivated.", sourceID); } } } BOOL IsInputSourceActive() { - BOOL isActive = NO; + int active = 0; CFArrayRef sourceList = TISCreateInputSourceList(NULL, true); for (int i = 0; i < CFArrayGetCount(sourceList); ++i) { TISInputSourceRef inputSource = (TISInputSourceRef)(CFArrayGetValueAtIndex( sourceList, i)); NSString *sourceID = (NSString *)(TISGetInputSourceProperty( inputSource, kTISPropertyInputSourceID)); - if ([sourceID isEqualToString:kSourceID]) { + NSLog(@"examining input source '%@'", sourceID); + if ([sourceID isEqualToString:kSourceID] || + [sourceID isEqualToString:kInputModeID]) { CFBooleanRef isEnabled = (CFBooleanRef)(TISGetInputSourceProperty( inputSource, kTISPropertyInputSourceIsEnabled)); - CFBooleanRef isSelected = (CFBooleanRef)(TISGetInputSourceProperty( - inputSource, kTISPropertyInputSourceIsEnabled)); - if (CFBooleanGetValue(isEnabled) || CFBooleanGetValue(isSelected)) { - isActive = YES; - break; + if (CFBooleanGetValue(isEnabled)) { + ++active; } } } - return isActive; + NSLog(@"IsInputSourceActive: %d / 2", active); + return active == 2; // 1 active input method + 1 active input mode } - - diff --git a/main.m b/main.m index 876fa1cc8..6d5669994 100644 --- a/main.m +++ b/main.m @@ -7,7 +7,8 @@ void RegisterInputSource(); void ActivateInputSource(); -BOOL IsInputSourceActive(); +void DeactivateInputSource(); +//BOOL IsInputSourceActive(); // Each input method needs a unique connection name. // Note that periods and spaces are not allowed in the connection name. @@ -35,10 +36,9 @@ int main(int argc, char *argv[]) if (argc > 1 && !strcmp("--install", argv[1])) { // register and enable Squirrel - if (!IsInputSourceActive()) { - RegisterInputSource(); - ActivateInputSource(); - } + RegisterInputSource(); + DeactivateInputSource(); + ActivateInputSource(); return 0; } diff --git a/package/Package.pmdoc/01squirrel-contents.xml b/package/Package.pmdoc/01squirrel-contents.xml index 6eb2d30c1..7ef9b22b2 100644 --- a/package/Package.pmdoc/01squirrel-contents.xml +++ b/package/Package.pmdoc/01squirrel-contents.xml @@ -1,6 +1,6 @@ - + @@ -578,6 +578,7 @@ + diff --git a/package/Package.pmdoc/01squirrel.xml b/package/Package.pmdoc/01squirrel.xml index d930aeaa5..0950ad1e7 100644 --- a/package/Package.pmdoc/01squirrel.xml +++ b/package/Package.pmdoc/01squirrel.xml @@ -1,12 +1,12 @@ - + com.googlecode.rimeime.Squirrel.pkg 0.9.26.1 - /Users/lotem/squirrel/build/Release/Squirrel.app + /Users/lotem/work/squirrel/build/Release/Squirrel.app /Library/Input Methods @@ -15,21 +15,30 @@ installTo postInstall relocatable - installFrom.path scripts.postinstall.path + scripts.preinstall.path identifier parent version installTo.path + ../preflight ../postflight 01squirrel-contents.xml - - - + + + isRelocatable + isDowngradeable + + + isRelocatable + isDowngradeable + + isRelocatable + isDowngradeable /CVS$ /\.svn$ diff --git a/package/Package.pmdoc/index.xml b/package/Package.pmdoc/index.xml index eaf4b3234..1dce4a17f 100644 --- a/package/Package.pmdoc/index.xml +++ b/package/Package.pmdoc/index.xml @@ -21,13 +21,13 @@ 今由〔RIME/中州韻輸入法引擎〕強力驅動 - + - 01squirrel.xml - properties.systemDomain + description properties.title properties.customizeOption properties.userDomain properties.anywhereDomain - description + properties.systemDomain diff --git a/preflight b/preflight new file mode 100755 index 000000000..b406b47ca --- /dev/null +++ b/preflight @@ -0,0 +1,6 @@ +#!/bin/bash +SQUIRREL_APP_PATH="/Library/Input Methods/Squirrel.app" + +echo "uninstalling previous version." +rm -Rf "$SQUIRREL_APP_PATH" +/usr/bin/true From c9a8ea0ad9a67c332dfa8c09717549095d3bc417 Mon Sep 17 00:00:00 2001 From: lotem Date: Tue, 23 Dec 2014 10:38:04 +0800 Subject: [PATCH 2/2] Squirrel 0.9.26.2 hotfix. --- CHANGES.md | 5 +++++ Info.plist | 2 +- package/Package.pmdoc/01squirrel.xml | 14 +++----------- package/Package.pmdoc/index.xml | 15 ++++++++++----- update/appcast.xml | 8 ++++---- 5 files changed, 23 insertions(+), 21 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 39295b7af..b52af6218 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -3,6 +3,11 @@ RIME 主葉:https://rimeime.github.io +鼠鬚管 0.9.26.2 <2014-12-23> +--- + + * 修復:安裝後輸入法在一些 app 中無法啓用 [#43](https://github.com/lotem/squirrel/issues/43) + 鼠鬚管 0.9.26.1 <2014-12-22> --- diff --git a/Info.plist b/Info.plist index 8e229ae9d..9310424c3 100644 --- a/Info.plist +++ b/Info.plist @@ -19,7 +19,7 @@ CFBundleSignature ???? CFBundleVersion - 0.9.26.1 + 0.9.26.2 InputMethodConnectionName Squirrel_1_Connection InputMethodServerControllerClass diff --git a/package/Package.pmdoc/01squirrel.xml b/package/Package.pmdoc/01squirrel.xml index 0950ad1e7..fd9ededae 100644 --- a/package/Package.pmdoc/01squirrel.xml +++ b/package/Package.pmdoc/01squirrel.xml @@ -2,7 +2,7 @@ com.googlecode.rimeime.Squirrel.pkg - 0.9.26.1 + 0.9.26.2 @@ -29,16 +29,8 @@ 01squirrel-contents.xml - - isRelocatable - isDowngradeable - - - isRelocatable - isDowngradeable - - isRelocatable - isDowngradeable + + /CVS$ /\.svn$ diff --git a/package/Package.pmdoc/index.xml b/package/Package.pmdoc/index.xml index 1dce4a17f..d068891d2 100644 --- a/package/Package.pmdoc/index.xml +++ b/package/Package.pmdoc/index.xml @@ -27,7 +27,7 @@ - \ +\f2 \'ca\'f3\'f4\'50\'b9\'dc 0.9.26.2 <2014-12-23>\ +---\ +\ + * \'d0\'de\'8f\'cd\'a3\'ba\'b0\'b2\'d1\'62\'e1\'e1\'dd\'94\'c8\'eb\'b7\'a8\'d4\'da\'d2\'bb\'d0\'a9 app \'d6\'d0\'9f\'6f\'b7\'a8\'86\'99\'d3\'c3 #43\ +\ +\'ca\'f3\'f4\'50\'b9\'dc 0.9.26.1 <2014-12-22>\ ---\ \ * \'d0\'de\'8f\'cd\'a3\'ba0.9.26 \'b0\'e6\'b1\'be\'d4\'4f\'d6\'c3 `translator/enable_user_dict: false` \'b0\'6c\'c9\'fa\'b1\'c0\'9d\'a2\ @@ -363,10 +368,10 @@ Rime \'cb\'e3\'b7\'a8\'8e\'ec\'d7\'83\'b8\'fc\'bc\'af\ 01squirrel.xml - description + properties.systemDomain properties.title properties.customizeOption + description properties.userDomain properties.anywhereDomain - properties.systemDomain diff --git a/update/appcast.xml b/update/appcast.xml index f3aa82066..4b15c0e85 100644 --- a/update/appcast.xml +++ b/update/appcast.xml @@ -6,14 +6,14 @@ 鼠鬚管 Appcast 更新頻道 zh - 鼠鬚管 0.9.26.1 + 鼠鬚管 0.9.26.2 http://rimeime.github.io/release/squirrel/ 10.7.0 Mon, 22 Dec 2014 12:00:00 +0800 -