00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
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 & )
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 whatsThisRemoteCUPSIPPBackend =
00084 i18n(
"<qt><p>Print queue on remote CUPS server</p>"
00085
"<p>Use this for a print queue installed on a remote "
00086
"machine running a CUPS server. This allows to use "
00087
"remote printers when CUPS browsing is turned off.</p></qt>"
00088 );
00089
00090
QString whatsThisRemotePrinterIPPBackend =
00091 i18n(
"<qt><p>Network IPP printer</p>"
00092
"<p>Use this for a network-enabled printer using the "
00093
"IPP protocol. Modern high-end printers can use this mode. "
00094
"Use this mode instead of TCP if your printer can do both.</p></qt>"
00095 );
00096
00097
QString whatsThisSerialFaxModemBackend =
00098 i18n(
"<qt><p>Fax/Modem printer</p>"
00099
"<p>Use this for a fax/modem printer. This requires the installation "
00100
"of the <a href=\"http://vigna.dsi.unimi.it/fax4CUPS/\">fax4CUPS</a> backend. Documents sent on this printer will be faxed "
00101
"to the given target fax number.</p></qt>"
00102 );
00103
00104
QString whatsThisOtherPrintertypeBackend =
00105 i18n(
"<qt><p>Other printer</p>"
00106
"<p>Use this for any printer type. To use this option, you must know "
00107
"the URI of the printer you want to install. Refer to the CUPS documentation "
00108
"for more information about the printer URI. This option is mainly useful for "
00109
"printer types using 3rd party backends not covered by the other possibilities.</p></qt>"
00110 );
00111
00112
QString whatsThisClassOfPrinters =
00113 i18n(
"<qt><p>Class of printers</p>"
00114
"<p>Use this to create a class of printers. When sending a document to a class, "
00115
"the document is actually sent to the first available (idle) printer in the class. "
00116
"Refer to the CUPS documentation for more information about class of printers.</p></qt>"
00117 );
00118
00119 KMWBackend *backend = wizard->backendPage();
00120
if (!backend)
00121
return;
00122 backend->addBackend(KMWizard::Local,
false);
00123 backend->addBackend(KMWizard::LPD,
false);
00124 backend->addBackend(KMWizard::SMB,
false,KMWizard::Password);
00125 backend->addBackend(KMWizard::TCP,
false);
00126 backend->addBackend(KMWizard::IPP,i18n(
"Re&mote CUPS server (IPP/HTTP)"),
false,whatsThisRemoteCUPSIPPBackend,KMWizard::Password);
00127 backend->addBackend(KMWizard::Custom+1,i18n(
"Network printer w/&IPP (IPP/HTTP)"),
false,whatsThisRemotePrinterIPPBackend);
00128 backend->addBackend(KMWizard::Custom+2,i18n(
"S&erial Fax/Modem printer"),
false,whatsThisSerialFaxModemBackend);
00129 backend->addBackend(KMWizard::Custom+5,i18n(
"Other &printer type"),
false,whatsThisOtherPrintertypeBackend);
00130 backend->addBackend();
00131 backend->addBackend(KMWizard::Class,i18n(
"Cl&ass of printers"),
false,whatsThisClassOfPrinters);
00132
00133 IppRequest req;
00134
QString uri;
00135
00136 req.setOperation(CUPS_GET_DEVICES);
00137 uri = QString::fromLocal8Bit(
"ipp://%1:%2/printers/").arg(CupsInfos::self()->host()).arg(CupsInfos::self()->port());
00138 req.addURI(IPP_TAG_OPERATION,
"printer-uri",uri);
00139
00140
if (req.doRequest(
"/"))
00141 {
00142 ipp_attribute_t *attr = req.first();
00143
while (attr)
00144 {
00145
if (attr->name && strcmp(attr->name,
"device-uri") == 0)
00146 {
00147
if (strncmp(attr->values[0].string.text,
"socket",6) == 0) backend->enableBackend(KMWizard::TCP,
true);
00148
else if (strncmp(attr->values[0].string.text,
"parallel",8) == 0) backend->enableBackend(KMWizard::Local,
true);
00149
else if (strncmp(attr->values[0].string.text,
"serial",6) == 0) backend->enableBackend(KMWizard::Local,
true);
00150
else if (strncmp(attr->values[0].string.text,
"smb",3) == 0) backend->enableBackend(KMWizard::SMB,
true);
00151
else if (strncmp(attr->values[0].string.text,
"lpd",3) == 0) backend->enableBackend(KMWizard::LPD,
true);
00152
else if (strncmp(attr->values[0].string.text,
"usb",3) == 0) backend->enableBackend(KMWizard::Local,
true);
00153
else if (strncmp(attr->values[0].string.text,
"http",4) == 0 || strncmp(attr->values[0].string.text,
"ipp",3) == 0)
00154 {
00155 backend->enableBackend(KMWizard::IPP,
true);
00156 backend->enableBackend(KMWizard::Custom+1,
true);
00157 }
00158
else if (strncmp(attr->values[0].string.text,
"fax",3) == 0) backend->enableBackend(KMWizard::Custom+2,
true);
00159 }
00160 attr = attr->next;
00161 }
00162 backend->enableBackend(KMWizard::Class,
true);
00163 backend->enableBackend(KMWizard::Custom+5,
true);
00164 }
00165
00166
00167 wizard->addPage(
new KMWBanners(wizard));
00168 wizard->setNextPage(KMWizard::DriverTest,KMWizard::Banners);
00169 wizard->addPage(
new KMWIpp(wizard));
00170 wizard->addPage(
new KMWIppSelect(wizard));
00171 wizard->addPage(
new KMWIppPrinter(wizard));
00172 wizard->addPage(
new KMWFax(wizard));
00173 wizard->addPage(
new KMWQuota(wizard));
00174 wizard->addPage(
new KMWUsers(wizard));
00175 wizard->addPage(
new KMWOther(wizard));
00176 }
00177
00178
void KMCupsUiManager::setupPrinterPropertyDialog(KPrinterPropertyDialog *dlg)
00179 {
00180
00181 dlg->addPage(
new KPGeneralPage(dlg->printer(),dlg->driver(),dlg,
"GeneralPage"));
00182
if (KMFactory::self()->settings()->application != KPrinter::Dialog)
00183 {
00184 dlg->addPage(
new KPImagePage(dlg->driver(), dlg,
"ImagePage"));
00185 dlg->addPage(
new KPTextPage(dlg->driver(), dlg,
"TextPage"));
00186 dlg->addPage(
new KPHpgl2Page(dlg,
"Hpgl2Page"));
00187 }
00188 }
00189
00190
void KMCupsUiManager::setupConfigDialog(KMConfigDialog *dlg)
00191 {
00192 dlg->addConfigPage(
new KMConfigCups(dlg));
00193 dlg->addConfigPage(
new KMConfigCupsDir(dlg));
00194 }
00195
00196
int KMCupsUiManager::pluginPageCap()
00197 {
00198
return (KMUiManager::CopyAll & ~KMUiManager::Current);
00199 }
00200
00201
void KMCupsUiManager::setupPrintDialogPages(
QPtrList<KPrintDialogPage>* pages)
00202 {
00203 pages->append(
new KPSchedulePage());
00204 pages->append(
new KPTagsPage());
00205 }
00206
00207
void KMCupsUiManager::setupJobViewer(
QListView *lv)
00208 {
00209 lv->addColumn(i18n(
"Priority"));
00210 lv->setColumnAlignment(lv->columns()-1, Qt::AlignRight|Qt::AlignVCenter);
00211 lv->addColumn(i18n(
"Billing Information"));
00212 lv->setColumnAlignment(lv->columns()-1, Qt::AlignRight|Qt::AlignVCenter);
00213 }