bool KMCupsJobManager::changePriority(const QPtrList<KMJob>& jobs, bool up) { QPtrListIterator<KMJob> it(jobs); bool result(true); for (; it.current() && result; ++it) { int value = it.current()->attribute(0).toInt(); if (up) value = QMIN(value+10, 100); else value = QMAX(value-10, 1); IppRequest req; /* if (!it.current()->uri().isEmpty()) { KURL url(it.current()->uri()); req.setHost(url.host()); req.setPort(url.port()); } */ req.setOperation(IPP_SET_JOB_ATTRIBUTES); req.addURI(IPP_TAG_OPERATION, "job-uri", it.current()->uri()); req.addName(IPP_TAG_OPERATION, "requesting-user-name", CupsInfos::self()->login()); req.addInteger(IPP_TAG_JOB, "job-priority", value); if (!(result = req.doRequest("/jobs/"))) KMManager::self()->setErrorMsg(i18n("Unable to change job priority: ")+req.statusMessage()); } return result; }
bool KMCupsJobManager::listJobs(const QString& prname, KMJobManager::JobType type, int limit) { IppRequest req; QStringList keys; CupsInfos *infos = CupsInfos::self(); // wanted attributes keys.append("job-id"); keys.append("job-uri"); keys.append("job-name"); keys.append("job-state"); keys.append("job-printer-uri"); keys.append("job-k-octets"); keys.append("job-originating-user-name"); keys.append("job-k-octets-completed"); keys.append("job-media-sheets"); keys.append("job-media-sheets-completed"); keys.append("job-priority"); keys.append("job-billing"); req.setOperation(IPP_GET_JOBS); // add printer-uri KMPrinter *mp = KMManager::self()->findPrinter(prname); if (!mp) return false; if (!mp->uri().isEmpty()) { req.addURI(IPP_TAG_OPERATION, "printer-uri", mp->uri().prettyURL()); /* req.setHost(mp->uri().host()); req.setPort(mp->uri().port()); */ } else req.addURI(IPP_TAG_OPERATION, "printer-uri", QString("ipp://%1/%2/%3").arg(infos->hostaddr(), (mp&&mp->isClass())?"classes":"printers", prname)); // other attributes req.addKeyword(IPP_TAG_OPERATION, "requested-attributes", keys); if (type == KMJobManager::CompletedJobs) req.addKeyword(IPP_TAG_OPERATION,"which-jobs",QString::fromLatin1("completed")); if (limit > 0) req.addInteger(IPP_TAG_OPERATION,"limit",limit); // send request if (req.doRequest("/")) parseListAnswer(req, mp); else return false; return true; }