Пример #1
0
int Configurator::SyncUserData() {
	HANDLE hMutex = CreateMutex(NULL, TRUE, L"WeaselDeployerMutex");
	if (!hMutex)
	{
		LOG(ERROR) << "Error creating WeaselDeployerMutex.";
		return 1;
	}
	if (GetLastError() == ERROR_ALREADY_EXISTS)
	{
		LOG(WARNING) << "another deployer process is running; aborting operation.";
		CloseHandle(hMutex);
		MessageBox(NULL, L"正在執行另一項部署任務,請稍候再試。", L"【小狼毫】", MB_OK | MB_ICONINFORMATION);
		return 1;
	}

	weasel::Client client;
	if (client.Connect())
	{
		LOG(INFO) << "Turning WeaselServer into maintenance mode.";
		client.StartMaintenance();
	}

	{
		rime::Deployer& deployer(rime::Service::instance().deployer());
		if (!RimeSyncUserData())
		{
			LOG(ERROR) << "Error synching user data.";
			return 1;
		}
		RimeJoinMaintenanceThread();
	}

	CloseHandle(hMutex);  // should be closed before resuming service.

	if (client.Connect())
	{
		LOG(INFO) << "Resuming service.";
		client.EndMaintenance();
	}
	return 0;
}
Пример #2
0
// deployment
static jboolean sync_user_data(JNIEnv *env, jobject thiz) {
  ALOGE("sync user data...");
  return RimeSyncUserData();
}