summaryrefslogtreecommitdiffstats
path: root/src/kile/kilelauncher.h
blob: 7af50a19d4583ca5d241f8fe3d6ab352c45b5be3 (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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
/***************************************************************************
    begin                : mon 3-11 20:40:00 CEST 2003
    copyright            : (C) 2003 by Jeroen Wijnhout
    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 KILE_LAUNCHER
#define KILE_LAUNCHER

#include <tqobject.h>
#include <tqdict.h>
#include <tqstringlist.h>

class TQWidgetStack;


class KProcess;
class KShellProcess;
class KileInfo;
namespace KParts { class ReadOnlyPart; class PartManager; }

namespace KileTool
{
	class Base;
	
	/**
	 * This class represents a way to launch a tool. This could be a commandline tool
	 * running in a Konsole, running as a separate process, it could even be responsible
	 * for starting a KPart.
	 *
	 * @author Jeroen Wijnhout
	 **/
	class Launcher : public TQObject
	{
		Q_OBJECT
  

	public:
		Launcher();
		~Launcher();

	public slots:
		virtual bool launch() = 0;
		virtual bool kill() = 0;
		virtual bool selfCheck() = 0;

	public:
		virtual void setWorkingDirectory(const TQString &) {}

		void setTool(Base *tool) { m_tool = tool; }
		Base* tool() { return m_tool; }
		
	signals:
		void message(int, const TQString & );
		void output(const TQString &);

		void exitedWith(int);
		void abnormalExit();

		void done(int);

	private:
		//TQDict<TQString>	*m_pdictParams;
		Base			*m_tool;
	};

	class ProcessLauncher : public Launcher
	{
		Q_OBJECT
  

	public:
		ProcessLauncher(const char * shellname =0);
		~ProcessLauncher();

	public:
		void setWorkingDirectory(const TQString &wd);
		void changeToWorkingDirectory(bool change) { m_changeTo = change; }
		void setCommand(const TQString & cmd) { m_cmd = cmd; }
		void setOptions(const TQString & opt) { m_options = opt; }

	public slots:
		bool launch();
		bool kill();
		bool selfCheck();

	private slots:
		void slotProcessOutput(KProcess*, char*, int );
		void slotProcessExited(KProcess*);

	private:
		TQString 	m_wd, m_cmd, m_options, m_texinputs, m_bibinputs, m_bstinputs;
		KShellProcess	*m_proc;
		bool		m_changeTo;
	};

	class KonsoleLauncher : public ProcessLauncher
	{
		Q_OBJECT
  

	public:
		KonsoleLauncher(const char * shellname =0);

	public slots:
		bool launch();
	};

	class PartLauncher : public Launcher
	{
		Q_OBJECT
  

	public:
		PartLauncher(const char * = 0);
		~PartLauncher();

		void setLibrary(const char *lib) { m_libName = lib; }
		void setClass(const char *clas) { m_className = clas; }
		void setOptions(TQString & options) { m_options = options; }

	public slots:
		bool launch();
		bool kill();
		bool selfCheck() { return true; } //no additional self-checks, all of them are done in launch()

		KParts::ReadOnlyPart* part() { return m_part; }

	protected:
		KParts::ReadOnlyPart	*m_part;

		TQString				m_state;
		const char			*m_name, *m_libName, *m_className;
		TQString				m_options;
	};

	class DocPartLauncher : public PartLauncher
	{
		Q_OBJECT
  

	public:
		DocPartLauncher(const char * name = 0) : PartLauncher(name) {}
		
	public slots:
		bool launch();
	};
}

#endif