aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/gpg/GpgContext.cpp73
-rw-r--r--src/ui/help/AboutDialog.cpp7
-rw-r--r--src/ui/help/VersionCheckThread.cpp5
-rw-r--r--src/ui/keypair_details/KeyPairDetailTab.cpp30
-rw-r--r--src/ui/main_window/MainWindowSlotFunction.cpp2
-rw-r--r--src/ui/widgets/FilePage.cpp33
-rw-r--r--src/ui/widgets/TextEdit.cpp2
7 files changed, 127 insertions, 25 deletions
diff --git a/src/gpg/GpgContext.cpp b/src/gpg/GpgContext.cpp
index 7ec521a7..0462433d 100644
--- a/src/gpg/GpgContext.cpp
+++ b/src/gpg/GpgContext.cpp
@@ -24,6 +24,7 @@
#include "gpg/GpgContext.h"
+#include <functional>
#include <unistd.h> /* contains read/write */
#ifdef _WIN32
@@ -72,8 +73,10 @@ namespace GpgME {
<< engineInfo->home_dir << engineInfo->version;
if (engineInfo->protocol == GPGME_PROTOCOL_GPGCONF && strcmp(engineInfo->version, "1.0.0") != 0)
find_gpgconf = true;
- if (engineInfo->protocol == GPGME_PROTOCOL_OpenPGP && strcmp(engineInfo->version, "1.0.0") != 0)
+ if (engineInfo->protocol == GPGME_PROTOCOL_OpenPGP && strcmp(engineInfo->version, "1.0.0") != 0) {
+ gpgExec = engineInfo->file_name;
find_openpgp = true;
+ }
if (engineInfo->protocol == GPGME_PROTOCOL_CMS && strcmp(engineInfo->version, "1.0.0") != 0)
find_cms = true;
if (engineInfo->protocol == GPGME_PROTOCOL_ASSUAN)
@@ -625,20 +628,31 @@ namespace GpgME {
}
/** return type should be gpgme_error_t*/
- void GpgContext::executeGpgCommand(const QStringList &arguments, QByteArray *stdOut, QByteArray *stdErr) {
+ QProcess * GpgContext::executeGpgCommand(const QStringList &arguments, QByteArray *stdOut, QByteArray *stdErr,
+ const std::function<void(QProcess *)> &interactFunc) {
QStringList args;
- args << "--homedir" << gpgKeys << "--batch" << arguments;
+ args << arguments;
+
+ auto *gpgProcess = new QProcess(this);
+ qDebug() << "gpgExec" << gpgExec << args;
- qDebug() << args;
- QProcess gpg;
- // qDebug() << "engine->file_name" << engine->file_name;
+ gpgProcess->setReadChannel(QProcess::StandardOutput);
+ connect(gpgProcess, SIGNAL(finished(int,QProcess::ExitStatus)),
+ gpgProcess, SLOT(deleteLater()));
+ connect(gpgProcess, &QProcess::readyReadStandardOutput, this, [gpgProcess, interactFunc]() {
+ qDebug() << "Function Called" << &gpgProcess;
+ // interactFunc(gpgProcess);
+ });
- gpg.start(gpgBin, args);
- gpg.waitForFinished();
+ gpgProcess->start(gpgExec, args);
- *stdOut = gpg.readAllStandardOutput();
- *stdErr = gpg.readAllStandardError();
- qDebug() << *stdOut;
+ if (gpgProcess->waitForStarted()){
+ qDebug() << "Gpg Process Started Success";
+ } else {
+ qDebug() << "Gpg Process Started Failed";
+ }
+
+ return gpgProcess;
}
/***
@@ -1180,4 +1194,41 @@ namespace GpgME {
}
return true;
}
+
+ QProcess * GpgContext::generateRevokeCert(const GpgKey &key, const QString &outputFileName) {
+ QByteArray out, stdErr;
+ auto process = executeGpgCommand({
+ "--command-fd",
+ "0",
+ "--status-fd", "1",
+ "-o",
+ outputFileName,
+ "--gen-revoke",
+ key.fpr
+ }, &out, &stdErr,
+ [](QProcess *proc) {
+ qDebug() << "Function Called" << proc;
+ while (proc->canReadLine()) {
+ const QString line = QString::fromUtf8(proc->readLine()).trimmed();
+ // Command-fd is a stable interface, while this is all kind of hacky we
+ // are on a deadline :-/
+ if (line == QLatin1String("[GNUPG:] GET_BOOL gen_revoke.okay")) {
+ proc->write("y\n");
+ } else if (line == QLatin1String("[GNUPG:] GET_LINE ask_revocation_reason.code")) {
+ proc->write("0\n");
+ } else if (line == QLatin1String("[GNUPG:] GET_LINE ask_revocation_reason.text")) {
+ proc->write("\n");
+ } else if (line == QLatin1String("[GNUPG:] GET_BOOL openfile.overwrite.okay")) {
+ // We asked before
+ proc->write("y\n");
+ } else if (line == QLatin1String("[GNUPG:] GET_BOOL ask_revocation_reason.okay")) {
+ proc->write("y\n");
+ }
+ }
+ });
+
+ qDebug() << "GenerateRevokeCert Process" << process;
+
+ return process;
+ }
}
diff --git a/src/ui/help/AboutDialog.cpp b/src/ui/help/AboutDialog.cpp
index 4c9b54c9..807c509d 100644
--- a/src/ui/help/AboutDialog.cpp
+++ b/src/ui/help/AboutDialog.cpp
@@ -181,6 +181,13 @@ void UpdateTab::getLatestVersion() {
this->pb->setHidden(true);
+ if(replay->error() != QNetworkReply::NoError) {
+ qDebug() << "VersionCheckThread Found Network Error";
+ auto latestVersion = "Unknown";
+ latestVersionLabel->setText("<center><b>" + tr("Latest Version From Github: ") + latestVersion + "</b></center>");
+ return;
+ }
+
QByteArray bytes = replay->readAll();
Document d;
diff --git a/src/ui/help/VersionCheckThread.cpp b/src/ui/help/VersionCheckThread.cpp
index 7bd0eb8f..c7c77d1c 100644
--- a/src/ui/help/VersionCheckThread.cpp
+++ b/src/ui/help/VersionCheckThread.cpp
@@ -20,6 +20,11 @@ void VersionCheckThread::run() {
QApplication::processEvents();
}
+ if(mNetworkReply->error() != QNetworkReply::NoError) {
+ qDebug() << "VersionCheckThread Found Network Error";
+ return;
+ }
+
QByteArray bytes = mNetworkReply->readAll();
Document d;
diff --git a/src/ui/keypair_details/KeyPairDetailTab.cpp b/src/ui/keypair_details/KeyPairDetailTab.cpp
index f2a3e613..0363ae30 100644
--- a/src/ui/keypair_details/KeyPairDetailTab.cpp
+++ b/src/ui/keypair_details/KeyPairDetailTab.cpp
@@ -23,6 +23,7 @@
*/
#include "ui/keypair_details/KeyPairDetailTab.h"
+#include "ui/WaitingDialog.h"
KeyPairDetailTab::KeyPairDetailTab(GpgME::GpgContext *ctx, const GpgKey &mKey, QWidget *parent) : mKey(mKey), QWidget(parent) {
@@ -140,9 +141,17 @@ KeyPairDetailTab::KeyPairDetailTab(GpgME::GpgContext *ctx, const GpgKey &mKey, Q
vboxPK->addWidget(editExpiresButton);
connect(editExpiresButton, SIGNAL(clicked()), this, SLOT(slotModifyEditDatetime()));
+ auto hBoxLayout = new QHBoxLayout();
auto *keyServerOperaButton = new QPushButton(tr("Key Server Operation (Pubkey)"));
keyServerOperaButton->setStyleSheet("text-align:center;");
- vboxPK->addWidget(keyServerOperaButton);
+
+ auto *revokeCertGenButton = new QPushButton(tr("Generate Revoke Certificate"));
+ connect(revokeCertGenButton, SIGNAL(clicked()), this, SLOT(slotGenRevokeCert()));
+
+ hBoxLayout->addWidget(keyServerOperaButton);
+ hBoxLayout->addWidget(revokeCertGenButton);
+
+ vboxPK->addLayout(hBoxLayout);
connect(keyServerOperaButton, SIGNAL(clicked()), this, SLOT(slotModifyEditDatetime()));
// Set Menu
@@ -300,7 +309,7 @@ void KeyPairDetailTab::slotRefreshKeyInfo() {
void KeyPairDetailTab::createKeyServerOperaMenu() {
keyServerOperaMenu = new QMenu(this);
- auto *uploadKeyPair = new QAction(tr("Upload Key Pair"), this);
+ auto *uploadKeyPair = new QAction(tr("Upload Key Pair to Key Server"), this);
connect(uploadKeyPair, SIGNAL(triggered()), this, SLOT(slotUploadKeyToServer()));
auto *updateKeyPair = new QAction(tr("Update Key Pair"), this);
connect(updateKeyPair, SIGNAL(triggered()), this, SLOT(slotUpdateKeyToServer()));
@@ -324,3 +333,20 @@ void KeyPairDetailTab::slotUpdateKeyToServer() {
dialog->slotImportKey(keys);
}
+void KeyPairDetailTab::slotGenRevokeCert() {
+ auto mOutputFileName = QFileDialog::getSaveFileName(this, tr("Generate revocation certificate"),
+ QString(),
+ QStringLiteral("%1 (*.rev)").arg(tr("Revocation Certificates")));
+
+ auto process = mCtx->generateRevokeCert(mKey, mOutputFileName);
+
+ auto *dialog = new WaitingDialog("Generating", this);
+
+ while(process->state() == QProcess::Running) {
+ QApplication::processEvents();
+ }
+
+ dialog->close();
+
+}
+
diff --git a/src/ui/main_window/MainWindowSlotFunction.cpp b/src/ui/main_window/MainWindowSlotFunction.cpp
index 8a4b786e..4bcee080 100644
--- a/src/ui/main_window/MainWindowSlotFunction.cpp
+++ b/src/ui/main_window/MainWindowSlotFunction.cpp
@@ -398,7 +398,7 @@ void MainWindow::slotDecryptVerify() {
connect(thread, SIGNAL(finished(QPrivateSignal)), thread, SLOT(deleteLater()));
thread->start();
- WaitingDialog *dialog = new WaitingDialog(tr("Decrypting and Verifying"), this);
+ auto *dialog = new WaitingDialog(tr("Decrypting and Verifying"), this);
while (thread->isRunning()) {
QApplication::processEvents();
}
diff --git a/src/ui/widgets/FilePage.cpp b/src/ui/widgets/FilePage.cpp
index 65755509..b9602d58 100644
--- a/src/ui/widgets/FilePage.cpp
+++ b/src/ui/widgets/FilePage.cpp
@@ -105,17 +105,22 @@ FilePage::FilePage(QWidget *parent) : QWidget(parent) {
}
void FilePage::fileTreeViewItemClicked(const QModelIndex &index) {
- mPath = dirModel->fileInfo(index).absoluteFilePath();
- qDebug() << "mPath" << mPath;
+ selectedPath = dirModel->fileInfo(index).absoluteFilePath();
+ qDebug() << "selectedPath" << selectedPath;
}
void FilePage::slotUpLevel() {
QModelIndex currentRoot = dirTreeView->rootIndex();
- mPath = dirModel->fileInfo(currentRoot.parent()).absoluteFilePath();
- auto fileInfo = QFileInfo(mPath);
+
+ mPath = dirModel->fileInfo(currentRoot).absoluteFilePath();
+ QDir dir(mPath);
+ dir.makeAbsolute();
+ dir.setPath(QDir::cleanPath(dir.filePath(QStringLiteral(".."))));
+ mPath = dir.absolutePath();
+ auto fileInfo = QFileInfo(dir.absolutePath());
if(fileInfo.isDir() && fileInfo.isReadable() && fileInfo.isExecutable()) {
- dirTreeView->setRootIndex(currentRoot.parent());
pathEdit->setText(mPath);
+ slotGoPath();
}
qDebug() << "Current Root mPath" << mPath;
emit pathChanged(mPath);
@@ -124,8 +129,9 @@ void FilePage::slotUpLevel() {
void FilePage::fileTreeViewItemDoubleClicked(const QModelIndex &index) {
mPath = dirModel->fileInfo(index).absoluteFilePath();
auto fileInfo = QFileInfo(mPath);
+ auto targetModelIndex = dirTreeView->model()->index(index.row(), 0, index.parent());
if(fileInfo.isDir() && fileInfo.isReadable() && fileInfo.isExecutable()) {
- dirTreeView->setRootIndex(index);
+ dirTreeView->setRootIndex(targetModelIndex);
pathEdit->setText(mPath);
}
qDebug() << "Index mPath" << mPath;
@@ -133,7 +139,7 @@ void FilePage::fileTreeViewItemDoubleClicked(const QModelIndex &index) {
}
QString FilePage::getSelected() const {
- return mPath;
+ return selectedPath;
}
void FilePage::slotGoPath() {
@@ -177,10 +183,10 @@ void FilePage::createPopupMenu() {
void FilePage::onCustomContextMenu(const QPoint &point) {
QModelIndex index = dirTreeView->indexAt(point);
- mPath = dirModel->fileInfo(index).absoluteFilePath();
- qDebug() << "Right Click" << mPath;
+ selectedPath = dirModel->fileInfo(index).absoluteFilePath();
+ qDebug() << "Right Click" << selectedPath;
if (index.isValid()) {
- QFileInfo info(mPath);
+ QFileInfo info(selectedPath);
encryptItemAct->setEnabled(info.isFile() && (info.suffix() != "gpg" && info.suffix() != "sig"));
decryptItemAct->setEnabled(info.isFile() && info.suffix() == "gpg");
signItemAct->setEnabled(info.isFile() && (info.suffix() != "gpg" && info.suffix() != "sig"));
@@ -252,3 +258,10 @@ void FilePage::slotVerifyItem() {
if(mainWindow != nullptr)
mainWindow->slotFileVerify();
}
+
+void FilePage::keyPressEvent(QKeyEvent *event) {
+ qDebug() << "Key Press" << event->key();
+ if(event->key() == Qt::Key_Return || event->key() == Qt::Key_Enter) {
+ slotGoPath();
+ }
+}
diff --git a/src/ui/widgets/TextEdit.cpp b/src/ui/widgets/TextEdit.cpp
index c9968565..eab0f799 100644
--- a/src/ui/widgets/TextEdit.cpp
+++ b/src/ui/widgets/TextEdit.cpp
@@ -637,7 +637,7 @@ void TextEdit::slotFilePagePathChanged(const QString &path) {
int index = tabWidget->currentIndex();
QString mPath;
QFileInfo fileInfo(path);
- QString tPath = fileInfo.path();
+ QString tPath = fileInfo.absoluteFilePath();
if (path.size() > 18) {
mPath = tPath.mid(tPath.size() - 18, 18).prepend("...");
} else {