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_DEBUG "-g -fsanitize=address -fsanitize-recover=address")
|
||||
SET (CMAKE_C_FLAGS_DEBUG "-g")
|
||||
SET (CMAKE_C_FLAGS_MINSIZERE "-Os -DNDEBUG")
|
||||
SET (CMAKE_C_FLAGS_RELEASE "-O3 -DNDEBUG")
|
||||
SET (CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 -g")
|
||||
|
||||
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_RELEASE "-O3 -DNDEBUG")
|
||||
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
|
||||
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(TARGETS mod_gpg_info
|
||||
LIBRARY DESTINATION "${CMAKE_INSTALL_PREFIX}/modules")
|
||||
|
@ -31,7 +31,6 @@
|
||||
#include <GFSDKBasic.h>
|
||||
#include <GFSDKBuildInfo.h>
|
||||
#include <GFSDKLog.h>
|
||||
#include <spdlog/spdlog.h>
|
||||
|
||||
// qt
|
||||
#include <QCoreApplication>
|
||||
@ -70,44 +69,26 @@ using Context = struct {
|
||||
};
|
||||
|
||||
auto GFGetModuleGFSDKVersion() -> const char * {
|
||||
return GFModuleStrDup(GF_SDK_VERSION_STR);
|
||||
return DUP(GF_SDK_VERSION_STR);
|
||||
}
|
||||
|
||||
auto GFGetModuleQtEnvVersion() -> const char * {
|
||||
return GFModuleStrDup(QT_VERSION_STR);
|
||||
}
|
||||
auto GFGetModuleQtEnvVersion() -> const char * { return DUP(QT_VERSION_STR); }
|
||||
|
||||
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 *p_meta = static_cast<GFModuleMetaData *>(
|
||||
GFAllocateMemory(sizeof(GFModuleMetaData)));
|
||||
auto *h_meta = p_meta;
|
||||
|
||||
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;
|
||||
return QMapToGFModuleMetaDataList(
|
||||
{{"Name", "GatherGnupgInfo"},
|
||||
{"Description", "Try gathering gnupg informations."},
|
||||
{"Author", "Saturneric"}});
|
||||
}
|
||||
|
||||
auto GFRegisterModule() -> int {
|
||||
GFModuleLogDebug("gnupg info gathering module registering");
|
||||
MLogDebug("gnupg info gathering module registering");
|
||||
|
||||
GFUIMountEntry(DUP("AboutDialogTabs"),
|
||||
QMapToMetaDataArray({{"TabTitle", GTrC::tr("GnuPG")}}), 1,
|
||||
@ -117,9 +98,8 @@ auto GFRegisterModule() -> int {
|
||||
}
|
||||
|
||||
auto GFActiveModule() -> int {
|
||||
GFModuleLogDebug("gnupg info gathering module activating");
|
||||
GFModuleListenEvent(GFGetModuleID(),
|
||||
GFModuleStrDup("REQUEST_GATHERING_GNUPG_INFO"));
|
||||
MLogDebug("gnupg info gathering module activating");
|
||||
GFModuleListenEvent(GFGetModuleID(), DUP("REQUEST_GATHERING_GNUPG_INFO"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -131,40 +111,39 @@ auto GFExecuteModule(GFModuleEvent *event) -> int {
|
||||
|
||||
char **event_argv =
|
||||
static_cast<char **>(GFAllocateMemory(sizeof(char **) * 1));
|
||||
event_argv[0] = GFModuleStrDup("0");
|
||||
event_argv[0] = DUP("0");
|
||||
|
||||
GFModuleTriggerModuleEventCallback(event, GFGetModuleID(), 1, event_argv);
|
||||
|
||||
GFModuleLogDebug("gnupg external info gathering done");
|
||||
MLogDebug("gnupg external info gathering done");
|
||||
return 0;
|
||||
}
|
||||
|
||||
auto GFDeactiveModule() -> int { return 0; }
|
||||
|
||||
auto GFUnregisterModule() -> int {
|
||||
GFModuleLogDebug("gnupg info gathering module unregistering");
|
||||
MLogDebug("gnupg info gathering module unregistering");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
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(
|
||||
GFModuleStrDup("core"), GFModuleStrDup("gpgme.version"),
|
||||
GFModuleStrDup("0.0.0"));
|
||||
DUP("core"), DUP("gpgme.version"), DUP("0.0.0"));
|
||||
MLogDebug(QString("got gpgme version from rt: %1").arg(gpgme_version));
|
||||
|
||||
const auto *const gpgconf_path = GFModuleRetrieveRTValueOrDefault(
|
||||
GFModuleStrDup("core"), GFModuleStrDup("gpgme.ctx.gpgconf_path"),
|
||||
GFModuleStrDup(""));
|
||||
DUP("core"), DUP("gpgme.ctx.gpgconf_path"), DUP(""));
|
||||
MLogDebug(QString("got gpgconf path from rt: %1").arg(gpgconf_path));
|
||||
|
||||
auto context = Context{gpgme_version, gpgconf_path};
|
||||
|
||||
// get all components
|
||||
const char *argv[] = {GFModuleStrDup("--list-components")};
|
||||
const char *argv[] = {DUP("--list-components")};
|
||||
GFExecuteCommandSync(gpgconf_path, 1, argv, GetGpgComponentInfos, &context);
|
||||
GFModuleLogDebug("load gnupg component info done.");
|
||||
MLogDebug("load gnupg component info done.");
|
||||
|
||||
#ifdef QT5_BUILD
|
||||
QVector<GFCommandExecuteContext> exec_contexts;
|
||||
@ -174,14 +153,14 @@ auto StartGatheringGnuPGInfo() -> int {
|
||||
|
||||
const char **argv_0 =
|
||||
static_cast<const char **>(GFAllocateMemory(sizeof(const char *)));
|
||||
argv_0[0] = GFModuleStrDup("--list-dirs");
|
||||
argv_0[0] = DUP("--list-dirs");
|
||||
|
||||
exec_contexts.push_back(
|
||||
{gpgconf_path, 1, argv_0, GetGpgDirectoryInfos, nullptr});
|
||||
|
||||
char **components_c_array;
|
||||
int ret = GFModuleListRTChildKeys(
|
||||
GFGetModuleID(), GFModuleStrDup("gnupg.components"), &components_c_array);
|
||||
int ret = GFModuleListRTChildKeys(GFGetModuleID(), DUP("gnupg.components"),
|
||||
&components_c_array);
|
||||
if (components_c_array == nullptr || ret == 0) return -1;
|
||||
|
||||
QStringList components;
|
||||
@ -191,8 +170,7 @@ auto StartGatheringGnuPGInfo() -> int {
|
||||
for (const auto &component : components) {
|
||||
const auto *component_info_json = GFModuleRetrieveRTValueOrDefault(
|
||||
GFGetModuleID(),
|
||||
GFModuleStrDup(QString("gnupg.components.%1").arg(component).toUtf8()),
|
||||
nullptr);
|
||||
DUP(QString("gnupg.components.%1").arg(component).toUtf8()), nullptr);
|
||||
|
||||
if (component_info_json == nullptr) continue;
|
||||
|
||||
@ -213,16 +191,15 @@ auto StartGatheringGnuPGInfo() -> int {
|
||||
|
||||
const char **argv_0 =
|
||||
static_cast<const char **>(GFAllocateMemory(sizeof(const char *) * 2));
|
||||
argv_0[0] = GFModuleStrDup("--list-options"),
|
||||
argv_0[1] = GFModuleStrDup(component_info.name.toUtf8());
|
||||
argv_0[0] = DUP("--list-options"),
|
||||
argv_0[1] = DUP(component_info.name.toUtf8());
|
||||
exec_contexts.push_back(
|
||||
{gpgconf_path, 2, argv_0, GetGpgOptionInfos, context});
|
||||
}
|
||||
|
||||
GFExecuteCommandBatchSync(static_cast<int32_t>(exec_contexts.size()),
|
||||
exec_contexts.constData());
|
||||
GFModuleUpsertRTValueBool(GFGetModuleID(),
|
||||
GFModuleStrDup("gnupg.gathering_done"), 1);
|
||||
GFModuleUpsertRTValueBool(GFGetModuleID(), DUP("gnupg.gathering_done"), 1);
|
||||
|
||||
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_gpgconf_component_info = c_i_gpgconf.Json();
|
||||
GFModuleUpsertRTValue(
|
||||
GFGetModuleID(), GFModuleStrDup("gnupg.components.gpgme"),
|
||||
GFModuleStrDup(QJsonDocument(jsonlized_gpgme_component_info).toJson()));
|
||||
GFGetModuleID(), DUP("gnupg.components.gpgme"),
|
||||
DUP(QJsonDocument(jsonlized_gpgme_component_info).toJson()));
|
||||
GFModuleUpsertRTValue(
|
||||
GFGetModuleID(), GFModuleStrDup("gnupg.components.gpgconf"),
|
||||
GFModuleStrDup(QJsonDocument(jsonlized_gpgconf_component_info).toJson()));
|
||||
GFGetModuleID(), DUP("gnupg.components.gpgconf"),
|
||||
DUP(QJsonDocument(jsonlized_gpgconf_component_info).toJson()));
|
||||
|
||||
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") {
|
||||
version = GFModuleRetrieveRTValueOrDefault(
|
||||
GFModuleStrDup("core"), GFModuleStrDup("gpgme.ctx.gnupg_version"),
|
||||
GFModuleStrDup("2.0.0"));
|
||||
DUP("core"), DUP("gpgme.ctx.gnupg_version"), DUP("2.0.0"));
|
||||
}
|
||||
if (component_name == "gpg-agent") {
|
||||
GFModuleUpsertRTValue(GFGetModuleID(),
|
||||
GFModuleStrDup("gnupg.gpg_agent_path"),
|
||||
GFModuleStrDup(QString(component_path).toUtf8()));
|
||||
GFModuleUpsertRTValue(GFGetModuleID(), DUP("gnupg.gpg_agent_path"),
|
||||
DUP(QString(component_path).toUtf8()));
|
||||
}
|
||||
if (component_name == "dirmngr") {
|
||||
GFModuleUpsertRTValue(GFGetModuleID(),
|
||||
GFModuleStrDup("gnupg.dirmngr_path"),
|
||||
GFModuleStrDup(QString(component_path).toUtf8()));
|
||||
GFModuleUpsertRTValue(GFGetModuleID(), DUP("gnupg.dirmngr_path"),
|
||||
DUP(QString(component_path).toUtf8()));
|
||||
}
|
||||
if (component_name == "keyboxd") {
|
||||
GFModuleUpsertRTValue(GFGetModuleID(),
|
||||
GFModuleStrDup("gnupg.keyboxd_path"),
|
||||
GFModuleStrDup(QString(component_path).toUtf8()));
|
||||
GFModuleUpsertRTValue(GFGetModuleID(), DUP("gnupg.keyboxd_path"),
|
||||
DUP(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();
|
||||
GFModuleUpsertRTValue(
|
||||
GFGetModuleID(),
|
||||
GFModuleStrDup(
|
||||
QString("gnupg.components.%1").arg(component_name).toUtf8()),
|
||||
GFModuleStrDup(QJsonDocument(jsonlized_component_info).toJson()));
|
||||
DUP(QString("gnupg.components.%1").arg(component_name).toUtf8()),
|
||||
DUP(QJsonDocument(jsonlized_component_info).toJson()));
|
||||
|
||||
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
|
||||
if (configuration_name == "homedir") {
|
||||
GFModuleUpsertRTValue(GFGetModuleID(), GFModuleStrDup("gnupg.home_path"),
|
||||
GFModuleStrDup(configuration_value.toUtf8()));
|
||||
GFModuleUpsertRTValue(GFGetModuleID(), DUP("gnupg.home_path"),
|
||||
DUP(configuration_value.toUtf8()));
|
||||
}
|
||||
|
||||
GFModuleUpsertRTValue(
|
||||
GFGetModuleID(),
|
||||
GFModuleStrDup(
|
||||
QString("gnupg.dirs.%1").arg(configuration_name).toUtf8()),
|
||||
GFModuleStrDup(configuration_value.toUtf8()));
|
||||
DUP(QString("gnupg.dirs.%1").arg(configuration_name).toUtf8()),
|
||||
DUP(configuration_value.toUtf8()));
|
||||
}
|
||||
}
|
||||
|
||||
@ -485,13 +456,12 @@ void GetGpgOptionInfos(void *data, int exit_code, const char *out,
|
||||
info.value = option_value;
|
||||
|
||||
auto const jsonlized_option_info = info.Json();
|
||||
GFModuleUpsertRTValue(
|
||||
GFGetModuleID(),
|
||||
GFModuleStrDup(QString("gnupg.components.%1.options.%2")
|
||||
GFModuleUpsertRTValue(GFGetModuleID(),
|
||||
DUP(QString("gnupg.components.%1.options.%2")
|
||||
.arg(component_name)
|
||||
.arg(option_name)
|
||||
.toUtf8()),
|
||||
GFModuleStrDup(QJsonDocument(jsonlized_option_info).toJson()));
|
||||
DUP(QJsonDocument(jsonlized_option_info).toJson()));
|
||||
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
|
||||
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(TARGETS mod_ver_check
|
||||
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 <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());
|
||||
}
|
||||
};
|
||||
#include "GFModuleCommonUtils.hpp"
|
||||
|
||||
auto SoftwareVersion::NeedUpgrade() const -> bool {
|
||||
GFModuleLogDebug(
|
||||
fmt::format(
|
||||
"compair version current {} latest {}, result {}", current_version,
|
||||
latest_version,
|
||||
GFCompareSoftwareVersion(GFModuleStrDup(current_version.toUtf8()),
|
||||
GFModuleStrDup(latest_version.toUtf8())))
|
||||
.c_str());
|
||||
MLogDebug(QString("compare version current: %1 latest %2, result: %3")
|
||||
.arg(current_version)
|
||||
.arg(latest_version)
|
||||
.arg(GFCompareSoftwareVersion(
|
||||
GFModuleStrDup(current_version.toUtf8()),
|
||||
GFModuleStrDup(latest_version.toUtf8()))));
|
||||
|
||||
GFModuleLogDebug(fmt::format("load done: {}, pre-release: {}, draft: {}",
|
||||
loading_done,
|
||||
latest_prerelease_version_from_remote,
|
||||
latest_draft_from_remote)
|
||||
.c_str());
|
||||
MLogDebug(QString("load done: %1, pre-release: %2, draft: %3")
|
||||
.arg(static_cast<int>(loading_done))
|
||||
.arg(static_cast<int>(latest_prerelease_version_from_remote))
|
||||
.arg(static_cast<int>(latest_draft_from_remote)));
|
||||
return loading_done && !latest_prerelease_version_from_remote &&
|
||||
!latest_draft_from_remote &&
|
||||
GFCompareSoftwareVersion(GFModuleStrDup(current_version.toUtf8()),
|
||||
|
@ -31,14 +31,12 @@
|
||||
#include <GFSDKBasic.h>
|
||||
#include <GFSDKExtra.h>
|
||||
#include <GFSDKLog.h>
|
||||
#include <qobject.h>
|
||||
|
||||
#include <QMetaType>
|
||||
#include <QtNetwork>
|
||||
|
||||
// spdlog
|
||||
#include <spdlog/spdlog.h>
|
||||
|
||||
#include "LogFormatter.h"
|
||||
#include "GFModuleCommonUtils.hpp"
|
||||
#include "SoftwareVersion.h"
|
||||
#include "VersionCheckingModule.h"
|
||||
|
||||
@ -50,8 +48,6 @@ VersionCheckTask::VersionCheckTask()
|
||||
}
|
||||
|
||||
auto VersionCheckTask::Run() -> int {
|
||||
GFModuleLogDebug(
|
||||
fmt::format("current project version: {}", current_version_).c_str());
|
||||
QString latest_version_url =
|
||||
"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_.loading_done = false;
|
||||
} else if (latest_reply_->error() != QNetworkReply::NoError) {
|
||||
GFModuleLogError(fmt::format("latest version request error: ",
|
||||
latest_reply_->errorString())
|
||||
.c_str());
|
||||
MLogError(QString("latest version request error: %1")
|
||||
.arg(latest_reply_->errorString()));
|
||||
version_.latest_version = current_version_;
|
||||
} else {
|
||||
latest_reply_bytes_ = latest_reply_->readAll();
|
||||
@ -85,15 +80,10 @@ void VersionCheckTask::slot_parse_latest_version_info() {
|
||||
auto version_match = re.match(latest_version);
|
||||
if (version_match.hasMatch()) {
|
||||
latest_version = version_match.captured(0);
|
||||
GFModuleLogInfo(fmt::format("latest released version from github: {}",
|
||||
latest_version)
|
||||
.c_str());
|
||||
} else {
|
||||
latest_version = current_version_;
|
||||
GFModuleLogWarn(
|
||||
fmt::format("latest version unknown, set to current version: {}",
|
||||
current_version_)
|
||||
.c_str());
|
||||
MLogWarn(QString("latest version unknown, set to current version: %1")
|
||||
.arg(current_version_));
|
||||
}
|
||||
|
||||
bool prerelease = latest_reply_json["prerelease"].toBool();
|
||||
@ -106,9 +96,8 @@ void VersionCheckTask::slot_parse_latest_version_info() {
|
||||
version_.publish_date = publish_date;
|
||||
version_.release_note = release_note;
|
||||
} else {
|
||||
GFModuleLogWarn(fmt::format("cannot parse data got from github: {}",
|
||||
latest_reply_bytes_)
|
||||
.c_str());
|
||||
MLogWarn(QString("cannot parse data got from github: %1")
|
||||
.arg(latest_reply_bytes_));
|
||||
}
|
||||
}
|
||||
|
||||
@ -120,9 +109,6 @@ void VersionCheckTask::slot_parse_latest_version_info() {
|
||||
QString current_version_url =
|
||||
"https://api.github.com/repos/saturneric/gpgfrontend/releases/tags/" +
|
||||
current_version_;
|
||||
GFModuleLogDebug(
|
||||
fmt::format("current version info query url: {}", current_version_url)
|
||||
.c_str());
|
||||
|
||||
QNetworkRequest current_request(current_version_url);
|
||||
current_request.setHeader(QNetworkRequest::UserAgentHeader,
|
||||
@ -143,9 +129,8 @@ void VersionCheckTask::slot_parse_current_version_info() {
|
||||
version_.loading_done = false;
|
||||
|
||||
} else if (current_reply_->error() != QNetworkReply::NoError) {
|
||||
GFModuleLogError(fmt::format("current version request network error: {}",
|
||||
current_reply_->errorString())
|
||||
.c_str());
|
||||
MLogError(QString("current version request network error: {}")
|
||||
.arg(current_reply_->errorString()));
|
||||
|
||||
// loading done
|
||||
version_.loading_done = true;
|
||||
@ -163,16 +148,11 @@ void VersionCheckTask::slot_parse_current_version_info() {
|
||||
// loading done
|
||||
version_.loading_done = true;
|
||||
} else {
|
||||
GFModuleLogWarn(fmt::format("cannot parse data got from github: {}",
|
||||
current_reply_bytes_)
|
||||
.c_str());
|
||||
MLogWarn(QString("cannot parse data got from github: %1")
|
||||
.arg(current_reply_bytes_));
|
||||
}
|
||||
}
|
||||
|
||||
GFModuleLogDebug(fmt::format("current version parse done: {}",
|
||||
version_.current_version_publish_in_remote)
|
||||
.c_str());
|
||||
|
||||
if (current_reply_ != nullptr) current_reply_->deleteLater();
|
||||
|
||||
slot_fill_grt_with_version_info(version_);
|
||||
|
@ -33,7 +33,6 @@
|
||||
#include <GFSDKExtra.h>
|
||||
#include <GFSDKLog.h>
|
||||
#include <GFSDKUI.h>
|
||||
#include <spdlog/spdlog.h>
|
||||
|
||||
#include <QMetaType>
|
||||
#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.
|
||||
#
|
||||
# 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