aboutsummaryrefslogtreecommitdiffstats
path: root/src/sdk
diff options
context:
space:
mode:
Diffstat (limited to 'src/sdk')
-rw-r--r--src/sdk/CMakeLists.txt61
-rw-r--r--src/sdk/GFSDK.h44
-rw-r--r--src/sdk/GFSDKBasic.cpp106
-rw-r--r--src/sdk/GFSDKBasic.h107
-rw-r--r--src/sdk/GFSDKBuildInfo.h36
-rw-r--r--src/sdk/GFSDKBuildInfo.h.in36
-rw-r--r--src/sdk/GFSDKExport.h42
-rw-r--r--src/sdk/GFSDKExtra.cpp42
-rw-r--r--src/sdk/GFSDKExtra.h39
-rw-r--r--src/sdk/GFSDKGpg.cpp27
-rw-r--r--src/sdk/GFSDKGpg.h33
-rw-r--r--src/sdk/GFSDKLog.cpp47
-rw-r--r--src/sdk/GFSDKLog.h44
-rw-r--r--src/sdk/GFSDKModule.cpp98
-rw-r--r--src/sdk/GFSDKModule.h94
-rw-r--r--src/sdk/GFSDKUI.cpp27
-rw-r--r--src/sdk/GFSDKUI.h29
-rw-r--r--src/sdk/GFSDKUtils.cpp29
-rw-r--r--src/sdk/GFSDKUtils.h34
19 files changed, 975 insertions, 0 deletions
diff --git a/src/sdk/CMakeLists.txt b/src/sdk/CMakeLists.txt
new file mode 100644
index 00000000..c8a10e7d
--- /dev/null
+++ b/src/sdk/CMakeLists.txt
@@ -0,0 +1,61 @@
+# Copyright (C) 2021 Saturneric <[email protected]>
+#
+# This file is part of GpgFrontend.
+#
+# GpgFrontend is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# GpgFrontend is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+#
+# The initial version of the source code is inherited from
+# the gpg4usb project, which is under GPL-3.0-or-later.
+#
+# All the source code of GpgFrontend was modified and released by
+# Saturneric <[email protected]> starting on May 12, 2021.
+#
+# SPDX-License-Identifier: GPL-3.0-or-later
+
+set(CMAKE_CXX_VISIBILITY_PRESET hidden)
+set(CMAKE_VISIBILITY_INLINES_HIDDEN 1)
+
+# define libgpgfrontend_module_sdk
+aux_source_directory(. MODULE_SDK_SOURCE)
+
+add_library(gpgfrontend_module_sdk SHARED ${MODULE_SDK_SOURCE})
+set(_export_file_sdk "${CMAKE_CURRENT_SOURCE_DIR}/GFSDKExport.h")
+generate_export_header(gpgfrontend_module_sdk EXPORT_FILE_NAME "${_export_file_sdk}")
+target_include_directories(gpgfrontend_module_sdk PRIVATE
+ ${CMAKE_CURRENT_BINARY_DIR}/gpgfrontend_module_sdk_autogen/include
+ ${CMAKE_SOURCE_DIR}/third_party/spdlog/include)
+
+target_include_directories(gpgfrontend_module_sdk PUBLIC sdk)
+
+# link module system
+target_link_libraries(gpgfrontend_module_sdk PRIVATE gpgfrontend_core)
+
+# sdk export headers
+file(GLOB _headerPath "${CMAKE_CURRENT_SOURCE_DIR}/*.h")
+set_target_properties(gpgfrontend_module_sdk PROPERTIES PUBLIC_HEADER "${_headerPath}")
+
+# lib output path
+set_target_properties(gpgfrontend_module_sdk PROPERTIES
+ LIBRARY_OUTPUT_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/lib
+ RUNTIME_OUTPUT_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/lib)
+
+if (XCODE_BUILD)
+ set_target_properties(gpgfrontend_module_sdk
+ PROPERTIES
+ ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE}
+ LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE}
+ LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE}
+ XCODE_ATTRIBUTE_SKIP_INSTALL "Yes"
+ XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "${GPGFRONTEND_XOCDE_CODE_SIGN_IDENTITY}")
+endif () \ No newline at end of file
diff --git a/src/sdk/GFSDK.h b/src/sdk/GFSDK.h
new file mode 100644
index 00000000..77e019af
--- /dev/null
+++ b/src/sdk/GFSDK.h
@@ -0,0 +1,44 @@
+/**
+ * Copyright (C) 2021 Saturneric <[email protected]>
+ *
+ * This file is part of GpgFrontend.
+ *
+ * GpgFrontend is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GpgFrontend is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
+ *
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric <[email protected]> starting on May 12, 2021.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ *
+ */
+
+#pragma once
+
+#include "GFSDKExport.h"
+
+extern "C" {
+
+void GPGFRONTEND_MODULE_SDK_EXPORT GFModuleLogTrace(const char*);
+
+void GPGFRONTEND_MODULE_SDK_EXPORT GFModuleLogDebug(const char*);
+
+void GPGFRONTEND_MODULE_SDK_EXPORT GFModuleLogInfo(const char*);
+
+void GPGFRONTEND_MODULE_SDK_EXPORT GFModuleLogWarn(const char*);
+
+void GPGFRONTEND_MODULE_SDK_EXPORT GFModuleLogError(const char*);
+} \ No newline at end of file
diff --git a/src/sdk/GFSDKBasic.cpp b/src/sdk/GFSDKBasic.cpp
new file mode 100644
index 00000000..4d8af6c8
--- /dev/null
+++ b/src/sdk/GFSDKBasic.cpp
@@ -0,0 +1,106 @@
+/**
+ * Copyright (C) 2021 Saturneric <[email protected]>
+ *
+ * This file is part of GpgFrontend.
+ *
+ * GpgFrontend is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GpgFrontend is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
+ *
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric <[email protected]> starting on May 12, 2021.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ *
+ */
+
+#include "GFSDKBasic.h"
+
+#include "core/function/SecureMemoryAllocator.h"
+#include "core/function/gpg/GpgCommandExecutor.h"
+#include "core/utils/BuildInfoUtils.h"
+#include "core/utils/CommonUtils.h"
+
+auto GFAllocateMemory(uint32_t size) -> void* {
+ return GpgFrontend::SecureMemoryAllocator::Allocate(size);
+}
+
+void GFFreeMemory(void* ptr) {
+ return GpgFrontend::SecureMemoryAllocator::Deallocate(ptr);
+}
+
+auto GFProjectVersion() -> const char* {
+ return GpgFrontend::GFStrDup(GpgFrontend::GetProjectVersion());
+}
+
+auto GFQtEnvVersion() -> const char* {
+ return GpgFrontend::GFStrDup(QT_VERSION_STR);
+}
+
+void GFExecuteCommandSync(const char* cmd, int32_t argc, const char** argv,
+ GFCommandExeucteCallback cb, void* data) {
+ QStringList args;
+ for (int i = 0; i < argc; i++) {
+ args.append(GpgFrontend::GFUnStrDup(argv[i]));
+ }
+
+ GpgFrontend::GpgCommandExecutor::ExecuteContext const 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 GFExecuteCommandBatchSync(int32_t context_size,
+ const GFCommandExecuteContext* context) {
+ QList<GpgFrontend::GpgCommandExecutor::ExecuteContext> contexts;
+
+ for (int i = 0; i < context_size; i++) {
+ const auto& exec_context = context[i];
+
+ QStringList args;
+ const char** argv = exec_context.argv;
+ for (int j = 0; j < exec_context.argc; j++) {
+ args.append(GpgFrontend::GFUnStrDup(argv[j]));
+ }
+
+ 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);
+}
+
+auto StrlenSafe(const char* str, size_t max_len) -> size_t {
+ const char* end = static_cast<const char*>(memchr(str, '\0', max_len));
+ if (end == nullptr) return max_len;
+ return end - str;
+}
+
+auto GPGFRONTEND_MODULE_SDK_EXPORT GFModuleStrDup(const char* src) -> char* {
+ auto len = StrlenSafe(src, kGfStrlenMax);
+ if (len > kGfStrlenMax) return nullptr;
+
+ char* dst = static_cast<char*>(GFAllocateMemory((len + 1) * sizeof(char)));
+ memcpy(dst, src, len);
+ dst[len] = '\0';
+
+ return dst;
+} \ No newline at end of file
diff --git a/src/sdk/GFSDKBasic.h b/src/sdk/GFSDKBasic.h
new file mode 100644
index 00000000..07ff6ed7
--- /dev/null
+++ b/src/sdk/GFSDKBasic.h
@@ -0,0 +1,107 @@
+/**
+ * Copyright (C) 2021 Saturneric <[email protected]>
+ *
+ * This file is part of GpgFrontend.
+ *
+ * GpgFrontend is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GpgFrontend is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
+ *
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric <[email protected]> starting on May 12, 2021.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ *
+ */
+
+#pragma once
+
+#include <cstddef>
+#include <cstdint>
+
+#include "GFSDKExport.h"
+
+extern "C" {
+
+constexpr int32_t kGfStrlenMax = static_cast<const int32_t>(1024 * 8);
+
+using GFCommandExeucteCallback = void (*)(void* data, int errcode,
+ const char* out, const char* err);
+
+using GFCommandExecuteContext = struct {
+ const char* cmd;
+ int32_t argc;
+ const char** argv;
+ GFCommandExeucteCallback cb;
+ void* data;
+};
+
+/**
+ * @brief
+ *
+ * @param size
+ * @return void*
+ */
+auto GPGFRONTEND_MODULE_SDK_EXPORT GFAllocateMemory(uint32_t size) -> void*;
+
+/**
+ * @brief
+ *
+ * @return const char*
+ */
+auto GPGFRONTEND_MODULE_SDK_EXPORT GFProjectVersion() -> const char*;
+
+/**
+ * @brief
+ *
+ * @return const char*
+ */
+auto GPGFRONTEND_MODULE_SDK_EXPORT GFQtEnvVersion() -> const char*;
+
+/**
+ * @brief
+ *
+ */
+void GPGFRONTEND_MODULE_SDK_EXPORT GFFreeMemory(void*);
+
+/**
+ * @brief
+ *
+ * @param cmd
+ * @param argc
+ * @param argv
+ * @param cb
+ * @param data
+ */
+void GPGFRONTEND_MODULE_SDK_EXPORT
+GFExecuteCommandSync(const char* cmd, int32_t argc, const char** argv,
+ GFCommandExeucteCallback cb, void* data);
+
+/**
+ * @brief
+ *
+ * @param context_size
+ * @param context
+ */
+void GPGFRONTEND_MODULE_SDK_EXPORT GFExecuteCommandBatchSync(
+ int32_t context_size, const GFCommandExecuteContext* context);
+
+/**
+ * @brief
+ *
+ * @return char*
+ */
+auto GPGFRONTEND_MODULE_SDK_EXPORT GFModuleStrDup(const char*) -> char*;
+} \ No newline at end of file
diff --git a/src/sdk/GFSDKBuildInfo.h b/src/sdk/GFSDKBuildInfo.h
new file mode 100644
index 00000000..a64d95c5
--- /dev/null
+++ b/src/sdk/GFSDKBuildInfo.h
@@ -0,0 +1,36 @@
+/**
+ * Copyright (C) 2021 Saturneric <[email protected]>
+ *
+ * This file is part of GpgFrontend.
+ *
+ * GpgFrontend is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GpgFrontend is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
+ *
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric <[email protected]> starting on May 12, 2021.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ *
+ */
+
+#pragma once
+
+#define GF_SDK_VERSION_MAJOR "2"
+#define GF_SDK_VERSION_MINOR "1"
+#define GF_SDK_VERSION_PATCH "3"
+
+#define GF_SDK_VERSION_STR \
+ GF_SDK_VERSION_MAJOR "." GF_SDK_VERSION_MINOR "." GF_SDK_VERSION_PATCH
diff --git a/src/sdk/GFSDKBuildInfo.h.in b/src/sdk/GFSDKBuildInfo.h.in
new file mode 100644
index 00000000..508c35d4
--- /dev/null
+++ b/src/sdk/GFSDKBuildInfo.h.in
@@ -0,0 +1,36 @@
+/**
+ * Copyright (C) 2021 Saturneric <[email protected]>
+ *
+ * This file is part of GpgFrontend.
+ *
+ * GpgFrontend is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GpgFrontend is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
+ *
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric <[email protected]> starting on May 12, 2021.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ *
+ */
+
+#pragma once
+
+#define GF_SDK_VERSION_MAJOR "@CMAKE_PROJECT_VERSION_MAJOR@"
+#define GF_SDK_VERSION_MINOR "@CMAKE_PROJECT_VERSION_MINOR@"
+#define GF_SDK_VERSION_PATCH "@CMAKE_PROJECT_VERSION_PATCH@"
+
+#define GF_SDK_VERSION_STR \
+ GF_SDK_VERSION_MAJOR "." GF_SDK_VERSION_MINOR "." GF_SDK_VERSION_PATCH \ No newline at end of file
diff --git a/src/sdk/GFSDKExport.h b/src/sdk/GFSDKExport.h
new file mode 100644
index 00000000..a62168bc
--- /dev/null
+++ b/src/sdk/GFSDKExport.h
@@ -0,0 +1,42 @@
+
+#ifndef GPGFRONTEND_MODULE_SDK_EXPORT_H
+#define GPGFRONTEND_MODULE_SDK_EXPORT_H
+
+#ifdef GPGFRONTEND_MODULE_SDK_STATIC_DEFINE
+# define GPGFRONTEND_MODULE_SDK_EXPORT
+# define GPGFRONTEND_MODULE_SDK_NO_EXPORT
+#else
+# ifndef GPGFRONTEND_MODULE_SDK_EXPORT
+# ifdef gpgfrontend_module_sdk_EXPORTS
+ /* We are building this library */
+# define GPGFRONTEND_MODULE_SDK_EXPORT __attribute__((visibility("default")))
+# else
+ /* We are using this library */
+# define GPGFRONTEND_MODULE_SDK_EXPORT __attribute__((visibility("default")))
+# endif
+# endif
+
+# ifndef GPGFRONTEND_MODULE_SDK_NO_EXPORT
+# define GPGFRONTEND_MODULE_SDK_NO_EXPORT __attribute__((visibility("hidden")))
+# endif
+#endif
+
+#ifndef GPGFRONTEND_MODULE_SDK_DEPRECATED
+# define GPGFRONTEND_MODULE_SDK_DEPRECATED __attribute__ ((__deprecated__))
+#endif
+
+#ifndef GPGFRONTEND_MODULE_SDK_DEPRECATED_EXPORT
+# define GPGFRONTEND_MODULE_SDK_DEPRECATED_EXPORT GPGFRONTEND_MODULE_SDK_EXPORT GPGFRONTEND_MODULE_SDK_DEPRECATED
+#endif
+
+#ifndef GPGFRONTEND_MODULE_SDK_DEPRECATED_NO_EXPORT
+# define GPGFRONTEND_MODULE_SDK_DEPRECATED_NO_EXPORT GPGFRONTEND_MODULE_SDK_NO_EXPORT GPGFRONTEND_MODULE_SDK_DEPRECATED
+#endif
+
+#if 0 /* DEFINE_NO_DEPRECATED */
+# ifndef GPGFRONTEND_MODULE_SDK_NO_DEPRECATED
+# define GPGFRONTEND_MODULE_SDK_NO_DEPRECATED
+# endif
+#endif
+
+#endif /* GPGFRONTEND_MODULE_SDK_EXPORT_H */
diff --git a/src/sdk/GFSDKExtra.cpp b/src/sdk/GFSDKExtra.cpp
new file mode 100644
index 00000000..bbfa8575
--- /dev/null
+++ b/src/sdk/GFSDKExtra.cpp
@@ -0,0 +1,42 @@
+/**
+ * Copyright (C) 2021 Saturneric <[email protected]>
+ *
+ * This file is part of GpgFrontend.
+ *
+ * GpgFrontend is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GpgFrontend is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
+ *
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric <[email protected]> starting on May 12, 2021.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ *
+ */
+
+#include "GFSDKExtra.h"
+
+#include "core/utils/BuildInfoUtils.h"
+#include "core/utils/CommonUtils.h"
+
+auto GFCompareSoftwareVersion(const char *current_version,
+ const char *latest_version) -> int {
+ return GpgFrontend::GFCompareSoftwareVersion(
+ GpgFrontend::GFUnStrDup(current_version),
+ GpgFrontend::GFUnStrDup(latest_version));
+}
+auto GFHttpRequestUserAgent() -> const char * {
+ return GpgFrontend::GFStrDup(GpgFrontend::GetHttpRequestUserAgent());
+} \ No newline at end of file
diff --git a/src/sdk/GFSDKExtra.h b/src/sdk/GFSDKExtra.h
new file mode 100644
index 00000000..3d7f4226
--- /dev/null
+++ b/src/sdk/GFSDKExtra.h
@@ -0,0 +1,39 @@
+/**
+ * Copyright (C) 2021 Saturneric <[email protected]>
+ *
+ * This file is part of GpgFrontend.
+ *
+ * GpgFrontend is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GpgFrontend is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
+ *
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric <[email protected]> starting on May 12, 2021.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ *
+ */
+
+#pragma once
+
+#include "GFSDKExport.h"
+
+extern "C" {
+
+auto GPGFRONTEND_MODULE_SDK_EXPORT GFCompareSoftwareVersion(
+ const char *current_version, const char *latest_version) -> int;
+
+auto GPGFRONTEND_MODULE_SDK_EXPORT GFHttpRequestUserAgent() -> const char *;
+} \ No newline at end of file
diff --git a/src/sdk/GFSDKGpg.cpp b/src/sdk/GFSDKGpg.cpp
new file mode 100644
index 00000000..63859763
--- /dev/null
+++ b/src/sdk/GFSDKGpg.cpp
@@ -0,0 +1,27 @@
+/**
+ * Copyright (C) 2021 Saturneric <[email protected]>
+ *
+ * This file is part of GpgFrontend.
+ *
+ * GpgFrontend is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GpgFrontend is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
+ *
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric <[email protected]> starting on May 12, 2021.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ *
+ */ \ No newline at end of file
diff --git a/src/sdk/GFSDKGpg.h b/src/sdk/GFSDKGpg.h
new file mode 100644
index 00000000..8823bfc5
--- /dev/null
+++ b/src/sdk/GFSDKGpg.h
@@ -0,0 +1,33 @@
+/**
+ * Copyright (C) 2021 Saturneric <[email protected]>
+ *
+ * This file is part of GpgFrontend.
+ *
+ * GpgFrontend is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GpgFrontend is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
+ *
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric <[email protected]> starting on May 12, 2021.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ *
+ */
+
+#pragma once
+
+extern "C" {
+
+} \ No newline at end of file
diff --git a/src/sdk/GFSDKLog.cpp b/src/sdk/GFSDKLog.cpp
new file mode 100644
index 00000000..603cc325
--- /dev/null
+++ b/src/sdk/GFSDKLog.cpp
@@ -0,0 +1,47 @@
+/**
+ * Copyright (C) 2021 Saturneric <[email protected]>
+ *
+ * This file is part of GpgFrontend.
+ *
+ * GpgFrontend is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GpgFrontend is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
+ *
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric <[email protected]> starting on May 12, 2021.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ *
+ */
+
+#include "GFSDKLog.h"
+
+#include "core/utils/LogUtils.h"
+
+#define MODULE_LOG_TRACE(...) GF_LOG_TRACE("module", __VA_ARGS__)
+#define MODULE_LOG_DEBUG(...) GF_LOG_DEBUG("module", __VA_ARGS__)
+#define MODULE_LOG_INFO(...) GF_LOG_INFO("module", __VA_ARGS__)
+#define MODULE_LOG_WARN(...) GF_LOG_WARN("module", __VA_ARGS__)
+#define MODULE_LOG_ERROR(...) GF_LOG_ERROR("module", __VA_ARGS__)
+
+void GFModuleLogTrace(const char* l) { MODULE_LOG_TRACE(l); }
+
+void GFModuleLogDebug(const char* l) { MODULE_LOG_DEBUG(l); }
+
+void GFModuleLogInfo(const char* l) { MODULE_LOG_INFO(l); }
+
+void GFModuleLogWarn(const char* l) { MODULE_LOG_WARN(l); }
+
+void GFModuleLogError(const char* l) { MODULE_LOG_ERROR(l); }
diff --git a/src/sdk/GFSDKLog.h b/src/sdk/GFSDKLog.h
new file mode 100644
index 00000000..77e019af
--- /dev/null
+++ b/src/sdk/GFSDKLog.h
@@ -0,0 +1,44 @@
+/**
+ * Copyright (C) 2021 Saturneric <[email protected]>
+ *
+ * This file is part of GpgFrontend.
+ *
+ * GpgFrontend is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GpgFrontend is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
+ *
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric <[email protected]> starting on May 12, 2021.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ *
+ */
+
+#pragma once
+
+#include "GFSDKExport.h"
+
+extern "C" {
+
+void GPGFRONTEND_MODULE_SDK_EXPORT GFModuleLogTrace(const char*);
+
+void GPGFRONTEND_MODULE_SDK_EXPORT GFModuleLogDebug(const char*);
+
+void GPGFRONTEND_MODULE_SDK_EXPORT GFModuleLogInfo(const char*);
+
+void GPGFRONTEND_MODULE_SDK_EXPORT GFModuleLogWarn(const char*);
+
+void GPGFRONTEND_MODULE_SDK_EXPORT GFModuleLogError(const char*);
+} \ No newline at end of file
diff --git a/src/sdk/GFSDKModule.cpp b/src/sdk/GFSDKModule.cpp
new file mode 100644
index 00000000..00594488
--- /dev/null
+++ b/src/sdk/GFSDKModule.cpp
@@ -0,0 +1,98 @@
+/**
+ * Copyright (C) 2021 Saturneric <[email protected]>
+ *
+ * This file is part of GpgFrontend.
+ *
+ * GpgFrontend is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GpgFrontend is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
+ *
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric <[email protected]> starting on May 12, 2021.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ *
+ */
+
+#include "GFSDKModule.h"
+
+#include <core/module/ModuleManager.h>
+#include <core/utils/CommonUtils.h>
+
+#include "GFSDKBasic.h"
+
+void GFModuleListenEvent(const char *module_id, const char *event_id) {
+ return GpgFrontend::Module::ModuleManager::GetInstance().ListenEvent(
+ GpgFrontend::GFUnStrDup(module_id).toLower(),
+ GpgFrontend::GFUnStrDup(event_id).toUpper());
+}
+
+auto GFModuleRetrieveRTValueOrDefault(const char *namespace_, const char *key,
+ const char *default_value) -> const
+ char * {
+ return GpgFrontend::GFStrDup(
+ GpgFrontend::Module::RetrieveRTValueTypedOrDefault(
+ GpgFrontend::GFUnStrDup(namespace_), GpgFrontend::GFUnStrDup(key),
+ GpgFrontend::GFUnStrDup(default_value)));
+}
+
+void GFModuleUpsertRTValue(const char *namespace_, const char *key,
+ const char *vaule) {
+ GpgFrontend::Module::UpsertRTValue(
+ GpgFrontend::GFUnStrDup(namespace_).toLower(),
+ GpgFrontend::GFUnStrDup(key).toLower(), GpgFrontend::GFUnStrDup(vaule));
+}
+
+void GFModuleUpsertRTValueBool(const char *namespace_, const char *key,
+ int value) {
+ GpgFrontend::Module::UpsertRTValue(
+ GpgFrontend::GFUnStrDup(namespace_).toLower(),
+ GpgFrontend::GFUnStrDup(key).toLower(), value != 0);
+}
+
+auto GFModuleListRTChildKeys(const char *namespace_, const char *key,
+ char ***child_keys) -> int32_t {
+ *child_keys = nullptr;
+ auto keys = GpgFrontend::Module::ListRTChildKeys(
+ GpgFrontend::GFUnStrDup(namespace_).toLower(),
+ GpgFrontend::GFUnStrDup(key).toLower());
+
+ if (keys.empty()) return 0;
+
+ *child_keys =
+ static_cast<char **>(GFAllocateMemory(sizeof(char **) * keys.size()));
+
+ for (int i = 0; i < keys.size(); i++) {
+ (*child_keys)[i] = GpgFrontend::GFStrDup(keys[i]);
+ }
+
+ return static_cast<int32_t>(keys.size());
+}
+
+void GFModuleTriggerModuleEventCallback(GFModuleEvent *module_event,
+ const char *module_id, int argc,
+ char **argv) {
+ auto data_object = GpgFrontend::TransferParams();
+ for (int i = 0; i < argc; i++) {
+ data_object->AppendObject(GpgFrontend::GFUnStrDup(argv[i]));
+ }
+
+ auto event = GpgFrontend::Module::ModuleManager::GetInstance().SearchEvent(
+ GpgFrontend::GFUnStrDup(module_event->trigger_id).toLower());
+ if (!event) return;
+
+ event.value()->ExecuteCallback(GpgFrontend::GFUnStrDup(module_id),
+ data_object);
+} \ No newline at end of file
diff --git a/src/sdk/GFSDKModule.h b/src/sdk/GFSDKModule.h
new file mode 100644
index 00000000..67c1f492
--- /dev/null
+++ b/src/sdk/GFSDKModule.h
@@ -0,0 +1,94 @@
+/**
+ * Copyright (C) 2021 Saturneric <[email protected]>
+ *
+ * This file is part of GpgFrontend.
+ *
+ * GpgFrontend is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GpgFrontend is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
+ *
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric <[email protected]> starting on May 12, 2021.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ *
+ */
+
+#pragma once
+
+#include "GFSDKExport.h"
+
+extern "C" {
+
+#include <stdint.h>
+
+struct GFModuleMetaData {
+ const char *key;
+ const char *value;
+ GFModuleMetaData *next;
+};
+
+struct GFModuleEventParam {
+ const char *name;
+ const char *value;
+ GFModuleEventParam *next;
+};
+
+struct GFModuleEvent {
+ const char *id;
+ const char *trigger_id;
+ GFModuleEventParam *params;
+};
+
+using GFModuleAPIGetModuleGFSDKVersion = auto (*)() -> const char *;
+
+using GFModuleAPIGetModuleQtEnvVersion = auto (*)() -> const char *;
+
+using GFModuleAPIGetModuleID = auto (*)() -> const char *;
+
+using GFModuleAPIGetModuleVersion = auto (*)() -> const char *;
+
+using GFModuleAPIGetModuleMetaData = auto (*)() -> GFModuleMetaData *;
+
+using GFModuleAPIRegisterModule = auto (*)() -> int;
+
+using GFModuleAPIActivateModule = auto (*)() -> int;
+
+using GFModuleAPIExecuteModule = auto (*)(GFModuleEvent *) -> int;
+
+using GFModuleAPIDeactivateModule = auto (*)() -> int;
+
+using GFModuleAPIUnregisterModule = auto (*)() -> int;
+
+void GPGFRONTEND_MODULE_SDK_EXPORT GFModuleListenEvent(const char *module_id,
+ const char *event_id);
+
+auto GPGFRONTEND_MODULE_SDK_EXPORT GFModuleRetrieveRTValueOrDefault(
+ const char *namespace_, const char *key, const char *default_value) -> const
+ char *;
+
+void GPGFRONTEND_MODULE_SDK_EXPORT GFModuleUpsertRTValue(const char *namespace_,
+ const char *key,
+ const char *vaule);
+
+void GPGFRONTEND_MODULE_SDK_EXPORT
+GFModuleUpsertRTValueBool(const char *namespace_, const char *key, int value);
+
+auto GPGFRONTEND_MODULE_SDK_EXPORT GFModuleListRTChildKeys(
+ const char *namespace_, const char *key, char ***child_keys) -> int32_t;
+
+void GPGFRONTEND_MODULE_SDK_EXPORT GFModuleTriggerModuleEventCallback(
+ GFModuleEvent *event, const char *module_id, int argc, char **argv);
+}; \ No newline at end of file
diff --git a/src/sdk/GFSDKUI.cpp b/src/sdk/GFSDKUI.cpp
new file mode 100644
index 00000000..63859763
--- /dev/null
+++ b/src/sdk/GFSDKUI.cpp
@@ -0,0 +1,27 @@
+/**
+ * Copyright (C) 2021 Saturneric <[email protected]>
+ *
+ * This file is part of GpgFrontend.
+ *
+ * GpgFrontend is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GpgFrontend is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
+ *
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric <[email protected]> starting on May 12, 2021.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ *
+ */ \ No newline at end of file
diff --git a/src/sdk/GFSDKUI.h b/src/sdk/GFSDKUI.h
new file mode 100644
index 00000000..0702632a
--- /dev/null
+++ b/src/sdk/GFSDKUI.h
@@ -0,0 +1,29 @@
+/**
+ * Copyright (C) 2021 Saturneric <[email protected]>
+ *
+ * This file is part of GpgFrontend.
+ *
+ * GpgFrontend is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GpgFrontend is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
+ *
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric <[email protected]> starting on May 12, 2021.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ *
+ */
+
+#pragma once \ No newline at end of file
diff --git a/src/sdk/GFSDKUtils.cpp b/src/sdk/GFSDKUtils.cpp
new file mode 100644
index 00000000..fcb510e3
--- /dev/null
+++ b/src/sdk/GFSDKUtils.cpp
@@ -0,0 +1,29 @@
+/**
+ * Copyright (C) 2021 Saturneric <[email protected]>
+ *
+ * This file is part of GpgFrontend.
+ *
+ * GpgFrontend is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GpgFrontend is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
+ *
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric <[email protected]> starting on May 12, 2021.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ *
+ */
+
+#include "GFSDKUtils.h" \ No newline at end of file
diff --git a/src/sdk/GFSDKUtils.h b/src/sdk/GFSDKUtils.h
new file mode 100644
index 00000000..7d72e9ee
--- /dev/null
+++ b/src/sdk/GFSDKUtils.h
@@ -0,0 +1,34 @@
+/**
+ * Copyright (C) 2021 Saturneric <[email protected]>
+ *
+ * This file is part of GpgFrontend.
+ *
+ * GpgFrontend is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GpgFrontend is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
+ *
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric <[email protected]> starting on May 12, 2021.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ *
+ */
+
+#pragma once
+
+extern "C" {
+
+
+} \ No newline at end of file