Skip to content
This repository has been archived by the owner on Nov 1, 2024. It is now read-only.

Commit

Permalink
Finish v1.1-r29
Browse files Browse the repository at this point in the history
  • Loading branch information
ufna committed Apr 1, 2020
2 parents cbbe78f + ac130d8 commit 3ac2d5b
Show file tree
Hide file tree
Showing 18 changed files with 471 additions and 206 deletions.
15 changes: 12 additions & 3 deletions Config/BaseVaRest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,18 @@
+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")
+EnumRedirects=(OldName="/Script/VaRestPlugin.EVaRestRequestVerb",NewName="/Script/VaRest.EVaRestRequestVerb")
+EnumRedirects=(OldName="/Script/VaRestPlugin.EVaRestRequestContentType",NewName="/Script/VaRest.EVaRestRequestContentType")
+EnumRedirects=(OldName="/Script/VaRestPlugin.EVaRestRequestStatus",NewName="/Script/VaRest.EVaRestRequestStatus")
+EnumRedirects=(OldName="/Script/VaRest.EVaRestRequestVerb",NewName="/Script/VaRest.EVaRestRequestVerb")
+EnumRedirects=(OldName="/Script/VaRest.EVaRestRequestContentType",NewName="/Script/VaRest.EVaRestRequestContentType")
+EnumRedirects=(OldName="/Script/VaRest.EVaRestRequestStatus",NewName="/Script/VaRest.EVaRestRequestStatus")
+FunctionRedirects=(OldName="VaRestRequestJSON.ConstructRequest",NewName="VaRestRequestJSON.ConstructVaRestRequest")
+FunctionRedirects=(OldName="VaRestRequestJSON.ConstructRequestExt",NewName="VaRestRequestJSON.ConstructVaRestRequestExt")
+FunctionRedirects=(OldName="VaRestJsonObject.ConstructJsonObject",NewName="VaRestJsonObject.ConstructVaRestJsonObject")
+FunctionRedirects=(OldName="VaRestJsonValue.ConstructJsonValueNumber",NewName="VaRestSubsystem.ConstructJsonValueNumber")
+FunctionRedirects=(OldName="VaRestJsonValue.ConstructJsonValueString",NewName="VaRestSubsystem.ConstructJsonValueString")
+FunctionRedirects=(OldName="VaRestJsonValue.ConstructJsonValueBool",NewName="VaRestSubsystem.ConstructJsonValueBool")
+FunctionRedirects=(OldName="VaRestJsonValue.ConstructJsonValueArray",NewName="VaRestSubsystem.ConstructJsonValueArray")
+FunctionRedirects=(OldName="VaRestJsonValue.ConstructJsonValueObject",NewName="VaRestSubsystem.ConstructJsonValueObject")
+FunctionRedirects=(OldName="VaRestJsonValue.ConstructJsonValue",NewName="VaRestSubsystem.ConstructJsonValue")
16 changes: 13 additions & 3 deletions Config/DefaultVaRest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,19 @@
+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")
+EnumRedirects=(OldName="/Script/VaRestPlugin.EVaRestRequestVerb",NewName="/Script/VaRest.EVaRestRequestVerb")
+EnumRedirects=(OldName="/Script/VaRestPlugin.EVaRestRequestContentType",NewName="/Script/VaRest.EVaRestRequestContentType")
+EnumRedirects=(OldName="/Script/VaRestPlugin.EVaRestRequestStatus",NewName="/Script/VaRest.EVaRestRequestStatus")
+EnumRedirects=(OldName="/Script/VaRest.EVaRestRequestVerb",NewName="/Script/VaRest.EVaRestRequestVerb")
+EnumRedirects=(OldName="/Script/VaRest.EVaRestRequestContentType",NewName="/Script/VaRest.EVaRestRequestContentType")
+EnumRedirects=(OldName="/Script/VaRest.EVaRestRequestStatus",NewName="/Script/VaRest.EVaRestRequestStatus")
+EnumRedirects=(OldName="/Script/VaRest.EVaRestHttpStatusCode",NewName="/Script/VaRest.EVaRestHttpStatusCode")
+FunctionRedirects=(OldName="VaRestRequestJSON.ConstructRequest",NewName="VaRestRequestJSON.ConstructVaRestRequest")
+FunctionRedirects=(OldName="VaRestRequestJSON.ConstructRequestExt",NewName="VaRestRequestJSON.ConstructVaRestRequestExt")
+FunctionRedirects=(OldName="VaRestJsonObject.ConstructJsonObject",NewName="VaRestJsonObject.ConstructVaRestJsonObject")
+FunctionRedirects=(OldName="VaRestJsonValue.ConstructJsonValueNumber",NewName="VaRestSubsystem.ConstructJsonValueNumber")
+FunctionRedirects=(OldName="VaRestJsonValue.ConstructJsonValueString",NewName="VaRestSubsystem.ConstructJsonValueString")
+FunctionRedirects=(OldName="VaRestJsonValue.ConstructJsonValueBool",NewName="VaRestSubsystem.ConstructJsonValueBool")
+FunctionRedirects=(OldName="VaRestJsonValue.ConstructJsonValueArray",NewName="VaRestSubsystem.ConstructJsonValueArray")
+FunctionRedirects=(OldName="VaRestJsonValue.ConstructJsonValueObject",NewName="VaRestSubsystem.ConstructJsonValueObject")
+FunctionRedirects=(OldName="VaRestJsonValue.ConstructJsonValue",NewName="VaRestSubsystem.ConstructJsonValue")
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Key features:

