Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 149746
Collapse All | Expand All

(-)kdelibs-3.5.4.orig/kdeprint/cups/cupsdconf2/cups-util.c (-5 / +12 lines)
Lines 14-20 static char pwdstring[33]; Link Here
14
static int cups_local_auth(http_t *http);
14
static int cups_local_auth(http_t *http);
15
15
16
const char *				/* O - Filename for PPD file */
16
const char *				/* O - Filename for PPD file */
17
cupsGetConf()
17
cupsGetConf(void)
18
{
18
{
19
  int		fd;			/* PPD file */
19
  int		fd;			/* PPD file */
20
  int		bytes;			/* Number of bytes read */
20
  int		bytes;			/* Number of bytes read */
Lines 142-148 cupsGetConf() Link Here
142
	*/
142
	*/
143
143
144
	snprintf(plain, sizeof(plain), "%s:%s", cupsUser(), pwdstring);
144
	snprintf(plain, sizeof(plain), "%s:%s", cupsUser(), pwdstring);
145
	httpEncode64(encode, plain);
145
#if CUPS_VERSION_MAJOR == 1 && CUPS_VERSION_MINOR >= 2
146
       httpEncode64_2(encode, sizeof(encode), plain, sizeof(plain));
147
#else
148
       httpEncode64(encode, plain);
149
#endif
146
	snprintf(authstring, sizeof(authstring), "Basic %s", encode);
150
	snprintf(authstring, sizeof(authstring), "Basic %s", encode);
147
      }
151
      }
148
      else
152
      else
Lines 364-370 cupsPutConf(const char *name) /* I - Na Link Here
364
	*/
368
	*/
365
369
366
	snprintf(plain, sizeof(plain), "%s:%s", cupsUser(), pwdstring);
370
	snprintf(plain, sizeof(plain), "%s:%s", cupsUser(), pwdstring);
367
	httpEncode64(encode, plain);
371
#if CUPS_VERSION_MAJOR == 1 && CUPS_VERSION_MINOR >= 2
372
       httpEncode64_2(encode, sizeof(encode), plain, sizeof(plain));
373
#else
374
       httpEncode64(encode, plain);
375
#endif
368
	snprintf(authstring, sizeof(authstring), "Basic %s", encode);
376
	snprintf(authstring, sizeof(authstring), "Basic %s", encode);
369
      }
377
      }
370
      else
378
      else
Lines 443-450 cups_local_auth(http_t *http) /* I - Con Link Here
443
	the struct has changed in newer versions - PiggZ (adam@piggz.co.uk)
451
	the struct has changed in newer versions - PiggZ (adam@piggz.co.uk)
444
  */
452
  */
445
#if CUPS_VERSION_MAJOR == 1 && CUPS_VERSION_MINOR >= 2
453
#if CUPS_VERSION_MAJOR == 1 && CUPS_VERSION_MINOR >= 2
446
	if (ntohl(*(int*)&http->_hostaddr.sin_addr) != 0x7f000001 &&
454
        if (!httpAddrLocalhost(http))
447
      strcasecmp(http->hostname, "localhost") != 0)
448
#else
455
#else
449
	if (ntohl(*(int*)&http->hostaddr.sin_addr) != 0x7f000001 &&
456
	if (ntohl(*(int*)&http->hostaddr.sin_addr) != 0x7f000001 &&
450
      strcasecmp(http->hostname, "localhost") != 0)
457
      strcasecmp(http->hostname, "localhost") != 0)
