Commit 836cbf70 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

send process output info

parent 3cd3342c
......@@ -41,11 +41,36 @@ void AkonadiDatabaseToolsJob::start()
qCWarning(AKONADIDATABASETOOLS_LOG) << "mTool is unknown it's a bug! ";
break;
case AkonadiDatabaseToolsUtils::Vacuum: {
QProcess::execute(QStandardPaths::findExecutable(QStringLiteral("akonadictl")), QStringList({QStringLiteral("vacuum")}));
mProcess = new QProcess(this);
mProcess->setProgram(QStandardPaths::findExecutable(QStringLiteral("akonadictl")));
mProcess->setArguments(QStringList() << QStringLiteral("vacuum"));
connect(mProcess, &QProcess::readyReadStandardError, this, [this]() {
Q_EMIT receivedStandardError(QLatin1String(mProcess->readAllStandardError()));
});
connect(mProcess, &QProcess::readyReadStandardOutput, this, [this]() {
Q_EMIT receivedStandardOutput(QLatin1String(mProcess->readAllStandardOutput()));
});
mProcess->start();
if (!mProcess->waitForFinished()) {
qCWarning(AKONADIDATABASETOOLS_LOG) << "Impossible to start akonadi vacuum";
}
break;
}
case AkonadiDatabaseToolsUtils::Fsck: {
QProcess::execute(QStandardPaths::findExecutable(QStringLiteral("akonadictl")), QStringList({QStringLiteral("fsck")}));
mProcess = new QProcess(this);
mProcess->setProgram(QStandardPaths::findExecutable(QStringLiteral("akonadictl")));
mProcess->setArguments(QStringList() << QStringLiteral("fsck"));
connect(mProcess, &QProcess::readyReadStandardError, this, [this]() {
Q_EMIT receivedStandardError(QLatin1String(mProcess->readAllStandardError()));
});
connect(mProcess, &QProcess::readyReadStandardOutput, this, [this]() {
Q_EMIT receivedStandardOutput(QLatin1String(mProcess->readAllStandardOutput()));
});
mProcess->start();
if (!mProcess->waitForFinished()) {
qCWarning(AKONADIDATABASETOOLS_LOG) << "Impossible to start akonadi fsck";
}
break;
}
}
......
......@@ -9,7 +9,7 @@
#include "akonadidatabasetoolsutils.h"
#include "akonadidatasetools_private_export.h"
#include <QObject>
class QProcess;
class AKONADIDATASETOOLS_TESTS_EXPORT AkonadiDatabaseToolsJob : public QObject
{
Q_OBJECT
......@@ -22,7 +22,12 @@ public:
void start();
void setTool(AkonadiDatabaseToolsUtils::AkonadiDatabaseTool newTool);
Q_SIGNALS:
void receivedStandardError(const QString &str);
void receivedStandardOutput(const QString &str);
private:
Q_REQUIRED_RESULT QString processExist() const;
AkonadiDatabaseToolsUtils::AkonadiDatabaseTool mTool = AkonadiDatabaseToolsUtils::AkonadiDatabaseTool::Unknown;
QProcess *mProcess = nullptr;
};
......@@ -5,6 +5,7 @@
*/
#include "akonadidatabasetoolsplugininterface.h"
#include "akonadidatabasetoolsdialog.h"
#include "akonadidatabasetoolsjob.h"
#include "akonadidatasetools_debug.h"
#include <KActionCollection>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment