summaryrefslogtreecommitdiffstats
path: root/src/app/krservices.h
blob: 097fb11c8420c1d2c8bb4fbdc206403a112d32f6 (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
/***************************************************************************
                          krservices.h  -  description
                             -------------------
    begin                : Thu Aug 8 2002
    copyright            : (C) 2002 by Shie Erlich & Rafi Yanai
    email                : 
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   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 KRSERVICES_H
#define KRSERVICES_H

#include <tqstring.h>
#include <tqstringlist.h>
#include <tqmap.h>
#include <tdeprocess.h>

/**
  *@author Shie Erlich & Rafi Yanai
  */

class KrServices {
public: 
	KrServices(){}
	~KrServices(){}

	static bool         cmdExist(TQString cmdName);
	static TQString      detectFullPathName( TQString name );
	static TQString      fullPathName( TQString name, TQString confName = TQString() );
	static TQStringList  separateArgs( TQString args );
	static TQString      registerdProtocol(TQString mimetype);
	static void         clearProtocolCache();
	static bool         fileToStringList(TQTextStream *stream, TQStringList& target, bool keepEmptyLines=false);
	static TQString		  quote( TQString name );
	static TQStringList  quote( const TQStringList& names );

protected:
	static TQString 	  escape( TQString name );

private:
	static TQMap<TQString,TQString>* slaveMap;

};


// TODO: make KrServices a namespace and move it there

// wraps over tdeprocess, but buffers stdout and stderr and allows easy access to them later
// note, that you still have to enable stdout,stderr in KEasyProcess::start() for buffering
// to happen (ie: start(KEasyProcess::Block, KEasyProcess::AllOutput);)
class KEasyProcess: public TDEProcess {
	TQ_OBJECT
  
public:
	KEasyProcess(TQObject *parent, const char *name=0);
	KEasyProcess();
	virtual ~KEasyProcess() {}

	const TQString& getStdout() const { return _stdout; }
	const TQString& getStderr() const { return _stderr; }

protected slots:
	void receivedStdout (TDEProcess *proc, char *buffer, int buflen);
	void receivedStderr (TDEProcess *proc, char *buffer, int buflen);
	void init();

private:
	TQString _stdout, _stderr;
};

#endif