From e16866e072f94410321d70daedbcb855ea878cac Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Sun, 6 Nov 2011 15:56:40 -0600 Subject: Actually move the kde files that were renamed in the last commit --- kdeprint/lpr/CMakeLists.txt | 80 ------- kdeprint/lpr/Makefile.am | 40 ---- kdeprint/lpr/apsdriver1 | 84 ------- kdeprint/lpr/apsdriver2 | 83 ------- kdeprint/lpr/apshandler.cpp | 405 ------------------------------- kdeprint/lpr/apshandler.h | 57 ----- kdeprint/lpr/editentrydialog.cpp | 157 ------------ kdeprint/lpr/editentrydialog.h | 62 ----- kdeprint/lpr/klprfactory.cpp | 29 --- kdeprint/lpr/klprprinterimpl.cpp | 59 ----- kdeprint/lpr/klprprinterimpl.h | 38 --- kdeprint/lpr/kmconfiglpr.cpp | 66 ----- kdeprint/lpr/kmconfiglpr.h | 39 --- kdeprint/lpr/kmlprjobmanager.cpp | 90 ------- kdeprint/lpr/kmlprjobmanager.h | 44 ---- kdeprint/lpr/kmlprmanager.cpp | 492 -------------------------------------- kdeprint/lpr/kmlprmanager.h | 82 ------- kdeprint/lpr/kmlpruimanager.cpp | 67 ------ kdeprint/lpr/kmlpruimanager.h | 37 --- kdeprint/lpr/lpchelper.cpp | 320 ------------------------- kdeprint/lpr/lpchelper.h | 59 ----- kdeprint/lpr/lpqhelper.cpp | 117 --------- kdeprint/lpr/lpqhelper.h | 44 ---- kdeprint/lpr/lpr.print | 86 ------- kdeprint/lpr/lprhandler.cpp | 270 --------------------- kdeprint/lpr/lprhandler.h | 88 ------- kdeprint/lpr/lprngtooldriver1 | 85 ------- kdeprint/lpr/lprngtoolhandler.cpp | 393 ------------------------------ kdeprint/lpr/lprngtoolhandler.h | 54 ----- kdeprint/lpr/lprsettings.cpp | 146 ----------- kdeprint/lpr/lprsettings.h | 67 ------ kdeprint/lpr/make_driver_db_lpr.c | 192 --------------- kdeprint/lpr/matichandler.cpp | 481 ------------------------------------- kdeprint/lpr/matichandler.h | 57 ----- kdeprint/lpr/matichelper.cpp | 38 --- kdeprint/lpr/matichelper.h | 29 --- kdeprint/lpr/printcapentry.cpp | 82 ------- kdeprint/lpr/printcapentry.h | 81 ------- kdeprint/lpr/printcapreader.cpp | 176 -------------- kdeprint/lpr/printcapreader.h | 43 ---- 40 files changed, 4919 deletions(-) delete mode 100644 kdeprint/lpr/CMakeLists.txt delete mode 100644 kdeprint/lpr/Makefile.am delete mode 100644 kdeprint/lpr/apsdriver1 delete mode 100644 kdeprint/lpr/apsdriver2 delete mode 100644 kdeprint/lpr/apshandler.cpp delete mode 100644 kdeprint/lpr/apshandler.h delete mode 100644 kdeprint/lpr/editentrydialog.cpp delete mode 100644 kdeprint/lpr/editentrydialog.h delete mode 100644 kdeprint/lpr/klprfactory.cpp delete mode 100644 kdeprint/lpr/klprprinterimpl.cpp delete mode 100644 kdeprint/lpr/klprprinterimpl.h delete mode 100644 kdeprint/lpr/kmconfiglpr.cpp delete mode 100644 kdeprint/lpr/kmconfiglpr.h delete mode 100644 kdeprint/lpr/kmlprjobmanager.cpp delete mode 100644 kdeprint/lpr/kmlprjobmanager.h delete mode 100644 kdeprint/lpr/kmlprmanager.cpp delete mode 100644 kdeprint/lpr/kmlprmanager.h delete mode 100644 kdeprint/lpr/kmlpruimanager.cpp delete mode 100644 kdeprint/lpr/kmlpruimanager.h delete mode 100644 kdeprint/lpr/lpchelper.cpp delete mode 100644 kdeprint/lpr/lpchelper.h delete mode 100644 kdeprint/lpr/lpqhelper.cpp delete mode 100644 kdeprint/lpr/lpqhelper.h delete mode 100644 kdeprint/lpr/lpr.print delete mode 100644 kdeprint/lpr/lprhandler.cpp delete mode 100644 kdeprint/lpr/lprhandler.h delete mode 100644 kdeprint/lpr/lprngtooldriver1 delete mode 100644 kdeprint/lpr/lprngtoolhandler.cpp delete mode 100644 kdeprint/lpr/lprngtoolhandler.h delete mode 100644 kdeprint/lpr/lprsettings.cpp delete mode 100644 kdeprint/lpr/lprsettings.h delete mode 100644 kdeprint/lpr/make_driver_db_lpr.c delete mode 100644 kdeprint/lpr/matichandler.cpp delete mode 100644 kdeprint/lpr/matichandler.h delete mode 100644 kdeprint/lpr/matichelper.cpp delete mode 100644 kdeprint/lpr/matichelper.h delete mode 100644 kdeprint/lpr/printcapentry.cpp delete mode 100644 kdeprint/lpr/printcapentry.h delete mode 100644 kdeprint/lpr/printcapreader.cpp delete mode 100644 kdeprint/lpr/printcapreader.h (limited to 'kdeprint/lpr') diff --git a/kdeprint/lpr/CMakeLists.txt b/kdeprint/lpr/CMakeLists.txt deleted file mode 100644 index c893411b1..000000000 --- a/kdeprint/lpr/CMakeLists.txt +++ /dev/null @@ -1,80 +0,0 @@ -################################################# -# -# (C) 2010 Serghei Amelian -# serghei (DOT) amelian (AT) gmail.com -# -# Improvements and feedback are welcome -# -# This file is released under GPL >= 2 -# -################################################# - -add_definitions( - -D_KDEPRINT_COMPILE -) - -include_directories( - ${TQT_INCLUDE_DIRS} - ${CMAKE_CURRENT_BINARY_DIR} - ${CMAKE_BINARY_DIR} - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_BINARY_DIR}/tdecore - ${CMAKE_SOURCE_DIR} - ${CMAKE_SOURCE_DIR}/dcop - ${CMAKE_SOURCE_DIR}/tdecore - ${CMAKE_SOURCE_DIR}/tdeui - ${CMAKE_SOURCE_DIR}/tdeprint - ${CMAKE_SOURCE_DIR}/tdeprint/management -) - -link_directories( - ${TQT_LIBRARY_DIRS} -) - - -##### headers ################################### - -install( FILES - printcapentry.h lprhandler.h lprsettings.h - DESTINATION ${INCLUDE_INSTALL_DIR}/tdeprint/lpr ) - - -##### other data ################################ - -install( FILES lpr.print DESTINATION ${DATA_INSTALL_DIR}/tdeprint/plugins ) -install( FILES apsdriver1 apsdriver2 lprngtooldriver1 DESTINATION ${DATA_INSTALL_DIR}/tdeprint ) - - -#### tdeprint_lpr ############################### - -set( target tdeprint_lpr ) - -set( ${target}_SRCS - printcapreader.cpp lprhandler.cpp matichandler.cpp - klprfactory.cpp kmlprmanager.cpp kmlpruimanager.cpp - lpchelper.cpp lpqhelper.cpp kmlprjobmanager.cpp - matichelper.cpp klprprinterimpl.cpp printcapentry.cpp - lprsettings.cpp kmconfiglpr.cpp apshandler.cpp - lprngtoolhandler.cpp editentrydialog.cpp -) - -tde_add_kpart( ${target} AUTOMOC - SOURCES ${${target}_SRCS} - LINK tdeprint_management-shared - DESTINATION ${PLUGIN_INSTALL_DIR} -) - - -#### make_driver_db_lpr ######################### - -set( target make_driver_db_lpr ) - -set( ${target}_SRCS - make_driver_db_lpr.c -) - -tde_add_executable( ${target} - SOURCES ${${target}_SRCS} - LINK driverparse-static tdefakes-shared ${DL_LIBRARIES} - DESTINATION ${BIN_INSTALL_DIR} -) diff --git a/kdeprint/lpr/Makefile.am b/kdeprint/lpr/Makefile.am deleted file mode 100644 index a9039888f..000000000 --- a/kdeprint/lpr/Makefile.am +++ /dev/null @@ -1,40 +0,0 @@ -AM_CPPFLAGS = -D_KDEPRINT_COMPILE - -INCLUDES= -I$(top_srcdir) -I$(top_srcdir)/tdeprint -I$(top_srcdir)/tdeprint/management $(all_includes) - -kde_module_LTLIBRARIES = tdeprint_lpr.la - -tdeprint_lpr_la_SOURCES = printcapreader.cpp lprhandler.cpp \ - matichandler.cpp klprfactory.cpp kmlprmanager.cpp \ - kmlpruimanager.cpp lpchelper.cpp lpqhelper.cpp \ - kmlprjobmanager.cpp matichelper.cpp \ - klprprinterimpl.cpp printcapentry.cpp \ - lprsettings.cpp kmconfiglpr.cpp apshandler.cpp \ - lprngtoolhandler.cpp \ - editentrydialog.cpp -tdeprint_lpr_la_LDFLAGS = $(all_libraries) -module -avoid-version -no-undefined -tdeprint_lpr_la_LIBADD = $(top_builddir)/tdeprint/management/libtdeprint_management.la \ - $(LIB_QT) $(LIB_KDEPRINT) $(LIB_KDEUI) $(LIB_KDECORE) -tdeprint_lpr_la_METASOURCES = AUTO - -noinst_HEADERS = printcapreader.h \ - matichandler.h kmlprmanager.h \ - kmlpruimanager.h lpchelper.h lpqhelper.h \ - kmlprjobmanager.h matichelper.h klprprinterimpl.h \ - kmconfiglpr.h apshandler.h \ - lprngtoolhandler.h \ - editentrydialog.h - -tdeprintlpr_HEADERS = printcapentry.h lprhandler.h lprsettings.h -tdeprintlprdir = $(includedir)/tdeprint/lpr - -bin_PROGRAMS = make_driver_db_lpr -make_driver_db_lpr_SOURCES = make_driver_db_lpr.c -make_driver_db_lpr_LDFLAGS = $(all_libraries) -make_driver_db_lpr_LDADD = $(top_builddir)/tdecore/libtdefakes.la ../libdriverparse.a $(LIBDL) - -entry_DATA = lpr.print -entrydir = $(kde_datadir)/tdeprint/plugins - -miscdata_DATA = apsdriver1 apsdriver2 lprngtooldriver1 -miscdatadir = $(kde_datadir)/tdeprint diff --git a/kdeprint/lpr/apsdriver1 b/kdeprint/lpr/apsdriver1 deleted file mode 100644 index fa6bbde0e..000000000 --- a/kdeprint/lpr/apsdriver1 +++ /dev/null @@ -1,84 +0,0 @@ -GROUP|general|General -OPTION|PAPERSIZE|Page Size -CHOICE|a3|A3 -CHOICE|a4|A4 -CHOICE|legal|US Legal -CHOICE|letter|US Letter -CHOICE|ledger|Ledger -CHOICE|tabloid|Tabloid -DEFAULT|a4 -OPTION|COLOR|Color Mode -CHOICE|full|Color -CHOICE|gray|Grayscale -CHOICE|mono|Monochrome -DEFAULT|full -OPTION|QUALITY|Print Quality -CHOICE|draft|Draft -CHOICE|low|Low -CHOICE|medium|Medium -CHOICE|high|High -CHOICE|photo|Photo -DEFAULT|medium -OPTION|RESOLUTION|Print Resolution -CHOICE|150x150|150 DPI -CHOICE|180x180|180 DPI -CHOICE|300x300|300 DPI -CHOICE|360x180|360x180 DPI -CHOICE|360x360|360 DPI -CHOICE|600x600|600 DPI -CHOICE|720x720|720 DPI -CHOICE|1200x1200|1200 DPI -DEFAULT|300x300 -OPTION|METHOD|Print Method -CHOICE|auto|Automatic file conversion -CHOICE|ascii|Treat everything as text -CHOICE|raw|Pass-through mode -DEFAULT|auto -ENDGROUP| -GROUP|advanced|Advanced Settings -GROUP|paper|Paper Settings -OPTION|MEDIA|paper Type -CHOICE|plain|Plain paper -CHOICE|coated|Coated (InkJet) paper -CHOICE|glossy|Glossy paper -CHOICE|premium|Premium (Photo) paper -CHOICE|trans|Transparencies -CHOICE|(empty)|Default printer setting -DEFAULT|(empty) -OPTION|PAPERTRAY|Input Slot -CHOICE|tray0|Tray 0 -CHOICE|tray1|Tray 1 -CHOICE|tray2|Tray 2 -CHOICE|tray3|Tray 3 -CHOICE|tray4|Tray 4 -CHOICE|tray5|Tray 5 -CHOICE|(empty)|Default printer setting -DEFAULT|(empty) -OPTION|DUPLEX|Duplex Printing|BOOLEAN -CHOICE|true|Enabled -CHOICE|false|Disabled -DEFAULT|false -OPTION|BINDING|Paper Binding Edge -CHOICE|short|Short edge -CHOICE|long|Long edge -CHOICE|(empty)|Default printer setting -DEFAULT|(empty) -ENDGROUP| -GROUP|text|File Conversion Settings -OPTION|ASCII_HEADER|Text Header|BOOLEAN -CHOICE|true|Enabled -CHOICE|false|Disabled -DEFAULT|false -OPTION|ASCII_BORDER|Text Border|BOOLEAN -CHOICE|true|Enabled -CHOICE|false|Disabled -DEFAULT|false -OPTION|PRINT_DVI|DVI file converter|STRING -ENDGROUP| -GROUP|gs|Ghostscript Settings -OPTION|GS_FEATURES|Ghostscript options|STRING -OPTION|PS_INIT|Initialisation file|STRING -OPTION|PS_EXIT|Cleanup file|STRING -OPTION|POST_FILTER_OPTS|Post-Ghostscript filter options|STRING -ENDGROUP| -ENDGROUP| diff --git a/kdeprint/lpr/apsdriver2 b/kdeprint/lpr/apsdriver2 deleted file mode 100644 index 69d355f6c..000000000 --- a/kdeprint/lpr/apsdriver2 +++ /dev/null @@ -1,83 +0,0 @@ -GROUP|general|General -OPTION|PageSize|Page Size -CHOICE|a3|A3 -CHOICE|a4|A4 -CHOICE|legal|US Legal -CHOICE|letter|US Letter -CHOICE|ledger|Ledger -CHOICE|tabloid|Tabloid -DEFAULT|a4 -OPTION|MEDIA|Paper Type -CHOICE|plain|Plain paper -CHOICE|coated|Coated (InkJet) paper -CHOICE|glossy|Glossy paper -CHOICE|premium|Premium (Photo) paper -CHOICE|trans|Transparencies -CHOICE|(empty)|Default setting -DEFAULT|(empty) -OPTION|PAPERTRAY|Input Tray -CHOICE|tray0|Tray 0 -CHOICE|tray1|Tray 1 -CHOICE|tray2|Tray 2 -CHOICE|tray3|Tray 3 -CHOICE|tray4|Tray 4 -CHOICE|tray5|Tray 5 -CHOICE|(empty)|Default setting -DEFAULT|(empty) -ENDGROUP| -GROUP|others|Others -OPTION|COLOR|Color Mode -CHOICE|color|Color -CHOICE|gray|Grayscale -CHOICE|mono|Monochrome -CHOICE|(empty)|Default setting -DEFAULT|(empty) -OPTION|DUPLEX|Duplex Printing -CHOICE|duplex|Enabled -CHOICE|simplex|Disabled -CHOICE|(empty)|Default setting -DEFAULT|(empty) -OPTION|BINDING|Paper Binding Edge -CHOICE|shortbind|Short edge -CHOICE|longbind|Long edge -CHOICE|(empty)|Default setting -DEFAULT|(empty) -OPTION|QUALITY|Printing Quality -CHOICE|draft|Draft -CHOICE|low|Low -CHOICE|medium|Medium -CHOICE|high|High -CHOICE|photo|Photo -CHOICE|(empty)|Default setting -DEFAULT|(empty) -OPTION|PS_NUP|Pages per Sheet -CHOICE|1pps|1 -CHOICE|2pps|2 -CHOICE|4pps|4 -CHOICE|8pps|8 -DEFAULT|1pps -OPTION|SWEEP|Communication Type -CHOICE|uni|Unidirectional -CHOICE|bi|Bidirectional -CHOICE|(empty)|Default setting -DEFAULT|(empty) -ENDGROUP| -GROUP|text|Text Printing -OPTION|ASCII_FILTER|Text Converter -CHOICE|a2ps|a2ps -CHOICE|mpage|mpage -CHOICE|enscript|enscript -CHOICE|recode|recode -CHOICE|(empty)|Default setting -DEFAULT|(empty) -OPTION|ASCII_HEADER|Header -CHOICE|header|Enabled -CHOICE|noheader|Disabled -CHOICE|(empty)|Default setting -DEFAULT|(empty) -OPTION|ASCII_BORDER|Border -CHOICE|border|Enabled -CHOICE|noborder|Disabled -CHOICE|(empty)|Default setting -DEFAULT|(empty) -ENDGROUP| diff --git a/kdeprint/lpr/apshandler.cpp b/kdeprint/lpr/apshandler.cpp deleted file mode 100644 index d4107d7c7..000000000 --- a/kdeprint/lpr/apshandler.cpp +++ /dev/null @@ -1,405 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul - * - * 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 "apshandler.h" -#include "driver.h" -#include "printcapentry.h" -#include "kmprinter.h" -#include "lprsettings.h" -#include "kmmanager.h" -#include "util.h" -#include "kprinter.h" - -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -ApsHandler::ApsHandler(KMManager *mgr) -: LprHandler("apsfilter", mgr) -{ - m_counter = 1; -} - -bool ApsHandler::validate(PrintcapEntry *entry) -{ - return (entry->field("if").right(9) == "apsfilter"); -} - -KMPrinter* ApsHandler::createPrinter(PrintcapEntry *entry) -{ - entry->comment = TQString::tqfromLatin1("# APS%1_BEGIN:printer%2").arg(m_counter).arg(m_counter); - entry->postcomment = TQString::tqfromLatin1("# APS%1_END - don't delete this").arg(m_counter); - m_counter++; - return LprHandler::createPrinter(entry); -} - -bool ApsHandler::completePrinter(KMPrinter *prt, PrintcapEntry *entry, bool shortmode) -{ - if (LprHandler::completePrinter(prt, entry, shortmode)) - { - if (!shortmode) - { - TQMap opts = loadResources(entry); - if (opts.contains("PRINTER")) - { - prt->setDescription(i18n("APS Driver (%1)").arg(opts["PRINTER"])); - prt->setDriverInfo(prt->description()); - } - } - if (prt->device().isEmpty()) - { - TQString prot; - TQString smbname(sysconfDir() + "/" + prt->printerName() + "/smbclient.conf"); - TQString ncpname(sysconfDir() + "/" + prt->printerName() + "/netware.conf"); - if (TQFile::exists(smbname)) - { - TQMap opts = loadVarFile(smbname); - if (opts.count() == 0) - prt->setDevice("smb:///"); - else - { - prt->setDevice(buildSmbURI( - opts[ "SMB_WORKGROUP" ], - opts[ "SMB_SERVER" ], - opts[ "SMB_PRINTER" ], - opts[ "SMB_USER" ], - opts[ "SMB_PASSWD" ] ) ); - } - prot = "smb"; - } - else if (TQFile::exists(ncpname)) - { - TQMap opts = loadVarFile(ncpname); - if (opts.count() == 0) - prt->setDevice("ncp:///"); - else - { - TQString uri = buildSmbURI( - TQString::null, - opts[ "NCP_SERVER" ], - opts[ "NCP_PRINTER" ], - opts[ "NCP_USER" ], - opts[ "NCP_PASSWD" ] ); - uri.replace( 0, 3, "ncp" ); - prt->setDevice(uri); - } - prot = "ncp"; - } - if (!prt->device().isEmpty()) - prt->setLocation(i18n("Network printer (%1)").arg(prot)); - } - return true; - } - return false; -} - -TQString ApsHandler::sysconfDir() -{ - return TQFile::encodeName("/etc/apsfilter"); -} - -TQString ApsHandler::shareDir() -{ - return driverDirectory(); -} - -TQString ApsHandler::driverDirInternal() -{ - return locateDir("apsfilter/setup", "/usr/share:/usr/local/share:/opt/share"); -} - -TQMap ApsHandler::loadResources(PrintcapEntry *entry) -{ - return loadVarFile(sysconfDir() + "/" + (entry ? entry->name : TQString::null) + "/apsfilterrc"); -} - -TQMap ApsHandler::loadVarFile(const TQString& filename) -{ - TQMap opts; - TQFile f(filename); - if (f.open(IO_ReadOnly)) - { - TQTextStream t(&f); - TQString line; - int p(-1); - while (!t.atEnd()) - { - line = t.readLine().stripWhiteSpace(); - if (line.isEmpty() || line[0] == '#' || (p = line.find('=')) == -1) - continue; - TQString variable = line.left(p).stripWhiteSpace(); - TQString value = line.mid(p+1).stripWhiteSpace(); - if (!value.isEmpty() && value[0] == '\'') - value = value.mid(1, value.length()-2); - opts[variable] = value; - } - } - return opts; -} - -DrMain* ApsHandler::loadDriver(KMPrinter *prt, PrintcapEntry *entry, bool config) -{ - DrMain *driver = loadApsDriver(config); - if (driver /* && config */ ) // Load resources in all case, to get the correct page size - { - TQMap opts = loadResources(entry); - if ( !config && opts.contains( "PAPERSIZE" ) ) - { - // this is needed to keep applications informed - // about the current selected page size - opts[ "PageSize" ] = opts[ "PAPERSIZE" ]; - - // default page size needs to be set to the actual - // value of the printer driver, otherwise it's blocked - // to A4 - DrBase *opt = driver->findOption( "PageSize" ); - if ( opt ) - opt->set( "default", opts[ "PageSize" ] ); - } - driver->setOptions(opts); - driver->set("gsdriver", opts["PRINTER"]); - } - return driver; -} - -DrMain* ApsHandler::loadDbDriver(const TQString& s) -{ - int p = s.find('/'); - DrMain *driver = loadApsDriver(true); - if (driver) - driver->set("gsdriver", s.mid(p+1)); - return driver; -} - -DrMain* ApsHandler::loadApsDriver(bool config) -{ - DrMain *driver = loadToolDriver(locate("data", (config ? "tdeprint/apsdriver1" : "tdeprint/apsdriver2"))); - if (driver) - driver->set("text", "APS Common Driver"); - return driver; -} - -void ApsHandler::reset() -{ - m_counter = 1; -} - -PrintcapEntry* ApsHandler::createEntry(KMPrinter *prt) -{ - TQString prot = prt->deviceProtocol(); - if (prot != "parallel" && prot != "lpd" && prot != "smb" && prot != "ncp") - { - manager()->setErrorMsg(i18n("Unsupported backend: %1.").arg(prot)); - return NULL; - } - TQString path = sysconfDir() + "/" + prt->printerName(); - if (!KStandardDirs::makeDir(path, 0755)) - { - manager()->setErrorMsg(i18n("Unable to create directory %1.").arg(path)); - return NULL; - } - if (prot == "smb" || prot == "ncp") - { - // either "smb" or "ncp" - TQFile::remove(path + "/smbclient.conf"); - TQFile::remove(path + "/netware.conf"); - TQFile f; - if (prot == "smb") - { - f.setName(path + "/smbclient.conf"); - if (f.open(IO_WriteOnly)) - { - TQTextStream t(&f); - TQString work, server, printer, user, passwd; - if ( splitSmbURI( prt->device(), work, server, printer, user, passwd ) ) - { - if (work.isEmpty()) - { - manager()->setErrorMsg(i18n("Missing element: %1.").arg("Workgroup")); - return NULL; - } - t << "SMB_SERVER='" << server << "'" << endl; - t << "SMB_PRINTER='" << printer << "'" << endl; - t << "SMB_IP=''" << endl; - t << "SMB_WORKGROUP='" << work << "'" << endl; - t << "SMB_BUFFER=1400" << endl; - t << "SMB_FLAGS='-N'" << endl; - if (!user.isEmpty()) - { - t << "SMB_USER='" << user << "'" << endl; - t << "SMB_PASSWD='" << passwd << "'" << endl; - } - } - else - { - manager()->setErrorMsg( i18n( "Invalid printer backend specification: %1" ).arg( prt->device() ) ); - return NULL; - } - } - else - { - manager()->setErrorMsg(i18n("Unable to create the file %1.").arg(f.name())); - return NULL; - } - } - else - { - f.setName(path + "/netware.conf"); - if (f.open(IO_WriteOnly)) - { - TQString work, server, printer, user, passwd; - TQString uri = prt->device(); - uri.replace( 0, 3, "smb" ); - if ( splitSmbURI( uri, work, server, printer, user, passwd ) ) - { - TQTextStream t(&f); - t << "NCP_SERVER='" << server << "'" << endl; - t << "NCP_PRINTER='" << printer << "'" << endl; - if (!user.isEmpty()) - { - t << "NCP_USER='" << user << "'" << endl; - t << "NCP_PASSWD='" << passwd << "'" << endl; - } - } - else - { - manager()->setErrorMsg( i18n( "Invalid printer backend specification: %1" ).arg( prt->device() ) ); - return NULL; - } - } - else - { - manager()->setErrorMsg(i18n("Unable to create the file %1.").arg(f.name())); - return NULL; - } - } - // change file permissions - ::chmod(TQFile::encodeName(f.name()).data(), S_IRUSR|S_IWUSR); - } - PrintcapEntry *entry = LprHandler::createEntry(prt); - if (!entry) - { - entry = new PrintcapEntry; - entry->addField("lp", Field::String, "/dev/null"); - } - TQString sd = LprSettings::self()->baseSpoolDir() + "/" + prt->printerName(); - entry->addField("af", Field::String, sd + "/acct"); - entry->addField("lf", Field::String, sd + "/log"); - entry->addField("if", Field::String, sysconfDir() + "/basedir/bin/apsfilter"); - entry->comment = TQString::tqfromLatin1("# APS%1_BEGIN:printer%2").arg(m_counter).arg(m_counter); - entry->postcomment = TQString::tqfromLatin1("# APS%1_END").arg(m_counter); - m_counter++; - return entry; -} - -bool ApsHandler::savePrinterDriver(KMPrinter *prt, PrintcapEntry *entry, DrMain *driver, bool*) -{ - if (driver->get("gsdriver").isEmpty()) - { - manager()->setErrorMsg(i18n("The APS driver is not defined.")); - return false; - } - TQFile f(sysconfDir() + "/" + prt->printerName() + "/apsfilterrc"); - if (f.open(IO_WriteOnly)) - { - TQTextStream t(&f); - t << "# File generated by KDEPrint" << endl; - t << "PRINTER='" << driver->get("gsdriver") << "'" << endl; - TQValueStack stack; - stack.push(driver); - while (stack.count() > 0) - { - DrGroup *grp = stack.pop(); - TQPtrListIterator git(grp->groups()); - for (; git.current(); ++git) - stack.push(git.current()); - TQPtrListIterator oit(grp->options()); - TQString value; - for (; oit.current(); ++oit) - { - value = oit.current()->valueText(); - switch (oit.current()->type()) - { - case DrBase::Boolean: - if (value == "true") - t << oit.current()->name() << "='" << value << "'" << endl; - break; - case DrBase::List: - if (value != "(empty)") - t << oit.current()->name() << "='" << value << "'" << endl; - break; - case DrBase::String: - if (!value.isEmpty()) - t << oit.current()->name() << "='" << value << "'" << endl; - break; - default: - break; - } - } - } - return true; - } - else - { - manager()->setErrorMsg(i18n("Unable to create the file %1.").arg(f.name())); - return false; - } -} - -bool ApsHandler::removePrinter(KMPrinter*, PrintcapEntry *entry) -{ - TQString path(sysconfDir() + "/" + entry->name); - TQFile::remove(path + "/smbclient.conf"); - TQFile::remove(path + "/netware.conf"); - TQFile::remove(path + "/apsfilterrc"); - if (!TQDir(path).rmdir(path)) - { - manager()->setErrorMsg(i18n("Unable to remove directory %1.").arg(path)); - return false; - } - return true; -} - -TQString ApsHandler::printOptions(KPrinter *printer) -{ - TQString optstr; - TQMap opts = printer->options(); - for (TQMap::ConstIterator it=opts.begin(); it!=opts.end(); ++it) - { - if (it.key().startsWith("kde-") || it.key().startsWith("_kde-") || it.key().startsWith( "app-" )) - continue; - optstr.append((*it)).append(":"); - } - if (!optstr.isEmpty()) - { - optstr = optstr.left(optstr.length()-1); - if (LprSettings::self()->mode() == LprSettings::LPR) - optstr.prepend("-C '").append("'"); - else - optstr.prepend("-Z '").append("'"); - } - return optstr; -} diff --git a/kdeprint/lpr/apshandler.h b/kdeprint/lpr/apshandler.h deleted file mode 100644 index db213d194..000000000 --- a/kdeprint/lpr/apshandler.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul - * - * 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 APSHANDLER_H -#define APSHANDLER_H - -#include "lprhandler.h" - -#include - -class ApsHandler : public LprHandler -{ -public: - ApsHandler(KMManager*); - - bool validate(PrintcapEntry*); - KMPrinter* createPrinter(PrintcapEntry*); - bool completePrinter(KMPrinter*, PrintcapEntry*, bool = true); - DrMain* loadDriver(KMPrinter*, PrintcapEntry*, bool = false); - DrMain* loadDbDriver(const TQString&); - void reset(); - PrintcapEntry* createEntry(KMPrinter*); - bool savePrinterDriver(KMPrinter*, PrintcapEntry*, DrMain*, bool* = 0); - bool removePrinter(KMPrinter*, PrintcapEntry*); - TQString printOptions(KPrinter*); - -protected: - TQString driverDirInternal(); - -private: - TQMap loadResources(PrintcapEntry*); - TQMap loadVarFile(const TQString&); - TQString sysconfDir(); - TQString shareDir(); - DrMain* loadApsDriver(bool = false); - -private: - int m_counter; -}; - -#endif diff --git a/kdeprint/lpr/editentrydialog.cpp b/kdeprint/lpr/editentrydialog.cpp deleted file mode 100644 index 6c4ecc30c..000000000 --- a/kdeprint/lpr/editentrydialog.cpp +++ /dev/null @@ -1,157 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul - * - * 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 "editentrydialog.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -EditEntryDialog::EditEntryDialog(PrintcapEntry *entry, TQWidget *parent, const char *name) -: KDialogBase(parent, name, true, TQString::null, Ok|Cancel) -{ - TQWidget *w = new TQWidget(this); - setMainWidget(w); - - TQLabel *lab0 = new TQLabel(i18n("Aliases:"), w); - m_aliases = new TQLineEdit(w); - m_view = new KListView(w); - m_view->addColumn(""); - m_view->header()->hide(); - m_type = new TQComboBox(w); - m_type->insertItem(i18n("String")); - m_type->insertItem(i18n("Number")); - m_type->insertItem(i18n("Boolean")); - m_stack = new TQWidgetStack(w); - m_boolean = new TQCheckBox(i18n("Enabled"), m_stack); - m_string = new TQLineEdit(m_stack); - m_number = new TQSpinBox(0, 9999, 1, m_stack); - m_stack->addWidget(m_string, 0); - m_stack->addWidget(m_boolean, 2); - m_stack->addWidget(m_number, 1); - m_name = new TQLineEdit(w); - - TQVBoxLayout *l0 = new TQVBoxLayout(w, 0, 10); - TQHBoxLayout *l1 = new TQHBoxLayout(0, 0, 10); - TQHBoxLayout *l2 = new TQHBoxLayout(0, 0, 5); - l0->addLayout(l1); - l1->addWidget(lab0); - l1->addWidget(m_aliases); - l0->addWidget(m_view); - l0->addLayout(l2); - l2->addWidget(m_name, 0); - l2->addWidget(m_type, 0); - l2->addWidget(m_stack, 1); - - if (entry) - { - setCaption(i18n("Printcap Entry: %1").arg(entry->name)); - m_fields = entry->fields; - m_aliases->setText(entry->aliases.join("|")); - TQListViewItem *root = new TQListViewItem(m_view, entry->name), *item = 0; - root->setSelectable(false); - root->setOpen(true); - root->setPixmap(0, SmallIcon("fileprint")); - for (TQMap::ConstIterator it=m_fields.begin(); it!=m_fields.end(); ++it) - item = new TQListViewItem(root, item, (*it).toString(), it.key()); - } - - m_block = true; - enableButton(Ok, false); - slotItemSelected(NULL); - slotTypeChanged(0); - m_block = false; - - connect(m_view, TQT_SIGNAL(selectionChanged(TQListViewItem*)), TQT_SLOT(slotItemSelected(TQListViewItem*))); - connect(m_string, TQT_SIGNAL(textChanged(const TQString&)), TQT_SLOT(slotChanged())); - connect(m_boolean, TQT_SIGNAL(toggled(bool)), TQT_SLOT(slotChanged())); - connect(m_number, TQT_SIGNAL(valueChanged(int)), TQT_SLOT(slotChanged())); - connect(m_type, TQT_SIGNAL(activated(int)), TQT_SLOT(slotTypeChanged(int))); - connect(m_name, TQT_SIGNAL(textChanged(const TQString&)), TQT_SLOT(slotChanged())); - - resize(500,400); -} - -Field EditEntryDialog::createField() -{ - Field f; - f.name = m_name->text(); - f.type = (Field::Type)(m_type->currentItem()); - switch (f.type) - { - case Field::String: f.value = m_string->text(); break; - case Field::Integer: f.value = m_number->cleanText(); break; - case Field::Boolean: f.value = (m_boolean->isChecked() ? "1" : "0"); break; - } - return f; -} - -void EditEntryDialog::slotChanged() -{ - if (!m_block && m_view->currentItem()) - { - Field f = createField(); - if (f.name != m_current) - m_fields.remove(m_current); - m_fields[f.name] = f; - m_view->currentItem()->setText(0, f.toString()); - } -} - -void EditEntryDialog::slotItemSelected(TQListViewItem *item) -{ - m_stack->setEnabled(item); - m_name->setEnabled(item); - m_type->setEnabled(item); - if (item) - { - m_block = true; - m_current = item->text(1); - Field f = m_fields[m_current]; - m_name->setText(f.name); - m_type->setCurrentItem(f.type); - slotTypeChanged(f.type); - m_string->setText(f.value); - m_number->setValue(f.value.toInt()); - m_boolean->setChecked(f.value.toInt() == 1); - m_block = false; - } -} - -void EditEntryDialog::fillEntry(PrintcapEntry *entry) -{ - entry->aliases = TQStringList::split('|', m_aliases->text(), false); - entry->fields = m_fields; -} - -void EditEntryDialog::slotTypeChanged(int ID) -{ - m_stack->raiseWidget(ID); - slotChanged(); -} - -#include "editentrydialog.moc" diff --git a/kdeprint/lpr/editentrydialog.h b/kdeprint/lpr/editentrydialog.h deleted file mode 100644 index f4359dd89..000000000 --- a/kdeprint/lpr/editentrydialog.h +++ /dev/null @@ -1,62 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul - * - * 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 EDITENTRYDIALOG_H -#define EDITENTRYDIALOG_H - -#include -#include "printcapentry.h" - -class TQLineEdit; -class TQCheckBox; -class TQSpinBox; -class TQComboBox; -class TQListView; -class TQListviewItem; -class TQWidgetStack; - -class EditEntryDialog : public KDialogBase -{ - Q_OBJECT -public: - EditEntryDialog(PrintcapEntry *entry, TQWidget *parent = 0, const char *name = 0); - - void fillEntry(PrintcapEntry *entry); - -protected slots: - void slotItemSelected(TQListViewItem*); - void slotChanged(); - void slotTypeChanged(int); - -protected: - Field createField(); - -private: - TQMap m_fields; - TQLineEdit *m_name, *m_string, *m_aliases; - TQCheckBox *m_boolean; - TQComboBox *m_type; - TQSpinBox *m_number; - TQListView *m_view; - TQWidgetStack *m_stack; - TQString m_current; - bool m_block; -}; - -#endif diff --git a/kdeprint/lpr/klprfactory.cpp b/kdeprint/lpr/klprfactory.cpp deleted file mode 100644 index 4764dfc6a..000000000 --- a/kdeprint/lpr/klprfactory.cpp +++ /dev/null @@ -1,29 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul - * - * 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 "kmlprmanager.h" -#include "kmlpruimanager.h" -#include "kmlprjobmanager.h" -#include "klprprinterimpl.h" - -#include - -typedef K_TYPELIST_4( KMLprManager, KMLprUiManager, KMLprJobManager, KLprPrinterImpl ) Products; -K_EXPORT_COMPONENT_FACTORY( tdeprint_lpr, KGenericFactory< Products > ) - diff --git a/kdeprint/lpr/klprprinterimpl.cpp b/kdeprint/lpr/klprprinterimpl.cpp deleted file mode 100644 index 70356f23c..000000000 --- a/kdeprint/lpr/klprprinterimpl.cpp +++ /dev/null @@ -1,59 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul - * - * 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 "klprprinterimpl.h" -#include "kprinter.h" -#include "kmlprmanager.h" - -#include -#include -#include - -KLprPrinterImpl::KLprPrinterImpl(TQObject *parent, const char *name, const TQStringList & /*args*/) -: KPrinterImpl(parent,name) -{ - m_exepath = KStandardDirs::findExe("lpr"); -} - -KLprPrinterImpl::~KLprPrinterImpl() -{ -} - -bool KLprPrinterImpl::setupCommand(TQString& cmd, KPrinter *printer) -{ - // check printer object - if (!printer || m_exepath.isEmpty()) - return false; - - cmd = TQString::tqfromLatin1("%1 -P %1 '-#%1'").arg(m_exepath).arg(quote(printer->printerName())).arg( printer->numCopies() ); - QString opts = static_cast(KMManager::self())->printOptions(printer); - if (!opts.isEmpty()) - cmd += (" " + opts); - return true; -} - -void KLprPrinterImpl::broadcastOption(const TQString& key, const TQString& value) -{ - KPrinterImpl::broadcastOption(key,value); - if (key == "kde-pagesize") - { - QString pagename = TQString::tqfromLatin1(pageSizeToPageName((KPrinter::PageSize)value.toInt())); - KPrinterImpl::broadcastOption("PageSize",pagename); - } -} diff --git a/kdeprint/lpr/klprprinterimpl.h b/kdeprint/lpr/klprprinterimpl.h deleted file mode 100644 index 508173f1d..000000000 --- a/kdeprint/lpr/klprprinterimpl.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul - * - * 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 KLPRPRINTERIMPL_H -#define KLPRPRINTERIMPL_H - -#include "kprinterimpl.h" - -class KLprPrinterImpl : public KPrinterImpl -{ -public: - KLprPrinterImpl(TQObject *parent, const char *name, const TQStringList & /*args*/); - ~KLprPrinterImpl(); - - bool setupCommand(TQString&, KPrinter*); - void broadcastOption(const TQString& key, const TQString& value); - -private: - QString m_exepath; -}; - -#endif diff --git a/kdeprint/lpr/kmconfiglpr.cpp b/kdeprint/lpr/kmconfiglpr.cpp deleted file mode 100644 index f43a8da2d..000000000 --- a/kdeprint/lpr/kmconfiglpr.cpp +++ /dev/null @@ -1,66 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul - * - * 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 "kmconfiglpr.h" -#include "lprsettings.h" - -#include -#include -#include -#include -#include -#include - -KMConfigLpr::KMConfigLpr(TQWidget *parent, const char *name) -: KMConfigPage(parent, name) -{ - setPageName(i18n("Spooler")); - setPageHeader(i18n("Spooler Settings")); - setPagePixmap("gear"); - - TQGroupBox *m_modebox = new TQGroupBox(1, Qt::Vertical, i18n("Spooler"), this); - - m_mode = new TQComboBox(m_modebox); - m_mode->insertItem("LPR (BSD compatible)"); - m_mode->insertItem("LPRng"); - - TQVBoxLayout *l0 = new TQVBoxLayout(this, 5, 10); - l0->addWidget(m_modebox); - l0->addStretch(1); -} - -void KMConfigLpr::loadConfig(KConfig*) -{ - m_mode->setCurrentItem(LprSettings::self()->mode()); -} - -void KMConfigLpr::saveConfig(KConfig *conf) -{ - LprSettings::self()->setMode((LprSettings::Mode)(m_mode->currentItem())); - - TQString modestr; - switch (m_mode->currentItem()) - { - default: - case 0: modestr = "LPR"; break; - case 1: modestr = "LPRng"; break; - } - conf->setGroup("LPR"); - conf->writeEntry("Mode", modestr); -} diff --git a/kdeprint/lpr/kmconfiglpr.h b/kdeprint/lpr/kmconfiglpr.h deleted file mode 100644 index 7f3d50857..000000000 --- a/kdeprint/lpr/kmconfiglpr.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul - * - * 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 KMCONFIGLPR_H -#define KMCONFIGLPR_H - -#include "kmconfigpage.h" - -class TQComboBox; - -class KMConfigLpr : public KMConfigPage -{ -public: - KMConfigLpr(TQWidget *parent = 0, const char *name = 0); - - void loadConfig(KConfig*); - void saveConfig(KConfig*); - -private: - TQComboBox *m_mode; -}; - -#endif diff --git a/kdeprint/lpr/kmlprjobmanager.cpp b/kdeprint/lpr/kmlprjobmanager.cpp deleted file mode 100644 index 851663664..000000000 --- a/kdeprint/lpr/kmlprjobmanager.cpp +++ /dev/null @@ -1,90 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul - * - * 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 "kmlprjobmanager.h" -#include "kmlprmanager.h" -#include "lpqhelper.h" -#include "lpchelper.h" -#include "kmjob.h" -#include "lprsettings.h" - -#include -#include - -KMLprJobManager::KMLprJobManager(TQObject *parent, const char *name, const TQStringList & /*args*/) -: KMJobManager(parent, name) -{ - m_lpqhelper = new LpqHelper(this, "LpqHelper"); -} - -bool KMLprJobManager::listJobs(const TQString& prname, JobType, int limit) -{ - TQPtrList jobList; - jobList.setAutoDelete(false); - m_lpqhelper->listJobs(jobList, prname, limit); - TQPtrListIterator it(jobList); - for (; it.current(); ++it) - addJob(it.current()); - return false; -} - -LpcHelper* KMLprJobManager::lpcHelper() -{ - return static_cast(KMManager::self())->lpcHelper(); -} - -int KMLprJobManager::actions() -{ - if (LprSettings::self()->mode() == LprSettings::LPR) - return KMJob::Remove; - else - // some additional actions to be added here - return (KMJob::Remove | KMJob::Hold | KMJob::Resume); -} - -bool KMLprJobManager::sendCommandSystemJob(const TQPtrList& jobs, int action, const TQString& arg) -{ - TQString msg; - TQPtrListIterator it(jobs); - bool status(true); - LpcHelper *helper = lpcHelper(); - - for (; it.current() && status; ++it) - { - switch (action) - { - case KMJob::Remove: - status = helper->removeJob(it.current(), msg); - break; - case KMJob::Hold: - status = helper->changeJobState(it.current(), KMJob::Held, msg); - break; - case KMJob::Resume: - status = helper->changeJobState(it.current(), KMJob::Queued, msg); - break; - default: - status = false; - msg = i18n("Unsupported operation."); - break; - } - } - if (!status && !msg.isEmpty()) - KMManager::self()->setErrorMsg(msg); - return status; -} diff --git a/kdeprint/lpr/kmlprjobmanager.h b/kdeprint/lpr/kmlprjobmanager.h deleted file mode 100644 index d9a8eae3f..000000000 --- a/kdeprint/lpr/kmlprjobmanager.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul - * - * 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 KMLPRJOBMANAGER_H -#define KMLPRJOBMANAGER_H - -#include "kmjobmanager.h" - -class LpqHelper; -class LpcHelper; - -class KMLprJobManager : public KMJobManager -{ -public: - KMLprJobManager(TQObject *parent, const char *name, const TQStringList & /*args*/); - - int actions(); - -protected: - bool listJobs(const TQString&, JobType, int = 0); - LpcHelper* lpcHelper(); - bool sendCommandSystemJob(const TQPtrList&, int, const TQString& = TQString::null); - -private: - LpqHelper *m_lpqhelper; -}; - -#endif diff --git a/kdeprint/lpr/kmlprmanager.cpp b/kdeprint/lpr/kmlprmanager.cpp deleted file mode 100644 index cf4dbbb94..000000000 --- a/kdeprint/lpr/kmlprmanager.cpp +++ /dev/null @@ -1,492 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul - * - * 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 "kmlprmanager.h" -#include "printcapreader.h" -#include "printcapentry.h" -#include "lpchelper.h" -#include "matichandler.h" -#include "apshandler.h" -#include "lprngtoolhandler.h" -#include "lprsettings.h" -#include "driver.h" -#include "editentrydialog.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -KMLprManager::KMLprManager(TQObject *parent, const char *name, const TQStringList & /*args*/) -: KMManager(parent,name) -{ - m_handlers.setAutoDelete(true); - m_handlerlist.setAutoDelete(false); - m_entries.setAutoDelete(true); - - m_lpchelper = new LpcHelper(this); - m_currentprinter = 0; - - setHasManagement(getuid() == 0); - setPrinterOperationMask( - KMManager::PrinterEnabling | - KMManager::PrinterConfigure | - KMManager::PrinterTesting | - KMManager::PrinterCreation | - KMManager::PrinterRemoval | - KMManager::PrinterTesting - ); - - initHandlers(); -} - -void KMLprManager::listPrinters() -{ - TQFileInfo fi(LprSettings::self()->printcapFile()); - - if (m_lpchelper) - m_lpchelper->updateStates(); - - // update only if needed - if (!m_updtime.isValid() || m_updtime < fi.lastModified()) - { - // cleanup previous entries - m_entries.clear(); - // notify handlers - TQPtrListIterator hit(m_handlerlist); - for (; hit.current(); ++hit) - hit.current()->reset(); - - // try to open the printcap file and parse it - PrintcapReader reader; - TQFile f(fi.absFilePath()); - PrintcapEntry *entry; - if (f.exists() && f.open(IO_ReadOnly)) - { - reader.setPrintcapFile(&f); - while ((entry = reader.nextEntry()) != NULL) - { - TQPtrListIterator it(m_handlerlist); - for (; it.current(); ++it) - if (it.current()->validate(entry)) - { - KMPrinter *prt = it.current()->createPrinter(entry); - checkPrinterState(prt); - prt->setOption("kde-lpr-handler", it.current()->name()); - addPrinter(prt); - break; - } - m_entries.insert(entry->name, entry); - } - } - - // save update time - m_updtime = fi.lastModified(); - } - else - { - TQPtrListIterator it(m_printers); - for (; it.current(); ++it) - if (!it.current()->isSpecial()) - { - it.current()->setDiscarded(false); - checkPrinterState(it.current()); - } - } -} - -void KMLprManager::insertHandler(LprHandler *handler) -{ - m_handlers.insert(handler->name(), handler); - m_handlerlist.append(handler); - kdDebug() << "Handler: " << handler->name() << endl; -} - -void KMLprManager::initHandlers() -{ - m_handlers.clear(); - m_handlerlist.clear(); - - insertHandler(new MaticHandler(this)); - insertHandler(new ApsHandler(this)); - insertHandler(new LPRngToolHandler(this)); - - // now load external handlers - TQStringList l = KGlobal::dirs()->findAllResources("data", "tdeprint/lpr/*.la"); - for (TQStringList::ConstIterator it=l.begin(); it!=l.end(); ++it) - { - KLibrary *library = KLibLoader::self()->library(TQFile::encodeName(*it)); - if (library) - { - kdDebug() << "loading external handler from " << *it << endl; - LprHandler*(*func)(KMManager*) = (LprHandler*(*)(KMManager*))(library->symbol("create_handler")); - if (func) - insertHandler(func(this)); - else - kdDebug() << "couldn't find the symbol 'create_handler'" << endl; - } - } - - // default handler - insertHandler(new LprHandler("default", this)); -} - -LprHandler* KMLprManager::findHandler(KMPrinter *prt) -{ - TQString handlerstr(prt->option("kde-lpr-handler")); - LprHandler *handler(0); - if (handlerstr.isEmpty() || (handler = m_handlers.find(handlerstr)) == NULL) - { - return NULL; - } - return handler; -} - -PrintcapEntry* KMLprManager::findEntry(KMPrinter *prt) -{ - PrintcapEntry *entry = m_entries.find(prt->printerName()); - if (!entry) - { - return NULL; - } - return entry; -} - -bool KMLprManager::completePrinter(KMPrinter *prt) -{ - LprHandler *handler = findHandler(prt); - PrintcapEntry *entry = findEntry(prt); - if (handler && entry) - return handler->completePrinter(prt, entry, false); - return false; -} - -bool KMLprManager::completePrinterShort(KMPrinter *prt) -{ - LprHandler *handler = findHandler(prt); - PrintcapEntry *entry = findEntry(prt); - if (!handler || !entry) - return false; - - return handler->completePrinter(prt, entry, true); -} - -void KMLprManager::checkPrinterState(KMPrinter *prt) -{ - if (m_lpchelper) - { - KMPrinter::PrinterState st = m_lpchelper->state(prt); - prt->setState(st); - prt->setAcceptJobs(!(st & KMPrinter::Rejecting)); - } - else - { - prt->setState(KMPrinter::Idle); - prt->setAcceptJobs(true); - } -} - -DrMain* KMLprManager::loadPrinterDriver(KMPrinter *prt, bool config) -{ - if (!prt) - return NULL; - - LprHandler *handler = findHandler(prt); - PrintcapEntry *entry = findEntry(prt); - if (handler && entry) - { - DrMain *driver = handler->loadDriver(prt, entry, config); - if (driver) - driver->set("handler", handler->name()); - return driver; - } - return NULL; -} - -DrMain* KMLprManager::loadFileDriver(const TQString& filename) -{ - int p = filename.find('/'); - TQString handler_str = (p != -1 ? filename.left(p) : TQString::tqfromLatin1("default")); - LprHandler *handler = m_handlers.find(handler_str); - if (handler) - { - DrMain *driver = handler->loadDbDriver(filename); - if (driver) - driver->set("handler", handler->name()); - return driver; - } - return NULL; -} - -bool KMLprManager::enablePrinter(KMPrinter *prt, bool state) -{ - TQString msg; - if (!m_lpchelper->enable(prt, state, msg)) - { - setErrorMsg(msg); - return false; - } - return true; -} - -bool KMLprManager::startPrinter(KMPrinter *prt, bool state) -{ - TQString msg; - if (!m_lpchelper->start(prt, state, msg)) - { - setErrorMsg(msg); - return false; - } - return true; -} - -bool KMLprManager::savePrinterDriver(KMPrinter *prt, DrMain *driver) -{ - LprHandler *handler = findHandler(prt); - PrintcapEntry *entry = findEntry(prt); - if (handler && entry) - { - bool mustSave(false); - if (handler->savePrinterDriver(prt, entry, driver, &mustSave)) - { - if (mustSave) - return savePrintcapFile(); - return true; - } - } - return false; -} - -bool KMLprManager::savePrintcapFile() -{ - if (!LprSettings::self()->isLocalPrintcap()) - { - setErrorMsg(i18n("The printcap file is a remote file (NIS). It cannot be written.")); - return false; - } - TQFile f(LprSettings::self()->printcapFile()); - if (f.open(IO_WriteOnly)) - { - TQTextStream t(&f); - TQDictIterator it(m_entries); - for (; it.current(); ++it) - { - it.current()->writeEntry(t); - } - return true; - } - else - { - setErrorMsg(i18n("Unable to save printcap file. Check that " - "you have write permissions for that file.")); - return false; - } -} - -bool KMLprManager::createPrinter(KMPrinter *prt) -{ - // remove existing printcap entry - PrintcapEntry *oldEntry = m_entries.find(prt->printerName()); - - // look for the handler and re-create entry - LprHandler *handler(0); - // To look for the handler, either we base ourselves - // on the driver (1: new printer, 2: modifying driver) - // or we use the handler of the existing printer - // (modifying something else, handler stays the same) - if (prt->driver()) - handler = m_handlers.find(prt->driver()->get("handler")); - else if (oldEntry) - handler = findHandler(prt); - else - handler = m_handlers.find("default"); - if (!handler) - { - setErrorMsg(i18n("Internal error: no handler defined.")); - return false; - } - prt->setOption("kde-lpr-handler", handler->name()); - - // we reload the driver if the printer object doesn't have one - // and there's an old entry (sometimes needed to keep the backend - // like in Foomatic) - if (!prt->driver() && oldEntry) - prt->setDriver(handler->loadDriver(prt, oldEntry, true)); - - TQString sd = LprSettings::self()->baseSpoolDir(); - if (sd.isEmpty()) - { - setErrorMsg(i18n("Couldn't determine spool directory. See options dialog.")); - return false; - } - sd.append("/").append(prt->printerName()); - if (!KStandardDirs::makeDir(sd, 0755)) - { - setErrorMsg(i18n("Unable to create the spool directory %1. Check that you " - "have the required permissions for that operation.").arg(sd)); - return false; - } - PrintcapEntry *entry = handler->createEntry(prt); - if (!entry) - return false; // error should be set in the handler - // old entry can be removed now - m_entries.remove(prt->printerName()); - entry->name = prt->printerName(); - entry->addField("sh", Field::Boolean); - entry->addField("mx", Field::Integer, "0"); - entry->addField("sd", Field::String, sd); - if (!prt->option("kde-aliases").isEmpty()) - entry->aliases += TQStringList::split("|", prt->option("kde-aliases"), false); - - // insert the new entry and save printcap file - m_entries.insert(prt->printerName(), entry); - bool result = savePrintcapFile(); - if (result) - { - if (prt->driver()) - { - result = handler->savePrinterDriver(prt, entry, prt->driver()); - } - - // in case of LPRng, we need to tell the daemon about new printer - if (LprSettings::self()->mode() == LprSettings::LPRng) - { - TQString msg; - if (!m_lpchelper->restart(msg)) - { - setErrorMsg(i18n("The printer has been created but the print daemon " - "could not be restarted. %1").arg(msg)); - return false; - } - } - } - return result; -} - -bool KMLprManager::removePrinter(KMPrinter *prt) -{ - LprHandler *handler = findHandler(prt); - PrintcapEntry *entry = findEntry(prt); - if (handler && entry) - { - if (handler->removePrinter(prt, entry)) - { - TQString sd = entry->field("sd"); - // first try to save the printcap file, and if - // successful, remove the spool directory - m_entries.take(prt->printerName()); - bool status = savePrintcapFile(); - if (status) - { - // printcap file saved, entry can be deleted now - delete entry; - status = (::system(TQFile::encodeName("rm -rf " + KProcess::quote(sd))) == 0); - if (!status) - setErrorMsg(i18n("Unable to remove spool directory %1. " - "Check that you have write permissions " - "for that directory.").arg(sd)); - return status; - } - else - // push back the non-removed entry - m_entries.insert(prt->printerName(), entry); - } - } - return false; -} - -TQString KMLprManager::driverDbCreationProgram() -{ - return TQString::tqfromLatin1("make_driver_db_lpr"); -} - -TQString KMLprManager::driverDirectory() -{ - TQPtrListIterator it(m_handlerlist); - TQString dbDirs; - for (; it.current(); ++it) - { - TQString dir = it.current()->driverDirectory(); - if (!dir.isEmpty()) - dbDirs.append(dir).append(":"); - } - if (!dbDirs.isEmpty()) - dbDirs.truncate(dbDirs.length()-1); - return dbDirs; -} - -TQString KMLprManager::printOptions(KPrinter *prt) -{ - KMPrinter *mprt = findPrinter(prt->printerName()); - TQString opts; - if (mprt) - { - LprHandler *handler = findHandler(mprt); - if (handler) - return handler->printOptions(prt); - } - return TQString::null; -} - -void KMLprManager::createPluginActions(KActionCollection *coll) -{ - KAction *act = new KAction(i18n("&Edit printcap Entry..."), "tdeprint_report", 0, this, TQT_SLOT(slotEditPrintcap()), coll, "plugin_editprintcap"); - act->setGroup("plugin"); -} - -void KMLprManager::validatePluginActions(KActionCollection *coll, KMPrinter *prt) -{ - m_currentprinter = prt; - // FIXME: disabled until completion - coll->action("plugin_editprintcap")->setEnabled(0 && hasManagement() && prt && !prt->isSpecial()); -} - -void KMLprManager::slotEditPrintcap() -{ - if (!m_currentprinter || - KMessageBox::warningContinueCancel(NULL, - i18n("Editing a printcap entry manually should only be " - "done by confirmed system administrator. This may " - "prevent your printer from working. Do you want to " - "continue?"), TQString::null, KStdGuiItem::cont(), - "editPrintcap") == KMessageBox::Cancel) - return; - - PrintcapEntry *entry = findEntry(m_currentprinter); - EditEntryDialog dlg(entry, NULL); - if (dlg.exec()) - { - } -} - -TQString KMLprManager::stateInformation() -{ - return i18n("Spooler type: %1").arg(LprSettings::self()->mode() == LprSettings::LPR ? "LPR (BSD compatible)" : "LPRng"); -} - -#include "kmlprmanager.moc" diff --git a/kdeprint/lpr/kmlprmanager.h b/kdeprint/lpr/kmlprmanager.h deleted file mode 100644 index 34d38340f..000000000 --- a/kdeprint/lpr/kmlprmanager.h +++ /dev/null @@ -1,82 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul - * - * 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 KMLRMANAGER_H -#define KMLRMANAGER_H - -#include "kmmanager.h" - -#include -#include -#include -#include - -class LprHandler; -class PrintcapEntry; -class LpcHelper; -class KPrinter; - -class KMLprManager : public KMManager -{ - Q_OBJECT -public: - KMLprManager(TQObject *parent, const char *name, const TQStringList & /*args*/); - - bool completePrinter(KMPrinter*); - bool completePrinterShort(KMPrinter*); - bool enablePrinter(KMPrinter*, bool); - bool startPrinter(KMPrinter*, bool); - bool savePrinterDriver(KMPrinter*, DrMain*); - DrMain* loadPrinterDriver(KMPrinter*, bool = false); - DrMain* loadFileDriver(const TQString&); - bool createPrinter(KMPrinter*); - bool removePrinter(KMPrinter*); - - TQString driverDbCreationProgram(); - TQString driverDirectory(); - - LpcHelper* lpcHelper() { return m_lpchelper; } - TQString printOptions(KPrinter*); - - void createPluginActions(KActionCollection*); - void validatePluginActions(KActionCollection*, KMPrinter*); - TQString stateInformation(); - -protected slots: - void slotEditPrintcap(); - -protected: - void listPrinters(); - void initHandlers(); - void insertHandler(LprHandler*); - PrintcapEntry* findEntry(KMPrinter*); - LprHandler* findHandler(KMPrinter*); - void checkPrinterState(KMPrinter*); - bool savePrintcapFile(); - -private: - TQDict m_handlers; - TQPtrList m_handlerlist; - TQDict m_entries; - TQDateTime m_updtime; - LpcHelper *m_lpchelper; - KMPrinter *m_currentprinter; -}; - -#endif diff --git a/kdeprint/lpr/kmlpruimanager.cpp b/kdeprint/lpr/kmlpruimanager.cpp deleted file mode 100644 index 655309e0c..000000000 --- a/kdeprint/lpr/kmlpruimanager.cpp +++ /dev/null @@ -1,67 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul - * - * 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 "kmlpruimanager.h" -#include "kmpropertypage.h" -#include "kprinterpropertydialog.h" -#include "kpqtpage.h" -#include "kmconfigdialog.h" - -#include "kmpropdriver.h" -#include "kmpropbackend.h" -#include "kmwizard.h" -#include "kmwbackend.h" -#include "kmconfiglpr.h" - -#include - -KMLprUiManager::KMLprUiManager(TQObject *parent, const char *name, const TQStringList & /*args*/) -: KMUiManager(parent,name) -{ -} - -KMLprUiManager::~KMLprUiManager() -{ -} - -void KMLprUiManager::setupPropertyPages(KMPropertyPage *pages) -{ - pages->addPropPage(new KMPropBackend(pages, "Backend")); - pages->addPropPage(new KMPropDriver(pages, "Driver")); -} - -void KMLprUiManager::setupPrinterPropertyDialog(KPrinterPropertyDialog *dlg) -{ - dlg->addPage(new KPQtPage(dlg->driver(), dlg, "QtPage")); -} - -void KMLprUiManager::setupWizard(KMWizard *wizard) -{ - KMWBackend *backend = wizard->backendPage(); - - backend->addBackend(KMWizard::Local, true); - backend->addBackend(KMWizard::LPD, true); - backend->addBackend(KMWizard::TCP, true); - backend->addBackend(KMWizard::SMB, true, KMWizard::Password); -} - -void KMLprUiManager::setupConfigDialog(KMConfigDialog *dlg) -{ - dlg->addConfigPage(new KMConfigLpr(dlg)); -} diff --git a/kdeprint/lpr/kmlpruimanager.h b/kdeprint/lpr/kmlpruimanager.h deleted file mode 100644 index 561f93500..000000000 --- a/kdeprint/lpr/kmlpruimanager.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul - * - * 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 KMLPRUIMANAGER_H -#define KMLPRUIMANAGER_H - -#include "kmuimanager.h" - -class KMLprUiManager : public KMUiManager -{ -public: - KMLprUiManager(TQObject *parent, const char *name, const TQStringList & /*args*/); - ~KMLprUiManager(); - - void setupPropertyPages(KMPropertyPage*); - void setupPrinterPropertyDialog(KPrinterPropertyDialog*); - void setupWizard(KMWizard*); - void setupConfigDialog(KMConfigDialog*); -}; - -#endif diff --git a/kdeprint/lpr/lpchelper.cpp b/kdeprint/lpr/lpchelper.cpp deleted file mode 100644 index c921a803c..000000000 --- a/kdeprint/lpr/lpchelper.cpp +++ /dev/null @@ -1,320 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul - * - * 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 "lpchelper.h" -#include "kpipeprocess.h" -#include "kmjob.h" -#include "lprsettings.h" - -#include -#include -#include -#include -#include -#include -#include - -static TQString execute(const TQString& cmd) -{ - KPipeProcess proc; - TQString output; - if (proc.open(cmd)) - { - TQTextStream t(&proc); - while (!t.atEnd()) - output.append(t.readLine()).append("\n"); - proc.close(); - } - return output; -} - -LpcHelper::LpcHelper(TQObject *parent, const char *name) -: TQObject(parent, name) -{ - // look for the "lpc" executable. Use the PATH variable and - // add some specific dirs. - TQString PATH = getenv("PATH"); - PATH.append(":/usr/sbin:/usr/local/sbin:/sbin:/opt/sbin:/opt/local/sbin"); - m_exepath = KStandardDirs::findExe("lpc", PATH); - m_checkpcpath = KStandardDirs::findExe("checkpc", PATH); - m_lprmpath = KStandardDirs::findExe("lprm"); -} - -LpcHelper::~LpcHelper() -{ -} - -KMPrinter::PrinterState LpcHelper::state(const TQString& prname) const -{ - if (m_state.contains(prname)) - return m_state[prname]; - return KMPrinter::Unknown; -} - -KMPrinter::PrinterState LpcHelper::state(KMPrinter *prt) const -{ - return state(prt->printerName()); -} - -void LpcHelper::parseStatusLPR(TQTextStream &t) -{ - TQString printer, line; - int p(-1); - - while (!t.atEnd()) - { - line = t.readLine(); - if (line.isEmpty()) - continue; - else if (!line[0].isSpace() && (p = line.find(':')) != -1) - { - printer = line.left(p); - m_state[printer] = KMPrinter::Idle; - } - else if (line.find("printing is disabled") != -1) - { - if (!printer.isEmpty()) - m_state[printer] = KMPrinter::PrinterState((KMPrinter::Stopped) | (m_state[printer] & ~KMPrinter::StateMask)); - } - else if (line.find("queuing is disabled") != -1) - { - if (!printer.isEmpty()) - m_state[printer] = KMPrinter::PrinterState((KMPrinter::Rejecting) | (m_state[printer] & KMPrinter::StateMask)); - } - else if (line.find("entries") != -1) - { - if (!printer.isEmpty() && - (m_state[printer] & KMPrinter::StateMask) != KMPrinter::Stopped && - line.find("no entries") == -1) - m_state[printer] = KMPrinter::PrinterState((m_state[printer] & ~KMPrinter::StateMask) | KMPrinter::Processing); - } - } -} - -void LpcHelper::parseStatusLPRng(TQTextStream& t) -{ - TQStringList l; - int p(-1); - TQString printer; - - while (!t.atEnd()) - if (t.readLine().stripWhiteSpace().startsWith("Printer")) - break; - while (!t.atEnd()) - { - l = TQStringList::split(TQRegExp("\\s"), t.readLine(), false); - if (l.count() < 4) - continue; - p = l[0].find('@'); - if (p == 0) - printer = l[0]; - else - printer = l[0].left(p); - int st(0); - if (l[1] == "disabled") - st = KMPrinter::Stopped; - else if (l[3] != "0") - st = KMPrinter::Processing; - else - st = KMPrinter::Idle; - if (l[2] == "disabled") - st |= KMPrinter::Rejecting; - m_state[printer] = KMPrinter::PrinterState(st); - } -} - -void LpcHelper::updateStates() -{ - KPipeProcess proc; - - m_state.clear(); - if (!m_exepath.isEmpty() && proc.open(m_exepath + " status all")) - { - TQTextStream t(&proc); - - switch (LprSettings::self()->mode()) - { - default: - case LprSettings::LPR: - parseStatusLPR(t); - break; - case LprSettings::LPRng: - parseStatusLPRng(t); - break; - } - proc.close(); - } - -} - -bool LpcHelper::enable(KMPrinter *prt, bool state, TQString& msg) -{ - int st = m_state[prt->printerName()] & KMPrinter::StateMask; - if (changeState(prt->printerName(), (state ? "enable" : "disable"), msg)) - { - m_state[prt->printerName()] = KMPrinter::PrinterState((state ? KMPrinter::Rejecting : 0) | st); - return true; - } - return false; -} - -bool LpcHelper::start(KMPrinter *prt, bool state, TQString& msg) -{ - int rej = m_state[prt->printerName()] & ~KMPrinter::StateMask; - if (changeState(prt->printerName(), (state ? "start" : "stop"), msg)) - { - m_state[prt->printerName()] = KMPrinter::PrinterState((state ? KMPrinter::Idle : KMPrinter::Stopped) | rej); - return true; - } - return false; -} - -// status -// 0 : success -// -1 : permission denied -// -2 : unknown printer -// 1 : unknown error -int LpcHelper::parseStateChangeLPR(const TQString& result, const TQString& printer) -{ - if (result.startsWith(printer + ":")) - return 0; - else if (result.startsWith("?Privileged")) - return -1; - else if (result.startsWith("unknown")) - return -2; - else - return 1; -} - -static TQString lprngAnswer(const TQString& result, const TQString& printer) -{ - int p, q; - - p = result.find("\n" + printer); - if (p != -1) - { - q = result.find(':', p)+2; - p = result.find('\n', q); - TQString answer = result.mid(q, p-q).stripWhiteSpace(); - return answer; - } - return TQString::null; -} - -int LpcHelper::parseStateChangeLPRng(const TQString& result, const TQString& printer) -{ - TQString answer = lprngAnswer(result, printer); - if (answer == "no") - return -1; - else if (answer == "disabled" || answer == "enabled" || answer == "started" || answer == "stopped") - return 0; - else - return 1; -} - -bool LpcHelper::changeState(const TQString& printer, const TQString& op, TQString& msg) -{ - if (m_exepath.isEmpty()) - { - msg = i18n("The executable %1 couldn't be found in your PATH.").arg("lpc"); - return false; - } - TQString result = execute(m_exepath + " " + op + " " + KProcess::quote(printer)); - int status; - - switch (LprSettings::self()->mode()) - { - default: - case LprSettings::LPR: - status = parseStateChangeLPR(result, printer); - break; - case LprSettings::LPRng: - status = parseStateChangeLPRng(result, printer); - break; - } - switch (status) - { - case 0: - break; - case -1: - msg = i18n("Permission denied."); - break; - case -2: - msg = i18n("Printer %1 does not exist.").arg(printer); - break; - default: - case 1: - msg = i18n("Unknown error: %1").arg(result.replace(TQRegExp("\\n"), " ")); - break; - } - return (status == 0); -} - -bool LpcHelper::removeJob(KMJob *job, TQString& msg) -{ - if (m_lprmpath.isEmpty()) - { - msg = i18n("The executable %1 couldn't be found in your PATH.").arg("lprm"); - return false; - } - TQString result = execute(m_lprmpath + " -P " + KProcess::quote(job->printer()) + " " + TQString::number(job->id())); - if (result.find("dequeued") != -1) - return true; - else if (result.find("Permission denied") != -1 || result.find("no permissions") != -1) - msg = i18n("Permission denied."); - else - msg = i18n("Execution of lprm failed: %1").arg(result); - return false; -} - -// LPRng only -bool LpcHelper::changeJobState(KMJob *job, int state, TQString& msg) -{ - if (m_lprmpath.isEmpty()) - { - msg = i18n("The executable %1 couldn't be found in your PATH.").arg("lpc"); - return false; - } - TQString result = execute(m_exepath + (state == KMJob::Held ? " hold " : " release ") + KProcess::quote(job->printer()) + " " + TQString::number(job->id())); - TQString answer = lprngAnswer(result, job->printer()); - if (answer == "no") - { - msg = i18n("Permission denied."); - return false; - } - else - return true; -} - -bool LpcHelper::restart(TQString& msg) -{ - TQString s; - if (m_exepath.isEmpty()) - s = "lpc"; - else if (m_checkpcpath.isEmpty()) - s = "checkpc"; - if (!s.isEmpty()) - { - msg = i18n("The executable %1 couldn't be found in your PATH.").arg(s); - return false; - } - ::system(TQFile::encodeName(m_exepath + " reread")); - ::system(TQFile::encodeName(m_checkpcpath + " -f")); - return true; -} diff --git a/kdeprint/lpr/lpchelper.h b/kdeprint/lpr/lpchelper.h deleted file mode 100644 index b1e20f089..000000000 --- a/kdeprint/lpr/lpchelper.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul - * - * 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 LPCHELPER_H -#define LPCHELPER_H - -#include -#include -#include -#include "kmprinter.h" - -class KMJob; - -class LpcHelper : public TQObject -{ -public: - LpcHelper(TQObject *parent = 0, const char *name = 0); - ~LpcHelper(); - - KMPrinter::PrinterState state(const TQString&) const; - KMPrinter::PrinterState state(KMPrinter*) const; - void updateStates(); - - bool enable(KMPrinter*, bool, TQString&); - bool start(KMPrinter*, bool, TQString&); - bool removeJob(KMJob*, TQString&); - bool changeJobState(KMJob*, int, TQString&); - - bool restart(TQString&); - -protected: - bool changeState(const TQString&, const TQString&, TQString&); - void parseStatusLPR(TQTextStream&); - void parseStatusLPRng(TQTextStream&); - int parseStateChangeLPR(const TQString&, const TQString&); - int parseStateChangeLPRng(const TQString&, const TQString&); - -private: - TQMap m_state; - TQString m_exepath, m_lprmpath, m_checkpcpath; -}; - -#endif diff --git a/kdeprint/lpr/lpqhelper.cpp b/kdeprint/lpr/lpqhelper.cpp deleted file mode 100644 index 30348f591..000000000 --- a/kdeprint/lpr/lpqhelper.cpp +++ /dev/null @@ -1,117 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul - * - * 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 "lpqhelper.h" -#include "kmjob.h" -#include "kpipeprocess.h" -#include "lprsettings.h" - -#include -#include -#include - -LpqHelper::LpqHelper(TQObject *parent, const char *name) -: TQObject(parent, name) -{ - m_exepath = KStandardDirs::findExe("lpq"); -} - -LpqHelper::~LpqHelper() -{ -} - -KMJob* LpqHelper::parseLineLpr(const TQString& line) -{ - TQString rank = line.left(7); - if (!rank[0].isDigit() && rank != "active") - return NULL; - KMJob *job = new KMJob; - job->setState((rank[0].isDigit() ? KMJob::Queued : KMJob::Printing)); - job->setOwner(line.mid(7, 11).stripWhiteSpace()); - job->setId(line.mid(18, 5).toInt()); - job->setName(line.mid(23, 38).stripWhiteSpace()); - int p = line.find(' ', 61); - if (p != -1) - { - job->setSize(line.mid(61, p-61).toInt() / 1000); - } - return job; -} - -KMJob* LpqHelper::parseLineLPRng(const TQString& line) -{ - TQString rank = line.left(7).stripWhiteSpace(); - if (!rank[0].isDigit() && rank != "active" && rank != "hold") - return NULL; - KMJob *job = new KMJob; - job->setState((rank[0].isDigit() ? KMJob::Queued : (rank == "hold" ? KMJob::Held : KMJob::Printing))); - int p = line.find('@', 7), q = line.find(' ', 7); - job->setOwner(line.mid(7, TQMIN(p,q)-7)); - while (line[q].isSpace()) - q++; - q++; - while (line[q].isSpace()) - q++; - p = line.find(' ', q); - job->setId(line.mid(q, p-q).toInt()); - while (line[p].isSpace()) - p++; - q = p+25; - while (line[q].isDigit()) - q--; - job->setName(line.mid(p, q-p).stripWhiteSpace()); - job->setSize(line.mid(q+1, p+26-q).toInt() / 1000); - return job; -} - -void LpqHelper::listJobs(TQPtrList& jobs, const TQString& prname, int limit) -{ - KPipeProcess proc; - if (!m_exepath.isEmpty() && proc.open(m_exepath + " -P " + KProcess::quote(prname))) - { - TQTextStream t(&proc); - TQString line; - bool lprng = (LprSettings::self()->mode() == LprSettings::LPRng); - int count = 0; - - while (!t.atEnd()) - { - line = t.readLine().stripWhiteSpace(); - if (line.startsWith("Rank")) - break; - } - while (!t.atEnd()) - { - line = t.readLine(); - if ( limit > 0 && count >= limit ) - continue; - KMJob *job = (lprng ? parseLineLPRng(line) : parseLineLpr(line)); - if (job) - { - job->setPrinter(prname); - job->setUri("lpd://"+prname+"/"+TQString::number(job->id())); - jobs.append(job); - count++; - } - else - break; - } - proc.close(); - } -} diff --git a/kdeprint/lpr/lpqhelper.h b/kdeprint/lpr/lpqhelper.h deleted file mode 100644 index 2c38566c5..000000000 --- a/kdeprint/lpr/lpqhelper.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul - * - * 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 LPQHELPER_H -#define LPQHELPER_H - -#include -#include - -class KMJob; - -class LpqHelper : public TQObject -{ -public: - LpqHelper(TQObject *parent = 0, const char *name = 0); - ~LpqHelper(); - - void listJobs(TQPtrList& jobs, const TQString& prname, int limit = 0); - -protected: - KMJob* parseLineLpr(const TQString&); - KMJob* parseLineLPRng(const TQString&); - -private: - TQString m_exepath; -}; - -#endif diff --git a/kdeprint/lpr/lpr.print b/kdeprint/lpr/lpr.print deleted file mode 100644 index e8cd8a3d7..000000000 --- a/kdeprint/lpr/lpr.print +++ /dev/null @@ -1,86 +0,0 @@ -[KDE Print Entry] -PrintSystem=lpr -Comment=LPR/LPRng Print System -Comment[af]= lpr /Lprng Druk Stelsel -Comment[ar]=نظام طباعة LPR/LPRng -Comment[az]=LPR/LPRng Çap Sistemi -Comment[be]=Сістэма друку LPR/LPRng -Comment[bn]=এল-পি-আর/এল-পি-আর-এন-জি মুদ্রণ ব্যবস্থা -Comment[br]=Reizhiad moulañ LPR/LPRng -Comment[bs]=LPR/LPRng sistem štampe -Comment[ca]=Sistema d'impressió LPR/LPRng -Comment[cs]=Tiskový systém LPR/LPRng -Comment[csb]=Systema drëkù LPR/LPRng -Comment[cy]=Cysawd Argraffu LPR/LPRng -Comment[da]=LPR/LPRng-udskriftssystem -Comment[de]=LPR/LPRng-Drucksystem -Comment[el]=LPR/LPRng σύστημα εκτύπωσης -Comment[eo]=LPR/LPRng-presosistemo -Comment[es]=Sistema de impresión LPR/LPRNg -Comment[et]=LPR/LPRng trükkimise süsteem -Comment[eu]=LPR/LPRng inprimatze-sistema -Comment[fa]=سیستم چاپ LPR/LPRng -Comment[fi]=LPR/LPRng-tulostusjärjestelmä -Comment[fr]=Système d'impression LPR / LPRng -Comment[fy]=LPR-/LPRNG-ôfdruksysteem -Comment[ga]=Córas Priontála LPR/LPRng -Comment[gl]=Sistema de Impresión LPR/LPRng -Comment[he]=מערכת ההדפסה LPR/LPRng -Comment[hi]=LPR/LPRng छपाई पद्धत्ति -Comment[hr]=LPR/LPRng sustav za ispis -Comment[hu]=LPR/LPRng -Comment[id]=Sistem Pencetakan LPR/LPRng -Comment[is]=LPR/LPRng prentkerfið -Comment[it]=Sistema di stampa LPR/LPRng -Comment[ja]=LPR/LPRng 印刷システム -Comment[ka]=LPR/LPRng ბეჭდვის სისტემა -Comment[kk]=LPR/LPRng басып шығару жүйесі -Comment[km]=ប្រព័ន្ធ​បោះពុម្ព LPR/LPRng -Comment[ko]=LPR/LPRng 인쇄 시스템 -Comment[lb]=LPR/LPRng-Drécksystem -Comment[lt]=LPR/LPRng spausdinimo sistema -Comment[lv]=LPR/LPRng drukas sistēma -Comment[mk]=LPR/LPRng системот за печатење -Comment[mn]=LPR/LPRng-Хэвлэх систем -Comment[ms]=Sistem Cetak LPR/LPRng -Comment[mt]=Sistema tal-ipprintjar LPR/LPRng -Comment[nb]=Utskriftssystemet LPR/LPRng -Comment[nds]=Dat Drucksysteem LPR/LPRng -Comment[ne]=LPR/LPRng मुद्रण प्रणाली -Comment[nl]=LPR-/LPRNG-afdruksysteem -Comment[nn]=Utskriftssystemet LPR/LPRng -Comment[nso]=System ya Kgatiso ya LPR/LPRng -Comment[pa]=LPR/LPRng ਪ੍ਰਿੰਟਰ ਸਿਸਟਮ -Comment[pl]=System druku LPR/LPRng -Comment[pt]=O sistema de impressão LPR/LPRng -Comment[pt_BR]=Sistema de Impressão LPR/LPRng -Comment[ro]=Sistem de tipărire LPR/LPRng -Comment[ru]=Система печати LPR/LPRng -Comment[rw]=Sisitemu yo Gucapa LPR/LPRng -Comment[se]=LPR/LPRng čálihanvuogádat -Comment[sk]=Tlačový systém LPR/LPRng -Comment[sl]=Tiskalniški sistem za LPR/LPRng -Comment[sq]=Sistem Shtypi për LPR/LPRng -Comment[sr]=LPR/LPRng систем за штампање -Comment[sr@Latn]=LPR/LPRng sistem za štampanje -Comment[ss]=LPR/LPRng umhini wekushivelela -Comment[sv]=LPR/LPRNG-skrivarsystem -Comment[ta]=LPR/LPRng அச்சுத் தொகுதி -Comment[te]=ఎల్ పి ఆర్/ఎల్ పి ఆర్ ఎన్ జి ప్రచురణ వ్యవస్థ -Comment[tg]=Системаи чопи LPR/LPRng -Comment[th]=ระบบการพิมพ์ LPR/LPRng -Comment[tr]=LPR/LPRng Yazdırma Sistemi -Comment[tt]=LPR/LPRng Bastıru Sisteme -Comment[uk]=Система друку LPR/LPRng -Comment[uz]=LPR/LPRng bosib chiqarish tizimi -Comment[uz@cyrillic]=LPR/LPRng босиб чиқариш тизими -Comment[ven]=LPR/Maitele au phirintha a LPRng -Comment[vi]=Hệ thống in LPR/LPRng -Comment[wa]=Sistinme d' imprimaedje LPR/LPRng -Comment[xh]=LPR/LPRng Indlela Yokushicilela -Comment[zh_CN]=LPR/LPRng 打印系统 -Comment[zh_HK]=LPR/LPRng 列印系統 -Comment[zh_TW]=LPR/LPRng 列印系統 -Comment[zu]=Isistimu Yokushicilela ye-LPR/LRng -DetectUris=service:/printer -DetectPrecedence=0 diff --git a/kdeprint/lpr/lprhandler.cpp b/kdeprint/lpr/lprhandler.cpp deleted file mode 100644 index fcb838bb9..000000000 --- a/kdeprint/lpr/lprhandler.cpp +++ /dev/null @@ -1,270 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul - * - * 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 "lprhandler.h" -#include "kmprinter.h" -#include "printcapentry.h" -#include "kmmanager.h" -#include "lprsettings.h" -#include "driver.h" - -#include -#include -#include -#include - -#include - -LprHandler::LprHandler(const TQString& name, KMManager *mgr) -: m_name(name), m_manager(mgr) -{ -} - -LprHandler::~LprHandler() -{ -} - -bool LprHandler::validate(PrintcapEntry*) -{ - return true; -} - -KMPrinter* LprHandler::createPrinter(PrintcapEntry *entry) -{ - KMPrinter *prt = new KMPrinter; - prt->setPrinterName(entry->name); - prt->setName(entry->name); - prt->setType(KMPrinter::Printer); - return prt; -} - -bool LprHandler::completePrinter(KMPrinter *prt, PrintcapEntry *entry, bool) -{ - prt->setDescription(i18n("Unknown (unrecognized entry)")); - TQString val = entry->field("lp"); - KURL uri; - if (!val.isEmpty() && val != "/dev/null") - { - int p = val.find('@'); - if (p != -1) - { - prt->setLocation(i18n("Remote queue (%1) on %2").arg(val.left(p)).arg(val.mid(p+1))); - uri.setProtocol("lpd"); - uri.setHost(val.mid(p+1)); - uri.setPath("/" + val.left(p)); - } - else if ((p = val.find('%')) != -1) - { - prt->setLocation(i18n("Network printer (%1)").arg("socket")); - uri.setProtocol("socket"); - uri.setHost(val.left(p)); - uri.setPort(val.mid(p+1).toInt()); - } - else - { - prt->setLocation(i18n("Local printer on %1").arg(val)); - uri.setProtocol("parallel"); - uri.setPath(val); - } - } - else if (!(val = entry->field("rp")).isEmpty()) - { - TQString rm = entry->has("rm") ? - entry->field("rm") : - LprSettings::self()->defaultRemoteHost(); - prt->setLocation(i18n("Remote queue (%1) on %2").arg(val).arg(rm)); - uri.setProtocol("lpd"); - uri.setHost(rm); - uri.setPath("/" + val); - } - else - prt->setLocation(i18n("Unknown (unrecognized entry)")); - prt->setDevice(uri.url()); - return true; -} - -DrMain* LprHandler::loadDriver(KMPrinter*, PrintcapEntry*, bool) -{ - manager()->setErrorMsg(i18n("Unrecognized entry.")); - return NULL; -} - -bool LprHandler::savePrinterDriver(KMPrinter*, PrintcapEntry*, DrMain*, bool*) -{ - manager()->setErrorMsg(i18n("Unrecognized entry.")); - return false; -} - -DrMain* LprHandler::loadDbDriver(const TQString&) -{ - manager()->setErrorMsg(i18n("Unrecognized entry.")); - return NULL; -} - -PrintcapEntry* LprHandler::createEntry(KMPrinter *prt) -{ - // this default handler only supports local parallel and remote lpd URIs - KURL uri ( prt->device() ); - TQString prot = uri.protocol(); - if (!prot.isEmpty() && prot != "parallel" && prot != "file" && prot != "lpd" && prot != "socket") - { - manager()->setErrorMsg(i18n("Unsupported backend: %1.").arg(prot)); - return NULL; - } - PrintcapEntry *entry = new PrintcapEntry; - entry->comment = "# Default handler"; - if (prot == "lpd") - { - entry->addField("rm", Field::String, uri.host()); - TQString rp = uri.path(); - if (rp[0] == '/') - rp = rp.mid(1); - entry->addField("rp", Field::String, rp); - // force this entry to null (otherwise it seems it's redirected - // to /dev/lp0 by default) - entry->addField("lp", Field::String, TQString::null); - } - else if ( prot == "socket" ) - { - TQString lp = uri.host(); - if ( uri.port() == 0 ) - lp.append( "%9100" ); - else - lp.append( "%" ).append( TQString::number( uri.port() ) ); - entry->addField("lp", Field::String, lp); - } - else - { - entry->addField("lp", Field::String, uri.path()); - } - return entry; -} - -bool LprHandler::removePrinter(KMPrinter*, PrintcapEntry*) -{ - return true; -} - -TQString LprHandler::printOptions(KPrinter*) -{ - return TQString::null; -} - -void LprHandler::reset() -{ -} - -DrMain* LprHandler::loadToolDriver(const TQString& filename) -{ - TQFile f(filename); - if (f.open(IO_ReadOnly)) - { - DrMain *driver = new DrMain; - TQValueStack groups; - TQTextStream t(&f); - TQStringList l; - DrListOption *lopt(0); - DrBase *opt(0); - - groups.push(driver); - driver->set("text", "Tool Driver"); - while (!t.atEnd()) - { - l = TQStringList::split('|', t.readLine().stripWhiteSpace(), false); - if (l.count() == 0) - continue; - if (l[0] == "GROUP") - { - DrGroup *grp = new DrGroup; - grp->setName(l[1]); - grp->set("text", l[2]); - groups.top()->addGroup(grp); - groups.push(grp); - } - else if (l[0] == "ENDGROUP") - { - groups.pop(); - } - else if (l[0] == "OPTION") - { - opt = 0; - lopt = 0; - if (l.count() > 3) - { - if (l[3] == "STRING") - opt = new DrStringOption; - else if (l[3] == "BOOLEAN") - { - lopt = new DrBooleanOption; - opt = lopt; - } - } - else - { - lopt = new DrListOption; - opt = lopt; - } - if (opt) - { - opt->setName(l[1]); - opt->set("text", l[2]); - groups.top()->addOption(opt); - } - } - else if (l[0] == "CHOICE" && lopt) - { - DrBase *ch = new DrBase; - ch->setName(l[1]); - ch->set("text", l[2]); - lopt->addChoice(ch); - } - else if (l[0] == "DEFAULT" && opt) - { - opt->setValueText(l[1]); - opt->set("default", l[1]); - } - } - return driver; - } - return NULL; -} - -TQString LprHandler::driverDirectory() -{ - if (m_cacheddriverdir.isEmpty()) - m_cacheddriverdir = driverDirInternal(); - return m_cacheddriverdir; -} - -TQString LprHandler::driverDirInternal() -{ - return TQString::null; -} - -TQString LprHandler::locateDir(const TQString& dirname, const TQString& paths) -{ - TQStringList pathlist = TQStringList::split(':', paths, false); - for (TQStringList::ConstIterator it=pathlist.begin(); it!=pathlist.end(); ++it) - { - TQString testpath = *it + "/" + dirname; - if (::access(TQFile::encodeName(testpath), F_OK) == 0) - return testpath; - } - return TQString::null; -} diff --git a/kdeprint/lpr/lprhandler.h b/kdeprint/lpr/lprhandler.h deleted file mode 100644 index e0e66e146..000000000 --- a/kdeprint/lpr/lprhandler.h +++ /dev/null @@ -1,88 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul - * - * 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 LPRHANDLER_H -#define LPRHANDLER_H - -#if !defined( _KDEPRINT_COMPILE ) && defined( __GNUC__ ) -#warning internal header, do not use except if you are a KDEPrint developer -#endif - -#include - -class PrintcapEntry; -class KMPrinter; -class DrMain; -class KMManager; -class KPrinter; - -/** - * @internal - * This class is internal to KDEPrint and is not intended to be - * used outside it. Please do not make use of this header, except - * if you're a KDEPrint developer. The API might change in the - * future and binary compatibility might be broken. - */ -class LprHandler -{ -public: - LprHandler(const TQString& name, KMManager *mgr = 0); - virtual ~LprHandler(); - - virtual bool validate(PrintcapEntry*); - virtual KMPrinter* createPrinter(PrintcapEntry*); - virtual bool completePrinter(KMPrinter*, PrintcapEntry*, bool shortmode = true); - virtual DrMain* loadDriver(KMPrinter*, PrintcapEntry*, bool = false); - virtual DrMain* loadDbDriver(const TQString&); - virtual bool savePrinterDriver(KMPrinter*, PrintcapEntry*, DrMain*, bool* = 0); - virtual PrintcapEntry* createEntry(KMPrinter*); - virtual bool removePrinter(KMPrinter*, PrintcapEntry*); - virtual TQString printOptions(KPrinter*); - virtual void reset(); - - TQString name() const; - KMManager* manager() const; - TQString driverDirectory(); - -protected: - DrMain* loadToolDriver(const TQString&); - TQString locateDir(const TQString& dirname, const TQString& paths); - TQString cachedDriverDir() const; - void setCachedDriverDir(const TQString&); - virtual TQString driverDirInternal(); - -protected: - TQString m_name; - KMManager *m_manager; - TQString m_cacheddriverdir; -}; - -inline TQString LprHandler::name() const -{ return m_name; } - -inline KMManager* LprHandler::manager() const -{ return m_manager; } - -inline TQString LprHandler::cachedDriverDir() const -{ return m_cacheddriverdir; } - -inline void LprHandler::setCachedDriverDir(const TQString& s) -{ m_cacheddriverdir = s; } - -#endif diff --git a/kdeprint/lpr/lprngtooldriver1 b/kdeprint/lpr/lprngtooldriver1 deleted file mode 100644 index 11636403c..000000000 --- a/kdeprint/lpr/lprngtooldriver1 +++ /dev/null @@ -1,85 +0,0 @@ -GROUP|general|General -OPTION|PageSize|Page Size -CHOICE|letter|US Letter -CHOICE|legal|US Legal -CHOICE|ledger|Ledger -CHOICE|11x17|11x17 -CHOICE|tabloid|Tabloid -CHOICE|oversize|Oversize -CHOICE|executive|Executive -CHOICE|envelope|Envelope -CHOICE|a0|A0 -CHOICE|a1|A1 -CHOICE|a2|A2 -CHOICE|a3|A3 -CHOICE|a4|A4 -DEFAULT|a4 -OPTION|MediaType|Media Type -CHOICE|bond|Bond paper -CHOICE|cardstock|Card stock -CHOICE|color|Color paper -CHOICE|glossy|Glossy paper -CHOICE|heavy|Heavy paper -CHOICE|labels|Labels -CHOICE|letterhead|Letter head -CHOICE|plain|Plain paper -CHOICE|preprinted|Preprinted paper -CHOICE|prepunched|Prepunched paper -CHOICE|recycle|Recycled paper -CHOICE|transparency|Transparencies -CHOICE|default|Default setting -DEFAULT|default -OPTION|InputSlot|Input Slot -CHOICE|manual|Manual tray -CHOICE|inupper|Upper tray -CHOICE|inmiddle|Middle tray -CHOICE|inlower|Lower tray -CHOICE|inlarge|Large tray -CHOICE|inright|Right tray -CHOICE|intray1|Tray 1 -CHOICE|intray2|Tray 2 -CHOICE|intray3|Tray 3 -CHOICE|intray4|Tray 4 -CHOICE|intray5|Tray 5 -CHOICE|intray6|Tray 6 -CHOICE|intray7|Tray 7 -CHOICE|intray8|Tray 8 -CHOICE|intray9|Tray 9 -CHOICE|intray10|Tray 10 -CHOICE|inlargecapacity|Large capacity tray -CHOICE|inhighcapacity|High capacity tray -CHOICE|default|Default setting -DEFAULT|default -OPTION|OutputBin|Output Tray -CHOICE|outupper|Upper tray -CHOICE|outlower|Lower tray -CHOICE|outbin2|Tray 2 -CHOICE|outbin3|Tray 3 -CHOICE|outbin4|Tray 4 -CHOICE|outbin5|Tray 5 -CHOICE|outbin6|Tray 6 -CHOICE|outbin7|Tray 7 -CHOICE|outbin8|Tray 8 -CHOICE|outbin9|Tray 9 -CHOICE|default|Default setting -DEFAULT|default -ENDGROUP -GROUP|others|Others -OPTION|Duplex|Duplex -CHOICE|simplex|Simplex -CHOICE|duplex|Duplex -CHOICE|duplexshort|Duplex (short edge) -CHOICE|tumble|Tumble -CHOICE|default|Default setting -DEFAULT|default -OPTION|Resolution|Printing Resolution -CHOICE|300|300 DPI -CHOICE|600|600 DPI -CHOICE|1200|1200 DPI -CHOICE|default|Default setting -DEFAULT|default -ENDGROUP -GROUP|advanced|Advanced Settings -OPTION|filter|Filter options (comma sepatared)|STRING -OPTION|lpr|LPR options (comma separated)|STRING -ENDGROUP diff --git a/kdeprint/lpr/lprngtoolhandler.cpp b/kdeprint/lpr/lprngtoolhandler.cpp deleted file mode 100644 index 1d76cf2f5..000000000 --- a/kdeprint/lpr/lprngtoolhandler.cpp +++ /dev/null @@ -1,393 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul - * - * 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 "lprngtoolhandler.h" -#include "printcapentry.h" -#include "kmprinter.h" -#include "util.h" -#include "lprsettings.h" -#include "driver.h" -#include "kmmanager.h" -#include "kprinter.h" - -#include -#include -#include -#include -#include - -LPRngToolHandler::LPRngToolHandler(KMManager *mgr) -: LprHandler("lprngtool", mgr) -{ -} - -bool LPRngToolHandler::validate(PrintcapEntry *entry) -{ - if (entry->comment.startsWith("##LPRNGTOOL##") && - entry->comment.find("UNKNOWN") == -1) - return true; - return false; -} - -bool LPRngToolHandler::completePrinter(KMPrinter *prt, PrintcapEntry *entry, bool shortmode) -{ - TQString str, lp; - - // look for type in comment - TQStringList l = TQStringList::split(' ', entry->comment, false); - lp = entry->field("lp"); - if (l.count() < 1) - return false; - - if (l[1] == "DEVICE" || l[1] == "SOCKET" || l[1] == "QUEUE") - LprHandler::completePrinter(prt, entry, shortmode); - else if (l[1] == "SMB") - { - TQMap opts = parseXferOptions(entry->field("xfer_options")); - TQString user, pass; - loadAuthFile(LprSettings::self()->baseSpoolDir() + "/" + entry->name + "/" + opts["authfile"], user, pass); - TQString uri = buildSmbURI( - opts[ "workgroup" ], - opts[ "host" ], - opts[ "printer" ], - user, - pass ); - prt->setDevice( uri ); - prt->setLocation(i18n("Network printer (%1)").arg("smb")); - } - - // look for comment - if (!(str=entry->field("cm")).isEmpty()) - prt->setDescription(str); - - // driver - //if (!shortmode) - //{ - if (!(str=entry->field("ifhp")).isEmpty()) - { - TQString model; - int p = str.find("model"); - if (p != -1) - { - p = str.find('=', p); - if (p != -1) - { - p++; - int q = str.find(',', p); - if (q == -1) - model = str.mid(p); - else - model = str.mid(p, q-p); - } - } - prt->setDriverInfo(i18n("IFHP Driver (%1)").arg((model.isEmpty() ? i18n("unknown") : model))); - prt->setOption("driverID", model); - } - //} - return true; -} - -TQMap LPRngToolHandler::parseXferOptions(const TQString& str) -{ - uint p(0), q; - TQMap opts; - TQString key, val; - - while (p < str.length()) - { - key = val = TQString::null; - // skip spaces - while (p < str.length() && str[p].isSpace()) - p++; - q = p; - while (q < str.length() && str[q] != '=') - q++; - key = str.mid(p, q-p); - p = q+2; - while (p < str.length() && str[p] != '"') - p++; - val = str.mid(q+2, p-q-2); - if (!key.isEmpty()) - opts[key] = val; - p++; - } - return opts; -} - -void LPRngToolHandler::loadAuthFile(const TQString& filename, TQString& user, TQString& pass) -{ - TQFile f(filename); - if (f.open(IO_ReadOnly)) - { - TQTextStream t(&f); - TQString line; - while (!t.atEnd()) - { - line = t.readLine().stripWhiteSpace(); - if (line.isEmpty()) - continue; - int p = line.find('='); - if (p != -1) - { - TQString key = line.left(p); - if (key == "username") - user = line.mid(p+1); - else if (key == "password") - pass = line.mid(p+1); - } - } - } -} - -DrMain* LPRngToolHandler::loadDriver(KMPrinter *prt, PrintcapEntry *entry, bool config) -{ - if (entry->field("lprngtooloptions").isEmpty()) - { - manager()->setErrorMsg(i18n("No driver defined for that printer. It might be a raw printer.")); - return NULL; - } - - DrMain* driver = loadToolDriver(locate("data", "tdeprint/lprngtooldriver1")); - if (driver) - { - TQString model = prt->option("driverID"); - driver->set("text", i18n("LPRngTool Common Driver (%1)").arg((model.isEmpty() ? i18n("unknown") : model))); - if (!model.isEmpty()) - driver->set("driverID", model); - TQMap opts = parseZOptions(entry->field("prefix_z")); - opts["lpr"] = entry->field("lpr"); - driver->setOptions(opts); - // if not configuring, don't show the "lpr" options - if (!config) - driver->removeOptionGlobally("lpr"); - } - return driver; -} - -DrMain* LPRngToolHandler::loadDbDriver(const TQString& s) -{ - int p = s.find('/'); - DrMain* driver = loadToolDriver(locate("data", "tdeprint/lprngtooldriver1")); - if (driver) - driver->set("driverID", s.mid(p+1)); - return driver; -} - -TQValueList< TQPair > LPRngToolHandler::loadChoiceDict(const TQString& filename) -{ - TQFile f(filename); - TQValueList< TQPair > dict; - if (f.open(IO_ReadOnly)) - { - TQTextStream t(&f); - TQString line, key; - TQStringList l; - while (!t.atEnd()) - { - line = t.readLine().stripWhiteSpace(); - if (line.startsWith("OPTION")) - { - if (l.count() > 0 && !key.isEmpty()) - dict << TQPair(key, l); - l.clear(); - key = TQString::null; - if (line.contains('|') == 2 || line.right(7) == "BOOLEAN") - { - int p = line.find('|', 7); - key = line.mid(7, p-7); - } - } - else if (line.startsWith("CHOICE")) - { - int p = line.find('|', 7); - l << line.mid(7, p-7); - } - } - } - return dict; -} - -TQMap LPRngToolHandler::parseZOptions(const TQString& optstr) -{ - TQMap opts; - TQStringList l = TQStringList::split(',', optstr, false); - if (l.count() == 0) - return opts; - - if (m_dict.count() == 0) - m_dict = loadChoiceDict(locate("data", "tdeprint/lprngtooldriver1")); - - TQString unknown; - for (TQStringList::ConstIterator it=l.begin(); it!=l.end(); ++it) - { - bool found(false); - for (TQValueList< TQPair >::ConstIterator p=m_dict.begin(); p!=m_dict.end() && !found; ++p) - { - if ((*p).second.find(*it) != (*p).second.end()) - { - opts[(*p).first] = (*it); - found = true; - } - } - if (!found) - { - unknown.append(*it).append(','); - } - } - if (!unknown.isEmpty()) - { - unknown.truncate(unknown.length()-1); - opts["filter"] = unknown; - } - return opts; -} - -TQString LPRngToolHandler::filterDir() -{ - return driverDirectory(); -} - -TQString LPRngToolHandler::driverDirInternal() -{ - return locateDir("filters", "/usr/lib:/usr/local/lib:/opt/lib:/usr/libexec:/usr/local/libexec:/opt/libexec"); -} - -PrintcapEntry* LPRngToolHandler::createEntry(KMPrinter *prt) -{ - TQString prot = prt->deviceProtocol(); - if (prot != "parallel" && prot != "lpd" && prot != "smb" && prot != "socket") - { - manager()->setErrorMsg(i18n("Unsupported backend: %1.").arg(prot)); - return NULL; - } - PrintcapEntry *entry = new PrintcapEntry; - entry->addField("cm", Field::String, prt->description()); - TQString lp, comment("##LPRNGTOOL## "); - if (prot == "parallel") - { - comment.append("DEVICE "); - lp = prt->device().mid( 9 ); - entry->addField("rw@", Field::Boolean); - } - else if (prot == "socket") - { - comment.append("SOCKET "); - KURL url( prt->device() ); - lp = url.host(); - if (url.port() == 0) - lp.append("%9100"); - else - lp.append("%").append(TQString::number(url.port())); - } - else if (prot == "lpd") - { - comment.append("QUEUE "); - KURL url( prt->device() ); - lp = url.path().mid(1) + "@" + url.host(); - } - else if (prot == "smb") - { - comment.append("SMB "); - lp = "| " + filterDir() + "/smbprint"; - TQString work, server, printer, user, passwd; - if ( splitSmbURI( prt->device(), work, server, printer, user, passwd ) ) - { - entry->addField("xfer_options", Field::String, TQString::tqfromLatin1("authfile=\"auth\" crlf=\"0\" hostip=\"\" host=\"%1\" printer=\"%2\" remote_mode=\"SMB\" share=\"//%3/%4\" workgroup=\"%5\"").arg(server).arg(printer).arg(server).arg(printer).arg(work)); - TQFile authfile(LprSettings::self()->baseSpoolDir() + "/" + prt->printerName() + "/auth"); - if (authfile.open(IO_WriteOnly)) - { - TQTextStream t(&authfile); - t << "username=" << user << endl; - t << "password=" << passwd << endl; - authfile.close(); - } - } - else - { - manager()->setErrorMsg( i18n( "Invalid printer backend specification: %1" ).arg( prt->device() ) ); - delete entry; - return NULL; - } - } - - if (prt->driver()) - { - DrMain *driver = prt->driver(); - comment.append("filtertype=IFHP ifhp_options=status@,sync@,pagecount@,waitend@ printerdb_entry="); - comment.append(driver->get("driverID")); - entry->addField("ifhp", Field::String, TQString::tqfromLatin1("model=%1,status@,sync@,pagecount@,waitend@").arg(driver->get("driverID"))); - entry->addField("lprngtooloptions", Field::String, TQString::tqfromLatin1("FILTERTYPE=\"IFHP\" IFHP_OPTIONS=\"status@,sync@,pagecount@,waitend@\" PRINTERDB_ENTRY=\"%1\"").arg(driver->get("driverID"))); - TQMap opts; - TQString optstr; - driver->getOptions(opts, false); - for (TQMap::ConstIterator it=opts.begin(); it!=opts.end(); ++it) - if (it.key() != "lpr") - optstr.append(*it).append(","); - if (!optstr.isEmpty()) - { - optstr.truncate(optstr.length()-1); - entry->addField("prefix_z", Field::String, optstr); - } - if (!opts["lpr"].isEmpty()) - entry->addField("lpr", Field::String, opts["lpr"]); - } - - entry->addField("lp", Field::String, lp); - entry->comment = comment; - - return entry; -} - -bool LPRngToolHandler::savePrinterDriver(KMPrinter*, PrintcapEntry *entry, DrMain *driver, bool *mustSave) -{ - // save options in the "prefix_z" field and tell the manager to save the printcap file - TQMap opts; - TQString optstr; - driver->getOptions(opts, false); - for (TQMap::ConstIterator it=opts.begin(); it!=opts.end(); ++it) - if (it.key() != "lpr") - optstr.append(*it).append(","); - if (!optstr.isEmpty()) - optstr.truncate(optstr.length()-1); - // save options in any case, otherwise nothing will happen whn - // options are reset to their default value - entry->addField("prefix_z", Field::String, optstr); - entry->addField("lpr", Field::String, opts["lpr"]); - if (mustSave) - *mustSave = true; - return true; -} - -TQString LPRngToolHandler::printOptions(KPrinter *printer) -{ - TQString optstr; - TQMap opts = printer->options(); - for (TQMap::ConstIterator it=opts.begin(); it!=opts.end(); ++it) - { - if (it.key().startsWith("kde-") || it.key().startsWith("_kde-") || it.key() == "lpr" || it.key().startsWith( "app-" )) - continue; - optstr.append(*it).append(","); - } - if (!optstr.isEmpty()) - { - optstr.truncate(optstr.length()-1); - optstr.prepend("-Z '").append("'"); - } - return optstr; -} diff --git a/kdeprint/lpr/lprngtoolhandler.h b/kdeprint/lpr/lprngtoolhandler.h deleted file mode 100644 index 49641ca3a..000000000 --- a/kdeprint/lpr/lprngtoolhandler.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul - * - * 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 LPRNGTOOLHANDLER_H -#define LPRNGTOOLHANDLER_H - -#include "lprhandler.h" -#include -#include -#include - -class LPRngToolHandler : public LprHandler -{ -public: - LPRngToolHandler(KMManager *mgr = 0); - - bool validate(PrintcapEntry*); - bool completePrinter(KMPrinter*, PrintcapEntry*, bool = true); - DrMain* loadDriver(KMPrinter*, PrintcapEntry*, bool = false); - DrMain* loadDbDriver(const TQString&); - PrintcapEntry* createEntry(KMPrinter*); - bool savePrinterDriver(KMPrinter*, PrintcapEntry*, DrMain*, bool* = 0); - TQString printOptions(KPrinter*); - -protected: - TQMap parseXferOptions(const TQString&); - void loadAuthFile(const TQString&, TQString&, TQString&); - TQValueList< TQPair > loadChoiceDict(const TQString&); - TQMap parseZOptions(const TQString&); - TQString filterDir(); - TQString driverDirInternal(); - - -private: - TQValueList< TQPair > m_dict; -}; - -#endif diff --git a/kdeprint/lpr/lprsettings.cpp b/kdeprint/lpr/lprsettings.cpp deleted file mode 100644 index 0c1cec2a9..000000000 --- a/kdeprint/lpr/lprsettings.cpp +++ /dev/null @@ -1,146 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001,2002 Michael Goffioul - * - * 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 "lprsettings.h" -#include "kmmanager.h" -#include "kmfactory.h" - -#include -#include -#include - -#define LPDCONF "/etc/lpd.conf" -#define PRINTCAP "/etc/printcap" - -LprSettings* LprSettings::m_self = 0; - -LprSettings::LprSettings(TQObject *parent, const char *name) -: TQObject(parent, name), KPReloadObject(true) -{ - init(); -} - -LprSettings::~LprSettings() -{ - m_self = 0; -} - -LprSettings* LprSettings::self() -{ - if (!m_self) - { - m_self = new LprSettings(KMManager::self(), "LprSettings"); - } - return m_self; -} - -void LprSettings::init() -{ - // LPR/LPRng mode - KConfig *conf = KMFactory::self()->printConfig(); - conf->setGroup("LPR"); - TQString modestr = conf->readEntry("Mode"); - if (modestr == "LPRng") - m_mode = LPRng; - else if (modestr == "LPR") - m_mode = LPR; - else - { - // try to guess - if (TQFile::exists(LPDCONF)) - m_mode = LPRng; - else - m_mode = LPR; - } - - // Printcap file - m_printcapfile = TQString(); - m_local = true; - - // Spool directory - m_spooldir = "/var/spool/lpd"; -} - -TQString LprSettings::printcapFile() -{ - if (m_printcapfile.isEmpty()) - { - // default value - m_printcapfile = PRINTCAP; - if (m_mode == LPRng) - { - // look into /etc/lpd/conf file - TQFile cf(LPDCONF); - if (cf.open(IO_ReadOnly)) - { - TQTextStream t(&cf); - TQString line; - while (!t.atEnd()) - { - line = t.readLine().stripWhiteSpace(); - if (line.startsWith("printcap_path")) - { - TQString filename = line.mid(14).stripWhiteSpace(); - if (filename[0] != '|') - m_printcapfile = filename; - else - { - // should download the printcap file - // and set m_local to false - } - } - } - } - } - } - return m_printcapfile; -} - -TQString LprSettings::defaultRemoteHost() -{ - if (m_defaultremotehost.isEmpty()) - { - m_defaultremotehost = "localhost"; - TQFile cf(LPDCONF); - if (cf.open(IO_ReadOnly)) - { - TQTextStream t(&cf); - TQString line; - while (!t.atEnd()) - { - line = t.readLine().stripWhiteSpace(); - if (line.startsWith("default_remote_host")) - { - TQString hostname = line.mid(20).stripWhiteSpace(); - m_defaultremotehost = hostname; - } - } - } - } - return m_defaultremotehost; -} - -void LprSettings::reload() -{ -} - -void LprSettings::configChanged() -{ - init(); -} diff --git a/kdeprint/lpr/lprsettings.h b/kdeprint/lpr/lprsettings.h deleted file mode 100644 index 01abbeeb3..000000000 --- a/kdeprint/lpr/lprsettings.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001,2002 Michael Goffioul - * - * 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 LPRSETTINGS_H -#define LPRSETTINGS_H - -#if !defined( _KDEPRINT_COMPILE ) && defined( __GNUC__ ) -#warning internal header, do not use except if you are a KDEPrint developer -#endif - -#include -#include - -/** - * @internal - * This class is internal to KDEPrint and is not intended to be - * used outside it. Please do not make use of this header, except - * if you're a KDEPrint developer. The API might change in the - * future and binary compatibility might be broken. - */ -class LprSettings : public TQObject, public KPReloadObject -{ -public: - LprSettings(TQObject *parent = 0, const char *name = 0); - ~LprSettings(); - - static LprSettings* self(); - - enum Mode { LPR, LPRng }; - Mode mode() const { return m_mode; } - void setMode(Mode m) { m_mode = m; } - TQString printcapFile(); - TQString defaultRemoteHost(); - bool isLocalPrintcap() { return m_local; } - TQString baseSpoolDir() { return m_spooldir; } - -protected: - void init(); - void reload(); - void configChanged(); - -private: - static LprSettings* m_self; - Mode m_mode; - QString m_printcapfile; - bool m_local; - QString m_spooldir; - TQString m_defaultremotehost; -}; - -#endif diff --git a/kdeprint/lpr/make_driver_db_lpr.c b/kdeprint/lpr/make_driver_db_lpr.c deleted file mode 100644 index fabbcb2fe..000000000 --- a/kdeprint/lpr/make_driver_db_lpr.c +++ /dev/null @@ -1,192 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "driverparse.h" - -void simplifyModel(const char *modelname) -{ - char *g; - - if ((g=strchr(modelname, ',')) != NULL) - *g = 0; - else if ((g=strchr(modelname, '(')) != NULL || (g=strchr(modelname, '{')) != NULL) - { - if (g != modelname) - { - if (isspace(*(g-1))) - g--; - *g = 0; - } - } -} - -int parseApsFile(const char *filename, FILE *output) -{ - FILE *apsfile; - char buf[256], modelname[256]; - char *c, *d; - - apsfile = fopen(filename, "r"); - if (apsfile == NULL) - return 0; - while (fgets(buf, 255, apsfile) != NULL) - { - if ((c = strchr(buf, '\n')) != NULL) - *c = 0; - if (strlen(buf) == 0 || buf[0] == '#' || (c = strchr(buf, '|')) == NULL) - continue; - *c = 0; - fprintf(output, "FILE=apsfilter/%s\n", c+1); - d = strchr(buf, ' '); - if (d) - { - *d = 0; - strlcpy(modelname, d+1, 255); - simplifyModel(modelname); - fprintf(output, "MANUFACTURER=%s\n", buf); - fprintf(output, "MODELNAME=%s\n", modelname); - fprintf(output, "MODEL=%s\n", modelname); - fprintf(output, "DESCRIPTION=%s %s (APSFilter + %s)\n", buf, d+1, c+1); - } - else - { - strlcpy(modelname, buf, 255); - simplifyModel(modelname); - fprintf(output, "MANUFACTURER=Unknown\n"); - fprintf(output, "MODELNAME=%s\n", modelname); - fprintf(output, "MODEL=%s\n", modelname); - fprintf(output, "DESCRIPTION=%s (APSFilter + %s)\n", buf, c+1); - } - fprintf(output, "\n"); - } - fclose(apsfile); - return 1; -} - -void initAps(const char *base) -{ - char drFile[256]; - DIR *apsdir; - struct dirent *d; - int gsversion = 0; - - if (strstr(base, "apsfilter") == NULL) - return; - - apsdir = opendir(base); - if (apsdir == NULL) - return; - while ((d = readdir(apsdir)) != NULL) - { - if (strncmp(d->d_name, "printer-", 8) != 0) - continue; - if (isdigit(d->d_name[8])) - { - if (gsversion) - continue; - gsversion = 1; - } - snprintf(drFile, 256, "apsfilter:%s/%s", base, d->d_name); - addFile(drFile); - } - closedir(apsdir); -} - -char* nextWord(char *c) -{ - char *d = c; - while (*d && isspace(*d)) - d++; - return d; -} - -int parseIfhpFile(const char *filename, FILE *output) -{ - char buf[1024]; - FILE *in; - char model[32], desc[256]; - - in = fopen(filename, "r"); - if (in == NULL) - return 0; - while (fgets(buf, 1023, in)) - { - char *c; - if ((c = strchr(buf, '\n')) != NULL) - *c = 0; - c = buf; - while (*c && isspace(*c)) - c++; - if (*c == '#') - continue; - if (strncmp(c, "IfhpModel:", 10) == 0) - strlcpy(model, nextWord(c+11), 31); - else if (strncmp(c, "Description:", 12) == 0) - strlcpy(desc, nextWord(c+13), 255); - else if (strncmp(c, "EndEntry", 8) == 0) - { - char *d = desc, *e, make[32] = {0}; - int first_time = 1; - do - { - e = strchr(d, ','); - if (e) - *e = 0; - if (first_time) - { - char *f = strchr(d, ' '); - if (f) - strlcpy(make, d, f-d); - first_time = 0; - } - if (strstr(d, "Family") == NULL) - { - char modelname[256] = {0}; - - strlcpy(modelname, d, 255); - simplifyModel(modelname); - fprintf(output, "FILE=lprngtool/%s\n", model); - fprintf(output, "MANUFACTURER=%s\n", make); - fprintf(output, "MODEL=%s\n", modelname); - fprintf(output, "MODELNAME=%s\n", modelname); - fprintf(output, "DESCRIPTION=%s (IFHP + %s)\n", d, model); - fprintf(output, "\n"); - } - if (e) - { - d = e+1; - while (*d && isspace(*d)) - d++; - } - } while (e); - } - } - fclose(in); - return 1; -} - -void initIfhp(const char *base) -{ - char path[256]; - - snprintf(path, 255, "lprngtool:%s/printerdb", base); - if (access(path+10, R_OK) == 0) - { - addFile(path); - } -} - -int main(int argc, char **argv) -{ - initFoomatic(); - registerHandler("apsfilter:", initAps, parseApsFile); - registerHandler("lprngtool:", initIfhp, parseIfhpFile); - return execute(argc, argv); -} diff --git a/kdeprint/lpr/matichandler.cpp b/kdeprint/lpr/matichandler.cpp deleted file mode 100644 index ef2f1584b..000000000 --- a/kdeprint/lpr/matichandler.cpp +++ /dev/null @@ -1,481 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul - * - * 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 "matichandler.h" -#include "printcapentry.h" -#include "kmprinter.h" -#include "matichelper.h" -#include "driver.h" -#include "kpipeprocess.h" -#include "kmmanager.h" -#include "kprinter.h" -#include "lprsettings.h" -#include "util.h" -#include "foomatic2loader.h" - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -MaticHandler::MaticHandler(KMManager *mgr) -: LprHandler("foomatic", mgr) -{ - TQString PATH = getenv("PATH"); - PATH.append(":/usr/sbin:/usr/local/sbin:/opt/sbin:/opt/local/sbin"); - m_exematicpath = KStandardDirs::findExe("lpdomatic", PATH); - m_ncpath = KStandardDirs::findExe("nc"); - m_smbpath = KStandardDirs::findExe("smbclient"); - m_rlprpath = KStandardDirs::findExe("rlpr"); -} - -bool MaticHandler::validate(PrintcapEntry *entry) -{ - if (entry) - return (entry->field("if").right(9) == "lpdomatic"); - return false; -} - -KMPrinter* MaticHandler::createPrinter(PrintcapEntry *entry) -{ - if (entry && validate(entry)) - { - KMPrinter *prt = new KMPrinter; - prt->setName(entry->name); - prt->setPrinterName(entry->name); - prt->setType(KMPrinter::Printer); - //if (entry->field("lp") == "/dev/null" || entry->field("lp").isEmpty()) - // prt->addType(KMPrinter::Remote); - return prt; - } - return NULL; -} - -bool MaticHandler::completePrinter(KMPrinter *prt, PrintcapEntry *entry, bool shortmode) -{ - TQString val = entry->field("lp"); - if (val == "/dev/null" || val.isEmpty()) - { - prt->setLocation(i18n("Network printer")); - } - else - { - prt->setLocation(i18n("Local printer on %1").arg(val)); - KURL url(val); - if (val.find("usb") != -1) - url.setProtocol("usb"); - else - url.setProtocol("parallel"); - prt->setDevice(url.url()); - } - prt->setDescription(entry->aliases.join(", ")); - - if (!shortmode) - { - Foomatic2Loader loader; - if ( loader.readFromFile( maticFile( entry ) ) ) - { - TQString postpipe = loader.data()[ "POSTPIPE" ].toString(); - if (!postpipe.isEmpty()) - { - KURL url ( parsePostpipe(postpipe) ); - if (!url.isEmpty()) - { - TQString ds = TQString::tqfromLatin1("%1 (%2)").arg(prt->location()).arg(url.protocol()); - prt->setDevice(url.url()); - prt->setLocation(ds); - } - } - - TQMap m = loader.data()[ "VAR" ].toMap(); - if ( !m.isEmpty() ) - { - prt->setManufacturer(m["make"].toString()); - prt->setModel(m["model"].toString()); - prt->setDriverInfo(TQString::tqfromLatin1("%1 %2 (%3)").arg(prt->manufacturer()).arg(prt->model()).arg(m["driver"].toString())); - } - } - } - - return true; -} - -TQString MaticHandler::parsePostpipe(const TQString& s) -{ - TQString url; - int p = s.findRev('|'); - TQStringList args = TQStringList::split(" ", s.right(s.length()-p-1)); - - if (args.count() != 0) - { - // socket printer - if (args[0].right(3) == "/nc") - { - url = "socket://" + args[ 1 ]; - if ( args.count() > 2 ) - url += ":" + args[ 2 ]; - else - url += ":9100"; - } - // smb printer - else if (args[0].right(10) == "/smbclient") - { - TQStringList host_components = TQStringList::split(TQRegExp("/|\\\\\""), args[1], false); - TQString workgrp, user, pass; - for (uint i=2; irandomString(8)); - ::system(TQFile::encodeName("cp " + KProcess::quote(origfilename) + " " + KProcess::quote(filename))); - DrMain *driver = Foomatic2Loader::loadDriver(filename); - if (driver) - { - driver->set("template", filename); - driver->set("temporary", "true"); - return driver; - } - else - return NULL; -} - -DrMain* MaticHandler::loadDbDriver(const TQString& path) -{ - TQStringList comps = TQStringList::split('/', path, false); - if (comps.count() < 3 || comps[0] != "foomatic") - { - manager()->setErrorMsg(i18n("Internal error.")); - return NULL; - } - - TQString tmpFile = locateLocal("tmp", "foomatic_" + kapp->randomString(8)); - TQString PATH = getenv("PATH") + TQString::tqfromLatin1(":/usr/sbin:/usr/local/sbin:/opt/sbin:/opt/local/sbin"); - TQString exe = KStandardDirs::findExe("foomatic-datafile", PATH); - if (exe.isEmpty()) - { - manager()->setErrorMsg(i18n("Unable to find the executable foomatic-datafile " - "in your PATH. Check that Foomatic is correctly installed.")); - return NULL; - } - - KPipeProcess in; - TQFile out(tmpFile); - TQString cmd = KProcess::quote(exe); - cmd += " -t lpd -d "; - cmd += KProcess::quote(comps[2]); - cmd += " -p "; - cmd += KProcess::quote(comps[1]); - if (in.open(cmd) && out.open(IO_WriteOnly)) - { - TQTextStream tin(&in), tout(&out); - TQString line; - while (!tin.atEnd()) - { - line = tin.readLine(); - tout << line << endl; - } - in.close(); - out.close(); - - DrMain *driver = Foomatic2Loader::loadDriver(tmpFile); - if (driver) - { - driver->set("template", tmpFile); - driver->set("temporary", tmpFile); - return driver; - } - } - manager()->setErrorMsg(i18n("Unable to create the Foomatic driver [%1,%2]. " - "Either that driver does not exist, or you don't have " - "the required permissions to perform that operation.").arg(comps[1]).arg(comps[2])); - return NULL; -} - -bool MaticHandler::savePrinterDriver(KMPrinter *prt, PrintcapEntry *entry, DrMain *driver, bool*) -{ - TQFile tmpFile(locateLocal("tmp", "foomatic_" + kapp->randomString(8))); - TQFile inFile(driver->get("template")); - TQString outFile = maticFile(entry); - bool result(false); - TQString postpipe = createPostpipe(prt->device()); - - if (inFile.open(IO_ReadOnly) && tmpFile.open(IO_WriteOnly)) - { - TQTextStream tin(&inFile), tout(&tmpFile); - TQString line, optname; - int p(-1), q(-1); - if (!postpipe.isEmpty()) - tout << "$postpipe = \"" << postpipe << "\";" << endl; - while (!tin.atEnd()) - { - line = tin.readLine(); - if (line.stripWhiteSpace().startsWith("$postpipe")) - continue; - else if ((p = line.find("'name'")) != -1) - { - p = line.find('\'', p+6)+1; - q = line.find('\'', p); - optname = line.mid(p, q-p); - } - else if ((p = line.find("'default'")) != -1) - { - DrBase *opt = driver->findOption(optname); - if (opt) - { - tout << line.left(p+9) << " => '" << opt->valueText() << "'," << endl; - continue; - } - } - tout << line << endl; - } - inFile.close(); - tmpFile.close(); - - TQString cmd = "mv " + KProcess::quote(tmpFile.name()) + " " + KProcess::quote(outFile); - int status = ::system(TQFile::encodeName(cmd).data()); - TQFile::remove(tmpFile.name()); - result = (status != -1 && WEXITSTATUS(status) == 0); - } - - if (!result) - manager()->setErrorMsg(i18n("You probably don't have the required permissions " - "to perform that operation.")); - TQFile::remove(tmpFile.name()); - if (!result || entry->field("ppdfile").isEmpty()) - return result; - else - return savePpdFile(driver, entry->field("ppdfile")); -} - -bool MaticHandler::savePpdFile(DrMain *driver, const TQString& filename) -{ - TQString mdriver(driver->get("matic_driver")), mprinter(driver->get("matic_printer")); - if (mdriver.isEmpty() || mprinter.isEmpty()) - return true; - - TQString PATH = getenv("PATH") + TQString::tqfromLatin1(":/usr/sbin:/usr/local/sbin:/opt/sbin:/opt/local/sbin"); - TQString exe = KStandardDirs::findExe("foomatic-datafile", PATH); - if (exe.isEmpty()) - { - manager()->setErrorMsg(i18n("Unable to find the executable foomatic-datafile " - "in your PATH. Check that Foomatic is correctly installed.")); - return false; - } - - KPipeProcess in; - TQFile out(filename); - if (in.open(exe + " -t cups -d " + mdriver + " -p " + mprinter) && out.open(IO_WriteOnly)) - { - TQTextStream tin(&in), tout(&out); - TQString line, optname; - TQRegExp re("^\\*Default(\\w+):"), foo("'name'\\s+=>\\s+'(\\w+)'"), foo2("'\\w+'\\s*,\\s*$"); - while (!tin.atEnd()) - { - line = tin.readLine(); - if (line.startsWith("*% COMDATA #")) - { - if (line.find("'default'") != -1) - { - DrBase *opt = (optname.isEmpty() ? NULL : driver->findOption(optname)); - if (opt) - { - line.replace(foo2, "'"+opt->valueText()+"',"); - } - } - else if (foo.search(line) != -1) - optname = foo.cap(1); - } - else if (re.search(line) != -1) - { - DrBase *opt = driver->findOption(re.cap(1)); - if (opt) - { - TQString val = opt->valueText(); - if (opt->type() == DrBase::Boolean) - val = (val == "1" ? "True" : "False"); - tout << "*Default" << opt->name() << ": " << val << endl; - continue; - } - } - tout << line << endl; - } - in.close(); - out.close(); - - return true; - } - manager()->setErrorMsg(i18n("Unable to create the Foomatic driver [%1,%2]. " - "Either that driver does not exist, or you don't have " - "the required permissions to perform that operation.").arg(mdriver).arg(mprinter)); - - return false; -} - -PrintcapEntry* MaticHandler::createEntry(KMPrinter *prt) -{ - KURL url( prt->device() ); - TQString prot = url.protocol(); - if ((prot != "lpd" || m_rlprpath.isEmpty()) && - (prot != "socket" || m_ncpath.isEmpty()) && - (prot != "smb" || m_smbpath.isEmpty()) && - prot != "parallel") - { - manager()->setErrorMsg(i18n("Unsupported backend: %1.").arg(prot)); - return NULL; - } - if (m_exematicpath.isEmpty()) - { - manager()->setErrorMsg(i18n("Unable to find executable lpdomatic. " - "Check that Foomatic is correctly installed " - "and that lpdomatic is installed in a standard " - "location.")); - return NULL; - } - PrintcapEntry *entry = new PrintcapEntry; - entry->addField("lf", Field::String, "/var/log/lp-errs"); - entry->addField("lp", Field::String, (prot != "parallel" ? "/dev/null" : url.path())); - entry->addField("if", Field::String, m_exematicpath); - if (LprSettings::self()->mode() == LprSettings::LPRng) - { - entry->addField("filter_options", Field::String, " --lprng $Z /etc/foomatic/lpd/"+prt->printerName()+".lom"); - entry->addField("force_localhost", Field::Boolean); - entry->addField("ppdfile", Field::String, "/etc/foomatic/"+prt->printerName()+".ppd"); - } - else - entry->addField("af", Field::String, "/etc/foomatic/lpd/"+prt->printerName()+".lom"); - if (!prt->description().isEmpty()) - entry->aliases << prt->description(); - return entry; -} - -bool MaticHandler::removePrinter(KMPrinter *prt, PrintcapEntry *entry) -{ - // remove Foomatic driver - TQString af = entry->field("af"); - if (af.isEmpty()) - return true; - if (!TQFile::remove(af)) - { - manager()->setErrorMsg(i18n("Unable to remove driver file %1.").arg(af)); - return false; - } - return true; -} - -TQString MaticHandler::printOptions(KPrinter *printer) -{ - TQMap opts = printer->options(); - TQString str; - for (TQMap::Iterator it=opts.begin(); it!=opts.end(); ++it) - { - if (it.key().startsWith("kde-") || it.key().startsWith("_kde-") || it.key().startsWith( "app-" )) - continue; - str += (" " + it.key() + "=" + (*it)); - } - if (!str.isEmpty()) - str.prepend("-J '").append("'"); - return str; -} - -TQString MaticHandler::driverDirInternal() -{ - return locateDir("foomatic/db/source", "/usr/share:/usr/local/share:/opt/share"); -} diff --git a/kdeprint/lpr/matichandler.h b/kdeprint/lpr/matichandler.h deleted file mode 100644 index e30eee39e..000000000 --- a/kdeprint/lpr/matichandler.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul - * - * 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 MATICHANDLER_H -#define MATICHANDLER_H - -#include "lprhandler.h" - -#include - -class MaticBlock; - -class MaticHandler : public LprHandler -{ -public: - MaticHandler(KMManager *mgr = 0); - - bool validate(PrintcapEntry*); - KMPrinter* createPrinter(PrintcapEntry*); - bool completePrinter(KMPrinter*, PrintcapEntry*, bool = true); - DrMain* loadDriver(KMPrinter*, PrintcapEntry*, bool = false); - DrMain* loadDbDriver(const TQString&); - bool savePrinterDriver(KMPrinter*, PrintcapEntry*, DrMain*, bool* = 0); - PrintcapEntry* createEntry(KMPrinter*); - bool removePrinter(KMPrinter*, PrintcapEntry*); - TQString printOptions(KPrinter*); - -protected: - TQString driverDirInternal(); - -private: - TQString parsePostpipe(const TQString&); - TQString createPostpipe(const TQString&); - bool savePpdFile(DrMain*, const TQString&); - -private: - TQString m_exematicpath; - TQString m_ncpath, m_smbpath, m_rlprpath; -}; - -#endif diff --git a/kdeprint/lpr/matichelper.cpp b/kdeprint/lpr/matichelper.cpp deleted file mode 100644 index ec0041b7c..000000000 --- a/kdeprint/lpr/matichelper.cpp +++ /dev/null @@ -1,38 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2002 Michael Goffioul - * - * 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 "matichelper.h" -#include "printcapentry.h" -#include "driver.h" - -TQString maticFile(PrintcapEntry *entry) -{ - TQString s(entry->field("af")); - if (s.isEmpty()) - { - s = entry->field("filter_options"); - if (!s.isEmpty()) - { - int p = s.findRev(' '); - if (p != -1) - s = s.mid(p+1); - } - } - return s; -} diff --git a/kdeprint/lpr/matichelper.h b/kdeprint/lpr/matichelper.h deleted file mode 100644 index 5a2b64fe3..000000000 --- a/kdeprint/lpr/matichelper.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2002 Michael Goffioul - * - * 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 MATICHELPER_H -#define MATICHELPER_H - -#include - -class PrintcapEntry; - -TQString maticFile(PrintcapEntry*); - -#endif diff --git a/kdeprint/lpr/printcapentry.cpp b/kdeprint/lpr/printcapentry.cpp deleted file mode 100644 index 9c83537e4..000000000 --- a/kdeprint/lpr/printcapentry.cpp +++ /dev/null @@ -1,82 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001,2002 Michael Goffioul - * - * 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 "printcapentry.h" - -TQString Field::toString() const -{ - TQString s = name; - switch (type) - { - case String: - s += ("=" + value); - break; - case Integer: - s += ("#" + value); - break; - case Boolean: - if (!value.toInt()) - s += "@"; - break; - } - return s; -} - -bool PrintcapEntry::writeEntry(TQTextStream& t) -{ - t << comment << endl; - t << name; - if (aliases.count() > 0) - t << '|' << aliases.join("|"); - t << ':'; - for (TQMap::ConstIterator it=fields.begin(); it!=fields.end(); ++it) - { - t << '\\' << endl << " :"; - t << (*it).name; - switch ((*it).type) - { - case Field::String: - t << '=' << (*it).value << ':'; - break; - case Field::Integer: - t << '#' << (*it).value << ':'; - break; - case Field::Boolean: - t << ':'; - break; - default: - t << endl << endl; - return false; - } - } - t << endl; - if (!postcomment.isEmpty()) - t << postcomment << endl; - t << endl; - return true; -} - -void PrintcapEntry::addField(const TQString& name, Field::Type type, const TQString& value) -{ - Field f; - f.name = name; - f.type = type; - f.value = value; - fields[name] = f; -} diff --git a/kdeprint/lpr/printcapentry.h b/kdeprint/lpr/printcapentry.h deleted file mode 100644 index f8ba99197..000000000 --- a/kdeprint/lpr/printcapentry.h +++ /dev/null @@ -1,81 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul - * - * 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 PRINTCAPENTRY_H -#define PRINTCAPENTRY_H - -#if !defined( _KDEPRINT_COMPILE ) && defined( __GNUC__ ) -#warning internal header, do not use except if you are a KDEPrint developer -#endif - -#include -#include -#include -#include - -/** - * @internal - * This class is internal to KDEPrint and is not intended to be - * used outside it. Please do not make use of this header, except - * if you're a KDEPrint developer. The API might change in the - * future and binary compatibility might be broken. - */ -class Field -{ -public: - enum Type { String, Integer, Boolean }; - Field() : type(String) {} - Field(const Field &f) : type(f.type), name(f.name), value(f.value) {} - Field& operator= (const Field& f) - { - type = f.type; - name = f.name; - value = f.value; - return (*this); - } - TQString toString() const; - - Type type; - TQString name; - TQString value; -}; - -/** - * @internal - * This class is internal to KDEPrint and is not intended to be - * used outside it. Please do not make use of this header, except - * if you're a KDEPrint developer. The API might change in the - * future and binary compatibility might be broken. - */ -class PrintcapEntry -{ -public: - TQString name; - TQStringList aliases; - TQString comment; - TQMap fields; - TQString postcomment; - - bool has(const TQString& f) const { return fields.contains(f); } - TQString field(const TQString& f) const { return fields[f].value; } - bool writeEntry(TQTextStream&); - void addField(const TQString& name, Field::Type type = Field::Boolean, const TQString& value = TQString::null); -}; - -#endif diff --git a/kdeprint/lpr/printcapreader.cpp b/kdeprint/lpr/printcapreader.cpp deleted file mode 100644 index 00016c14f..000000000 --- a/kdeprint/lpr/printcapreader.cpp +++ /dev/null @@ -1,176 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul - * - * 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 "printcapreader.h" -#include "printcapentry.h" - -#include -#include - -void PrintcapReader::setPrintcapFile(TQFile *f) -{ - if (f->isOpen()) - { - m_stream.setDevice(TQT_TQIODEVICE(f)); - m_buffer = TQString::null; - } -} - -bool PrintcapReader::nextLine(TQString& line) -{ - if (m_stream.atEnd() && m_buffer.isEmpty()) - return false; - else if (!m_buffer.isEmpty()) - { - line = m_buffer; - m_buffer = TQString::null; - } - else - line = m_stream.readLine().stripWhiteSpace(); - // strip any '\' at the end - if (line[line.length()-1] == '\\') - line = line.left(line.length()-1).stripWhiteSpace(); - return true; -} - -void PrintcapReader::unputLine(const TQString& s) -{ - m_buffer = s; -} - -PrintcapEntry* PrintcapReader::nextEntry() -{ - if (!m_stream.tqdevice()) - return NULL; - - TQString line, comment, name, fields, buf; - // skip comments, keep last one - while (1) - { - if (!nextLine(line)) - return NULL; - else if (line.isEmpty()) - continue; - else if (line[0] == '#') - comment = line; - else - { - buf = line; - break; - } - } - - // look for the complete entry - while (1) - { - // we found the entry if we reached the end of file or - // found an empty line - if (!nextLine(line) || line.isEmpty()) - break; - // just skip comments - else if (line[0] == '#') - continue; - // lines starting with ':' or '|' are appended - else if (line[0] == ':' || line[0] == '|') - buf += line; - // otherwise it's another entry, put it back in the - // buffer - else - { - unputLine(line); - break; - } - } - - // now parse the entry - kdDebug() << "COMMENT: " << comment << endl; - kdDebug() << "LINE: " << buf << endl; - int p = buf.find(':'); - if (p == -1) - name = buf; - else - { - name = buf.left(p); - fields = buf.right(buf.length()-p-1); - } - - // construct the printcap entry - if (!name.isEmpty()) - { - PrintcapEntry *entry = new PrintcapEntry; - TQStringList l = TQStringList::split('|', name, false); - entry->name = l[0]; - entry->comment = comment; - // kdDebug() << "Printer: " << entry->name << endl; - // kdDebug() << "Aliases:" << endl; - for (uint i=1; ialiases << l[i]; - // kdDebug() << " " << l[i] << endl; - } - if (!fields.isEmpty()) - { - // kdDebug() << "Fields:" << endl; - // kdDebug() << "(" << fields << ")" << endl; - l = TQStringList::split(':', fields, false); - for (TQStringList::ConstIterator it=l.begin(); it!=l.end(); ++it) - { - Field f; - int p = (*it).find('='); - if (p == -1) - { - p = (*it).find('#'); - if (p == -1) - { - f.type = Field::Boolean; - p = (*it).find('@'); - if (p == -1) - { - f.name = (*it); - f.value = "1"; - } - else - { - f.name = (*it).left(p); - f.value = "0"; - } - } - else - { - f.type = Field::Integer; - f.name = (*it).left(p); - f.value = (*it).mid(p+1); - } - } - else - { - f.type = Field::String; - f.name = (*it).left(p); - f.value = (*it).mid(p+1); - if (f.value.startsWith("\"")) - f.value = f.value.mid(1, f.value.length()-2); - } - entry->fields[f.name] = f; - } - } - // kdDebug() << endl; - return entry; - } - return NULL; -} diff --git a/kdeprint/lpr/printcapreader.h b/kdeprint/lpr/printcapreader.h deleted file mode 100644 index 2236e5068..000000000 --- a/kdeprint/lpr/printcapreader.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2001 Michael Goffioul - * - * 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 PRINTCAPREADER_H -#define PRINTCAPREADER_H - -#include -#include - -class TQFile; -class PrintcapEntry; - -class PrintcapReader -{ -public: - void setPrintcapFile(TQFile*); - PrintcapEntry* nextEntry(); - -private: - TQString m_buffer; - TQTextStream m_stream; - - bool nextLine(TQString&); - void unputLine(const TQString&); -}; - -#endif -- cgit v1.2.1