| # kdeprint Library API Documentation
Overview | Class Hierarchy | Classes | Classes (annotated) | Members | Namespaces | Source Files

# kmwipp.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 "kmwipp.h"
    00021 #include "kmwizard.h"
    00022 #include "kmprinter.h"
    00023
    00024 #include <qlabel.h>
    00025 #include <qlineedit.h>
    00026 #include <klocale.h>
    00027 #include <qvalidator.h>
    00028
    00029 #include <cups/http.h>
    00030
    00031 KMWIpp::KMWIpp(QWidget *parent, const char *name)
    00032 : KMWInfoBase(2,parent,name)
    00033 {
    00034     m_ID = KMWizard::IPP;
    00035     m_title = i18n("Remote IPP server");
    00036     m_nextpage = KMWizard::IPPSelect;
    00037     lineEdit( 1 )->setValidator( new QIntValidator( this ) );
    00038
    00039     setInfo(i18n("<p>Enter the information concerning the remote IPP server "
    00040              "owning the targeted printer. This wizard will poll the server "
    00041              "before continuing.</p>"));
    00042     setLabel(0,i18n("Host:"));
    00043     setLabel(1,i18n("Port:"));
    00044     setText( 1, QString::fromLatin1( "631" ) );
    00045 }
    00046
    00047 bool KMWIpp::isValid(QString& msg)
    00048 {
    00049     // check informations
    00050     if (text(0).isEmpty())
    00051     {
    00052         msg = i18n("Empty server name.");
    00053         return false;
    00054     }
    00055     bool    ok(false);
    00056     int p = text(1).toInt(&ok);
    00057     if (!ok)
    00058     {
    00059         msg = i18n("Incorrect port number.");
    00060         return false;
    00061     }
    00062
    00063     // check server
    00064     http_t  *HTTP = httpConnect(text(0).latin1(),p);
    00065     if (HTTP)
    00066     {
    00067         httpClose(HTTP);
    00068         return true;
    00069     }
    00070     else
    00071     {
    00072         msg = i18n("<nobr>Unable to connect to <b>%1</b> on port <b>%2</b> .</nobr>").arg(text(0)).arg(p);
    00073         return false;
    00074     }
    00075 }
    00076
    00077 void KMWIpp::updatePrinter(KMPrinter *p)
    00078 {
    00079     KURL    url;
    00080     url.setProtocol("ipp");
    00081     url.setHost(text(0));
    00082     url.setPort(text(1).toInt());
    00083     if (!p->option("kde-login").isEmpty()) url.setUser(p->option("kde-login"));
    00084     if (!p->option("kde-password").isEmpty()) url.setPass(p->option("kde-password"));
    00085     p->setDevice(url.url());
    00086 }

This file is part of the documentation for kdeprint Library Version 3.4.1.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Sat Jun 11 20:31:03 2005 by doxygen 1.4.1 written by Dimitri van Heesch, © 1997-2003