(-)kdelibs-3.5.4.orig/kdeprint/cups/cupsdconf2/cups-util.h (-1 / +1 lines)
Lines 20-26 Link Here
20
#ifndef CUPS_UTIL_H
20
#ifndef CUPS_UTIL_H
21
#define CUPS_UTIL_H
21
#define CUPS_UTIL_H
22
22
23
const char* cupsGetConf();
23
const char* cupsGetConf(void);
24
int cupsPutConf(const char *filename);
24
int cupsPutConf(const char *filename);
25
25
26
#endif
26
#endif
(-)kdelibs-3.5.4.orig/kdeprint/cups/cupsdoprint.c (-3 / +3 lines)
Lines 41-47 FILE *debugF = NULL; Link Here
41
#endif
41
#endif
42
42
43
/* utility functions */
43
/* utility functions */
44
void error(const char* msg)
44
static void error(const char* msg)
45
{
45
{
46
	fprintf(stderr, "%s\n", msg);
46
	fprintf(stderr, "%s\n", msg);
47
#if USE_LOG
47
#if USE_LOG
Lines 50-56 void error(const char* msg) Link Here
50
	exit(-1);
50
	exit(-1);
51
}
51
}
52
52
53
void usage()
53
static void usage()
54
{
54
{
55
	error("usage: cupsdoprint [-H host[:port]][-P dest][-J name][-o opt=value[,...]][-U login[:password]] files...");
55
	error("usage: cupsdoprint [-H host[:port]][-P dest][-J name][-o opt=value[,...]][-U login[:password]] files...");
56
}
56
}
Lines 81-87 static char * shell_quote(const char *s) Link Here
81
   return result;
81
   return result;
