krlprprinterimpl.cpp00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include "krlprprinterimpl.h"
00021 #include "kprinter.h"
00022 #include "kmfactory.h"
00023 #include "kmmanager.h"
00024 #include "kmprinter.h"
00025
00026 #include <qfile.h>
00027 #include <kstandarddirs.h>
00028 #include <kconfig.h>
00029 #include <klocale.h>
00030
00031 KRlprPrinterImpl::KRlprPrinterImpl(QObject *parent, const char *name, const QStringList & )
00032 : KPrinterImpl(parent,name)
00033 {
00034 }
00035
00036 KRlprPrinterImpl::~KRlprPrinterImpl()
00037 {
00038 }
00039
00040 bool KRlprPrinterImpl::setupCommand(QString& cmd, KPrinter *printer)
00041 {
00042
00043 KMPrinter *rpr = KMFactory::self()->manager()->findPrinter(printer->printerName());
00044 if (!rpr)
00045 return false;
00046
00047 QString host(rpr->option("host")), queue(rpr->option("queue"));
00048 if (!host.isEmpty() && !queue.isEmpty())
00049 {
00050 QString exestr = KStandardDirs::findExe("rlpr");
00051 if (exestr.isEmpty())
00052 {
00053 printer->setErrorMessage(i18n("The <b>%1</b> executable could not be found in your path. Check your installation.").arg("rlpr"));
00054 return false;
00055 }
00056
00057 cmd = QString::fromLatin1("%1 -H %2 -P %3 -\\#%4").arg(exestr).arg(quote(host)).arg(quote(queue)).arg(printer->numCopies());
00058
00059
00060 KConfig *conf = KMFactory::self()->printConfig();
00061 conf->setGroup("RLPR");
00062 QString host = conf->readEntry("ProxyHost",QString::null), port = conf->readEntry("ProxyPort",QString::null);
00063 if (!host.isEmpty())
00064 {
00065 cmd.append(" -X ").append(quote(host));
00066 if (!port.isEmpty()) cmd.append(" --port=").append(port);
00067 }
00068
00069 return true;
00070 }
00071 else
00072 {
00073 printer->setErrorMessage(i18n("The printer is incompletely defined. Try to reinstall it."));
00074 return false;
00075 }
00076 }
|