diff options
Diffstat (limited to 'kdeprint/rlpr')
-rw-r--r-- | kdeprint/rlpr/Makefile.am | 17 | ||||
-rw-r--r-- | kdeprint/rlpr/kmconfigproxy.cpp | 47 | ||||
-rw-r--r-- | kdeprint/rlpr/kmconfigproxy.h | 40 | ||||
-rw-r--r-- | kdeprint/rlpr/kmproprlpr.cpp | 75 | ||||
-rw-r--r-- | kdeprint/rlpr/kmproprlpr.h | 43 | ||||
-rw-r--r-- | kdeprint/rlpr/kmproxywidget.cpp | 71 | ||||
-rw-r--r-- | kdeprint/rlpr/kmproxywidget.h | 43 | ||||
-rw-r--r-- | kdeprint/rlpr/kmrlprfactory.cpp | 28 | ||||
-rw-r--r-- | kdeprint/rlpr/kmrlprmanager.cpp | 158 | ||||
-rw-r--r-- | kdeprint/rlpr/kmrlprmanager.h | 48 | ||||
-rw-r--r-- | kdeprint/rlpr/kmrlpruimanager.cpp | 55 | ||||
-rw-r--r-- | kdeprint/rlpr/kmrlpruimanager.h | 36 | ||||
-rw-r--r-- | kdeprint/rlpr/kmwrlpr.cpp | 210 | ||||
-rw-r--r-- | kdeprint/rlpr/kmwrlpr.h | 50 | ||||
-rw-r--r-- | kdeprint/rlpr/krlprprinterimpl.cpp | 76 | ||||
-rw-r--r-- | kdeprint/rlpr/krlprprinterimpl.h | 36 | ||||
-rw-r--r-- | kdeprint/rlpr/rlpr.print | 84 |
17 files changed, 1117 insertions, 0 deletions
diff --git a/kdeprint/rlpr/Makefile.am b/kdeprint/rlpr/Makefile.am new file mode 100644 index 000000000..ce075fb7c --- /dev/null +++ b/kdeprint/rlpr/Makefile.am @@ -0,0 +1,17 @@ +AM_CPPFLAGS = -D_KDEPRINT_COMPILE + +INCLUDES= -I$(top_srcdir) -I$(top_srcdir)/kdeprint -I$(top_srcdir)/kdeprint/management $(all_includes) + +kde_module_LTLIBRARIES = kdeprint_rlpr.la + +kdeprint_rlpr_la_SOURCES = kmrlprfactory.cpp kmrlprmanager.cpp krlprprinterimpl.cpp kmrlpruimanager.cpp \ + kmwrlpr.cpp kmproprlpr.cpp kmproxywidget.cpp kmconfigproxy.cpp +kdeprint_rlpr_la_LDFLAGS = $(all_libraries) -module -avoid-version -no-undefined +kdeprint_rlpr_la_LIBADD = $(top_builddir)/kdeprint/management/libkdeprint_management.la +kdeprint_rlpr_la_METASOURCES = AUTO + +noinst_HEADERS = kmrlprmanager.h krlprprinterimpl.h kmrlpruimanager.h kmwrlpr.h kmproprlpr.h \ + kmproxywidget.h kmconfigproxy.h + +entry_DATA = rlpr.print +entrydir = $(kde_datadir)/kdeprint/plugins diff --git a/kdeprint/rlpr/kmconfigproxy.cpp b/kdeprint/rlpr/kmconfigproxy.cpp new file mode 100644 index 000000000..4c81ba6fc --- /dev/null +++ b/kdeprint/rlpr/kmconfigproxy.cpp @@ -0,0 +1,47 @@ +/* + * This file is part of the KDE libraries + * Copyright (c) 2001 Michael Goffioul <kdeprint@swing.be> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License version 2 as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + **/ + +#include "kmconfigproxy.h" +#include "kmproxywidget.h" + +#include <qlayout.h> +#include <klocale.h> + +KMConfigProxy::KMConfigProxy(QWidget *parent) +: KMConfigPage(parent,"Proxy") +{ + setPageName(i18n("Proxy")); + setPageHeader(i18n("RLPR Proxy Server Settings")); + setPagePixmap("proxy"); + + m_widget = new KMProxyWidget(this); + QVBoxLayout *lay0 = new QVBoxLayout(this, 5, 0); + lay0->addWidget(m_widget); + lay0->addStretch(1); +} + +void KMConfigProxy::loadConfig(KConfig *conf) +{ + m_widget->loadConfig(conf); +} + +void KMConfigProxy::saveConfig(KConfig *conf) +{ + m_widget->saveConfig(conf); +} diff --git a/kdeprint/rlpr/kmconfigproxy.h b/kdeprint/rlpr/kmconfigproxy.h new file mode 100644 index 000000000..ea3e80118 --- /dev/null +++ b/kdeprint/rlpr/kmconfigproxy.h @@ -0,0 +1,40 @@ +/* + * This file is part of the KDE libraries + * Copyright (c) 2001 Michael Goffioul <kdeprint@swing.be> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License version 2 as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + **/ + +#ifndef KMCONFIGPROXY_H +#define KMCONFIGPROXY_H + +#include "kmconfigpage.h" + +class KMProxyWidget; +class KConfig; + +class KMConfigProxy : public KMConfigPage +{ +public: + KMConfigProxy(QWidget *parent = 0); + + void loadConfig(KConfig*); + void saveConfig(KConfig*); + +private: + KMProxyWidget *m_widget; +}; + +#endif diff --git a/kdeprint/rlpr/kmproprlpr.cpp b/kdeprint/rlpr/kmproprlpr.cpp new file mode 100644 index 000000000..f13436e0b --- /dev/null +++ b/kdeprint/rlpr/kmproprlpr.cpp @@ -0,0 +1,75 @@ +/* + * This file is part of the KDE libraries + * Copyright (c) 2001 Michael Goffioul <kdeprint@swing.be> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License version 2 as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + **/ + +#include "kmproprlpr.h" +#include "kmprinter.h" +#include "kmwizard.h" + +#include <qlabel.h> +#include <qlayout.h> +#include <klocale.h> + +KMPropRlpr::KMPropRlpr(QWidget *parent, const char *name) +: KMPropWidget(parent,name) +{ + m_host = new QLabel("",this); + m_queue = new QLabel("",this); + + QLabel *l1 = new QLabel(i18n("Host:"), this); + QLabel *l2 = new QLabel(i18n("Queue:"), this); + + // layout + QGridLayout *main_ = new QGridLayout(this, 3, 2, 10, 7); + main_->setColStretch(0,0); + main_->setColStretch(1,1); + main_->setRowStretch(2,1); + main_->addWidget(l1,0,0); + main_->addWidget(l2,1,0); + main_->addWidget(m_host,0,1); + main_->addWidget(m_queue,1,1); + + m_pixmap = "connect_established"; + m_title = i18n("Queue"); + m_header = i18n("Remote LPD Queue Settings"); +} + +KMPropRlpr::~KMPropRlpr() +{ +} + +void KMPropRlpr::setPrinter(KMPrinter *p) +{ + if (p && !p->isSpecial()) + { + m_host->setText(p->option("host")); + m_queue->setText(p->option("queue")); + emit enable(true); + } + else + { + emit enable(false); + m_host->setText(""); + m_queue->setText(""); + } +} + +void KMPropRlpr::configureWizard(KMWizard *w) +{ + w->configure(KMWizard::Custom+1,KMWizard::Custom+1,true); +} diff --git a/kdeprint/rlpr/kmproprlpr.h b/kdeprint/rlpr/kmproprlpr.h new file mode 100644 index 000000000..587321719 --- /dev/null +++ b/kdeprint/rlpr/kmproprlpr.h @@ -0,0 +1,43 @@ +/* + * This file is part of the KDE libraries + * Copyright (c) 2001 Michael Goffioul <kdeprint@swing.be> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License version 2 as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + **/ + +#ifndef KMPROPRLPR_H +#define KMPROPRLPR_H + +#include "kmpropwidget.h" + +class QLabel; + +class KMPropRlpr : public KMPropWidget +{ +public: + KMPropRlpr(QWidget *parent = 0, const char *name = 0); + ~KMPropRlpr(); + + void setPrinter(KMPrinter*); + +protected: + void configureWizard(KMWizard*); + +private: + QLabel *m_host; + QLabel *m_queue; +}; + +#endif diff --git a/kdeprint/rlpr/kmproxywidget.cpp b/kdeprint/rlpr/kmproxywidget.cpp new file mode 100644 index 000000000..5e4256ecf --- /dev/null +++ b/kdeprint/rlpr/kmproxywidget.cpp @@ -0,0 +1,71 @@ +/* + * This file is part of the KDE libraries + * Copyright (c) 2001 Michael Goffioul <kdeprint@swing.be> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License version 2 as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + **/ + +#include "kmproxywidget.h" + +#include <qlineedit.h> +#include <qlabel.h> +#include <qcheckbox.h> +#include <qlayout.h> +#include <qvalidator.h> +#include <klocale.h> +#include <kconfig.h> +#include <kcursor.h> + +KMProxyWidget::KMProxyWidget(QWidget *parent, const char *name) +: QGroupBox(0, Qt::Vertical, i18n("Proxy Settings"), parent, name) +{ + QLabel *m_hostlabel = new QLabel(i18n("&Host:"), this); + QLabel *m_portlabel = new QLabel(i18n("&Port:"), this); + m_useproxy = new QCheckBox(i18n("&Use proxy server"), this); + m_useproxy->setCursor(KCursor::handCursor()); + m_proxyhost = new QLineEdit(this); + m_proxyport = new QLineEdit(this); + m_proxyport->setValidator(new QIntValidator(m_proxyport)); + m_hostlabel->setBuddy(m_proxyhost); + m_portlabel->setBuddy(m_proxyport); + + connect(m_useproxy,SIGNAL(toggled(bool)),m_proxyhost,SLOT(setEnabled(bool))); + connect(m_useproxy,SIGNAL(toggled(bool)),m_proxyport,SLOT(setEnabled(bool))); + m_proxyhost->setEnabled(false); + m_proxyport->setEnabled(false); + + QGridLayout *lay0 = new QGridLayout(layout(), 3, 2, 10); + lay0->setColStretch(1,1); + lay0->addMultiCellWidget(m_useproxy,0,0,0,1); + lay0->addWidget(m_hostlabel,1,0); + lay0->addWidget(m_portlabel,2,0); + lay0->addWidget(m_proxyhost,1,1); + lay0->addWidget(m_proxyport,2,1); +} + +void KMProxyWidget::loadConfig(KConfig *conf) +{ + conf->setGroup("RLPR"); + m_proxyhost->setText(conf->readEntry("ProxyHost",QString::null)); + m_proxyport->setText(conf->readEntry("ProxyPort",QString::null)); + m_useproxy->setChecked(!m_proxyhost->text().isEmpty()); +} + +void KMProxyWidget::saveConfig(KConfig *conf) +{ + conf->setGroup("RLPR"); + conf->writeEntry("ProxyHost",(m_useproxy->isChecked() ? m_proxyhost->text() : QString::null)); + conf->writeEntry("ProxyPort",(m_useproxy->isChecked() ? m_proxyport->text() : QString::null)); +} diff --git a/kdeprint/rlpr/kmproxywidget.h b/kdeprint/rlpr/kmproxywidget.h new file mode 100644 index 000000000..4c9dbf7e1 --- /dev/null +++ b/kdeprint/rlpr/kmproxywidget.h @@ -0,0 +1,43 @@ +/* + * This file is part of the KDE libraries + * Copyright (c) 2001 Michael Goffioul <kdeprint@swing.be> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License version 2 as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + **/ + +#ifndef KMPROXYWIDGET_H +#define KMPROXYWIDGET_H + +#include <qgroupbox.h> + +class KConfig; +class QLineEdit; +class QCheckBox; + +class KMProxyWidget : public QGroupBox +{ +public: + KMProxyWidget(QWidget *parent = 0, const char *name = 0); + + void loadConfig(KConfig*); + void saveConfig(KConfig*); + +private: + QLineEdit *m_proxyhost; + QLineEdit *m_proxyport; + QCheckBox *m_useproxy; +}; + +#endif diff --git a/kdeprint/rlpr/kmrlprfactory.cpp b/kdeprint/rlpr/kmrlprfactory.cpp new file mode 100644 index 000000000..1e414bc59 --- /dev/null +++ b/kdeprint/rlpr/kmrlprfactory.cpp @@ -0,0 +1,28 @@ +/* + * This file is part of the KDE libraries + * Copyright (c) 2001 Michael Goffioul <kdeprint@swing.be> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License version 2 as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + **/ + +#include "kmrlprmanager.h" +#include "kmrlpruimanager.h" +#include "krlprprinterimpl.h" + +#include <kgenericfactory.h> + +typedef K_TYPELIST_3( KMRlprManager, KMRlprUiManager, KRlprPrinterImpl ) Products; +K_EXPORT_COMPONENT_FACTORY( kdeprint_rlpr, KGenericFactory< Products > ) + diff --git a/kdeprint/rlpr/kmrlprmanager.cpp b/kdeprint/rlpr/kmrlprmanager.cpp new file mode 100644 index 000000000..eafb1a497 --- /dev/null +++ b/kdeprint/rlpr/kmrlprmanager.cpp @@ -0,0 +1,158 @@ +/* + * This file is part of the KDE libraries + * Copyright (c) 2001 Michael Goffioul <kdeprint@swing.be> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License version 2 as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + **/ + +#include "kmrlprmanager.h" +#include "kmprinter.h" + +#include <qfile.h> +#include <qfileinfo.h> +#include <qtextstream.h> +#include <qmap.h> + +#include <kstandarddirs.h> +#include <klocale.h> + +KMRlprManager::KMRlprManager(QObject *parent, const char *name, const QStringList & /*args*/) +: KMManager(parent,name) +{ + setHasManagement(true); + setPrinterOperationMask(KMManager::PrinterCreation|KMManager::PrinterRemoval|KMManager::PrinterTesting); +} + +KMRlprManager::~KMRlprManager() +{ +} + +bool KMRlprManager::createPrinter(KMPrinter *p) +{ + if (p->name().isEmpty()) + setErrorMsg(i18n("Empty printer name.")); + else if (p->option("host").isEmpty()) + setErrorMsg(i18n("Empty host name.")); + else if (p->option("queue").isEmpty()) + setErrorMsg(i18n("Empty queue name.")); + else + { + KMPrinter *pr = new KMPrinter(*p); + addPrinter(pr); + savePrinters(); + return true; + } + return false; +} + +bool KMRlprManager::removePrinter(KMPrinter *p) +{ + if (m_printers.findRef(p) == -1) + setErrorMsg(i18n("Printer not found.")); + else + { + m_printers.removeRef(p); + savePrinters(); + return true; + } + return false; +} + +bool KMRlprManager::testPrinter(KMPrinter *) +{ + setErrorMsg(i18n("Not implemented yet.")); + return false; +} + +void KMRlprManager::listPrinters() +{ + QFileInfo pfi(printerFile()); + if (pfi.exists() && (!m_checktime.isValid() || m_checktime < pfi.lastModified())) + { + loadPrintersConf(pfi.absFilePath()); + m_checktime = pfi.lastModified(); + } + else + discardAllPrinters(false); +} + +void KMRlprManager::loadPrintersConf(const QString& filename) +{ + QFile f(filename); + if (f.exists() && f.open(IO_ReadOnly)) + { + QTextStream t(&f); + QString line; + while (!t.eof()) + { + line = t.readLine().stripWhiteSpace(); + if (line.isEmpty() || line[0] == '#') + continue; + QStringList w = QStringList::split('\t',line,true); + if (w.count() < 3) + continue; + + KMPrinter *printer = new KMPrinter; + printer->setName(w[0]); + printer->setPrinterName(w[0]); + printer->setType(KMPrinter::Printer); + printer->setOption("host",w[1]); + printer->setOption("queue",w[2]); + if (w.count() > 3) + { + printer->setDescription(w[3]); + if (w.count() > 4) printer->setLocation(w[4]); + } + printer->setState(KMPrinter::Idle); + printer->setDevice(QString::fromLatin1("lpd://%1/%2").arg(w[1]).arg(w[2])); + + addPrinter(printer); + } + } +} + +void KMRlprManager::savePrinters() +{ + savePrintersConf(printerFile()); +} + +void KMRlprManager::savePrintersConf(const QString& filename) +{ + QFile f(filename); + if (f.open(IO_WriteOnly)) + { + QTextStream t(&f); + t << "# File generated by KDE print system. Don't edit by hand." << endl; + QPtrListIterator<KMPrinter> it(m_printers); + for (;it.current();++it) + { + if (!it.current()->name().isEmpty() && it.current()->instanceName().isEmpty()) + { + QString host = it.current()->option("host"); + QString queue = it.current()->option("queue"); + if (!host.isEmpty() && !queue.isEmpty()) + { + t << it.current()->name() << '\t' << host << '\t' << queue; + t << '\t' << it.current()->description() << '\t' << it.current()->location() << endl; + } + } + } + } +} + +QString KMRlprManager::printerFile() +{ + return locateLocal("data","kdeprint/printers.conf"); +} diff --git a/kdeprint/rlpr/kmrlprmanager.h b/kdeprint/rlpr/kmrlprmanager.h new file mode 100644 index 000000000..2a2e6844d --- /dev/null +++ b/kdeprint/rlpr/kmrlprmanager.h @@ -0,0 +1,48 @@ +/* + * This file is part of the KDE libraries + * Copyright (c) 2001 Michael Goffioul <kdeprint@swing.be> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License version 2 as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + **/ + +#ifndef KMRLPRMANAGER_H +#define KMRLPRMANAGER_H + +#include "kmmanager.h" +#include <qdict.h> +#include <qdatetime.h> + +class KMRlprManager : public KMManager +{ +public: + KMRlprManager(QObject *parent, const char *name, const QStringList & /*args*/); + ~KMRlprManager(); + + bool createPrinter(KMPrinter*); + bool removePrinter(KMPrinter*); + bool testPrinter(KMPrinter*); + +protected: + void listPrinters(); + void savePrinters(); + void loadPrintersConf(const QString& filename); + void savePrintersConf(const QString& filename); + QString printerFile(); + +private: + QDateTime m_checktime; +}; + +#endif diff --git a/kdeprint/rlpr/kmrlpruimanager.cpp b/kdeprint/rlpr/kmrlpruimanager.cpp new file mode 100644 index 000000000..5cdb03b95 --- /dev/null +++ b/kdeprint/rlpr/kmrlpruimanager.cpp @@ -0,0 +1,55 @@ +/* + * This file is part of the KDE libraries + * Copyright (c) 2001 Michael Goffioul <kdeprint@swing.be> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License version 2 as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + **/ + +#include "kmrlpruimanager.h" +#include "kmpropertypage.h" +#include "kmwizard.h" +#include "kmconfigdialog.h" + +#include "kmwrlpr.h" +#include "kmproprlpr.h" +#include "kmconfigproxy.h" + +#include <klocale.h> + +KMRlprUiManager::KMRlprUiManager(QObject *parent, const char *name, const QStringList & /*args*/) +: KMUiManager(parent,name) +{ +} + +KMRlprUiManager::~KMRlprUiManager() +{ +} + +void KMRlprUiManager::setupPropertyPages(KMPropertyPage *pages) +{ + pages->addPropPage(new KMPropRlpr(pages,"RlprPage")); +} + +void KMRlprUiManager::setupWizard(KMWizard *wizard) +{ + wizard->setNextPage(KMWizard::Start,KMWizard::Custom+1); + // add page + wizard->addPage(new KMWRlpr(wizard,"Rlpr")); +} + +void KMRlprUiManager::setupConfigDialog(KMConfigDialog *dlg) +{ + dlg->addConfigPage(new KMConfigProxy(dlg)); +} diff --git a/kdeprint/rlpr/kmrlpruimanager.h b/kdeprint/rlpr/kmrlpruimanager.h new file mode 100644 index 000000000..5a31f4dee --- /dev/null +++ b/kdeprint/rlpr/kmrlpruimanager.h @@ -0,0 +1,36 @@ +/* + * This file is part of the KDE libraries + * Copyright (c) 2001 Michael Goffioul <kdeprint@swing.be> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License version 2 as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + **/ + +#ifndef KMRLPRUIMANAGER_H +#define KMRLPRUIMANAGER_H + +#include "kmuimanager.h" + +class KMRlprUiManager : public KMUiManager +{ +public: + KMRlprUiManager(QObject *parent, const char *name, const QStringList & /*args*/); + ~KMRlprUiManager(); + + void setupPropertyPages(KMPropertyPage*); + void setupWizard(KMWizard*); + void setupConfigDialog(KMConfigDialog*); +}; + +#endif diff --git a/kdeprint/rlpr/kmwrlpr.cpp b/kdeprint/rlpr/kmwrlpr.cpp new file mode 100644 index 000000000..50006c14c --- /dev/null +++ b/kdeprint/rlpr/kmwrlpr.cpp @@ -0,0 +1,210 @@ +/* + * This file is part of the KDE libraries + * Copyright (c) 2001 Michael Goffioul <kdeprint@swing.be> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License version 2 as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + **/ + +#include "kmwrlpr.h" +#include "kmprinter.h" +#include "kmwizard.h" + +#include <qdir.h> +#include <qfile.h> +#include <qtextstream.h> +#include <qlayout.h> +#include <qlabel.h> +#include <qlineedit.h> +#include <qheader.h> +#include <klistview.h> +#include <klocale.h> +#include <kiconloader.h> + +static QListViewItem* findChild(QListViewItem *c, const QString& txt) +{ + QListViewItem *item(c); + while (item) + if (item->text(0) == txt) return item; + else item = item->nextSibling(); + return NULL; +} + +//***************************************************************************************************** + +KMWRlpr::KMWRlpr(QWidget *parent, const char *name) +: KMWizardPage(parent,name) +{ + m_ID = KMWizard::Custom+1; + m_title = i18n("Remote LPD Queue Settings"); + m_nextpage = KMWizard::Name; + + m_view = new KListView(this); + m_view->setFrameStyle(QFrame::WinPanel|QFrame::Sunken); + m_view->setLineWidth(1); + m_view->addColumn(QString::fromLatin1("")); + m_view->header()->hide(); + m_view->setRootIsDecorated(true); + m_view->setSorting(0); + m_host = new QLineEdit(this); + m_queue = new QLineEdit(this); + QLabel *m_hostlabel = new QLabel(i18n("Host:"), this); + QLabel *m_queuelabel = new QLabel(i18n("Queue:"), this); + m_hostlabel->setBuddy(m_host); + m_queuelabel->setBuddy(m_queue); + connect(m_view,SIGNAL(selectionChanged(QListViewItem*)),SLOT(slotPrinterSelected(QListViewItem*))); + + QHBoxLayout *lay0 = new QHBoxLayout(this, 0, 10); + QVBoxLayout *lay1 = new QVBoxLayout(0, 0, 5); + lay0->addWidget(m_view,1); + lay0->addLayout(lay1,1); + lay1->addWidget(m_hostlabel); + lay1->addWidget(m_host); + lay1->addSpacing(20); + lay1->addWidget(m_queuelabel); + lay1->addWidget(m_queue); + lay1->addStretch(1); + + initialize(); +} + +bool KMWRlpr::isValid(QString& msg) +{ + if (m_host->text().isEmpty()) + msg = i18n("Empty host name."); + else if (m_queue->text().isEmpty()) + msg = i18n("Empty queue name."); + else + return true; + return false; +} + +void KMWRlpr::initPrinter(KMPrinter *p) +{ + m_host->setText(p->option("host")); + m_queue->setText(p->option("queue")); + QListViewItem *item = findChild(m_view->firstChild(),m_host->text()); + if (item) + { + item = findChild(item->firstChild(),m_queue->text()); + if (item) + { + item->parent()->setOpen(true); + m_view->setCurrentItem(item); + m_view->ensureItemVisible(item); + } + } +} + +void KMWRlpr::updatePrinter(KMPrinter *p) +{ + QString uri = QString::fromLatin1("lpd://%1/%2").arg(m_host->text()).arg(m_queue->text()); + p->setDevice(uri); + p->setOption("host",m_host->text()); + p->setOption("queue",m_queue->text()); + p->setOption("kde-backend-description",i18n("Remote LPD queue")); + // setting default name and description, but only if the "name()" is empty + // which is the case on first pass when adding a printer. This prevents from + // bad side-effects when simply modifying an existing printer. + if (p->name().isEmpty()) + { + p->setName(m_queue->text()); + p->setPrinterName(p->name()); + p->setDescription(i18n("Remote queue %1 on %2").arg(m_queue->text()).arg(m_host->text())); + } +} + +void KMWRlpr::initialize() +{ + m_view->clear(); + QFile f(QDir::homeDirPath()+"/.rlprrc"); + if (!f.exists()) f.setName("/etc/rlprrc"); + if (f.exists() && f.open(IO_ReadOnly)) + { + QTextStream t(&f); + QString line, host; + int p(-1); + while (!t.eof()) + { + line = t.readLine().stripWhiteSpace(); + if (line.isEmpty()) + continue; + if ((p=line.find(':')) != -1) + { + host = line.left(p).stripWhiteSpace(); + QListViewItem *hitem = new QListViewItem(m_view,host); + hitem->setPixmap(0,SmallIcon("kdeprint_computer")); + QStringList prs = QStringList::split(' ',line.right(line.length()-p-1),false); + for (QStringList::ConstIterator it=prs.begin(); it!=prs.end(); ++it) + { + QListViewItem *pitem = new QListViewItem(hitem,*it); + pitem->setPixmap(0,SmallIcon("kdeprint_printer")); + } + } + } + f.close(); + } + + // parse printcap file for local printers + f.setName("/etc/printcap"); + if (f.exists() && f.open(IO_ReadOnly)) + { + QTextStream t(&f); + QString line, buffer; + QListViewItem *hitem(m_view->firstChild()); + while (hitem) if (hitem->text(0) == "localhost") break; else hitem = hitem->nextSibling(); + while (!t.eof()) + { + buffer = QString::null; + while (!t.eof()) + { + line = t.readLine().stripWhiteSpace(); + if (line.isEmpty() || line[0] == '#') + continue; + buffer.append(line); + if (buffer.right(1) == "\\") + buffer = buffer.left(buffer.length()-1).stripWhiteSpace(); + else + break; + } + if (buffer.isEmpty()) + continue; + int p = buffer.find(':'); + if (p != -1) + { + QString name = buffer.left(p); + if (!hitem) + { + hitem = new QListViewItem(m_view,"localhost"); + hitem->setPixmap(0,SmallIcon("kdeprint_computer")); + } + QListViewItem *pitem = new QListViewItem(hitem,name); + pitem->setPixmap(0,SmallIcon("kdeprint_printer")); + } + } + } + + if (m_view->childCount() == 0) + new QListViewItem(m_view,i18n("No Predefined Printers")); +} + +void KMWRlpr::slotPrinterSelected(QListViewItem *item) +{ + if (item && item->depth() == 1) + { + m_host->setText(item->parent()->text(0)); + m_queue->setText(item->text(0)); + } +} +#include "kmwrlpr.moc" diff --git a/kdeprint/rlpr/kmwrlpr.h b/kdeprint/rlpr/kmwrlpr.h new file mode 100644 index 000000000..5f66180ad --- /dev/null +++ b/kdeprint/rlpr/kmwrlpr.h @@ -0,0 +1,50 @@ +/* + * This file is part of the KDE libraries + * Copyright (c) 2001 Michael Goffioul <kdeprint@swing.be> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License version 2 as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + **/ + +#ifndef KMWRLPR_H +#define KMWRLPR_H + +#include "kmwizardpage.h" + +class KListView; +class QLineEdit; +class QListViewItem; + +class KMWRlpr : public KMWizardPage +{ + Q_OBJECT +public: + KMWRlpr(QWidget *parent = 0, const char *name = 0); + + bool isValid(QString&); + void initPrinter(KMPrinter*); + void updatePrinter(KMPrinter*); + +protected slots: + void slotPrinterSelected(QListViewItem*); + +protected: + void initialize(); + +private: + KListView *m_view; + QLineEdit *m_host, *m_queue; +}; + +#endif diff --git a/kdeprint/rlpr/krlprprinterimpl.cpp b/kdeprint/rlpr/krlprprinterimpl.cpp new file mode 100644 index 000000000..9c77518b6 --- /dev/null +++ b/kdeprint/rlpr/krlprprinterimpl.cpp @@ -0,0 +1,76 @@ +/* + * This file is part of the KDE libraries + * Copyright (c) 2001 Michael Goffioul <kdeprint@swing.be> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License version 2 as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + **/ + +#include "krlprprinterimpl.h" +#include "kprinter.h" +#include "kmfactory.h" +#include "kmmanager.h" +#include "kmprinter.h" + +#include <qfile.h> +#include <kstandarddirs.h> +#include <kconfig.h> +#include <klocale.h> + +KRlprPrinterImpl::KRlprPrinterImpl(QObject *parent, const char *name, const QStringList & /*args*/) +: KPrinterImpl(parent,name) +{ +} + +KRlprPrinterImpl::~KRlprPrinterImpl() +{ +} + +bool KRlprPrinterImpl::setupCommand(QString& cmd, KPrinter *printer) +{ + // retrieve the KMPrinter object, to get host and queue name + KMPrinter *rpr = KMFactory::self()->manager()->findPrinter(printer->printerName()); + if (!rpr) + return false; + + QString host(rpr->option("host")), queue(rpr->option("queue")); + if (!host.isEmpty() && !queue.isEmpty()) + { + QString exestr = KStandardDirs::findExe("rlpr"); + if (exestr.isEmpty()) + { + printer->setErrorMessage(i18n("The <b>%1</b> executable could not be found in your path. Check your installation.").arg("rlpr")); + return false; + } + + cmd = QString::fromLatin1("%1 -H %2 -P %3 -\\#%4").arg(exestr).arg(quote(host)).arg(quote(queue)).arg(printer->numCopies()); + + // proxy settings + KConfig *conf = KMFactory::self()->printConfig(); + conf->setGroup("RLPR"); + QString host = conf->readEntry("ProxyHost",QString::null), port = conf->readEntry("ProxyPort",QString::null); + if (!host.isEmpty()) + { + cmd.append(" -X ").append(quote(host)); + if (!port.isEmpty()) cmd.append(" --port=").append(port); + } + + return true; + } + else + { + printer->setErrorMessage(i18n("The printer is incompletely defined. Try to reinstall it.")); + return false; + } +} diff --git a/kdeprint/rlpr/krlprprinterimpl.h b/kdeprint/rlpr/krlprprinterimpl.h new file mode 100644 index 000000000..14c054b1e --- /dev/null +++ b/kdeprint/rlpr/krlprprinterimpl.h @@ -0,0 +1,36 @@ +/* + * This file is part of the KDE libraries + * Copyright (c) 2001 Michael Goffioul <kdeprint@swing.be> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License version 2 as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + **/ + +#ifndef KRLPRPRINTERIMPL_H +#define KRLPRPRINTERIMPL_H + +#include "kprinterimpl.h" + +class KProcess; + +class KRlprPrinterImpl : public KPrinterImpl +{ +public: + KRlprPrinterImpl(QObject *parent, const char *name, const QStringList & /*args*/); + ~KRlprPrinterImpl(); + + bool setupCommand(QString&, KPrinter*); +}; + +#endif diff --git a/kdeprint/rlpr/rlpr.print b/kdeprint/rlpr/rlpr.print new file mode 100644 index 000000000..25f16ee63 --- /dev/null +++ b/kdeprint/rlpr/rlpr.print @@ -0,0 +1,84 @@ +[KDE Print Entry] +PrintSystem=rlpr +Comment=RLPR Environment (Remote LPD servers) +Comment[af]=Rlpr Omgewing (Afgeleë Lpd bedieners) +Comment[ar]=بيئة RLPR (خادمات LPR عن بعد) +Comment[az]=RLPR Mühiti (Uzaq LPD vericiləri) +Comment[be]=Асяроддзе RLPR (аддаленыя серверы LPD) +Comment[bs]=RLPR okolina (udaljeni LPD serveri) +Comment[ca]=Entorn RLPR (servidors LPD remots) +Comment[cs]=Prostředí RLPR (Vzdálené LPD servery) +Comment[csb]=Òkrãże RLPR (daleczi serwerë LPD) +Comment[cy]=Amgylchedd RLPR (Gweinyddion LPD pell) +Comment[da]=RLPR-miljø (fjerne LPD-servere) +Comment[de]=RLPR-Umgebung (LPD-Server auf Fremdrechner) +Comment[el]=Περιβάλλον RLPR (Απομακρυσμένοι εξυπηρετητές LPD) +Comment[eo]=RLPR-medio (Foraj LPD-servoj) +Comment[es]=Entorno RLPR (servidores LPD remotos) +Comment[et]=RLPR keskkond (LPD võrguserverid) +Comment[eu]=RLPR ingurunea (urruneko LPD zerbitzariak) +Comment[fa]=محیط RLPR )کارسازهای LPD دور( +Comment[fi]=RLPR-tulostus (LPD-palvelin) +Comment[fr]=Environnement RLPR (serveurs LPD distants) +Comment[fy]=RLPR-fermidden (LPD-tsjinners op ôfstân) +Comment[ga]=Timpeallach RLPR (Cianfhreastalaithe LPD) +Comment[gl]=Entorno RLPR (Servidores Remotos LPD) +Comment[he]=סביבת RLPR (שרתי LPD מרוחקים) +Comment[hi]=RLPR वातावरण (रिमोट LPD सर्वर्स) +Comment[hr]=RLPR okruženje (udaljeni LPD poslužitelji) +Comment[hu]=RLPR (távoli LPD-kiszolgálón keresztül) +Comment[id]=Lingkungan RLPR (Server LPD remote) +Comment[is]=RLPR umhverfi (fjarlægir LPD þjónar) +Comment[it]=Ambiente RLPR (server LPD remoti) +Comment[ja]=RLPR 環境 (リモート LPD サーバ) +Comment[ka]=RLPR გარემო (დაშორებული LPD სერვერები) +Comment[kk]=RLPR ортасы (Желідегі LPD серверлері) +Comment[km]=បរិស្ថាន RLPR (ម៉ាស៊ីនបម្រើ LPD ពីចម្ងាយ) +Comment[ko]=RLPR 환경 (원격지 LPD 서버) +Comment[lb]=RLPR mfeld(LPD-ServeËren op anere Computeren) +Comment[lt]=RLPR aplinka (nutolę LPD serveriai) +Comment[lv]=RLPR vide (Attālināti LPD serveri) +Comment[mk]=RLPR околина (оддалечени LPD сервери) +Comment[mn]=RLPR-орчин (алсын LPD-Сервер) +Comment[ms]=Persekitaran RLPR (Pelayan LPD jauh) +Comment[mt]=Ambjent RLPR (servers LPD remoti) +Comment[nb]=RLPR-miljø (LPD-tjenere over nettverk) +Comment[nds]=RLPR-Ümgeven (LPD-Servers op anner Reekners) +Comment[ne]=RLPR परिवेश (टाढाको LPD सर्भर) +Comment[nl]=RLPR-omgeving (LPD-servers op afstand) +Comment[nn]=RLPR-miljø (LPD-tenarar over nettverk) +Comment[nso]=Tikologo ya RLPR (Baabi remote ba LPD) +Comment[pa]=RLPR ਵਾਤਾਵਰਣ(ਰਿਮੋਟ LPD ਸਰਵਰ) +Comment[pl]=Środowisko RLPR (zdalne serwery LPD) +Comment[pt]=O ambiente RLPR (servidores remotos de LPD) +Comment[pt_BR]= Ambiente RLPR (Servidores LPD Remotos) +Comment[ro]=Mediu RLPR (Servere LPD distante) +Comment[ru]=Среда RLPR (сетевые принт-серверы LPD) +Comment[rw]=Ibikikije RLPR (Amaseriveri LPD ya Kure) +Comment[se]=RLPR-biras (LPD-gáiddusbálvvát) +Comment[sk]=Prostredie RLPR (Vzdialené LPD servery) +Comment[sl]=Okolje RLPR (oddaljeni strežniki LPD) +Comment[sq]=Ambienti RLPR (Shërbyesit e Largët LPD) +Comment[sr]=RLPR окружење (удаљени LPD сервери) +Comment[sr@Latn]=RLPR okruženje (udaljeni LPD serveri) +Comment[ss]=Siminhlalo se RLPR (Susa tigcini teLPD) +Comment[sv]=RLPR-miljö (LPD-fjärrservrar) +Comment[ta]=RLPR சூழல் (சேய்மை LPD சேவகன்கள்) +Comment[te]=ఆర్ ఎల్ పి ఆర్ పర్యావరణం (సుదూర అల్ పి డి సెర్వర్లు) +Comment[tg]=Муҳити RLPR (серверҳои чопи шабақавии LPD) +Comment[th]=สภาพแวดล้อม RLPR (เซอร์เวอร์ LPD ระยะไกล) +Comment[tr]=RLPR Ortamı (Uzak LPD Sunucuları) +Comment[tt]=RLPR Eşläw Tiräse (Çittäge LPD serverläre) +Comment[uk]=Оточення RLPR (віддалені сервери LPD) +Comment[uz]=RLPR muhiti (masofadagi LPD serverlar) +Comment[uz@cyrillic]=RLPR муҳити (масофадаги LPD серверлар) +Comment[ven]=Vhupo ha RLPR (dzisiva dza LPD) +Comment[vi]=Môi trường RLPR (máy phục vụ LPD từ xa) +Comment[wa]=Evironmint d' imprimaedje RLPR (sierveus LPD å lon) +Comment[xh]=RLPR Imeko-bume ye RLPR (Abancedisi be LPD ababeka kude) +Comment[zh_CN]=RLPR 环境(远程 LPD 服务器) +Comment[zh_HK]=RLPR 環境 (遠端 LPD 伺服器) +Comment[zh_TW]=RLPR 環境(遠端 LPD 伺服器) +Comment[zu]=Ezendalo ze-RLPR (abalekeleli abakude be-LPD) +DetectUris=exec:/rlpr +DetectPrecedence=0 |