1 /**************************************************************************
2 *   Copyright (C) 2005-2020 by Oleksandr Shneyder                         *
3 *                              <o.shneyder@phoca-gmbh.de>                 *
4 *                                                                         *
5 *   This program is free software; you can redistribute it and/or modify  *
6 *   it under the terms of the GNU General Public License as published by  *
7 *   the Free Software Foundation; either version 2 of the License, or     *
8 *   (at your option) any later version.                                   *
9 *   This program is distributed in the hope that it will be useful,       *
10 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
11 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
12 *   GNU General Public License for more details.                          *
13 *                                                                         *
14 *   You should have received a copy of the GNU General Public License     *
15 *   along with this program.  If not, see <https://www.gnu.org/licenses/>. *
16 ***************************************************************************/
17 
18 #ifndef CUPSPRINT_H
19 #define CUPSPRINT_H
20 #include "x2goclientconfig.h"
21 #ifndef Q_OS_WIN
22 #include <QStringList>
23 #include <cups/cups.h>
24 #include <cups/ppd.h>
25 /**
26 	@author Oleksandr Shneyder <oleksandr.shneyder@obviously-nice.de>
27 */
28 class CUPSPrint
29 {
30 	public:
31 		enum printState {NDEF,IDLE,PRINTING,STOPPED};
32 
33 		CUPSPrint();
34 		~CUPSPrint();
35 		void setDefaultUserPrinter ( QString printer );
36 		QString getDefaultUserPrinter();
37 		QStringList getPrinters();
38 		bool getPrinterInfo ( const QString& printerName,
39 		                      QString& info, bool& acceptJobs,
40 		                      QString& location, QString& model,
41 		                      printState& state, QString& stateReason );
42 		bool setCurrentPrinter ( QString );
43 		bool getOptionValue ( const QString& option,
44 		                      QString& value, QString& valueText );
45 		int getOptionValues ( const QString& option,
46 		                      QStringList& values,
47 		                      QStringList& descriptions );
48 		int getOptionGroups ( QStringList& names, QStringList& texts );
49 		int getOptionsList ( const QString& group, QStringList& names,
50 		                     QStringList& texts );
51 		bool setValue ( const QString& option, const QString& value,
52 		                QString& conflict_opt, QString& conflict_val );
53 		bool getOptionText ( const QString& option, QString& text );
54 		void setDefaults();
55 		void saveOptions();
56 		void print ( const QString& file, QString title="" );
57 
58 	private:
59 		cups_dest_t *dests;
60 		int num_dests;
61 		ppd_file_t *ppd;
62 		QString currentPrinter;
63 	private:
64 		void loadUserOptions();
65 };
66 
67 #endif
68 #endif
69