summaryrefslogtreecommitdiffstats
path: root/kmyfirewall/core/kprocesswrapper.h
blob: 1edc4a52c707c18b1f15f79d2bf4c7d3bc2fbbc0 (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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
//
// C++ Interface: kprocesswrapper
//
// Description: 
//
//
// Author: Christian Hubinger <chubinger@irrsinnig.org>, (C) 2008
//
// Copyright: See COPYING file that comes with this distribution
//
//
#ifndef KMFKPROCESSWRAPPER_H
#define KMFKPROCESSWRAPPER_H


// QT Includes
#include <tqobject.h>
#include <tqstring.h>

// KDE includes


class KProcess;

// Project includes
namespace KMF {
class KMFTarget;

/**
	@author Christian Hubinger <chubinger@irrsinnig.org>
*/
class KProcessWrapper : public TQObject {
Q_OBJECT
  TQ_OBJECT

//############# Beginn static stuff ##############	
public:
	/** return the one and only instance */
	static KProcessWrapper* instance();
private:	
	static KProcessWrapper* m_instance;
	
//############# End static stuff ##############

public:
    KProcessWrapper( TQObject*, const char* );

    ~KProcessWrapper();

	bool isRunning();
	
	const TQString& jobName() const {
		return m_jobName;
	}
	const TQString& stdOut() const {
		return m_stdOut;
	}
	const TQString& stdErr() const {
		return m_stdErr;
	}
	const TQString& stdCombined() const {
		return m_allOut;
	}
	const int exitStatus() const {
		return m_status;
	}
	const bool exitedNormal() const {
		return m_exitedNormal;
	}
	
public slots:
	void slotKillJob();

	void slotStartLocalJob( const TQString& jobName, const TQString& command, bool useKdeSu /* = false */, bool synchronous /* = false */); 
	void slotStartRemoteJob( const TQString& jobName, const TQString& scriptFile, KMFTarget* execHost ); 

protected slots:
	void slotReceivedOutput( KProcess*, char*, int );
	void slotReceivedError( KProcess*, char*, int );
	void slotProcessExited( KProcess* );
		

private:
	TQString* m_stderrbuf;
	TQString* m_stdoutbuf;
	
	TQString m_jobName;
	TQString m_allOut;
	int m_status;
	bool m_exitedNormal;
	
	TQString m_stdOut;
	TQString m_stdErr;
	KProcess* m_childproc;

signals:
	void sigProcessFinished( const TQString& jobName, int status, bool exitedNormal, const TQString& stdOut, const TQString& stdErr, const TQString& completeOut );
	
	void sigReceivedStdOut( const TQString& jobName, const TQString& stdOut );
	void sigReceivedStdErr( const TQString& jobName, const TQString& stdOut );
};

}

#endif