diff options
author | Michael Nottebrock <lofi@FreeBSD.org> | 2006-09-27 11:56:59 +0000 |
---|---|---|
committer | Michael Nottebrock <lofi@FreeBSD.org> | 2006-09-27 11:56:59 +0000 |
commit | 952cad3bd300f959e509c0d8397db5c54f68f0c2 (patch) | |
tree | 4d1bcaef9baea011115625876f143e2d30cd0765 /x11/kdelibs3 | |
parent | - take maintainership (diff) |
Support printing over CUPS 1.2.x' unix domain socket interface.
Diffstat (limited to 'x11/kdelibs3')
-rw-r--r-- | x11/kdelibs3/Makefile | 2 | ||||
-rw-r--r-- | x11/kdelibs3/files/patch-cups-1.2.x-sockets | 251 |
2 files changed, 252 insertions, 1 deletions
diff --git a/x11/kdelibs3/Makefile b/x11/kdelibs3/Makefile index e642612b2a0a..2b22d7547581 100644 --- a/x11/kdelibs3/Makefile +++ b/x11/kdelibs3/Makefile @@ -8,7 +8,7 @@ PORTNAME= kdelibs PORTVERSION= ${KDE_VERSION} -PORTREVISION= 1 +PORTREVISION= 2 CATEGORIES= x11 kde MASTER_SITES= ${MASTER_SITE_KDE} MASTER_SITE_SUBDIR= stable/${PORTVERSION:S/.0//}/src diff --git a/x11/kdelibs3/files/patch-cups-1.2.x-sockets b/x11/kdelibs3/files/patch-cups-1.2.x-sockets new file mode 100644 index 000000000000..be679ae693e6 --- /dev/null +++ b/x11/kdelibs3/files/patch-cups-1.2.x-sockets @@ -0,0 +1,251 @@ +--- kdeprint/cups/Makefile.in Tue Sep 26 17:18:13 2006 ++++ kdeprint/cups/Makefile.in Tue Sep 26 17:19:12 2006 +@@ -110,7 +110,7 @@ + make_driver_db_cups_DEPENDENCIES = ../libdriverparse.a \ + $(top_builddir)/kdecore/libkdefakes.la $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) +-DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir) -I$(top_builddir)/dcop -I$(top_builddir)/kdecore -I$(top_builddir)/kio/kssl -I$(top_builddir)/kjs ++DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir) -I$(top_builddir)/dcop -I$(top_builddir)/kdecore -I$(top_builddir)/kdecore/network -I$(top_builddir)/kio/kssl -I$(top_builddir)/kjs + depcomp = $(SHELL) $(top_srcdir)/admin/depcomp + am__depfiles_maybe = depfiles + COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ +--- kdeprint/cups/cupsinfos.cpp 2005/09/29 09:47:40 465272 ++++ kdeprint/cups/cupsinfos.cpp 2006/09/20 15:33:24 586778 +@@ -69,6 +69,13 @@ + { + } + ++QString CupsInfos::hostaddr() const ++{ ++ if (host_[0] != '/') ++ return host_ + ":" + port_; ++ return host_; ++} ++ + void CupsInfos::setHost(const QString& s) + { + host_ = s; +--- kdeprint/cups/kmcupsmanager.cpp 2005/11/28 03:56:46 483752 ++++ kdeprint/cups/kmcupsmanager.cpp 2006/09/20 15:38:41 586782 +@@ -45,12 +45,14 @@ + #include <klocale.h> + #include <kconfig.h> + #include <kstandarddirs.h> ++#include <ksocketbase.h> + #include <klibloader.h> + #include <kmessagebox.h> + #include <kaction.h> + #include <kdialogbase.h> + #include <kextendedsocket.h> + #include <kprocess.h> ++#include <kbufferedsocket.h> + #include <kfilterdev.h> + #include <cups/cups.h> + #include <cups/ppd.h> +@@ -88,7 +90,7 @@ + + KMCupsManager::~KMCupsManager() + { +- //delete m_socket; ++ delete m_socket; + } + + QString KMCupsManager::driverDbCreationProgram() +@@ -135,7 +137,8 @@ + { + req.setOperation(CUPS_ADD_CLASS); + QStringList members = p->members(), uris; +- QString s = QString::fromLocal8Bit("ipp://%1:%2/printers/").arg(CupsInfos::self()->host()).arg(CupsInfos::self()->port()); ++ QString s; ++ s = QString::fromLocal8Bit("ipp://%1/printers/").arg(CupsInfos::self()->hostaddr()); + for (QStringList::ConstIterator it=members.begin(); it!=members.end(); ++it) + uris.append(s+(*it)); + req.addURI(IPP_TAG_PRINTER,"member-uris",uris); +@@ -907,25 +910,23 @@ + + QString KMCupsManager::stateInformation() + { +- return QString("%1: %2:%3") ++ return QString("%1: %2") + .arg(i18n("Server")) +- .arg(CupsInfos::self()->host()) +- .arg(CupsInfos::self()->port()); ++ .arg(CupsInfos::self()->hostaddr()); + } + + void KMCupsManager::checkUpdatePossibleInternal() + { + kdDebug(500) << "Checking for update possible" << endl; + delete m_socket; +- /*m_socket = new KExtendedSocket( CupsInfos::self()->host(), CupsInfos::self()->port() ); +- connect( m_socket, SIGNAL( connectionSuccess() ), SLOT( slotConnectionSuccess() ) ); +- connect( m_socket, SIGNAL( connectionFailed( int ) ), SLOT( slotConnectionFailed( int ) ) ); +- m_socket->setTimeout( 1 );*/ +- m_socket = new QSocket( this ); +- connect( m_socket, SIGNAL( connected() ), SLOT( slotConnectionSuccess() ) ); +- connect( m_socket, SIGNAL( error( int ) ), SLOT( slotConnectionFailed( int ) ) ); +- trials = 5; +- QTimer::singleShot( 1, this, SLOT( slotAsyncConnect() ) ); ++ m_socket = new KNetwork::KBufferedSocket; ++ m_socket->setTimeout( 1 ); ++ connect( m_socket, SIGNAL( connected(const KResolverEntry&) ), ++ SLOT( slotConnectionSuccess() ) ); ++ connect( m_socket, SIGNAL( gotError( int ) ), SLOT( slotConnectionFailed( int ) ) ); ++ ++ trials = 5; ++ QTimer::singleShot( 1, this, SLOT( slotAsyncConnect() ) ); + } + + void KMCupsManager::slotConnectionSuccess() +@@ -959,7 +960,10 @@ + { + kdDebug(500) << "Starting async connect" << endl; + //m_socket->startAsyncConnect(); +- m_socket->connectToHost( CupsInfos::self()->host(), CupsInfos::self()->port() ); ++ if (CupsInfos::self()->host().startsWith("/")) ++ m_socket->connect( QString(), CupsInfos::self()->host()); ++ else ++ m_socket->connectToHost( CupsInfos::self()->host(), CupsInfos::self()->port() ); + } + + void KMCupsManager::slotConnectionFailed( int errcode ) +@@ -975,9 +979,25 @@ + return; + } + +- setErrorMsg( i18n( "Connection to CUPS server failed. Check that the CUPS server is correctly installed and running. " +- "Error: %1." ).arg( errcode == QSocket::ErrConnectionRefused ? i18n( "connection refused" ) : i18n( "host not found" ) ) ); +- setUpdatePossible( false ); ++ QString einfo; ++ ++ switch (errcode) { ++ case KNetwork::KSocketBase::ConnectionRefused: ++ case KNetwork::KSocketBase::ConnectionTimedOut: ++ einfo = i18n("connection refused") + QString(" (%1)").arg(errcode); ++ break; ++ case KNetwork::KSocketBase::LookupFailure: ++ einfo = i18n("host not found") + QString(" (%1)").arg(errcode); ++ break; ++ case KNetwork::KSocketBase::WouldBlock: ++ default: ++ einfo = i18n("read failed (%1)").arg(errcode); ++ break; ++ } ++ ++ setErrorMsg( i18n( "Connection to CUPS server failed. Check that the CUPS server is correctly installed and running. " ++ "Error: %2: %1." ).arg( einfo, CupsInfos::self()->host())); ++ setUpdatePossible( false ); + } + + void KMCupsManager::hostPingSlot() { +@@ -1014,7 +1034,7 @@ + if (use && !p->uri().isEmpty()) + uri = p->uri().prettyURL(); + else +- uri = QString("ipp://%1:%2/%4/%3").arg(CupsInfos::self()->host()).arg(CupsInfos::self()->port()).arg(p->printerName()).arg((p->isClass(false) ? "classes" : "printers")); ++ uri = QString("ipp://%1/%3/%2").arg(CupsInfos::self()->hostaddr()).arg(p->printerName()).arg((p->isClass(false) ? "classes" : "printers")); + return uri; + } + +--- kdeprint/cups/kmcupsuimanager.cpp 2005/09/29 09:47:40 465272 ++++ kdeprint/cups/kmcupsuimanager.cpp 2006/09/20 15:38:41 586782 +@@ -135,7 +135,7 @@ + QString uri; + + req.setOperation(CUPS_GET_DEVICES); +- uri = QString::fromLocal8Bit("ipp://%1:%2/printers/").arg(CupsInfos::self()->host()).arg(CupsInfos::self()->port()); ++ uri = QString::fromLocal8Bit("ipp://%1/printers/").arg(CupsInfos::self()->hostaddr()); + req.addURI(IPP_TAG_OPERATION,"printer-uri",uri); + + if (req.doRequest("/")) +--- kdeprint/cups/cupsinfos.h 2005/09/29 09:47:40 465272 ++++ kdeprint/cups/cupsinfos.h 2006/09/20 15:33:24 586778 +@@ -32,6 +32,7 @@ + ~CupsInfos(); + + const QString& host() const; ++ QString hostaddr() const; + int port() const; + const QString& login() const; + const QString& password() const; +--- kdeprint/cups/kmcupsmanager.h 2005/09/29 09:47:40 465272 ++++ kdeprint/cups/kmcupsmanager.h 2006/09/20 15:38:41 586782 +@@ -25,7 +25,10 @@ + class IppRequest; + class KLibrary; + class KExtendedSocket; +-class QSocket; ++ ++namespace KNetwork { ++ class KStreamSocket; ++} + + class KMCupsManager : public KMManager + { +@@ -95,7 +98,7 @@ + private: + KLibrary *m_cupsdconf; + KMPrinter *m_currentprinter; +- QSocket *m_socket; ++ KNetwork::KStreamSocket *m_socket; + bool m_hostSuccess; + bool m_lookupDone; + }; +--- kdeprint/cups/cupsdconf2/cups-util.c 2005/11/30 19:59:17 484443 ++++ kdeprint/cups/cupsdconf2/cups-util.c 2006/09/20 15:22:50 586776 +@@ -14,7 +14,7 @@ + static int cups_local_auth(http_t *http); + + const char * /* O - Filename for PPD file */ +-cupsGetConf() ++cupsGetConf(void) + { + int fd; /* PPD file */ + int bytes; /* Number of bytes read */ +@@ -142,7 +142,11 @@ + */ + + snprintf(plain, sizeof(plain), "%s:%s", cupsUser(), pwdstring); +- httpEncode64(encode, plain); ++#if CUPS_VERSION_MAJOR == 1 && CUPS_VERSION_MINOR >= 2 ++ httpEncode64_2(encode, sizeof(encode), plain, sizeof(plain)); ++#else ++ httpEncode64(encode, plain); ++#endif + snprintf(authstring, sizeof(authstring), "Basic %s", encode); + } + else +@@ -364,7 +368,11 @@ + */ + + snprintf(plain, sizeof(plain), "%s:%s", cupsUser(), pwdstring); +- httpEncode64(encode, plain); ++#if CUPS_VERSION_MAJOR == 1 && CUPS_VERSION_MINOR >= 2 ++ httpEncode64_2(encode, sizeof(encode), plain, sizeof(plain)); ++#else ++ httpEncode64(encode, plain); ++#endif + snprintf(authstring, sizeof(authstring), "Basic %s", encode); + } + else +@@ -443,8 +451,7 @@ + the struct has changed in newer versions - PiggZ (adam@piggz.co.uk) + */ + #if CUPS_VERSION_MAJOR == 1 && CUPS_VERSION_MINOR >= 2 +- if (ntohl(*(int*)&http->_hostaddr.sin_addr) != 0x7f000001 && +- strcasecmp(http->hostname, "localhost") != 0) ++ if (!httpAddrLocalhost(http)) + #else + if (ntohl(*(int*)&http->hostaddr.sin_addr) != 0x7f000001 && + strcasecmp(http->hostname, "localhost") != 0) +--- kdeprint/cups/cupsdconf2/cups-util.h 2005/09/29 09:47:40 465272 ++++ kdeprint/cups/cupsdconf2/cups-util.h 2006/09/20 15:22:50 586776 +@@ -20,7 +20,7 @@ + #ifndef CUPS_UTIL_H + #define CUPS_UTIL_H + +-const char* cupsGetConf(); ++const char* cupsGetConf(void); + int cupsPutConf(const char *filename); + + #endif |