aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSaturneric <[email protected]>2023-03-31 08:24:48 +0000
committerSaturneric <[email protected]>2023-03-31 08:24:48 +0000
commit09bd72beba0234e1b576379f6c654b54bd693e8e (patch)
tree8f032e414e32fcec66615d16f423669926092f36
parentfeat: add offline and auto import support in context (diff)
downloadGpgFrontend-09bd72beba0234e1b576379f6c654b54bd693e8e.tar.gz
GpgFrontend-09bd72beba0234e1b576379f6c654b54bd693e8e.zip
feat: read offline and auto import config when init
-rw-r--r--src/core/GpgCoreInit.cpp40
1 files changed, 35 insertions, 5 deletions
diff --git a/src/core/GpgCoreInit.cpp b/src/core/GpgCoreInit.cpp
index 840b2b87..34780d98 100644
--- a/src/core/GpgCoreInit.cpp
+++ b/src/core/GpgCoreInit.cpp
@@ -93,12 +93,38 @@ void ShutdownCoreLoggingSystem() {
void ResetGpgFrontendCore() { reset_gpgfrontend_core(); }
void init_gpgfrontend_core() {
- // read from settings file
+ /* Initialize the locale environment. */
+ SPDLOG_DEBUG("locale: {}", setlocale(LC_CTYPE, nullptr));
+ // init gpgme subsystem
+ gpgme_check_version(nullptr);
+ gpgme_set_locale(nullptr, LC_CTYPE, setlocale(LC_CTYPE, nullptr));
+#ifdef LC_MESSAGES
+ gpgme_set_locale(nullptr, LC_MESSAGES, setlocale(LC_MESSAGES, nullptr));
+#endif
+
+ // get settings
+ auto& settings = GlobalSettingStation::GetInstance().GetUISettings();
+
+ // read settings
+ bool forbid_all_gnupg_connection = false;
+ try {
+ forbid_all_gnupg_connection =
+ settings.lookup("network.forbid_all_gnupg_connection");
+ } catch (...) {
+ SPDLOG_ERROR("setting operation error: forbid_all_gnupg_connection");
+ }
+ bool auto_import_missing_key = false;
+ try {
+ auto_import_missing_key =
+ settings.lookup("network.auto_import_missing_key");
+ } catch (...) {
+ SPDLOG_ERROR("setting operation error: auto_import_missing_key");
+ }
+
+ // 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 (...) {
@@ -110,8 +136,6 @@ void init_gpgfrontend_core() {
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"));
@@ -132,6 +156,9 @@ void init_gpgfrontend_core() {
args.db_path = custom_key_database_path;
}
+ args.offline_mode = forbid_all_gnupg_connection;
+ args.auto_import_missing_key = auto_import_missing_key;
+
return std::unique_ptr<ChannelObject>(new GpgContext(args));
});
@@ -146,6 +173,9 @@ void init_gpgfrontend_core() {
args.db_path = custom_key_database_path;
}
+ args.offline_mode = forbid_all_gnupg_connection;
+ args.auto_import_missing_key = auto_import_missing_key;
+
return std::unique_ptr<ChannelObject>(new GpgContext(args));
});