diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/CMakeLists.txt | 6 | ||||
-rw-r--r-- | src/main.cpp | 14 | ||||
-rw-r--r-- | src/ui/settings/GlobalSettingStation.h | 12 | ||||
-rw-r--r-- | src/ui/widgets/KeyList.cpp | 11 |
4 files changed, 40 insertions, 3 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index fc7d8169..3810a6e8 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -119,14 +119,14 @@ if (APPLICATION_BUILD) file(COPY ${CMAKE_SOURCE_DIR}/resource/css DESTINATION ${RESOURCE_OUTPUT_DIRECTORY}/ FOLLOW_SYMLINK_CHAIN) file(COPY ${CMAKE_SOURCE_DIR}/resource/icons DESTINATION ${RESOURCE_OUTPUT_DIRECTORY}/ FOLLOW_SYMLINK_CHAIN) file(COPY ${CMAKE_SOURCE_DIR}/TRANSLATORS DESTINATION ${RESOURCE_OUTPUT_DIRECTORY} FOLLOW_SYMLINK_CHAIN) + if(GPG_STANDALONE_MODE) + file(COPY ${CMAKE_SOURCE_DIR}/resource/gpg1.4 DESTINATION ${RESOURCE_OUTPUT_DIRECTORY}/ FOLLOW_SYMLINK_CHAIN) + endif() endif () if (APPLICATION_BUILD) if (${CMAKE_BUILD_TYPE} STREQUAL "Release") if (APPLE) - if(APPLE_SANDBOX) - file(COPY ${CMAKE_SOURCE_DIR}/resource/gpg1.4 DESTINATION ${RESOURCE_OUTPUT_DIRECTORY}/ FOLLOW_SYMLINK_CHAIN) - endif() file(COPY ${CMAKE_SOURCE_DIR}/gpgfrontend.icns DESTINATION ${RESOURCE_OUTPUT_DIRECTORY}/ FOLLOW_SYMLINK_CHAIN) # Refresh App Bundle file(REMOVE ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${AppName}.app) diff --git a/src/main.cpp b/src/main.cpp index ed863f41..ae04d7db 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -28,6 +28,7 @@ #include "GpgFrontendBuildInfo.h" #include "gpg/GpgContext.h" +#include "gpg/GpgFunctionObject.h" #include "ui/MainWindow.h" #include "ui/function/CtxCheckThread.h" #include "ui/settings/GlobalSettingStation.h" @@ -88,6 +89,19 @@ int main(int argc, char* argv[]) { file.close(); #endif +#ifdef GPG_STANDALONE_MODE + LOG(INFO) << "GPG_STANDALONE_MODE Enabled"; + auto gpg_path = GpgFrontend::UI::GlobalSettingStation::GetInstance() + .GetStandaloneGpgBinDir(); + auto db_path = GpgFrontend::UI::GlobalSettingStation::GetInstance() + .GetStandaloneDatabaseDir(); + GpgFrontend::GpgContext::CreateInstance( + GpgFrontend::SingletonFunctionObject< + GpgFrontend::GpgContext>::GetDefaultChannel(), + std::make_unique<GpgFrontend::GpgContext>(true, db_path.string(), true, + gpg_path.string())); +#endif + auto* init_ctx_thread = new GpgFrontend::UI::CtxCheckThread(); QApplication::connect(init_ctx_thread, &QThread::finished, init_ctx_thread, diff --git a/src/ui/settings/GlobalSettingStation.h b/src/ui/settings/GlobalSettingStation.h index a7cbe569..a89bf32d 100644 --- a/src/ui/settings/GlobalSettingStation.h +++ b/src/ui/settings/GlobalSettingStation.h @@ -48,6 +48,18 @@ class GlobalSettingStation : public QObject { return app_log_path; } + [[nodiscard]] boost::filesystem::path GetStandaloneDatabaseDir() const { + auto db_path = app_configure_path / "db"; + if (!boost::filesystem::exists(db_path)) { + boost::filesystem::create_directory(db_path); + } + return db_path; + } + + [[nodiscard]] boost::filesystem::path GetStandaloneGpgBinDir() const { + return app_resource_path / "gpg1.4" / "gpg"; + } + [[nodiscard]] boost::filesystem::path GetLocaleDir() const { return app_locale_path; } diff --git a/src/ui/widgets/KeyList.cpp b/src/ui/widgets/KeyList.cpp index 0e4c5bba..464727dc 100644 --- a/src/ui/widgets/KeyList.cpp +++ b/src/ui/widgets/KeyList.cpp @@ -46,6 +46,17 @@ KeyList::KeyList(bool menu, QWidget* parent) } void KeyList::init() { +#ifdef GPG_STANDALONE_MODE + LOG(INFO) << "GPG_STANDALONE_MODE Enabled"; + auto gpg_path = GpgFrontend::UI::GlobalSettingStation::GetInstance() + .GetStandaloneGpgBinDir(); + auto db_path = GpgFrontend::UI::GlobalSettingStation::GetInstance() + .GetStandaloneDatabaseDir(); + GpgContext::CreateInstance( + _m_key_list_id, std::make_unique<GpgContext>(true, db_path.string(), true, + gpg_path.string())); +#endif + ui->setupUi(this); ui->menuWidget->setHidden(!menu_status); |