summaryrefslogtreecommitdiffstats
path: root/src/kile/configtester.h
blob: 8646970a52e45c57d1e26ef6a7bb19ae4d15052a (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
/***************************************************************************
    begin                : Fri Jun 4 2004
    copyright            : (C) 2004 by Jeroen Wijnout
    email                : Jeroen.Wijnhout@kdemail.net
 ***************************************************************************/

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

#include <tqobject.h>

class KTempDir;
class KConfig;
class KProcess;
class KURL;

/**
@author Jeroen Wijnhout
*/

class ConfigTest
{
	public:
		enum tqStatus { Success = 3, Failure = 2, Critical = 1 };

		ConfigTest();
		ConfigTest(const TQString &name, bool mustpass, const TQString &arg, const TQString &altarg = TQString());

		int status() const;

		TQString resultText() const;
		TQString name() const;

	private:
		TQString	m_name, m_arg, m_altArg;
		bool 		m_mustPass;

	public:
		static void addPrettyName(const TQString &test, const TQString &prettyName);
		static void addSuccessMessage(const TQString &test, const TQString &msg);
		static void addFailureMessage(const TQString &test, const TQString &msg);
		static void addCriticalMessage(const TQString &test, const TQString &msg);

		static TQString prettyName(const TQString &test);
		static TQString successMessage(const TQString &test);
		static TQString failureMessage(const TQString &test);
		static TQString criticalMessage(const TQString &test);

	private:
		static TQMap<TQString,TQString> s_prettyName, s_msgSuccess, s_msgFailure, s_msgCritical;
};

class Tester : public TQObject
{
	Q_OBJECT
  TQ_OBJECT

public:
	Tester(TQObject *tqparent = 0, const char *name = 0);
	~Tester();

	TQStringList testedTools();
	TQValueList<ConfigTest> resultForTool(const TQString &);
	int statusForTool(const TQString &);

public slots:
	void runTests();
	void saveResults(const KURL &);
	void stop();

signals:
	void started();
	void percentageDone(int);
	void finished(bool);

private slots:
	void determineProgress(KProcess *, char *, int);
	void processTestResults (KProcess *);
	void processTool(KConfig *, const TQString &);

	void addResult(const TQString &tool, const TQValueList<ConfigTest> &tests);

private:
	TQMap<TQString,TQValueList<ConfigTest> >	m_results;
	TQString								m_resultsFile;
	KTempDir							*m_tempDir;
	KProcess								*m_process;
};

#endif