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