Removed the WebUI. Removed the Modules

This commit is contained in:
2024-10-30 23:10:04 +02:00
parent f8df0f0254
commit 9e8bfbbe16
2133 changed files with 120 additions and 15581 deletions

View File

@@ -22,7 +22,7 @@ namespace CppCompatibilityModule.Extern
return Result.Success();
}
Application.Logger.Log($"Loading library {LibraryPath}");
Application.CurrentApplication.Logger.Log($"Loading library {LibraryPath}");
if(!NativeLibrary.TryLoad(LibraryPath, out IntPtr hModule))
@@ -30,7 +30,7 @@ namespace CppCompatibilityModule.Extern
return Result.Failure(new DllNotFoundException($"Unable to load library {LibraryPath}"));
}
Application.Logger.Log($"Library {LibraryPath} loaded successfully [{hModule}]");
Application.CurrentApplication.Logger.Log($"Library {LibraryPath} loaded successfully [{hModule}]");
LibraryHandle = hModule;
@@ -47,7 +47,7 @@ namespace CppCompatibilityModule.Extern
NativeLibrary.Free(LibraryHandle);
LibraryHandle = IntPtr.Zero;
Application.Logger.Log($"Library {LibraryPath} freed successfully");
Application.CurrentApplication.Logger.Log($"Library {LibraryPath} freed successfully");
}
private IntPtr GetFunctionPointer(string functionName)
@@ -69,11 +69,11 @@ namespace CppCompatibilityModule.Extern
{
IntPtr functionPointer = GetFunctionPointer(methodName);
Application.Logger.Log($"Function pointer for {methodName} obtained successfully [address: {functionPointer}]");
Application.CurrentApplication.Logger.Log($"Function pointer for {methodName} obtained successfully [address: {functionPointer}]");
T result = (T)Marshal.GetDelegateForFunctionPointer(functionPointer, typeof(T));
Application.Logger.Log($"Delegate for {methodName} created successfully");
Application.CurrentApplication.Logger.Log($"Delegate for {methodName} created successfully");
return result;
}
@@ -82,7 +82,7 @@ namespace CppCompatibilityModule.Extern
{
IntPtr functionPointer = Marshal.GetFunctionPointerForDelegate(functionDelegate);
Application.Logger.Log($"Function pointer for delegate {functionDelegate.Method.Name} obtained successfully [address: {functionPointer}]");
Application.CurrentApplication.Logger.Log($"Function pointer for delegate {functionDelegate.Method.Name} obtained successfully [address: {functionPointer}]");
return functionPointer;
}
@@ -107,7 +107,7 @@ namespace CppCompatibilityModule.Extern
var result = setterDelegate.DynamicInvoke(executableFunctionPtr);
Application.Logger.Log($"Function {setterExternFunctionName} bound to local action successfully");
Application.CurrentApplication.Logger.Log($"Function {setterExternFunctionName} bound to local action successfully");
return result;
}
@@ -118,7 +118,7 @@ namespace CppCompatibilityModule.Extern
functionDelegate(ref parameter);
Application.Logger.Log($"Function {methodName} called successfully with parameter");
Application.CurrentApplication.Logger.Log($"Function {methodName} called successfully with parameter");
}
public void CallFunction(string methodName)
@@ -127,7 +127,7 @@ namespace CppCompatibilityModule.Extern
functionDelegate();
Application.Logger.Log($"Function {methodName} called successfully");
Application.CurrentApplication.Logger.Log($"Function {methodName} called successfully");
}
}
}

View File

@@ -47,7 +47,7 @@ public class ExternalApplication
return result.Match<ExternalApplication?>(
() => new ExternalApplication(Guid.NewGuid(), library),
(ex) => {
Application.Logger.Log(ex.Message, LogType.Error);
Application.CurrentApplication.Logger.Log(ex.Message, LogType.Error);
library.FreeLibrary();
return null;
});

View File

