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

id Identifier provided by the caller for this queued request. 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)
 Executor::Executor executes external applications.
void execute (int id, const QString &app, const QStringList &args, bool readStdout, bool readStderr=true)
 Executor::execute execute an app.
void execute (int id, const QString &workDir, const QString &app, const QStringList &args, bool readStdout, bool readStderr=true)
 Executor::execute executes an app from a workDir.
void execute (int id, const QString &app, const QStringList &args, QString input=QString(), bool readStdout=false, bool readStderr=true)
 Executor::execute an app, takes input and presents it as stdin.
void execute (int id, const QString &workDir, const QString &app, const QStringList &args, QString input=QString(), bool readStdout=false, bool readStderr=true)
 Executor::execute executes an app from a workDir, takes input and presents it as stdin.
void setEnvironment (const QStringList &env)
 Executor::setEnvironment set environment variables for executor processes.
auto cancelNext () -> int
 Executor::cancelNext cancels execution of first process in queue if it's not already running.

Static Public Member Functions

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.
static auto executeBlocking (QString app, const QStringList &args, QString *process_out, QString *process_err=nullptr) -> int
 Executor::executeBlocking blocking version of the executor.
static auto executeBlocking (const QStringList &env, QString app, const QStringList &args, QString *process_out=nullptr, QString *process_err=nullptr) -> int
 Executor::executeBlocking blocking version with custom environment.

Detailed Description

id Identifier provided by the caller for this queued request.

Executor executes external commands used for password, git, and other non-interactive operations.

Uses a single QProcess and an internal FIFO queue to run requested commands in order and emit completion or error signals for each request. Execution queue item representing a single non-interactive process request.

Contains the command, its arguments, optional stdin content, capture flags, and an optional working directory.

app Path to the executable to run.

args Arguments to pass to the executable.

input Data to write to the process's stdin.

readStdout When true, capture the process's stdout for the result.

readStderr When true, capture the process's stderr for the result. Note: stderr is captured regardless of this flag when the process exits with a non-zero exit code.

workingDir Working directory in which the process will be started.

finished Emitted when a queued process completes.

Parameters
idIdentifier of the completed request.
exitCodeProcess exit code.
outputCaptured stdout produced by the process (may be empty).
erroutCaptured stderr produced by the process (may be empty).

starting Emitted when the executor begins running a queued process.

error Emitted when a queued process finishes with an error condition.

Parameters
idIdentifier of the failed request.
exitCodeProcess exit code.
outputCaptured stdout produced by the process (may be empty).
erroutCaptured stderr produced by the process (may be empty).
Examples
/home/annejan/Projects/QtPass/src/pass.cpp.

Definition at line 76 of file executor.h.

Constructor & Destructor Documentation

◆ Executor()

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

Executor::Executor executes external applications.

Parameters
parent

Definition at line 22 of file executor.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

Member Function Documentation

◆ cancelNext()

auto Executor::cancelNext ( ) -> int

Executor::cancelNext cancels execution of first process in queue if it's not already running.

Returns
id of the cancelled process or -1 on error

Definition at line 331 of file executor.cpp.

◆ 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

◆ execute() [1/4]

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

Executor::execute execute an app.

Parameters
id
app
args
readStdout
readStderr

Definition at line 111 of file executor.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ execute() [2/4]

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

Executor::execute an app, takes input and presents it as stdin.

Parameters
id
app
args
input
readStdout
readStderr

Definition at line 140 of file executor.cpp.

Here is the call graph for this function:

◆ execute() [3/4]

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

Executor::execute executes an app from a workDir.

Parameters
id
workDir
app
args
readStdout
readStderr

Definition at line 125 of file executor.cpp.

Here is the call graph for this function:

◆ 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 )

Executor::execute executes an app from a workDir, takes input and presents it as stdin.

Parameters
id
workDir
app
args
input
readStdout
readStderr

Definition at line 156 of file executor.cpp.

◆ executeBlocking() [1/3]

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

Executor::executeBlocking blocking version with custom environment.

Parameters
envEnvironment variables to set
appExecutable path
argsArguments
process_outStandard output
process_errStandard error
Returns
Exit code

Definition at line 284 of file executor.cpp.

◆ executeBlocking() [2/3]

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

Executor::executeBlocking blocking version of the executor, takes input and presents it as stdin.

Parameters
app
args
input
process_out
process_err
Returns

Note: Returning error code instead of throwing to maintain compatibility with the existing error handling pattern used throughout QtPass.

Examples
/home/annejan/Projects/QtPass/src/imitatepass.cpp, /home/annejan/Projects/QtPass/src/pass.cpp, and /home/annejan/Projects/QtPass/src/util.cpp.

Definition at line 223 of file executor.cpp.

Here is the caller graph for this function:

◆ executeBlocking() [3/3]

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

Executor::executeBlocking blocking version of the executor.

Parameters
app
args
process_out
process_err
Returns

Definition at line 268 of file executor.cpp.

Here is the call graph for this function:

◆ 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)

Executor::setEnvironment set environment variables for executor processes.

Parameters
env

Definition at line 321 of file executor.cpp.

◆ starting

void Executor::starting ( )
signal

starting signal that is emited when process starts

Examples
/home/annejan/Projects/QtPass/src/pass.cpp.
Here is the caller graph for this function:

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