kdeprint Library API Documentation

krlprprinterimpl.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 "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 & /*args*/) 00032 : KPrinterImpl(parent,name) 00033 { 00034 } 00035 00036 KRlprPrinterImpl::~KRlprPrinterImpl() 00037 { 00038 } 00039 00040 bool KRlprPrinterImpl::setupCommand(QString& cmd, KPrinter *printer) 00041 { 00042 // retrieve the KMPrinter object, to get host and queue name 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 // proxy settings 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 }
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 Fri Aug 20 09:50:01 2004 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003