Correctly enable all input modes when upgrading.
This commit is contained in:
parent
362801eb6c
commit
d1893b6a37
|
@ -616,7 +616,7 @@
|
|||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
shellPath = /bin/sh;
|
||||
shellScript = "FROM=\"$BUILT_PRODUCTS_DIR/$FULL_PRODUCT_NAME\"\nPREVIOUS=\"$HOME/Library/Input Methods/$FULL_PRODUCT_NAME\"\nTO=\"$HOME/Library/Input Methods/\"\nEXE=\"$HOME/Library/Input Methods/$EXECUTABLE_FOLDER_PATH/$EXECUTABLE_NAME\"\n\nif [ $CONFIGURATION = \"Debug\" ]\nthen\n echo Stopping $PRODUCT_NAME\n killall \"$PRODUCT_NAME\"\n\n echo Removing the installed version at $PREVIOUS\n rm -rf \"$PREVIOUS\"\n\n echo Copying built product from $FROM to $TO\n cp -R \"$FROM\" \"$TO\"\n\n echo Invoking $EXE to activate $PRODUCT_NAME\n \"$EXE\" install\n\n echo Restarting SystemUIServer to reflect icon changes\n killall SystemUIServer\nfi\n";
|
||||
shellScript = "FROM=\"$BUILT_PRODUCTS_DIR/$FULL_PRODUCT_NAME\"\nPREVIOUS=\"$HOME/Library/Input Methods/$FULL_PRODUCT_NAME\"\nTO=\"$HOME/Library/Input Methods/\"\nEXE=\"$HOME/Library/Input Methods/$EXECUTABLE_FOLDER_PATH/$EXECUTABLE_NAME\"\n\nif [ $CONFIGURATION = \"Debug\" ]\nthen\n echo Stopping $PRODUCT_NAME\n killall \"$PRODUCT_NAME\"\n\n echo Removing the installed version at $PREVIOUS\n rm -rf \"$PREVIOUS\"\n\n echo Restarting SystemUIServer to ensure full removal of the old copy\n killall SystemUIServer\n\n echo Copying built product from $FROM to $TO\n cp -R \"$FROM\" \"$TO\"\n\n echo Invoking $EXE to activate $PRODUCT_NAME\n \"$EXE\" install\nfi\n";
|
||||
};
|
||||
/* End PBXShellScriptBuildPhase section */
|
||||
|
||||
|
|
|
@ -112,7 +112,7 @@ static const NSTimeInterval kNextCheckInterval = 86400.0;
|
|||
|
||||
- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error
|
||||
{
|
||||
NSLog(@"error");
|
||||
NSLog(@"error");
|
||||
}
|
||||
|
||||
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
|
||||
|
|
|
@ -85,6 +85,12 @@ static NSString *const kTargetFullBinPartialPath = @"~/Library/Input Methods/McB
|
|||
[[NSWorkspace sharedWorkspace] performFileOperation:NSWorkspaceRecycleOperation source:sourceDir destination:trashDir files:[NSArray arrayWithObject:kTargetBundle] tag:&tag];
|
||||
(void)tag;
|
||||
|
||||
// alno need to restart SystemUIServer to ensure that the icon is fully cleaned up
|
||||
if (_currentVersion && [_currentVersion compare:@"0.9.4"] != NSOrderedDescending) {
|
||||
NSTask *restartSystemUIServerTask = [NSTask launchedTaskWithLaunchPath:@"/usr/bin/killall" arguments:[NSArray arrayWithObjects: @"-9", @"SystemUIServer", nil]];
|
||||
[restartSystemUIServerTask waitUntilExit];
|
||||
}
|
||||
|
||||
NSTask *killTask = [NSTask launchedTaskWithLaunchPath:@"/usr/bin/killall" arguments:[NSArray arrayWithObjects: @"-9", kTargetBin, nil]];
|
||||
[killTask waitUntilExit];
|
||||
}
|
||||
|
@ -95,20 +101,19 @@ static NSString *const kTargetFullBinPartialPath = @"~/Library/Input Methods/McB
|
|||
NSRunAlertPanel(NSLocalizedString(@"Install Failed", nil), NSLocalizedString(@"Cannot copy the file to the destination.", nil), NSLocalizedString(@"Cancel", nil), nil, nil);
|
||||
[NSApp terminate:self];
|
||||
}
|
||||
|
||||
NSTask *installTask = [NSTask launchedTaskWithLaunchPath:[kTargetFullBinPartialPath stringByExpandingTildeInPath] arguments:[NSArray arrayWithObjects:@"install", nil]];
|
||||
|
||||
NSArray *installArgs = [NSArray arrayWithObjects:@"install", nil];
|
||||
if (_currentVersion && [_currentVersion compare:@"0.9.4"] != NSOrderedDescending) {
|
||||
installArgs = [installArgs arrayByAddingObject:@"--all"];
|
||||
}
|
||||
|
||||
NSTask *installTask = [NSTask launchedTaskWithLaunchPath:[kTargetFullBinPartialPath stringByExpandingTildeInPath] arguments:installArgs];
|
||||
[installTask waitUntilExit];
|
||||
if ([installTask terminationStatus] != 0) {
|
||||
NSRunAlertPanel(NSLocalizedString(@"Install Failed", nil), NSLocalizedString(@"Cannot activate the input method.", nil), NSLocalizedString(@"Cancel", nil), nil, nil);
|
||||
[NSApp terminate:self];
|
||||
}
|
||||
|
||||
// alno need to restart SystemUIServer to reflect icon changes if the replaced version <= 0.9.4
|
||||
if (_currentVersion && [_currentVersion compare:@"0.9.4"] != NSOrderedDescending) {
|
||||
NSTask *restartSystemUIServerTask = [NSTask launchedTaskWithLaunchPath:@"/usr/bin/killall" arguments:[NSArray arrayWithObjects: @"-9", @"SystemUIServer", nil]];
|
||||
[restartSystemUIServerTask waitUntilExit];
|
||||
}
|
||||
|
||||
NSRunAlertPanel(NSLocalizedString(@"Installation Successful", nil), NSLocalizedString(@"McBopomofo is ready to use.", nil), NSLocalizedString(@"OK", nil), nil, nil);
|
||||
[NSApp terminate:self];
|
||||
}
|
||||
|
|
|
@ -40,6 +40,7 @@
|
|||
// enable/disable an input source (along with all its input modes)
|
||||
+ (BOOL)inputSourceEnabled:(TISInputSourceRef)inInputSource;
|
||||
+ (BOOL)enableInputSource:(TISInputSourceRef)inInputSource;
|
||||
+ (BOOL)enableAllInputModesForInputSourceBundleID:(NSString *)inID;
|
||||
+ (BOOL)disableInputSource:(TISInputSourceRef)inInputSource;
|
||||
|
||||
// register (i.e. make available to Input Source tab in Language & Text Preferences)
|
||||
|
|
|
@ -36,7 +36,6 @@
|
|||
|
||||
+ (TISInputSourceRef)inputSourceForProperty:(CFStringRef)inPropertyKey stringValue:(NSString *)inValue
|
||||
{
|
||||
|
||||
CFTypeID stringID = CFStringGetTypeID();
|
||||
|
||||
for (id source in [self allInstalledInputSources]) {
|
||||
|
@ -70,6 +69,27 @@
|
|||
return status == noErr;
|
||||
}
|
||||
|
||||
+ (BOOL)enableAllInputModesForInputSourceBundleID:(NSString *)inID
|
||||
{
|
||||
BOOL enabled = NO;
|
||||
|
||||
for (id source in [self allInstalledInputSources]) {
|
||||
TISInputSourceRef inputSource = (TISInputSourceRef)source;
|
||||
NSString *bundleID = (NSString *)TISGetInputSourceProperty(inputSource, kTISPropertyBundleID);
|
||||
NSString *mode = (NSString *)TISGetInputSourceProperty(inputSource, kTISPropertyInputModeID);
|
||||
if (mode && [bundleID isEqualToString:inID]) {
|
||||
BOOL modeEnabled = [self enableInputSource:inputSource];
|
||||
if (!modeEnabled) {
|
||||
return NO;
|
||||
}
|
||||
|
||||
enabled = YES;
|
||||
}
|
||||
}
|
||||
|
||||
return enabled;
|
||||
}
|
||||
|
||||
+ (BOOL)disableInputSource:(TISInputSourceRef)inInputSource
|
||||
{
|
||||
OSStatus status = TISDisableInputSource(inInputSource);
|
||||
|
|
|
@ -94,6 +94,17 @@ int main(int argc, char *argv[])
|
|||
}
|
||||
}
|
||||
|
||||
if (argc > 2 && !strcmp(argv[2], "--all")) {
|
||||
BOOL enabled = [OVInputSourceHelper enableAllInputModesForInputSourceBundleID:bundleID];
|
||||
if (enabled) {
|
||||
NSLog(@"All input sources enabled for %@", bundleID);
|
||||
}
|
||||
else {
|
||||
NSLog(@"Failed to enable all input sources for %@", bundleID);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue