|
|
@ -1,220 +0,0 @@ |
|
|
|
This is a hotfix for KDE 3.5.5 with CUPS 1.2.x. |
|
|
|
|
|
|
|
Copied from http://bugs.kde.org/show_bug.cgi?id=115891: |
|
|
|
Rework & unify IPP URI generation. Support UNIX socket properly patch 2006-11-01 18:09:53 |
|
|
|
|
|
|
|
--- kdelibs-3.5.5a.dfsg.1.orig/kdeprint/cups/cupsinfos.cpp 2006-10-26 19:31:11.000000000 +0300
|
|
|
|
+++ kdelibs-3.5.5a.dfsg.1/kdeprint/cups/cupsinfos.cpp 2006-10-26 21:29:07.000000000 +0300
|
|
|
|
@@ -21,6 +21,7 @@
|
|
|
|
#include "kmfactory.h" |
|
|
|
#include "kmtimer.h" |
|
|
|
#include "messagewindow.h" |
|
|
|
+#include "ipprequest.h"
|
|
|
|
|
|
|
|
#include <kio/passdlg.h> |
|
|
|
#include <kio/authinfo.h> |
|
|
|
@@ -76,6 +77,11 @@
|
|
|
|
return host_; |
|
|
|
} |
|
|
|
|
|
|
|
+QString CupsInfos::ippAssembleURI(const QString& resource) const
|
|
|
|
+{
|
|
|
|
+ return IppRequest::assembleURI(host(), port(), resource);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
void CupsInfos::setHost(const QString& s) |
|
|
|
{ |
|
|
|
host_ = s; |
|
|
|
--- kdelibs-3.5.5a.dfsg.1.orig/kdeprint/cups/cupsinfos.h 2006-10-26 19:31:11.000000000 +0300
|
|
|
|
+++ kdelibs-3.5.5a.dfsg.1/kdeprint/cups/cupsinfos.h 2006-10-26 21:26:26.000000000 +0300
|
|
|
|
@@ -34,6 +34,7 @@
|
|
|
|
const QString& host() const; |
|
|
|
QString hostaddr() const; |
|
|
|
int port() const; |
|
|
|
+ QString ippAssembleURI(const QString& resource) const;
|
|
|
|
const QString& login() const; |
|
|
|
const QString& password() const; |
|
|
|
const QString& realLogin() const; |
|
|
|
--- kdelibs-3.5.5a.dfsg.1.orig/kdeprint/cups/ipprequest.cpp 2006-10-26 19:31:11.000000000 +0300
|
|
|
|
+++ kdelibs-3.5.5a.dfsg.1/kdeprint/cups/ipprequest.cpp 2006-10-26 21:33:09.000000000 +0300
|
|
|
|
@@ -529,4 +529,48 @@
|
|
|
|
attr = attr->next; |
|
|
|
} |
|
|
|
#endif |
|
|
|
+
|
|
|
|
+
|
|
|
|
} |
|
|
|
+
|
|
|
|
+
|
|
|
|
+QString IppRequest::assembleURI(const QString& host, int port, const QString& resource)
|
|
|
|
+{
|
|
|
|
+ const char* hostname;
|
|
|
|
+
|
|
|
|
+ // Replace UNIX socket address with "localhost". ipp URI specification
|
|
|
|
+ // does not allow UNIX socket addresses in the host portion
|
|
|
|
+ if (host[0] == '/' || host.isEmpty()) {
|
|
|
|
+ hostname = "localhost";
|
|
|
|
+ port = 0;
|
|
|
|
+ } else {
|
|
|
|
+ hostname = host.local8Bit();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (port < 0)
|
|
|
|
+ return QString::null;
|
|
|
|
+
|
|
|
|
+#if CUPS_VERSION_MAJOR == 1 && CUPS_VERSION_MINOR >= 2
|
|
|
|
+ QCString uri(HTTP_MAX_URI);
|
|
|
|
+
|
|
|
|
+ // Use URI assembling function provided by CUPS
|
|
|
|
+ if (httpAssembleURI(HTTP_URI_CODING_ALL, uri.data(), uri.size(),
|
|
|
|
+ "ipp", NULL, hostname, port, resource.local8Bit()) == HTTP_URI_OK)
|
|
|
|
+ return QString(uri);
|
|
|
|
+ else
|
|
|
|
+ return QString::null;
|
|
|
|
+
|
|
|
|
+#else
|
|
|
|
+ // Use our own URI assembling function
|
|
|
|
+ if (port > 0)
|
|
|
|
+ return QString("ipp://%1:%2%3")
|
|
|
|
+ .arg(hostname)
|
|
|
|
+ .arg(port)
|
|
|
|
+ .arg(KURL::encode_string(resource));
|
|
|
|
+ else
|
|
|
|
+ return QString("ipp://%1%2")
|
|
|
|
+ .arg(hostname)
|
|
|
|
+ .arg(KURL::encode_string(resource));
|
|
|
|
+#endif
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
--- kdelibs-3.5.5a.dfsg.1.orig/kdeprint/cups/ipprequest.h 2006-10-26 19:31:11.000000000 +0300
|
|
|
|
+++ kdelibs-3.5.5a.dfsg.1/kdeprint/cups/ipprequest.h 2006-10-26 21:24:41.000000000 +0300
|
|
|
|
@@ -86,6 +86,9 @@
|
|
|
|
// debug function |
|
|
|
void dump(int state); |
|
|
|
|
|
|
|
+ // URI assembling function [static]
|
|
|
|
+ static QString assembleURI(const QString& host, int port, const QString& resource);
|
|
|
|
+
|
|
|
|
protected: |
|
|
|
void addString_p(int group, int type, const QString& name, const QString& value); |
|
|
|
void addStringList_p(int group, int type, const QString& name, const QStringList& values); |
|
|
|
--- kdelibs-3.5.5a.dfsg.1.orig/kdeprint/cups/kmcupsjobmanager.cpp 2006-10-26 21:45:23.000000000 +0300
|
|
|
|
+++ kdelibs-3.5.5a.dfsg.1/kdeprint/cups/kmcupsjobmanager.cpp 2006-10-27 01:33:12.000000000 +0300
|
|
|
|
@@ -92,7 +92,7 @@
|
|
|
|
case KMJob::Move: |
|
|
|
if (argstr.isEmpty()) return false; |
|
|
|
req.setOperation(CUPS_MOVE_JOB); |
|
|
|
- uri = QString::fromLatin1("ipp://%1:%2/printers/%3").arg(CupsInfos::self()->host()).arg(CupsInfos::self()->port()).arg(argstr);
|
|
|
|
+ uri = CupsInfos::self()->ippAssembleURI(QString("/printers/%1").arg(argstr));
|
|
|
|
req.addURI(IPP_TAG_OPERATION, "job-printer-uri", uri); |
|
|
|
break; |
|
|
|
default: |
|
|
|
@@ -109,7 +109,6 @@
|
|
|
|
bool KMCupsJobManager::listJobs(const QString& prname, KMJobManager::JobType type, int limit) |
|
|
|
{ |
|
|
|
IppRequest req; |
|
|
|
- QString uri("ipp://%1:%2/%3/%4");
|
|
|
|
QStringList keys; |
|
|
|
CupsInfos *infos = CupsInfos::self(); |
|
|
|
|
|
|
|
@@ -143,7 +142,8 @@
|
|
|
|
*/ |
|
|
|
} |
|
|
|
else |
|
|
|
- req.addURI(IPP_TAG_OPERATION, "printer-uri", uri.arg(infos->host()).arg(infos->port()).arg(((mp&&mp->isClass())?"classes":"printers")).arg(prname));
|
|
|
|
+ req.addURI(IPP_TAG_OPERATION, "printer-uri",
|
|
|
|
+ infos->ippAssembleURI(QString("/%1/%2").arg(((mp&&mp->isClass())?"classes":"printers")).arg(prname)));
|
|
|
|
|
|
|
|
// other attributes |
|
|
|
req.addKeyword(IPP_TAG_OPERATION, "requested-attributes", keys); |
|
|
|
--- kdelibs-3.5.5a.dfsg.1.orig/kdeprint/cups/kmcupsmanager.cpp 2006-10-26 19:31:11.000000000 +0300
|
|
|
|
+++ kdelibs-3.5.5a.dfsg.1/kdeprint/cups/kmcupsmanager.cpp 2006-10-26 21:31:12.000000000 +0300
|
|
|
|
@@ -138,7 +138,7 @@
|
|
|
|
req.setOperation(CUPS_ADD_CLASS); |
|
|
|
QStringList members = p->members(), uris; |
|
|
|
QString s; |
|
|
|
- s = QString::fromLocal8Bit("ipp://%1/printers/").arg(CupsInfos::self()->hostaddr());
|
|
|
|
+ s = CupsInfos::self()->ippAssembleURI("/printers/");
|
|
|
|
for (QStringList::ConstIterator it=members.begin(); it!=members.end(); ++it) |
|
|
|
uris.append(s+(*it)); |
|
|
|
req.addURI(IPP_TAG_PRINTER,"member-uris",uris); |
|
|
|
@@ -1024,7 +1024,7 @@
|
|
|
|
if (use && !p->uri().isEmpty()) |
|
|
|
uri = p->uri().prettyURL(); |
|
|
|
else |
|
|
|
- uri = QString("ipp://%1/%3/%2").arg(CupsInfos::self()->hostaddr()).arg(p->printerName()).arg((p->isClass(false) ? "classes" : "printers"));
|
|
|
|
+ uri = CupsInfos::self()->ippAssembleURI(QString("/%2/%1").arg(p->printerName()).arg((p->isClass(false) ? "classes" : "printers")));
|
|
|
|
return uri; |
|
|
|
} |
|
|
|
|
|
|
|
--- kdelibs-3.5.5a.dfsg.1.orig/kdeprint/cups/kmcupsuimanager.cpp 2006-10-26 19:31:11.000000000 +0300
|
|
|
|
+++ kdelibs-3.5.5a.dfsg.1/kdeprint/cups/kmcupsuimanager.cpp 2006-10-26 21:34:02.000000000 +0300
|
|
|
|
@@ -135,7 +135,7 @@
|
|
|
|
QString uri; |
|
|
|
|
|
|
|
req.setOperation(CUPS_GET_DEVICES); |
|
|
|
- uri = QString::fromLocal8Bit("ipp://%1/printers/").arg(CupsInfos::self()->hostaddr());
|
|
|
|
+ uri = CupsInfos::self()->ippAssembleURI("/printers/");
|
|
|
|
req.addURI(IPP_TAG_OPERATION,"printer-uri",uri); |
|
|
|
|
|
|
|
if (req.doRequest("/")) |
|
|
|
--- kdelibs-3.5.5a.dfsg.1.orig/kdeprint/cups/kmwfax.cpp 2006-10-26 19:31:11.000000000 +0300
|
|
|
|
+++ kdelibs-3.5.5a.dfsg.1/kdeprint/cups/kmwfax.cpp 2006-10-26 21:34:54.000000000 +0300
|
|
|
|
@@ -48,7 +48,7 @@
|
|
|
|
// initialize |
|
|
|
IppRequest req; |
|
|
|
req.setOperation(CUPS_GET_DEVICES); |
|
|
|
- QString uri = QString::fromLatin1("ipp://%1:%2/printers/").arg(CupsInfos::self()->host()).arg(CupsInfos::self()->port());
|
|
|
|
+ QString uri = CupsInfos::self()->ippAssembleURI("/printers/");
|
|
|
|
req.addURI(IPP_TAG_OPERATION,"printer-uri",uri); |
|
|
|
if (req.doRequest("/")) |
|
|
|
{ |
|
|
|
--- kdelibs-3.5.5a.dfsg.1.orig/kdeprint/cups/kmwippprinter.cpp 2006-10-26 19:31:11.000000000 +0300
|
|
|
|
+++ kdelibs-3.5.5a.dfsg.1/kdeprint/cups/kmwippprinter.cpp 2006-10-26 21:41:20.000000000 +0300
|
|
|
|
@@ -157,7 +157,7 @@
|
|
|
|
req.setOperation(IPP_GET_PRINTER_ATTRIBUTES); |
|
|
|
req.setHost(item->text(1)); |
|
|
|
req.setPort(item->text(2).toInt()); |
|
|
|
- uri = QString::fromLatin1("ipp://%1:%2/ipp").arg(item->text(1)).arg(item->text(2));
|
|
|
|
+ uri = IppRequest::assembleURI(item->text(1), item->text(2).toInt(), "/ipp");
|
|
|
|
req.addURI(IPP_TAG_OPERATION,"printer-uri",uri); |
|
|
|
keys.append("printer-name"); |
|
|
|
keys.append("printer-state"); |
|
|
|
@@ -176,7 +176,7 @@
|
|
|
|
if (req.uri("printer-uri-supported",value)) |
|
|
|
{ |
|
|
|
if (value[0] == '/') |
|
|
|
- value.prepend(QString::fromLatin1("ipp://%1:%2").arg(item->text(1)).arg(item->text(2)));
|
|
|
|
+ value = IppRequest::assembleURI(item->text(1), item->text(2).toInt(), value);
|
|
|
|
m_uri->setText(value); |
|
|
|
} |
|
|
|
if (req.text("printer-make-and-model",value) && !value.isEmpty()) txt.append(i18n("<b>Model</b>: %1<br>").arg(value)); |
|
|
|
@@ -203,7 +203,7 @@
|
|
|
|
void KMWIppPrinter::slotIppReport() |
|
|
|
{ |
|
|
|
IppRequest req; |
|
|
|
- QString uri("ipp://%1:%2/ipp");
|
|
|
|
+ QString uri;
|
|
|
|
QListViewItem *item = m_list->currentItem(); |
|
|
|
|
|
|
|
if (item) |
|
|
|
@@ -211,7 +211,7 @@
|
|
|
|
req.setOperation(IPP_GET_PRINTER_ATTRIBUTES); |
|
|
|
req.setHost(item->text(1)); |
|
|
|
req.setPort(item->text(2).toInt()); |
|
|
|
- uri = uri.arg(item->text(1)).arg(item->text(2));
|
|
|
|
+ uri = IppRequest::assembleURI(item->text(1), item->text(2).toInt(), "/ipp");
|
|
|
|
req.addURI(IPP_TAG_OPERATION, "printer-uri", uri); |
|
|
|
if (req.doRequest("/ipp/")) |
|
|
|
{ |
|
|
|
--- kdelibs-3.5.5a.dfsg.1.orig/kdeprint/cups/kmwippselect.cpp 2006-10-26 19:31:11.000000000 +0300
|
|
|
|
+++ kdelibs-3.5.5a.dfsg.1/kdeprint/cups/kmwippselect.cpp 2006-10-26 21:32:34.000000000 +0300
|
|
|
|
@@ -75,7 +75,7 @@
|
|
|
|
IppRequest req; |
|
|
|
QString uri; |
|
|
|
req.setOperation(CUPS_GET_PRINTERS); |
|
|
|
- uri = QString::fromLatin1("ipp://%1:%2/printers/").arg(url.host()).arg(url.port());
|
|
|
|
+ uri = IppRequest::assembleURI(url.host(), url.port(), "/printers/");
|
|
|
|
req.addURI(IPP_TAG_OPERATION,"printer-uri",uri); |
|
|
|
req.addKeyword(IPP_TAG_OPERATION,"requested-attributes",QString::fromLatin1("printer-name")); |
|
|
|
if (req.doRequest("/printers/")) |