aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornils <nils@34ebc366-c3a9-4b3c-9f84-69acf7962910>2009-09-13 17:00:05 +0000
committernils <nils@34ebc366-c3a9-4b3c-9f84-69acf7962910>2009-09-13 17:00:05 +0000
commita50ece2918992b91134bb03b26595d35c1f2db92 (patch)
tree148a55752eb137f654bf6f6e174f86edcb7767b0
parentadd scripts, structure and readme for crosscompiling for win & lin32, partial... (diff)
downloadgpg4usb-a50ece2918992b91134bb03b26595d35c1f2db92.tar.gz
gpg4usb-a50ece2918992b91134bb03b26595d35c1f2db92.zip
put keygeneration to own thread for GUI responsibility
git-svn-id: http://cpunk.de/svn/src/gpg4usb/trunk@212 34ebc366-c3a9-4b3c-9f84-69acf7962910
-rw-r--r--gpg4usb.pro4
-rw-r--r--keygenthread.cpp20
-rw-r--r--keygenthread.h29
-rwxr-xr-xkeymgmt.cpp36
-rwxr-xr-xkeymgmt.h5
5 files changed, 83 insertions, 11 deletions
diff --git a/gpg4usb.pro b/gpg4usb.pro
index ce18643..4a64200 100644
--- a/gpg4usb.pro
+++ b/gpg4usb.pro
@@ -12,8 +12,8 @@ INCLUDEPATH += . ./include
CONFIG += release static
# Input
-HEADERS += context.h gpgwin.h keylist.h attachments.h keymgmt.h fileencryptiondialog.h
-SOURCES += context.cpp gpgwin.cpp main.cpp keylist.cpp attachments.cpp keymgmt.cpp fileencryptiondialog.cpp
+HEADERS += context.h gpgwin.h keylist.h attachments.h keymgmt.h fileencryptiondialog.h keygenthread.h
+SOURCES += context.cpp gpgwin.cpp main.cpp keylist.cpp attachments.cpp keymgmt.cpp fileencryptiondialog.cpp keygenthread.cpp
RC_FILE = gpg4usb.rc
# comment out line below for static building
LIBS += -lgpgme -lgpg-error
diff --git a/keygenthread.cpp b/keygenthread.cpp
new file mode 100644
index 0000000..9fc6a5a
--- /dev/null
+++ b/keygenthread.cpp
@@ -0,0 +1,20 @@
+#include "keygenthread.h"
+
+
+KeyGenThread::KeyGenThread(QString keyGenParams, GpgME::Context *ctx)
+{
+ qDebug() << keyGenParams;
+ this->keyGenParams=keyGenParams;
+ this->ctx=ctx;
+ abort=false;
+}
+
+void KeyGenThread::run()
+{
+ qDebug() << keyGenParams;
+ qDebug("hallo2");
+ ctx->generateKey(&keyGenParams);
+
+ qDebug("hallo323");
+
+}
diff --git a/keygenthread.h b/keygenthread.h
new file mode 100644
index 0000000..b9196f5
--- /dev/null
+++ b/keygenthread.h
@@ -0,0 +1,29 @@
+#include <qthread.h>
+#include <iostream>
+#include <string>
+#include <cmath>
+#include <QtGui>
+
+class QMessageBox;
+
+#include "context.h"
+
+class KeyGenThread : public QThread {
+ Q_OBJECT
+
+public:
+ KeyGenThread(QString keyGenParams, GpgME::Context *ctx);
+
+signals:
+ void keyGenerated();
+
+private:
+ QString keyGenParams;
+ GpgME::Context *ctx;
+ bool abort;
+ QMutex mutex;
+
+protected:
+ void run();
+
+};
diff --git a/keymgmt.cpp b/keymgmt.cpp
index de0ec35..ea11aca 100755
--- a/keymgmt.cpp
+++ b/keymgmt.cpp
@@ -111,6 +111,8 @@ void KeyMgmt::createToolBars()
keyToolBar->addAction(importKeyFromFileAct);
keyToolBar->addAction(importKeyFromClipboardAct);
keyToolBar->addSeparator();
+ keyToolBar->addAction(generateKeyDialogAct);
+ keyToolBar->addSeparator();
keyToolBar->addAction(deleteCheckedKeysAct);
keyToolBar->addSeparator();
keyToolBar->addAction(exportKeyToFileAct);
@@ -194,13 +196,14 @@ void KeyMgmt::generateKeyDialog()
expireLabel = new QLabel(tr("Never Expire"));
pwStrengthLabel = new QLabel(tr("Password: Strength\nWeak -> Strong"));
errorLabel = new QLabel(tr(""));
- nameEdit = new QLineEdit(genkeyDialog);
+ nameEdit = new QLineEdit("hallo",genkeyDialog);
emailEdit = new QLineEdit(genkeyDialog);
commentEdit = new QLineEdit(genkeyDialog);
keySizeSpinBox = new QSpinBox(genkeyDialog);
keySizeSpinBox->setRange(512,8192);
- keySizeSpinBox->setValue(2048);
+ keySizeSpinBox->setValue(512);
+
keySizeSpinBox->setSingleStep(256);
dateEdit = new QDateEdit(QDate::currentDate().addYears(5), genkeyDialog);
@@ -212,8 +215,8 @@ void KeyMgmt::generateKeyDialog()
expireCheckBox = new QCheckBox(genkeyDialog);
expireCheckBox->setCheckState(Qt::Checked);
- passwordEdit = new QLineEdit(genkeyDialog);
- repeatpwEdit = new QLineEdit(genkeyDialog);
+ passwordEdit = new QLineEdit("asd",genkeyDialog);
+ repeatpwEdit = new QLineEdit("asd",genkeyDialog);
passwordEdit->setEchoMode(QLineEdit::Password);
repeatpwEdit->setEchoMode(QLineEdit::Password);
@@ -260,7 +263,7 @@ void KeyMgmt::generateKeyDialog()
connect(passwordEdit,SIGNAL(textChanged(QString)), this, SLOT(passwordEditChanged()));
genkeyDialog->setLayout(vbox2);
genkeyDialog->show();
-
+
if(genkeyDialog->exec() == QDialog::Accepted ) {
}
@@ -269,6 +272,7 @@ void KeyMgmt::generateKeyDialog()
void KeyMgmt::keyGenAccept()
{
+
QString errorString="";
QString keyGenParams="";
/**
@@ -306,8 +310,26 @@ void KeyMgmt::keyGenAccept()
"Passphrase: "+passwordEdit->text()+"\n";
}
keyGenParams += "</GnupgKeyParms>";
- mCtx->generateKey(&keyGenParams);
- genkeyDialog->accept();
+// mCtx->generateKey(&keyGenParams);
+
+ KeyGenThread *kg = new KeyGenThread(keyGenParams, mCtx);
+ kg->start();
+
+ genkeyDialog->accept();
+ QProgressDialog *qpd = new QProgressDialog("Generating", "Jau",0,5,this);
+ qpd->setWindowModality(Qt::WindowModal);
+
+ int value=0;
+ while(kg->isRunning())
+ {
+ value++;
+ value=value%5;
+ qDebug() << value;
+ qpd->setValue(value);
+ //sleep(1);
+ }
+ qpd->cancel();
+ //genkeyDialog->accept();
} else {
/**
diff --git a/keymgmt.h b/keymgmt.h
index bd91fb7..81577de 100755
--- a/keymgmt.h
+++ b/keymgmt.h
@@ -38,6 +38,7 @@ class QSlider;
#include "context.h"
#include "keylist.h"
+#include "keygenthread.h"
class KeyMgmt : public QMainWindow
{
@@ -82,8 +83,8 @@ private:
QAction *deleteSelectedKeysAct;
QAction *generateKeyDialogAct;
QAction *closeAct;
-
-
+ KeyGenThread *keyGenThread;
+ QMessageBox msgbox;
/**
* Variables For Key-Generation
*/