aboutsummaryrefslogtreecommitdiffstats
path: root/src/ver_check
diff options
context:
space:
mode:
Diffstat (limited to 'src/ver_check')
-rw-r--r--src/ver_check/CMakeLists.txt64
-rw-r--r--src/ver_check/GFModuleExport.h42
-rw-r--r--src/ver_check/QtLoggerFmt.h68
-rw-r--r--src/ver_check/SoftwareVersion.cpp100
-rw-r--r--src/ver_check/SoftwareVersion.h83
-rw-r--r--src/ver_check/VersionCheckTask.cpp176
-rw-r--r--src/ver_check/VersionCheckTask.h89
-rw-r--r--src/ver_check/VersionCheckingModule.cpp164
-rw-r--r--src/ver_check/VersionCheckingModule.h56
9 files changed, 0 insertions, 842 deletions
diff --git a/src/ver_check/CMakeLists.txt b/src/ver_check/CMakeLists.txt
deleted file mode 100644
index 30a6faf..0000000
--- a/src/ver_check/CMakeLists.txt
+++ /dev/null
@@ -1,64 +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
-
-# com.bktus.gpgfrontend.module.integrated.version_checking
-
-aux_source_directory(. INTEGRATED_MODULE_SOURCE)
-
-# define libgpgfrontend_module
-add_library(mod_ver_check SHARED ${INTEGRATED_MODULE_SOURCE})
-set(_export_file "${CMAKE_CURRENT_SOURCE_DIR}/GFModuleExport.h")
-generate_export_header(mod_ver_check
- BASE_NAME "GF_MODULE"
- EXPORT_FILE_NAME "${_export_file}")
-
-target_include_directories(mod_ver_check PRIVATE
- ${CMAKE_SOURCE_DIR}/third_party/spdlog/include)
-
-# set output directory
-set_target_properties(mod_ver_check PROPERTIES
- LIBRARY_OUTPUT_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
- RUNTIME_OUTPUT_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
-
-install(TARGETS mod_ver_check
- LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}")
-
-# link sdk
-target_link_libraries(mod_ver_check PRIVATE
- gpgfrontend_module_sdk)
-
-if(GPGFRONTEND_QT5_BUILD)
- # link Qt
- target_link_libraries(mod_ver_check PUBLIC Qt5::Core Qt5::Network)
-else()
- # link Qt
- target_link_libraries(mod_ver_check PUBLIC Qt6::Core Qt6::Network)
-endif()
-
-# property
-set_property(TARGET mod_ver_check PROPERTY AUTOMOC ON)
-
-# using std c++ 17
-target_compile_features(mod_ver_check PRIVATE cxx_std_17) \ No newline at end of file
diff --git a/src/ver_check/GFModuleExport.h b/src/ver_check/GFModuleExport.h
deleted file mode 100644
index ce663b5..0000000
--- a/src/ver_check/GFModuleExport.h
+++ /dev/null
@@ -1,42 +0,0 @@
-
-#ifndef GF_MODULE_EXPORT_H
-#define GF_MODULE_EXPORT_H
-
-#ifdef GF_MODULE_STATIC_DEFINE
-# define GF_MODULE_EXPORT
-# define GF_MODULE_NO_EXPORT
-#else
-# ifndef GF_MODULE_EXPORT
-# ifdef mod_ver_check_EXPORTS
- /* We are building this library */
-# define GF_MODULE_EXPORT __attribute__((visibility("default")))
-# else
- /* We are using this library */
-# define GF_MODULE_EXPORT __attribute__((visibility("default")))
-# endif
-# endif
-
-# ifndef GF_MODULE_NO_EXPORT
-# define GF_MODULE_NO_EXPORT __attribute__((visibility("hidden")))
-# endif
-#endif
-
-#ifndef GF_MODULE_DEPRECATED
-# define GF_MODULE_DEPRECATED __attribute__ ((__deprecated__))
-#endif
-
-#ifndef GF_MODULE_DEPRECATED_EXPORT
-# define GF_MODULE_DEPRECATED_EXPORT GF_MODULE_EXPORT GF_MODULE_DEPRECATED
-#endif
-
-#ifndef GF_MODULE_DEPRECATED_NO_EXPORT
-# define GF_MODULE_DEPRECATED_NO_EXPORT GF_MODULE_NO_EXPORT GF_MODULE_DEPRECATED
-#endif
-
-#if 0 /* DEFINE_NO_DEPRECATED */
-# ifndef GF_MODULE_NO_DEPRECATED
-# define GF_MODULE_NO_DEPRECATED
-# endif
-#endif
-
-#endif /* GF_MODULE_EXPORT_H */
diff --git a/src/ver_check/QtLoggerFmt.h b/src/ver_check/QtLoggerFmt.h
deleted file mode 100644
index 2399746..0000000
--- a/src/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/ver_check/SoftwareVersion.cpp b/src/ver_check/SoftwareVersion.cpp
deleted file mode 100644
index cd86419..0000000
--- a/src/ver_check/SoftwareVersion.cpp
+++ /dev/null
@@ -1,100 +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
- *
- */
-
-#include "SoftwareVersion.h"
-
-#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(
- fmt::format(
- "compair version current {} latest {}, result {}", current_version,
- latest_version,
- GFCompareSoftwareVersion(GFModuleStrDup(current_version.toUtf8()),
- GFModuleStrDup(latest_version.toUtf8())))
- .c_str());
-
- GFModuleLogDebug(fmt::format("load done: {}, pre-release: {}, draft: {}",
- loading_done,
- latest_prerelease_version_from_remote,
- latest_draft_from_remote)
- .c_str());
- return loading_done && !latest_prerelease_version_from_remote &&
- !latest_draft_from_remote &&
- GFCompareSoftwareVersion(GFModuleStrDup(current_version.toUtf8()),
- GFModuleStrDup(latest_version.toUtf8())) < 0;
-}
-
-auto SoftwareVersion::VersionWithdrawn() const -> bool {
- return loading_done && !current_version_publish_in_remote &&
- current_version_is_a_prerelease && !current_version_is_drafted;
-}
-
-auto SoftwareVersion::CurrentVersionReleased() const -> bool {
- return loading_done && current_version_publish_in_remote;
-} \ No newline at end of file
diff --git a/src/ver_check/SoftwareVersion.h b/src/ver_check/SoftwareVersion.h
deleted file mode 100644
index 6b05d41..0000000
--- a/src/ver_check/SoftwareVersion.h
+++ /dev/null
@@ -1,83 +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 <QString>
-
-/**
- * @brief
- *
- */
-struct SoftwareVersion {
- QString latest_version; ///<
- QString current_version; ///<
- bool latest_prerelease_version_from_remote = false; ///<
- bool latest_draft_from_remote = false; ///<
- bool current_version_is_a_prerelease = false; ///<
- bool current_version_is_drafted = false; ///<
- bool loading_done = false; ///<
- bool current_version_publish_in_remote = false; ///<
- QString publish_date; ///<
- QString release_note; ///<
-
- /**
- * @brief
- *
- * @return true
- * @return false
- */
- [[nodiscard]] auto InfoValid() const -> bool { return loading_done; }
-
- /**
- * @brief
- *
- * @return true
- * @return false
- */
- [[nodiscard]] auto NeedUpgrade() const -> bool;
-
- /**
- * @brief
- *
- * @return true
- * @return false
- */
- [[nodiscard]] auto VersionWithdrawn() const -> bool;
-
- /**
- * @brief
- *
- * @return true
- * @return false
- */
- [[nodiscard]] auto CurrentVersionReleased() const -> bool;
-
- private:
- static auto version_compare(const QString& a, const QString& b) -> int;
-};
diff --git a/src/ver_check/VersionCheckTask.cpp b/src/ver_check/VersionCheckTask.cpp
deleted file mode 100644
index a0a3dfe..0000000
--- a/src/ver_check/VersionCheckTask.cpp
+++ /dev/null
@@ -1,176 +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
- *
- */
-
-#include "VersionCheckTask.h"
-
-#include <GFSDKBasic.h>
-#include <GFSDKExtra.h>
-#include <GFSDKLog.h>
-
-#include <QMetaType>
-#include <QtNetwork>
-
-// spdlog
-#include <spdlog/spdlog.h>
-
-#include "LogFormatter.h"
-
-VersionCheckTask::VersionCheckTask()
- : network_manager_(new QNetworkAccessManager(this)),
- current_version_(GFProjectVersion()) {
- qRegisterMetaType<SoftwareVersion>("SoftwareVersion");
- version_.current_version = current_version_;
-}
-
-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";
-
- QNetworkRequest latest_request(latest_version_url);
- latest_request.setHeader(QNetworkRequest::UserAgentHeader,
- GFHttpRequestUserAgent());
-
- latest_reply_ = network_manager_->get(latest_request);
- connect(latest_reply_, &QNetworkReply::finished, this,
- &VersionCheckTask::slot_parse_latest_version_info);
- return 0;
-}
-
-void VersionCheckTask::slot_parse_latest_version_info() {
- if (latest_reply_ == nullptr) {
- 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());
- version_.latest_version = current_version_;
- } else {
- latest_reply_bytes_ = latest_reply_->readAll();
- auto latest_reply_json = QJsonDocument::fromJson(latest_reply_bytes_);
-
- if (latest_reply_json.isObject()) {
- QString latest_version = latest_reply_json["tag_name"].toString();
-
- QRegularExpression re(R"(^[vV](\d+\.)?(\d+\.)?(\*|\d+))");
- 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());
- }
-
- bool prerelease = latest_reply_json["prerelease"].toBool();
- bool draft = latest_reply_json["draft"].toBool();
- auto publish_date = latest_reply_json["published_at"].toString();
- auto release_note = latest_reply_json["body"].toString();
- version_.latest_version = latest_version;
- version_.latest_prerelease_version_from_remote = prerelease;
- version_.latest_draft_from_remote = draft;
- 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());
- }
- }
-
- if (latest_reply_ != nullptr) {
- latest_reply_->deleteLater();
- }
-
- try {
- 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,
- GFHttpRequestUserAgent());
-
- current_reply_ = network_manager_->get(current_request);
-
- connect(current_reply_, &QNetworkReply::finished, this,
- &VersionCheckTask::slot_parse_current_version_info);
- } catch (...) {
- GFModuleLogError("current version request create error");
- }
-}
-
-void VersionCheckTask::slot_parse_current_version_info() {
- if (current_reply_ == nullptr) {
- // loading done
- version_.loading_done = false;
-
- } else if (current_reply_->error() != QNetworkReply::NoError) {
- GFModuleLogError(fmt::format("current version request network error: {}",
- current_reply_->errorString())
- .c_str());
-
- // loading done
- version_.loading_done = true;
- version_.current_version_publish_in_remote = false;
- } else {
- version_.current_version_publish_in_remote = true;
- current_reply_bytes_ = current_reply_->readAll();
- auto current_reply_json = QJsonDocument::fromJson(current_reply_bytes_);
-
- if (current_reply_json.isObject()) {
- bool current_prerelease = current_reply_json["prerelease"].toBool();
- bool current_draft = current_reply_json["draft"].toBool();
- version_.latest_prerelease_version_from_remote = current_prerelease;
- version_.latest_draft_from_remote = current_draft;
- // loading done
- version_.loading_done = true;
- } else {
- GFModuleLogWarn(fmt::format("cannot parse data got from github: {}",
- 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();
- emit SignalUpgradeVersion(version_);
-}
diff --git a/src/ver_check/VersionCheckTask.h b/src/ver_check/VersionCheckTask.h
deleted file mode 100644
index 2d42b36..0000000
--- a/src/ver_check/VersionCheckTask.h
+++ /dev/null
@@ -1,89 +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 <QObject>
-
-#include "SoftwareVersion.h"
-
-class QNetworkReply;
-class QNetworkAccessManager;
-
-/**
- * @brief
- *
- */
-class VersionCheckTask : public QObject {
- Q_OBJECT
- public:
- /**
- * @brief Construct a new Version Check Thread object
- *
- */
- VersionCheckTask();
-
- /**
- * @brief
- *
- * @return int
- */
- auto Run() -> int;
-
- signals:
-
- /**
- * @brief
- *
- * @param version
- */
- void SignalUpgradeVersion(SoftwareVersion version);
-
- private slots:
-
- /**
- * @brief
- *
- */
- void slot_parse_latest_version_info();
-
- /**
- * @brief
- *
- */
- void slot_parse_current_version_info();
-
- private:
- QByteArray latest_reply_bytes_; ///<
- QByteArray current_reply_bytes_; ///<
- QNetworkReply *latest_reply_ = nullptr; ///< latest version info reply
- QNetworkReply *current_reply_ = nullptr; ///< current version info reply
- QNetworkAccessManager *network_manager_; ///<
- QString current_version_;
- SoftwareVersion version_;
-};
diff --git a/src/ver_check/VersionCheckingModule.cpp b/src/ver_check/VersionCheckingModule.cpp
deleted file mode 100644
index 35d3b82..0000000
--- a/src/ver_check/VersionCheckingModule.cpp
+++ /dev/null
@@ -1,164 +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
- *
- */
-
-#include "VersionCheckingModule.h"
-
-#include <GFSDKBasic.h>
-#include <GFSDKBuildInfo.h>
-#include <GFSDKExtra.h>
-#include <GFSDKLog.h>
-#include <spdlog/spdlog.h>
-
-#include <QMetaType>
-#include <QtNetwork>
-
-#include "SoftwareVersion.h"
-#include "VersionCheckTask.h"
-
-extern void VersionCheckDone(const SoftwareVersion& version);
-
-auto GFGetModuleGFSDKVersion() -> const char* {
- return GFModuleStrDup(GF_SDK_VERSION_STR);
-}
-
-auto GFGetModuleQtEnvVersion() -> const char* {
- return GFModuleStrDup(QT_VERSION_STR);
-}
-
-auto GFGetModuleID() -> const char* {
- return GFModuleStrDup("com.bktus.gpgfrontend.module.version_checking");
-}
-
-auto GFGetModuleVersion() -> const char* { return GFModuleStrDup("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 = "VersionChecking";
- p_meta->next = static_cast<GFModuleMetaData*>(
- GFAllocateMemory(sizeof(GFModuleMetaData)));
- p_meta = p_meta->next;
-
- p_meta->key = "Description";
- p_meta->value = "Try checking gpgfrontend version";
- 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 {
- GFModuleLogInfo("version checking module registering");
- return 0;
-}
-
-auto GFActiveModule() -> int {
- GFModuleLogInfo("version checking module activating");
-
- GFModuleListenEvent(GFGetModuleID(), GFModuleStrDup("APPLICATION_LOADED"));
- GFModuleListenEvent(GFGetModuleID(),
- GFModuleStrDup("CHECK_APPLICATION_VERSION"));
- return 0;
-}
-
-auto GFExecuteModule(GFModuleEvent* event) -> int {
- GFModuleLogInfo(
- fmt::format("version checking module executing, event id: {}", event->id)
- .c_str());
-
- auto* task = new VersionCheckTask();
- QObject::connect(
- task, &VersionCheckTask::SignalUpgradeVersion, QThread::currentThread(),
- [event](const SoftwareVersion& version) {
- VersionCheckDone(version);
-
- char** event_argv =
- static_cast<char**>(GFAllocateMemory(sizeof(char**) * 1));
- event_argv[0] = GFModuleStrDup("0");
-
- GFModuleTriggerModuleEventCallback(event, GFGetModuleID(), 1,
- event_argv);
- });
- QObject::connect(task, &VersionCheckTask::SignalUpgradeVersion, task,
- &QObject::deleteLater);
- task->Run();
-
- return 0;
-}
-
-auto GFDeactiveModule() -> int { return 0; }
-
-auto GFUnregisterModule() -> int { return 0; }
-
-void VersionCheckDone(const SoftwareVersion& version) {
- GFModuleLogDebug("filling software information info in rt...");
-
- GFModuleUpsertRTValue(GFGetModuleID(),
- GFModuleStrDup("version.current_version"),
- GFModuleStrDup(version.current_version.toUtf8()));
- GFModuleUpsertRTValue(GFGetModuleID(),
- GFModuleStrDup("version.latest_version"),
- GFModuleStrDup(version.latest_version.toUtf8()));
- GFModuleUpsertRTValueBool(
- GFGetModuleID(), GFModuleStrDup("version.current_version_is_drafted"),
- version.current_version_is_drafted ? 1 : 0);
- GFModuleUpsertRTValueBool(
- GFGetModuleID(),
- GFModuleStrDup("version.current_version_is_a_prerelease"),
- version.current_version_is_a_prerelease ? 1 : 0);
- GFModuleUpsertRTValueBool(
- GFGetModuleID(),
- GFModuleStrDup("version.current_version_publish_in_remote"),
- version.current_version_publish_in_remote ? 1 : 0);
- GFModuleUpsertRTValueBool(
- GFGetModuleID(),
- GFModuleStrDup("version.latest_prerelease_version_from_remote"),
- version.latest_prerelease_version_from_remote ? 1 : 0);
- GFModuleUpsertRTValueBool(GFGetModuleID(),
- GFModuleStrDup("version.need_upgrade"),
- version.NeedUpgrade() ? 1 : 0);
- GFModuleUpsertRTValueBool(GFGetModuleID(),
- GFModuleStrDup("version.current_version_released"),
- version.CurrentVersionReleased() ? 1 : 0);
- GFModuleUpsertRTValueBool(
- GFGetModuleID(), GFModuleStrDup("version.current_a_withdrawn_version"),
- version.VersionWithdrawn() ? 1 : 0);
- GFModuleUpsertRTValueBool(GFGetModuleID(),
- GFModuleStrDup("version.loading_done"),
- version.loading_done ? 1 : 0);
-
- GFModuleLogDebug("software information filled in rt");
-}
diff --git a/src/ver_check/VersionCheckingModule.h b/src/ver_check/VersionCheckingModule.h
deleted file mode 100644
index 35ee4ac..0000000
--- a/src/ver_check/VersionCheckingModule.h
+++ /dev/null
@@ -1,56 +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 <GFSDKModule.h>
-
-#include "GFModuleExport.h"
-
-extern "C" {
-
-auto GF_MODULE_EXPORT GFGetModuleGFSDKVersion() -> const char *;
-
-auto GF_MODULE_EXPORT GFGetModuleQtEnvVersion() -> const char *;
-
-auto GF_MODULE_EXPORT GFGetModuleID() -> const char *;
-
-auto GF_MODULE_EXPORT GFGetModuleVersion() -> const char *;
-
-auto GF_MODULE_EXPORT GFGetModuleMetaData() -> GFModuleMetaData *;
-
-auto GF_MODULE_EXPORT GFRegisterModule() -> int;
-
-auto GF_MODULE_EXPORT GFActiveModule() -> int;
-
-auto GF_MODULE_EXPORT GFExecuteModule(GFModuleEvent *) -> int;
-
-auto GF_MODULE_EXPORT GFDeactiveModule() -> int;
-
-auto GF_MODULE_EXPORT GFUnregisterModule() -> int;
-};