diff options
author | Saturneric <[email protected]> | 2021-09-05 15:02:19 +0000 |
---|---|---|
committer | Saturneric <[email protected]> | 2021-09-05 15:02:19 +0000 |
commit | 39440522111abf3adeef6b56cb23722119fbf3c2 (patch) | |
tree | 5979b3808d58c8c576e288004877d826556b4cda /src/gpg/function/GpgCommandExecutor.cpp | |
parent | Modified ResultAnalyse. (diff) | |
download | GpgFrontend-39440522111abf3adeef6b56cb23722119fbf3c2.tar.gz GpgFrontend-39440522111abf3adeef6b56cb23722119fbf3c2.zip |
Rewrite the core.
Adjust the structure.
Diffstat (limited to 'src/gpg/function/GpgCommandExecutor.cpp')
-rw-r--r-- | src/gpg/function/GpgCommandExecutor.cpp | 42 |
1 files changed, 23 insertions, 19 deletions
diff --git a/src/gpg/function/GpgCommandExecutor.cpp b/src/gpg/function/GpgCommandExecutor.cpp index 98743ed4..c36cb2b6 100644 --- a/src/gpg/function/GpgCommandExecutor.cpp +++ b/src/gpg/function/GpgCommandExecutor.cpp @@ -23,23 +23,27 @@ */ #include "gpg/function/GpgCommandExecutor.h" - -void GpgFrontend::GpgCommandExecutor::execute(const QStringList &arguments, - const std::function<void(QProcess *)> &interactFunc) { - QEventLoop looper; - auto *gpgProcess = new QProcess(&looper); - gpgProcess->setProcessChannelMode(QProcess::MergedChannels); - connect(gpgProcess, qOverload<int, QProcess::ExitStatus>(&QProcess::finished), &looper, &QEventLoop::quit); - connect(gpgProcess, &QProcess::errorOccurred, []() -> void { qDebug("Error in Process"); }); - connect(gpgProcess, &QProcess::errorOccurred, &looper, &QEventLoop::quit); - connect(gpgProcess, &QProcess::started, []() -> void { qDebug() << "Gpg Process Started Success"; }); - connect(gpgProcess, &QProcess::readyReadStandardOutput, [interactFunc, gpgProcess]() { - qDebug() << "Function Called"; - interactFunc(gpgProcess); - }); - gpgProcess->setProgram(ctx.getInfo().appPath); - gpgProcess->setArguments(arguments); - gpgProcess->start(); - looper.exec(); - +void GpgFrontend::GpgCommandExecutor::Execute( + const QStringList &arguments, + const std::function<void(QProcess *)> &interact_func) { + QEventLoop looper; + auto *gpg_process = new QProcess(&looper); + gpg_process->setProcessChannelMode(QProcess::MergedChannels); + connect(gpg_process, + qOverload<int, QProcess::ExitStatus>(&QProcess::finished), &looper, + &QEventLoop::quit); + connect(gpg_process, &QProcess::errorOccurred, + []() -> void { qDebug("Error in Process"); }); + connect(gpg_process, &QProcess::errorOccurred, &looper, &QEventLoop::quit); + connect(gpg_process, &QProcess::started, + []() -> void { qDebug() << "Gpg Process Started Success"; }); + connect(gpg_process, &QProcess::readyReadStandardOutput, + [interact_func, gpg_process]() { + qDebug() << "Function Called"; + interact_func(gpg_process); + }); + gpg_process->setProgram(ctx.GetInfo().appPath.c_str()); + gpg_process->setArguments(arguments); + gpg_process->start(); + looper.exec(); } |