QtPass 1.7.0
Multi-platform GUI for pass, the standard unix password manager.
Loading...
Searching...
No Matches
Executor Class Reference

Runs non-interactive external commands in FIFO order using a single QProcess. More...

#include <executor.h>

Inheritance diagram for Executor:
Collaboration diagram for Executor:

Signals

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
void error (int id, int exitCode, const QString &output, const QString &errout)
 error signal that is emited when process finishes with an error

Public Member Functions

 Executor (QObject *parent=nullptr)
 Construct an Executor with an optional parent QObject.
void execute (int id, const QString &app, const QStringList &args, bool readStdout, bool readStderr=true)
 Queue a command without stdin input.
void execute (int id, const QString &workDir, const QString &app, const QStringList &args, bool readStdout, bool readStderr=true)
 Queue a command with an explicit working directory.
void execute (int id, const QString &app, const QStringList &args, QString input=QString(), bool readStdout=false, bool readStderr=true)
 Queue a command with optional stdin input.
void execute (int id, const QString &workDir, const QString &app, const QStringList &args, QString input=QString(), bool readStdout=false, bool readStderr=true)
 Queue a command with working directory and optional stdin input.
void setEnvironment (const QStringList &env)
 Set the environment passed to all child processes.
auto environment () const -> QStringList
 Return the environment passed to child processes.
auto cancelNext () -> int
 Cancel the next queued command without executing it.

Static Public Member Functions

static auto executeBlocking (const QString &app, const QStringList &args, const QString &input=QString(), QString *process_out=nullptr, QString *process_err=nullptr) -> int
 Run a command synchronously and return its exit code.
static auto executeBlocking (const QString &app, const QStringList &args, QString *process_out, QString *process_err=nullptr) -> int
 Run a command synchronously capturing stdout and stderr.
static auto executeBlocking (const QStringList &env, const QString &app, const QStringList &args, QString *process_out=nullptr, QString *process_err=nullptr) -> int
 Run a command synchronously with a custom environment.

Detailed Description

Runs non-interactive external commands in FIFO order using a single QProcess.

Queues execution requests and emits per-request completion or error signals; supports optional stdin, configurable stdout/stderr capture, and per-request working directory and environment.

Definition at line 20 of file executor.h.

Constructor & Destructor Documentation

◆ Executor()

Executor::Executor ( QObject * parent = nullptr)
explicit

Construct an Executor with an optional parent QObject.

Parameters
parentParent QObject, or nullptr for no parent.

Member Function Documentation

◆ cancelNext()

auto Executor::cancelNext ( ) -> int

Cancel the next queued command without executing it.

Returns
The id of the cancelled command, or -1 if the queue was empty.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ environment()

auto Executor::environment ( ) const -> QStringList

Return the environment passed to child processes.

Returns
Environment as a list of "KEY=value" strings.

◆ error

void Executor::error ( int id,
int exitCode,
const QString & output,
const QString & errout )
signal

error signal that is emited when process finishes with an error

Parameters
idid of the process
exitCodereturn code of the process
outputstdout produced by the process
erroutstderr produced by the process
Here is the call graph for this function:
Here is the caller graph for this function:

◆ execute() [1/4]

void Executor::execute ( int id,
const QString & app,
const QStringList & args,
bool readStdout,
bool readStderr = true )

Queue a command without stdin input.

Parameters
idCaller-assigned process identifier.
appExecutable path.
argsCommand arguments.
readStdoutWhether to capture stdout.
readStderrWhether to capture stderr.

◆ execute() [2/4]

void Executor::execute ( int id,
const QString & app,
const QStringList & args,
QString input = QString(),
bool readStdout = false,
bool readStderr = true )

Queue a command with optional stdin input.

Parameters
idCaller-assigned process identifier.
appExecutable path.
argsCommand arguments.
inputData to write to stdin.
readStdoutWhether to capture stdout.
readStderrWhether to capture stderr.

◆ execute() [3/4]

void Executor::execute ( int id,
const QString & workDir,
const QString & app,
const QStringList & args,
bool readStdout,
bool readStderr = true )

Queue a command with an explicit working directory.

Parameters
idCaller-assigned process identifier.
workDirWorking directory for the process.
appExecutable path.
argsCommand arguments.
readStdoutWhether to capture stdout.
readStderrWhether to capture stderr.

◆ execute() [4/4]

void Executor::execute ( int id,
const QString & workDir,
const QString & app,
const QStringList & args,
QString input = QString(),
bool readStdout = false,
bool readStderr = true )

Queue a command with working directory and optional stdin input.

Parameters
idCaller-assigned process identifier.
workDirWorking directory for the process.
appExecutable path.
argsCommand arguments.
inputData to write to stdin.
readStdoutWhether to capture stdout.
readStderrWhether to capture stderr.

◆ executeBlocking() [1/3]

auto Executor::executeBlocking ( const QString & app,
const QStringList & args,
const QString & input = QString(),
QString * process_out = nullptr,
QString * process_err = nullptr ) -> int
static

Run a command synchronously and return its exit code.

Parameters
appExecutable path.
argsCommand arguments.
inputData to write to stdin.
process_outIf non-null, receives stdout output.
process_errIf non-null, receives stderr output.
Returns
Process exit code.

◆ executeBlocking() [2/3]

auto Executor::executeBlocking ( const QString & app,
const QStringList & args,
QString * process_out,
QString * process_err = nullptr ) -> int
static

Run a command synchronously capturing stdout and stderr.

Parameters
appExecutable path.
argsCommand arguments.
process_outReceives stdout output.
process_errIf non-null, receives stderr output.
Returns
Process exit code.

◆ executeBlocking() [3/3]

auto Executor::executeBlocking ( const QStringList & env,
const QString & app,
const QStringList & args,
QString * process_out = nullptr,
QString * process_err = nullptr ) -> int
static

Run a command synchronously with a custom environment.

Parameters
envEnvironment variable list in "KEY=value" format.
appExecutable path.
argsCommand arguments.
process_outIf non-null, receives stdout output.
process_errIf non-null, receives stderr output.
Returns
Process exit code.

◆ finished

void Executor::finished ( int id,
int exitCode,
const QString & output,
const QString & errout )
signal

finished signal that is emited when process finishes

Parameters
idid of the process
exitCodereturn code of the process
outputstdout produced by the process
erroutstderr produced by the process

◆ setEnvironment()

void Executor::setEnvironment ( const QStringList & env)

Set the environment passed to all child processes.

Parameters
envEnvironment variable list in "KEY=value" format.

The documentation for this class was generated from the following file: