feat: remove dependency 'spdlog'
This commit is contained in:
parent
46b7ecec8f
commit
12d5852ffe
3
.gitmodules
vendored
3
.gitmodules
vendored
@ -1,3 +0,0 @@
|
|||||||
[submodule "third_party/spdlog"]
|
|
||||||
path = third_party/spdlog
|
|
||||||
url = https://github.com/gabime/spdlog.git
|
|
@ -1,11 +1,11 @@
|
|||||||
SET (CMAKE_C_FLAGS "-Wall -std=c11")
|
SET (CMAKE_C_FLAGS "-Wall -std=c11")
|
||||||
SET (CMAKE_C_FLAGS_DEBUG "-g -fsanitize=address -fsanitize-recover=address")
|
SET (CMAKE_C_FLAGS_DEBUG "-g")
|
||||||
SET (CMAKE_C_FLAGS_MINSIZERE "-Os -DNDEBUG")
|
SET (CMAKE_C_FLAGS_MINSIZERE "-Os -DNDEBUG")
|
||||||
SET (CMAKE_C_FLAGS_RELEASE "-O3 -DNDEBUG")
|
SET (CMAKE_C_FLAGS_RELEASE "-O3 -DNDEBUG")
|
||||||
SET (CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 -g")
|
SET (CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 -g")
|
||||||
|
|
||||||
SET (CMAKE_CXX_FLAGS "-Wall -std=c++17")
|
SET (CMAKE_CXX_FLAGS "-Wall -std=c++17")
|
||||||
SET (CMAKE_CXX_FLAGS_DEBUG "-g -fsanitize=address -fsanitize-recover=address")
|
SET (CMAKE_CXX_FLAGS_DEBUG "-g")
|
||||||
SET (CMAKE_CXX_FLAGS_MINSIZEREL "-Os -DNDEBUG")
|
SET (CMAKE_CXX_FLAGS_MINSIZEREL "-Os -DNDEBUG")
|
||||||
SET (CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG")
|
SET (CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG")
|
||||||
SET (CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g")
|
SET (CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g")
|
@ -1,71 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (C) 2021 Saturneric <eric@bktus.com>
|
|
||||||
*
|
|
||||||
* 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 <eric@bktus.com> starting on May 12, 2021.
|
|
||||||
*
|
|
||||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
// spdlog library configuration
|
|
||||||
#undef SPDLOG_ACTIVE_LEVEL
|
|
||||||
#define SPDLOG_ACTIVE_LEVEL SPDLOG_LEVEL_TRACE
|
|
||||||
#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 const 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());
|
|
||||||
}
|
|
||||||
};
|
|
@ -30,9 +30,6 @@ aux_source_directory(. INTEGRATED_MODULE_SOURCE)
|
|||||||
# define libgpgfrontend_module
|
# define libgpgfrontend_module
|
||||||
add_library(mod_gpg_info SHARED ${INTEGRATED_MODULE_SOURCE})
|
add_library(mod_gpg_info SHARED ${INTEGRATED_MODULE_SOURCE})
|
||||||
|
|
||||||
target_include_directories(mod_gpg_info PRIVATE
|
|
||||||
${CMAKE_SOURCE_DIR}/third_party/spdlog/include)
|
|
||||||
|
|
||||||
# install dir
|
# install dir
|
||||||
install(TARGETS mod_gpg_info
|
install(TARGETS mod_gpg_info
|
||||||
LIBRARY DESTINATION "${CMAKE_INSTALL_PREFIX}/modules")
|
LIBRARY DESTINATION "${CMAKE_INSTALL_PREFIX}/modules")
|
||||||
|
@ -31,7 +31,6 @@
|
|||||||
#include <GFSDKBasic.h>
|
#include <GFSDKBasic.h>
|
||||||
#include <GFSDKBuildInfo.h>
|
#include <GFSDKBuildInfo.h>
|
||||||
#include <GFSDKLog.h>
|
#include <GFSDKLog.h>
|
||||||
#include <spdlog/spdlog.h>
|
|
||||||
|
|
||||||
// qt
|
// qt
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
@ -70,44 +69,26 @@ using Context = struct {
|
|||||||
};
|
};
|
||||||
|
|
||||||
auto GFGetModuleGFSDKVersion() -> const char * {
|
auto GFGetModuleGFSDKVersion() -> const char * {
|
||||||
return GFModuleStrDup(GF_SDK_VERSION_STR);
|
return DUP(GF_SDK_VERSION_STR);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto GFGetModuleQtEnvVersion() -> const char * {
|
auto GFGetModuleQtEnvVersion() -> const char * { return DUP(QT_VERSION_STR); }
|
||||||
return GFModuleStrDup(QT_VERSION_STR);
|
|
||||||
}
|
|
||||||
|
|
||||||
auto GFGetModuleID() -> const char * {
|
auto GFGetModuleID() -> const char * {
|
||||||
return GFModuleStrDup("com.bktus.gpgfrontend.module.gnupg_info_gathering");
|
return DUP("com.bktus.gpgfrontend.module.gnupg_info_gathering");
|
||||||
}
|
}
|
||||||
|
|
||||||
auto GFGetModuleVersion() -> const char * { return GFModuleStrDup("1.0.0"); }
|
auto GFGetModuleVersion() -> const char * { return DUP("1.0.0"); }
|
||||||
|
|
||||||
auto GFGetModuleMetaData() -> GFModuleMetaData * {
|
auto GFGetModuleMetaData() -> GFModuleMetaData * {
|
||||||
auto *p_meta = static_cast<GFModuleMetaData *>(
|
return QMapToGFModuleMetaDataList(
|
||||||
GFAllocateMemory(sizeof(GFModuleMetaData)));
|
{{"Name", "GatherGnupgInfo"},
|
||||||
auto *h_meta = p_meta;
|
{"Description", "Try gathering gnupg informations."},
|
||||||
|
{"Author", "Saturneric"}});
|
||||||
p_meta->key = "Name";
|
|
||||||
p_meta->value = "GatherGnupgInfo";
|
|
||||||
p_meta->next = static_cast<GFModuleMetaData *>(
|
|
||||||
GFAllocateMemory(sizeof(GFModuleMetaData)));
|
|
||||||
p_meta = p_meta->next;
|
|
||||||
|
|
||||||
p_meta->key = "Description";
|
|
||||||
p_meta->value = "Try gathering gnupg informations";
|
|
||||||
p_meta->next = static_cast<GFModuleMetaData *>(
|
|
||||||
GFAllocateMemory(sizeof(GFModuleMetaData)));
|
|
||||||
p_meta = p_meta->next;
|
|
||||||
|
|
||||||
p_meta->key = "Author";
|
|
||||||
p_meta->value = "Saturneric";
|
|
||||||
p_meta->next = nullptr;
|
|
||||||
return h_meta;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
auto GFRegisterModule() -> int {
|
auto GFRegisterModule() -> int {
|
||||||
GFModuleLogDebug("gnupg info gathering module registering");
|
MLogDebug("gnupg info gathering module registering");
|
||||||
|
|
||||||
GFUIMountEntry(DUP("AboutDialogTabs"),
|
GFUIMountEntry(DUP("AboutDialogTabs"),
|
||||||
QMapToMetaDataArray({{"TabTitle", GTrC::tr("GnuPG")}}), 1,
|
QMapToMetaDataArray({{"TabTitle", GTrC::tr("GnuPG")}}), 1,
|
||||||
@ -117,9 +98,8 @@ auto GFRegisterModule() -> int {
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto GFActiveModule() -> int {
|
auto GFActiveModule() -> int {
|
||||||
GFModuleLogDebug("gnupg info gathering module activating");
|
MLogDebug("gnupg info gathering module activating");
|
||||||
GFModuleListenEvent(GFGetModuleID(),
|
GFModuleListenEvent(GFGetModuleID(), DUP("REQUEST_GATHERING_GNUPG_INFO"));
|
||||||
GFModuleStrDup("REQUEST_GATHERING_GNUPG_INFO"));
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -131,40 +111,39 @@ auto GFExecuteModule(GFModuleEvent *event) -> int {
|
|||||||
|
|
||||||
char **event_argv =
|
char **event_argv =
|
||||||
static_cast<char **>(GFAllocateMemory(sizeof(char **) * 1));
|
static_cast<char **>(GFAllocateMemory(sizeof(char **) * 1));
|
||||||
event_argv[0] = GFModuleStrDup("0");
|
event_argv[0] = DUP("0");
|
||||||
|
|
||||||
GFModuleTriggerModuleEventCallback(event, GFGetModuleID(), 1, event_argv);
|
GFModuleTriggerModuleEventCallback(event, GFGetModuleID(), 1, event_argv);
|
||||||
|
|
||||||
GFModuleLogDebug("gnupg external info gathering done");
|
MLogDebug("gnupg external info gathering done");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto GFDeactiveModule() -> int { return 0; }
|
auto GFDeactiveModule() -> int { return 0; }
|
||||||
|
|
||||||
auto GFUnregisterModule() -> int {
|
auto GFUnregisterModule() -> int {
|
||||||
GFModuleLogDebug("gnupg info gathering module unregistering");
|
MLogDebug("gnupg info gathering module unregistering");
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto StartGatheringGnuPGInfo() -> int {
|
auto StartGatheringGnuPGInfo() -> int {
|
||||||
GFModuleLogDebug("start to load extra info at module gnupginfogathering...");
|
MLogDebug("start to load extra info at module gnupginfogathering...");
|
||||||
|
|
||||||
const auto *const gpgme_version = GFModuleRetrieveRTValueOrDefault(
|
const auto *const gpgme_version = GFModuleRetrieveRTValueOrDefault(
|
||||||
GFModuleStrDup("core"), GFModuleStrDup("gpgme.version"),
|
DUP("core"), DUP("gpgme.version"), DUP("0.0.0"));
|
||||||
GFModuleStrDup("0.0.0"));
|
|
||||||
MLogDebug(QString("got gpgme version from rt: %1").arg(gpgme_version));
|
MLogDebug(QString("got gpgme version from rt: %1").arg(gpgme_version));
|
||||||
|
|
||||||
const auto *const gpgconf_path = GFModuleRetrieveRTValueOrDefault(
|
const auto *const gpgconf_path = GFModuleRetrieveRTValueOrDefault(
|
||||||
GFModuleStrDup("core"), GFModuleStrDup("gpgme.ctx.gpgconf_path"),
|
DUP("core"), DUP("gpgme.ctx.gpgconf_path"), DUP(""));
|
||||||
GFModuleStrDup(""));
|
|
||||||
MLogDebug(QString("got gpgconf path from rt: %1").arg(gpgconf_path));
|
MLogDebug(QString("got gpgconf path from rt: %1").arg(gpgconf_path));
|
||||||
|
|
||||||
auto context = Context{gpgme_version, gpgconf_path};
|
auto context = Context{gpgme_version, gpgconf_path};
|
||||||
|
|
||||||
// get all components
|
// get all components
|
||||||
const char *argv[] = {GFModuleStrDup("--list-components")};
|
const char *argv[] = {DUP("--list-components")};
|
||||||
GFExecuteCommandSync(gpgconf_path, 1, argv, GetGpgComponentInfos, &context);
|
GFExecuteCommandSync(gpgconf_path, 1, argv, GetGpgComponentInfos, &context);
|
||||||
GFModuleLogDebug("load gnupg component info done.");
|
MLogDebug("load gnupg component info done.");
|
||||||
|
|
||||||
#ifdef QT5_BUILD
|
#ifdef QT5_BUILD
|
||||||
QVector<GFCommandExecuteContext> exec_contexts;
|
QVector<GFCommandExecuteContext> exec_contexts;
|
||||||
@ -174,14 +153,14 @@ auto StartGatheringGnuPGInfo() -> int {
|
|||||||
|
|
||||||
const char **argv_0 =
|
const char **argv_0 =
|
||||||
static_cast<const char **>(GFAllocateMemory(sizeof(const char *)));
|
static_cast<const char **>(GFAllocateMemory(sizeof(const char *)));
|
||||||
argv_0[0] = GFModuleStrDup("--list-dirs");
|
argv_0[0] = DUP("--list-dirs");
|
||||||
|
|
||||||
exec_contexts.push_back(
|
exec_contexts.push_back(
|
||||||
{gpgconf_path, 1, argv_0, GetGpgDirectoryInfos, nullptr});
|
{gpgconf_path, 1, argv_0, GetGpgDirectoryInfos, nullptr});
|
||||||
|
|
||||||
char **components_c_array;
|
char **components_c_array;
|
||||||
int ret = GFModuleListRTChildKeys(
|
int ret = GFModuleListRTChildKeys(GFGetModuleID(), DUP("gnupg.components"),
|
||||||
GFGetModuleID(), GFModuleStrDup("gnupg.components"), &components_c_array);
|
&components_c_array);
|
||||||
if (components_c_array == nullptr || ret == 0) return -1;
|
if (components_c_array == nullptr || ret == 0) return -1;
|
||||||
|
|
||||||
QStringList components;
|
QStringList components;
|
||||||
@ -191,8 +170,7 @@ auto StartGatheringGnuPGInfo() -> int {
|
|||||||
for (const auto &component : components) {
|
for (const auto &component : components) {
|
||||||
const auto *component_info_json = GFModuleRetrieveRTValueOrDefault(
|
const auto *component_info_json = GFModuleRetrieveRTValueOrDefault(
|
||||||
GFGetModuleID(),
|
GFGetModuleID(),
|
||||||
GFModuleStrDup(QString("gnupg.components.%1").arg(component).toUtf8()),
|
DUP(QString("gnupg.components.%1").arg(component).toUtf8()), nullptr);
|
||||||
nullptr);
|
|
||||||
|
|
||||||
if (component_info_json == nullptr) continue;
|
if (component_info_json == nullptr) continue;
|
||||||
|
|
||||||
@ -213,16 +191,15 @@ auto StartGatheringGnuPGInfo() -> int {
|
|||||||
|
|
||||||
const char **argv_0 =
|
const char **argv_0 =
|
||||||
static_cast<const char **>(GFAllocateMemory(sizeof(const char *) * 2));
|
static_cast<const char **>(GFAllocateMemory(sizeof(const char *) * 2));
|
||||||
argv_0[0] = GFModuleStrDup("--list-options"),
|
argv_0[0] = DUP("--list-options"),
|
||||||
argv_0[1] = GFModuleStrDup(component_info.name.toUtf8());
|
argv_0[1] = DUP(component_info.name.toUtf8());
|
||||||
exec_contexts.push_back(
|
exec_contexts.push_back(
|
||||||
{gpgconf_path, 2, argv_0, GetGpgOptionInfos, context});
|
{gpgconf_path, 2, argv_0, GetGpgOptionInfos, context});
|
||||||
}
|
}
|
||||||
|
|
||||||
GFExecuteCommandBatchSync(static_cast<int32_t>(exec_contexts.size()),
|
GFExecuteCommandBatchSync(static_cast<int32_t>(exec_contexts.size()),
|
||||||
exec_contexts.constData());
|
exec_contexts.constData());
|
||||||
GFModuleUpsertRTValueBool(GFGetModuleID(),
|
GFModuleUpsertRTValueBool(GFGetModuleID(), DUP("gnupg.gathering_done"), 1);
|
||||||
GFModuleStrDup("gnupg.gathering_done"), 1);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -310,11 +287,11 @@ void GetGpgComponentInfos(void *data, int exit_code, const char *out,
|
|||||||
auto const jsonlized_gpgme_component_info = c_i_gpgme.Json();
|
auto const jsonlized_gpgme_component_info = c_i_gpgme.Json();
|
||||||
auto const jsonlized_gpgconf_component_info = c_i_gpgconf.Json();
|
auto const jsonlized_gpgconf_component_info = c_i_gpgconf.Json();
|
||||||
GFModuleUpsertRTValue(
|
GFModuleUpsertRTValue(
|
||||||
GFGetModuleID(), GFModuleStrDup("gnupg.components.gpgme"),
|
GFGetModuleID(), DUP("gnupg.components.gpgme"),
|
||||||
GFModuleStrDup(QJsonDocument(jsonlized_gpgme_component_info).toJson()));
|
DUP(QJsonDocument(jsonlized_gpgme_component_info).toJson()));
|
||||||
GFModuleUpsertRTValue(
|
GFModuleUpsertRTValue(
|
||||||
GFGetModuleID(), GFModuleStrDup("gnupg.components.gpgconf"),
|
GFGetModuleID(), DUP("gnupg.components.gpgconf"),
|
||||||
GFModuleStrDup(QJsonDocument(jsonlized_gpgconf_component_info).toJson()));
|
DUP(QJsonDocument(jsonlized_gpgconf_component_info).toJson()));
|
||||||
|
|
||||||
auto line_split_list = p_out.split("\n");
|
auto line_split_list = p_out.split("\n");
|
||||||
|
|
||||||
@ -346,23 +323,19 @@ void GetGpgComponentInfos(void *data, int exit_code, const char *out,
|
|||||||
|
|
||||||
if (component_name == "gpg") {
|
if (component_name == "gpg") {
|
||||||
version = GFModuleRetrieveRTValueOrDefault(
|
version = GFModuleRetrieveRTValueOrDefault(
|
||||||
GFModuleStrDup("core"), GFModuleStrDup("gpgme.ctx.gnupg_version"),
|
DUP("core"), DUP("gpgme.ctx.gnupg_version"), DUP("2.0.0"));
|
||||||
GFModuleStrDup("2.0.0"));
|
|
||||||
}
|
}
|
||||||
if (component_name == "gpg-agent") {
|
if (component_name == "gpg-agent") {
|
||||||
GFModuleUpsertRTValue(GFGetModuleID(),
|
GFModuleUpsertRTValue(GFGetModuleID(), DUP("gnupg.gpg_agent_path"),
|
||||||
GFModuleStrDup("gnupg.gpg_agent_path"),
|
DUP(QString(component_path).toUtf8()));
|
||||||
GFModuleStrDup(QString(component_path).toUtf8()));
|
|
||||||
}
|
}
|
||||||
if (component_name == "dirmngr") {
|
if (component_name == "dirmngr") {
|
||||||
GFModuleUpsertRTValue(GFGetModuleID(),
|
GFModuleUpsertRTValue(GFGetModuleID(), DUP("gnupg.dirmngr_path"),
|
||||||
GFModuleStrDup("gnupg.dirmngr_path"),
|
DUP(QString(component_path).toUtf8()));
|
||||||
GFModuleStrDup(QString(component_path).toUtf8()));
|
|
||||||
}
|
}
|
||||||
if (component_name == "keyboxd") {
|
if (component_name == "keyboxd") {
|
||||||
GFModuleUpsertRTValue(GFGetModuleID(),
|
GFModuleUpsertRTValue(GFGetModuleID(), DUP("gnupg.keyboxd_path"),
|
||||||
GFModuleStrDup("gnupg.keyboxd_path"),
|
DUP(QString(component_path).toUtf8()));
|
||||||
GFModuleStrDup(QString(component_path).toUtf8()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -378,14 +351,13 @@ void GetGpgComponentInfos(void *data, int exit_code, const char *out,
|
|||||||
auto const jsonlized_component_info = c_i.Json();
|
auto const jsonlized_component_info = c_i.Json();
|
||||||
GFModuleUpsertRTValue(
|
GFModuleUpsertRTValue(
|
||||||
GFGetModuleID(),
|
GFGetModuleID(),
|
||||||
GFModuleStrDup(
|
DUP(QString("gnupg.components.%1").arg(component_name).toUtf8()),
|
||||||
QString("gnupg.components.%1").arg(component_name).toUtf8()),
|
DUP(QJsonDocument(jsonlized_component_info).toJson()));
|
||||||
GFModuleStrDup(QJsonDocument(jsonlized_component_info).toJson()));
|
|
||||||
|
|
||||||
component_infos.push_back(c_i);
|
component_infos.push_back(c_i);
|
||||||
}
|
}
|
||||||
|
|
||||||
GFModuleLogDebug("load gnupg component info actually done.");
|
MLogDebug("load gnupg component info actually done.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -416,15 +388,14 @@ void GetGpgDirectoryInfos(void *, int exit_code, const char *out,
|
|||||||
|
|
||||||
// record gnupg home path
|
// record gnupg home path
|
||||||
if (configuration_name == "homedir") {
|
if (configuration_name == "homedir") {
|
||||||
GFModuleUpsertRTValue(GFGetModuleID(), GFModuleStrDup("gnupg.home_path"),
|
GFModuleUpsertRTValue(GFGetModuleID(), DUP("gnupg.home_path"),
|
||||||
GFModuleStrDup(configuration_value.toUtf8()));
|
DUP(configuration_value.toUtf8()));
|
||||||
}
|
}
|
||||||
|
|
||||||
GFModuleUpsertRTValue(
|
GFModuleUpsertRTValue(
|
||||||
GFGetModuleID(),
|
GFGetModuleID(),
|
||||||
GFModuleStrDup(
|
DUP(QString("gnupg.dirs.%1").arg(configuration_name).toUtf8()),
|
||||||
QString("gnupg.dirs.%1").arg(configuration_name).toUtf8()),
|
DUP(configuration_value.toUtf8()));
|
||||||
GFModuleStrDup(configuration_value.toUtf8()));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -485,13 +456,12 @@ void GetGpgOptionInfos(void *data, int exit_code, const char *out,
|
|||||||
info.value = option_value;
|
info.value = option_value;
|
||||||
|
|
||||||
auto const jsonlized_option_info = info.Json();
|
auto const jsonlized_option_info = info.Json();
|
||||||
GFModuleUpsertRTValue(
|
GFModuleUpsertRTValue(GFGetModuleID(),
|
||||||
GFGetModuleID(),
|
DUP(QString("gnupg.components.%1.options.%2")
|
||||||
GFModuleStrDup(QString("gnupg.components.%1.options.%2")
|
.arg(component_name)
|
||||||
.arg(component_name)
|
.arg(option_name)
|
||||||
.arg(option_name)
|
.toUtf8()),
|
||||||
.toUtf8()),
|
DUP(QJsonDocument(jsonlized_option_info).toJson()));
|
||||||
GFModuleStrDup(QJsonDocument(jsonlized_option_info).toJson()));
|
|
||||||
options_infos.push_back(info);
|
options_infos.push_back(info);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,68 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (C) 2021 Saturneric <eric@bktus.com>
|
|
||||||
*
|
|
||||||
* 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 <eric@bktus.com> 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());
|
|
||||||
}
|
|
||||||
};
|
|
@ -30,9 +30,6 @@ aux_source_directory(. MODULE_SOURCE_FILES)
|
|||||||
# define libgpgfrontend_module
|
# define libgpgfrontend_module
|
||||||
add_library(mod_ver_check SHARED ${MODULE_SOURCE_FILES})
|
add_library(mod_ver_check SHARED ${MODULE_SOURCE_FILES})
|
||||||
|
|
||||||
target_include_directories(mod_ver_check PRIVATE
|
|
||||||
${CMAKE_SOURCE_DIR}/third_party/spdlog/include)
|
|
||||||
|
|
||||||
# install dir
|
# install dir
|
||||||
install(TARGETS mod_ver_check
|
install(TARGETS mod_ver_check
|
||||||
LIBRARY DESTINATION "${CMAKE_INSTALL_PREFIX}/modules")
|
LIBRARY DESTINATION "${CMAKE_INSTALL_PREFIX}/modules")
|
||||||
|
@ -1,68 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (C) 2021 Saturneric <eric@bktus.com>
|
|
||||||
*
|
|
||||||
* 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 <eric@bktus.com> 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());
|
|
||||||
}
|
|
||||||
};
|
|
@ -31,59 +31,23 @@
|
|||||||
#include <GFSDKBasic.h>
|
#include <GFSDKBasic.h>
|
||||||
#include <GFSDKExtra.h>
|
#include <GFSDKExtra.h>
|
||||||
#include <GFSDKLog.h>
|
#include <GFSDKLog.h>
|
||||||
#include <spdlog/spdlog.h>
|
|
||||||
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
template <>
|
#include "GFModuleCommonUtils.hpp"
|
||||||
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 {
|
auto SoftwareVersion::NeedUpgrade() const -> bool {
|
||||||
GFModuleLogDebug(
|
MLogDebug(QString("compare version current: %1 latest %2, result: %3")
|
||||||
fmt::format(
|
.arg(current_version)
|
||||||
"compair version current {} latest {}, result {}", current_version,
|
.arg(latest_version)
|
||||||
latest_version,
|
.arg(GFCompareSoftwareVersion(
|
||||||
GFCompareSoftwareVersion(GFModuleStrDup(current_version.toUtf8()),
|
GFModuleStrDup(current_version.toUtf8()),
|
||||||
GFModuleStrDup(latest_version.toUtf8())))
|
GFModuleStrDup(latest_version.toUtf8()))));
|
||||||
.c_str());
|
|
||||||
|
|
||||||
GFModuleLogDebug(fmt::format("load done: {}, pre-release: {}, draft: {}",
|
MLogDebug(QString("load done: %1, pre-release: %2, draft: %3")
|
||||||
loading_done,
|
.arg(static_cast<int>(loading_done))
|
||||||
latest_prerelease_version_from_remote,
|
.arg(static_cast<int>(latest_prerelease_version_from_remote))
|
||||||
latest_draft_from_remote)
|
.arg(static_cast<int>(latest_draft_from_remote)));
|
||||||
.c_str());
|
|
||||||
return loading_done && !latest_prerelease_version_from_remote &&
|
return loading_done && !latest_prerelease_version_from_remote &&
|
||||||
!latest_draft_from_remote &&
|
!latest_draft_from_remote &&
|
||||||
GFCompareSoftwareVersion(GFModuleStrDup(current_version.toUtf8()),
|
GFCompareSoftwareVersion(GFModuleStrDup(current_version.toUtf8()),
|
||||||
|
@ -31,14 +31,12 @@
|
|||||||
#include <GFSDKBasic.h>
|
#include <GFSDKBasic.h>
|
||||||
#include <GFSDKExtra.h>
|
#include <GFSDKExtra.h>
|
||||||
#include <GFSDKLog.h>
|
#include <GFSDKLog.h>
|
||||||
|
#include <qobject.h>
|
||||||
|
|
||||||
#include <QMetaType>
|
#include <QMetaType>
|
||||||
#include <QtNetwork>
|
#include <QtNetwork>
|
||||||
|
|
||||||
// spdlog
|
#include "GFModuleCommonUtils.hpp"
|
||||||
#include <spdlog/spdlog.h>
|
|
||||||
|
|
||||||
#include "LogFormatter.h"
|
|
||||||
#include "SoftwareVersion.h"
|
#include "SoftwareVersion.h"
|
||||||
#include "VersionCheckingModule.h"
|
#include "VersionCheckingModule.h"
|
||||||
|
|
||||||
@ -50,8 +48,6 @@ VersionCheckTask::VersionCheckTask()
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto VersionCheckTask::Run() -> int {
|
auto VersionCheckTask::Run() -> int {
|
||||||
GFModuleLogDebug(
|
|
||||||
fmt::format("current project version: {}", current_version_).c_str());
|
|
||||||
QString latest_version_url =
|
QString latest_version_url =
|
||||||
"https://api.github.com/repos/saturneric/gpgfrontend/releases/latest";
|
"https://api.github.com/repos/saturneric/gpgfrontend/releases/latest";
|
||||||
|
|
||||||
@ -70,9 +66,8 @@ void VersionCheckTask::slot_parse_latest_version_info() {
|
|||||||
version_.latest_version = current_version_;
|
version_.latest_version = current_version_;
|
||||||
version_.loading_done = false;
|
version_.loading_done = false;
|
||||||
} else if (latest_reply_->error() != QNetworkReply::NoError) {
|
} else if (latest_reply_->error() != QNetworkReply::NoError) {
|
||||||
GFModuleLogError(fmt::format("latest version request error: ",
|
MLogError(QString("latest version request error: %1")
|
||||||
latest_reply_->errorString())
|
.arg(latest_reply_->errorString()));
|
||||||
.c_str());
|
|
||||||
version_.latest_version = current_version_;
|
version_.latest_version = current_version_;
|
||||||
} else {
|
} else {
|
||||||
latest_reply_bytes_ = latest_reply_->readAll();
|
latest_reply_bytes_ = latest_reply_->readAll();
|
||||||
@ -85,15 +80,10 @@ void VersionCheckTask::slot_parse_latest_version_info() {
|
|||||||
auto version_match = re.match(latest_version);
|
auto version_match = re.match(latest_version);
|
||||||
if (version_match.hasMatch()) {
|
if (version_match.hasMatch()) {
|
||||||
latest_version = version_match.captured(0);
|
latest_version = version_match.captured(0);
|
||||||
GFModuleLogInfo(fmt::format("latest released version from github: {}",
|
|
||||||
latest_version)
|
|
||||||
.c_str());
|
|
||||||
} else {
|
} else {
|
||||||
latest_version = current_version_;
|
latest_version = current_version_;
|
||||||
GFModuleLogWarn(
|
MLogWarn(QString("latest version unknown, set to current version: %1")
|
||||||
fmt::format("latest version unknown, set to current version: {}",
|
.arg(current_version_));
|
||||||
current_version_)
|
|
||||||
.c_str());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool prerelease = latest_reply_json["prerelease"].toBool();
|
bool prerelease = latest_reply_json["prerelease"].toBool();
|
||||||
@ -106,9 +96,8 @@ void VersionCheckTask::slot_parse_latest_version_info() {
|
|||||||
version_.publish_date = publish_date;
|
version_.publish_date = publish_date;
|
||||||
version_.release_note = release_note;
|
version_.release_note = release_note;
|
||||||
} else {
|
} else {
|
||||||
GFModuleLogWarn(fmt::format("cannot parse data got from github: {}",
|
MLogWarn(QString("cannot parse data got from github: %1")
|
||||||
latest_reply_bytes_)
|
.arg(latest_reply_bytes_));
|
||||||
.c_str());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -120,9 +109,6 @@ void VersionCheckTask::slot_parse_latest_version_info() {
|
|||||||
QString current_version_url =
|
QString current_version_url =
|
||||||
"https://api.github.com/repos/saturneric/gpgfrontend/releases/tags/" +
|
"https://api.github.com/repos/saturneric/gpgfrontend/releases/tags/" +
|
||||||
current_version_;
|
current_version_;
|
||||||
GFModuleLogDebug(
|
|
||||||
fmt::format("current version info query url: {}", current_version_url)
|
|
||||||
.c_str());
|
|
||||||
|
|
||||||
QNetworkRequest current_request(current_version_url);
|
QNetworkRequest current_request(current_version_url);
|
||||||
current_request.setHeader(QNetworkRequest::UserAgentHeader,
|
current_request.setHeader(QNetworkRequest::UserAgentHeader,
|
||||||
@ -143,9 +129,8 @@ void VersionCheckTask::slot_parse_current_version_info() {
|
|||||||
version_.loading_done = false;
|
version_.loading_done = false;
|
||||||
|
|
||||||
} else if (current_reply_->error() != QNetworkReply::NoError) {
|
} else if (current_reply_->error() != QNetworkReply::NoError) {
|
||||||
GFModuleLogError(fmt::format("current version request network error: {}",
|
MLogError(QString("current version request network error: {}")
|
||||||
current_reply_->errorString())
|
.arg(current_reply_->errorString()));
|
||||||
.c_str());
|
|
||||||
|
|
||||||
// loading done
|
// loading done
|
||||||
version_.loading_done = true;
|
version_.loading_done = true;
|
||||||
@ -163,16 +148,11 @@ void VersionCheckTask::slot_parse_current_version_info() {
|
|||||||
// loading done
|
// loading done
|
||||||
version_.loading_done = true;
|
version_.loading_done = true;
|
||||||
} else {
|
} else {
|
||||||
GFModuleLogWarn(fmt::format("cannot parse data got from github: {}",
|
MLogWarn(QString("cannot parse data got from github: %1")
|
||||||
current_reply_bytes_)
|
.arg(current_reply_bytes_));
|
||||||
.c_str());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GFModuleLogDebug(fmt::format("current version parse done: {}",
|
|
||||||
version_.current_version_publish_in_remote)
|
|
||||||
.c_str());
|
|
||||||
|
|
||||||
if (current_reply_ != nullptr) current_reply_->deleteLater();
|
if (current_reply_ != nullptr) current_reply_->deleteLater();
|
||||||
|
|
||||||
slot_fill_grt_with_version_info(version_);
|
slot_fill_grt_with_version_info(version_);
|
||||||
|
@ -33,7 +33,6 @@
|
|||||||
#include <GFSDKExtra.h>
|
#include <GFSDKExtra.h>
|
||||||
#include <GFSDKLog.h>
|
#include <GFSDKLog.h>
|
||||||
#include <GFSDKUI.h>
|
#include <GFSDKUI.h>
|
||||||
#include <spdlog/spdlog.h>
|
|
||||||
|
|
||||||
#include <QMetaType>
|
#include <QMetaType>
|
||||||
#include <QtNetwork>
|
#include <QtNetwork>
|
||||||
|
2
third_party/CMakeLists.txt
vendored
2
third_party/CMakeLists.txt
vendored
@ -22,5 +22,3 @@
|
|||||||
# Saturneric <eric@bktus.com> starting on May 12, 2021.
|
# Saturneric <eric@bktus.com> starting on May 12, 2021.
|
||||||
#
|
#
|
||||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
add_subdirectory(spdlog EXCLUDE_FROM_ALL)
|
|
1
third_party/spdlog
vendored
1
third_party/spdlog
vendored
@ -1 +0,0 @@
|
|||||||
Subproject commit d276069a6e916b1e1fd45885b15b72bd8ee000a7
|
|
Loading…
Reference in New Issue
Block a user