summaryrefslogtreecommitdiffstats
path: root/kmyfirewall/core/kprocesswrapper.h
blob: b64e74f6da3f77e3537c456b22945ea0c37f602f (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
//
// C++ Interface: kprocesswrapper
//
// Description: 
//
//
// Author: Christian Hubinger <[email protected]>, (C) 2008
//
// Copyright: See COPYING file that comes with this distribution
//
//
#ifndef KMFKPROCESSWRAPPER_H
#define KMFKPROCESSWRAPPER_H


// QT Includes
#include <qobject.h>
#include <qstring.h>

// KDE includes


class KProcess;

// Project includes
namespace KMF {
class KMFTarget;

/**
	@author Christian Hubinger <[email protected]>
*/
class KProcessWrapper : public QObject {
Q_OBJECT

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

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

    ~KProcessWrapper();

	bool isRunning();
	
	const QString& jobName() const {
		return m_jobName;
	}
	const QString& stdOut() const {
		return m_stdOut;
	}
	const QString& stdErr() const {
		return m_stdErr;
	}
	const QString& 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 QString& jobName, const QString& command, bool useKdeSu /* = false */, bool synchronous /* = false */); 
	void slotStartRemoteJob( const QString& jobName, const QString& scriptFile, KMFTarget* execHost ); 

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

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

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

}

#endif