diff options
author | Anne Jan Brouwer <brouwer@annejan.com> | 2015-05-04 01:57:22 +0200 |
---|---|---|
committer | Anne Jan Brouwer <brouwer@annejan.com> | 2015-05-04 01:57:22 +0200 |
commit | b224d9e3a1e0c14f14be90af79765e32ff08eb25 (patch) | |
tree | 7f3ce17ab9cb80a9be7a59494a00625747be45a8 | |
parent | 1c73153836ff8ce53ab251e1f0e7f2b2ded47e75 (diff) |
Added and execution queue and better string (space) handling
-rw-r--r-- | mainwindow.cpp | 28 | ||||
-rw-r--r-- | mainwindow.h | 8 |
2 files changed, 30 insertions, 6 deletions
diff --git a/mainwindow.cpp b/mainwindow.cpp index 40428513..f58f7305 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -8,6 +8,7 @@ #include <QMessageBox> #include <QTimer> #include <QFileInfo> +#include <QQueue> #ifdef Q_OS_WIN #include <windows.h> #include <winnetwk.h> @@ -29,6 +30,8 @@ MainWindow::MainWindow(QWidget *parent) : connect(process.data(), SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(processFinished(int, QProcess::ExitStatus))); ui->setupUi(this); enableUiElements(true); + wrapperRunning = false; + execQueue = new QQueue<execQueueItem>; } /** @@ -334,6 +337,16 @@ void MainWindow::executePass(QString args, QString input) { * @param args */ void MainWindow::executeWrapper(QString app, QString args, QString input) { + if (wrapperRunning) { + execQueueItem item; + item.app = app; + item.args = args; + item.input = input; + execQueue->enqueue(item); + //qDebug() << item.app + "," + item.args + "," + item.input; + return; + } + wrapperRunning = true; process->setWorkingDirectory(passStore); if (!gpgHome.isEmpty()) { QStringList env = QProcess::systemEnvironment(); @@ -415,6 +428,7 @@ void MainWindow::clearClipboard() * @param exitStatus */ void MainWindow::processFinished(int exitCode, QProcess::ExitStatus exitStatus) { + wrapperRunning = false; bool error = exitStatus != QProcess::NormalExit || exitCode > 0; if (error) { ui->textBrowser->setTextColor(Qt::red); @@ -424,6 +438,10 @@ void MainWindow::processFinished(int exitCode, QProcess::ExitStatus exitStatus) if (!error && currentAction == EDIT) { on_treeView_clicked(ui->treeView->currentIndex()); } + if (!execQueue->isEmpty()) { + execQueueItem item = execQueue->dequeue(); + executeWrapper(item.app, item.args, item.input); + } } /** @@ -643,12 +661,12 @@ void MainWindow::setPassword(QString file, bool overwrite) executeWrapper(gpgExecutable , force + "--batch -eq --output \"" + file + "\" " + recipients + " -", newValue); if (!useWebDav) { if (!overwrite) { - executeWrapper(gitExecutable, "add " + file); + executeWrapper(gitExecutable, "add \"" + file + '"'); } QString path = file; path.replace(QRegExp("\\.gpg$"), ""); path.replace(QRegExp("^" + passStore), ""); - executeWrapper(gitExecutable, "commit " + file + " -m \"" + (overwrite ? "Edit" : "Add") + " for " + path + " using QtPass\""); + executeWrapper(gitExecutable, "commit \"" + file + "\" -m \"" + (overwrite ? "Edit" : "Add") + " for " + path + " using QtPass\""); } } } @@ -668,8 +686,6 @@ void MainWindow::on_addButton_clicked() } lastDecrypt = ""; setPassword(file, false); - executeWrapper(gitExecutable, "add " + file); -// executeWrapper(gitExecutable, "commit -a -m \"Adding " + file + "\""); } void MainWindow::on_deleteButton_clicked() @@ -799,11 +815,11 @@ void MainWindow::on_usersButton_clicked() gpgId.close(); if (!useWebDav){ if (addFile) { - executeWrapper(gitExecutable, "add " + gpgIdFile); + executeWrapper(gitExecutable, "add \"" + gpgIdFile + '"'); } QString path = gpgIdFile; path.replace(QRegExp("\\.gpg$"), ""); - executeWrapper(gitExecutable, "commit " + gpgIdFile + " -m \"Added "+ path + " using QtPass\""); + executeWrapper(gitExecutable, "commit \"" + gpgIdFile + "\" -m \"Added "+ path + " using QtPass\""); } } diff --git a/mainwindow.h b/mainwindow.h index 2eeb079e..8cd092a4 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -17,6 +17,12 @@ namespace Ui { class MainWindow; } +struct execQueueItem { + QString app; + QString args; + QString input; +}; + struct UserInfo; class MainWindow : public QMainWindow @@ -79,6 +85,8 @@ private: QString clippedPass; actionType currentAction; QString lastDecrypt; + bool wrapperRunning; + QQueue<execQueueItem> *execQueue; void updateText(); void executePass(QString, QString = QString()); void executeWrapper(QString, QString, QString = QString()); |