kmwipp.cpp00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
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
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
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 }
|