summaryrefslogtreecommitdiffstats
path: root/src/common/nokde/nokde_kprocess.h
blob: 59ff73c4a7267603b2c2fc26131b04bcd9b1afd6 (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
#ifndef _KPROCESS_H_
#define _KPROCESS_H_

#include <qdir.h>
#include "common/global/global.h"
#include "common/common/synchronous.h"
#if QT_VERSION<0x040000
class QProcess;
#else
class Q3Process;
#endif

class KProcess : public QObject
{
Q_OBJECT
public:
  KProcess(QObject *parent = 0, const char *name = 0);
  void clearArguments() { _arguments.clear(); }
  KProcess &operator<< (const QString &arg) { _arguments += arg; return *this; }
  KProcess &operator<< (const QStringList &args) { _arguments += args; return *this; }
  QStringList args() const { return _arguments; }
  void setEnvironment(const QString &name, const QString &value) { _environment += name + "=" + value; }
  bool start();
  bool writeStdin(const char *buffer, int len);
  bool kill();
  bool kill(int n);
  int exitStatus() const;
  bool isRunning() const;
  void setWorkingDirectory(const QDir &dir);
  void setUseShell(bool useShell);

signals:
  void processExited(KProcess *process);
  void receivedStdout(KProcess *process, char *buffer, int len);
  void receivedStderr(KProcess *process, char *buffer, int len);

private slots:
  void processExitedSlot();
  void readyReadStdoutSlot();
  void readyReadStderrSlot();

private:
#if QT_VERSION<0x040000
  QProcess *_process;
#else
  Q3Process  *_process;
#endif
  QStringList _arguments,_environment;
};

#endif