kdeprint Library API Documentation

kmwfax.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 "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 // initialize 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 }
KDE Logo
This file is part of the documentation for kdeprint Library Version 3.2.3.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Mar 16 17:23:17 2005 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003