KMWFax::KMWFax(QWidget *parent, const char *name) : KMWizardPage(parent,name) { m_ID = KMWizard::Custom+2; m_title = i18n("Fax Serial Device"); m_nextpage = KMWizard::Driver; QLabel *lab = new QLabel(this); lab->setText(i18n("<p>Select the device which your serial Fax/Modem is connected to.</p>")); m_list = new KListBox(this); QVBoxLayout *l1 = new QVBoxLayout(this,0,10); l1->addWidget(lab,0); l1->addWidget(m_list,1); // initialize IppRequest req; req.setOperation(CUPS_GET_DEVICES); QString uri = QString::fromLatin1("ipp://%1/printers/").arg(CupsInfos::self()->hostaddr()); req.addURI(IPP_TAG_OPERATION,"printer-uri",uri); if (req.doRequest("/")) { ipp_attribute_t *attr = req.first(); while (attr) { if (attr->name && strcmp(attr->name,"device-uri") == 0 && strncmp(attr->values[0].string.text,"fax",3) == 0) { m_list->insertItem(SmallIcon("blockdevice"),QString::fromLatin1(attr->values[0].string.text)); } attr = attr->next; } } }
void KMWIppSelect::initPrinter(KMPrinter *p) { // storage variables QString host, login, password; int port; // save config host = CupsInfos::self()->host(); login = CupsInfos::self()->login(); password = CupsInfos::self()->password(); port = CupsInfos::self()->port(); m_list->clear(); // retrieve printer list KURL url = p->device(); CupsInfos::self()->setHost(url.host()); CupsInfos::self()->setLogin(url.user()); CupsInfos::self()->setPassword(url.pass()); CupsInfos::self()->setPort(url.port()); IppRequest req; QString uri; req.setOperation(CUPS_GET_PRINTERS); uri = QString::fromLatin1("ipp://%1/printers/").arg(CupsInfos::self()->hostaddr()); req.addURI(IPP_TAG_OPERATION,"printer-uri",uri); req.addKeyword(IPP_TAG_OPERATION,"requested-attributes",QString::fromLatin1("printer-name")); if (req.doRequest("/printers/")) { ipp_attribute_t *attr = req.first(); while (attr) { if (attr->name && strcmp(attr->name,"printer-name") == 0) m_list->insertItem(SmallIcon("kdeprint_printer"),QString::fromLatin1(attr->values[0].string.text)); attr = attr->next; } m_list->sort(); } // restore config CupsInfos::self()->setHost(host); CupsInfos::self()->setLogin(login); CupsInfos::self()->setPassword(password); CupsInfos::self()->setPort(port); }
void KMCupsJobManager::parseListAnswer(IppRequest& req, KMPrinter *pr) { ipp_attribute_t *attr = req.first(); KMJob *job = new KMJob(); QString uri; while (attr) { QString name(attr->name); if (name == "job-id") job->setId(attr->values[0].integer); else if (name == "job-uri") job->setUri(QString::fromLocal8Bit(attr->values[0].string.text)); else if (name == "job-name") job->setName(QString::fromLocal8Bit(attr->values[0].string.text)); else if (name == "job-state") { switch (attr->values[0].integer) { case IPP_JOB_PENDING: job->setState(KMJob::Queued); break; case IPP_JOB_HELD: job->setState(KMJob::Held); break; case IPP_JOB_PROCESSING: job->setState(KMJob::Printing); break; case IPP_JOB_STOPPED: job->setState(KMJob::Error); break; case IPP_JOB_CANCELLED: job->setState(KMJob::Cancelled); break; case IPP_JOB_ABORTED: job->setState(KMJob::Aborted); break; case IPP_JOB_COMPLETED: job->setState(KMJob::Completed); break; default: job->setState(KMJob::Unknown); break; } } else if (name == "job-k-octets") job->setSize(attr->values[0].integer); else if (name == "job-originating-user-name") job->setOwner(QString::fromLocal8Bit(attr->values[0].string.text)); else if (name == "job-k-octets-completed") job->setProcessedSize(attr->values[0].integer); else if (name == "job-media-sheets") job->setPages(attr->values[0].integer); else if (name == "job-media-sheets-completed") job->setProcessedPages(attr->values[0].integer); else if (name == "job-printer-uri" && !pr->isRemote()) { QString str(attr->values[0].string.text); int p = str.findRev('/'); if (p != -1) job->setPrinter(str.mid(p+1)); } else if (name == "job-priority") { job->setAttribute(0, QString::fromLatin1("%1").arg(attr->values[0].integer, 3)); } else if (name == "job-billing") { job->setAttributeCount(2); job->setAttribute(1, QString::fromLocal8Bit(attr->values[0].string.text)); } if (name.isEmpty() || attr == req.last()) { if (job->printer().isEmpty()) job->setPrinter(pr->printerName()); job->setRemote(pr->isRemote()); addJob(job); // don't use job after this call !!! job = new KMJob(); } attr = attr->next; } delete job; }