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/rlpr/kmrlprmanager.cpp | 158 ---------------------------------------- 1 file changed, 158 deletions(-) delete mode 100644 kdeprint/rlpr/kmrlprmanager.cpp (limited to 'kdeprint/rlpr/kmrlprmanager.cpp') diff --git a/kdeprint/rlpr/kmrlprmanager.cpp b/kdeprint/rlpr/kmrlprmanager.cpp deleted file mode 100644 index 64f6acde1..000000000 --- a/kdeprint/rlpr/kmrlprmanager.cpp +++ /dev/null @@ -1,158 +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 "kmrlprmanager.h" -#include "kmprinter.h" - -#include -#include -#include -#include - -#include -#include - -KMRlprManager::KMRlprManager(TQObject *parent, const char *name, const TQStringList & /*args*/) -: KMManager(parent,name) -{ - setHasManagement(true); - setPrinterOperationMask(KMManager::PrinterCreation|KMManager::PrinterRemoval|KMManager::PrinterTesting); -} - -KMRlprManager::~KMRlprManager() -{ -} - -bool KMRlprManager::createPrinter(KMPrinter *p) -{ - if (p->name().isEmpty()) - setErrorMsg(i18n("Empty printer name.")); - else if (p->option("host").isEmpty()) - setErrorMsg(i18n("Empty host name.")); - else if (p->option("queue").isEmpty()) - setErrorMsg(i18n("Empty queue name.")); - else - { - KMPrinter *pr = new KMPrinter(*p); - addPrinter(pr); - savePrinters(); - return true; - } - return false; -} - -bool KMRlprManager::removePrinter(KMPrinter *p) -{ - if (m_printers.findRef(p) == -1) - setErrorMsg(i18n("Printer not found.")); - else - { - m_printers.removeRef(p); - savePrinters(); - return true; - } - return false; -} - -bool KMRlprManager::testPrinter(KMPrinter *) -{ - setErrorMsg(i18n("Not implemented yet.")); - return false; -} - -void KMRlprManager::listPrinters() -{ - TQFileInfo pfi(printerFile()); - if (pfi.exists() && (!m_checktime.isValid() || m_checktime < pfi.lastModified())) - { - loadPrintersConf(pfi.absFilePath()); - m_checktime = pfi.lastModified(); - } - else - discardAllPrinters(false); -} - -void KMRlprManager::loadPrintersConf(const TQString& filename) -{ - TQFile f(filename); - if (f.exists() && f.open(IO_ReadOnly)) - { - TQTextStream t(&f); - TQString line; - while (!t.eof()) - { - line = t.readLine().stripWhiteSpace(); - if (line.isEmpty() || line[0] == '#') - continue; - TQStringList w = TQStringList::split('\t',line,true); - if (w.count() < 3) - continue; - - KMPrinter *printer = new KMPrinter; - printer->setName(w[0]); - printer->setPrinterName(w[0]); - printer->setType(KMPrinter::Printer); - printer->setOption("host",w[1]); - printer->setOption("queue",w[2]); - if (w.count() > 3) - { - printer->setDescription(w[3]); - if (w.count() > 4) printer->setLocation(w[4]); - } - printer->setState(KMPrinter::Idle); - printer->setDevice(TQString::tqfromLatin1("lpd://%1/%2").arg(w[1]).arg(w[2])); - - addPrinter(printer); - } - } -} - -void KMRlprManager::savePrinters() -{ - savePrintersConf(printerFile()); -} - -void KMRlprManager::savePrintersConf(const TQString& filename) -{ - TQFile f(filename); - if (f.open(IO_WriteOnly)) - { - TQTextStream t(&f); - t << "# File generated by KDE print system. Don't edit by hand." << endl; - TQPtrListIterator it(m_printers); - for (;it.current();++it) - { - if (!it.current()->name().isEmpty() && it.current()->instanceName().isEmpty()) - { - TQString host = it.current()->option("host"); - TQString queue = it.current()->option("queue"); - if (!host.isEmpty() && !queue.isEmpty()) - { - t << it.current()->name() << '\t' << host << '\t' << queue; - t << '\t' << it.current()->description() << '\t' << it.current()->location() << endl; - } - } - } - } -} - -TQString KMRlprManager::printerFile() -{ - return locateLocal("data","tdeprint/printers.conf"); -} -- cgit v1.2.1