summaryrefslogtreecommitdiff
path: root/libopie2/opiecore/oprocess.h
authormickeyl <mickeyl>2004-01-13 19:20:49 (UTC)
committer mickeyl <mickeyl>2004-01-13 19:20:49 (UTC)
commit81b48fa5be4806e3afa64a0d1fa254fbdf9b7315 (patch) (unidiff)
treea28289a6d048ec80e359233a6b72bd946a9b8eb8 /libopie2/opiecore/oprocess.h
parent399cf645e63e53043975fa2b26768d8db6d83ee4 (diff)
downloadopie-81b48fa5be4806e3afa64a0d1fa254fbdf9b7315.zip
opie-81b48fa5be4806e3afa64a0d1fa254fbdf9b7315.tar.gz
opie-81b48fa5be4806e3afa64a0d1fa254fbdf9b7315.tar.bz2
cleanup and unify source layout
Diffstat (limited to 'libopie2/opiecore/oprocess.h') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiecore/oprocess.h152
1 files changed, 76 insertions, 76 deletions
diff --git a/libopie2/opiecore/oprocess.h b/libopie2/opiecore/oprocess.h
index 8dd19b5..352485b 100644
--- a/libopie2/opiecore/oprocess.h
+++ b/libopie2/opiecore/oprocess.h
@@ -1,42 +1,46 @@
1/* This file is part of the KDE libraries 1/*
2 Copyright (C) 1997 Christian Czezakte (e9025461@student.tuwien.ac.at) 2                This file is part of the Opie Project
3 3             Copyright (C) 2003-2004 Holger Freyther <zecke@handhelds.org>
4 This library is free software; you can redistribute it and/or 4 Copyright (C) The Opie Team <opie-devel@handhelds.org>
5 modify it under the terms of the GNU Library General Public 5 =. Based on KProcess (C) 1997 Christian Czezatke (e9025461@student.tuwien.ac.at)
6 License as published by the Free Software Foundation; either 6 .=l.
7 version 2 of the License, or (at your option) any later version. 7          .>+-=
8 8_;:,     .>    :=|. This program is free software; you can
9 This library is distributed in the hope that it will be useful, 9.> <`_,   >  .   <= redistribute it and/or modify it under
10 but WITHOUT ANY WARRANTY; without even the implied warranty of 10:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11.="- .-=="i,     .._ License as published by the Free Software
12 Library General Public License for more details. 12- .   .-<_>     .<> Foundation; either version 2 of the License,
13 13    ._= =}       : or (at your option) any later version.
14 You should have received a copy of the GNU Library General Public License 14   .%`+i>       _;_.
15 along with this library; see the file COPYING.LIB. If not, write to 15   .i_,=:_.      -<s. This program is distributed in the hope that
16 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 16    +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
17 Boston, MA 02111-1307, USA. 17   : ..    .:,     . . . without even the implied warranty of
18   =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
19 _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
20..}^=.=       =       ; Library General Public License for more
21++=   -.     .`     .: details.
22:     =  ...= . :.=-
23-.   .:....=;==+<; You should have received a copy of the GNU
24 -_. . .   )=.  = Library General Public License along with
25   --        :-=` this library; see the file COPYING.LIB.
26 If not, write to the Free Software Foundation,
27 Inc., 59 Temple Place - Suite 330,
28 Boston, MA 02111-1307, USA.
18*/ 29*/
19//
20// KPROCESS -- A class for handling child processes in KDE without
21// having to take care of Un*x specific implementation details
22//
23// version 0.3.1, Jan 8th 1998
24//
25// (C) Christian Czezatke
26// e9025461@student.tuwien.ac.at
27// Ported by Holger Freyther to the Open Palmtop Integrated Environment
28//
29
30#ifndef __kprocess_h__
31#define __kprocess_h__
32 30
31#ifndef OPROCESS_H
32#define OPROCESS_H
33
34/* QT */
35#include <qcstring.h>
36#include <qobject.h>
37#include <qvaluelist.h>
38
39/* STD */
33#include <sys/types.h> // for pid_t 40#include <sys/types.h> // for pid_t
34#include <sys/wait.h> 41#include <sys/wait.h>
35#include <signal.h> 42#include <signal.h>
36#include <unistd.h> 43#include <unistd.h>
37#include <qvaluelist.h>
38#include <qcstring.h>
39#include <qobject.h>
40 44
41class QSocketNotifier; 45class QSocketNotifier;
42class OProcessPrivate; 46class OProcessPrivate;
@@ -141,7 +145,7 @@ class OProcessPrivate;
141 *client . 145 *client .
142 * 146 *
143 *@author Christian Czezakte e9025461@student.tuwien.ac.at 147 *@author Christian Czezakte e9025461@student.tuwien.ac.at
144 * 148 *@author Holger Freyther (Opie Port)
145 * 149 *
146 **/ 150 **/
147class OProcess : public QObject 151class OProcess : public QObject
@@ -187,15 +191,15 @@ public:
187 /** 191 /**
188 * Constructor 192 * Constructor
189 */ 193 */
190 OProcess(QObject *parent = 0, const char *name = 0); 194 OProcess( QObject *parent = 0, const char *name = 0 );
191 /** 195 /**
192 * Constructor 196 * Constructor
193 */ 197 */
194 OProcess(const QString &arg0, QObject *parent = 0, const char *name = 0); 198 OProcess( const QString &arg0, QObject *parent = 0, const char *name = 0 );
195 /** 199 /**
196 * Constructor 200 * Constructor
197 */ 201 */
198 OProcess(const QStringList &args, QObject *parent = 0, const char *name = 0); 202 OProcess( const QStringList &args, QObject *parent = 0, const char *name = 0 );
199 203
200 /** 204 /**
201 *Destructor: 205 *Destructor:
@@ -220,7 +224,7 @@ public:
220 @see operator<< 224 @see operator<<
221 225
222 */ 226 */
223 bool setExecutable(const QString& proc); 227 bool setExecutable( const QString& proc );
224 228
225 229
226 /** 230 /**
@@ -234,21 +238,21 @@ public:
234 * </pre> 238 * </pre>
235 * 239 *
236 **/ 240 **/
237 OProcess &operator<<(const QString& arg); 241 OProcess &operator<<( const QString& arg );
238 /** 242 /**
239 * Similar to previous method, takes a char *, supposed to be in locale 8 bit already. 243 * Similar to previous method, takes a char *, supposed to be in locale 8 bit already.
240 */ 244 */
241 OProcess &operator<<(const char * arg); 245 OProcess &operator<<( const char * arg );
242 /** 246 /**
243 * Similar to previous method, takes a QCString, supposed to be in locale 8 bit already. 247 * Similar to previous method, takes a QCString, supposed to be in locale 8 bit already.
244 */ 248 */
245 OProcess &operator<<(const QCString & arg); 249 OProcess &operator<<( const QCString & arg );
246 250
247 /** 251 /**
248 * Sets the executable and the command line argument list for this process, 252 * Sets the executable and the command line argument list for this process,
249 * in a single method call, or add a list of arguments. 253 * in a single method call, or add a list of arguments.
250 **/ 254 **/
251 OProcess &operator<<(const QStringList& args); 255 OProcess &operator<<( const QStringList& args );
252 256
253 /** 257 /**
254 * Clear a command line argument list that has been set by using 258 * Clear a command line argument list that has been set by using
@@ -278,8 +282,8 @@ public:
278 * @return true on success, false on error 282 * @return true on success, false on error
279 * (see above for error conditions) 283 * (see above for error conditions)
280 **/ 284 **/
281 virtual bool start(RunMode runmode = NotifyOnExit, 285 virtual bool start( RunMode runmode = NotifyOnExit,
282 Communication comm = NoCommunication); 286 Communication comm = NoCommunication );
283 287
284 /** 288 /**
285 * Stop the process (by sending it a signal). 289 * Stop the process (by sending it a signal).
@@ -287,7 +291,7 @@ public:
287 * @param signoThe signal to send. The default is SIGTERM. 291 * @param signoThe signal to send. The default is SIGTERM.
288 * @return @p true if the signal was delivered successfully. 292 * @return @p true if the signal was delivered successfully.
289 */ 293 */
290 virtual bool kill(int signo = SIGTERM); 294 virtual bool kill( int signo = SIGTERM );
291 295
292 /** 296 /**
293 @return @p true if the process is (still) considered to be running 297 @return @p true if the process is (still) considered to be running
@@ -333,7 +337,7 @@ public:
333 * this function because if the process did not exit normally, 337 * this function because if the process did not exit normally,
334 * it does not have a valid exit status. 338 * it does not have a valid exit status.
335 */ 339 */
336 int exitStatus() const; 340 int exitStatus() const;
337 341
338 342
339 /** 343 /**
@@ -360,7 +364,7 @@ public:
360 * data has been sent or a @ref processHasExited() signal shows that 364 * data has been sent or a @ref processHasExited() signal shows that
361 * the child process is no longer alive... 365 * the child process is no longer alive...
362 **/ 366 **/
363 bool writeStdin(const char *buffer, int buflen); 367 bool writeStdin( const char *buffer, int buflen );
364 368
365 void flushStdin(); 369 void flushStdin();
366 370
@@ -395,7 +399,10 @@ public:
395 * Lets you see what your arguments are for debugging. 399 * Lets you see what your arguments are for debugging.
396 */ 400 */
397 401
398 const QValueList<QCString> &args() { return arguments; } 402 const QValueList<QCString> &args()
403 {
404 return arguments;
405 }
399 406
400 /** 407 /**
401 * Controls whether the started process should drop any 408 * Controls whether the started process should drop any
@@ -403,7 +410,7 @@ public:
403 * 410 *
404 * The default is @p false : drop privileges 411 * The default is @p false : drop privileges
405 */ 412 */
406 void setRunPrivileged(bool keepPrivileges); 413 void setRunPrivileged( bool keepPrivileges );
407 414
408 /** 415 /**
409 * Returns whether the started process will drop any 416 * Returns whether the started process will drop any
@@ -415,14 +422,14 @@ public:
415 * Modifies the environment of the process to be started. 422 * Modifies the environment of the process to be started.
416 * This function must be called before starting the process. 423 * This function must be called before starting the process.
417 */ 424 */
418 void setEnvironment(const QString &name, const QString &value); 425 void setEnvironment( const QString &name, const QString &value );
419 426
420 /** 427 /**
421 * Changes the current working directory (CWD) of the process 428 * Changes the current working directory (CWD) of the process
422 * to be started. 429 * to be started.
423 * This function must be called before starting the process. 430 * This function must be called before starting the process.
424 */ 431 */
425 void setWorkingDirectory(const QString &dir); 432 void setWorkingDirectory( const QString &dir );
426 433
427 /** 434 /**
428 * Specify whether to start the command via a shell or directly. 435 * Specify whether to start the command via a shell or directly.
@@ -435,7 +442,7 @@ public:
435 * are properly quoted when passed as argument. 442 * are properly quoted when passed as argument.
436 * @see quote() 443 * @see quote()
437 */ 444 */
438 void setUseShell(bool useShell, const char *shell = 0); 445 void setUseShell( bool useShell, const char *shell = 0 );
439 446
440 /** 447 /**
441 * This function can be used to quote an argument string such that 448 * This function can be used to quote an argument string such that
@@ -443,7 +450,7 @@ public:
443 * user-provided file names which may contain spaces or quotes. 450 * user-provided file names which may contain spaces or quotes.
444 * It also prevents expansion of wild cards and environment variables. 451 * It also prevents expansion of wild cards and environment variables.
445 */ 452 */
446 static QString quote(const QString &arg); 453 static QString quote( const QString &arg );
447 454
448 /** 455 /**
449 * Detaches OProcess from child process. All communication is closed. 456 * Detaches OProcess from child process. All communication is closed.
@@ -454,8 +461,6 @@ public:
454 */ 461 */
455 void detach(); 462 void detach();
456 463
457
458
459signals: 464signals:
460 465
461 /** 466 /**
@@ -463,7 +468,7 @@ signals:
463 * the process was run in the @p NotifyOnExit (==default option to 468 * the process was run in the @p NotifyOnExit (==default option to
464 * @ref start()) or the @ref Block mode. 469 * @ref start()) or the @ref Block mode.
465 **/ 470 **/
466 void processExited(OProcess *proc); 471 void processExited( OProcess *proc );
467 472
468 473
469 /** 474 /**
@@ -480,7 +485,7 @@ signals:
480 * You should copy the information contained in @p buffer to your private 485 * You should copy the information contained in @p buffer to your private
481 * data structures before returning from this slot. 486 * data structures before returning from this slot.
482 **/ 487 **/
483 void receivedStdout(OProcess *proc, char *buffer, int buflen); 488 void receivedStdout( OProcess *proc, char *buffer, int buflen );
484 489
485 /** 490 /**
486 * Emitted when output from the child process has 491 * Emitted when output from the child process has
@@ -497,7 +502,7 @@ signals:
497 * 502 *
498 * The data still has to be read from file descriptor @p fd. 503 * The data still has to be read from file descriptor @p fd.
499 **/ 504 **/
500 void receivedStdout(int fd, int &len); 505 void receivedStdout( int fd, int &len );
501 506
502 507
503 /** 508 /**
@@ -513,15 +518,14 @@ signals:
513 * You should copy the information contained in @p buffer to your private 518 * You should copy the information contained in @p buffer to your private
514 * data structures before returning from this slot. 519 * data structures before returning from this slot.
515 */ 520 */
516 void receivedStderr(OProcess *proc, char *buffer, int buflen); 521 void receivedStderr( OProcess *proc, char *buffer, int buflen );
517 522
518 /** 523 /**
519 * Emitted after all the data that has been 524 * Emitted after all the data that has been
520 * specified by a prior call to @ref writeStdin() has actually been 525 * specified by a prior call to @ref writeStdin() has actually been
521 * written to the child process. 526 * written to the child process.
522 **/ 527 **/
523 void wroteStdin(OProcess *proc); 528 void wroteStdin( OProcess *proc );
524
525 529
526protected slots: 530protected slots:
527 531
@@ -529,13 +533,13 @@ protected slots:
529 * This slot gets activated when data from the child's stdout arrives. 533 * This slot gets activated when data from the child's stdout arrives.
530 * It usually calls "childOutput" 534 * It usually calls "childOutput"
531 */ 535 */
532 void slotChildOutput(int fdno); 536 void slotChildOutput( int fdno );
533 537
534 /** 538 /**
535 * This slot gets activated when data from the child's stderr arrives. 539 * This slot gets activated when data from the child's stderr arrives.
536 * It usually calls "childError" 540 * It usually calls "childError"
537 */ 541 */
538 void slotChildError(int fdno); 542 void slotChildError( int fdno );
539 /* 543 /*
540 Slot functions for capturing stdout and stderr of the child 544 Slot functions for capturing stdout and stderr of the child
541 */ 545 */
@@ -545,7 +549,7 @@ protected slots:
545 * stdin. If there is no more data to be sent to stdin currently 549 * stdin. If there is no more data to be sent to stdin currently
546 * available, this function must disable the QSocketNotifier "innot". 550 * available, this function must disable the QSocketNotifier "innot".
547 */ 551 */
548 void slotSendData(int dummy); 552 void slotSendData( int dummy );
549 553
550protected: 554protected:
551 555
@@ -624,7 +628,7 @@ protected:
624 * but you could overload this function and establish a TCP/IP communication for 628 * but you could overload this function and establish a TCP/IP communication for
625 * network communication, for example. 629 * network communication, for example.
626 */ 630 */
627 virtual int setupCommunication(Communication comm); 631 virtual int setupCommunication( Communication comm );
628 632
629 /** 633 /**
630 * Called right after a (successful) fork on the parent side. This function 634 * Called right after a (successful) fork on the parent side. This function
@@ -654,7 +658,7 @@ protected:
654 * process and emits the "processExited" signal (if the process was 658 * process and emits the "processExited" signal (if the process was
655 * not running in the "DontCare" mode). 659 * not running in the "DontCare" mode).
656 */ 660 */
657 virtual void processHasExited(int state); 661 virtual void processHasExited( int state );
658 662
659 /** 663 /**
660 * Should clean up the communication links to the child after it has 664 * Should clean up the communication links to the child after it has
@@ -666,9 +670,9 @@ protected:
666 /** 670 /**
667 * the socket descriptors for stdin/stdout/stderr. 671 * the socket descriptors for stdin/stdout/stderr.
668 */ 672 */
669 int out[2]; 673 int out[ 2 ];
670 int in[2]; 674 int in[ 2 ];
671 int err[2]; 675 int err[ 2 ];
672 676
673 /** 677 /**
674 * The socket notifiers for the above socket descriptors. 678 * The socket notifiers for the above socket descriptors.
@@ -688,14 +692,14 @@ protected:
688 * child process's stdout to the respective buffer and emits the signal 692 * child process's stdout to the respective buffer and emits the signal
689 * "@ref receivedStderr". 693 * "@ref receivedStderr".
690 */ 694 */
691 int childOutput(int fdno); 695 int childOutput( int fdno );
692 696
693 /** 697 /**
694 * Called by "slotChildOutput" this function copies data arriving from the 698 * Called by "slotChildOutput" this function copies data arriving from the
695 * child process's stdout to the respective buffer and emits the signal 699 * child process's stdout to the respective buffer and emits the signal
696 * "@ref receivedStderr" 700 * "@ref receivedStderr"
697 */ 701 */
698 int childError(int fdno); 702 int childError( int fdno );
699 703
700 // information about the data that has to be sent to the child: 704 // information about the data that has to be sent to the child:
701 705
@@ -709,7 +713,6 @@ protected:
709 */ 713 */
710 friend class OProcessController; 714 friend class OProcessController;
711 715
712
713private: 716private:
714 /** 717 /**
715 * Searches for a valid shell. 718 * Searches for a valid shell.
@@ -729,7 +732,7 @@ private:
729 * Used by @ref searchShell in order to find out whether the shell found 732 * Used by @ref searchShell in order to find out whether the shell found
730 * is actually executable at all. 733 * is actually executable at all.
731 */ 734 */
732 bool isExecutable(const QCString &filename); 735 bool isExecutable( const QCString &filename );
733 736
734 // Disallow assignment and copy-construction 737 // Disallow assignment and copy-construction
735 OProcess( const OProcess& ); 738 OProcess( const OProcess& );
@@ -737,11 +740,8 @@ private:
737 740
738private: 741private:
739 void init ( ); 742 void init ( );
740
741 OProcessPrivate *d; 743 OProcessPrivate *d;
742}; 744};
743 745
744
745
746#endif 746#endif
747 747