aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--gpgcontext.cpp22
-rw-r--r--mainwindow.cpp1
-rwxr-xr-xsettingsdialog.cpp80
-rwxr-xr-xsettingsdialog.h23
4 files changed, 124 insertions, 2 deletions
diff --git a/gpgcontext.cpp b/gpgcontext.cpp
index 8f7c07e..45e053b 100644
--- a/gpgcontext.cpp
+++ b/gpgcontext.cpp
@@ -68,7 +68,18 @@ GpgContext::GpgContext()
#else
gpgBin = appPath + "/bin/gpg";
#endif
- gpgKeys = appPath + "/keydb";
+
+ QSettings settings;
+ QString accKeydbPath = settings.value("gpgpaths/keydbpath").toString();
+ QString gpgKeys = appPath + "/keydb/"+accKeydbPath;
+
+ if (accKeydbPath != "") {
+ if (!QDir(gpgKeys).exists()) {
+ QMessageBox::critical(0,tr("keydb path"),tr("Didn't find keydb directory. Switching to gpg4usb's default keydb directory for this session."));
+ gpgKeys = appPath + "/keydb";
+ }
+ }
+
/* err = gpgme_ctx_set_engine_info(mCtx, GPGME_PROTOCOL_OpenPGP,
gpgBin.toUtf8().constData(),
gpgKeys.toUtf8().constData());*/
@@ -79,6 +90,15 @@ GpgContext::GpgContext()
checkErr(err);
#endif
+ gpgme_engine_info_t engineInfo;
+ engineInfo = gpgme_ctx_get_engine_info(mCtx);
+
+
+ while (engineInfo !=NULL ) {
+ qDebug() << gpgme_get_protocol_name(engineInfo->protocol);
+ engineInfo=engineInfo->next;
+ }
+
/** Setting the output type must be done at the beginning */
/** think this means ascii-armor --> ? */
gpgme_set_armor(mCtx, 1);
diff --git a/mainwindow.cpp b/mainwindow.cpp
index 1a698ea..6e00eb9 100644
--- a/mainwindow.cpp
+++ b/mainwindow.cpp
@@ -944,6 +944,7 @@ void MainWindow::slotOpenSettingsDialog()
{
QString preLang = settings.value("int/lang").toString();
+ QString preKeydbPath = settings.value("gpgpaths/keydbpath").toString();
new SettingsDialog(mCtx, this);
// Iconsize
diff --git a/settingsdialog.cpp b/settingsdialog.cpp
index ac41092..c4eda75 100755
--- a/settingsdialog.cpp
+++ b/settingsdialog.cpp
@@ -31,11 +31,13 @@ SettingsDialog::SettingsDialog(GpgME::GpgContext *ctx, QWidget *parent)
mimeTab = new MimeTab;
keyserverTab = new KeyserverTab;
advancedTab = new AdvancedTab;
+ gpgPathsTab = new GpgPathsTab;
tabWidget->addTab(generalTab, tr("General"));
tabWidget->addTab(appearanceTab, tr("Appearance"));
tabWidget->addTab(mimeTab, tr("PGP/Mime"));
tabWidget->addTab(keyserverTab, tr("Keyserver"));
+ tabWidget->addTab(gpgPathsTab, tr("Gpg paths"));
tabWidget->addTab(advancedTab, tr("Advanced"));
buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok
@@ -81,6 +83,7 @@ void SettingsDialog::slotAccept()
appearanceTab->applySettings();
keyserverTab->applySettings();
advancedTab->applySettings();
+ gpgPathsTab->applySettings();
if (getRestartNeeded()) {
emit signalRestartNeeded(true);
}
@@ -611,3 +614,80 @@ void AdvancedTab::applySettings()
QSettings settings;
settings.setValue("advanced/steganography", steganoCheckBox->isChecked());
}
+
+GpgPathsTab::GpgPathsTab(QWidget *parent)
+ : QWidget(parent)
+{
+ setSettings();
+
+ /*****************************************
+ * Keydb Box
+ *****************************************/
+ QGroupBox *keydbBox = new QGroupBox(tr("Relative path to keydb"));
+ QGridLayout *keydbBoxLayout = new QGridLayout();
+
+ // Label containing the current keydbpath relative to default keydb path
+ keydbLabel = new QLabel(accKeydbPath,this);
+
+ QPushButton *keydbButton = new QPushButton("Change keydb path",this);
+ connect(keydbButton, SIGNAL(clicked()), this, SLOT(chooseKeydbDir()));
+ QPushButton *keydbDefaultButton = new QPushButton("Set keydb to default path",this);
+ connect(keydbDefaultButton, SIGNAL(clicked()), this, SLOT(setKeydbPathToDefault()));
+
+ keydbBox->setLayout(keydbBoxLayout);
+ keydbBoxLayout->addWidget(new QLabel(tr("Current keydb path: ")),1,1);
+ keydbBoxLayout->addWidget(keydbLabel,1,2);
+ keydbBoxLayout->addWidget(keydbButton,1,3);
+ keydbBoxLayout->addWidget(keydbDefaultButton,2,3);
+ keydbBoxLayout->addWidget(new QLabel(tr("<b>NOTE: </b> Gpg4usb will restart automatically if you change the keydb path!")),3,1,1,3);
+
+ QVBoxLayout *mainLayout = new QVBoxLayout;
+ mainLayout->addWidget(keydbBox);
+ mainLayout->addStretch(1);
+ setLayout(mainLayout);
+}
+
+QString GpgPathsTab::getRelativePath(const QString dir1,const QString dir2)
+{
+ QDir dir(dir1);
+ QString s;
+
+ s = dir.relativeFilePath(dir2);
+ qDebug() << "relative path: " << s;
+ if (s.isEmpty()) {
+ s = ".";
+ }
+ return s;
+}
+
+void GpgPathsTab::setKeydbPathToDefault()
+{
+ accKeydbPath = ".";
+ keydbLabel->setText(".");
+}
+
+QString GpgPathsTab::chooseKeydbDir()
+{
+ QString dir = QFileDialog::getExistingDirectory(this,tr ("Choose keydb directory"),accKeydbPath,QFileDialog::ShowDirsOnly);
+
+ accKeydbPath = getRelativePath(defKeydbPath, dir);
+ keydbLabel->setText(accKeydbPath);
+ return "";
+}
+
+void GpgPathsTab::setSettings()
+{
+ defKeydbPath = qApp->applicationDirPath() + "/keydb";
+
+ QSettings settings;
+ accKeydbPath = settings.value("gpgpaths/keydbpath").toString();
+ if (accKeydbPath.isEmpty()) {
+ accKeydbPath = ".";
+ }
+}
+
+void GpgPathsTab::applySettings()
+{
+ QSettings settings;
+ settings.setValue("gpgpaths/keydbpath",accKeydbPath);
+}
diff --git a/settingsdialog.h b/settingsdialog.h
index 20bb4d2..b709b71 100755
--- a/settingsdialog.h
+++ b/settingsdialog.h
@@ -158,7 +158,27 @@ signals:
};
-class SettingsDialog : public QDialog
+ class GpgPathsTab : public QWidget
+ {
+ Q_OBJECT
+ public:
+ GpgPathsTab(QWidget *parent = 0);
+ void applySettings();
+
+private:
+ QString getRelativePath(const QString dir1,const QString dir2);
+ QString defKeydbPath; /** The default keydb path used by gpg4usb */
+ QString accKeydbPath; /** The currently used keydb path */
+ QLabel *keydbLabel;
+ void setSettings();
+
+ private slots:
+ QString chooseKeydbDir();
+ void setKeydbPathToDefault();
+
+ };
+
+ class SettingsDialog : public QDialog
{
Q_OBJECT
@@ -169,6 +189,7 @@ class SettingsDialog : public QDialog
AppearanceTab *appearanceTab;
KeyserverTab *keyserverTab;
AdvancedTab *advancedTab;
+ GpgPathsTab *gpgPathsTab;
static QHash<QString, QString> listLanguages();
public slots: