QtPass 1.5.1
Multi-platform GUI for pass, the standard unix password manager.
Loading...
Searching...
No Matches
executor.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2016 Anne Jan Brouwer
2// SPDX-License-Identifier: GPL-3.0-or-later
3#ifndef SRC_EXECUTOR_H_
4#define SRC_EXECUTOR_H_
5
6#include <QObject>
7#include <QProcess>
8#include <QQueue>
9
14class Executor : public QObject {
15 Q_OBJECT
16
21 struct execQueueItem {
25 int id;
29 QString app;
33 QStringList args;
37 QString input;
41 bool readStdout;
47 bool readStderr;
52 QString workingDir;
53 };
54
55 QQueue<execQueueItem> m_execQueue;
56 QProcess m_process;
57 bool running;
58 void executeNext();
59
60public:
61 explicit Executor(QObject *parent = 0);
62
63 void execute(int id, const QString &app, const QStringList &args,
64 bool readStdout, bool readStderr = true);
65
66 void execute(int id, const QString &workDir, const QString &app,
67 const QStringList &args, bool readStdout,
68 bool readStderr = true);
69
70 void execute(int id, const QString &app, const QStringList &args,
71 QString input = QString(), bool readStdout = false,
72 bool readStderr = true);
73
74 void execute(int id, const QString &workDir, const QString &app,
75 const QStringList &args, QString input = QString(),
76 bool readStdout = false, bool readStderr = true);
77
78 static auto executeBlocking(QString app, const QStringList &args,
79 const QString &input = QString(),
80 QString *process_out = nullptr,
81 QString *process_err = nullptr) -> int;
82
83 static auto executeBlocking(QString app, const QStringList &args,
84 QString *process_out,
85 QString *process_err = nullptr) -> int;
86
87 void setEnvironment(const QStringList &env);
88
89 auto cancelNext() -> int;
90private slots:
91 void finished(int exitCode, QProcess::ExitStatus exitStatus);
92signals:
101 void finished(int id, int exitCode, const QString &output,
102 const QString &errout);
106 void starting();
116 void error(int id, int exitCode, const QString &output,
117 const QString &errout);
118};
119
120#endif // SRC_EXECUTOR_H_
Executes external commands for handleing password, git and other data.
Definition executor.h:14
static auto executeBlocking(QString app, const QStringList &args, const QString &input=QString(), QString *process_out=nullptr, QString *process_err=nullptr) -> int
Executor::executeBlocking blocking version of the executor, takes input and presents it as stdin.
Definition executor.cpp:177
void execute(int id, const QString &app, const QStringList &args, bool readStdout, bool readStderr=true)
Executor::execute execute an app.
Definition executor.cpp:73
void error(int id, int exitCode, const QString &output, const QString &errout)
error signal that is emited when process finishes with an error
void setEnvironment(const QStringList &env)
Executor::setEnvironment set environment variables for executor processes.
Definition executor.cpp:234
void finished(int id, int exitCode, const QString &output, const QString &errout)
finished signal that is emited when process finishes
void starting()
starting signal that is emited when process starts
auto cancelNext() -> int
Executor::cancelNext cancels execution of first process in queue if it's not already running.
Definition executor.cpp:244