kmwfax.cpp
00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 #include "kmwfax.h"
00021 #include "kmwizard.h"
00022 #include "kmprinter.h"
00023 #include "ipprequest.h"
00024 #include "cupsinfos.h"
00025 
00026 #include <qlabel.h>
00027 #include <qlayout.h>
00028 #include <klistbox.h>
00029 #include <klocale.h>
00030 #include <kiconloader.h>
00031 #include <kurl.h>
00032 
00033 KMWFax::KMWFax(QWidget *parent, const char *name)
00034 : KMWizardPage(parent,name)
00035 {
00036     m_ID = KMWizard::Custom+2;
00037     m_title = i18n("Fax Serial Device");
00038     m_nextpage = KMWizard::Driver;
00039 
00040     QLabel  *lab = new QLabel(this);
00041     lab->setText(i18n("<p>Select the device which your serial Fax/Modem is connected to.</p>"));
00042     m_list = new KListBox(this);
00043 
00044     QVBoxLayout *l1 = new QVBoxLayout(this,0,10);
00045     l1->addWidget(lab,0);
00046     l1->addWidget(m_list,1);
00047 
00048     
00049     IppRequest  req;
00050     req.setOperation(CUPS_GET_DEVICES);
00051     QString uri = QString::fromLatin1("ipp://%1:%2/printers/").arg(CupsInfos::self()->host()).arg(CupsInfos::self()->port());
00052     req.addURI(IPP_TAG_OPERATION,"printer-uri",uri);
00053     if (req.doRequest("/"))
00054     {
00055         ipp_attribute_t *attr = req.first();
00056         while (attr)
00057         {
00058             if (attr->name && strcmp(attr->name,"device-uri") == 0 && strncmp(attr->values[0].string.text,"fax",3) == 0)
00059             {
00060                 m_list->insertItem(SmallIcon("blockdevice"),QString::fromLatin1(attr->values[0].string.text));
00061             }
00062             attr = attr->next;
00063         }
00064     }
00065 }
00066 
00067 bool KMWFax::isValid(QString& msg)
00068 {
00069     if (m_list->currentItem() == -1)
00070     {
00071         msg = i18n("You must select a device.");
00072         return false;
00073     }
00074     return true;
00075 }
00076 
00077 void KMWFax::updatePrinter(KMPrinter *printer)
00078 {
00079     QString uri = m_list->currentText();
00080     printer->setDevice(uri);
00081 }
 
This file is part of the documentation for kdeprint Library Version 3.2.0.