This repository has been archived by the owner on Nov 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 297
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
33 changed files
with
407 additions
and
360 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
[CoreRedirects] | ||
+PackageRedirects=(OldName="/VaRestPlugin/", NewName="/VaRest/", MatchSubstring=true) | ||
+ClassRedirects=(OldName="/Script/VaRestPlugin.VaRestJsonObject",NewName="/Script/VaRest.VaRestJsonObject") | ||
+ClassRedirects=(OldName="/Script/VaRestPlugin.VaRestJsonValue",NewName="/Script/VaRest.VaRestJsonValue") | ||
+ClassRedirects=(OldName="/Script/VaRestPlugin.VaRestLibrary",NewName="/Script/VaRest.VaRestLibrary") | ||
+ClassRedirects=(OldName="/Script/VaRestPlugin.VaRestRequestJSON",NewName="/Script/VaRest.VaRestRequestJSON") | ||
+StructRedirects=(OldName="/Script/VaRestPlugin.VaRestCallResponse",NewName="/Script/VaRest.VaRestCallResponse") | ||
+EnumRedirects=(OldName="/Script/VaRestPlugin.EVaJson",NewName="/Script/VaRest.EVaJson") | ||
+EnumRedirects=(OldName="/Script/VaRestPlugin.ERequestVerb",NewName="/Script/VaRest.ERequestVerb") | ||
+EnumRedirects=(OldName="/Script/VaRestPlugin.ERequestContentType",NewName="/Script/VaRest.ERequestContentType") | ||
+EnumRedirects=(OldName="/Script/VaRestPlugin.ERequestStatus",NewName="/Script/VaRest.ERequestStatus") | ||
+FunctionRedirects=(OldName="VaRestRequestJSON.ConstructRequest",NewName="VaRestRequestJSON.ConstructVaRestRequest") | ||
+FunctionRedirects=(OldName="VaRestRequestJSON.ConstructRequestExt",NewName="VaRestRequestJSON.ConstructVaRestRequestExt") | ||
+FunctionRedirects=(OldName="VaRestJsonObject.ConstructJsonObject",NewName="VaRestJsonObject.ConstructVaRestJsonObject") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
[CoreRedirects] | ||
+PackageRedirects=(OldName="/VaRestPlugin/", NewName="/VaRest/", MatchSubstring=true) | ||
+ClassRedirects=(OldName="/Script/VaRestPlugin.VaRestJsonObject",NewName="/Script/VaRest.VaRestJsonObject") | ||
+ClassRedirects=(OldName="/Script/VaRestPlugin.VaRestJsonValue",NewName="/Script/VaRest.VaRestJsonValue") | ||
+ClassRedirects=(OldName="/Script/VaRestPlugin.VaRestLibrary",NewName="/Script/VaRest.VaRestLibrary") | ||
+ClassRedirects=(OldName="/Script/VaRestPlugin.VaRestRequestJSON",NewName="/Script/VaRest.VaRestRequestJSON") | ||
+StructRedirects=(OldName="/Script/VaRestPlugin.VaRestCallResponse",NewName="/Script/VaRest.VaRestCallResponse") | ||
+EnumRedirects=(OldName="/Script/VaRestPlugin.EVaJson",NewName="/Script/VaRest.EVaJson") | ||
+EnumRedirects=(OldName="/Script/VaRestPlugin.ERequestVerb",NewName="/Script/VaRest.ERequestVerb") | ||
+EnumRedirects=(OldName="/Script/VaRestPlugin.ERequestContentType",NewName="/Script/VaRest.ERequestContentType") | ||
+EnumRedirects=(OldName="/Script/VaRestPlugin.ERequestStatus",NewName="/Script/VaRest.ERequestStatus") | ||
+FunctionRedirects=(OldName="VaRestRequestJSON.ConstructRequest",NewName="VaRestRequestJSON.ConstructVaRestRequest") | ||
+FunctionRedirects=(OldName="VaRestRequestJSON.ConstructRequestExt",NewName="VaRestRequestJSON.ConstructVaRestRequestExt") | ||
+FunctionRedirects=(OldName="VaRestJsonObject.ConstructJsonObject",NewName="VaRestJsonObject.ConstructVaRestJsonObject") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[FilterPlugin] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
// Copyright 2014-2019 Vladimir Alyamkin. All Rights Reserved. | ||
|
||
#include "VaRest.h" | ||
|
||
#include "VaRestDefines.h" | ||
#include "VaRestJsonObject.h" | ||
#include "VaRestJsonValue.h" | ||
#include "VaRestRequestController.h" | ||
#include "VaRestRequestJSON.h" | ||
#include "VaRestSettings.h" | ||
|
||
#include "Developer/Settings/Public/ISettingsModule.h" | ||
|
||
#define LOCTEXT_NAMESPACE "FVaRestModule" | ||
|
||
void FVaRestModule::StartupModule() | ||
{ | ||
// @HACK Force classes to be compiled on shipping build | ||
UVaRestJsonObject::StaticClass(); | ||
UVaRestJsonValue::StaticClass(); | ||
UVaRestRequestJSON::StaticClass(); | ||
|
||
VaRestSettings = NewObject<UVaRestSettings>(GetTransientPackage(), "VaRestSettings", RF_Standalone); | ||
VaRestSettings->AddToRoot(); | ||
|
||
// Register settings | ||
if (ISettingsModule* SettingsModule = FModuleManager::GetModulePtr<ISettingsModule>("Settings")) | ||
{ | ||
SettingsModule->RegisterSettings("Project", "Plugins", "VaRest", | ||
LOCTEXT("RuntimeSettingsName", "VaRest"), | ||
LOCTEXT("RuntimeSettingsDescription", "Configure VaRest plugin settings"), | ||
VaRestSettings); | ||
} | ||
|
||
FWorldDelegates::OnWorldCleanup.AddLambda([this](UWorld* World, bool bSessionEnded, bool bCleanupResources) { | ||
RequestControllers.Remove(World); | ||
|
||
UE_LOG(LogVaRest, Log, TEXT("%s: Request Controller is removed for: %s"), *VA_FUNC_LINE, *World->GetName()); | ||
}); | ||
|
||
FWorldDelegates::OnPostWorldInitialization.AddLambda([this](UWorld* World, const UWorld::InitializationValues IVS) { | ||
auto Controller = NewObject<UVaRestRequestController>(GetTransientPackage()); | ||
Controller->SetFlags(RF_Standalone); | ||
Controller->AddToRoot(); | ||
|
||
Controller->Initialize(); | ||
|
||
RequestControllers.Add(World, Controller); | ||
|
||
UE_LOG(LogVaRest, Log, TEXT("%s: Request Controller is created for: %s"), *VA_FUNC_LINE, *World->GetName()); | ||
}); | ||
|
||
UE_LOG(LogVaRest, Log, TEXT("%s: VaRest module started"), *VA_FUNC_LINE); | ||
} | ||
|
||
void FVaRestModule::ShutdownModule() | ||
{ | ||
if (ISettingsModule* SettingsModule = FModuleManager::GetModulePtr<ISettingsModule>("Settings")) | ||
{ | ||
SettingsModule->UnregisterSettings("Project", "Plugins", "VaRest"); | ||
} | ||
|
||
if (!GExitPurge) | ||
{ | ||
VaRestSettings->RemoveFromRoot(); | ||
|
||
// If we're in exit purge, this object has already been destroyed | ||
for (auto Controller : RequestControllers) | ||
{ | ||
Controller.Value->RemoveFromRoot(); | ||
} | ||
} | ||
else | ||
{ | ||
VaRestSettings = nullptr; | ||
} | ||
|
||
RequestControllers.Empty(); | ||
} | ||
|
||
UVaRestSettings* FVaRestModule::GetSettings() const | ||
{ | ||
check(VaRestSettings); | ||
return VaRestSettings; | ||
} | ||
|
||
UVaRestRequestController* FVaRestModule::GetRequestController(UWorld* World) const | ||
{ | ||
return RequestControllers.FindChecked(World); | ||
} | ||
|
||
IMPLEMENT_MODULE(FVaRestModule, VaRest) | ||
|
||
DEFINE_LOG_CATEGORY(LogVaRest); | ||
|
||
#undef LOCTEXT_NAMESPACE |
10 changes: 5 additions & 5 deletions
10
...VaRestPlugin/Private/VaRestJsonObject.cpp → Source/VaRest/Private/VaRestJsonObject.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
9 changes: 5 additions & 4 deletions
9
.../VaRestPlugin/Private/VaRestJsonValue.cpp → Source/VaRest/Private/VaRestJsonValue.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
// Copyright 2014-2019 Vladimir Alyamkin. All Rights Reserved. | ||
|
||
#include "VaRestLibrary.h" | ||
|
||
#include "VaRestDefines.h" | ||
#include "VaRestJsonObject.h" | ||
#include "VaRestRequestJSON.h" | ||
|
||
#include "Misc/Base64.h" | ||
#include "Misc/FileHelper.h" | ||
#include "Misc/Paths.h" | ||
|
||
////////////////////////////////////////////////////////////////////////// | ||
// Helpers | ||
|
||
FString UVaRestLibrary::PercentEncode(const FString& Source) | ||
{ | ||
return FGenericPlatformHttp::UrlEncode(Source); | ||
} | ||
|
||
FString UVaRestLibrary::Base64Encode(const FString& Source) | ||
{ | ||
return FBase64::Encode(Source); | ||
} | ||
|
||
bool UVaRestLibrary::Base64Decode(const FString& Source, FString& Dest) | ||
{ | ||
return FBase64::Decode(Source, Dest); | ||
} | ||
|
||
bool UVaRestLibrary::Base64EncodeData(const TArray<uint8>& Data, FString& Dest) | ||
{ | ||
if (Data.Num() > 0) | ||
{ | ||
Dest = FBase64::Encode(Data); | ||
return true; | ||
} | ||
|
||
return false; | ||
} | ||
|
||
bool UVaRestLibrary::Base64DecodeData(const FString& Source, TArray<uint8>& Dest) | ||
{ | ||
return FBase64::Decode(Source, Dest); | ||
} | ||
|
||
////////////////////////////////////////////////////////////////////////// | ||
// File system integration | ||
|
||
class UVaRestJsonObject* UVaRestLibrary::LoadJsonFromFile(UObject* WorldContextObject, const FString& Path, const bool bIsRelativeToContentDir) | ||
{ | ||
UVaRestJsonObject* Json = UVaRestJsonObject::ConstructVaRestJsonObject(WorldContextObject); | ||
|
||
FString JSONString; | ||
if (FFileHelper::LoadFileToString(JSONString, *(bIsRelativeToContentDir ? FPaths::ProjectContentDir() / Path : Path))) | ||
{ | ||
if (Json->DecodeJson(JSONString)) | ||
{ | ||
return Json; | ||
} | ||
else | ||
{ | ||
UE_LOG(LogVaRest, Error, TEXT("%s: Can't decode json from file %s"), *VA_FUNC_LINE, *Path); | ||
} | ||
} | ||
else | ||
{ | ||
UE_LOG(LogVaRest, Error, TEXT("%s: Can't open file %s"), *VA_FUNC_LINE, *Path); | ||
} | ||
|
||
return nullptr; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// Copyright 2014-2019 Vladimir Alyamkin. All Rights Reserved. | ||
|
||
#include "VaRestRequestController.h" | ||
|
||
#include "VaRestDefines.h" | ||
|
||
UVaRestRequestController::UVaRestRequestController(const FObjectInitializer& ObjectInitializer) | ||
: Super(ObjectInitializer) | ||
{ | ||
} | ||
|
||
void UVaRestRequestController::Initialize() | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...e/VaRestPlugin/Private/VaRestSettings.cpp → Source/VaRest/Private/VaRestSettings.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.