temporary change for debugging, see #9

master
Marc Wäckerlin 15 years ago
parent 2b781c84a4
commit 234e6e66f9
  1. 42
      proxyface/autoproxy.hxx

@ -96,7 +96,9 @@ namespace proxy {
#ifdef QT_NETWORK_LIB
Q_OBJECT
#endif
public:
//! Keep your instance as long as possible, because of caching.
Interface()
#ifdef QT_NETWORK_LIB
@ -115,7 +117,9 @@ namespace proxy {
#endif
#endif
}
virtual ~Interface() {}
//! Get list of proxies for a given URL.
virtual List proxies(const std::string& url) = 0;
#ifdef QT_NETWORK_LIB
@ -171,12 +175,15 @@ namespace proxy {
setupProxyCheck(defaultProxy, url);
_timeout2.start();
}
void ping(const QUrl& url, int timeout2=30000) {
ping(url.toString().toStdString(), timeout2);
}
void ping(const QString& url, int timeout2=30000) {
ping(url.toStdString(), timeout2);
}
//! If Qt Network is available you may check the proxies found
/*! First checks for direct access to the target. If this is not
possible, starts scan for proxies.
@ -204,20 +211,24 @@ namespace proxy {
_timeout2.setInterval(timeout2);
_timeout1.setSingleShot(true);
_timeout1.setInterval(timeout1);
_timeout1.start();
timeout();
// @todo add again after test _timeout1.start();
}
//! If Qt Network is available you may check the proxies found
/*! @copydoc proxy(const std::string&, int) */
void proxy(const QUrl& url, int timeout1=5000, int timeout2=30000) {
PROXYFACE_LOG;
proxy(url.toString().toStdString(), timeout1, timeout2);
}
//! If Qt Network is available you may check the proxies found
/*! @copydoc proxy(const std::string&, int) */
void proxy(const QString& url, int timeout1=5000, int timeout2=30000) {
PROXYFACE_LOG;
proxy(url.toStdString(), timeout1, timeout2);
}
static QString toString(const QNetworkProxy& p) {
switch (p.type()) {
case QNetworkProxy::NoProxy:
@ -243,7 +254,9 @@ namespace proxy {
}
return QString("**ERROR** illegal proxy type");
}
Q_SIGNALS:
//! Signals a valid proxy for the URL requested earlier.
void proxyFound(const QUrl&, const QNetworkProxy&);
//! Signals a timeout, and no valid proxy for the URL requested earlier.
@ -252,7 +265,9 @@ namespace proxy {
void temporaryError(QNetworkReply::NetworkError, QString, QString);
void authenticationRequired(QNetworkReply*, QAuthenticator*);
void proxyAuthenticationRequired(const QNetworkProxy&, QAuthenticator*);
private:
void setupProxyCheck(const QNetworkProxy& prxy, const std::string& url) {
PROXYFACE_LOG;
qDebug()<<"Testing proxy for url:"<<toString(prxy)<<"url="<<url.data();
@ -262,8 +277,10 @@ namespace proxy {
SLOT(replyFinished(QNetworkReply*))))
qFatal("connect failed");
if (!connect(manager,
SIGNAL(authenticationRequired(QNetworkReply*, QAuthenticator*)),
SIGNAL(authenticationRequired(QNetworkReply*, QAuthenticator*))))
SIGNAL(authenticationRequired(QNetworkReply*,
QAuthenticator*)),
SIGNAL(authenticationRequired(QNetworkReply*,
QAuthenticator*))))
qFatal("connect failed");
if (!connect(manager,
SIGNAL(proxyAuthenticationRequired
@ -315,14 +332,18 @@ namespace proxy {
SLOT(sslErrors(QNetworkReply*, const QList<QSslError>&)));
//delete manager;
}
private Q_SLOTS:
void proxyAuthenticationRequiredLog(const QNetworkProxy&,
QAuthenticator* auth) {
qDebug()<<"proxyAuthenticationRequired for "<<auth->realm();
}
void bullshit() {
qDebug()<<"SCHEISSE";
}
void timeout() {
PROXYFACE_LOG;
reset();
@ -341,6 +362,7 @@ namespace proxy {
proxyError(QNetworkReply::TimeoutError);
}
}
void replyFinished(QNetworkReply* reply) {
PROXYFACE_LOG;
qDebug()<<"Proxydetection got reply with status:"
@ -357,12 +379,14 @@ namespace proxy {
<<"url="<<url<<"proxy="<<toString(prxy);
proxyFound(url, prxy);
}
void sslErrors(QNetworkReply*, const QList<QSslError>& l) {
PROXYFACE_LOG;
qDebug()<<"## "<<__PRETTY_FUNCTION__;
for (QList<QSslError>::const_iterator it(l.begin()); it!=l.end(); ++it)
qDebug()<<" SSL-Error -> "<<it->errorString();
}
void threadFinished() {
PROXYFACE_LOG;
for (List::const_iterator it(_proxies.begin());
@ -374,13 +398,15 @@ namespace proxy {
QString::fromStdString(it->host), it->port);
setupProxyCheck(prxy, _url);
}
QNetworkProxy directProxy(QNetworkProxy::NoProxy);
setupProxyCheck(directProxy, _url);
QNetworkProxy defaultProxy;
setupProxyCheck(defaultProxy, _url);
/// @todo add again after test QNetworkProxy directProxy(QNetworkProxy::NoProxy);
/// @todo add again after test setupProxyCheck(directProxy, _url);
/// @todo add again after test QNetworkProxy defaultProxy;
/// @todo add again after test setupProxyCheck(defaultProxy, _url);
_timeout2.start();
}
protected:
void run() {
PROXYFACE_LOG;
_proxies = proxies(_url);
@ -388,7 +414,9 @@ namespace proxy {
threadFinished();
#endif
}
private:
typedef std::map
<QNetworkReply*, std::pair<QNetworkAccessManager*, QNetworkProxy> >
Requests;

Loading…
Cancel
Save