• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • tdeprint
 

tdeprint

  • tdeprint
  • cups
kmcupsuimanager.cpp
1 /*
2  * This file is part of the KDE libraries
3  * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Library General Public
7  * License version 2 as published by the Free Software Foundation.
8  *
9  * This library 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 GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public License
15  * along with this library; see the file COPYING.LIB. If not, write to
16  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17  * Boston, MA 02110-1301, USA.
18  **/
19 
20 #include "kmcupsuimanager.h"
21 #include "kmpropertypage.h"
22 #include "kmwizard.h"
23 #include "kmconfigdialog.h"
24 #include "kmwbackend.h"
25 #include "kmfactory.h"
26 #include "kprinter.h"
27 
28 #include "kmpropbanners.h"
29 #include "kmpropmembers.h"
30 #include "kmpropbackend.h"
31 #include "kmpropdriver.h"
32 #include "kmwbanners.h"
33 #include "kmwipp.h"
34 #include "kmwippselect.h"
35 #include "kmwippprinter.h"
36 #include "kmconfigcups.h"
37 #include "kmconfigcupsdir.h"
38 #include "kmwfax.h"
39 #include "kmwother.h"
40 #include "kmwquota.h"
41 #include "kmpropquota.h"
42 #include "kmwusers.h"
43 #include "kmpropusers.h"
44 #include "kpschedulepage.h"
45 #include "kptagspage.h"
46 
47 #include "kprinterpropertydialog.h"
48 #include "kpgeneralpage.h"
49 #include "kpimagepage.h"
50 #include "kptextpage.h"
51 #include "kphpgl2page.h"
52 
53 #include "ipprequest.h"
54 #include "cupsinfos.h"
55 
56 #include <tqlistview.h>
57 #include <tqwhatsthis.h>
58 #include <tdelocale.h>
59 #include <kdebug.h>
60 #include <tdeaction.h>
61 #include <tdemessagebox.h>
62 
63 #include "config.h"
64 
65 KMCupsUiManager::KMCupsUiManager(TQObject *parent, const char *name, const TQStringList & /*args*/)
66 : KMUiManager(parent,name)
67 {
68 }
69 
70 KMCupsUiManager::~KMCupsUiManager()
71 {
72 }
73 
74 void KMCupsUiManager::setupPropertyPages(KMPropertyPage *p)
75 {
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"));
82 }
83 
84 void KMCupsUiManager::setupWizard(KMWizard *wizard)
85 {
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>"
91  );
92 
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>"
98  );
99 
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>"
105  );
106 
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>"
113  );
114 
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>"
120  );
121 
122  KMWBackend *backend = wizard->backendPage();
123  if (!backend)
124  return;
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);
135 
136  IppRequest req;
137  QString uri;
138 
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);
142 
143  if (req.doRequest("/"))
144  {
145  ipp_attribute_t *attr = req.first();
146  while (attr)
147  {
148 #ifdef HAVE_CUPS_1_6
149  if (ippGetName(attr) && strcmp(ippGetName(attr),"device-uri") == 0)
150  {
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)
158  {
159  backend->enableBackend(KMWizard::IPP,true);
160  backend->enableBackend(KMWizard::Custom+1,true);
161  }
162  else if (strncmp(ippGetString(attr, 0, NULL),"fax",3) == 0) backend->enableBackend(KMWizard::Custom+2,true);
163  }
164  attr = ippNextAttribute(req.request());
165 #else // HAVE_CUPS_1_6
166  if (attr->name && strcmp(attr->name,"device-uri") == 0)
167  {
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)
175  {
176  backend->enableBackend(KMWizard::IPP,true);
177  backend->enableBackend(KMWizard::Custom+1,true);
178  }
179  else if (strncmp(attr->values[0].string.text,"fax",3) == 0) backend->enableBackend(KMWizard::Custom+2,true);
180  }
181  attr = attr->next;
182 #endif // HAVE_CUPS_1_6
183  }
184  backend->enableBackend(KMWizard::Class, true);
185  backend->enableBackend(KMWizard::Custom+5, true);
186  }
187  else
188  KMessageBox::error(wizard,
189  "<qt><nobr>" +
190  i18n("An error occurred while retrieving the list of available backends:") +
191  "</nobr><br><br>" + req.statusMessage() + "</qt>");
192 
193  // banners page
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));
203 }
204 
205 void KMCupsUiManager::setupPrinterPropertyDialog(KPrinterPropertyDialog *dlg)
206 {
207  // add general page
208  dlg->addPage(new KPGeneralPage(dlg->printer(),dlg->driver(),dlg,"GeneralPage"));
209  if (KMFactory::self()->settings()->application != KPrinter::Dialog)
210  {
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"));
214  }
215 }
216 
217 void KMCupsUiManager::setupConfigDialog(KMConfigDialog *dlg)
218 {
219  dlg->addConfigPage(new KMConfigCups(dlg));
220  dlg->addConfigPage(new KMConfigCupsDir(dlg));
221 }
222 
223 int KMCupsUiManager::pluginPageCap()
224 {
225  return (KMUiManager::CopyAll & ~KMUiManager::Current);
226 }
227 
228 void KMCupsUiManager::setupPrintDialogPages(TQPtrList<KPrintDialogPage>* pages)
229 {
230  pages->append(new KPSchedulePage());
231  pages->append(new KPTagsPage());
232 }
233 
234 void KMCupsUiManager::setupJobViewer(TQListView *lv)
235 {
236  lv->addColumn(i18n("Priority"));
237  lv->setColumnAlignment(lv->columns()-1, Qt::AlignRight|Qt::AlignVCenter);
238  lv->addColumn(i18n("Billing Information"));
239  lv->setColumnAlignment(lv->columns()-1, Qt::AlignRight|Qt::AlignVCenter);
240 }

tdeprint

Skip menu "tdeprint"
  • Main Page
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Class Members
  • Related Pages

tdeprint

Skip menu "tdeprint"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  •     tdecore
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  • tdeioslave
  •   http
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tdeprint by doxygen 1.8.8
This website is maintained by Timothy Pearson.