diff options
37 files changed, 282 insertions, 178 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 3e6ec8cb..92856c45 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -454,7 +454,7 @@ endif () # link options for GpgFrontend if (BUILD_APPLICATION) - target_link_libraries(${AppName} gpgfrontend_ui gpgfrontend_module gpgfrontend_test) + target_link_libraries(${AppName} gpgfrontend_ui gpgfrontend_test) if (MINGW) message(STATUS "Link Application Library For MINGW") target_link_libraries(${AppName} crypto) @@ -536,9 +536,7 @@ if (LINUX AND LINUX_INSTALL_SOFTWARE) gpgfrontend_core gpgfrontend_ui gpgfrontend_test - gpgfrontend_pinentry - gpgfrontend_module_sdk - gpgfrontend_module) + gpgfrontend_pinentry) message(STATUS "GpgFrontend Install Libraries: ${GPGFRONTEND_INSTALL_LIBRARIES}") install(TARGETS ${AppName} ${GPGFRONTEND_INSTALL_LIBRARIES} diff --git a/src/app.cpp b/src/app.cpp index a5539a37..9aa72894 100644 --- a/src/app.cpp +++ b/src/app.cpp @@ -29,7 +29,7 @@ #include "GpgFrontendContext.h" #include "core/GpgConstants.h" #include "core/GpgCoreInit.h" -#include "module/GpgFrontendModuleInit.h" +#include "core/module/ModuleInit.h" #include "ui/GpgFrontendUIInit.h" // main diff --git a/src/core/GpgCoreInit.h b/src/core/GpgCoreInit.h index 15f0254d..ecd6afea 100644 --- a/src/core/GpgCoreInit.h +++ b/src/core/GpgCoreInit.h @@ -28,7 +28,7 @@ #pragma once -#include "GpgConstants.h" +#include "core/GpgFrontendCoreExport.h" namespace GpgFrontend { diff --git a/src/core/GpgFrontendCore.h b/src/core/GpgFrontendCore.h index 14b1f878..f07824cf 100644 --- a/src/core/GpgFrontendCore.h +++ b/src/core/GpgFrontendCore.h @@ -30,23 +30,3 @@ // Qt #include <QtCore> - -// std -#include <cstdint> -#include <vector> - -// spdlog library configuration -#define SPDLOG_ACTIVE_LEVEL SPDLOG_LEVEL_TRACE -#include <spdlog/spdlog.h> - -// logger fmt -#include "log/QtLoggerFmt.h" - -// gpgme library -#include <gpgme.h> - -// logbal includes or macroes -#include "GpgFrontend.h" - -// dll export macroes -#include "GpgFrontendCoreExport.h" diff --git a/src/core/function/CoreSignalStation.h b/src/core/function/CoreSignalStation.h index e0a11fa3..8827c803 100644 --- a/src/core/function/CoreSignalStation.h +++ b/src/core/function/CoreSignalStation.h @@ -28,7 +28,7 @@ #pragma once -#include "core/GpgFrontendCore.h" +#include "core/GpgFrontendCoreExport.h" namespace GpgFrontend { diff --git a/src/core/function/SecureMemoryAllocator.h b/src/core/function/SecureMemoryAllocator.h index e9f1c1c3..e86d54d6 100644 --- a/src/core/function/SecureMemoryAllocator.h +++ b/src/core/function/SecureMemoryAllocator.h @@ -28,9 +28,7 @@ #pragma once -#include <cstdint> -#include <memory> - +#include "core/GpgFrontendCoreExport.h" #include "core/utils/LogUtils.h" namespace GpgFrontend { diff --git a/src/core/function/gpg/GpgContext.h b/src/core/function/gpg/GpgContext.h index d473a341..2a8f6fdd 100644 --- a/src/core/function/gpg/GpgContext.h +++ b/src/core/function/gpg/GpgContext.h @@ -28,6 +28,8 @@ #pragma once +#include <gpgme.h> + #include "core/function/SecureMemoryAllocator.h" #include "core/function/basic/GpgFunctionObject.h" diff --git a/src/core/model/GpgData.h b/src/core/model/GpgData.h index 358ebd19..eb1d7621 100644 --- a/src/core/model/GpgData.h +++ b/src/core/model/GpgData.h @@ -28,6 +28,8 @@ #pragma once +#include <gpgme.h> + #include "core/GpgFrontendCoreExport.h" #include "core/model/GFBuffer.h" #include "core/typedef/CoreTypedef.h" diff --git a/src/core/model/GpgGenKeyInfo.h b/src/core/model/GpgGenKeyInfo.h index 166c6b0f..65a7d03e 100644 --- a/src/core/model/GpgGenKeyInfo.h +++ b/src/core/model/GpgGenKeyInfo.h @@ -28,6 +28,8 @@ #pragma once +#include "core/GpgFrontendCoreExport.h" + namespace GpgFrontend { class GPGFRONTEND_CORE_EXPORT GenKeyInfo { diff --git a/src/core/model/GpgGenerateKeyResult.h b/src/core/model/GpgGenerateKeyResult.h index f312d415..dfd92ae1 100644 --- a/src/core/model/GpgGenerateKeyResult.h +++ b/src/core/model/GpgGenerateKeyResult.h @@ -28,6 +28,8 @@ #pragma once +#include <gpgme.h> + #include "core/GpgFrontendCore.h" #include "core/GpgFrontendCoreExport.h" diff --git a/src/core/model/GpgImportInformation.h b/src/core/model/GpgImportInformation.h index 5f85a338..cbe5a265 100644 --- a/src/core/model/GpgImportInformation.h +++ b/src/core/model/GpgImportInformation.h @@ -28,6 +28,10 @@ #pragma once +#include <gpgme.h> + +#include "core/GpgFrontendCoreExport.h" + namespace GpgFrontend { /** diff --git a/src/core/model/GpgPassphraseContext.cpp b/src/core/model/GpgPassphraseContext.cpp index 5df3f5a8..0156c04d 100644 --- a/src/core/model/GpgPassphraseContext.cpp +++ b/src/core/model/GpgPassphraseContext.cpp @@ -28,6 +28,7 @@ #include "GpgPassphraseContext.h" + namespace GpgFrontend { GpgPassphraseContext::GpgPassphraseContext(const QString& uids_info, diff --git a/src/core/model/GpgPassphraseContext.h b/src/core/model/GpgPassphraseContext.h index 2bc1ac75..1db36f62 100644 --- a/src/core/model/GpgPassphraseContext.h +++ b/src/core/model/GpgPassphraseContext.h @@ -30,6 +30,8 @@ #pragma once +#include "core/GpgFrontendCoreExport.h" + namespace GpgFrontend { class GPGFRONTEND_CORE_EXPORT GpgPassphraseContext : public QObject { diff --git a/src/core/model/GpgSubKey.h b/src/core/model/GpgSubKey.h index 83d75e2d..8257eab8 100644 --- a/src/core/model/GpgSubKey.h +++ b/src/core/model/GpgSubKey.h @@ -28,6 +28,10 @@ #pragma once +#include <gpgme.h> + +#include "core/GpgFrontendCoreExport.h" + namespace GpgFrontend { /** diff --git a/src/core/model/GpgTOFUInfo.h b/src/core/model/GpgTOFUInfo.h index ec4c49b7..5e8d83d4 100644 --- a/src/core/model/GpgTOFUInfo.h +++ b/src/core/model/GpgTOFUInfo.h @@ -28,6 +28,10 @@ #pragma once +#include <gpgme.h> + +#include "core/GpgFrontendCoreExport.h" + namespace GpgFrontend { /** * @brief diff --git a/src/module/GpgFrontendModuleInit.cpp b/src/core/module/ModuleInit.cpp index b03dbab2..d74ea1c4 100644 --- a/src/module/GpgFrontendModuleInit.cpp +++ b/src/core/module/ModuleInit.cpp @@ -26,7 +26,10 @@ * */ -#include "GpgFrontendModuleInit.h" +#include "ModuleInit.h" + +#include <QCoreApplication> +#include <QDir> #include "core/module/ModuleManager.h" #include "core/thread/Task.h" @@ -39,17 +42,17 @@ void LoadGpgFrontendModules(ModuleInitArgs) { Thread::TaskRunnerGetter::GetInstance().GetTaskRunner()->PostTask( new Thread::Task( [](const DataObjectPtr&) -> int { - MODULE_LOG_INFO("loading modules..."); + GF_CORE_LOG_INFO("loading modules..."); auto exec_binary_path = QCoreApplication::applicationDirPath(); auto mods_path = exec_binary_path + "/mods"; if (!QDir(mods_path).exists()) { - MODULE_LOG_WARN("module directory not found, abort..."); + GF_CORE_LOG_INFO("module directory not found, abort..."); return -1; } - MODULE_LOG_INFO("the path of modules directory: {}", mods_path); + GF_CORE_LOG_INFO("the path of modules directory: {}", mods_path); for (const auto& module_library_name : QDir(mods_path).entryList(QStringList() << "*.so" @@ -60,7 +63,7 @@ void LoadGpgFrontendModules(ModuleInitArgs) { module_library_name); } - MODULE_LOG_INFO("load modules done."); + GF_CORE_LOG_INFO("load modules done."); return 0; }, "modules_system_init_task")); diff --git a/src/module/GpgFrontendModuleInit.h b/src/core/module/ModuleInit.h index a3a8bbd3..e7e86f0f 100644 --- a/src/module/GpgFrontendModuleInit.h +++ b/src/core/module/ModuleInit.h @@ -28,7 +28,9 @@ #pragma once -#include "module/GpgFrontendModule.h" +#include <spdlog/spdlog.h> + +#include "core/GpgFrontendCoreExport.h" namespace GpgFrontend::Module { @@ -40,12 +42,12 @@ struct ModuleInitArgs { * @brief init the module library * */ -void GPGFRONTEND_MODULE_EXPORT LoadGpgFrontendModules(ModuleInitArgs args); +void GPGFRONTEND_CORE_EXPORT LoadGpgFrontendModules(ModuleInitArgs args); /** * @brief shutdown the module library * */ -void GPGFRONTEND_MODULE_EXPORT ShutdownGpgFrontendModules(); +void GPGFRONTEND_CORE_EXPORT ShutdownGpgFrontendModules(); }; // namespace GpgFrontend::Module diff --git a/src/core/typedef/GpgTypedef.h b/src/core/typedef/GpgTypedef.h index cf0887bf..599c5c59 100644 --- a/src/core/typedef/GpgTypedef.h +++ b/src/core/typedef/GpgTypedef.h @@ -28,7 +28,7 @@ #pragma once -#include <tuple> +#include <gpgme.h> #include "core/model/DataObject.h" diff --git a/src/core/utils/BuildInfoUtils.h b/src/core/utils/BuildInfoUtils.h index bac5d8a5..07b0bb21 100644 --- a/src/core/utils/BuildInfoUtils.h +++ b/src/core/utils/BuildInfoUtils.h @@ -28,6 +28,8 @@ #pragma once +#include "core/GpgFrontendCoreExport.h" + namespace GpgFrontend { /** diff --git a/src/core/utils/CacheUtils.h b/src/core/utils/CacheUtils.h index 48b9ac4b..eae45353 100644 --- a/src/core/utils/CacheUtils.h +++ b/src/core/utils/CacheUtils.h @@ -28,6 +28,8 @@ #pragma once +#include "core/GpgFrontendCoreExport.h" + namespace GpgFrontend { /** diff --git a/src/core/utils/FilesystemUtils.h b/src/core/utils/FilesystemUtils.h index 0b58bbb7..0bc90ac5 100644 --- a/src/core/utils/FilesystemUtils.h +++ b/src/core/utils/FilesystemUtils.h @@ -28,6 +28,8 @@ #pragma once +#include "core/GpgFrontendCoreExport.h" + namespace GpgFrontend { /** @@ -54,8 +56,8 @@ auto GPGFRONTEND_CORE_EXPORT GetOnlyFileNameWithPath(const QString& path) * @param filename_pattern The pattern of the file name, e.g. "*.txt" * @return int64_t */ -auto GPGFRONTEND_CORE_EXPORT GetFileSizeByPath( - const QString& path, const QString& filename_pattern) +auto GPGFRONTEND_CORE_EXPORT GetFileSizeByPath(const QString& path, + const QString& filename_pattern) -> int64_t; /** @@ -72,7 +74,7 @@ auto GPGFRONTEND_CORE_EXPORT GetHumanFriendlyFileSize(int64_t size) -> QString; * @param path * @param filename_pattern */ -void GPGFRONTEND_CORE_EXPORT DeleteAllFilesByPattern( - const QString& path, const QString& filename_pattern); +void GPGFRONTEND_CORE_EXPORT +DeleteAllFilesByPattern(const QString& path, const QString& filename_pattern); } // namespace GpgFrontend
\ No newline at end of file diff --git a/src/core/utils/LocalizedUtils.h b/src/core/utils/LocalizedUtils.h index b93b500c..10ada833 100644 --- a/src/core/utils/LocalizedUtils.h +++ b/src/core/utils/LocalizedUtils.h @@ -28,6 +28,8 @@ #pragma once +#include "core/GpgFrontendCoreExport.h" + namespace GpgFrontend { auto GPGFRONTEND_CORE_EXPORT GetLocalizedDateByTimestamp(time_t) -> QString; diff --git a/src/core/utils/LogUtils.h b/src/core/utils/LogUtils.h index a1a5685a..e8dc6f3b 100644 --- a/src/core/utils/LogUtils.h +++ b/src/core/utils/LogUtils.h @@ -28,6 +28,49 @@ #pragma once +// spdlog library configuration +#undef SPDLOG_ACTIVE_LEVEL +#define SPDLOG_ACTIVE_LEVEL SPDLOG_LEVEL_TRACE +#include <spdlog/spdlog.h> + +// logger fmt +#include "core/GpgFrontendCoreExport.h" + +template <> +struct fmt::formatter<QString> { + // Parses format specifications. + constexpr auto parse(format_parse_context& ctx) -> decltype(ctx.begin()) { + return ctx.begin(); + } + + // Formats the QString qstr and writes it to the output. + template <typename FormatContext> + auto format(const QString& qstr, FormatContext& ctx) const + -> decltype(ctx.out()) { + // Convert QString to UTF-8 QString (to handle Unicode characters + // correctly) + QByteArray utf8_array = qstr.toUtf8(); + return fmt::format_to(ctx.out(), "{}", utf8_array.constData()); + } +}; + +template <> +struct fmt::formatter<QByteArray> { + // Parses format specifications. + constexpr auto parse(format_parse_context& ctx) -> decltype(ctx.begin()) { + return ctx.begin(); + } + + // Formats the QString qstr and writes it to the output. + template <typename FormatContext> + auto format(const QByteArray& qarray, FormatContext& ctx) const + -> decltype(ctx.out()) { + // Convert QString to UTF-8 QString (to handle Unicode characters + // correctly) + return fmt::format_to(ctx.out(), "{}", qarray.constData()); + } +}; + namespace GpgFrontend { /** @@ -50,7 +93,7 @@ auto GPGFRONTEND_CORE_EXPORT GetCoreLogger() -> std::shared_ptr<spdlog::logger>; * * @return std::shared_ptr<spdlog::logger> */ -auto GPGFRONTEND_CORE_EXPORT GetLogger(const QString &) +auto GPGFRONTEND_CORE_EXPORT GetLogger(const QString&) -> std::shared_ptr<spdlog::logger>; /** @@ -65,7 +108,7 @@ void GPGFRONTEND_CORE_EXPORT SetDefaultLogLevel(spdlog::level::level_enum); * * @return auto */ -void GPGFRONTEND_CORE_EXPORT RegisterAsyncLogger(const QString &, +void GPGFRONTEND_CORE_EXPORT RegisterAsyncLogger(const QString&, spdlog::level::level_enum); /** @@ -73,7 +116,7 @@ void GPGFRONTEND_CORE_EXPORT RegisterAsyncLogger(const QString &, * * @return auto */ -void GPGFRONTEND_CORE_EXPORT RegisterSyncLogger(const QString &, +void GPGFRONTEND_CORE_EXPORT RegisterSyncLogger(const QString&, spdlog::level::level_enum); } // namespace GpgFrontend diff --git a/src/init.cpp b/src/init.cpp index 76c1fd4c..e5936d31 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -31,9 +31,9 @@ #include "core/GpgCoreInit.h" #include "core/function/GlobalSettingStation.h" #include "core/function/gpg/GpgAdvancedOperator.h" +#include "core/module/ModuleInit.h" #include "core/thread/TaskRunnerGetter.h" #include "core/utils/LogUtils.h" -#include "module/GpgFrontendModuleInit.h" #include "ui/GpgFrontendUIInit.h" // main diff --git a/src/module/CMakeLists.txt b/src/module/CMakeLists.txt index e8f8a11e..d298dbb6 100644 --- a/src/module/CMakeLists.txt +++ b/src/module/CMakeLists.txt @@ -32,13 +32,14 @@ aux_source_directory(sdk MODULE_SDK_SOURCE) add_library(gpgfrontend_module_sdk SHARED ${MODULE_SDK_SOURCE}) set(_export_file_sdk "${CMAKE_CURRENT_SOURCE_DIR}/sdk/GFSDKExport.h") generate_export_header(gpgfrontend_module_sdk EXPORT_FILE_NAME "${_export_file_sdk}") -target_include_directories(gpgfrontend_module_sdk PUBLIC - 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 PUBLIC gpgfrontend_core) +target_link_libraries(gpgfrontend_module_sdk PRIVATE gpgfrontend_core) if (XCODE_BUILD) set_target_properties(gpgfrontend_module_sdk @@ -62,39 +63,4 @@ foreach(child ${children}) set(integrated_lib_name "gpgfrontend_integrated_module_${stripped_module}") list(APPEND all_integrated_module_libraries ${integrated_lib_name}) endif() -endforeach() - -aux_source_directory(. MODULE_SOURCE) -add_library(gpgfrontend_module SHARED ${MODULE_SOURCE}) - -set(_export_file "${CMAKE_CURRENT_SOURCE_DIR}/GpgFrontendModuleExport.h") -generate_export_header(gpgfrontend_module EXPORT_FILE_NAME "${_export_file}") - -# set up pch -target_precompile_headers(gpgfrontend_module PUBLIC GpgFrontendModule.h) - -# add ui generator include path -target_include_directories(gpgfrontend_module PUBLIC - ${CMAKE_CURRENT_BINARY_DIR}/gpgfrontend_module_autogen/include - ${CMAKE_SOURCE_DIR}/third_party/spdlog/include) - -# link gpgfrontend_module_sdk -target_link_libraries(gpgfrontend_module PRIVATE gpgfrontend_module_sdk) - -if (XCODE_BUILD) - set_target_properties(gpgfrontend_module - 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 () - - -# link all integrated modules -message(STATUS "All Module Libraries: ${all_integrated_module_libraries}") -# target_link_libraries(gpgfrontend_module PRIVATE ${all_integrated_module_libraries}) - -# using std c++ 17 -target_compile_features(gpgfrontend_module PUBLIC cxx_std_17)
\ No newline at end of file +endforeach()
\ No newline at end of file diff --git a/src/module/GpgFrontendModule.h b/src/module/GpgFrontendModule.h deleted file mode 100644 index 8277a4f4..00000000 --- a/src/module/GpgFrontendModule.h +++ /dev/null @@ -1,46 +0,0 @@ -/** - * 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 - -/** - * Project internal dependencies - */ -#include "GpgFrontend.h" -#include "GpgFrontendModuleExport.h" -#include "core/GpgFrontendCore.h" - -/** - * @brief logger for inner - * - */ -#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__) diff --git a/src/module/GpgFrontendModuleExport.h b/src/module/GpgFrontendModuleExport.h deleted file mode 100644 index 33ecbd3b..00000000 --- a/src/module/GpgFrontendModuleExport.h +++ /dev/null @@ -1,42 +0,0 @@ - -#ifndef GPGFRONTEND_MODULE_EXPORT_H -#define GPGFRONTEND_MODULE_EXPORT_H - -#ifdef GPGFRONTEND_MODULE_STATIC_DEFINE -# define GPGFRONTEND_MODULE_EXPORT -# define GPGFRONTEND_MODULE_NO_EXPORT -#else -# ifndef GPGFRONTEND_MODULE_EXPORT -# ifdef gpgfrontend_module_EXPORTS - /* We are building this library */ -# define GPGFRONTEND_MODULE_EXPORT __attribute__((visibility("default"))) -# else - /* We are using this library */ -# define GPGFRONTEND_MODULE_EXPORT __attribute__((visibility("default"))) -# endif -# endif - -# ifndef GPGFRONTEND_MODULE_NO_EXPORT -# define GPGFRONTEND_MODULE_NO_EXPORT __attribute__((visibility("hidden"))) -# endif -#endif - -#ifndef GPGFRONTEND_MODULE_DEPRECATED -# define GPGFRONTEND_MODULE_DEPRECATED __attribute__ ((__deprecated__)) -#endif - -#ifndef GPGFRONTEND_MODULE_DEPRECATED_EXPORT -# define GPGFRONTEND_MODULE_DEPRECATED_EXPORT GPGFRONTEND_MODULE_EXPORT GPGFRONTEND_MODULE_DEPRECATED -#endif - -#ifndef GPGFRONTEND_MODULE_DEPRECATED_NO_EXPORT -# define GPGFRONTEND_MODULE_DEPRECATED_NO_EXPORT GPGFRONTEND_MODULE_NO_EXPORT GPGFRONTEND_MODULE_DEPRECATED -#endif - -#if 0 /* DEFINE_NO_DEPRECATED */ -# ifndef GPGFRONTEND_MODULE_NO_DEPRECATED -# define GPGFRONTEND_MODULE_NO_DEPRECATED -# endif -#endif - -#endif /* GPGFRONTEND_MODULE_EXPORT_H */ diff --git a/src/module/integrated/gnupg_info_gathering_module/CMakeLists.txt b/src/module/integrated/gnupg_info_gathering_module/CMakeLists.txt index 5b72004b..578d60d3 100644 --- a/src/module/integrated/gnupg_info_gathering_module/CMakeLists.txt +++ b/src/module/integrated/gnupg_info_gathering_module/CMakeLists.txt @@ -34,6 +34,9 @@ generate_export_header(gpgfrontend_gnupg_info_gathering BASE_NAME "GF_MODULE" EXPORT_FILE_NAME "${_export_file}") +target_include_directories(gpgfrontend_gnupg_info_gathering PRIVATE + ${CMAKE_SOURCE_DIR}/third_party/spdlog/include) + if (XCODE_BUILD) set_target_properties(gpgfrontend_gnupg_info_gathering PROPERTIES @@ -46,7 +49,12 @@ endif () # link sdk target_link_libraries(gpgfrontend_gnupg_info_gathering PRIVATE - gpgfrontend_module_sdk) + gpgfrontend_module_sdk) + +# link qt +target_link_libraries(gpgfrontend_gnupg_info_gathering PRIVATE + Qt6::Core) + # set output directory set_target_properties(gpgfrontend_gnupg_info_gathering PROPERTIES diff --git a/src/module/integrated/gnupg_info_gathering_module/GnuPGInfoGatheringModule.cpp b/src/module/integrated/gnupg_info_gathering_module/GnuPGInfoGatheringModule.cpp index dd506134..c5c760b0 100644 --- a/src/module/integrated/gnupg_info_gathering_module/GnuPGInfoGatheringModule.cpp +++ b/src/module/integrated/gnupg_info_gathering_module/GnuPGInfoGatheringModule.cpp @@ -31,9 +31,50 @@ #include <GFSDKBasic.h> #include <GFSDKBuildInfo.h> #include <GFSDKLog.h> +#include <spdlog/spdlog.h> + +#include <QCryptographicHash> +#include <QFileInfo> +#include <QJsonDocument> +#include <QString> #include "GpgInfo.h" +template <> +struct fmt::formatter<QString> { + // Parses format specifications. + constexpr auto parse(format_parse_context &ctx) -> decltype(ctx.begin()) { + return ctx.begin(); + } + + // Formats the QString qstr and writes it to the output. + template <typename FormatContext> + auto format(const QString &qstr, FormatContext &ctx) const + -> decltype(ctx.out()) { + // Convert QString to UTF-8 QString (to handle Unicode characters + // correctly) + QByteArray utf8_array = qstr.toUtf8(); + return fmt::format_to(ctx.out(), "{}", utf8_array.constData()); + } +}; + +template <> +struct fmt::formatter<QByteArray> { + // Parses format specifications. + constexpr auto parse(format_parse_context &ctx) -> decltype(ctx.begin()) { + return ctx.begin(); + } + + // Formats the QString qstr and writes it to the output. + template <typename FormatContext> + auto format(const QByteArray &qarray, FormatContext &ctx) const + -> decltype(ctx.out()) { + // Convert QString to UTF-8 QString (to handle Unicode characters + // correctly) + return fmt::format_to(ctx.out(), "{}", qarray.constData()); + } +}; + extern auto CalculateBinaryChacksum(const QString &path) -> std::optional<QString>; diff --git a/src/module/integrated/gnupg_info_gathering_module/GpgInfo.h b/src/module/integrated/gnupg_info_gathering_module/GpgInfo.h index 97c9f6b5..1aacc207 100644 --- a/src/module/integrated/gnupg_info_gathering_module/GpgInfo.h +++ b/src/module/integrated/gnupg_info_gathering_module/GpgInfo.h @@ -28,6 +28,10 @@ #pragma once +#include <QJsonObject> +#include <QString> +#include <map> + /** * @brief Use to record some info about gnupg * diff --git a/src/core/log/QtLoggerFmt.h b/src/module/integrated/gnupg_info_gathering_module/QtLoggerFmt.h index e7ac2c82..23997465 100644 --- a/src/core/log/QtLoggerFmt.h +++ b/src/module/integrated/gnupg_info_gathering_module/QtLoggerFmt.h @@ -28,6 +28,10 @@ #pragma once +#include <spdlog/spdlog.h> + +#include <QString> + template <> struct fmt::formatter<QString> { // Parses format specifications. diff --git a/src/module/integrated/version_checking_module/CMakeLists.txt b/src/module/integrated/version_checking_module/CMakeLists.txt index ba1ea591..9b6fa271 100644 --- a/src/module/integrated/version_checking_module/CMakeLists.txt +++ b/src/module/integrated/version_checking_module/CMakeLists.txt @@ -34,6 +34,9 @@ generate_export_header(gpgfrontend_version_checking BASE_NAME "GF_MODULE" EXPORT_FILE_NAME "${_export_file}") +target_include_directories(gpgfrontend_version_checking PRIVATE + ${CMAKE_SOURCE_DIR}/third_party/spdlog/include) + if (XCODE_BUILD) set_target_properties(gpgfrontend_version_checking PROPERTIES @@ -46,14 +49,14 @@ endif () # link sdk target_link_libraries(gpgfrontend_version_checking PRIVATE - gpgfrontend_module_sdk) + gpgfrontend_module_sdk) if(GPGFRONTEND_QT5_BUILD) # link Qt - target_link_libraries(gpgfrontend_version_checking PUBLIC Qt5::Network) + target_link_libraries(gpgfrontend_version_checking PUBLIC Qt5::Core Qt5::Network) else() # link Qt - target_link_libraries(gpgfrontend_version_checking PUBLIC Qt6::Network) + target_link_libraries(gpgfrontend_version_checking PUBLIC Qt6::Core Qt6::Network) endif() # set output directory diff --git a/src/module/integrated/version_checking_module/QtLoggerFmt.h b/src/module/integrated/version_checking_module/QtLoggerFmt.h new file mode 100644 index 00000000..23997465 --- /dev/null +++ b/src/module/integrated/version_checking_module/QtLoggerFmt.h @@ -0,0 +1,68 @@ +/** + * 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 <spdlog/spdlog.h> + +#include <QString> + +template <> +struct fmt::formatter<QString> { + // Parses format specifications. + constexpr auto parse(format_parse_context& ctx) -> decltype(ctx.begin()) { + return ctx.begin(); + } + + // Formats the QString qstr and writes it to the output. + template <typename FormatContext> + auto format(const QString& qstr, FormatContext& ctx) const + -> decltype(ctx.out()) { + // Convert QString to UTF-8 QString (to handle Unicode characters + // correctly) + QByteArray utf8_array = qstr.toUtf8(); + return fmt::format_to(ctx.out(), "{}", utf8_array.constData()); + } +}; + +template <> +struct fmt::formatter<QByteArray> { + // Parses format specifications. + constexpr auto parse(format_parse_context& ctx) -> decltype(ctx.begin()) { + return ctx.begin(); + } + + // Formats the QString qstr and writes it to the output. + template <typename FormatContext> + auto format(const QByteArray& qarray, FormatContext& ctx) const + -> decltype(ctx.out()) { + // Convert QString to UTF-8 QString (to handle Unicode characters + // correctly) + return fmt::format_to(ctx.out(), "{}", qarray.constData()); + } +}; diff --git a/src/module/integrated/version_checking_module/SoftwareVersion.cpp b/src/module/integrated/version_checking_module/SoftwareVersion.cpp index 4e1c2dfa..cd864195 100644 --- a/src/module/integrated/version_checking_module/SoftwareVersion.cpp +++ b/src/module/integrated/version_checking_module/SoftwareVersion.cpp @@ -31,6 +31,44 @@ #include <GFSDKBasic.h> #include <GFSDKExtra.h> #include <GFSDKLog.h> +#include <spdlog/spdlog.h> + +#include <QString> + +template <> +struct fmt::formatter<QString> { + // Parses format specifications. + constexpr auto parse(format_parse_context& ctx) -> decltype(ctx.begin()) { + return ctx.begin(); + } + + // Formats the QString qstr and writes it to the output. + template <typename FormatContext> + auto format(const QString& qstr, FormatContext& ctx) const + -> decltype(ctx.out()) { + // Convert QString to UTF-8 QString (to handle Unicode characters + // correctly) + QByteArray utf8_array = qstr.toUtf8(); + return fmt::format_to(ctx.out(), "{}", utf8_array.constData()); + } +}; + +template <> +struct fmt::formatter<QByteArray> { + // Parses format specifications. + constexpr auto parse(format_parse_context& ctx) -> decltype(ctx.begin()) { + return ctx.begin(); + } + + // Formats the QString qstr and writes it to the output. + template <typename FormatContext> + auto format(const QByteArray& qarray, FormatContext& ctx) const + -> decltype(ctx.out()) { + // Convert QString to UTF-8 QString (to handle Unicode characters + // correctly) + return fmt::format_to(ctx.out(), "{}", qarray.constData()); + } +}; auto SoftwareVersion::NeedUpgrade() const -> bool { GFModuleLogDebug( diff --git a/src/module/integrated/version_checking_module/SoftwareVersion.h b/src/module/integrated/version_checking_module/SoftwareVersion.h index f0af8d3e..6b05d413 100644 --- a/src/module/integrated/version_checking_module/SoftwareVersion.h +++ b/src/module/integrated/version_checking_module/SoftwareVersion.h @@ -28,6 +28,8 @@ #pragma once +#include <QString> + /** * @brief * diff --git a/src/module/integrated/version_checking_module/VersionCheckingModule.cpp b/src/module/integrated/version_checking_module/VersionCheckingModule.cpp index 0c97311d..0db00485 100644 --- a/src/module/integrated/version_checking_module/VersionCheckingModule.cpp +++ b/src/module/integrated/version_checking_module/VersionCheckingModule.cpp @@ -32,6 +32,7 @@ #include <GFSDKBuildInfo.h> #include <GFSDKExtra.h> #include <GFSDKLog.h> +#include <spdlog/spdlog.h> #include <QMetaType> #include <QtNetwork> diff --git a/src/module/sdk/GFSDKModule.h b/src/module/sdk/GFSDKModule.h index 0ae23cf3..4df07762 100644 --- a/src/module/sdk/GFSDKModule.h +++ b/src/module/sdk/GFSDKModule.h @@ -32,6 +32,8 @@ extern "C" { +#include <stdint.h> + struct GFModuleMetaData { const char *key; const char *value; |