20 #include "kmcupsuimanager.h"
21 #include "kmpropertypage.h"
23 #include "kmconfigdialog.h"
24 #include "kmwbackend.h"
25 #include "kmfactory.h"
28 #include "kmpropbanners.h"
29 #include "kmpropmembers.h"
30 #include "kmpropbackend.h"
31 #include "kmpropdriver.h"
32 #include "kmwbanners.h"
34 #include "kmwippselect.h"
35 #include "kmwippprinter.h"
36 #include "kmconfigcups.h"
37 #include "kmconfigcupsdir.h"
41 #include "kmpropquota.h"
43 #include "kmpropusers.h"
44 #include "kpschedulepage.h"
45 #include "kptagspage.h"
47 #include "kprinterpropertydialog.h"
48 #include "kpgeneralpage.h"
49 #include "kpimagepage.h"
50 #include "kptextpage.h"
51 #include "kphpgl2page.h"
53 #include "ipprequest.h"
54 #include "cupsinfos.h"
56 #include <tqlistview.h>
57 #include <tqwhatsthis.h>
58 #include <tdelocale.h>
60 #include <tdeaction.h>
61 #include <tdemessagebox.h>
65 KMCupsUiManager::KMCupsUiManager(TQObject *parent,
const char *name,
const TQStringList & )
66 : KMUiManager(parent,name)
70 KMCupsUiManager::~KMCupsUiManager()
74 void KMCupsUiManager::setupPropertyPages(KMPropertyPage *p)
76 p->addPropPage(
new KMPropMembers(p,
"Members"));
77 p->addPropPage(
new KMPropBackend(p,
"Backend"));
78 p->addPropPage(
new KMPropDriver(p,
"Driver"));
79 p->addPropPage(
new KMPropBanners(p,
"Banners"));
80 p->addPropPage(
new KMPropQuota(p,
"Quotas"));
81 p->addPropPage(
new KMPropUsers(p,
"Users"));
84 void KMCupsUiManager::setupWizard(KMWizard *wizard)
86 TQString whatsThisRemoteCUPSIPPBackend =
87 i18n(
"<qt><p>Print queue on remote CUPS server</p>"
88 "<p>Use this for a print queue installed on a remote "
89 "machine running a CUPS server. This allows to use "
90 "remote printers when CUPS browsing is turned off.</p></qt>"
93 TQString whatsThisRemotePrinterIPPBackend =
94 i18n(
"<qt><p>Network IPP printer</p>"
95 "<p>Use this for a network-enabled printer using the "
96 "IPP protocol. Modern high-end printers can use this mode. "
97 "Use this mode instead of TCP if your printer can do both.</p></qt>"
100 TQString whatsThisSerialFaxModemBackend =
101 i18n(
"<qt><p>Fax/Modem printer</p>"
102 "<p>Use this for a fax/modem printer. This requires the installation "
103 "of the <a href=\"http://vigna.dsi.unimi.it/fax4CUPS/\">fax4CUPS</a> backend. Documents sent on this printer will be faxed "
104 "to the given target fax number.</p></qt>"
107 TQString whatsThisOtherPrintertypeBackend =
108 i18n(
"<qt><p>Other printer</p>"
109 "<p>Use this for any printer type. To use this option, you must know "
110 "the URI of the printer you want to install. Refer to the CUPS documentation "
111 "for more information about the printer URI. This option is mainly useful for "
112 "printer types using 3rd party backends not covered by the other possibilities.</p></qt>"
115 TQString whatsThisClassOfPrinters =
116 i18n(
"<qt><p>Class of printers</p>"
117 "<p>Use this to create a class of printers. When sending a document to a class, "
118 "the document is actually sent to the first available (idle) printer in the class. "
119 "Refer to the CUPS documentation for more information about class of printers.</p></qt>"
122 KMWBackend *backend = wizard->backendPage();
125 backend->addBackend(KMWizard::Local,
false);
126 backend->addBackend(KMWizard::LPD,
false);
127 backend->addBackend(KMWizard::SMB,
false,KMWizard::Password);
128 backend->addBackend(KMWizard::TCP,
false);
129 backend->addBackend(KMWizard::IPP,i18n(
"Re&mote CUPS server (IPP/HTTP)"),
false,whatsThisRemoteCUPSIPPBackend,KMWizard::Password);
130 backend->addBackend(KMWizard::Custom+1,i18n(
"Network printer w/&IPP (IPP/HTTP)"),
false,whatsThisRemotePrinterIPPBackend);
131 backend->addBackend(KMWizard::Custom+2,i18n(
"S&erial Fax/Modem printer"),
false,whatsThisSerialFaxModemBackend);
132 backend->addBackend(KMWizard::Custom+5,i18n(
"Other &printer type"),
false,whatsThisOtherPrintertypeBackend);
133 backend->addBackend();
134 backend->addBackend(KMWizard::Class,i18n(
"Cl&ass of printers"),
false,whatsThisClassOfPrinters);
139 req.setOperation(CUPS_GET_DEVICES);
140 uri = TQString::fromLocal8Bit(
"ipp://%1/printers/").arg(CupsInfos::self()->hostaddr());
141 req.addURI(IPP_TAG_OPERATION,
"printer-uri",uri);
143 if (req.doRequest(
"/"))
145 ipp_attribute_t *attr = req.first();
149 if (ippGetName(attr) && strcmp(ippGetName(attr),
"device-uri") == 0)
151 if (strncmp(ippGetString(attr, 0, NULL),
"socket",6) == 0) backend->enableBackend(KMWizard::TCP,
true);
152 else if (strncmp(ippGetString(attr, 0, NULL),
"parallel",8) == 0) backend->enableBackend(KMWizard::Local,
true);
153 else if (strncmp(ippGetString(attr, 0, NULL),
"serial",6) == 0) backend->enableBackend(KMWizard::Local,
true);
154 else if (strncmp(ippGetString(attr, 0, NULL),
"smb",3) == 0) backend->enableBackend(KMWizard::SMB,
true);
155 else if (strncmp(ippGetString(attr, 0, NULL),
"lpd",3) == 0) backend->enableBackend(KMWizard::LPD,
true);
156 else if (strncmp(ippGetString(attr, 0, NULL),
"usb",3) == 0) backend->enableBackend(KMWizard::Local,
true);
157 else if (strncmp(ippGetString(attr, 0, NULL),
"http",4) == 0 || strncmp(ippGetString(attr, 0, NULL),
"ipp",3) == 0)
159 backend->enableBackend(KMWizard::IPP,
true);
160 backend->enableBackend(KMWizard::Custom+1,
true);
162 else if (strncmp(ippGetString(attr, 0, NULL),
"fax",3) == 0) backend->enableBackend(KMWizard::Custom+2,
true);
164 attr = ippNextAttribute(req.request());
166 if (attr->name && strcmp(attr->name,
"device-uri") == 0)
168 if (strncmp(attr->values[0].string.text,
"socket",6) == 0) backend->enableBackend(KMWizard::TCP,
true);
169 else if (strncmp(attr->values[0].string.text,
"parallel",8) == 0) backend->enableBackend(KMWizard::Local,
true);
170 else if (strncmp(attr->values[0].string.text,
"serial",6) == 0) backend->enableBackend(KMWizard::Local,
true);
171 else if (strncmp(attr->values[0].string.text,
"smb",3) == 0) backend->enableBackend(KMWizard::SMB,
true);
172 else if (strncmp(attr->values[0].string.text,
"lpd",3) == 0) backend->enableBackend(KMWizard::LPD,
true);
173 else if (strncmp(attr->values[0].string.text,
"usb",3) == 0) backend->enableBackend(KMWizard::Local,
true);
174 else if (strncmp(attr->values[0].string.text,
"http",4) == 0 || strncmp(attr->values[0].string.text,
"ipp",3) == 0)
176 backend->enableBackend(KMWizard::IPP,
true);
177 backend->enableBackend(KMWizard::Custom+1,
true);
179 else if (strncmp(attr->values[0].string.text,
"fax",3) == 0) backend->enableBackend(KMWizard::Custom+2,
true);
184 backend->enableBackend(KMWizard::Class,
true);
185 backend->enableBackend(KMWizard::Custom+5,
true);
188 KMessageBox::error(wizard,
190 i18n(
"An error occurred while retrieving the list of available backends:") +
191 "</nobr><br><br>" + req.statusMessage() +
"</qt>");
194 wizard->addPage(
new KMWBanners(wizard));
195 wizard->setNextPage(KMWizard::DriverTest,KMWizard::Banners);
196 wizard->addPage(
new KMWIpp(wizard));
197 wizard->addPage(
new KMWIppSelect(wizard));
198 wizard->addPage(
new KMWIppPrinter(wizard));
199 wizard->addPage(
new KMWFax(wizard));
200 wizard->addPage(
new KMWQuota(wizard));
201 wizard->addPage(
new KMWUsers(wizard));
202 wizard->addPage(
new KMWOther(wizard));
205 void KMCupsUiManager::setupPrinterPropertyDialog(KPrinterPropertyDialog *dlg)
208 dlg->addPage(
new KPGeneralPage(dlg->printer(),dlg->driver(),dlg,
"GeneralPage"));
209 if (KMFactory::self()->settings()->application != KPrinter::Dialog)
211 dlg->addPage(
new KPImagePage(dlg->driver(), dlg,
"ImagePage"));
212 dlg->addPage(
new KPTextPage(dlg->driver(), dlg,
"TextPage"));
213 dlg->addPage(
new KPHpgl2Page(dlg,
"Hpgl2Page"));
217 void KMCupsUiManager::setupConfigDialog(KMConfigDialog *dlg)
219 dlg->addConfigPage(
new KMConfigCups(dlg));
220 dlg->addConfigPage(
new KMConfigCupsDir(dlg));
223 int KMCupsUiManager::pluginPageCap()
225 return (KMUiManager::CopyAll & ~KMUiManager::Current);
228 void KMCupsUiManager::setupPrintDialogPages(TQPtrList<KPrintDialogPage>* pages)
230 pages->append(
new KPSchedulePage());
231 pages->append(
new KPTagsPage());
234 void KMCupsUiManager::setupJobViewer(TQListView *lv)
236 lv->addColumn(i18n(
"Priority"));
237 lv->setColumnAlignment(lv->columns()-1, TQt::AlignRight|TQt::AlignVCenter);
238 lv->addColumn(i18n(
"Billing Information"));
239 lv->setColumnAlignment(lv->columns()-1, TQt::AlignRight|TQt::AlignVCenter);