summaryrefslogtreecommitdiffstats
path: root/kommander/widget/myprocess.h
blob: cb9c80b5df8a0c964346d2afda5adc3ecb6c4f9a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/***************************************************************************
                          myprocess.h - Wrapper class for running shell processes 
                             -------------------
    copyright            : (C) 2002 by Marc Britton
    email                : consume@optusnet.com.au
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/
#ifndef _HAVE_MYPROCESS_H_
#define _HAVE_MYPROCESS_H_

/* KDE INCLUDES */
#include <kprocess.h>

/* QT INCLUDES */
#include <tqstring.h>
#include <tqobject.h>
#include "kommander_export.h"

class KommanderWidget;

class KOMMANDER_EXPORT MyProcess : public TQObject
{
  Q_OBJECT
  
public:
  MyProcess(const KommanderWidget *);
  // Run given command, using a_shell as a shell (this can be overridden by shebang in the first line)
  // Process is run in blocking mode.
  TQString run(const TQString& a_command, const TQString& a_shell = "/bin/sh");
  // Kill running process
  void cancel();
  void setBlocking(bool blocking);
  bool isBlocking() const;
  TQString output() const;
signals:
  void processExited(MyProcess*);
  void processReceivedStdout(MyProcess*, char*, int);
private slots:
  void slotReceivedStdout(KProcess*, char*, int);
  void slotProcessExited(KProcess*);
protected:
  const KommanderWidget *m_atw;
  TQString m_output;
  TQCString m_input;
  bool m_loopStarted;
  bool m_blocking;
  bool m_handleOutput;
  KProcess* mProcess;
};

#endif