feat: try using ui and i18n apis from sdk
This commit is contained in:
parent
2003507822
commit
96e4c85edc
@ -74,11 +74,11 @@ link_directories(
|
|||||||
if(GPGFRONTEND_QT5_BUILD)
|
if(GPGFRONTEND_QT5_BUILD)
|
||||||
# Introduce Qt
|
# Introduce Qt
|
||||||
# Support Qt version: 5.15.x
|
# Support Qt version: 5.15.x
|
||||||
find_package(Qt5 5.15 COMPONENTS Core Widgets PrintSupport Network LinguistTools REQUIRED)
|
find_package(Qt5 5.15 COMPONENTS Core Widgets Network LinguistTools REQUIRED)
|
||||||
else()
|
else()
|
||||||
# Introduce Qt
|
# Introduce Qt
|
||||||
# Support Qt version: 6.x
|
# Support Qt version: 6.x
|
||||||
find_package(Qt6 6 COMPONENTS Core Widgets PrintSupport Network LinguistTools REQUIRED)
|
find_package(Qt6 6 COMPONENTS Core Widgets Network LinguistTools REQUIRED)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Qt configuration
|
# Qt configuration
|
||||||
@ -87,6 +87,18 @@ set(CMAKE_AUTORCC ON)
|
|||||||
set(CMAKE_AUTOUIC ON)
|
set(CMAKE_AUTOUIC ON)
|
||||||
set(CMAKE_AUTORCC_OPTIONS "--compress;9")
|
set(CMAKE_AUTORCC_OPTIONS "--compress;9")
|
||||||
|
|
||||||
|
# rpath config
|
||||||
|
if (WIN32)
|
||||||
|
message(STATUS "Configuring for Windows without rpath")
|
||||||
|
elseif (APPLE)
|
||||||
|
set(CMAKE_MACOSX_RPATH 1)
|
||||||
|
set(CMAKE_INSTALL_RPATH "@loader_path/../lib")
|
||||||
|
else()
|
||||||
|
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
|
||||||
|
set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
|
||||||
|
set(CMAKE_INSTALL_RPATH "$ORIGIN:$ORIGIN/../lib")
|
||||||
|
endif()
|
||||||
|
|
||||||
# third_party
|
# third_party
|
||||||
add_subdirectory(third_party)
|
add_subdirectory(third_party)
|
||||||
|
|
||||||
|
112
include/GFModuleCommonUtils.hpp
Normal file
112
include/GFModuleCommonUtils.hpp
Normal file
@ -0,0 +1,112 @@
|
|||||||
|
/**
|
||||||
|
* 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 <GFSDKUI.h>
|
||||||
|
|
||||||
|
#include <QMap>
|
||||||
|
#include <QString>
|
||||||
|
#include <cstring>
|
||||||
|
|
||||||
|
#include "GFSDKBasic.h"
|
||||||
|
#include "GFSDKLog.h"
|
||||||
|
#include "GFSDKModule.h"
|
||||||
|
|
||||||
|
#define DUP(v) GFModuleStrDup(v)
|
||||||
|
|
||||||
|
inline void MLogDebug(const QString& s) { GFModuleLogDebug(s.toUtf8()); }
|
||||||
|
inline void MLogInfo(const QString& s) { GFModuleLogInfo(s.toUtf8()); }
|
||||||
|
inline void MLogWarn(const QString& s) { GFModuleLogWarn(s.toUtf8()); }
|
||||||
|
inline void MLogError(const QString& s) { GFModuleLogError(s.toUtf8()); }
|
||||||
|
|
||||||
|
#define MLogDebugS(format, ...) \
|
||||||
|
MLogDebug(QString::asprintf(format, __VA_ARGS__))
|
||||||
|
#define MLogInfoS(format, ...) MLogInfo(QString::asprintf(format, __VA_ARGS__))
|
||||||
|
#define MLogWarnS(format, ...) MLogWarn(QString::asprintf(format, __VA_ARGS__))
|
||||||
|
#define MLogErrorS(format, ...) \
|
||||||
|
MLogError(QString::asprintf(format, __VA_ARGS__))
|
||||||
|
|
||||||
|
auto QMapToMetaDataArray(const QMap<QString, QString>& map) -> MetaData** {
|
||||||
|
auto** meta_data_array =
|
||||||
|
static_cast<MetaData**>(GFAllocateMemory(sizeof(MetaData*) * map.size()));
|
||||||
|
|
||||||
|
int index = 0;
|
||||||
|
for (auto it = map.begin(); it != map.end(); ++it) {
|
||||||
|
meta_data_array[index] =
|
||||||
|
static_cast<MetaData*>(GFAllocateMemory(sizeof(MetaData)));
|
||||||
|
|
||||||
|
QByteArray const key = it.key().toUtf8();
|
||||||
|
QByteArray const value = it.value().toUtf8();
|
||||||
|
|
||||||
|
meta_data_array[index]->key = GFModuleStrDup(key);
|
||||||
|
|
||||||
|
meta_data_array[index]->value = GFModuleStrDup(value);
|
||||||
|
|
||||||
|
++index;
|
||||||
|
}
|
||||||
|
|
||||||
|
return meta_data_array;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto QMapToGFModuleMetaDataList(const QMap<QString, QString>& map)
|
||||||
|
-> GFModuleMetaData* {
|
||||||
|
GFModuleMetaData* head = nullptr;
|
||||||
|
GFModuleMetaData* tail = nullptr;
|
||||||
|
|
||||||
|
for (auto it = map.begin(); it != map.end(); ++it) {
|
||||||
|
auto* new_node = static_cast<GFModuleMetaData*>(
|
||||||
|
GFAllocateMemory(sizeof(GFModuleMetaData)));
|
||||||
|
|
||||||
|
QByteArray const key = it.key().toUtf8();
|
||||||
|
QByteArray const value = it.value().toUtf8();
|
||||||
|
|
||||||
|
new_node->key = new char[key.size() + 1];
|
||||||
|
std::strcpy(const_cast<char*>(new_node->key), key.constData());
|
||||||
|
|
||||||
|
new_node->value = new char[value.size() + 1];
|
||||||
|
std::strcpy(const_cast<char*>(new_node->value), value.constData());
|
||||||
|
|
||||||
|
new_node->next = nullptr;
|
||||||
|
|
||||||
|
if (tail != nullptr) {
|
||||||
|
tail->next = new_node;
|
||||||
|
} else {
|
||||||
|
head = new_node;
|
||||||
|
}
|
||||||
|
tail = new_node;
|
||||||
|
}
|
||||||
|
|
||||||
|
return head;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto AllocBufferAndCopy(const QByteArray& b) -> char* {
|
||||||
|
auto* p = static_cast<char*>(GFAllocateMemory(sizeof(char) * b.size()));
|
||||||
|
memcpy(p, b.constData(), b.size());
|
||||||
|
return p;
|
||||||
|
}
|
@ -7,7 +7,7 @@
|
|||||||
# define GF_MODULE_NO_EXPORT
|
# define GF_MODULE_NO_EXPORT
|
||||||
#else
|
#else
|
||||||
# ifndef GF_MODULE_EXPORT
|
# ifndef GF_MODULE_EXPORT
|
||||||
# ifdef mod_gpg_info_EXPORTS
|
# ifdef GF_MODULE_EXPORTS
|
||||||
/* We are building this library */
|
/* We are building this library */
|
||||||
# define GF_MODULE_EXPORT __attribute__((visibility("default")))
|
# define GF_MODULE_EXPORT __attribute__((visibility("default")))
|
||||||
# else
|
# else
|
@ -24,5 +24,5 @@
|
|||||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
# modules
|
# modules
|
||||||
add_subdirectory(ver_check)
|
add_subdirectory(m_ver_check)
|
||||||
add_subdirectory(gpg_info)
|
add_subdirectory(m_gpg_info)
|
@ -29,22 +29,13 @@ 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})
|
||||||
set(_export_file "${CMAKE_CURRENT_SOURCE_DIR}/GFModuleExport.h")
|
|
||||||
generate_export_header(mod_gpg_info
|
|
||||||
BASE_NAME "GF_MODULE"
|
|
||||||
EXPORT_FILE_NAME "${_export_file}")
|
|
||||||
|
|
||||||
target_include_directories(mod_gpg_info PRIVATE
|
target_include_directories(mod_gpg_info PRIVATE
|
||||||
${CMAKE_SOURCE_DIR}/third_party/spdlog/include)
|
${CMAKE_SOURCE_DIR}/third_party/spdlog/include)
|
||||||
|
|
||||||
# set output directory
|
|
||||||
set_target_properties(mod_gpg_info PROPERTIES
|
|
||||||
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
|
|
||||||
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
|
|
||||||
|
|
||||||
# install dir
|
# install dir
|
||||||
install(TARGETS mod_gpg_info
|
install(TARGETS mod_gpg_info
|
||||||
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}")
|
LIBRARY DESTINATION "${CMAKE_INSTALL_PREFIX}/modules")
|
||||||
|
|
||||||
# link sdk
|
# link sdk
|
||||||
target_link_libraries(mod_gpg_info PRIVATE
|
target_link_libraries(mod_gpg_info PRIVATE
|
||||||
@ -58,8 +49,8 @@ else()
|
|||||||
target_link_libraries(mod_gpg_info PRIVATE Qt6::Core)
|
target_link_libraries(mod_gpg_info PRIVATE Qt6::Core)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# property
|
|
||||||
set_property(TARGET mod_gpg_info PROPERTY AUTOMOC ON)
|
|
||||||
|
|
||||||
# using std c++ 17
|
# using std c++ 17
|
||||||
target_compile_features(mod_gpg_info PRIVATE cxx_std_17)
|
target_compile_features(mod_gpg_info PRIVATE cxx_std_17)
|
||||||
|
|
||||||
|
# ui
|
||||||
|
set(CMAKE_AUTOUIC_SEARCH_PATHS ${CMAKE_AUTOUIC_SEARCH_PATHS} ${CMAKE_CURRENT_SOURCE_DIR}/ui)
|
@ -25,25 +25,17 @@
|
|||||||
|
|
||||||
# com.bktus.gpgfrontend.module.integrated.version_checking
|
# com.bktus.gpgfrontend.module.integrated.version_checking
|
||||||
|
|
||||||
aux_source_directory(. INTEGRATED_MODULE_SOURCE)
|
aux_source_directory(. MODULE_SOURCE_FILES)
|
||||||
|
|
||||||
# define libgpgfrontend_module
|
# define libgpgfrontend_module
|
||||||
add_library(mod_ver_check SHARED ${INTEGRATED_MODULE_SOURCE})
|
add_library(mod_ver_check SHARED ${MODULE_SOURCE_FILES})
|
||||||
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
|
target_include_directories(mod_ver_check PRIVATE
|
||||||
${CMAKE_SOURCE_DIR}/third_party/spdlog/include)
|
${CMAKE_SOURCE_DIR}/third_party/spdlog/include)
|
||||||
|
|
||||||
# set output directory
|
# install dir
|
||||||
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
|
install(TARGETS mod_ver_check
|
||||||
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}")
|
LIBRARY DESTINATION "${CMAKE_INSTALL_PREFIX}/modules")
|
||||||
|
|
||||||
# link sdk
|
# link sdk
|
||||||
target_link_libraries(mod_ver_check PRIVATE
|
target_link_libraries(mod_ver_check PRIVATE
|
||||||
@ -51,14 +43,26 @@ target_link_libraries(mod_ver_check PRIVATE
|
|||||||
|
|
||||||
if(GPGFRONTEND_QT5_BUILD)
|
if(GPGFRONTEND_QT5_BUILD)
|
||||||
# link Qt
|
# link Qt
|
||||||
target_link_libraries(mod_ver_check PUBLIC Qt5::Core Qt5::Network)
|
target_link_libraries(mod_ver_check PUBLIC Qt5::Core Qt5::Network Qt5::Widgets)
|
||||||
else()
|
else()
|
||||||
# link Qt
|
# link Qt
|
||||||
target_link_libraries(mod_ver_check PUBLIC Qt6::Core Qt6::Network)
|
target_link_libraries(mod_ver_check PUBLIC Qt6::Core Qt6::Network Qt6::Widgets)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# property
|
|
||||||
set_property(TARGET mod_ver_check PROPERTY AUTOMOC ON)
|
|
||||||
|
|
||||||
# using std c++ 17
|
# using std c++ 17
|
||||||
target_compile_features(mod_ver_check PRIVATE cxx_std_17)
|
target_compile_features(mod_ver_check PRIVATE cxx_std_17)
|
||||||
|
|
||||||
|
# ui
|
||||||
|
set(CMAKE_AUTOUIC_SEARCH_PATHS ${CMAKE_AUTOUIC_SEARCH_PATHS} ${CMAKE_CURRENT_SOURCE_DIR}/ui)
|
||||||
|
|
||||||
|
# i18n
|
||||||
|
set(LOCALE_TS_PATH ${CMAKE_CURRENT_SOURCE_DIR}/ts)
|
||||||
|
set(TS_FILES "${LOCALE_TS_PATH}/ModuleVersionChecking.en_US.ts"
|
||||||
|
"${LOCALE_TS_PATH}/ModuleVersionChecking.de_DE.ts"
|
||||||
|
"${LOCALE_TS_PATH}/ModuleVersionChecking.fr_FR.ts"
|
||||||
|
"${LOCALE_TS_PATH}/ModuleVersionChecking.zh_CN.ts")
|
||||||
|
qt_add_translations(mod_ver_check
|
||||||
|
RESOURCE_PREFIX "/i18n"
|
||||||
|
TS_FILES ${TS_FILES}
|
||||||
|
SOURCES ${MODULE_SOURCE_FILES}
|
||||||
|
INCLUDE_DIRECTORIES ${CMAKE_CURRENT_SOURCE_DIR})
|
171
src/m_ver_check/UpdateTab.cpp
Normal file
171
src/m_ver_check/UpdateTab.cpp
Normal file
@ -0,0 +1,171 @@
|
|||||||
|
/**
|
||||||
|
* 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
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "UpdateTab.h"
|
||||||
|
|
||||||
|
#include "GFSDKBasic.h"
|
||||||
|
#include "GFSDKLog.h"
|
||||||
|
#include "GFSDKModule.h"
|
||||||
|
#include "VersionCheckTask.h"
|
||||||
|
#include "VersionCheckingModule.h"
|
||||||
|
|
||||||
|
UpdateTab::UpdateTab(QWidget* parent) : QWidget(parent) {
|
||||||
|
auto* layout = new QGridLayout();
|
||||||
|
|
||||||
|
current_version_ = GFProjectVersion();
|
||||||
|
|
||||||
|
auto* tips_label = new QLabel();
|
||||||
|
tips_label->setText(
|
||||||
|
"<center>" +
|
||||||
|
tr("It is recommended that you always check the version "
|
||||||
|
"of GpgFrontend and upgrade to the latest version.") +
|
||||||
|
"</center><center>" +
|
||||||
|
tr("New versions not only represent new features, but "
|
||||||
|
"also often represent functional and security fixes.") +
|
||||||
|
"</center>");
|
||||||
|
tips_label->setWordWrap(true);
|
||||||
|
|
||||||
|
current_version_label_ = new QLabel();
|
||||||
|
current_version_label_->setText("<center>" + tr("Current Version") +
|
||||||
|
tr(": ") + "<b>" + current_version_ +
|
||||||
|
"</b></center>");
|
||||||
|
current_version_label_->setWordWrap(true);
|
||||||
|
|
||||||
|
latest_version_label_ = new QLabel();
|
||||||
|
latest_version_label_->setWordWrap(true);
|
||||||
|
|
||||||
|
upgrade_label_ = new QLabel();
|
||||||
|
upgrade_label_->setWordWrap(true);
|
||||||
|
upgrade_label_->setOpenExternalLinks(true);
|
||||||
|
upgrade_label_->setHidden(true);
|
||||||
|
|
||||||
|
pb_ = new QProgressBar();
|
||||||
|
pb_->setRange(0, 0);
|
||||||
|
pb_->setTextVisible(false);
|
||||||
|
|
||||||
|
layout->addWidget(tips_label, 1, 0, 1, -1);
|
||||||
|
layout->addWidget(current_version_label_, 2, 0, 1, -1);
|
||||||
|
layout->addWidget(latest_version_label_, 3, 0, 1, -1);
|
||||||
|
layout->addWidget(upgrade_label_, 4, 0, 1, -1);
|
||||||
|
layout->addWidget(pb_, 5, 0, 1, -1);
|
||||||
|
layout->addItem(
|
||||||
|
new QSpacerItem(20, 10, QSizePolicy::Minimum, QSizePolicy::Fixed), 2, 1,
|
||||||
|
1, 1);
|
||||||
|
|
||||||
|
setLayout(layout);
|
||||||
|
}
|
||||||
|
|
||||||
|
void UpdateTab::showEvent(QShowEvent* event) {
|
||||||
|
QWidget::showEvent(event);
|
||||||
|
GFModuleLogDebug("loading version loading info from rt");
|
||||||
|
|
||||||
|
auto is_loading_done = GFModuleRetrieveRTValueOrDefaultBool(
|
||||||
|
GFGetModuleID(), GFModuleStrDup("version.loading_done"), 0);
|
||||||
|
|
||||||
|
if (is_loading_done == 0) {
|
||||||
|
auto* task = new VersionCheckTask();
|
||||||
|
QObject::connect(
|
||||||
|
task, &VersionCheckTask::SignalUpgradeVersion, QThread::currentThread(),
|
||||||
|
[this](const SoftwareVersion&) { slot_show_version_status(); });
|
||||||
|
QObject::connect(task, &VersionCheckTask::SignalUpgradeVersion, task,
|
||||||
|
&QObject::deleteLater);
|
||||||
|
task->Run();
|
||||||
|
|
||||||
|
} else {
|
||||||
|
slot_show_version_status();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void UpdateTab::slot_show_version_status() {
|
||||||
|
GFModuleLogDebug("loading version info from rt");
|
||||||
|
this->pb_->setHidden(true);
|
||||||
|
|
||||||
|
auto is_loading_done = GFModuleRetrieveRTValueOrDefaultBool(
|
||||||
|
GFGetModuleID(), GFModuleStrDup("version.loading_done"), 0);
|
||||||
|
|
||||||
|
if (is_loading_done == 0) {
|
||||||
|
GFModuleLogDebug("version info loading haven't been done yet.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto is_need_upgrade = GFModuleRetrieveRTValueOrDefaultBool(
|
||||||
|
GFGetModuleID(), GFModuleStrDup("version.need_upgrade"), 0);
|
||||||
|
|
||||||
|
auto is_current_a_withdrawn_version = GFModuleRetrieveRTValueOrDefaultBool(
|
||||||
|
GFGetModuleID(), GFModuleStrDup("version.current_a_withdrawn_version"),
|
||||||
|
0);
|
||||||
|
|
||||||
|
auto is_current_version_released = GFModuleRetrieveRTValueOrDefaultBool(
|
||||||
|
GFGetModuleID(), GFModuleStrDup("version.current_version_released"), 0);
|
||||||
|
|
||||||
|
QString const latest_version = GFModuleRetrieveRTValueOrDefault(
|
||||||
|
GFGetModuleID(), GFModuleStrDup("version.latest_version"),
|
||||||
|
GFModuleStrDup(""));
|
||||||
|
|
||||||
|
latest_version_label_->setText("<center><b>" +
|
||||||
|
tr("Latest Version From Github") + ": " +
|
||||||
|
latest_version + "</b></center>");
|
||||||
|
|
||||||
|
if (is_need_upgrade != 0) {
|
||||||
|
upgrade_label_->setText(
|
||||||
|
"<center>" +
|
||||||
|
tr("The current version is less than the latest version on "
|
||||||
|
"github.") +
|
||||||
|
"</center><center>" + tr("Please click") +
|
||||||
|
" <a "
|
||||||
|
"href=\"https://www.gpgfrontend.bktus.com/#/downloads\">" +
|
||||||
|
tr("Here") + "</a> " + tr("to download the latest stable version.") +
|
||||||
|
"</center>");
|
||||||
|
upgrade_label_->show();
|
||||||
|
} else if (is_current_a_withdrawn_version != 0) {
|
||||||
|
upgrade_label_->setText(
|
||||||
|
"<center>" +
|
||||||
|
tr("This version has serious problems and has been withdrawn. "
|
||||||
|
"Please stop using it immediately.") +
|
||||||
|
"</center><center>" + tr("Please click") +
|
||||||
|
" <a "
|
||||||
|
"href=\"https://github.com/saturneric/GpgFrontend/releases\">" +
|
||||||
|
tr("Here") + "</a> " + tr("to download the latest stable version.") +
|
||||||
|
"</center>");
|
||||||
|
upgrade_label_->show();
|
||||||
|
} else if (is_current_version_released == 0) {
|
||||||
|
upgrade_label_->setText(
|
||||||
|
"<center>" +
|
||||||
|
tr("This version has not been released yet, it may be a beta "
|
||||||
|
"version. If you are not a tester and care about version "
|
||||||
|
"stability, please do not use this version.") +
|
||||||
|
"</center><center>" + tr("Please click") +
|
||||||
|
" <a "
|
||||||
|
"href=\"https://www.gpgfrontend.bktus.com/#/downloads\">" +
|
||||||
|
tr("Here") + "</a> " + tr("to download the latest stable version.") +
|
||||||
|
"</center>");
|
||||||
|
upgrade_label_->show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
auto UpdateTabFactory(const char* id) -> void* { return new UpdateTab(); }
|
74
src/m_ver_check/UpdateTab.h
Normal file
74
src/m_ver_check/UpdateTab.h
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
/**
|
||||||
|
* 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 <QtWidgets/QtWidgets>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Class containing the main tab of about dialog
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
class UpdateTab : public QWidget {
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
QLabel* current_version_label_; ///<
|
||||||
|
QLabel* latest_version_label_; ///<
|
||||||
|
QLabel* upgrade_label_; ///<
|
||||||
|
QProgressBar* pb_; ///<
|
||||||
|
QString current_version_; ///<
|
||||||
|
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* @brief Construct a new Update Tab object
|
||||||
|
*
|
||||||
|
* @param parent
|
||||||
|
*/
|
||||||
|
explicit UpdateTab(QWidget* parent = nullptr);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void showEvent(QShowEvent* event) override;
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
/**
|
||||||
|
* @brief
|
||||||
|
*
|
||||||
|
* @param version
|
||||||
|
*/
|
||||||
|
void slot_show_version_status();
|
||||||
|
|
||||||
|
signals:
|
||||||
|
/**
|
||||||
|
* @brief
|
||||||
|
*
|
||||||
|
* @param data
|
||||||
|
*/
|
||||||
|
void SignalReplyFromUpdateServer(QByteArray data);
|
||||||
|
};
|
||||||
|
|
||||||
|
auto UpdateTabFactory(const char* id) -> void*;
|
@ -39,6 +39,8 @@
|
|||||||
#include <spdlog/spdlog.h>
|
#include <spdlog/spdlog.h>
|
||||||
|
|
||||||
#include "LogFormatter.h"
|
#include "LogFormatter.h"
|
||||||
|
#include "SoftwareVersion.h"
|
||||||
|
#include "VersionCheckingModule.h"
|
||||||
|
|
||||||
VersionCheckTask::VersionCheckTask()
|
VersionCheckTask::VersionCheckTask()
|
||||||
: network_manager_(new QNetworkAccessManager(this)),
|
: network_manager_(new QNetworkAccessManager(this)),
|
||||||
@ -172,5 +174,48 @@ void VersionCheckTask::slot_parse_current_version_info() {
|
|||||||
.c_str());
|
.c_str());
|
||||||
|
|
||||||
if (current_reply_ != nullptr) current_reply_->deleteLater();
|
if (current_reply_ != nullptr) current_reply_->deleteLater();
|
||||||
|
|
||||||
|
slot_fill_grt_with_version_info(version_);
|
||||||
emit SignalUpgradeVersion(version_);
|
emit SignalUpgradeVersion(version_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void VersionCheckTask::slot_fill_grt_with_version_info(
|
||||||
|
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");
|
||||||
|
}
|
@ -78,12 +78,18 @@ class VersionCheckTask : public QObject {
|
|||||||
*/
|
*/
|
||||||
void slot_parse_current_version_info();
|
void slot_parse_current_version_info();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void slot_fill_grt_with_version_info(const SoftwareVersion&);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QByteArray latest_reply_bytes_; ///<
|
QByteArray latest_reply_bytes_; ///<
|
||||||
QByteArray current_reply_bytes_; ///<
|
QByteArray current_reply_bytes_; ///<
|
||||||
QNetworkReply *latest_reply_ = nullptr; ///< latest version info reply
|
QNetworkReply* latest_reply_ = nullptr; ///< latest version info reply
|
||||||
QNetworkReply *current_reply_ = nullptr; ///< current version info reply
|
QNetworkReply* current_reply_ = nullptr; ///< current version info reply
|
||||||
QNetworkAccessManager *network_manager_; ///<
|
QNetworkAccessManager* network_manager_; ///<
|
||||||
QString current_version_;
|
QString current_version_;
|
||||||
SoftwareVersion version_;
|
SoftwareVersion version_;
|
||||||
};
|
};
|
115
src/m_ver_check/VersionCheckingModule.cpp
Normal file
115
src/m_ver_check/VersionCheckingModule.cpp
Normal file
@ -0,0 +1,115 @@
|
|||||||
|
/**
|
||||||
|
* 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
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "VersionCheckingModule.h"
|
||||||
|
|
||||||
|
#include <GFSDKBasic.h>
|
||||||
|
#include <GFSDKBuildInfo.h>
|
||||||
|
#include <GFSDKExtra.h>
|
||||||
|
#include <GFSDKLog.h>
|
||||||
|
#include <GFSDKUI.h>
|
||||||
|
#include <spdlog/spdlog.h>
|
||||||
|
|
||||||
|
#include <QMetaType>
|
||||||
|
#include <QtNetwork>
|
||||||
|
|
||||||
|
#include "GFModuleCommonUtils.hpp"
|
||||||
|
#include "SoftwareVersion.h"
|
||||||
|
#include "UpdateTab.h"
|
||||||
|
#include "VersionCheckTask.h"
|
||||||
|
|
||||||
|
auto GFGetModuleGFSDKVersion() -> const char* {
|
||||||
|
return DUP(GF_SDK_VERSION_STR);
|
||||||
|
}
|
||||||
|
|
||||||
|
auto GFGetModuleQtEnvVersion() -> const char* { return DUP(QT_VERSION_STR); }
|
||||||
|
|
||||||
|
auto GFGetModuleID() -> const char* {
|
||||||
|
return DUP("com.bktus.gpgfrontend.module.version_checking");
|
||||||
|
}
|
||||||
|
|
||||||
|
auto GFGetModuleVersion() -> const char* { return DUP("1.0.0"); }
|
||||||
|
|
||||||
|
auto GFGetModuleMetaData() -> GFModuleMetaData* {
|
||||||
|
return QMapToGFModuleMetaDataList(
|
||||||
|
{{"Name", "VersionChecking"},
|
||||||
|
{"Description", "Try checking GpgFrontend version."},
|
||||||
|
{"Author", "Saturneric"}});
|
||||||
|
}
|
||||||
|
|
||||||
|
auto GFRegisterModule() -> int {
|
||||||
|
MLogInfo("version checking module registering");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto GFActiveModule() -> int {
|
||||||
|
MLogInfo("version checking module activating");
|
||||||
|
|
||||||
|
GFModuleListenEvent(GFGetModuleID(), DUP("APPLICATION_LOADED"));
|
||||||
|
GFModuleListenEvent(GFGetModuleID(), DUP("CHECK_APPLICATION_VERSION"));
|
||||||
|
|
||||||
|
GFUIMountEntry(DUP("AboutDialogTabs"),
|
||||||
|
QMapToMetaDataArray({{"TabTitle", "Update"}}), 1,
|
||||||
|
UpdateTabFactory);
|
||||||
|
|
||||||
|
// load translations
|
||||||
|
QFile f(
|
||||||
|
QString(":/i18n/ModuleVersionChecking.%1.qm").arg(GFAppActiveLocale()));
|
||||||
|
if (f.exists() && f.open(QIODevice::ReadOnly)) {
|
||||||
|
auto f_n = f.fileName().toUtf8();
|
||||||
|
MLogInfoS("version checking module loading, locale: %s, path: %s",
|
||||||
|
GFAppActiveLocale(), f_n.data());
|
||||||
|
auto b = f.readAll();
|
||||||
|
GFAppRegisterTranslator(AllocBufferAndCopy(b), b.size());
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto GFExecuteModule(GFModuleEvent* event) -> int {
|
||||||
|
MLogInfoS("version checking module executing, event id: %s", event->id);
|
||||||
|
|
||||||
|
auto* task = new VersionCheckTask();
|
||||||
|
QObject::connect(task, &VersionCheckTask::SignalUpgradeVersion,
|
||||||
|
QThread::currentThread(), [event](const SoftwareVersion&) {
|
||||||
|
char** event_argv = static_cast<char**>(
|
||||||
|
GFAllocateMemory(sizeof(char**) * 1));
|
||||||
|
event_argv[0] = DUP("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; }
|
68
src/m_ver_check/ts/ModuleVersionChecking.de_DE.ts
Normal file
68
src/m_ver_check/ts/ModuleVersionChecking.de_DE.ts
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!DOCTYPE TS>
|
||||||
|
<TS version="2.1" language="de_DE">
|
||||||
|
<context>
|
||||||
|
<name>UpdateTab</name>
|
||||||
|
<message>
|
||||||
|
<location filename="../UpdateTab.cpp" line="45"/>
|
||||||
|
<source>It is recommended that you always check the version of GpgFrontend and upgrade to the latest version.</source>
|
||||||
|
<translation type="unfinished">Es wird empfohlen, immer die Version von GpgFrontend zu überprüfen und auf die neueste Version zu aktualisieren.</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../UpdateTab.cpp" line="48"/>
|
||||||
|
<source>New versions not only represent new features, but also often represent functional and security fixes.</source>
|
||||||
|
<translation type="unfinished">Neue Versionen beinhalten nicht nur neue Funktionen, sondern stellen oft auch Funktions- und Sicherheitskorrekturen dar.</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../UpdateTab.cpp" line="54"/>
|
||||||
|
<source>Current Version</source>
|
||||||
|
<translation type="unfinished">Aktuelle Version</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../UpdateTab.cpp" line="55"/>
|
||||||
|
<source>: </source>
|
||||||
|
<translation type="unfinished">: </translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../UpdateTab.cpp" line="131"/>
|
||||||
|
<source>Latest Version From Github</source>
|
||||||
|
<translation type="unfinished">Neueste Version von Github</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../UpdateTab.cpp" line="137"/>
|
||||||
|
<source>The current version is less than the latest version on github.</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../UpdateTab.cpp" line="139"/>
|
||||||
|
<location filename="../UpdateTab.cpp" line="150"/>
|
||||||
|
<location filename="../UpdateTab.cpp" line="162"/>
|
||||||
|
<source>Please click</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../UpdateTab.cpp" line="142"/>
|
||||||
|
<location filename="../UpdateTab.cpp" line="153"/>
|
||||||
|
<location filename="../UpdateTab.cpp" line="165"/>
|
||||||
|
<source>Here</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../UpdateTab.cpp" line="142"/>
|
||||||
|
<location filename="../UpdateTab.cpp" line="153"/>
|
||||||
|
<location filename="../UpdateTab.cpp" line="165"/>
|
||||||
|
<source>to download the latest stable version.</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../UpdateTab.cpp" line="148"/>
|
||||||
|
<source>This version has serious problems and has been withdrawn. Please stop using it immediately.</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../UpdateTab.cpp" line="159"/>
|
||||||
|
<source>This version has not been released yet, it may be a beta version. If you are not a tester and care about version stability, please do not use this version.</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
</context>
|
||||||
|
</TS>
|
68
src/m_ver_check/ts/ModuleVersionChecking.en_US.ts
Normal file
68
src/m_ver_check/ts/ModuleVersionChecking.en_US.ts
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!DOCTYPE TS>
|
||||||
|
<TS version="2.1">
|
||||||
|
<context>
|
||||||
|
<name>UpdateTab</name>
|
||||||
|
<message>
|
||||||
|
<location filename="../UpdateTab.cpp" line="45"/>
|
||||||
|
<source>It is recommended that you always check the version of GpgFrontend and upgrade to the latest version.</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../UpdateTab.cpp" line="48"/>
|
||||||
|
<source>New versions not only represent new features, but also often represent functional and security fixes.</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../UpdateTab.cpp" line="54"/>
|
||||||
|
<source>Current Version</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../UpdateTab.cpp" line="55"/>
|
||||||
|
<source>: </source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../UpdateTab.cpp" line="131"/>
|
||||||
|
<source>Latest Version From Github</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../UpdateTab.cpp" line="137"/>
|
||||||
|
<source>The current version is less than the latest version on github.</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../UpdateTab.cpp" line="139"/>
|
||||||
|
<location filename="../UpdateTab.cpp" line="150"/>
|
||||||
|
<location filename="../UpdateTab.cpp" line="162"/>
|
||||||
|
<source>Please click</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../UpdateTab.cpp" line="142"/>
|
||||||
|
<location filename="../UpdateTab.cpp" line="153"/>
|
||||||
|
<location filename="../UpdateTab.cpp" line="165"/>
|
||||||
|
<source>Here</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../UpdateTab.cpp" line="142"/>
|
||||||
|
<location filename="../UpdateTab.cpp" line="153"/>
|
||||||
|
<location filename="../UpdateTab.cpp" line="165"/>
|
||||||
|
<source>to download the latest stable version.</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../UpdateTab.cpp" line="148"/>
|
||||||
|
<source>This version has serious problems and has been withdrawn. Please stop using it immediately.</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../UpdateTab.cpp" line="159"/>
|
||||||
|
<source>This version has not been released yet, it may be a beta version. If you are not a tester and care about version stability, please do not use this version.</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
</context>
|
||||||
|
</TS>
|
68
src/m_ver_check/ts/ModuleVersionChecking.fr_FR.ts
Normal file
68
src/m_ver_check/ts/ModuleVersionChecking.fr_FR.ts
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!DOCTYPE TS>
|
||||||
|
<TS version="2.1">
|
||||||
|
<context>
|
||||||
|
<name>UpdateTab</name>
|
||||||
|
<message>
|
||||||
|
<location filename="../UpdateTab.cpp" line="45"/>
|
||||||
|
<source>It is recommended that you always check the version of GpgFrontend and upgrade to the latest version.</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../UpdateTab.cpp" line="48"/>
|
||||||
|
<source>New versions not only represent new features, but also often represent functional and security fixes.</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../UpdateTab.cpp" line="54"/>
|
||||||
|
<source>Current Version</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../UpdateTab.cpp" line="55"/>
|
||||||
|
<source>: </source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../UpdateTab.cpp" line="131"/>
|
||||||
|
<source>Latest Version From Github</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../UpdateTab.cpp" line="137"/>
|
||||||
|
<source>The current version is less than the latest version on github.</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../UpdateTab.cpp" line="139"/>
|
||||||
|
<location filename="../UpdateTab.cpp" line="150"/>
|
||||||
|
<location filename="../UpdateTab.cpp" line="162"/>
|
||||||
|
<source>Please click</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../UpdateTab.cpp" line="142"/>
|
||||||
|
<location filename="../UpdateTab.cpp" line="153"/>
|
||||||
|
<location filename="../UpdateTab.cpp" line="165"/>
|
||||||
|
<source>Here</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../UpdateTab.cpp" line="142"/>
|
||||||
|
<location filename="../UpdateTab.cpp" line="153"/>
|
||||||
|
<location filename="../UpdateTab.cpp" line="165"/>
|
||||||
|
<source>to download the latest stable version.</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../UpdateTab.cpp" line="148"/>
|
||||||
|
<source>This version has serious problems and has been withdrawn. Please stop using it immediately.</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../UpdateTab.cpp" line="159"/>
|
||||||
|
<source>This version has not been released yet, it may be a beta version. If you are not a tester and care about version stability, please do not use this version.</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
</context>
|
||||||
|
</TS>
|
68
src/m_ver_check/ts/ModuleVersionChecking.zh_CN.ts
Normal file
68
src/m_ver_check/ts/ModuleVersionChecking.zh_CN.ts
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!DOCTYPE TS>
|
||||||
|
<TS version="2.1">
|
||||||
|
<context>
|
||||||
|
<name>UpdateTab</name>
|
||||||
|
<message>
|
||||||
|
<location filename="../UpdateTab.cpp" line="45"/>
|
||||||
|
<source>It is recommended that you always check the version of GpgFrontend and upgrade to the latest version.</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../UpdateTab.cpp" line="48"/>
|
||||||
|
<source>New versions not only represent new features, but also often represent functional and security fixes.</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../UpdateTab.cpp" line="54"/>
|
||||||
|
<source>Current Version</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../UpdateTab.cpp" line="55"/>
|
||||||
|
<source>: </source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../UpdateTab.cpp" line="131"/>
|
||||||
|
<source>Latest Version From Github</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../UpdateTab.cpp" line="137"/>
|
||||||
|
<source>The current version is less than the latest version on github.</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../UpdateTab.cpp" line="139"/>
|
||||||
|
<location filename="../UpdateTab.cpp" line="150"/>
|
||||||
|
<location filename="../UpdateTab.cpp" line="162"/>
|
||||||
|
<source>Please click</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../UpdateTab.cpp" line="142"/>
|
||||||
|
<location filename="../UpdateTab.cpp" line="153"/>
|
||||||
|
<location filename="../UpdateTab.cpp" line="165"/>
|
||||||
|
<source>Here</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../UpdateTab.cpp" line="142"/>
|
||||||
|
<location filename="../UpdateTab.cpp" line="153"/>
|
||||||
|
<location filename="../UpdateTab.cpp" line="165"/>
|
||||||
|
<source>to download the latest stable version.</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../UpdateTab.cpp" line="148"/>
|
||||||
|
<source>This version has serious problems and has been withdrawn. Please stop using it immediately.</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../UpdateTab.cpp" line="159"/>
|
||||||
|
<source>This version has not been released yet, it may be a beta version. If you are not a tester and care about version stability, please do not use this version.</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
</context>
|
||||||
|
</TS>
|
@ -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 */
|
|
@ -1,164 +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
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#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");
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user