aboutsummaryrefslogtreecommitdiffstats
path: root/src/m_ver_check
diff options
context:
space:
mode:
authorsaturneric <[email protected]>2024-07-27 09:29:29 +0000
committersaturneric <[email protected]>2024-07-27 09:29:29 +0000
commit12d5852ffe277cb10ad91dde609f86d4b3eb51d6 (patch)
tree71c1a46ce00544536272174c1955ffda783b76a2 /src/m_ver_check
parentfeat: move in GnuPGTab (diff)
downloadModules-12d5852ffe277cb10ad91dde609f86d4b3eb51d6.tar.gz
Modules-12d5852ffe277cb10ad91dde609f86d4b3eb51d6.zip
feat: remove dependency 'spdlog'
Diffstat (limited to 'src/m_ver_check')
-rw-r--r--src/m_ver_check/CMakeLists.txt3
-rw-r--r--src/m_ver_check/QtLoggerFmt.h68
-rw-r--r--src/m_ver_check/SoftwareVersion.cpp58
-rw-r--r--src/m_ver_check/VersionCheckTask.cpp44
-rw-r--r--src/m_ver_check/VersionCheckingModule.cpp1
5 files changed, 23 insertions, 151 deletions
diff --git a/src/m_ver_check/CMakeLists.txt b/src/m_ver_check/CMakeLists.txt
index 58edcd7..69464f8 100644
--- a/src/m_ver_check/CMakeLists.txt
+++ b/src/m_ver_check/CMakeLists.txt
@@ -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")
diff --git a/src/m_ver_check/QtLoggerFmt.h b/src/m_ver_check/QtLoggerFmt.h
deleted file mode 100644
index 2399746..0000000
--- a/src/m_ver_check/QtLoggerFmt.h
+++ /dev/null
@@ -1,68 +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
-
-#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/m_ver_check/SoftwareVersion.cpp b/src/m_ver_check/SoftwareVersion.cpp
index cd86419..a3cd933 100644
--- a/src/m_ver_check/SoftwareVersion.cpp
+++ b/src/m_ver_check/SoftwareVersion.cpp
@@ -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()),
diff --git a/src/m_ver_check/VersionCheckTask.cpp b/src/m_ver_check/VersionCheckTask.cpp
index 3455ddc..5cffb1d 100644
--- a/src/m_ver_check/VersionCheckTask.cpp
+++ b/src/m_ver_check/VersionCheckTask.cpp
@@ -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_);
diff --git a/src/m_ver_check/VersionCheckingModule.cpp b/src/m_ver_check/VersionCheckingModule.cpp
index c28aaaa..947ae75 100644
--- a/src/m_ver_check/VersionCheckingModule.cpp
+++ b/src/m_ver_check/VersionCheckingModule.cpp
@@ -33,7 +33,6 @@
#include <GFSDKExtra.h>
#include <GFSDKLog.h>
#include <GFSDKUI.h>
-#include <spdlog/spdlog.h>
#include <QMetaType>
#include <QtNetwork>