00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
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 & )
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
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 }