• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • kdeprint
 

kdeprint

klpdunixprinterimpl.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., 51 Franklin Street, Fifth Floor,
00017  *  Boston, MA 02110-1301, USA.
00018  **/
00019 
00020 #include "klpdunixprinterimpl.h"
00021 #include "kprinter.h"
00022 
00023 #include <tqfile.h>
00024 #include <kstandarddirs.h>
00025 #include <klocale.h>
00026 #include <kmacroexpander.h>
00027 
00028 KLpdUnixPrinterImpl::KLpdUnixPrinterImpl(TQObject *parent, const char *name, const TQStringList & /*args*/)
00029 : KPrinterImpl(parent,name)
00030 {
00031 }
00032 
00033 KLpdUnixPrinterImpl::~KLpdUnixPrinterImpl()
00034 {
00035 }
00036 
00037 void KLpdUnixPrinterImpl::initLpPrint(TQString& cmd, KPrinter *printer)
00038 {
00039     cmd += TQString::fromLatin1(" -d %1 -n%2").arg(quote(printer->printerName())).arg(printer->numCopies());
00040 }
00041 
00042 void KLpdUnixPrinterImpl::initLprPrint(TQString& cmd, KPrinter *printer)
00043 {
00044     cmd += TQString::fromLatin1(" -P %1 '-#%2'").arg(quote(printer->printerName())).arg(printer->numCopies());
00045 }
00046 
00047 // look for executable, starting with "lpr"
00048 TQString KLpdUnixPrinterImpl::executable()
00049 {
00050     QString exe = KStandardDirs::findExe("lpr");
00051     if (exe.isEmpty())
00052         exe = KStandardDirs::findExe("lp");
00053     return exe;
00054 }
00055 
00056 bool KLpdUnixPrinterImpl::setupCommand(TQString& cmd, KPrinter *printer)
00057 {
00058     TQString exe = printer->option( "kde-printcommand" );
00059     if ( exe.isEmpty() || exe == "<automatic>" )
00060     {
00061         exe = executable();
00062         if (!exe.isEmpty())
00063         {
00064             cmd = exe;
00065             if (exe.right(3) == "lpr")
00066                 initLprPrint(cmd,printer);
00067             else
00068                 initLpPrint(cmd,printer);
00069             return true;
00070         }
00071         else
00072             printer->setErrorMessage(i18n("No valid print executable was found in your path. Check your installation."));
00073         return false;
00074     }
00075     else
00076     {
00077         TQMap<TQString,TQString> map;
00078         map.insert( "printer", printer->printerName() );
00079         map.insert( "copies", TQString::number( printer->numCopies() ) );
00080         cmd = KMacroExpander::expandMacrosShellQuote( exe, map );
00081         return true;
00082     }
00083 }

kdeprint

Skip menu "kdeprint"
  • Main Page
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Class Members
  • Related Pages

kdeprint

Skip menu "kdeprint"
  • arts
  • dcop
  • dnssd
  • interfaces
  •     interface
  •     library
  •   kspeech
  •   ktexteditor
  • kabc
  • kate
  • kcmshell
  • kdecore
  • kded
  • kdefx
  • kdeprint
  • kdesu
  • kdeui
  • kdoctools
  • khtml
  • kimgio
  • kinit
  • kio
  •   bookmarks
  •   httpfilter
  •   kfile
  •   kio
  •   kioexec
  •   kpasswdserver
  •   kssl
  • kioslave
  •   http
  • kjs
  • kmdi
  •   kmdi
  • knewstuff
  • kparts
  • krandr
  • kresources
  • kspell2
  • kunittest
  • kutils
  • kwallet
  • libkmid
  • libkscreensaver
Generated for kdeprint by doxygen 1.7.6.1
This website is maintained by Timothy Pearson.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. |