From ce4a32fe52ef09d8f5ff1dd22c001110902b60a2 Mon Sep 17 00:00:00 2001 From: toma Date: Wed, 25 Nov 2009 17:56:58 +0000 Subject: Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features. BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdelibs@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- kdeprint/cups/kmwipp.cpp | 86 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 kdeprint/cups/kmwipp.cpp (limited to 'kdeprint/cups/kmwipp.cpp') diff --git a/kdeprint/cups/kmwipp.cpp b/kdeprint/cups/kmwipp.cpp new file mode 100644 index 000000000..fbef937cf --- /dev/null +++ b/kdeprint/cups/kmwipp.cpp @@ -0,0 +1,86 @@ +/* + * This file is part of the KDE libraries + * Copyright (c) 2001 Michael Goffioul + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License version 2 as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + **/ + +#include "kmwipp.h" +#include "kmwizard.h" +#include "kmprinter.h" + +#include +#include +#include +#include + +#include + +KMWIpp::KMWIpp(QWidget *parent, const char *name) +: KMWInfoBase(2,parent,name) +{ + m_ID = KMWizard::IPP; + m_title = i18n("Remote IPP server"); + m_nextpage = KMWizard::IPPSelect; + lineEdit( 1 )->setValidator( new QIntValidator( this ) ); + + setInfo(i18n("

Enter the information concerning the remote IPP server " + "owning the targeted printer. This wizard will poll the server " + "before continuing.

")); + setLabel(0,i18n("Host:")); + setLabel(1,i18n("Port:")); + setText( 1, QString::fromLatin1( "631" ) ); +} + +bool KMWIpp::isValid(QString& msg) +{ + // check informations + if (text(0).isEmpty()) + { + msg = i18n("Empty server name."); + return false; + } + bool ok(false); + int p = text(1).toInt(&ok); + if (!ok) + { + msg = i18n("Incorrect port number."); + return false; + } + + // check server + http_t *HTTP = httpConnect(text(0).latin1(),p); + if (HTTP) + { + httpClose(HTTP); + return true; + } + else + { + msg = i18n("Unable to connect to %1 on port %2 .").arg(text(0)).arg(p); + return false; + } +} + +void KMWIpp::updatePrinter(KMPrinter *p) +{ + KURL url; + url.setProtocol("ipp"); + url.setHost(text(0)); + url.setPort(text(1).toInt()); + if (!p->option("kde-login").isEmpty()) url.setUser(p->option("kde-login")); + if (!p->option("kde-password").isEmpty()) url.setPass(p->option("kde-password")); + p->setDevice(url.url()); +} -- cgit v1.2.1