[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-devel
Subject: [PATCH] proxy weirdness (Was: 3.0rc2 networking problems)
From: Waldo Bastian <bastian () kde ! org>
Date: 2002-03-14 7:57:03
[Download RAW message or body]
On Tuesday 12 March 2002 02:03 pm, Lauri Watts wrote:
> Very similar here.
> I don't have to reenter the proxy config though.
>
> Most of the time, typing (for example) dot.kde.org into the url bar, it
> tells me time out waiting for the server. If I hit enter again, it mostly
> will connect. If it doesn't, I can type www.kde.org, and follow the link
> to dot.kde.org, and that will connect. So long as I keep that window open,
> I don't have any more trouble.
>
> I can't completely reproduce this, sometimes dot.kde.org will work the
> first time, so it's hard to report properly.
>
> Links clicked in ksirc, kmail, or knode, always fail. The same link cut
> and paste works perfectly fine.
Ok, please *test* the following patch. It looks big but it doesn't really
change very much.
Cheers,
Waldo
--
bastian@kde.org | SuSE Labs KDE Developer | bastian@suse.com
["proxy.patch" (text/x-diff)]
Index: scheduler.cpp
===================================================================
RCS file: /home/kde/kdelibs/kio/kio/scheduler.cpp,v
retrieving revision 1.85
diff -u -p -r1.85 scheduler.cpp
--- scheduler.cpp 2002/03/04 04:17:37 1.85
+++ scheduler.cpp 2002/03/14 07:52:42
@@ -274,6 +274,52 @@ void Scheduler::startStep()
}
}
+void Scheduler::setupSlave(KIO::Slave *slave, const KURL &url, const QString \
&protocol, const QString &proxy , bool newSlave, const KIO::MetaData *config) +{
+ QString host = url.host();
+ int port = url.port();
+ QString user = url.user();
+ QString passwd = url.pass();
+
+ if ((newSlave) ||
+ (slave->host() != host) ||
+ (slave->port() != port) ||
+ (slave->user() != user) ||
+ (slave->passwd() != passwd))
+ {
+ MetaData configData = slaveConfig->configData(protocol, host);
+ sessionData->configDataFor( configData, protocol, host );
+
+ configData["UseProxy"] = proxy;
+
+ QString autoLogin = configData["EnableAutoLogin"].lower();
+ if ( autoLogin == "true" )
+ {
+ NetRC::AutoLogin l;
+ l.login = user;
+ bool usern = (protocol == "ftp");
+ if ( NetRC::self()->lookup( url, l, usern) )
+ {
+ configData["autoLoginUser"] = l.login;
+ configData["autoLoginPass"] = l.password;
+ if ( usern )
+ {
+ QString macdef;
+ QMap<QString, QStringList>::ConstIterator it = l.macdef.begin();
+ for ( ; it != l.macdef.end(); ++it )
+ macdef += it.key() + '\\' + it.data().join( "\\" ) + '\n';
+ configData["autoLoginMacro"] = macdef;
+ }
+ }
+ }
+ if (config)
+ configData += *config;
+ slave->setConfig(configData);
+ slave->setProtocol(url.protocol());
+ slave->setHost(host, port, user, passwd);
+ }
+}
+
bool Scheduler::startJobScheduled(ProtocolInfo *protInfo)
{
if (protInfo->joblist.isEmpty())
@@ -344,54 +390,12 @@ bool Scheduler::startJobScheduled(Protoc
idleSlaves->removeRef(slave);
protInfo->joblist.removeRef(job);
// kdDebug(7006) << "scheduler: job started " << job << endl;
-
- KURL url =job->url();
- QString host = url.host();
- int port = url.port();
- QString user = url.user();
- QString passwd = url.pass();
-
- if ((newSlave) ||
- (slave->host() != host) ||
- (slave->port() != port) ||
- (slave->user() != user) ||
- (slave->passwd() != passwd))
- {
- JobData *jobData = extraJobData->find(job);
- slaveConfig->setConfigData( jobData->protocol, QString::null,
- "UseProxy", jobData->proxy );
- sessionData->configDataFor( slaveConfig, jobData->protocol, host );
- QString autoLogin = slaveConfig->configData( jobData->protocol, host,
- "EnableAutoLogin").lower();
- if ( autoLogin == "true" )
- {
- NetRC::AutoLogin l;
- l.login = user;
- bool usern = (jobData->protocol == "ftp");
- if ( NetRC::self()->lookup( url, l, usern) )
- {
- slaveConfig->setConfigData( jobData->protocol, host,
- "autoLoginUser", l.login );
- slaveConfig->setConfigData( jobData->protocol, host,
- "autoLoginPass", l.password );
- if ( usern )
- {
- QString macdef;
- QMap<QString, QStringList>::ConstIterator it = l.macdef.begin();
- for ( ; it != l.macdef.end(); ++it )
- macdef += it.key() + '\\' + it.data().join( "\\" ) + '\n';
- slaveConfig->setConfigData( jobData->protocol, host,
- "autoLoginMacro", macdef );
- }
- }
- }
- MetaData configData = slaveConfig->configData(jobData->protocol, host);
- slave->setConfig(configData);
- slave->setProtocol(url.protocol());
- slave->setHost(host, port, user, passwd);
- }
+
+ JobData *jobData = extraJobData->find(job);
+ setupSlave(slave, job->url(), jobData->protocol, jobData->proxy, newSlave);
job->start(slave);
+
slaveTimer.start(0, true);
return true;
}
@@ -428,50 +432,7 @@ if (!jobData)
idleSlaves->removeRef(slave);
// kdDebug(7006) << "scheduler: job started " << job << endl;
- KURL url =job->url();
- QString host = url.host();
- int port = url.port();
- QString user = url.user();
- QString passwd = url.pass();
-
- if ((newSlave) ||
- (slave->host() != host) ||
- (slave->port() != port) ||
- (slave->user() != user) ||
- (slave->passwd() != passwd))
- {
- slaveConfig->setConfigData( protocol, QString::null, "UseProxy",
- jobData->proxy );
- sessionData->configDataFor( slaveConfig, protocol, host );
- QString autoLogin = slaveConfig->configData(protocol, host,
- "EnableAutoLogin").lower();
- if ( autoLogin == "true" )
- {
- NetRC::AutoLogin l;
- l.login = user;
- bool usern = (protocol == "ftp");
- if ( NetRC::self()->lookup( url, l, usern) )
- {
- slaveConfig->setConfigData( protocol, host , "autoLoginUser",
- l.login );
- slaveConfig->setConfigData( protocol, host, "autoLoginPass",
- l.password );
- if ( usern )
- {
- QString macdef;
- QMap<QString, QStringList>::ConstIterator it = l.macdef.begin();
- for ( ; it != l.macdef.end(); ++it )
- macdef += it.key() + '\\' + it.data().join( "\\" ) + '\n';
- slaveConfig->setConfigData( jobData->protocol, host,
- "autoLoginMacro", macdef );
- }
- }
- }
- MetaData configData = slaveConfig->configData(protocol, host);
- slave->setConfig(configData);
- slave->setProtocol(url.protocol());
- slave->setHost(host, port, user, passwd);
- }
+ setupSlave(slave, job->url(), protocol, jobData->proxy, newSlave);
job->start(slave);
return true;
}
@@ -738,39 +699,7 @@ Scheduler::_getConnectedSlave(const KURL
return 0; // Error
idleSlaves->removeRef(slave);
- QString host = url.host();
-
- slaveConfig->setConfigData(protocol, QString::null, "UseProxy", proxy);
- sessionData->configDataFor( slaveConfig, protocol, host );
- QString autoLogin = slaveConfig->configData(protocol, host,
- "EnableAutoLogin").lower();
- if ( autoLogin == "true" )
- {
- NetRC::AutoLogin l;
- l.login = url.user();
- bool usern = (protocol == "ftp");
- if ( NetRC::self()->lookup( url, l, usern) )
- {
- slaveConfig->setConfigData(protocol, host,
- "autoLoginUser", l.login );
- slaveConfig->setConfigData(protocol, host,
- "autoLoginPass", l.password );
- if ( usern )
- {
- QString macdef;
- QMap<QString, QStringList>::ConstIterator it = l.macdef.begin();
- for ( ; it != l.macdef.end(); ++it )
- macdef += it.key() + '\\' + it.data().join( "\\" ) + '\n';
- slaveConfig->setConfigData( protocol, host,
- "autoLoginMacro", macdef );
- }
- }
- }
- MetaData configData = slaveConfig->configData(protocol, host);
- configData += config;
- slave->setConfig(configData);
- slave->setProtocol(url.protocol());
- slave->setHost(host, url.port(), url.user(), url.pass());
+ setupSlave(slave, url, protocol, proxy, true, &config);
slave->connection()->send( CMD_CONNECT );
connect(slave, SIGNAL(connected()),
Index: scheduler.h
===================================================================
RCS file: /home/kde/kdelibs/kio/kio/scheduler.h,v
retrieving revision 1.39
diff -u -p -r1.39 scheduler.h
--- scheduler.h 2002/03/04 04:17:37 1.39
+++ scheduler.h 2002/03/14 07:52:42
@@ -256,6 +256,7 @@ namespace KIO {
void slaveError(KIO::Slave *slave, int error, const QString &errorMsg);
protected:
+ void setupSlave(KIO::Slave *slave, const KURL &url, const QString &protocol, \
const QString &proxy , bool newSlave, const KIO::MetaData *config=0); bool \
startJobScheduled(ProtocolInfo *protInfo); bool startJobDirect();
Scheduler();
Index: sessiondata.cpp
===================================================================
RCS file: /home/kde/kdelibs/kio/kio/sessiondata.cpp,v
retrieving revision 1.19
diff -u -p -r1.19 sessiondata.cpp
--- sessiondata.cpp 2002/03/04 04:17:37 1.19
+++ sessiondata.cpp 2002/03/14 07:52:42
@@ -206,33 +206,27 @@ SessionData::~SessionData()
authData = 0L;
}
-void KIO::SessionData::configDataFor( SlaveConfig* cfg, const QString& proto,
- const QString& host )
+void KIO::SessionData::configDataFor( KIO::MetaData &configData, const QString \
&proto, + const QString & )
{
- if ( cfg && proto.find("http", 0, false) == 0 )
+ if ( proto.find("http", 0, false) == 0 )
{
if (!d->initDone)
reset();
- cfg->setConfigData( proto, host, "Cookies",
- d->useCookie ? "true":"false" );
-
+
// These might have already been set so check first
// to make sure that we do not trumpt settings sent
// by apps or end-user.
- if ( cfg->configData(proto,host)["Languages"].isEmpty() )
- cfg->setConfigData( proto, host, "Languages", d->language );
- if ( cfg->configData(proto,host)["Charsets"].isEmpty() )
- cfg->setConfigData( proto, host, "Charsets", d->charsets );
- if ( cfg->configData(proto,host)["CacheDir"].isEmpty() )
- {
- cfg->setConfigData( proto, host, "CacheDir",
- KGlobal::dirs()->saveLocation("cache", "http"));
- }
- if ( cfg->configData(proto,host)["UserAgent"].isEmpty() )
- {
- cfg->setConfigData( proto, host, "UserAgent",
- KProtocolManager::defaultUserAgent() );
- }
+ if ( configData["Cookies"].isEmpty() )
+ configData["Cookies"] = d->useCookie ? "true" : "false";
+ if ( configData["Languages"].isEmpty() )
+ configData["Languages"] = d->language;
+ if ( configData["Charsets"].isEmpty() )
+ configData["Charsets"] = d->charsets;
+ if ( configData["CacheDir"].isEmpty() )
+ configData["CacheDir"] = KGlobal::dirs()->saveLocation("cache", "http");
+ if ( configData["UserAgent"].isEmpty() )
+ configData["UserAgent"] = KProtocolManager::defaultUserAgent();
}
}
Index: sessiondata.h
===================================================================
RCS file: /home/kde/kdelibs/kio/kio/sessiondata.h,v
retrieving revision 1.8
diff -u -p -r1.8 sessiondata.h
--- sessiondata.h 2002/03/04 04:17:37 1.8
+++ sessiondata.h 2002/03/14 07:52:42
@@ -22,6 +22,7 @@
#define __KIO_SESSIONDATA_H
#include <qobject.h>
+#include <kio/global.h>
namespace KIO {
@@ -38,8 +39,8 @@ public:
SessionData();
~SessionData();
- virtual void configDataFor( SlaveConfig*, const QString&,
- const QString& = QString::null );
+ virtual void configDataFor( KIO::MetaData &configData, const QString &proto,
+ const QString &host );
virtual void reset();
public slots:
>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic