File indexing completed on 2025-01-05 05:09:28
0001 /** 0002 * SPDX-FileCopyrightText: 2010-2018 Daniel Nicoletti <dantti12@gmail.com> 0003 * SPDX-FileCopyrightText: 2022 Nicolas Fella <nicolas.fella@gmx.de> 0004 * SPDX-FileCopyrightText: 2023 Mike Noe <noeerover@gmail.com> 0005 * SPDX-License-Identifier: GPL-2.0-or-later 0006 */ 0007 0008 #ifndef PRINTERMANAGER_H 0009 #define PRINTERMANAGER_H 0010 0011 #include <KQuickConfigModule> 0012 #include <QDBusMessage> 0013 #include <QObject> 0014 0015 namespace PMTypes 0016 { 0017 Q_NAMESPACE 0018 enum PPDType { Manual = 0, Auto, Custom }; 0019 Q_ENUM_NS(PPDType) 0020 } 0021 0022 class KCupsRequest; 0023 0024 class PrinterManager : public KQuickConfigModule 0025 { 0026 Q_OBJECT 0027 0028 Q_PROPERTY(QVariantList remotePrinters READ remotePrinters NOTIFY remotePrintersLoaded) 0029 0030 Q_PROPERTY(QVariantList recommendedDrivers READ recommendedDrivers NOTIFY recommendedDriversLoaded) 0031 0032 Q_PROPERTY(QVariantMap serverSettings READ serverSettings NOTIFY serverSettingsChanged) 0033 0034 Q_PROPERTY(bool serverSettingsLoaded READ serverSettingsLoaded NOTIFY serverSettingsChanged) 0035 0036 Q_PROPERTY(bool shareConnectedPrinters READ shareConnectedPrinters NOTIFY serverSettingsChanged) 0037 0038 Q_PROPERTY(bool allowPrintingFromInternet READ allowPrintingFromInternet NOTIFY serverSettingsChanged) 0039 0040 Q_PROPERTY(bool allowRemoteAdmin READ allowRemoteAdmin NOTIFY serverSettingsChanged) 0041 0042 Q_PROPERTY(bool allowUserCancelAnyJobs READ allowUserCancelAnyJobs NOTIFY serverSettingsChanged) 0043 0044 public: 0045 PrinterManager(QObject *parent, const KPluginMetaData &metaData); 0046 0047 Q_INVOKABLE void removePrinter(const QString &name); 0048 0049 Q_INVOKABLE void makePrinterDefault(const QString &name); 0050 Q_INVOKABLE void makePrinterShared(const QString &name, bool shared, bool isClass); 0051 Q_INVOKABLE void makePrinterRejectJobs(const QString &name, bool reject); 0052 0053 Q_INVOKABLE void printTestPage(const QString &name, bool isClass); 0054 Q_INVOKABLE void printSelfTestPage(const QString &name); 0055 Q_INVOKABLE void cleanPrintHeads(const QString &name); 0056 0057 Q_INVOKABLE void pausePrinter(const QString &name); 0058 Q_INVOKABLE void resumePrinter(const QString &name); 0059 0060 bool shareConnectedPrinters() const; 0061 bool allowPrintingFromInternet() const; 0062 bool allowRemoteAdmin() const; 0063 bool allowUserCancelAnyJobs() const; 0064 0065 public Q_SLOTS: 0066 void savePrinter(const QString &name, const QVariantMap &saveArgs, bool isClass); 0067 QVariantMap getPrinterPPD(const QString &name); 0068 void getServerSettings(); 0069 void saveServerSettings(const QVariantMap &settings); 0070 0071 void getRemotePrinters(const QString &uri, const QString &uriScheme); 0072 void getRecommendedDrivers(const QString &deviceId, const QString &makeAndModel, const QString &deviceUri); 0073 void clearRemotePrinters(); 0074 void clearRecommendedDrivers(); 0075 0076 Q_SIGNALS: 0077 void requestError(const QString &errorMessage); 0078 void removeDone(); 0079 void saveDone(); 0080 void serverSettingsChanged(); 0081 void remotePrintersLoaded(); 0082 void recommendedDriversLoaded(); 0083 0084 private Q_SLOTS: 0085 void getDriversFinished(const QDBusMessage &message); 0086 void getDriversFailed(const QDBusError &error, const QDBusMessage &message); 0087 0088 private: 0089 KCupsRequest *setupRequest(std::function<void()> finished = []() {}); 0090 QVariantList remotePrinters() const; 0091 QVariantList recommendedDrivers() const; 0092 QVariantMap serverSettings() const; 0093 bool serverSettingsLoaded() const; 0094 void serverEvent(const QString &event, bool reload, const QString &msg = QString()); 0095 0096 QVariantMap m_serverSettings; 0097 bool m_serverSettingsLoaded = false; 0098 QVariantList m_remotePrinters; 0099 QVariantList m_recommendedDrivers; 0100 }; 0101 0102 #endif