summaryrefslogtreecommitdiffstats
path: root/kdpkg-install/process.cpp
blob: 9c02a774e62b6705afd123e9a23a4b2f9641cefc (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
#include "process.h"




	Process::Process()
	{
		_buffer = QString::null;
		_process = new KProcess();
	
		connect(_process, SIGNAL(receivedStdout(KProcess*, char*, int)),
			this, SLOT(slotProcessOutput(KProcess*, char*, int)));
	
	}
	
	Process::~Process()
	{
	}
	
	void Process::setCommand(QString command)
	{
		// make clean
		_process->clearArguments();
		_buffer = QString::null;
		
		*_process << "/bin/sh";
		*_process << "-c";
		*_process << command;
	}
	
	
	void Process::start(bool block)
	{
		if( block )
			_process->start(KProcess::Block, KProcess::Stdout);
		else
			_process->start(KProcess::DontCare, KProcess::Stdout);
	}
	
	QString Process::getBuffer()
	{
		return _buffer;
	}
	
	int Process::exitStatus()
	{
		return _process->exitStatus();
	}
	
	bool Process::normalExit()
	{
		return _process->normalExit();
	}
	
	void Process::slotProcessOutput(KProcess* process, char* buffer, int len)
	{
		if (process != _process) return;
	
		_buffer.append(QString::fromLocal8Bit(buffer, len));
	}