15 zDebug() <<
"ZFile::ZFile";
19 m_p =
new QProcess(
this);
23 m_p->setProcessEnvironment(QProcessEnvironment::systemEnvironment());
30 connect(m_p, SIGNAL(readyReadStandardOutput()),
this, SIGNAL(readyReadStandardOutput()));
31 connect(m_p, SIGNAL(readyReadStandardError()),
this, SIGNAL(readyReadStandardError()));
36 zDebug() <<
"ZProcess::~ZProcess";
44 qmlRegisterType<ZProcess>(
"org.zuble.qml", 1, 0,
"ZProcess");
51 connect(
m_zd, SIGNAL(getCurrentDevice(QIODevice**)),
52 SLOT(
getQDevice(QIODevice**)), Qt::DirectConnection);
63 map.insert(
"errorCrashed",
Crashed);
64 map.insert(
"errorTimedout",
Timedout);
69 map.insert(
"stateStarting",
Starting);
70 map.insert(
"stateRunning",
Running);
81 m_tags = QVariant::fromValue(map);
93 Z_FAC_JS, ZProcess::getStatus, getStatus failed)
98 *device = qobject_cast<QIODevice*>(
m_p);
102 void ZProcess::release()
111 void ZProcess::close()
126 m_p->start(static_cast<QIODevice::OpenMode>(mode));
131 return m_p->arguments();
136 m_p->setArguments(arguments);
141 return m_p->program();
146 m_p->setProgram(program);
151 m_p->closeWriteChannel();
156 m_p->closeReadChannel(static_cast<QProcess::ProcessChannel>(channel));
161 return m_p->processId();
166 return m_p->readChannel();
171 m_p->setReadChannel(static_cast<QProcess::ProcessChannel>(channel));
176 QByteArray data =
m_p->readAllStandardError();
183 QByteArray data =
m_p->readAllStandardOutput();
190 return static_cast<int>(
m_p->state());
195 return static_cast<int>(
m_p->error());
200 m_p->setProcessChannelMode(static_cast<QProcess::ProcessChannelMode>(mode));
205 return static_cast<int>(
m_p->processChannelMode());
210 return static_cast<int>(
m_p->exitCode());
215 return static_cast<int>(
m_p->exitStatus());
220 m_p->setProcessEnvironment(QProcessEnvironment());
225 return m_p->processEnvironment().toStringList();
230 QProcessEnvironment env(
m_p->processEnvironment());
231 env.insert(name, value);
232 m_p->setProcessEnvironment(env);
237 return m_p->processEnvironment().value(name);
242 return m_p->processEnvironment().contains(name);
void getQDevice(QIODevice **device)
Obtains the QIODevice pointer for this object.
Q_INVOKABLE void envClear()
Clears the process execution environment that will be passed to the child process.
int exitCode() const
Obtains the exit code of the last process that finished.
This class supports streaming of text and binary data.
QML/Javascript wrapper for the QProcess class, allows QML programs to spawn and communicate with a ba...
void start(int mode=static_cast< int >(ZioDevice::ReadWrite))
Starts the process.
ZBL_DECLARE_LOGGED_OBJECT void initZioDevice()
Construct and connect a ZioDevice object that presents a Javascript interface to this process's QIODe...
Q_INVOKABLE void envSetValue(const QString &name, const QString &value)
Sets an environment variable that will be passed to the child process.
Q_INVOKABLE void closeReadChannel(int channel)
Closes the specified read channel of the process.
int getReadChannel() const
Obtain the current read channel.
ZioDevice * m_zd
Pointer to QioDevice interface object.
#define ZBL_REGISTER_LOGGED_OBJECT
void closeWriteChannel()
Schedules the write channel of the process to close once all input data has been read by the process...
Q_INVOKABLE QString envGetValue(const QString &name)
Returns the value of an environment variable that will be passed to the child process.
void setArguments(const QStringList &arguments)
Sets the arguments that will be passed to the process when it starts.
void createTags()
Create the m_tag object that presents a Javascript interface for QProcess enumeration values...
Q_INVOKABLE QStringList envGetList()
Obtains the list of process environment variables that will be passed to the child process...
QString program
Set/get the program for the process.
qint64 getProcessID() const
Obtain the process ID. Note that Linux will reuse process IDs. They are ephemeral, not unique.
Q_INVOKABLE bool envValueExists(const QString &name)
Determine if an environment variable has been set to be passed to the child process.
void setReadChannel(int channel)
Determine which read channel is currently active.
static void registerType()
Registers ZFile as a QML type.
int exitStatus() const
Obtains the exit status of the last process that finished.
A javascript wrapper for QIODevice.
void setProcessChannelMode(int mode)
Sets the process channel mode that will be used the next time the process starts. ...
int getError() const
Obtains the current error state.
#define ZBL_SLOT_BEGIN_TRY
static QVariant m_tags
A QVariantMap used to pass QFile enumeration values to Javascript programs.
#define ZBL_DEFINE_LOGGED_OBJECT(class_name)
void setProgram(const QString &program)
Sets the path to the program the process will be started with.
Q_INVOKABLE QObject * readAllStandardOutput()
Obtains all available data from the process's stdout channel.
QStringList arguments
Set/get the argument list for the process.
#define ZBL_SLOT_END_VOID(facility, code, error_message)
int getProcessChannelMode() const
Returns the channel mode of the QProcess standard output and standard error channels.
Q_INVOKABLE QObject * readAllStandardError()
Obtains all available data from the process's stderr channel.
QStringList getArguments()
Returns the arguments that will be passed to the process when it starts.
QObject device
A ZioDevice object that represents the File's QioDevice interface.
int getState() const
Obtains the current process state.
QProcess * m_p
Smart pointer to the embedded QFile object.
#define ZBL_SLOT_END_RETURN(return_success, return_failed, facility, code, error_message)
QString getProgram() const
Returns the path to the program the process will be started with.