aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornils <nils@34ebc366-c3a9-4b3c-9f84-69acf7962910>2011-11-03 19:12:57 +0000
committernils <nils@34ebc366-c3a9-4b3c-9f84-69acf7962910>2011-11-03 19:12:57 +0000
commit6ef2367c83d57c3f70091a29c112a2c62e3f541c (patch)
treee21715749f7ccbdceaba1e941fc7ca30cf662f35
parentupdated and released translation files (diff)
downloadgpg4usb-6ef2367c83d57c3f70091a29c112a2c62e3f541c.tar.gz
gpg4usb-6ef2367c83d57c3f70091a29c112a2c62e3f541c.zip
added wizardpage for importing keyrings from gnupg homedir. But getting gnupg-homedir in windows is missing
git-svn-id: http://cpunk.de/svn/src/gpg4usb/trunk@596 34ebc366-c3a9-4b3c-9f84-69acf7962910
Diffstat (limited to '')
-rw-r--r--TODO1
-rw-r--r--main.cpp1
-rw-r--r--release/css/default.css2
-rw-r--r--wizard.cpp97
-rw-r--r--wizard.h22
5 files changed, 120 insertions, 3 deletions
diff --git a/TODO b/TODO
index 93272c3..07be1c8 100644
--- a/TODO
+++ b/TODO
@@ -30,6 +30,7 @@ Release 0.3.2
- refactoring and cleanup: [DONE]
- gpgwin.cpp -> mainwindow.cpp [DONE]
- context.cpp -> gpgcontext.cpp [DONE]
+- show keyrings (files with .gpg) in import from file dialog too
- set gpgme error language to chosen language (context.cpp:49)
- import from keyserver doesn't end, if network-connection is available, but no connection to keyserver (?)
- minimal steganography option: remove or add pgp-headers on demand
diff --git a/main.cpp b/main.cpp
index cfe7ae2..57ae4b8 100644
--- a/main.cpp
+++ b/main.cpp
@@ -46,6 +46,7 @@ int main(int argc, char *argv[])
unsetenv("GPG_AGENT_INFO");
#endif
+ qDebug() << getenv("GNUPGHOME");
// take care of gpg not creating directorys on harddisk
putenv(QString("GNUPGHOME=" + appPath + "/keydb").toAscii().data());
diff --git a/release/css/default.css b/release/css/default.css
index 8165d2a..c839b79 100644
--- a/release/css/default.css
+++ b/release/css/default.css
@@ -1,8 +1,6 @@
/* CSS for GUI, look e.g. at http://doc.qt.nokia.com/latest/stylesheet-examples.html */
-/*#verifyBox { background-color: #CBFDCB }*/
-/*#cryptToolBar { background-color: #CBFDCB }*/
/*
QLabel, QAbstractButton {
font: bold;
diff --git a/wizard.cpp b/wizard.cpp
index 320a9ad..5bb6823 100644
--- a/wizard.cpp
+++ b/wizard.cpp
@@ -29,9 +29,11 @@ Wizard::Wizard(GpgME::GpgContext *ctx, QWidget *parent)
mCtx=ctx;
IntroPage *introPage = new IntroPage();
KeyGenPage *keyGenPage = new KeyGenPage(mCtx);
+ ImportPage *importPage = new ImportPage(mCtx);
ConclusionPage *conclusionPage = new ConclusionPage();
addPage(introPage);
addPage(keyGenPage);
+ addPage(importPage);
addPage(conclusionPage);
#ifndef Q_WS_MAC
@@ -66,7 +68,7 @@ KeyGenPage::KeyGenPage(GpgME::GpgContext *ctx, QWidget *parent)
setTitle(tr("Key-Generating"));
topLabel = new QLabel(tr("First you've got to create an own key."));
createKeyButton = new QPushButton(tr("Create New Key"));
- layout = new QVBoxLayout;
+ layout = new QVBoxLayout();
layout->addWidget(topLabel);
layout->addWidget(createKeyButton);
connect(createKeyButton, SIGNAL(clicked()), this, SLOT(generateKeyDialog()));
@@ -91,6 +93,99 @@ void KeyGenPage::showKeyGeneratedMessage()
layout->addWidget(new QLabel(tr("key generated. Now you can crypt and sign texts.")));
}
+ImportPage::ImportPage(GpgME::GpgContext *ctx, QWidget *parent)
+ : QWizardPage(parent)
+{
+ mCtx=ctx;
+ setTitle(tr("Keyring Import from GnuPG-home-directory"));
+ topLabel = new QLabel(tr("Should I try to import keys from gnupg?"));
+
+ // Layout for private keys
+ privateKeysCheckBox = new QCheckBox();
+ QLabel *privateKeysLabel = new QLabel(tr("Private keys"));
+ QWidget *privHBox = new QWidget(this);
+ QHBoxLayout *privHBoxLayout = new QHBoxLayout();
+ privHBoxLayout->addWidget(privateKeysCheckBox);
+ privHBoxLayout->addWidget(privateKeysLabel);
+ privHBox->setLayout(privHBoxLayout);
+
+ // Layout for public keys
+ publicKeysCheckBox = new QCheckBox();
+ QLabel *publicKeysLabel = new QLabel(tr("Public keys"));
+ QWidget *pubHBox = new QWidget();
+ QHBoxLayout *pubHBoxLayout = new QHBoxLayout();
+ pubHBoxLayout->addWidget(publicKeysCheckBox);
+ pubHBoxLayout->addWidget(publicKeysLabel);
+ pubHBox->setLayout(pubHBoxLayout);
+
+ importKeyButton = new QPushButton(tr("Import keys"));
+ layout = new QVBoxLayout();
+ layout->addWidget(topLabel);
+ layout->addWidget(privHBox);
+ layout->addWidget(pubHBox);
+ layout->addWidget(importKeyButton);
+ connect(importKeyButton, SIGNAL(clicked()), this, SLOT(importKeys()));
+ setLayout(layout);
+}
+
+bool ImportPage::importKeys()
+{
+ // first get gnupghomedir and check, if it exists
+ QString gnuPGHome = getGnuPGHome();
+ if (gnuPGHome == NULL) {
+ qDebug() << "couldn't locate gnupg-Homedirectory";
+ return false;
+ }
+
+ // try to import private files, if private key checkbox is checked
+ if (privateKeysCheckBox->isChecked()) {
+ QString privRingFile = gnuPGHome+"/secring.gpg";
+ QFile file;
+ file.setFileName(privRingFile);
+ if (!file.open(QIODevice::ReadOnly)) {
+ qDebug() << tr("Couldn't Open Private Keyringfile: ") + privRingFile;
+ }
+ QByteArray inBuffer = file.readAll();
+
+ mCtx->importKey(inBuffer);
+ }
+
+ // try to import public keys, if public checkbox is checked
+ if (publicKeysCheckBox->isChecked()) {
+ QString pubRingFile = gnuPGHome+"/pubring.gpg";
+ QFile file;
+ file.setFileName(pubRingFile);
+ if (!file.open(QIODevice::ReadOnly)) {
+ qDebug() << tr("Couldn't Open Public Keyringfile: ") + pubRingFile;
+ }
+ QByteArray inBuffer = file.readAll();
+
+ mCtx->importKey(inBuffer);
+ }
+
+ return true;
+}
+
+QString ImportPage::getGnuPGHome()
+{
+ QString gnuPGHome="";
+ #ifdef _WIN32
+ QSettings gnuPGsettings("HKEY_CURRENT_USER\\Software\\GNU\\GNUPG\\Default", QSettings::Nativeformat);
+ gnuPGsettings.value();
+ #else
+ gnuPGHome=QDir::homePath()+"/.gnupg";
+ if (! QFile(gnuPGHome).exists()) {
+ return NULL;
+ }
+ #endif
+
+ return gnuPGHome;
+}
+
+int ImportPage::nextId() const
+{
+ return 3;
+}
ConclusionPage::ConclusionPage(QWidget *parent)
: QWizardPage(parent)
diff --git a/wizard.h b/wizard.h
index beccd78..73dd38e 100644
--- a/wizard.h
+++ b/wizard.h
@@ -72,6 +72,28 @@ private:
QVBoxLayout *layout;
};
+class ImportPage : public QWizardPage
+{
+ Q_OBJECT
+
+public:
+ ImportPage(GpgME::GpgContext *ctx, QWidget *parent = 0);
+
+private slots:
+ bool importKeys();
+
+private:
+ int nextId() const;
+ QString getGnuPGHome();
+
+ QLabel *topLabel;
+ QVBoxLayout *layout;
+ GpgME::GpgContext *mCtx;
+ QCheckBox *privateKeysCheckBox;
+ QCheckBox *publicKeysCheckBox;
+ QPushButton *importKeyButton;
+};
+
class ConclusionPage : public QWizardPage
{
Q_OBJECT