2
* Copyright (C) 2017 Canonical, Ltd.
4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU Lesser General Public License as published by
6
* the Free Software Foundation; version 3.
8
* This program is distributed in the hope that it will be useful,
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
* GNU Lesser General Public License for more details.
13
* You should have received a copy of the GNU Lesser General Public License
14
* along with this program. If not, see <http://www.gnu.org/licenses/>.
17
#ifndef USC_PRINTERS_BACKEND_H
18
#define USC_PRINTERS_BACKEND_H
20
#include "printer/printer.h"
21
#include "printer/printerjob.h"
23
// TODO: remove cups specific things from this API
24
#include <cups/cups.h>
30
#include <QStringList>
34
class PRINTERS_DECL_EXPORT PrinterBackend : public QObject
38
explicit PrinterBackend(QObject *parent = Q_NULLPTR);
39
explicit PrinterBackend(const QString &printerName,
40
QObject *parent = Q_NULLPTR);
41
virtual ~PrinterBackend();
43
virtual bool holdsDefinition() const;
45
// Add a printer using an already existing ppd.
46
virtual QString printerAdd(const QString &name,
48
const QString &ppdFile,
50
const QString &location);
52
// Add a printer and provide a ppd file.
53
virtual QString printerAddWithPpd(const QString &name,
55
const QString &ppdFileName,
57
const QString &location);
58
virtual QString printerDelete(const QString &name);
59
virtual QString printerSetDefault(const QString &name);
60
virtual QString printerSetEnabled(const QString &name,
62
virtual QString printerSetAcceptJobs(
65
const QString &reason = QString::null);
66
virtual QString printerSetInfo(const QString &name,
68
virtual QString printerSetLocation(const QString &name,
69
const QString &location);
70
virtual QString printerSetShared(const QString &name,
72
virtual QString printerSetJobSheets(const QString &name,
75
virtual QString printerSetErrorPolicy(const QString &name,
76
const PrinterEnum::ErrorPolicy &policy);
78
virtual QString printerSetOpPolicy(const QString &name,
79
const PrinterEnum::OperationPolicy &policy);
80
virtual QString printerSetUsersAllowed(const QString &name,
81
const QStringList &users);
82
virtual QString printerSetUsersDenied(const QString &name,
83
const QStringList &users);
84
virtual QString printerAddOptionDefault(const QString &name,
85
const QString &option,
86
const QStringList &values);
87
virtual QString printerDeleteOptionDefault(const QString &name,
88
const QString &value);
89
virtual QString printerAddOption(const QString &name,
90
const QString &option,
91
const QStringList &values);
93
virtual QVariant printerGetOption(const QString &name,
94
const QString &option) const;
95
virtual QMap<QString, QVariant> printerGetOptions(
96
const QString &name, const QStringList &options) const;
97
// FIXME: maybe have a PrinterDest iface that has a CupsDest impl?
98
virtual cups_dest_t* makeDest(const QString &name,
99
const PrinterJob *options);
101
virtual void cancelJob(const QString &name, const int jobId);
102
virtual int printFileToDest(const QString &filepath,
103
const QString &title,
104
const cups_dest_t *dest);
105
virtual QList<QSharedPointer<PrinterJob>> printerGetJobs();
106
virtual QMap<QString, QVariant> printerGetJobAttributes(
107
const QString &name, const int jobId);
109
virtual QString printerName() const;
110
virtual QString description() const;
111
virtual QString location() const;
112
virtual QString makeAndModel() const;
114
virtual PrinterEnum::State state() const;
115
virtual QList<QPageSize> supportedPageSizes() const;
116
virtual QPageSize defaultPageSize() const;
117
virtual bool supportsCustomPageSizes() const;
119
virtual QPageSize minimumPhysicalPageSize() const;
120
virtual QPageSize maximumPhysicalPageSize() const;
121
virtual QList<int> supportedResolutions() const;
122
virtual PrinterEnum::DuplexMode defaultDuplexMode() const;
123
virtual QList<PrinterEnum::DuplexMode> supportedDuplexModes() const;
125
virtual QList<QSharedPointer<Printer>> availablePrinters();
126
virtual QStringList availablePrinterNames();
127
virtual QSharedPointer<Printer> getPrinter(const QString &printerName);
128
virtual QString defaultPrinterName();
130
virtual void requestPrinterDrivers();
131
virtual void requestPrinter(const QString &printerName);
133
virtual PrinterEnum::PrinterType type() const;
135
virtual void setPrinterNameInternal(const QString &printerName);
138
virtual void refresh();
141
void printerDriversLoaded(const QList<PrinterDriver> &drivers);
142
void printerDriversFailedToLoad(const QString &errorMessage);
144
void printerLoaded(QSharedPointer<Printer> printers);
148
const QString &printerUri,
149
const QString &printerName,
151
const QString &printerStateReason,
155
const QString &jobStateReason,
156
const QString &job_name,
157
uint jobImpressionsCompleted
161
const QString &printerUri,
162
const QString &printerName,
164
const QString &printerStateReason,
168
const QString &jobStateReason,
169
const QString &job_name,
170
uint jobImpressionsCompleted
174
const QString &printerUri,
175
const QString &printerName,
177
const QString &printerStateReason,
181
const QString &jobStateReason,
182
const QString &job_name,
183
uint jobImpressionsCompleted
187
const QString &printerUri,
188
const QString &printerName,
190
const QString &printerStateReason,
195
const QString &printerUri,
196
const QString &printerName,
198
const QString &printerStateReason,
201
void printerModified(
203
const QString &printerUri,
204
const QString &printerName,
206
const QString &printerStateReason,
209
void printerStateChanged(
211
const QString &printerUri,
212
const QString &printerName,
214
const QString &printerStateReason,
219
QString m_printerName;
220
PrinterEnum::PrinterType m_type;
223
#endif // USC_PRINTERS_BACKEND_H