Check the [Wiki](http://bit.ly/VaRest-Docs) for plugin usage examples and installation notes.

Current version: **1.1 R 26** (UE 4.19-4.23)
Current version: **1.1 R 29** (UE 4.24)

![SCREENSHOT](SCREENSHOT.jpg)

Expand Down
47 changes: 47 additions & 0 deletions Source/VaRest/Private/VaRest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,54 @@
#include "VaRest.h"

#include "VaRestDefines.h"
#include "VaRestSettings.h"

#include "Developer/Settings/Public/ISettingsModule.h"

#define LOCTEXT_NAMESPACE "FVaRestModule"

void FVaRestModule::StartupModule()
{
ModuleSettings = NewObject<UVaRestSettings>(GetTransientPackage(), "VaRestSettings", RF_Standalone);
ModuleSettings->AddToRoot();

// Register settings
if (ISettingsModule* SettingsModule = FModuleManager::GetModulePtr<ISettingsModule>("Settings"))
{
SettingsModule->RegisterSettings("Project", "Plugins", "VaRest",
LOCTEXT("RuntimeSettingsName", "VaRest"),
LOCTEXT("RuntimeSettingsDescription", "Configure VaRest plugin settings"),
ModuleSettings);
}

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)
{
ModuleSettings->RemoveFromRoot();
}
else
{
ModuleSettings = nullptr;
}
}

UVaRestSettings* FVaRestModule::GetSettings() const
{
check(ModuleSettings);
return ModuleSettings;
}

IMPLEMENT_MODULE(FVaRestModule, VaRest)

DEFINE_LOG_CATEGORY(LogVaRest);

#undef LOCTEXT_NAMESPACE
28 changes: 28 additions & 0 deletions Source/VaRest/Private/VaRestJsonObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,34 @@ void UVaRestJsonObject::SetObjectField(const FString& FieldName, UVaRestJsonObje
JsonObj->SetObjectField(FieldName, JsonObject->GetRootObject());
}

void UVaRestJsonObject::SetMapFields_string(const TMap<FString, FString>& Fields)
{
for (auto& field : Fields)
{
SetStringField(field.Key, field.Value);
}
}

void UVaRestJsonObject::SetMapFields_uint8(const TMap<FString, uint8>& Fields)
{
SetMapFields_Impl(Fields);
}

void UVaRestJsonObject::SetMapFields_int32(const TMap<FString, int32>& Fields)
{
SetMapFields_Impl(Fields);
}

void UVaRestJsonObject::SetMapFields_int64(const TMap<FString, int64>& Fields)
{
SetMapFields_Impl(Fields);
}

void UVaRestJsonObject::SetMapFields_bool(const TMap<FString, bool>& Fields)
{
SetMapFields_Impl(Fields);
}

//////////////////////////////////////////////////////////////////////////
// Array fields helpers (uniform arrays)

Expand Down
67 changes: 0 additions & 67 deletions Source/VaRest/Private/VaRestJsonValue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,73 +10,6 @@ UVaRestJsonValue::UVaRestJsonValue(const FObjectInitializer& ObjectInitializer)
{
}

UVaRestJsonValue* UVaRestJsonValue::ConstructJsonValueNumber(UObject* WorldContextObject, float Number)
{
TSharedPtr<FJsonValue> NewVal = MakeShareable(new FJsonValueNumber(Number));

UVaRestJsonValue* NewValue = NewObject<UVaRestJsonValue>();
NewValue->SetRootValue(NewVal);

return NewValue;
}

UVaRestJsonValue* UVaRestJsonValue::ConstructJsonValueString(UObject* WorldContextObject, const FString& StringValue)
{
TSharedPtr<FJsonValue> NewVal = MakeShareable(new FJsonValueString(StringValue));

UVaRestJsonValue* NewValue = NewObject<UVaRestJsonValue>();
NewValue->SetRootValue(NewVal);

return NewValue;
}

UVaRestJsonValue* UVaRestJsonValue::ConstructJsonValueBool(UObject* WorldContextObject, bool InValue)
{
TSharedPtr<FJsonValue> NewVal = MakeShareable(new FJsonValueBoolean(InValue));

UVaRestJsonValue* NewValue = NewObject<UVaRestJsonValue>();
NewValue->SetRootValue(NewVal);

return NewValue;
}

UVaRestJsonValue* UVaRestJsonValue::ConstructJsonValueArray(UObject* WorldContextObject, const TArray<UVaRestJsonValue*>& InArray)
{
// Prepare data array to create new value
TArray<TSharedPtr<FJsonValue>> ValueArray;
for (auto InVal : InArray)
{
ValueArray.Add(InVal->GetRootValue());
}

TSharedPtr<FJsonValue> NewVal = MakeShareable(new FJsonValueArray(ValueArray));

UVaRestJsonValue* NewValue = NewObject<UVaRestJsonValue>();
NewValue->SetRootValue(NewVal);

return NewValue;
}

UVaRestJsonValue* UVaRestJsonValue::ConstructJsonValueObject(UObject* WorldContextObject, UVaRestJsonObject* JsonObject)
{
TSharedPtr<FJsonValue> NewVal = MakeShareable(new FJsonValueObject(JsonObject->GetRootObject()));

UVaRestJsonValue* NewValue = NewObject<UVaRestJsonValue>();
NewValue->SetRootValue(NewVal);

return NewValue;
}

UVaRestJsonValue* ConstructJsonValue(UObject* WorldContextObject, const TSharedPtr<FJsonValue>& InValue)
{
TSharedPtr<FJsonValue> NewVal = InValue;

UVaRestJsonValue* NewValue = NewObject<UVaRestJsonValue>();
NewValue->SetRootValue(NewVal);

return NewValue;
}

TSharedPtr<FJsonValue>& UVaRestJsonValue::GetRootValue()
{
return JsonVal;
Expand Down
43 changes: 39 additions & 4 deletions Source/VaRest/Private/VaRestLibrary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,18 @@

#include "VaRestLibrary.h"

#include "VaRest.h"
#include "VaRestDefines.h"
#include "VaRestJsonObject.h"
#include "VaRestRequestJSON.h"
#include "VaRestSettings.h"

#include "Misc/Base64.h"

//////////////////////////////////////////////////////////////////////////
// Helpers
UVaRestSettings* UVaRestLibrary::GetVaRestSettings()
{
return FVaRestModule::Get().GetSettings();
}

FString UVaRestLibrary::PercentEncode(const FString& Source)
{
Expand All @@ -18,12 +22,22 @@ FString UVaRestLibrary::PercentEncode(const FString& Source)

FString UVaRestLibrary::Base64Encode(const FString& Source)
{
return FBase64::Encode(Source);
TArray<uint8> ByteArray;
FTCHARToUTF8 StringSrc = FTCHARToUTF8(Source.GetCharArray().GetData());
ByteArray.Append((uint8*)StringSrc.Get(), StringSrc.Length());

return FBase64::Encode(ByteArray);
}

bool UVaRestLibrary::Base64Decode(const FString& Source, FString& Dest)
{
return FBase64::Decode(Source, Dest);
TArray<uint8> ByteArray;
bool Success = FBase64::Decode(Source, ByteArray);

FUTF8ToTCHAR StringSrc = FUTF8ToTCHAR((const ANSICHAR*)ByteArray.GetData(), ByteArray.Num());
Dest.AppendChars(StringSrc.Get(), StringSrc.Length() + 1);

return Success;
}

bool UVaRestLibrary::Base64EncodeData(const TArray<uint8>& Data, FString& Dest)
Expand All @@ -41,3 +55,24 @@ bool UVaRestLibrary::Base64DecodeData(const FString& Source, TArray<uint8>& Dest
{
return FBase64::Decode(Source, Dest);
}

FString UVaRestLibrary::StringToMd5(const FString& StringToHash)
{
return FMD5::HashAnsiString(*StringToHash);
}

FString UVaRestLibrary::StringToSha1(const FString& StringToHash)
{
FSHA1 Sha1Gen;

Sha1Gen.Update((unsigned char*)TCHAR_TO_ANSI(*StringToHash), FCString::Strlen(*StringToHash));
Sha1Gen.Final();

FString Sha1String;
for (int32 i = 0; i < 20; i++)
{
Sha1String += FString::Printf(TEXT("%02x"), Sha1Gen.m_digest[i]);
}

return Sha1String;
}
Loading

0 comments on commit 3ac2d5b

Please sign in to comment.