summaryrefslogtreecommitdiffstats
path: root/kdeprint/kmmanager.h
blob: 3042457302805362031aa3e7fa82b09d4e9f5356 (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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
/*
 *  This file is part of the KDE libraries
 *  Copyright (c) 2001 Michael Goffioul <kdeprint@swing.be>
 *
 *  This library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Library General Public
 *  License version 2 as published by the Free Software Foundation.
 *
 *  This library is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *  Library General Public License for more details.
 *
 *  You should have received a copy of the GNU Library General Public License
 *  along with this library; see the file COPYING.LIB.  If not, write to
 *  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 *  Boston, MA 02110-1301, USA.
 **/

#ifndef KMMANAGER_H
#define KMMANAGER_H

#if !defined( _KDEPRINT_COMPILE ) && defined( __GNUC__ )
#warning internal header, do not use except if you are a KDEPrint developer
#endif

#include <kdeprint/kmprinter.h>

#include <tqobject.h>
#include <tqstring.h>
#include <tqptrlist.h>

class DrMain;
class KMDBEntry;
class KMVirtualManager;
class KMSpecialManager;
class TQWidget;
class KActionCollection;
class PrinterFilter;

/**
 * @internal
 * This class is internal to KDEPrint and is not intended to be
 * used outside it. Please do not make use of this header, except
 * if you're a KDEPrint developer. The API might change in the
 * future and binary compatibility might be broken.
 */
class KDEPRINT_EXPORT KMManager : public TQObject
{
	Q_OBJECT

friend class KMVirtualManager;
friend class KMSpecialManager;
friend class KMFactory;

public:
	enum PrinterOperations {
		PrinterEnabling  = 0x01,
		PrinterCreation  = 0x02,
		PrinterDefault   = 0x04,
		PrinterTesting   = 0x08,
		PrinterConfigure = 0x10,
		PrinterRemoval   = 0x20,
		PrinterAll       = 0xFF
	};
	enum ServerOperations {
		ServerRestarting = 0x1,
		ServerConfigure  = 0x2,
		ServerAll        = 0xF
	};

	KMManager(TQObject *parent = 0, const char *name = 0);
	virtual ~KMManager();

    static KMManager* self();

	// error management functions
	TQString errorMsg() const		{ return m_errormsg; }
	void setErrorMsg(const TQString& s)	{ m_errormsg = s; }

	// support management ?
	bool hasManagement() const 		{ return m_hasmanagement; }

	// printer management functions
	virtual bool createPrinter(KMPrinter *p);
	virtual bool removePrinter(KMPrinter *p);
	virtual bool enablePrinter(KMPrinter *p, bool on);
	virtual bool startPrinter(KMPrinter *p, bool on);
	virtual bool completePrinter(KMPrinter *p);
	virtual bool completePrinterShort(KMPrinter *p);
	virtual bool setDefaultPrinter(KMPrinter *p);
	virtual bool testPrinter(KMPrinter *p);
	bool upPrinter(KMPrinter *p, bool state);
	bool modifyPrinter(KMPrinter *oldp, KMPrinter *newp);
	bool removePrinter(const TQString& name);
	bool enablePrinter(const TQString& name, bool state);
	bool startPrinter(const TQString& name, bool state);
	bool completePrinter(const TQString& name);
	bool setDefaultPrinter(const TQString& name);
	int printerOperationMask() const 	{ return m_printeroperationtqmask; }
	int addPrinterWizard(TQWidget *parent = 0);

	// special printer management functions
	bool createSpecialPrinter(KMPrinter *p);
	bool removeSpecialPrinter(KMPrinter *p);

	// printer listing functions
	KMPrinter* tqfindPrinter(const TQString& name);
	TQPtrList<KMPrinter>* printerList(bool reload = true);
	TQPtrList<KMPrinter>* printerListComplete(bool reload = true);
	KMPrinter* defaultPrinter();
	void enableFilter(bool on);
	bool isFilterEnabled() const;

	// driver DB functions
	virtual TQString driverDbCreationProgram();
	virtual TQString driverDirectory();

	// driver functions
	virtual DrMain* loadPrinterDriver(KMPrinter *p, bool config = false);
	virtual DrMain* loadDbDriver(KMDBEntry *entry);
	virtual DrMain* loadFileDriver(const TQString& filename);
	DrMain* loadDriver(KMPrinter *p, bool config = false);
	virtual bool savePrinterDriver(KMPrinter *p, DrMain *d);
	virtual bool validateDbDriver(KMDBEntry *entry);

	// configuration functions
	bool invokeOptionsDialog(TQWidget *parent = 0);
	virtual TQString stateInformation();

	// server functions
	int serverOperationMask() const 	{ return m_serveroperationtqmask; }
	virtual bool restartServer();
	virtual bool configureServer(TQWidget *parent = 0);
	virtual TQStringList detectLocalPrinters();

	// additional actions (for print manager)
	virtual void createPluginActions(KActionCollection*);
	virtual void validatePluginActions(KActionCollection*, KMPrinter*);

	// utility function
	void checkUpdatePossible();

signals:
	void updatePossible( bool );

protected:
	// the real printer listing job is done here
	virtual void listPrinters();

	// utility functions
	void addPrinter(KMPrinter *p);	// in any case, the pointer given MUST not be used after
					// calling this function. Useful when listing printers.
	void setHardDefault(KMPrinter*);
	void setSoftDefault(KMPrinter*);
	KMPrinter* softDefault() const;
	KMPrinter* hardDefault() const;
	// this function uncompress the given file (or does nothing
	// if the file is not compressed). Returns wether the file was
	// compressed or not.
	bool uncompressFile(const TQString& srcname, TQString& destname);
	bool notImplemented();
	void setHasManagement(bool on)		{ m_hasmanagement = on; }
	void setPrinterOperationMask(int m)	{ m_printeroperationtqmask = m; }
	void setServerOperationMask(int m)	{ m_serveroperationtqmask = m; }
	TQString testPage();
	void discardAllPrinters(bool);
	void setUpdatePossible( bool );
	virtual void checkUpdatePossibleInternal();

protected:
	QString			m_errormsg;
	KMPrinterList		m_printers, m_fprinters;	// filtered printers
	bool 			m_hasmanagement;
	int			m_printeroperationtqmask;
	int 			m_serveroperationtqmask;
	KMSpecialManager	*m_specialmgr;
	KMVirtualManager	*m_virtualmgr;
	PrinterFilter	*m_printerfilter;
	bool m_updatepossible;
};

#endif