diff options
author | saturneric <[email protected]> | 2023-10-16 20:19:26 +0000 |
---|---|---|
committer | saturneric <[email protected]> | 2023-10-16 20:19:26 +0000 |
commit | 5175b3ae6687839afa2cdfe01f2fd70d714024ed (patch) | |
tree | 96eef7e087749c9118d5da7a838fdd81b0e96354 /src/core/GpgCoreInit.cpp | |
parent | feat: using piml tech on plugin system (diff) | |
download | GpgFrontend-5175b3ae6687839afa2cdfe01f2fd70d714024ed.tar.gz GpgFrontend-5175b3ae6687839afa2cdfe01f2fd70d714024ed.zip |
refactor: use c++17 features and piml tech to rewrite DataObject and Task
Diffstat (limited to 'src/core/GpgCoreInit.cpp')
-rw-r--r-- | src/core/GpgCoreInit.cpp | 61 |
1 files changed, 30 insertions, 31 deletions
diff --git a/src/core/GpgCoreInit.cpp b/src/core/GpgCoreInit.cpp index 1799472f..0441b7d8 100644 --- a/src/core/GpgCoreInit.cpp +++ b/src/core/GpgCoreInit.cpp @@ -206,37 +206,36 @@ void init_gpgfrontend_core() { // async init no-ascii channel Thread::TaskRunnerGetter::GetInstance() .GetTaskRunner(Thread::TaskRunnerGetter::kTaskRunnerType_GPG) - ->PostTask( - new Thread::Task([=](Thread::Task::DataObjectPtr data_obj) -> int { - // init non-ascii channel - auto& ctx = GpgFrontend::GpgContext::CreateInstance( - 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; - } - - if (use_custom_gnupg_install_path) { - args.custom_gpgconf = true; - args.custom_gpgconf_path = - custom_gnupg_install_fs_path.u8string(); - } - - args.offline_mode = forbid_all_gnupg_connection; - args.auto_import_missing_key = auto_import_missing_key; - args.use_pinentry = use_pinentry_as_password_input_dialog; - - return std::unique_ptr<ChannelObject>(new GpgContext(args)); - }); - - if (!ctx.good()) SPDLOG_ERROR("no-ascii channel init error"); - return ctx.good() ? 0 : -1; - })); + ->PostTask(new Thread::Task([=](Thread::DataObjectPtr data_obj) -> int { + // init non-ascii channel + auto& ctx = GpgFrontend::GpgContext::CreateInstance( + 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; + } + + if (use_custom_gnupg_install_path) { + args.custom_gpgconf = true; + args.custom_gpgconf_path = + custom_gnupg_install_fs_path.u8string(); + } + + args.offline_mode = forbid_all_gnupg_connection; + args.auto_import_missing_key = auto_import_missing_key; + args.use_pinentry = use_pinentry_as_password_input_dialog; + + return std::unique_ptr<ChannelObject>(new GpgContext(args)); + }); + + if (!ctx.good()) SPDLOG_ERROR("no-ascii channel init error"); + return ctx.good() ? 0 : -1; + })); // try to restart all components GpgFrontend::GpgAdvancedOperator::GetInstance().RestartGpgComponents(); |