aboutsummaryrefslogtreecommitdiffstats
path: root/src/core/GpgCoreInit.cpp
diff options
context:
space:
mode:
authorSaturneric <[email protected]>2022-12-04 10:15:50 +0000
committerSaturneric <[email protected]>2022-12-04 10:16:25 +0000
commit6bdfddb208bb00fc67a309b0c23af124217d3541 (patch)
treeb2fe2928b8ae7396021b433b808121260c6ef80f /src/core/GpgCoreInit.cpp
parentfix: solve a refresh crash (diff)
downloadGpgFrontend-6bdfddb208bb00fc67a309b0c23af124217d3541.tar.gz
GpgFrontend-6bdfddb208bb00fc67a309b0c23af124217d3541.zip
feat(ui, core): add custom key db support
1. add custom key db support 2. add deep restart mode for custom key db settings 3. add core reset function
Diffstat (limited to 'src/core/GpgCoreInit.cpp')
-rw-r--r--src/core/GpgCoreInit.cpp50
1 files changed, 48 insertions, 2 deletions
diff --git a/src/core/GpgCoreInit.cpp b/src/core/GpgCoreInit.cpp
index f1664b2a..9ccc693d 100644
--- a/src/core/GpgCoreInit.cpp
+++ b/src/core/GpgCoreInit.cpp
@@ -77,23 +77,69 @@ void InitLoggingSystem() {
LOG(INFO) << _("log file path") << logfile_path;
}
+void ResetGpgFrontendCore() { reset_gpgfrontend_core(); }
+
void init_gpgfrontend_core() {
+ // read from settings file
+
+ bool use_custom_key_database_path = false;
+ try {
+ auto& settings =
+ GpgFrontend::GlobalSettingStation::GetInstance().GetUISettings();
+ use_custom_key_database_path =
+ settings.lookup("general.use_custom_key_database_path");
+ } catch (...) {
+ LOG(ERROR) << _("Setting Operation Error")
+ << _("use_custom_key_database_path");
+ }
+
+ LOG(INFO) << "core loaded if use custom key databse path: "
+ << use_custom_key_database_path;
+
+ std::string custom_key_database_path;
+ try {
+ auto& settings =
+ GpgFrontend::GlobalSettingStation::GetInstance().GetUISettings();
+ custom_key_database_path = static_cast<std::string>(
+ settings.lookup("general.custom_key_database_path"));
+
+ } catch (...) {
+ LOG(ERROR) << _("Setting Operation Error") << _("custom_key_database_path");
+ }
+
+ LOG(INFO) << "core loaded custom key databse path: "
+ << custom_key_database_path;
+
// init default channel
GpgFrontend::GpgContext::CreateInstance(
- GPGFRONTEND_DEFAULT_CHANNEL, [&]() -> std::unique_ptr<ChannelObject> {
+ GPGFRONTEND_DEFAULT_CHANNEL, [=]() -> std::unique_ptr<ChannelObject> {
GpgFrontend::GpgContextInitArgs args;
+
+ // set key database path
+ if (use_custom_key_database_path && !custom_key_database_path.empty()) {
+ args.db_path = custom_key_database_path;
+ }
+
return std::unique_ptr<ChannelObject>(new GpgContext(args));
});
// init non-ascii channel
GpgFrontend::GpgContext::CreateInstance(
- GPGFRONTEND_NON_ASCII_CHANNEL, [&]() -> std::unique_ptr<ChannelObject> {
+ GPGFRONTEND_NON_ASCII_CHANNEL, [=]() -> std::unique_ptr<ChannelObject> {
GpgFrontend::GpgContextInitArgs args;
args.ascii = false;
+
+ // set key database path
+ if (use_custom_key_database_path && !custom_key_database_path.empty()) {
+ args.db_path = custom_key_database_path;
+ }
+
return std::unique_ptr<ChannelObject>(new GpgContext(args));
});
}
+void reset_gpgfrontend_core() { SingletonStorageCollection::GetInstance(true); }
+
void new_default_settings_channel(int channel) {
GpgFrontend::GpgContext::CreateInstance(
channel, [&]() -> std::unique_ptr<ChannelObject> {