kdeprint Library API Documentation

kmcupsuimanager.cpp

00001 /*
00002  *  This file is part of the KDE libraries
00003  *  Copyright (c) 2001 Michael Goffioul <kdeprint@swing.be>
00004  *
00005  *  This library is free software; you can redistribute it and/or
00006  *  modify it under the terms of the GNU Library General Public
00007  *  License version 2 as published by the Free Software Foundation.
00008  *
00009  *  This library is distributed in the hope that it will be useful,
00010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012  *  Library General Public License for more details.
00013  *
00014  *  You should have received a copy of the GNU Library General Public License
00015  *  along with this library; see the file COPYING.LIB.  If not, write to
00016  *  the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00017  *  Boston, MA 02111-1307, USA.
00018  **/
00019 
00020 #include "kmcupsuimanager.h"
00021 #include "kmpropertypage.h"
00022 #include "kmwizard.h"
00023 #include "kmconfigdialog.h"
00024 #include "kmwbackend.h"
00025 #include "kmfactory.h"
00026 #include "kprinter.h"
00027 
00028 #include "kmpropbanners.h"
00029 #include "kmpropmembers.h"
00030 #include "kmpropbackend.h"
00031 #include "kmpropdriver.h"
00032 #include "kmwbanners.h"
00033 #include "kmwipp.h"
00034 #include "kmwippselect.h"
00035 #include "kmwippprinter.h"
00036 #include "kmconfigcups.h"
00037 #include "kmconfigcupsdir.h"
00038 #include "kmwfax.h"
00039 #include "kmwother.h"
00040 #include "kmwquota.h"
00041 #include "kmpropquota.h"
00042 #include "kmwusers.h"
00043 #include "kmpropusers.h"
00044 #include "kpschedulepage.h"
00045 #include "kptagspage.h"
00046 
00047 #include "kprinterpropertydialog.h"
00048 #include "kpgeneralpage.h"
00049 #include "kpimagepage.h"
00050 #include "kptextpage.h"
00051 #include "kphpgl2page.h"
00052 
00053 #include "ipprequest.h"
00054 #include "cupsinfos.h"
00055 
00056 #include <qlistview.h>
00057 #include <qwhatsthis.h>
00058 #include <klocale.h>
00059 #include <kdebug.h>
00060 #include <kaction.h>
00061 
00062 KMCupsUiManager::KMCupsUiManager(QObject *parent, const char *name, const QStringList & /*args*/)
00063 : KMUiManager(parent,name)
00064 {
00065 }
00066 
00067 KMCupsUiManager::~KMCupsUiManager()
00068 {
00069 }
00070 
00071 void KMCupsUiManager::setupPropertyPages(KMPropertyPage *p)
00072 {
00073     p->addPropPage(new KMPropMembers(p, "Members"));
00074     p->addPropPage(new KMPropBackend(p, "Backend"));
00075     p->addPropPage(new KMPropDriver(p, "Driver"));
00076     p->addPropPage(new KMPropBanners(p, "Banners"));
00077     p->addPropPage(new KMPropQuota(p, "Quotas"));
00078     p->addPropPage(new KMPropUsers(p, "Users"));
00079 }
00080 
00081 void KMCupsUiManager::setupWizard(KMWizard *wizard)
00082 {
00083     QString whatsThisLocalprinterBackend = i18n("<qt><p> </p>."
00084                             " </qt>" );
00085 
00086     QString whatsThisRemoteLPDBackend = i18n("<qt><p> </p>."
00087                             " </qt>" );
00088 
00089     QString whatsThisSMBSharedPrinterBackend = i18n("<qt><p> </p>."
00090                             " </qt>" );
00091 
00092     QString whatsThisNetworkprinterTCPBackend = i18n("<qt><p> </p>."
00093                             " </qt>" );
00094 
00095     QString whatsThisRemoteCUPSIPPBackend = i18n("<qt><p> </p>."
00096                             " </qt>" );
00097 
00098     QString whatsThisRemotePrinterIPPBackend = i18n("<qt><p> </p>."
00099                             " </qt>" );
00100 
00101     QString whatsThisSerialFaxModemBackend = i18n("<qt><p> </p>."
00102                             " </qt>" );
00103 
00104     QString whatsThisOtherPrintertypeBackend = i18n("<qt><p> </p>."
00105                             " </qt>" );
00106 
00107     QString whatsThisClassOfPrinters = i18n("<qt><p> </p>."
00108                             " </qt>" );
00109 
00110     QString whatsThis = i18n("<qt><p> </p>."
00111                             " </qt>" );
00112     KMWBackend  *backend = wizard->backendPage();
00113     if (!backend)
00114         return;
00115     backend->addBackend(KMWizard::Local,i18n("&Local printer (parallel, serial, USB)"),false);
00116     QWhatsThis::add(backend, whatsThisLocalprinterBackend);
00117     backend->addBackend(KMWizard::LPD,i18n("&Remote LPD queue"),false);
00118     QWhatsThis::add(backend, whatsThisRemoteLPDBackend);
00119     backend->addBackend(KMWizard::SMB,i18n("&SMB shared printer (Windows)"),false,KMWizard::Password);
00120     QWhatsThis::add(backend, whatsThisSMBSharedPrinterBackend);
00121     backend->addBackend(KMWizard::TCP,i18n("Ne&twork printer (TCP)"),false);
00122     QWhatsThis::add(backend, whatsThisNetworkprinterTCPBackend);
00123     backend->addBackend(KMWizard::IPP,i18n("Re&mote CUPS server (IPP/HTTP)"),false,KMWizard::Password);
00124     QWhatsThis::add(backend, whatsThisRemoteCUPSIPPBackend);
00125     backend->addBackend(KMWizard::Custom+1,i18n("Network printer w/&IPP (IPP/HTTP)"),false);
00126     QWhatsThis::add(backend, whatsThisRemotePrinterIPPBackend);
00127     backend->addBackend(KMWizard::Custom+2,i18n("S&erial Fax/Modem printer"),false);
00128     QWhatsThis::add(backend, whatsThisSerialFaxModemBackend);
00129     backend->addBackend(KMWizard::Custom+5,i18n("Other &printer type"),false);
00130     QWhatsThis::add(backend, whatsThisOtherPrintertypeBackend);
00131     backend->addBackend();
00132     QWhatsThis::add(backend, whatsThis);
00133     backend->addBackend(KMWizard::Class,i18n("Cl&ass of printers"),false);
00134     QWhatsThis::add(backend, whatsThisClassOfPrinters);
00135 
00136     IppRequest  req;
00137     QString     uri;
00138 
00139     req.setOperation(CUPS_GET_DEVICES);
00140     uri = QString::fromLocal8Bit("ipp://%1:%2/printers/").arg(CupsInfos::self()->host()).arg(CupsInfos::self()->port());
00141     req.addURI(IPP_TAG_OPERATION,"printer-uri",uri);
00142 
00143     if (req.doRequest("/"))
00144     {
00145         ipp_attribute_t *attr = req.first();
00146         while (attr)
00147         {
00148             if (attr->name && strcmp(attr->name,"device-uri") == 0)
00149             {
00150                 if (strncmp(attr->values[0].string.text,"socket",6) == 0) backend->enableBackend(KMWizard::TCP,true);
00151                 else if (strncmp(attr->values[0].string.text,"parallel",8) == 0) backend->enableBackend(KMWizard::Local,true);
00152                 else if (strncmp(attr->values[0].string.text,"serial",6) == 0) backend->enableBackend(KMWizard::Local,true);
00153                 else if (strncmp(attr->values[0].string.text,"smb",3) == 0) backend->enableBackend(KMWizard::SMB,true);
00154                 else if (strncmp(attr->values[0].string.text,"lpd",3) == 0) backend->enableBackend(KMWizard::LPD,true);
00155                 else if (strncmp(attr->values[0].string.text,"usb",3) == 0) backend->enableBackend(KMWizard::Local,true);
00156                 else if (strncmp(attr->values[0].string.text,"http",4) == 0 || strncmp(attr->values[0].string.text,"ipp",3) == 0)
00157                 {
00158                     backend->enableBackend(KMWizard::IPP,true);
00159                     backend->enableBackend(KMWizard::Custom+1,true);
00160                 }
00161                 else if (strncmp(attr->values[0].string.text,"fax",3) == 0) backend->enableBackend(KMWizard::Custom+2,true);
00162             }
00163             attr = attr->next;
00164         }
00165         backend->enableBackend(KMWizard::Class, true);
00166         backend->enableBackend(KMWizard::Custom+5, true);
00167     }
00168 
00169     // banners page
00170     wizard->addPage(new KMWBanners(wizard));
00171     wizard->setNextPage(KMWizard::DriverTest,KMWizard::Banners);
00172     wizard->addPage(new KMWIpp(wizard));
00173     wizard->addPage(new KMWIppSelect(wizard));
00174     wizard->addPage(new KMWIppPrinter(wizard));
00175     wizard->addPage(new KMWFax(wizard));
00176     wizard->addPage(new KMWQuota(wizard));
00177     wizard->addPage(new KMWUsers(wizard));
00178     wizard->addPage(new KMWOther(wizard));
00179 }
00180 
00181 void KMCupsUiManager::setupPrinterPropertyDialog(KPrinterPropertyDialog *dlg)
00182 {
00183     // add general page
00184     dlg->addPage(new KPGeneralPage(dlg->printer(),dlg->driver(),dlg,"GeneralPage"));
00185     if (KMFactory::self()->settings()->application != KPrinter::Dialog)
00186     {
00187         dlg->addPage(new KPImagePage(dlg->driver(), dlg, "ImagePage"));
00188         dlg->addPage(new KPTextPage(dlg->driver(), dlg, "TextPage"));
00189         dlg->addPage(new KPHpgl2Page(dlg, "Hpgl2Page"));
00190     }
00191 }
00192 
00193 void KMCupsUiManager::setupConfigDialog(KMConfigDialog *dlg)
00194 {
00195     dlg->addConfigPage(new KMConfigCups(dlg));
00196     dlg->addConfigPage(new KMConfigCupsDir(dlg));
00197 }
00198 
00199 int KMCupsUiManager::pluginPageCap()
00200 {
00201     return (KMUiManager::CopyAll & ~KMUiManager::Current);
00202 }
00203 
00204 void KMCupsUiManager::setupPrintDialogPages(QPtrList<KPrintDialogPage>* pages)
00205 {
00206     pages->append(new KPSchedulePage());
00207     pages->append(new KPTagsPage());
00208 }
00209 
00210 void KMCupsUiManager::setupJobViewer(QListView *lv)
00211 {
00212     lv->addColumn(i18n("Priority"));
00213     lv->setColumnAlignment(lv->columns()-1, Qt::AlignRight|Qt::AlignVCenter);
00214     lv->addColumn(i18n("Billing Information"));
00215     lv->setColumnAlignment(lv->columns()-1, Qt::AlignRight|Qt::AlignVCenter);
00216 }
KDE Logo
This file is part of the documentation for kdeprint Library Version 3.2.3.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Aug 4 05:27:58 2004 by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2003