@@ -1,27 +1,15 @@
using DiscordBotCore;
using DiscordBotCore.Interfaces.Modules;
using DiscordBotCore.Others;
namespace CppCompatibilityModule;
public class Entry : IModule
public class ExternalApplicationHandler
{
public ModuleType ModuleType => ModuleType.Compatibility;
public string Name => "CppCompatibility";
public IDictionary<string, string> MethodMapping => new Dictionary<string, string>()
{
{"create_application", "CreateApplication"},
{"stop_application", "StopApplication"},
{"execute_function_with_parameter", "CallFunctionWithParameter"},
{"execute_function_without_parameter", "CallFunctionWithoutParameter"}
};
private ExternalApplicationManager? _ExternalApplicationManager;
public Task Initialize()
public ExternalApplicationHandler()
{
_ExternalApplicationManager = new ExternalApplicationManager();
return Task.CompletedTask;
}
public Guid CreateApplication(string dllFilePath)
@@ -29,7 +17,7 @@ public class Entry : IModule
if (_ExternalApplicationManager is null)
{
Application.Logger.Log("Failed to create application because the manager is not initialized. This should have never happened in the first place !!!", this, LogType.Critical);
Application.CurrentApplication.Logger.Log("Failed to create application because the manager is not initialized. This should have never happened in the first place !!!", this, LogType.Critical);
return Guid.Empty;
}
@@ -45,7 +33,7 @@ public class Entry : IModule
{
if (_ExternalApplicationManager is null)
{
Application.Logger.Log("Failed to stop application because the manager is not initialized. This should have never happened in the first place!!!", this, LogType.Critical);
Application.CurrentApplication.Logger.Log("Failed to stop application because the manager is not initialized. This should have never happened in the first place!!!", this, LogType.Critical);
return;
}
@@ -56,7 +44,7 @@ public class Entry : IModule
{
if (_ExternalApplicationManager is null)
{
Application.Logger.Log("Failed to call function because the manager is not initialized. This should have never happened in the first place!!!", this, LogType.Critical);
Application.CurrentApplication.Logger.Log("Failed to call function because the manager is not initialized. This should have never happened in the first place!!!", this, LogType.Critical);
return;
}
@@ -67,7 +55,7 @@ public class Entry : IModule
{
if (_ExternalApplicationManager is null)
{
Application.Logger.Log("Failed to call function because the manager is not initialized. This should have never happened in the first place!!!", this, LogType.Critical);
Application.CurrentApplication.Logger.Log("Failed to call function because the manager is not initialized. This should have never happened in the first place!!!", this, LogType.Critical);
return;
}

View File

@@ -3,7 +3,7 @@ using DiscordBotCore;
namespace CppCompatibilityModule;
public class ExternalApplicationManager
internal class ExternalApplicationManager
{
private List<ExternalApplication> _ExternalApplications;
@@ -33,14 +33,14 @@ public class ExternalApplicationManager
var application = _ExternalApplications.FirstOrDefault(app => app.ApplicationId == applicationId, null);
if(application is null)
{
Application.Logger.Log($"Couldn't find application with id {applicationId}");
Application.CurrentApplication.Logger.Log($"Couldn't find application with id {applicationId}");
return;
}
application.FreeLibrary();
_ExternalApplications.Remove(application);
Application.Logger.Log($"Application with id {applicationId} freed successfully");
Application.CurrentApplication.Logger.Log($"Application with id {applicationId} freed successfully");
}
public void ExecuteApplicationFunctionWithParameter(Guid appId, string functionName, ref object parameter)
@@ -48,7 +48,7 @@ public class ExternalApplicationManager
var application = _ExternalApplications.FirstOrDefault(app => app.ApplicationId == appId);
if(application is null)
{
Application.Logger.Log($"Couldn't find application with id {appId}");
Application.CurrentApplication.Logger.Log($"Couldn't find application with id {appId}");
return;
}
@@ -60,7 +60,7 @@ public class ExternalApplicationManager
var application = _ExternalApplications.FirstOrDefault(app => app.ApplicationId == appId);
if(application is null)
{
Application.Logger.Log($"Couldn't find application with id {appId}");
Application.CurrentApplication.Logger.Log($"Couldn't find application with id {appId}");
return;
}