author | zecke <zecke> | 2005-03-17 23:59:00 (UTC) |
---|---|---|
committer | zecke <zecke> | 2005-03-17 23:59:00 (UTC) |
commit | c3ba7d98dc7d13132a75a14fce2cdaac6631dd26 (patch) (unidiff) | |
tree | 5732025b302537adf518bd3d5f8b36a8e18f84cc | |
parent | c87b38dc7b0acc53f5c92ac5e53f40cfff15d956 (diff) | |
download | opie-c3ba7d98dc7d13132a75a14fce2cdaac6631dd26.zip opie-c3ba7d98dc7d13132a75a14fce2cdaac6631dd26.tar.gz opie-c3ba7d98dc7d13132a75a14fce2cdaac6631dd26.tar.bz2 |
Update the API Documentation for OProcess and OApplicationFactory
-rw-r--r-- | libopie2/opiecore/oapplicationfactory.h | 2 | ||||
-rw-r--r-- | libopie2/opiecore/oprocess.h | 4 |
2 files changed, 3 insertions, 3 deletions
diff --git a/libopie2/opiecore/oapplicationfactory.h b/libopie2/opiecore/oapplicationfactory.h index cabaf79..8516565 100644 --- a/libopie2/opiecore/oapplicationfactory.h +++ b/libopie2/opiecore/oapplicationfactory.h | |||
@@ -130,193 +130,193 @@ struct OApplicationFactory : public ApplicationInterface { | |||
130 | return new Product(parent, name, f ); | 130 | return new Product(parent, name, f ); |
131 | else | 131 | else |
132 | return 0l; | 132 | return 0l; |
133 | } | 133 | } |
134 | 134 | ||
135 | virtual QStringList applications()const { | 135 | virtual QStringList applications()const { |
136 | QStringList list; | 136 | QStringList list; |
137 | list << Product::appName() ; | 137 | list << Product::appName() ; |
138 | 138 | ||
139 | return list; | 139 | return list; |
140 | } | 140 | } |
141 | Q_REFCOUNT | 141 | Q_REFCOUNT |
142 | 142 | ||
143 | }; | 143 | }; |
144 | 144 | ||
145 | 145 | ||
146 | /* Internal */ | 146 | /* Internal */ |
147 | 147 | ||
148 | template< class Product > | 148 | template< class Product > |
149 | struct OPrivate { | 149 | struct OPrivate { |
150 | inline static QWidget *multiFactory( const QString& appName, QWidget* parent, | 150 | inline static QWidget *multiFactory( const QString& appName, QWidget* parent, |
151 | const char* name, Qt::WFlags fl ) { | 151 | const char* name, Qt::WFlags fl ) { |
152 | if ( appName == Product::appName() ) | 152 | if ( appName == Product::appName() ) |
153 | return new Product( parent, name, fl ); | 153 | return new Product( parent, name, fl ); |
154 | else | 154 | else |
155 | return 0; | 155 | return 0; |
156 | } | 156 | } |
157 | 157 | ||
158 | inline static QStringList multiString( const QStringList& _list ) { | 158 | inline static QStringList multiString( const QStringList& _list ) { |
159 | QStringList list = _list; | 159 | QStringList list = _list; |
160 | list << Product::appName(); | 160 | list << Product::appName(); |
161 | return list; | 161 | return list; |
162 | } | 162 | } |
163 | }; | 163 | }; |
164 | 164 | ||
165 | template <> | 165 | template <> |
166 | struct OPrivate<Opie::Core::NullType > { | 166 | struct OPrivate<Opie::Core::NullType > { |
167 | inline static QWidget* multiFactory ( const QString& , QWidget* , | 167 | inline static QWidget* multiFactory ( const QString& , QWidget* , |
168 | const char* , Qt::WFlags ) { | 168 | const char* , Qt::WFlags ) { |
169 | return 0l; | 169 | return 0l; |
170 | } | 170 | } |
171 | inline static QStringList multiString( const QStringList& _list ) { | 171 | inline static QStringList multiString( const QStringList& _list ) { |
172 | return _list; | 172 | return _list; |
173 | } | 173 | } |
174 | }; | 174 | }; |
175 | 175 | ||
176 | /* | 176 | /* |
177 | template <> | 177 | template <> |
178 | struct OPrivate <Opie::NullType, Opie::NullType > { | 178 | struct OPrivate <Opie::NullType, Opie::NullType > { |
179 | inline static QWidget* multiFactory( const QString& , QWidget* , | 179 | inline static QWidget* multiFactory( const QString& , QWidget* , |
180 | const char* , Qt::WFlags ) { | 180 | const char* , Qt::WFlags ) { |
181 | return 0l; | 181 | return 0l; |
182 | } | 182 | } |
183 | 183 | ||
184 | inline static QStringList multiString( const QStringList& _list ) { | 184 | inline static QStringList multiString( const QStringList& _list ) { |
185 | return _list; | 185 | return _list; |
186 | } | 186 | } |
187 | }; | 187 | }; |
188 | */ | 188 | */ |
189 | 189 | ||
190 | template <class Product, class ProductListTail> | 190 | template <class Product, class ProductListTail> |
191 | struct OPrivate< Opie::Core::Typelist<Product, ProductListTail> > { | 191 | struct OPrivate< Opie::Core::Typelist<Product, ProductListTail> > { |
192 | inline static QWidget* multiFactory( const QString& appName, QWidget* parent, | 192 | inline static QWidget* multiFactory( const QString& appName, QWidget* parent, |
193 | const char* name, Qt::WFlags fl) { | 193 | const char* name, Qt::WFlags fl) { |
194 | QWidget* wid = OPrivate<Product>::multiFactory( appName, parent, name, fl ); | 194 | QWidget* wid = OPrivate<Product>::multiFactory( appName, parent, name, fl ); |
195 | 195 | ||
196 | if (!wid ) | 196 | if (!wid ) |
197 | wid = OPrivate<ProductListTail>::multiFactory( appName, parent, name, fl ); | 197 | wid = OPrivate<ProductListTail>::multiFactory( appName, parent, name, fl ); |
198 | 198 | ||
199 | return wid; | 199 | return wid; |
200 | } | 200 | } |
201 | 201 | ||
202 | inline static QStringList multiString( const QStringList& _list ) { | 202 | inline static QStringList multiString( const QStringList& _list ) { |
203 | QStringList list = _list; | 203 | QStringList list = _list; |
204 | 204 | ||
205 | list = OPrivate<Product>::multiString( list ); | 205 | list = OPrivate<Product>::multiString( list ); |
206 | list = OPrivate<ProductListTail>::multiString( list ); | 206 | list = OPrivate<ProductListTail>::multiString( list ); |
207 | 207 | ||
208 | return list; | 208 | return list; |
209 | } | 209 | } |
210 | }; | 210 | }; |
211 | 211 | ||
212 | 212 | ||
213 | 213 | ||
214 | 214 | ||
215 | 215 | ||
216 | 216 | ||
217 | 217 | ||
218 | 218 | ||
219 | /* Internal END */ | 219 | /* Internal END */ |
220 | 220 | ||
221 | /* | 221 | /* |
222 | * If you want to export more than one Widget use that function | 222 | * If you want to export more than one Widget use that function |
223 | * Make sure all your Widgets provide the appName() static method | 223 | * Make sure all your Widgets provide the appName() static method |
224 | * otherwise you'll get a compiler error | 224 | * otherwise you'll get a compiler error |
225 | * | 225 | * |
226 | * typedef Opie::MakeTypeList<MyWidget, MyDialog, MyMediaPlayer >::Result MyTypes; | 226 | * typedef Opie::Core::MakeTypelist<MyWidget, MyDialog, MyMediaPlayer >::Result MyTypes; |
227 | * OPIE_EXPORT_APP( OApplicationFactory<MyTypes> ) | 227 | * OPIE_EXPORT_APP( OApplicationFactory<MyTypes> ) |
228 | */ | 228 | */ |
229 | 229 | ||
230 | template<class Product, class ProductListTail> | 230 | template<class Product, class ProductListTail> |
231 | struct OApplicationFactory< Opie::Core::Typelist<Product, ProductListTail > > | 231 | struct OApplicationFactory< Opie::Core::Typelist<Product, ProductListTail > > |
232 | : ApplicationInterface { | 232 | : ApplicationInterface { |
233 | QRESULT queryInterface( const QUuid &uuid, QUnknownInterface **iface ) { | 233 | QRESULT queryInterface( const QUuid &uuid, QUnknownInterface **iface ) { |
234 | *iface = 0; | 234 | *iface = 0; |
235 | if ( uuid == IID_QUnknown ) *iface = this; | 235 | if ( uuid == IID_QUnknown ) *iface = this; |
236 | else if ( uuid ==IID_QtopiaApplication ) *iface = this; | 236 | else if ( uuid ==IID_QtopiaApplication ) *iface = this; |
237 | else return QS_FALSE; | 237 | else return QS_FALSE; |
238 | (*iface)->addRef(); | 238 | (*iface)->addRef(); |
239 | return QS_OK; | 239 | return QS_OK; |
240 | } | 240 | } |
241 | 241 | ||
242 | QWidget* createMainWindow ( const QString& appName, QWidget* parent, | 242 | QWidget* createMainWindow ( const QString& appName, QWidget* parent, |
243 | const char* name, Qt::WFlags fl ) { | 243 | const char* name, Qt::WFlags fl ) { |
244 | qWarning("StringList is %s", applications().join(":").latin1() ); | 244 | qWarning("StringList is %s", applications().join(":").latin1() ); |
245 | return OPrivate< Opie::Core::Typelist<Product, ProductListTail > >::multiFactory( appName, parent, name, fl ); | 245 | return OPrivate< Opie::Core::Typelist<Product, ProductListTail > >::multiFactory( appName, parent, name, fl ); |
246 | } | 246 | } |
247 | 247 | ||
248 | QStringList applications()const { | 248 | QStringList applications()const { |
249 | QStringList _list; | 249 | QStringList _list; |
250 | return OPrivate< Opie::Core::Typelist<Product, ProductListTail> >::multiString( _list ); | 250 | return OPrivate< Opie::Core::Typelist<Product, ProductListTail> >::multiString( _list ); |
251 | } | 251 | } |
252 | 252 | ||
253 | Q_REFCOUNT | 253 | Q_REFCOUNT |
254 | }; | 254 | }; |
255 | 255 | ||
256 | } | 256 | } |
257 | } | 257 | } |
258 | 258 | ||
259 | /* If the library version should be build */ | 259 | /* If the library version should be build */ |
260 | #ifdef OPIE_APP_INTERFACE | 260 | #ifdef OPIE_APP_INTERFACE |
261 | #define OPIE_EXPORT_APP( factory ) Q_EXPORT_INTERFACE() { Q_CREATE_INSTANCE( factory ) } | 261 | #define OPIE_EXPORT_APP( factory ) Q_EXPORT_INTERFACE() { Q_CREATE_INSTANCE( factory ) } |
262 | #else | 262 | #else |
263 | 263 | ||
264 | #include <qpe/qpeapplication.h> | 264 | #include <qpe/qpeapplication.h> |
265 | 265 | ||
266 | #define OPIE_EXPORT_APP( Factory ) \ | 266 | #define OPIE_EXPORT_APP( Factory ) \ |
267 | int main( int argc, char **argv ) { \ | 267 | int main( int argc, char **argv ) { \ |
268 | QPEApplication a(argc, argv ); \ | 268 | QPEApplication a(argc, argv ); \ |
269 | QWidget *mw = 0;\ | 269 | QWidget *mw = 0;\ |
270 | \ | 270 | \ |
271 | /* method from TT */ \ | 271 | /* method from TT */ \ |
272 | QString executableName = QString::fromLatin1( argv[0] ); \ | 272 | QString executableName = QString::fromLatin1( argv[0] ); \ |
273 | executableName = executableName.right(executableName.length() \ | 273 | executableName = executableName.right(executableName.length() \ |
274 | - executableName.findRev('/') - 1); \ | 274 | - executableName.findRev('/') - 1); \ |
275 | \ | 275 | \ |
276 | Factory f; \ | 276 | Factory f; \ |
277 | QStringList list = f.applications(); \ | 277 | QStringList list = f.applications(); \ |
278 | if (list.contains(executableName) ) \ | 278 | if (list.contains(executableName) ) \ |
279 | mw = f.createMainWindow(executableName, 0, 0, 0 ); \ | 279 | mw = f.createMainWindow(executableName, 0, 0, 0 ); \ |
280 | else \ | 280 | else \ |
281 | mw = f.createMainWindow( list[0], 0, 0, 0 ); \ | 281 | mw = f.createMainWindow( list[0], 0, 0, 0 ); \ |
282 | \ | 282 | \ |
283 | if( mw ) { \ | 283 | if( mw ) { \ |
284 | if ( mw->metaObject()->slotNames().contains("setDocument(const QString&)" ) ) \ | 284 | if ( mw->metaObject()->slotNames().contains("setDocument(const QString&)" ) ) \ |
285 | a.showMainDocumentWidget( mw ); \ | 285 | a.showMainDocumentWidget( mw ); \ |
286 | else \ | 286 | else \ |
287 | a.showMainWidget( mw ); \ | 287 | a.showMainWidget( mw ); \ |
288 | \ | 288 | \ |
289 | int rv = a.exec(); \ | 289 | int rv = a.exec(); \ |
290 | delete mw; \ | 290 | delete mw; \ |
291 | return rv; \ | 291 | return rv; \ |
292 | }else \ | 292 | }else \ |
293 | return -1; \ | 293 | return -1; \ |
294 | } | 294 | } |
295 | #endif | 295 | #endif |
296 | 296 | ||
297 | #ifdef OPIE_APP_INTERFACE | 297 | #ifdef OPIE_APP_INTERFACE |
298 | #define OPIE_EXPORT_APP_V2( factory,name ) Q_EXPORT_INTERFACE() { Q_CREATE_INSTANCE( factory ) } | 298 | #define OPIE_EXPORT_APP_V2( factory,name ) Q_EXPORT_INTERFACE() { Q_CREATE_INSTANCE( factory ) } |
299 | #else | 299 | #else |
300 | 300 | ||
301 | #include <opie2/oapplication.h> | 301 | #include <opie2/oapplication.h> |
302 | 302 | ||
303 | #define OPIE_EXPORT_APP_V2( Factory,name ) \ | 303 | #define OPIE_EXPORT_APP_V2( Factory,name ) \ |
304 | int main( int argc, char **argv ) { \ | 304 | int main( int argc, char **argv ) { \ |
305 | Opie::Core::OApplication a(argc, argv, name ); \ | 305 | Opie::Core::OApplication a(argc, argv, name ); \ |
306 | QWidget *mw = 0;\ | 306 | QWidget *mw = 0;\ |
307 | \ | 307 | \ |
308 | /* method from TT */ \ | 308 | /* method from TT */ \ |
309 | QString executableName = QString::fromLatin1( argv[0] ); \ | 309 | QString executableName = QString::fromLatin1( argv[0] ); \ |
310 | executableName = executableName.right(executableName.length() \ | 310 | executableName = executableName.right(executableName.length() \ |
311 | - executableName.findRev('/') - 1); \ | 311 | - executableName.findRev('/') - 1); \ |
312 | \ | 312 | \ |
313 | Factory f; \ | 313 | Factory f; \ |
314 | QStringList list = f.applications(); \ | 314 | QStringList list = f.applications(); \ |
315 | if (list.contains(executableName) ) \ | 315 | if (list.contains(executableName) ) \ |
316 | mw = f.createMainWindow(executableName, 0, 0, 0 ); \ | 316 | mw = f.createMainWindow(executableName, 0, 0, 0 ); \ |
317 | else \ | 317 | else \ |
318 | mw = f.createMainWindow( list[0], 0, 0, 0 ); \ | 318 | mw = f.createMainWindow( list[0], 0, 0, 0 ); \ |
319 | \ | 319 | \ |
320 | if( mw ) { \ | 320 | if( mw ) { \ |
321 | if ( mw->metaObject()->slotNames().contains("setDocument(const QString&)" ) ) \ | 321 | if ( mw->metaObject()->slotNames().contains("setDocument(const QString&)" ) ) \ |
322 | a.showMainDocumentWidget( mw ); \ | 322 | a.showMainDocumentWidget( mw ); \ |
diff --git a/libopie2/opiecore/oprocess.h b/libopie2/opiecore/oprocess.h index ac6be98..23e9b10 100644 --- a/libopie2/opiecore/oprocess.h +++ b/libopie2/opiecore/oprocess.h | |||
@@ -8,194 +8,194 @@ | |||
8 | _;:, .> :=|. This program is free software; you can | 8 | _;:, .> :=|. This program is free software; you can |
9 | .> <`_, > . <= redistribute it and/or modify it under | 9 | .> <`_, > . <= redistribute it and/or modify it under |
10 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 10 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
11 | .="- .-=="i, .._ License as published by the Free Software | 11 | .="- .-=="i, .._ License as published by the Free Software |
12 | - . .-<_> .<> Foundation; either version 2 of the License, | 12 | - . .-<_> .<> Foundation; either version 2 of the License, |
13 | ._= =} : or (at your option) any later version. | 13 | ._= =} : or (at your option) any later version. |
14 | .%`+i> _;_. | 14 | .%`+i> _;_. |
15 | .i_,=:_. -<s. This program is distributed in the hope that | 15 | .i_,=:_. -<s. This program is distributed in the hope that |
16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
17 | : .. .:, . . . without even the implied warranty of | 17 | : .. .:, . . . without even the implied warranty of |
18 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 18 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
19 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 19 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
20 | ..}^=.= = ; Library General Public License for more | 20 | ..}^=.= = ; Library General Public License for more |
21 | ++= -. .` .: details. | 21 | ++= -. .` .: details. |
22 | : = ...= . :.=- | 22 | : = ...= . :.=- |
23 | -. .:....=;==+<; You should have received a copy of the GNU | 23 | -. .:....=;==+<; You should have received a copy of the GNU |
24 | -_. . . )=. = Library General Public License along with | 24 | -_. . . )=. = Library General Public License along with |
25 | -- :-=` this library; see the file COPYING.LIB. | 25 | -- :-=` this library; see the file COPYING.LIB. |
26 | If not, write to the Free Software Foundation, | 26 | If not, write to the Free Software Foundation, |
27 | Inc., 59 Temple Place - Suite 330, | 27 | Inc., 59 Temple Place - Suite 330, |
28 | Boston, MA 02111-1307, USA. | 28 | Boston, MA 02111-1307, USA. |
29 | */ | 29 | */ |
30 | 30 | ||
31 | #ifndef OPROCESS_H | 31 | #ifndef OPROCESS_H |
32 | #define OPROCESS_H | 32 | #define OPROCESS_H |
33 | 33 | ||
34 | /* QT */ | 34 | /* QT */ |
35 | #include <qcstring.h> | 35 | #include <qcstring.h> |
36 | #include <qobject.h> | 36 | #include <qobject.h> |
37 | #include <qvaluelist.h> | 37 | #include <qvaluelist.h> |
38 | 38 | ||
39 | /* STD */ | 39 | /* STD */ |
40 | #include <sys/types.h> // for pid_t | 40 | #include <sys/types.h> // for pid_t |
41 | #include <sys/wait.h> | 41 | #include <sys/wait.h> |
42 | #include <signal.h> | 42 | #include <signal.h> |
43 | #include <unistd.h> | 43 | #include <unistd.h> |
44 | 44 | ||
45 | class QSocketNotifier; | 45 | class QSocketNotifier; |
46 | 46 | ||
47 | namespace Opie { | 47 | namespace Opie { |
48 | namespace Core { | 48 | namespace Core { |
49 | namespace Internal { | 49 | namespace Internal { |
50 | class OProcessController; | 50 | class OProcessController; |
51 | class OProcessPrivate; | 51 | class OProcessPrivate; |
52 | } | 52 | } |
53 | 53 | ||
54 | /** | 54 | /** |
55 | * Child process invocation, monitoring and control. | 55 | * Child process invocation, monitoring and control. |
56 | * | 56 | * |
57 | * @par General usage and features | 57 | * @par General usage and features |
58 | * | 58 | * |
59 | *This class allows a KDE and OPIE application to start child processes without having | 59 | *This class allows a KDE and OPIE application to start child processes without having |
60 | *to worry about UN*X signal handling issues and zombie process reaping. | 60 | *to worry about UN*X signal handling issues and zombie process reaping. |
61 | * | 61 | * |
62 | *@see KProcIO | 62 | *@see KProcIO |
63 | * | 63 | * |
64 | *Basically, this class distinguishes three different ways of running | 64 | *Basically, this class distinguishes three different ways of running |
65 | *child processes: | 65 | *child processes: |
66 | * | 66 | * |
67 | *@li OProcess::DontCare -- The child process is invoked and both the child | 67 | *@li OProcess::DontCare -- The child process is invoked and both the child |
68 | *process and the parent process continue concurrently. | 68 | *process and the parent process continue concurrently. |
69 | * | 69 | * |
70 | *Starting a DontCare child process means that the application is | 70 | *Starting a DontCare child process means that the application is |
71 | *not interested in any notification to determine whether the | 71 | *not interested in any notification to determine whether the |
72 | *child process has already exited or not. | 72 | *child process has already exited or not. |
73 | * | 73 | * |
74 | *@li OProcess::NotifyOnExit -- The child process is invoked and both the | 74 | *@li OProcess::NotifyOnExit -- The child process is invoked and both the |
75 | *child and the parent process run concurrently. | 75 | *child and the parent process run concurrently. |
76 | * | 76 | * |
77 | *When the child process exits, the OProcess instance | 77 | *When the child process exits, the OProcess instance |
78 | *corresponding to it emits the Qt signal @ref processExited(). | 78 | *corresponding to it emits the Qt signal @ref processExited(). |
79 | * | 79 | * |
80 | *Since this signal is @em not emitted from within a UN*X | 80 | *Since this signal is @em not emitted from within a UN*X |
81 | *signal handler, arbitrary function calls can be made. | 81 | *signal handler, arbitrary function calls can be made. |
82 | * | 82 | * |
83 | *Be aware: When the OProcess objects gets destructed, the child | 83 | *Be aware: When the OProcess objects gets destructed, the child |
84 | *process will be killed if it is still running! | 84 | *process will be killed if it is still running! |
85 | *This means in particular, that you cannot use a OProcess on the stack | 85 | *This means in particular, that you cannot use a OProcess on the stack |
86 | *with OProcess::NotifyOnExit. | 86 | *with OProcess::NotifyOnExit. |
87 | * | 87 | * |
88 | *@li OProcess::Block -- The child process starts and the parent process | 88 | *@li OProcess::Block -- The child process starts and the parent process |
89 | *is suspended until the child process exits. (@em Really not recommended | 89 | *is suspended until the child process exits. (@em Really not recommended |
90 | *for programs with a GUI.) | 90 | *for programs with a GUI.) |
91 | * | 91 | * |
92 | *OProcess also provides several functions for determining the exit status | 92 | *OProcess also provides several functions for determining the exit status |
93 | *and the pid of the child process it represents. | 93 | *and the pid of the child process it represents. |
94 | * | 94 | * |
95 | *Furthermore it is possible to supply command-line arguments to the process | 95 | *Furthermore it is possible to supply command-line arguments to the process |
96 | *in a clean fashion (no null -- terminated stringlists and such...) | 96 | *in a clean fashion (no null -- terminated stringlists and such...) |
97 | * | 97 | * |
98 | *A small usage example: | 98 | *A small usage example: |
99 | *<pre> | 99 | *<pre> |
100 | *OProcess *proc = new OProcess; | 100 | *OProcess *proc = new OProcess; |
101 | * | 101 | * |
102 | **proc << "my_executable"; | 102 | **proc << "my_executable"; |
103 | **proc << "These" << "are" << "the" << "command" << "line" << "args"; | 103 | **proc << "These" << "are" << "the" << "command" << "line" << "args"; |
104 | *QApplication::connect(proc, SIGNAL(processExited(Opie::Core::OProcess *)), | 104 | *QObject::connect(proc, SIGNAL(processExited(Opie::Core::OProcess *)), |
105 | * pointer_to_my_object, SLOT(my_objects_slot(Opie::Core::OProcess *))); | 105 | * pointer_to_my_object, SLOT(my_objects_slot(Opie::Core::OProcess *))); |
106 | *proc->start(); | 106 | *proc->start(); |
107 | *</pre> | 107 | *</pre> |
108 | * | 108 | * |
109 | *This will start "my_executable" with the commandline arguments "These"... | 109 | *This will start "my_executable" with the commandline arguments "These"... |
110 | * | 110 | * |
111 | *When the child process exits, the respective Qt signal will be emitted. | 111 | *When the child process exits, the respective Qt signal will be emitted. |
112 | * | 112 | * |
113 | *@par Communication with the child process | 113 | *@par Communication with the child process |
114 | * | 114 | * |
115 | *OProcess supports communication with the child process through | 115 | *OProcess supports communication with the child process through |
116 | *stdin/stdout/stderr. | 116 | *stdin/stdout/stderr. |
117 | * | 117 | * |
118 | *The following functions are provided for getting data from the child | 118 | *The following functions are provided for getting data from the child |
119 | *process or sending data to the child's stdin (For more information, | 119 | *process or sending data to the child's stdin (For more information, |
120 | *have a look at the documentation of each function): | 120 | *have a look at the documentation of each function): |
121 | * | 121 | * |
122 | *@li bool @ref writeStdin(char *buffer, int buflen); | 122 | *@li bool @ref writeStdin(char *buffer, int buflen); |
123 | *@li -- Transmit data to the child process's stdin. | 123 | *@li -- Transmit data to the child process's stdin. |
124 | * | 124 | * |
125 | *@li bool @ref closeStdin(); | 125 | *@li bool @ref closeStdin(); |
126 | *@li -- Closes the child process's stdin (which causes it to see an feof(stdin)). | 126 | *@li -- Closes the child process's stdin (which causes it to see an feof(stdin)). |
127 | *Returns false if you try to close stdin for a process that has been started | 127 | *Returns false if you try to close stdin for a process that has been started |
128 | *without a communication channel to stdin. | 128 | *without a communication channel to stdin. |
129 | * | 129 | * |
130 | *@li bool @ref closeStdout(); | 130 | *@li bool @ref closeStdout(); |
131 | *@li -- Closes the child process's stdout. | 131 | *@li -- Closes the child process's stdout. |
132 | *Returns false if you try to close stdout for a process that has been started | 132 | *Returns false if you try to close stdout for a process that has been started |
133 | *without a communication channel to stdout. | 133 | *without a communication channel to stdout. |
134 | * | 134 | * |
135 | *@li bool @ref closeStderr(); | 135 | *@li bool @ref closeStderr(); |
136 | *@li -- Closes the child process's stderr. | 136 | *@li -- Closes the child process's stderr. |
137 | *Returns false if you try to close stderr for a process that has been started | 137 | *Returns false if you try to close stderr for a process that has been started |
138 | *without a communication channel to stderr. | 138 | *without a communication channel to stderr. |
139 | * | 139 | * |
140 | * | 140 | * |
141 | *@par QT signals: | 141 | *@par QT signals: |
142 | * | 142 | * |
143 | *@li void @ref receivedStdout(OProcess *proc, char *buffer, int buflen); | 143 | *@li void @ref receivedStdout(OProcess *proc, char *buffer, int buflen); |
144 | *@li void @ref receivedStderr(OProcess *proc, char *buffer, int buflen); | 144 | *@li void @ref receivedStderr(OProcess *proc, char *buffer, int buflen); |
145 | *@li -- Indicates that new data has arrived from either the | 145 | *@li -- Indicates that new data has arrived from either the |
146 | *child process's stdout or stderr. | 146 | *child process's stdout or stderr. |
147 | * | 147 | * |
148 | *@li void @ref wroteStdin(OProcess *proc); | 148 | *@li void @ref wroteStdin(OProcess *proc); |
149 | *@li -- Indicates that all data that has been sent to the child process | 149 | *@li -- Indicates that all data that has been sent to the child process |
150 | *by a prior call to @ref writeStdin() has actually been transmitted to the | 150 | *by a prior call to @ref writeStdin() has actually been transmitted to the |
151 | *client . | 151 | *client . |
152 | * | 152 | * |
153 | *@author Christian Czezakte e9025461@student.tuwien.ac.at | 153 | *@author Christian Czezakte e9025461@student.tuwien.ac.at |
154 | *@author Holger Freyther (Opie Port) | 154 | *@author Holger Freyther (Opie Port) |
155 | * | 155 | * |
156 | **/ | 156 | **/ |
157 | class OProcess : public QObject | 157 | class OProcess : public QObject |
158 | { | 158 | { |
159 | Q_OBJECT | 159 | Q_OBJECT |
160 | 160 | ||
161 | public: | 161 | public: |
162 | 162 | ||
163 | /** | 163 | /** |
164 | * Modes in which the communication channel can be opened. | 164 | * Modes in which the communication channel can be opened. |
165 | * | 165 | * |
166 | * If communication for more than one channel is required, | 166 | * If communication for more than one channel is required, |
167 | * the values have to be or'ed together, for example to get | 167 | * the values have to be or'ed together, for example to get |
168 | * communication with stdout as well as with stdin, you would | 168 | * communication with stdout as well as with stdin, you would |
169 | * specify @p Stdin @p | @p Stdout | 169 | * specify @p Stdin @p | @p Stdout |
170 | * | 170 | * |
171 | * If @p NoRead is specified in conjunction with @p Stdout, | 171 | * If @p NoRead is specified in conjunction with @p Stdout, |
172 | * no data is actually read from @p Stdout but only | 172 | * no data is actually read from @p Stdout but only |
173 | * the signal @ref childOutput(int fd) is emitted. | 173 | * the signal @ref childOutput(int fd) is emitted. |
174 | */ | 174 | */ |
175 | enum Communication { NoCommunication = 0, Stdin = 1, Stdout = 2, Stderr = 4, | 175 | enum Communication { NoCommunication = 0, Stdin = 1, Stdout = 2, Stderr = 4, |
176 | AllOutput = 6, All = 7, | 176 | AllOutput = 6, All = 7, |
177 | NoRead }; | 177 | NoRead }; |
178 | 178 | ||
179 | /** | 179 | /** |
180 | * Run-modes for a child process. | 180 | * Run-modes for a child process. |
181 | */ | 181 | */ |
182 | enum RunMode { | 182 | enum RunMode { |
183 | /** | 183 | /** |
184 | * The application does not receive notifications from the subprocess when | 184 | * The application does not receive notifications from the subprocess when |
185 | * it is finished or aborted. | 185 | * it is finished or aborted. |
186 | */ | 186 | */ |
187 | DontCare, | 187 | DontCare, |
188 | /** | 188 | /** |
189 | * The application is notified when the subprocess dies. | 189 | * The application is notified when the subprocess dies. |
190 | */ | 190 | */ |
191 | NotifyOnExit, | 191 | NotifyOnExit, |
192 | /** | 192 | /** |
193 | * The application is suspended until the started process is finished. | 193 | * The application is suspended until the started process is finished. |
194 | */ | 194 | */ |
195 | Block }; | 195 | Block }; |
196 | 196 | ||
197 | /** | 197 | /** |
198 | * Constructor | 198 | * Constructor |
199 | */ | 199 | */ |
200 | OProcess( QObject *parent = 0, const char *name = 0 ); | 200 | OProcess( QObject *parent = 0, const char *name = 0 ); |
201 | /** | 201 | /** |