File indexing completed on 2025-01-05 05:09:30
0001 /* 0002 SPDX-FileCopyrightText: 2010-2012 Daniel Nicoletti <dantti12@gmail.com> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #include "KCupsServer.h" 0008 0009 #include <cups/adminutil.h> 0010 #include <cups/cups.h> 0011 0012 #include <config.h> 0013 0014 KCupsServer::KCupsServer() 0015 { 0016 } 0017 0018 KCupsServer::KCupsServer(const QVariantMap &arguments) 0019 : m_arguments(arguments) 0020 { 0021 } 0022 0023 bool KCupsServer::allowRemoteAdmin() const 0024 { 0025 return m_arguments[QLatin1String(CUPS_SERVER_REMOTE_ADMIN)].toBool(); 0026 } 0027 0028 void KCupsServer::setAllowRemoteAdmin(bool allow) 0029 { 0030 m_arguments[QLatin1String(CUPS_SERVER_REMOTE_ADMIN)] = allow ? QLatin1String("1") : QLatin1String("0"); 0031 } 0032 0033 bool KCupsServer::allowUserCancelAnyJobs() const 0034 { 0035 return m_arguments[QLatin1String(CUPS_SERVER_USER_CANCEL_ANY)].toBool(); 0036 } 0037 0038 void KCupsServer::setAllowUserCancelAnyJobs(bool allow) 0039 { 0040 m_arguments[QLatin1String(CUPS_SERVER_USER_CANCEL_ANY)] = allow ? QLatin1String("1") : QLatin1String("0"); 0041 } 0042 0043 bool KCupsServer::showSharedPrinters() const 0044 { 0045 #if CUPS_VERSION_MAJOR == 1 && CUPS_VERSION_MINOR < 6 0046 return m_arguments.value(CUPS_SERVER_REMOTE_PRINTERS).toBool(); 0047 #else 0048 return false; 0049 #endif 0050 } 0051 0052 void KCupsServer::setShowSharedPrinters(bool show) 0053 { 0054 #if CUPS_VERSION_MAJOR == 1 && CUPS_VERSION_MINOR < 6 0055 m_arguments[CUPS_SERVER_REMOTE_PRINTERS] = show ? QLatin1String("1") : QLatin1String("0"); 0056 #else 0057 Q_UNUSED(show) 0058 #endif // CUPS_VERSION_MAJOR == 1 && CUPS_VERSION_MINOR < 6 0059 } 0060 0061 bool KCupsServer::sharePrinters() const 0062 { 0063 return m_arguments[QLatin1String(CUPS_SERVER_SHARE_PRINTERS)].toBool(); 0064 } 0065 0066 void KCupsServer::setSharePrinters(bool share) 0067 { 0068 m_arguments[QLatin1String(CUPS_SERVER_SHARE_PRINTERS)] = share ? QLatin1String("1") : QLatin1String("0"); 0069 } 0070 0071 bool KCupsServer::allowPrintingFromInternet() const 0072 { 0073 return m_arguments[QLatin1String(CUPS_SERVER_REMOTE_ANY)].toBool(); 0074 } 0075 0076 void KCupsServer::setAllowPrintingFromInternet(bool allow) 0077 { 0078 m_arguments[QLatin1String(CUPS_SERVER_REMOTE_ANY)] = allow ? QLatin1String("1") : QLatin1String("0"); 0079 } 0080 0081 QVariantMap KCupsServer::arguments() const 0082 { 0083 return m_arguments; 0084 }