Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

允许使用命令行触发用户数据同步 #694

Merged
merged 1 commit into from
Jan 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions SquirrelApplicationDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,12 @@ -(void)rimeNeedsReload:(NSNotification *)aNotification
[self deploy:nil];
}

-(void)rimeNeedsSync:(NSNotification *)aNotification
{
NSLog(@"Sync rime on demand.");
[self syncUserData:nil];
}

-(NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender
{
NSLog(@"Squirrel is quitting.");
Expand All @@ -228,6 +234,11 @@ -(void)awakeFromNib
name:@"SquirrelReloadNotification"
object:nil];

[notifCenter addObserver:self
selector:@selector(rimeNeedsSync:)
name:@"SquirrelSyncNotification"
object:nil];

}

-(void)dealloc
Expand Down
7 changes: 7 additions & 0 deletions main.m
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,13 @@ int main(int argc, char *argv[]) {
return rime_get_api()->deploy() ? 0 : 1;
}

if (argc > 1 && !strcmp("--sync", argv[1])) {
[[NSDistributedNotificationCenter defaultCenter]
postNotificationName:@"SquirrelSyncNotification"
object:nil];
return 0;
}

@autoreleasepool {
// find the bundle identifier and then initialize the input method server
IMKServer *server __unused =
Expand Down