diff options
Diffstat (limited to 'src/cmd.cpp')
-rw-r--r-- | src/cmd.cpp | 112 |
1 files changed, 105 insertions, 7 deletions
diff --git a/src/cmd.cpp b/src/cmd.cpp index b7642b4e..092086fc 100644 --- a/src/cmd.cpp +++ b/src/cmd.cpp @@ -34,6 +34,10 @@ #include <qstring.h> #include <qtextstream.h> +#include "core/GpgCoreInit.h" +#include "core/model/SettingsObject.h" +#include "core/module/ModuleManager.h" +#include "core/struct/settings_object/KeyDatabaseListSO.h" #include "core/utils/BuildInfoUtils.h" // GpgFrontend @@ -43,22 +47,116 @@ namespace GpgFrontend { +inline auto Tr(const char* t) -> QString { return QCoreApplication::tr(t); } + auto PrintVersion() -> int { QTextStream stream(stdout); stream << GetProjectName() << " " << GetProjectVersion() << '\n'; stream << "Copyright (©) 2021 Saturneric <[email protected]>" << '\n' - << QCoreApplication::tr( - "This is free software; see the source for copying conditions.") + << Tr("This is free software; see the source for copying conditions.") << '\n' << '\n'; - stream << QCoreApplication::tr("Build DateTime: ") + stream << Tr("Build DateTime: ") << QLocale().toString(GetProjectBuildTimestamp()) << '\n' - << QCoreApplication::tr("Build Version: ") << GetProjectBuildVersion() - << '\n' - << QCoreApplication::tr("Source Code Version: ") - << GetProjectBuildGitVersion() << '\n'; + << Tr("Build Version: ") << GetProjectBuildVersion() << '\n' + << Tr("Source Code Version: ") << GetProjectBuildGitVersion() << '\n'; + + stream << Qt::endl; + return 0; +} + +auto PrintEnvInfo() -> int { + QTextStream stream(stdout); + stream << GetProjectName() << " " << GetProjectVersion() << " " + << "Environemnt Informations:" << '\n'; + + stream << '\n'; + + stream << Tr("Qt Version: ") << GetProjectQtVersion() << '\n'; + stream << Tr("OpenSSL Version: ") << GetProjectOpenSSLVersion() << '\n'; + stream << Tr("Libarchive Version: ") << GetProjectLibarchiveVersion() << '\n'; + + stream << '\n'; + + stream << Tr("GnuPG: ") << '\n'; + stream << '\n'; + + auto init_result = InitGpgME(); + + auto gnupg_version = Module::RetrieveRTValueTypedOrDefault<>( + "core", "gpgme.ctx.gnupg_version", QString{}); + stream << Tr("GnuPG Version: ") << gnupg_version << '\n'; + + stream << Tr("GpgME Init Status: ") + << (init_result ? Tr("Success") : Tr("Failed")) << '\n'; + + auto gpgconf = Module::RetrieveRTValueTypedOrDefault<>( + "core", "gpgme.engine.gpgconf", 0); + auto openpgp = Module::RetrieveRTValueTypedOrDefault<>( + "core", "gpgme.engine.openpgp", 0); + auto cms = + Module::RetrieveRTValueTypedOrDefault<>("core", "gpgme.engine.cms", 0); + auto assuan = + Module::RetrieveRTValueTypedOrDefault<>("core", "gpgme.engine.assuan", 0); + stream << Tr("Engine 'GPGCONF' Status: ") + << (gpgconf == 1 ? Tr("Exists") : Tr("NOT Exists")) << '\n'; + stream << Tr("Engine 'OPENPGP' Status: ") + << (openpgp == 1 ? Tr("Exists") : Tr("NOT Exists")) << '\n'; + stream << Tr("Engine 'CMS' Status: ") + << (cms == 1 ? Tr("Exists") : Tr("NOT Exists")) << '\n'; + stream << Tr("Engine 'ASSUAN' Status: ") + << (assuan == 1 ? Tr("Exists") : Tr("NOT Exists")) << '\n'; + + stream << '\n'; + + InitBasicPath(); + + auto app_path = Module::RetrieveRTValueTypedOrDefault<>( + "core", "gpgme.ctx.app_path", QString{}); + auto default_database_path = Module::RetrieveRTValueTypedOrDefault<>( + "core", "gpgme.ctx.default_database_path", QString{}); + auto gpgconf_path = Module::RetrieveRTValueTypedOrDefault<>( + "core", "gpgme.ctx.gpgconf_path", QString{}); + auto cms_path = Module::RetrieveRTValueTypedOrDefault<>( + "core", "gpgme.ctx.cms_path", QString{}); + auto assuan_path = Module::RetrieveRTValueTypedOrDefault<>( + "core", "gpgme.ctx.assuan_path", QString{}); + + if (gpgconf == 1) { + stream << Tr("GPGCONF Path: ") << gpgconf_path << '\n'; + } + + if (openpgp == 1) { + stream << Tr("GnuPG Path: ") << app_path << '\n'; + stream << Tr("Default Key Database Path: ") << default_database_path + << '\n'; + } + + if (cms == 1) { + stream << Tr("CMS Path: ") << cms_path << '\n'; + } + + if (assuan == 1) { + stream << Tr("ASSUAN Path: ") << assuan_path << '\n'; + } + + stream << '\n'; + + stream << "Key Database(s): " << '\n'; + stream << '\n'; + + auto key_database_list = + KeyDatabaseListSO(SettingsObject("key_database_list")); + const auto key_databases = key_database_list.key_databases; + + int index = 0; + for (const auto& key_database : key_databases) { + stream << Tr("Key Database [") << index++ << "] " << Tr("Name: ") + << key_database.name << " " << Tr("-> Path: ") << key_database.path + << '\n'; + } stream << Qt::endl; return 0; } |