1
0

Compare commits

...

2 Commits

2 changed files with 41 additions and 23 deletions

@ -1 +1 @@
Subproject commit bbbbbf535f153c59bffa47b88c54e9f5107aa648 Subproject commit 22ba38aac5edbf85cc879fd611ef79b9f818544a

View File

@ -69,11 +69,13 @@ auto SearchGpgconfPath(const QStringList& candidate_paths) -> QString {
} }
auto GetDefaultKeyDatabasePath(const QString& gpgconf_path) -> QString { auto GetDefaultKeyDatabasePath(const QString& gpgconf_path) -> QString {
QString default_db_path;
// portable mode // portable mode
if (GlobalSettingStation::GetInstance().IsProtableMode()) { if (GlobalSettingStation::GetInstance().IsProtableMode()) {
return GlobalSettingStation::GetInstance().GetAppDataPath() + "/db"; default_db_path =
} GlobalSettingStation::GetInstance().GetAppDataPath() + "/db";
} else {
if (gpgconf_path.isEmpty()) return {}; if (gpgconf_path.isEmpty()) return {};
QFileInfo info(gpgconf_path); QFileInfo info(gpgconf_path);
@ -85,11 +87,18 @@ auto GetDefaultKeyDatabasePath(const QString& gpgconf_path) -> QString {
p->start(); p->start();
p->waitForFinished(); p->waitForFinished();
auto home_path = p->readAll().trimmed(); default_db_path = p->readAll().trimmed();
p->deleteLater(); p->deleteLater();
}
QFileInfo home_info(home_path); QFileInfo info(default_db_path);
return home_info.absoluteFilePath(); default_db_path = info.absoluteFilePath();
// update GRT
Module::UpsertRTValue("core", "gpgme.ctx.default_database_path",
default_db_path);
return default_db_path;
} }
auto InitGpgME() -> bool { auto InitGpgME() -> bool {
@ -268,8 +277,10 @@ auto GetComponentPathsByGpgConf(const QString& gpgconf_install_fs_path)
-> bool { -> bool {
auto* process = new QProcess(QCoreApplication::instance()); auto* process = new QProcess(QCoreApplication::instance());
process->setProgram(gpgconf_install_fs_path); process->setProgram(gpgconf_install_fs_path);
process->setArguments({"--check-programs"});
process->start(); process->start();
process->waitForFinished(1000); process->waitForFinished(30000);
auto output_buffer = process->readAllStandardOutput(); auto output_buffer = process->readAllStandardOutput();
process->deleteLater(); process->deleteLater();
@ -279,24 +290,31 @@ auto GetComponentPathsByGpgConf(const QString& gpgconf_install_fs_path)
for (const auto& line : line_split_list) { for (const auto& line : line_split_list) {
auto info_split_list = line.split(":"); auto info_split_list = line.split(":");
if (info_split_list.size() != 3) continue; if (info_split_list.size() != 6) continue;
auto component_name = info_split_list[0].trimmed().toLower(); auto component_name = info_split_list[0].trimmed().toLower();
auto component_desc = info_split_list[1].trimmed(); auto component_desc = info_split_list[1].trimmed();
auto component_path = info_split_list[2].trimmed(); auto component_path = info_split_list[2].trimmed();
auto exists = info_split_list[3].trimmed();
auto runnable = info_split_list[4].trimmed();
#if defined(_WIN32) || defined(WIN32) #if defined(_WIN32) || defined(WIN32)
// replace some special substrings on windows platform // replace some special substrings on windows platform
component_path.replace("%3a", ":"); component_path.replace("%3a", ":");
#endif #endif
if (exists != "1" || runnable != "1") continue;
QFileInfo file_info(component_path); QFileInfo file_info(component_path);
if (!file_info.exists() || !file_info.isFile()) continue; if (!file_info.exists() || !file_info.isFile()) continue;
Module::UpsertRTValue("core", "gnupg.component.paths." + component_name, Module::UpsertRTValue(
"core", QString("gnupg.components.%1.checked").arg(component_name), 1);
Module::UpsertRTValue(
"core", QString("gnupg.components.%1.path").arg(component_name),
file_info.absoluteFilePath()); file_info.absoluteFilePath());
LOG_D() << "gpg components: " << component_name LOG_D() << "gpg components checked: " << component_name
<< "path: " << file_info.absoluteFilePath(); << "path: " << file_info.absoluteFilePath();
} }
@ -362,7 +380,7 @@ auto DecideGnuPGPath(const QString& default_gnupg_path) -> QString {
if (default_gnupg_path.isEmpty() || !info.exists() || !info.isFile()) { if (default_gnupg_path.isEmpty() || !info.exists() || !info.isFile()) {
return Module::RetrieveRTValueTypedOrDefault<>( return Module::RetrieveRTValueTypedOrDefault<>(
"core", "gnupg.component.paths.gpg", QString{}); "core", "gnupg.components.gpg.path", QString{});
} }
return default_gnupg_path; return default_gnupg_path;
@ -424,7 +442,7 @@ auto InitBasicPath() -> bool {
LOG_E() << "Cannot find default home path by gpgconf!" LOG_E() << "Cannot find default home path by gpgconf!"
<< "GpgFrontend cannot start under this situation!"; << "GpgFrontend cannot start under this situation!";
CoreSignalStation::GetInstance()->SignalBadGnupgEnv( CoreSignalStation::GetInstance()->SignalBadGnupgEnv(
QCoreApplication::tr("Cannot Find Home Path")); QCoreApplication::tr("Cannot Find Default Home Path"));
return false; return false;
} }