1 /*
2 ################################################################################
3 #  THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY  #
4 #  Read the zproject/README.md for information about making permanent changes. #
5 ################################################################################
6 */
7 
8 #ifndef QML_ZPROC_H
9 #define QML_ZPROC_H
10 
11 #include <QtQml>
12 
13 #include <czmq.h>
14 #include "qml_czmq_plugin.h"
15 
16 
17 class QmlZproc : public QObject
18 {
19     Q_OBJECT
20     Q_PROPERTY(bool isNULL READ isNULL)
21 
22 public:
23     zproc_t *self;
24 
QmlZproc()25     QmlZproc() { self = NULL; }
isNULL()26     bool isNULL() { return self == NULL; }
27 
28     static QObject* qmlAttachedProperties(QObject* object); // defined in QmlZproc.cpp
29 
30 public slots:
31     //  Return command line arguments (the first item is the executable) or
32     //  NULL if not set.
33     QmlZlist *args ();
34 
35     //  Setup the command line arguments, the first item must be an (absolute) filename
36     //  to run.
37     void setArgs (QmlZlist *arguments);
38 
39     //  Setup the command line arguments, the first item must be an (absolute) filename
40     //  to run. Variadic function, must be NULL terminated.
41     void setArgsx (const QString &arguments);
42 
43     //  Setup the environment variables for the process.
44     void setEnv (QmlZhash *arguments);
45 
46     //  Connects process stdin with a readable ('>', connect) zeromq socket. If
47     //  socket argument is NULL, zproc creates own managed pair of inproc
48     //  sockets.  The writable one is then accessbile via zproc_stdin method.
49     void setStdin (void *socket);
50 
51     //  Connects process stdout with a writable ('@', bind) zeromq socket. If
52     //  socket argument is NULL, zproc creates own managed pair of inproc
53     //  sockets.  The readable one is then accessbile via zproc_stdout method.
54     void setStdout (void *socket);
55 
56     //  Connects process stderr with a writable ('@', bind) zeromq socket. If
57     //  socket argument is NULL, zproc creates own managed pair of inproc
58     //  sockets.  The readable one is then accessbile via zproc_stderr method.
59     void setStderr (void *socket);
60 
61     //  Return subprocess stdin writable socket. NULL for
62     //  not initialized or external sockets.
63     void *stdin ();
64 
65     //  Return subprocess stdout readable socket. NULL for
66     //  not initialized or external sockets.
67     void *stdout ();
68 
69     //  Return subprocess stderr readable socket. NULL for
70     //  not initialized or external sockets.
71     void *stderr ();
72 
73     //  Starts the process, return just before execve/CreateProcess.
74     int run ();
75 
76     //  process exit code
77     int returncode ();
78 
79     //  PID of the process
80     int pid ();
81 
82     //  return true if process is running, false if not yet started or finished
83     bool running ();
84 
85     //  The timeout should be zero or greater, or -1 to wait indefinitely.
86     //  wait or poll process status, return return code
87     int wait (int timeout);
88 
89     //  send SIGTERM signal to the subprocess, wait for grace period and
90     //  eventually send SIGKILL
91     void shutdown (int timeout);
92 
93     //  return internal actor, useful for the polling if process died
94     void *actor ();
95 
96     //  send a signal to the subprocess
97     void kill (int signal);
98 
99     //  set verbose mode
100     void setVerbose (bool verbose);
101 };
102 
103 class QmlZprocAttached : public QObject
104 {
105     Q_OBJECT
106     QObject* m_attached;
107 
108 public:
QmlZprocAttached(QObject * attached)109     QmlZprocAttached (QObject* attached) {
110         Q_UNUSED (attached);
111     };
112 
113 public slots:
114     //  Self test of this class.
115     void test (bool verbose);
116 
117     //  Create a new zproc.
118     //  NOTE: On Windows and with libzmq3 and libzmq2 this function
119     //  returns NULL. Code needs to be ported there.
120     QmlZproc *construct ();
121 
122     //  Destroy zproc, wait until process ends.
123     void destruct (QmlZproc *qmlSelf);
124 };
125 
126 
127 QML_DECLARE_TYPEINFO(QmlZproc, QML_HAS_ATTACHED_PROPERTIES)
128 
129 #endif
130 /*
131 ################################################################################
132 #  THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY  #
133 #  Read the zproject/README.md for information about making permanent changes. #
134 ################################################################################
135 */
136