Skip to content

Commit b8b2623

Browse files
committed
feat(context): add support for offline and pinentry config
* Load and display new environment config options for offline GnuPG mode and custom pinentry program path * Improves transparency of application startup parameters for users
1 parent c4e2c52 commit b8b2623

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

src/GpgFrontendContext.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,20 +39,31 @@ namespace GpgFrontend {
3939

4040
void GpgFrontendContext::load_env_conf_set_properties() {
4141
auto env_config = QDir::currentPath() + "/ENV.ini";
42-
if (!QFileInfo(env_config).exists()) return;
42+
if (!QFileInfo(env_config).exists()) {
43+
qInfo() << "No ENV.ini found, skipping loading environment config.";
44+
return;
45+
}
4346

4447
QSettings s(env_config, QSettings::IniFormat);
4548

4649
property("GFSelfCheck", s.value("SelfCheck", false).toBool());
4750
property("GFSecureLevel", s.value("SecureLevel", 0).toInt());
4851
property("GFPortableMode", s.value("PortableMode", false).toBool());
52+
property("GFGnuPGOfflineMode", s.value("GnuPGOfflineMode", false).toBool());
53+
property("GFPinentryProgramPath",
54+
s.value("PinentryProgramPath", "").toString());
4955

56+
// Set ShowConsoleOnWindows property
5057
property("GFShowConsoleOnWindows",
5158
s.value("ShowConsoleOnWindows", false).toBool());
5259

5360
qInfo() << "ENV" << "GFSelfCheck" << property("GFSelfCheck").toInt();
5461
qInfo() << "ENV" << "GFSecureLevel" << property("GFSecureLevel").toInt();
5562
qInfo() << "ENV" << "GFPortableMode" << property("GFPortableMode").toBool();
63+
qInfo() << "ENV" << "GFGnuPGOfflineMode"
64+
<< property("GFGnuPGOfflineMode").toBool();
65+
qInfo() << "ENV" << "GFPinentryProgramPath"
66+
<< property("GFPinentryProgramPath").toString();
5667

5768
qInfo() << "ENV" << "GFShowConsoleOnWindows"
5869
<< property("GFShowConsoleOnWindows").toBool();

src/ui/dialog/help/AboutDialog.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,9 @@ StatusTab::StatusTab(QWidget* parent) : QWidget(parent) {
193193
const int secure_level = qApp->property("GFSecureLevel").toInt();
194194
const bool portable_mode = qApp->property("GFPortableMode").toBool();
195195
const bool self_check = qApp->property("GFSelfCheck").toBool();
196+
const bool gnupg_offline_mode = qApp->property("GFGnuPGOfflineMode").toBool();
197+
const QString pinentry_program_path =
198+
qApp->property("GFPinentryProgramPath").toString();
196199

197200
auto* main_layout = new QVBoxLayout(this);
198201
auto* status_form = new QFormLayout();
@@ -225,10 +228,23 @@ StatusTab::StatusTab(QWidget* parent) : QWidget(parent) {
225228
const QString self_check_str =
226229
self_check ? tr("Self-Check Active") : tr("Self-Check Disabled");
227230

231+
// GnuPG Offline Mode string
232+
const QString gnupg_offline_mode_str =
233+
gnupg_offline_mode ? tr("Active") : tr("Disabled");
234+
235+
// Pinentry Program Path string
236+
const QString pinentry_program_path_str = pinentry_program_path.isEmpty()
237+
? tr("Default Pinentry Program")
238+
: pinentry_program_path;
239+
228240
// Add rows to form
229241
status_form->addRow(tr("Security Level:"), new QLabel(secure_level_str));
230242
status_form->addRow(tr("Running Mode:"), new QLabel(portable_mode_str));
231243
status_form->addRow(tr("Self-Check Status:"), new QLabel(self_check_str));
244+
status_form->addRow(tr("GnuPG Offline Mode:"),
245+
new QLabel(gnupg_offline_mode_str));
246+
status_form->addRow(tr("Pinentry Program Path:"),
247+
new QLabel(pinentry_program_path_str));
232248

233249
auto* tip_label = new QLabel(tr(
234250
"Tips: The above parameters reflect how the application was started. "));

0 commit comments

Comments
 (0)