ELocalizationServiceOperationCommandResult::Type FOneSkyLocalizationServiceProvider::Execute(const TSharedRef<ILocalizationServiceOperation, ESPMode::ThreadSafe>& InOperation, const TArray<FLocalizationServiceTranslationIdentifier>& InTranslationIds, ELocalizationServiceOperationConcurrency::Type InConcurrency, const FLocalizationServiceOperationComplete& InOperationCompleteDelegate) { if(!IsEnabled()) { return ELocalizationServiceOperationCommandResult::Failed; } // Query to see if the we allow this operation TSharedPtr<IOneSkyLocalizationServiceWorker, ESPMode::ThreadSafe> Worker = CreateWorker(InOperation->GetName()); if(!Worker.IsValid()) { // this operation is unsupported by this source control provider FFormatNamedArguments Arguments; Arguments.Add( TEXT("OperationName"), FText::FromName(InOperation->GetName()) ); Arguments.Add( TEXT("ProviderName"), FText::FromName(GetName()) ); FMessageLog("LocalizationService").Error(FText::Format(LOCTEXT("UnsupportedOperation", "Operation '{OperationName}' not supported by source control provider '{ProviderName}'"), Arguments)); return ELocalizationServiceOperationCommandResult::Failed; } // fire off operation if(InConcurrency == ELocalizationServiceOperationConcurrency::Synchronous) { FOneSkyLocalizationServiceCommand* Command = new FOneSkyLocalizationServiceCommand(InOperation, Worker.ToSharedRef()); Command->bAutoDelete = false; Command->OperationCompleteDelegate = InOperationCompleteDelegate; return ExecuteSynchronousCommand(*Command, InOperation->GetInProgressString(), true); } else { FOneSkyLocalizationServiceCommand* Command = new FOneSkyLocalizationServiceCommand(InOperation, Worker.ToSharedRef()); Command->bAutoDelete = true; Command->OperationCompleteDelegate = InOperationCompleteDelegate; return IssueCommand(*Command, false); } }
ECommandResult::Type FSubversionSourceControlProvider::Execute( const TSharedRef<ISourceControlOperation, ESPMode::ThreadSafe>& InOperation, const TArray<FString>& InFiles, EConcurrency::Type InConcurrency, const FSourceControlOperationComplete& InOperationCompleteDelegate ) { if(!IsEnabled()) { return ECommandResult::Failed; } if(!SubversionSourceControlUtils::CheckFilenames(InFiles)) { return ECommandResult::Failed; } TArray<FString> AbsoluteFiles = SourceControlHelpers::AbsoluteFilenames(InFiles); // Query to see if the we allow this operation TSharedPtr<ISubversionSourceControlWorker, ESPMode::ThreadSafe> Worker = CreateWorker(InOperation->GetName()); if(!Worker.IsValid()) { // this operation is unsupported by this source control provider FFormatNamedArguments Arguments; Arguments.Add( TEXT("OperationName"), FText::FromName(InOperation->GetName()) ); Arguments.Add( TEXT("ProviderName"), FText::FromName(GetName()) ); FMessageLog("SourceControl").Error(FText::Format(LOCTEXT("UnsupportedOperation", "Operation '{OperationName}' not supported by source control provider '{ProviderName}'"), Arguments)); return ECommandResult::Failed; } // fire off operation if(InConcurrency == EConcurrency::Synchronous) { FSubversionSourceControlCommand* Command = new FSubversionSourceControlCommand(InOperation, Worker.ToSharedRef()); Command->bAutoDelete = false; Command->Files = AbsoluteFiles; Command->OperationCompleteDelegate = InOperationCompleteDelegate; return ExecuteSynchronousCommand(*Command, InOperation->GetInProgressString(), true); } else { FSubversionSourceControlCommand* Command = new FSubversionSourceControlCommand(InOperation, Worker.ToSharedRef()); Command->bAutoDelete = true; Command->Files = AbsoluteFiles; Command->OperationCompleteDelegate = InOperationCompleteDelegate; return IssueCommand(*Command, false); } }
ECommandResult::Type FProvider::Execute( const TSharedRef<ISourceControlOperation, ESPMode::ThreadSafe>& InOperation, const TArray<FString>& InFiles, EConcurrency::Type InConcurrency, const FSourceControlOperationComplete& InOperationCompleteDelegate ) { // the "Connect" operation is the only operation that can be performed while the // provider is disabled, if the operation is successful the provider will be enabled if (!IsEnabled() && (InOperation->GetName() != OperationNames::Connect)) { return ECommandResult::Failed; } // attempt to create a worker to perform the requested operation FWorkerPtr WorkerPtr = CreateWorker(InOperation->GetName()); if (!WorkerPtr.IsValid()) { // apparently we don't support this particular operation FFormatNamedArguments Arguments; Arguments.Add(TEXT("OperationName"), FText::FromName(InOperation->GetName())); Arguments.Add(TEXT("ProviderName"), FText::FromName(GetName())); LogError( FText::Format( LOCTEXT( "UnsupportedOperation", "Operation '{OperationName}' not supported by source control provider '{ProviderName}'" ), Arguments ) ); return ECommandResult::Failed; } auto* Command = new FCommand( GetWorkingDirectory(), AbsoluteContentDirectory, InOperation, WorkerPtr.ToSharedRef(), InOperationCompleteDelegate ); TArray<FString> AbsoluteFiles; if (InOperation->GetName() == OperationNames::Connect) { AbsoluteFiles.Add(Settings.GetMercurialPath()); } else if (InOperation->GetName() == OperationNames::MarkForAdd) { TArray<FString> AbsoluteLargeFiles; PrepareFilenamesForAddCommand(InFiles, AbsoluteFiles, AbsoluteLargeFiles); if (AbsoluteLargeFiles.Num() > 0) { Command->SetAbsoluteLargeFiles(AbsoluteLargeFiles); } } else { for (const auto& Filename : InFiles) { AbsoluteFiles.Add(FPaths::ConvertRelativePathToFull(Filename)); } } if (AbsoluteFiles.Num() > 0) { Command->SetAbsoluteFiles(AbsoluteFiles); } if (InConcurrency == EConcurrency::Synchronous) { auto Result = ExecuteSynchronousCommand(Command, InOperation->GetInProgressString()); delete Command; return Result; } else { return ExecuteCommand(Command, true); } }