# kdeprint Library API Documentation

Overview | Class Hierarchy | Classes | Classes (annotated) | Members | Namespaces | Source Files

# kmlprjobmanager.cpp

    00001 /*
    00002  *  This file is part of the KDE libraries
    00003  *  Copyright (c) 2001 Michael Goffioul <kdeprint@swing.be>
    00004  *
    00005  *  This library is free software; you can redistribute it and/or
    00006  *  modify it under the terms of the GNU Library General Public
    00007  *  License version 2 as published by the Free Software Foundation.
    00008  *
    00009  *  This library is distributed in the hope that it will be useful,
    00010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
    00011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    00012  *  Library General Public License for more details.
    00013  *
    00014  *  You should have received a copy of the GNU Library General Public License
    00015  *  along with this library; see the file COPYING.LIB.  If not, write to
    00016  *  the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    00017  *  Boston, MA 02111-1307, USA.
    00018  **/
    00019
    00020 #include "kmlprjobmanager.h"
    00021 #include "kmlprmanager.h"
    00022 #include "lpqhelper.h"
    00023 #include "lpchelper.h"
    00024 #include "kmjob.h"
    00025 #include "lprsettings.h"
    00026
    00027 #include <qptrlist.h>
    00028 #include <klocale.h>
    00029
    00030 KMLprJobManager::KMLprJobManager(QObject *parent, const char *name, const QStringList & /*args*/)
    00031 : KMJobManager(parent, name)
    00032 {
    00033     m_lpqhelper = new LpqHelper(this, "LpqHelper");
    00034 }
    00035
    00036 bool KMLprJobManager::listJobs(const QString& prname, JobType, int limit)
    00037 {
    00038     QPtrList<KMJob> jobList;
    00039     jobList.setAutoDelete(false);
    00040     m_lpqhelper->listJobs(jobList, prname, limit);
    00041     QPtrListIterator<KMJob> it(jobList);
    00042     for (; it.current(); ++it)
    00043         addJob(it.current());
    00044     return false;
    00045 }
    00046
    00047 LpcHelper* KMLprJobManager::lpcHelper()
    00048 {
    00049     return static_cast<KMLprManager*>(KMManager::self())->lpcHelper();
    00050 }
    00051
    00052 int KMLprJobManager::actions()
    00053 {
    00054     if (LprSettings::self()->mode() == LprSettings::LPR)
    00055         return KMJob::Remove;
    00056     else
    00057         // some additional actions to be added here
    00058         return (KMJob::Remove | KMJob::Hold | KMJob::Resume);
    00059 }
    00060
    00061 bool KMLprJobManager::sendCommandSystemJob(const QPtrList<KMJob>& jobs, int action, const QString& arg)
    00062 {
    00063     QString msg;
    00064     QPtrListIterator<KMJob> it(jobs);
    00065     bool    status(true);
    00066     LpcHelper   *helper = lpcHelper();
    00067
    00068     for (; it.current() && status; ++it)
    00069     {
    00070         switch (action)
    00071         {
    00072             case KMJob::Remove:
    00073                 status = helper->removeJob(it.current(), msg);
    00074                 break;
    00075             case KMJob::Hold:
    00076                 status = helper->changeJobState(it.current(), KMJob::Held, msg);
    00077                 break;
    00078             case KMJob::Resume:
    00079                 status = helper->changeJobState(it.current(), KMJob::Queued, msg);
    00080                 break;
    00081             default:
    00082                 status = false;
    00083                 msg = i18n("Unsupported operation.");
    00084                 break;
    00085         }
    00086     }
    00087     if (!status && !msg.isEmpty())
    00088         KMManager::self()->setErrorMsg(msg);
    00089     return status;
    00090 }

This file is part of the documentation for kdeprint Library Version 3.4.1.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Sat Jun 11 20:31:02 2005 by doxygen 1.4.1 written by Dimitri van Heesch, © 1997-2003