summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnne Jan Brouwer <brouwer@annejan.com>2015-05-26 02:49:51 +0200
committerAnne Jan Brouwer <brouwer@annejan.com>2015-05-26 02:49:51 +0200
commit4a79096d8ef975bb0573cc9a96b0e3d5f2cdffbd (patch)
tree61bdc38512b1d4e897aa8441a6a7b37c3f3562a1
parent8a1120e93bbb60dd3e49024c414bd676060c8ee9 (diff)
working keygen
-rw-r--r--dialog.cpp5
-rw-r--r--dialog.h2
-rw-r--r--keygendialog.cpp30
-rw-r--r--keygendialog.ui7
-rw-r--r--mainwindow.cpp28
-rw-r--r--mainwindow.h3
6 files changed, 37 insertions, 38 deletions
diff --git a/dialog.cpp b/dialog.cpp
index 84d31b1e..19d2d7d4 100644
--- a/dialog.cpp
+++ b/dialog.cpp
@@ -396,9 +396,8 @@ void Dialog::wizard()
/**
* @brief Dialog::genKey
* @param QString batch
- * @return status
*/
-bool Dialog::genKey(QString batch)
+void Dialog::genKey(QString batch, QDialog *dialog)
{
- return mainWindow->genKey(batch);
+ mainWindow->genKey(batch, dialog);
}
diff --git a/dialog.h b/dialog.h
index a8879644..adb2fa82 100644
--- a/dialog.h
+++ b/dialog.h
@@ -42,7 +42,7 @@ public:
bool hideContent();
bool addGPGId();
void wizard();
- bool genKey(QString);
+ void genKey(QString, QDialog *);
private slots:
void on_radioButtonNative_clicked();
diff --git a/keygendialog.cpp b/keygendialog.cpp
index 744b80b9..a04ed77d 100644
--- a/keygendialog.cpp
+++ b/keygendialog.cpp
@@ -69,6 +69,9 @@ void KeygenDialog::replace(QString key, QString value)
QStringList lines = expert.split(QRegExp("[\r\n]"),QString::SkipEmptyParts);
foreach (QString line, lines) {
line.replace(QRegExp(key+":.*"), key + ": " + value);
+ if (key == "Passphrase") {
+ line.replace("%no-protection", "Passphrase: " + value);
+ }
clear.append(line);
}
ui->plainTextEdit->setPlainText(clear.join("\n"));
@@ -91,7 +94,6 @@ void KeygenDialog::no_protection(bool enable)
}
} else {
if (line.indexOf("Passphrase") == 0) {
- clear.append(line);
line = "%no-protection";
}
}
@@ -116,23 +118,15 @@ void KeygenDialog::done(int r)
ui->plainTextEdit->setEnabled(false);
// some kind of animation or at-least explanation needed here
// people don't like wating :D
- bool status = dialog->genKey(ui->plainTextEdit->toPlainText());
- if(status)
- {
- QDialog::done(r);
- return;
- }
- else
- {
- QMessageBox::critical(this, tr("GPG gen-key error"),
- tr("Something went wrong, I guess"));
- ui->widget->setEnabled(true);
- ui->buttonBox->setEnabled(true);
- ui->checkBox->setEnabled(true);
- on_checkBox_stateChanged(ui->checkBox->isChecked());
- // something went wrong, explain things?
- return;
- }
+ dialog->genKey(ui->plainTextEdit->toPlainText(), this);
+// QMessageBox::critical(this, tr("GPG gen-key error"),
+// tr("Something went wrong, I guess"));
+// ui->widget->setEnabled(true);
+// ui->buttonBox->setEnabled(true);
+// ui->checkBox->setEnabled(true);
+// on_checkBox_stateChanged(ui->checkBox->isChecked());
+// // something went wrong, explain things?
+// return;
}
else // cancel, close or exc was pressed
{
diff --git a/keygendialog.ui b/keygendialog.ui
index e6e4be04..ef9a2aea 100644
--- a/keygendialog.ui
+++ b/keygendialog.ui
@@ -100,10 +100,10 @@
<bool>true</bool>
</property>
<property name="plainText">
- <string># QtPass GPG key generator
+ <string># QtPass GPG key generator
#
-# first test version please comment
-# or email to qtpass@ijhack.org
+# first test version please comment
+#
%echo Generating a default key
Key-Type: default
Subkey-Type: default
@@ -111,7 +111,6 @@ Name-Real:
Name-Comment: QtPass
Name-Email:
Expire-Date: 0
-Passphrase:
%no-protection
# Do a commit here, so that we can later print &quot;done&quot; :-)
%commit
diff --git a/mainwindow.cpp b/mainwindow.cpp
index e042b7e8..4ba874ca 100644
--- a/mainwindow.cpp
+++ b/mainwindow.cpp
@@ -2,6 +2,7 @@
#include "ui_mainwindow.h"
#include "dialog.h"
#include "usersdialog.h"
+#include "keygendialog.h"
#include "util.h"
#include <QClipboard>
#include <QInputDialog>
@@ -418,10 +419,15 @@ void MainWindow::readyRead(bool finished = false) {
}
output.replace(QRegExp("<"), "&lt;");
output.replace(QRegExp(">"), "&gt;");
- }
-
- if (error.size() > 0) {
- output = "<font color=\"red\">" + error + "</font><br />" + output;
+ } else {
+ qDebug() << process->readAllStandardOutput();
+ qDebug() << process->readAllStandardError();
+ if (finished && 0 != keygen) {
+ qDebug() << "Keygen Done";
+ keygen->close();
+ keygen = 0;
+ // TODO some sanity checking !
+ }
}
output.replace(QRegExp("((http|https|ftp)\\://[a-zA-Z0-9\\-\\.]+\\.[a-zA-Z]{2,3}(:[a-zA-Z0-9]*)?/?([a-zA-Z0-9\\-\\._\\?\\,\\'/\\\\+&amp;%\\$#\\=~])*)"), "<a href=\"\\1\">\\1</a>");
@@ -982,16 +988,16 @@ QStringList MainWindow::getSecretKeys()
/**
* @brief Dialog::genKey
* @param QString batch
- * @return status
*/
-bool MainWindow::genKey(QString batch)
+void MainWindow::genKey(QString batch, QDialog *keygenWindow)
{
+ keygen = keygenWindow;
ui->statusBar->showMessage(tr("Generating GPG key pair"), 60000);
currentAction = GPG_INTERNAL;
executeWrapper(gpgExecutable , "--gen-key --no-tty --batch", batch);
- process->waitForFinished(600000); // ten minutes enough ?
- if (process->exitStatus() != QProcess::NormalExit) {
- return true;
- }
- return false;
+// process->waitForFinished(600000); // ten minutes enough ?
+// if (process->exitStatus() != QProcess::NormalExit) {
+// return true;
+// }
+// return false;
}
diff --git a/mainwindow.h b/mainwindow.h
index 4a2f6ebe..ddae9202 100644
--- a/mainwindow.h
+++ b/mainwindow.h
@@ -43,7 +43,7 @@ public:
void setApp(SingleApplication* app);
void setText(QString);
QStringList getSecretKeys();
- bool genKey(QString);
+ void genKey(QString, QDialog *);
private slots:
void on_updateButton_clicked();
@@ -95,6 +95,7 @@ private:
QStringList env;
QQueue<execQueueItem> *execQueue;
bool firstRun;
+ QDialog *keygen = 0;
void updateText();
void executePass(QString, QString = QString());
void executeWrapper(QString, QString, QString = QString());