82
}
82
}
83
83
84
const char* getPasswordCB(const char* prompt)
84
static const char* getPasswordCB(const char* prompt)
85
{
85
{
86
	char buf[ 256 ] = {0}, *c;
86
	char buf[ 256 ] = {0}, *c;
87
	char *_user = shell_quote( cupsUser() ), *_passwd = NULL;
87
	char *_user = shell_quote( cupsUser() ), *_passwd = NULL;
(-)kdelibs-3.5.4.orig/kdeprint/cups/cupsinfos.cpp (+7 lines)
Lines 69-74 CupsInfos::~CupsInfos() Link Here
69
{
69
{
70
}
70
}
71
71
72
QString CupsInfos::hostaddr() const
73
{
74
    if (host_[0] != '/')
75
        return host_ + ":" + QString::number(port_);
76
    return host_;
77
}
78
72
void CupsInfos::setHost(const QString& s)
79
void CupsInfos::setHost(const QString& s)
73
{
80
{
74
	host_ = s;
81
	host_ = s;
(-)kdelibs-3.5.4.orig/kdeprint/cups/cupsinfos.h (+1 lines)
Lines 32-37 public: Link Here
32
	~CupsInfos();
32
	~CupsInfos();
33
33
34
	const QString& host() const;
34
	const QString& host() const;
35
        QString  hostaddr() const;
35
	int port() const;
36
	int port() const;
36
	const QString& login() const;
37
	const QString& login() const;
37
	const QString& password() const;
38
	const QString& password() const;
(-)kdelibs-3.5.4.orig/kdeprint/cups/kmcupsmanager.cpp (-19 / +39 lines)
Lines 45-56 Link Here
45
#include <klocale.h>
45
#include <klocale.h>
46
#include <kconfig.h>
46
#include <kconfig.h>
47
#include <kstandarddirs.h>
47
#include <kstandarddirs.h>
48
#include <ksocketbase.h>
48
#include <klibloader.h>
49
#include <klibloader.h>
49
#include <kmessagebox.h>
50
#include <kmessagebox.h>
50
#include <kaction.h>
51
#include <kaction.h>
51
#include <kdialogbase.h>
52
#include <kdialogbase.h>
52
#include <kextendedsocket.h>
53
#include <kextendedsocket.h>
53
#include <kprocess.h>
54
#include <kprocess.h>
55
#include <kbufferedsocket.h>
54
#include <kfilterdev.h>
56
#include <kfilterdev.h>
55
#include <cups/cups.h>
57
#include <cups/cups.h>
56
#include <cups/ppd.h>
58
#include <cups/ppd.h>
Lines 88-94 static int trials = 5; Link Here
88
90
89
KMCupsManager::~KMCupsManager()
91
KMCupsManager::~KMCupsManager()
90
{
92
{
91
	//delete m_socket;
93
	delete m_socket;
92
}
94
}
93
95
94
QString KMCupsManager::driverDbCreationProgram()
96
QString KMCupsManager::driverDbCreationProgram()
Lines 135-141 bool KMCupsManager::createPrinter(KMPrin Link Here
135
	{
137
	{
136
		req.setOperation(CUPS_ADD_CLASS);
138
		req.setOperation(CUPS_ADD_CLASS);
137
		QStringList	members = p->members(), uris;
139
		QStringList	members = p->members(), uris;
138
		QString		s = QString::fromLocal8Bit("ipp://%1:%2/printers/").arg(CupsInfos::self()->host()).arg(CupsInfos::self()->port());
140
		QString		s;
141
                s = QString::fromLocal8Bit("ipp://%1/printers/").arg(CupsInfos::self()->hostaddr());
139
		for (QStringList::ConstIterator it=members.begin(); it!=members.end(); ++it)
142
		for (QStringList::ConstIterator it=members.begin(); it!=members.end(); ++it)
140
			uris.append(s+(*it));
143
			uris.append(s+(*it));
141
		req.addURI(IPP_TAG_PRINTER,"member-uris",uris);
144
		req.addURI(IPP_TAG_PRINTER,"member-uris",uris);
Lines 907-931 void KMCupsManager::ippReport(IppRequest Link Here
907
910
908
QString KMCupsManager::stateInformation()
911
QString KMCupsManager::stateInformation()
909
{
912
{
910
	return QString("%1: %2:%3")
913
	return QString("%1: %2")
911
		.arg(i18n("Server"))
914
		.arg(i18n("Server"))
912
		.arg(CupsInfos::self()->host())
915
		.arg(CupsInfos::self()->hostaddr());
913
		.arg(CupsInfos::self()->port());
914
}
916
}
915
917
916
void KMCupsManager::checkUpdatePossibleInternal()
918
void KMCupsManager::checkUpdatePossibleInternal()
917
{
919
{
918
	kdDebug(500) << "Checking for update possible" << endl;
920
	kdDebug(500) << "Checking for update possible" << endl;
919
	delete m_socket;
921
	delete m_socket;
920
	/*m_socket = new KExtendedSocket( CupsInfos::self()->host(), CupsInfos::self()->port() );
922
        m_socket = new KNetwork::KBufferedSocket;
921
	connect( m_socket, SIGNAL( connectionSuccess() ), SLOT( slotConnectionSuccess() ) );
923
	m_socket->setTimeout( 1 );
922
	connect( m_socket, SIGNAL( connectionFailed( int ) ), SLOT( slotConnectionFailed( int ) ) );
924
	connect( m_socket, SIGNAL( connected(const KResolverEntry&) ), 
923
	m_socket->setTimeout( 1 );*/
925
                SLOT( slotConnectionSuccess() ) );
924
	m_socket = new QSocket( this );
926
	connect( m_socket, SIGNAL( gotError( int ) ), SLOT( slotConnectionFailed( int ) ) );
925
	connect( m_socket, SIGNAL( connected() ), SLOT( slotConnectionSuccess() ) );
927
926
	connect( m_socket, SIGNAL( error( int ) ), SLOT( slotConnectionFailed( int ) ) );
928
        trials = 5;
927
	trials = 5;
929
        QTimer::singleShot( 1, this, SLOT( slotAsyncConnect() ) );
928
	QTimer::singleShot( 1, this, SLOT( slotAsyncConnect() ) );
929
}
930
}
930
931
931
void KMCupsManager::slotConnectionSuccess()
932
void KMCupsManager::slotConnectionSuccess()
Lines 959-965 void KMCupsManager::slotAsyncConnect() Link Here
959
{
960
{
960
	kdDebug(500) << "Starting async connect" << endl;
961
	kdDebug(500) << "Starting async connect" << endl;
961
	//m_socket->startAsyncConnect();
962
	//m_socket->startAsyncConnect();
962
	m_socket->connectToHost( CupsInfos::self()->host(), CupsInfos::self()->port() );
963
        if (CupsInfos::self()->host().startsWith("/"))
964
            m_socket->connect( QString(), CupsInfos::self()->host());
965
        else
966
            m_socket->connectToHost( CupsInfos::self()->host(), CupsInfos::self()->port() );
963
}
967
}
964
968
965
void KMCupsManager::slotConnectionFailed( int errcode )
969
void KMCupsManager::slotConnectionFailed( int errcode )
Lines 975-983 void KMCupsManager::slotConnectionFailed Link Here
975
		return;
979
		return;
976
	}
980
	}
977
981
978
	setErrorMsg( i18n( "Connection to CUPS server failed. Check that the CUPS server is correctly installed and running. "
982
    QString einfo;
979
				"Error: %1." ).arg( errcode == QSocket::ErrConnectionRefused ? i18n( "connection refused" ) : i18n( "host not found" ) ) );
983
980
	setUpdatePossible( false );
984
    switch (errcode) {
985
    case KNetwork::KSocketBase::ConnectionRefused:
986
    case KNetwork::KSocketBase::ConnectionTimedOut:
987
        einfo = i18n("connection refused") + QString(" (%1)").arg(errcode);
988
        break;
989
    case KNetwork::KSocketBase::LookupFailure:
990
        einfo = i18n("host not found") + QString(" (%1)").arg(errcode);
991
        break;
992
    case KNetwork::KSocketBase::WouldBlock:
993
    default:
994
        einfo = i18n("read failed (%1)").arg(errcode);
995
        break;
996
    }
997
998
    setErrorMsg( i18n( "Connection to CUPS server failed. Check that the CUPS server is correctly installed and running. "
999
                "Error: %2: %1." ).arg( einfo, CupsInfos::self()->host()));
1000
    setUpdatePossible( false );
981
}
1001
}
982
1002
983
void KMCupsManager::hostPingSlot() {
1003
void KMCupsManager::hostPingSlot() {
Lines 1014-1020 QString printerURI(KMPrinter *p, bool us Link Here
1014
	if (use && !p->uri().isEmpty())
1034
	if (use && !p->uri().isEmpty())
1015
		uri = p->uri().prettyURL();
1035
		uri = p->uri().prettyURL();
1016
	else
1036
	else
1017
		uri = QString("ipp://%1:%2/%4/%3").arg(CupsInfos::self()->host()).arg(CupsInfos::self()->port()).arg(p->printerName()).arg((p->isClass(false) ? "classes" : "printers"));
1037
		uri = QString("ipp://%1/%3/%2").arg(CupsInfos::self()->hostaddr()).arg(p->printerName()).arg((p->isClass(false) ? "classes" : "printers"));
1018
	return uri;
1038
	return uri;
1019
}
1039
}
1020
1040
(-)kdelibs-3.5.4.orig/kdeprint/cups/kmcupsmanager.h (-2 / +5 lines)
Lines 25-31 Link Here
25
class IppRequest;
25
class IppRequest;
26
class KLibrary;
26
class KLibrary;
27
class KExtendedSocket;
27
class KExtendedSocket;
28
class QSocket;
28
29
namespace KNetwork {
30
    class KStreamSocket;
31
}
29
32
30
class KMCupsManager : public KMManager
33
class KMCupsManager : public KMManager
31
{
34
{
Lines 95-101 protected: Link Here
95
private:
98
private:
96
	KLibrary	*m_cupsdconf;
99
	KLibrary	*m_cupsdconf;
97
	KMPrinter	*m_currentprinter;
100
	KMPrinter	*m_currentprinter;
98
	QSocket *m_socket;
101
        KNetwork::KStreamSocket   *m_socket;
99
	bool m_hostSuccess;
102
	bool m_hostSuccess;
100
	bool m_lookupDone;
103
	bool m_lookupDone;
101
};
104
};
(-)kdelibs-3.5.4.orig/kdeprint/cups/kmcupsuimanager.cpp (-1 / +1 lines)
Lines 135-141 void KMCupsUiManager::setupWizard(KMWiza Link Here
135
	QString		uri;
135
	QString		uri;
136
136
137
	req.setOperation(CUPS_GET_DEVICES);
137
	req.setOperation(CUPS_GET_DEVICES);
138
	uri = QString::fromLocal8Bit("ipp://%1:%2/printers/").arg(CupsInfos::self()->host()).arg(CupsInfos::self()->port());
138
	uri = QString::fromLocal8Bit("ipp://%1/printers/").arg(CupsInfos::self()->hostaddr());
139
	req.addURI(IPP_TAG_OPERATION,"printer-uri",uri);
139
	req.addURI(IPP_TAG_OPERATION,"printer-uri",uri);
140
140
141
	if (req.doRequest("/"))
141
	if (req.doRequest("/"))

Return to bug 149746