aboutsummaryrefslogtreecommitdiffstats
path: root/src/module/sdk/Basic.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/module/sdk/Basic.cpp')
-rw-r--r--src/module/sdk/Basic.cpp50
1 files changed, 49 insertions, 1 deletions
diff --git a/src/module/sdk/Basic.cpp b/src/module/sdk/Basic.cpp
index 63859763..35ce8054 100644
--- a/src/module/sdk/Basic.cpp
+++ b/src/module/sdk/Basic.cpp
@@ -24,4 +24,52 @@
*
* SPDX-License-Identifier: GPL-3.0-or-later
*
- */ \ No newline at end of file
+ */
+
+#include "Basic.h"
+
+#include "core/function/SecureMemoryAllocator.h"
+#include "core/function/gpg/GpgCommandExecutor.h"
+
+auto AllocateMemory(uint32_t size) -> void* {
+ return GpgFrontend::SecureMemoryAllocator::Allocate(size);
+}
+
+void FreeMemory(void* ptr) {
+ return GpgFrontend::SecureMemoryAllocator::Deallocate(ptr);
+}
+
+void ExecuteCommandSync(const char* cmd, int32_t argc, const char** argv,
+ CommandExeucteCallback cb, void* data) {
+ QStringList args;
+ for (int i = 0; i < argc; i++) {
+ args.append(QString::fromUtf8(argv[i]));
+ }
+
+ GpgFrontend::GpgCommandExecutor::ExecuteContext context{
+ cmd, args, [=](int exit_code, const QString& out, const QString& err) {
+ cb(data, exit_code, out.toUtf8(), err.toUtf8());
+ }};
+
+ GpgFrontend::GpgCommandExecutor::ExecuteSync(context);
+}
+
+void ExecuteCommandBatchSync(int32_t context_size,
+ const CommandExecuteContext* context) {
+ QList<GpgFrontend::GpgCommandExecutor::ExecuteContext> contexts;
+ for (int i = 0; i < context_size; i++) {
+ auto exec_context = context[i];
+ QStringList args;
+ for (int i = 0; i < exec_context.argc; i++) {
+ args.append(QString::fromUtf8(exec_context.argv[i]));
+ }
+ contexts.append(
+ {exec_context.cmd, args,
+ [data = exec_context.data, cb = exec_context.cb](
+ int exit_code, const QString& out, const QString& err) {
+ cb(data, exit_code, out.toUtf8(), err.toUtf8());
+ }});
+ }
+
+ GpgFrontend::GpgCommandExecutor::ExecuteConcurrentlySync(contexts);
+} \ No newline at end of file