aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsaturneric <[email protected]>2024-12-01 21:14:30 +0000
committersaturneric <[email protected]>2024-12-01 21:14:30 +0000
commita91b2dced1ff25121fdaf1acd905373e0f1f3479 (patch)
tree77537f8b3ace5c7fc67baba9418c8e98aa25a614
parentfeat: add 'create date' column to key toolbox (diff)
downloadGpgFrontend-a91b2dced1ff25121fdaf1acd905373e0f1f3479.tar.gz
GpgFrontend-a91b2dced1ff25121fdaf1acd905373e0f1f3479.zip
feat: check commit hash from remote
m---------modules0
-rw-r--r--src/core/CMakeLists.txt7
-rw-r--r--src/sdk/CMakeLists.txt7
-rw-r--r--src/sdk/GFSDKBasic.cpp4
-rw-r--r--src/sdk/GFSDKBasic.h7
-rw-r--r--src/ui/CMakeLists.txt7
-rw-r--r--src/ui/main_window/MainWindowSlotFunction.cpp42
7 files changed, 58 insertions, 16 deletions
diff --git a/modules b/modules
-Subproject 5f436558c23ade79b72516c882f345946e2586f
+Subproject fcc31759f8c09e24f001c17549e95d65fc1a484
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt
index 3ce199e5..5a1c9477 100644
--- a/src/core/CMakeLists.txt
+++ b/src/core/CMakeLists.txt
@@ -92,6 +92,13 @@ target_precompile_headers(gpgfrontend_core
# using std c++ 17
target_compile_features(gpgfrontend_core PUBLIC cxx_std_17)
+# MODULEs will find libraries under artifacts lib
+if(${CMAKE_BUILD_TYPE} STREQUAL "Debug")
+ set_target_properties(gpgfrontend_core PROPERTIES
+ LIBRARY_OUTPUT_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/lib
+ RUNTIME_OUTPUT_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/lib)
+endif()
+
# link for different platforms
if(MINGW)
message(STATUS "Link GPG Static Library For MINGW")
diff --git a/src/sdk/CMakeLists.txt b/src/sdk/CMakeLists.txt
index de6d24a7..7ebb1d87 100644
--- a/src/sdk/CMakeLists.txt
+++ b/src/sdk/CMakeLists.txt
@@ -45,6 +45,13 @@ target_link_libraries(gpgfrontend_module_sdk PRIVATE gpgfrontend_core gpgfronten
file(GLOB _headerPath "${CMAKE_CURRENT_SOURCE_DIR}/*.h")
set_target_properties(gpgfrontend_module_sdk PROPERTIES PUBLIC_HEADER "${_headerPath}")
+# MODULEs will find libraries under artifacts lib
+if(${CMAKE_BUILD_TYPE} STREQUAL "Debug")
+ set_target_properties(gpgfrontend_module_sdk PROPERTIES
+ LIBRARY_OUTPUT_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/lib
+ RUNTIME_OUTPUT_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/lib)
+endif()
+
if(XCODE_BUILD)
set_target_properties(gpgfrontend_module_sdk
PROPERTIES
diff --git a/src/sdk/GFSDKBasic.cpp b/src/sdk/GFSDKBasic.cpp
index 1c7816d2..2815d17a 100644
--- a/src/sdk/GFSDKBasic.cpp
+++ b/src/sdk/GFSDKBasic.cpp
@@ -139,3 +139,7 @@ auto GPGFRONTEND_MODULE_SDK_EXPORT GFCacheSaveWithTTL(const char* key,
GFUnStrDup(value), ttl);
return 0;
}
+
+auto GPGFRONTEND_MODULE_SDK_EXPORT GFProjectGitCommitHash() -> const char* {
+ return GFStrDup(GpgFrontend::GetProjectBuildGitVersion());
+} \ No newline at end of file
diff --git a/src/sdk/GFSDKBasic.h b/src/sdk/GFSDKBasic.h
index cf4b5045..1c81299a 100644
--- a/src/sdk/GFSDKBasic.h
+++ b/src/sdk/GFSDKBasic.h
@@ -81,6 +81,13 @@ auto GPGFRONTEND_MODULE_SDK_EXPORT GFProjectVersion() -> const char*;
*
* @return const char*
*/
+auto GPGFRONTEND_MODULE_SDK_EXPORT GFProjectGitCommitHash() -> const char*;
+
+/**
+ * @brief
+ *
+ * @return const char*
+ */
auto GPGFRONTEND_MODULE_SDK_EXPORT GFQtEnvVersion() -> const char*;
/**
diff --git a/src/ui/CMakeLists.txt b/src/ui/CMakeLists.txt
index 644053be..0f35fdca 100644
--- a/src/ui/CMakeLists.txt
+++ b/src/ui/CMakeLists.txt
@@ -69,6 +69,13 @@ target_include_directories(gpgfrontend_ui PUBLIC
# using std c++ 17
target_compile_features(gpgfrontend_ui PUBLIC cxx_std_17)
+# MODULEs will find libraries under artifacts lib
+if(${CMAKE_BUILD_TYPE} STREQUAL "Debug")
+ set_target_properties(gpgfrontend_ui PROPERTIES
+ LIBRARY_OUTPUT_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/lib
+ RUNTIME_OUTPUT_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/lib)
+endif()
+
# for xcode archive build
if(XCODE_BUILD)
set_target_properties(gpgfrontend_ui
diff --git a/src/ui/main_window/MainWindowSlotFunction.cpp b/src/ui/main_window/MainWindowSlotFunction.cpp
index 8b0f3121..c0bb8b6f 100644
--- a/src/ui/main_window/MainWindowSlotFunction.cpp
+++ b/src/ui/main_window/MainWindowSlotFunction.cpp
@@ -311,33 +311,43 @@ void MainWindow::slot_version_upgrade_notify() {
auto latest_version = Module::RetrieveRTValueTypedOrDefault<>(
kVersionCheckingModuleID, "version.latest_version", QString{});
+ auto is_git_commit_hash_mismatch = Module::RetrieveRTValueTypedOrDefault<>(
+ kVersionCheckingModuleID, "version.git_commit_hash_mismatch", false);
+
if (is_need_upgrade) {
statusBar()->showMessage(
tr("GpgFrontend Upgradeable (New Version: %1).").arg(latest_version),
30000);
- auto* update_button = new QPushButton("Update GpgFrontend", this);
- connect(update_button, &QPushButton::clicked, [=]() {
- auto* about_dialog = new AboutDialog(tr("Update"), this);
- about_dialog->show();
- });
- statusBar()->addPermanentWidget(update_button, 0);
} else if (is_current_a_withdrawn_version) {
- QMessageBox::warning(
+ auto response = QMessageBox::warning(
this, tr("Withdrawn Version"),
+ tr("This version(%1) may have been withdrawn by the developer due to "
+ "serious problems. Please stop using this version immediately and "
+ "download the latest stable version (%2) on the Github Releases "
+ "Page.")
+ .arg(latest_version)
+ .arg(latest_version),
+ QMessageBox::Ok | QMessageBox::Open);
+
+ if (response == QMessageBox::Open) {
+ QDesktopServices::openUrl(
+ QUrl("https://github.com/saturneric/GpgFrontend/releases/latest"));
+ }
- tr("This version(%1) may have been withdrawn by the developer due "
- "to serious problems. Please stop using this version "
- "immediately and use the latest stable version.")
- .arg(latest_version) +
- "<br/>" +
- tr("You can download the latest stable version(%1) on "
- "Github Releases Page.<br/>")
- .arg(latest_version));
} else if (!is_current_version_released) {
statusBar()->showMessage(
- tr("This maybe a BETA Version (Latest Stable Version: %1).")
+ tr("This may be a BETA Version (Latest Stable Version: %1).")
.arg(latest_version),
30000);
+
+ } else if (is_git_commit_hash_mismatch) {
+ QMessageBox::information(
+ this, tr("Commit Hash Mismatch"),
+ tr("The current version's commit hash does not match the official "
+ "release. This may indicate a modified or unofficial build. For "
+ "security reasons, please verify your installation or download the "
+ "official release from the Github Releases Page."),
+ QMessageBox::Ok);
}
}