|
|
@ -114,6 +114,9 @@ namespace proxy { |
|
|
|
#ifdef QT_NETWORK_LIB |
|
|
|
#ifdef QT_NETWORK_LIB |
|
|
|
//! Reset, stop all outstanding checks
|
|
|
|
//! Reset, stop all outstanding checks
|
|
|
|
void reset() { |
|
|
|
void reset() { |
|
|
|
|
|
|
|
if (_requests.size() || _timeout1.isActive() || _timeout2.isActive()) |
|
|
|
|
|
|
|
// error when we need to abort
|
|
|
|
|
|
|
|
proxyError(QNetworkReply::TimeoutError); |
|
|
|
_timeout1.stop(); |
|
|
|
_timeout1.stop(); |
|
|
|
_timeout2.stop(); |
|
|
|
_timeout2.stop(); |
|
|
|
for (Requests::iterator it(_requests.begin()); |
|
|
|
for (Requests::iterator it(_requests.begin()); |
|
|
@ -122,7 +125,10 @@ namespace proxy { |
|
|
|
_requests.clear(); |
|
|
|
_requests.clear(); |
|
|
|
} |
|
|
|
} |
|
|
|
//! Network Ping: Check access to a given address using default proxy.
|
|
|
|
//! Network Ping: Check access to a given address using default proxy.
|
|
|
|
void ping(const std::string& url, int timeout2=30000) { |
|
|
|
void ping(const std::string& url, int timeout2=5000) { |
|
|
|
|
|
|
|
if (_requests.size() || _timeout1.isActive() || _timeout2.isActive()) |
|
|
|
|
|
|
|
// detection is already running, wait for that, don't restart
|
|
|
|
|
|
|
|
return; |
|
|
|
reset(); |
|
|
|
reset(); |
|
|
|
_timeout2.setSingleShot(true); |
|
|
|
_timeout2.setSingleShot(true); |
|
|
|
_timeout2.setInterval(timeout2); |
|
|
|
_timeout2.setInterval(timeout2); |
|
|
@ -132,10 +138,10 @@ namespace proxy { |
|
|
|
setupProxyCheck(defaultProxy, url); |
|
|
|
setupProxyCheck(defaultProxy, url); |
|
|
|
_timeout2.start(); |
|
|
|
_timeout2.start(); |
|
|
|
} |
|
|
|
} |
|
|
|
void ping(const QUrl& url, int timeout2=30000) { |
|
|
|
void ping(const QUrl& url, int timeout2=5000) { |
|
|
|
ping(url.toString().toStdString(), timeout2); |
|
|
|
ping(url.toString().toStdString(), timeout2); |
|
|
|
} |
|
|
|
} |
|
|
|
void ping(const QString& url, int timeout2=30000) { |
|
|
|
void ping(const QString& url, int timeout2=5000) { |
|
|
|
ping(url.toStdString(), timeout2); |
|
|
|
ping(url.toStdString(), timeout2); |
|
|
|
} |
|
|
|
} |
|
|
|
//! If Qt Network is available you may check the proxies found
|
|
|
|
//! If Qt Network is available you may check the proxies found
|
|
|
@ -150,7 +156,7 @@ namespace proxy { |
|
|
|
@param url the url to find a proxy for |
|
|
|
@param url the url to find a proxy for |
|
|
|
@param timeout [ms] time to give up search */ |
|
|
|
@param timeout [ms] time to give up search */ |
|
|
|
void proxy(const std::string& url, |
|
|
|
void proxy(const std::string& url, |
|
|
|
int timeout1=5000, int timeout2=30000) { |
|
|
|
int timeout1=5000, int timeout2=5000) { |
|
|
|
PROXYFACE_LOG; |
|
|
|
PROXYFACE_LOG; |
|
|
|
qDebug()<<"Search proxy for URL, direct and default" |
|
|
|
qDebug()<<"Search proxy for URL, direct and default" |
|
|
|
<<"url="<<url.data()<<"timeout1="<<timeout1; |
|
|
|
<<"url="<<url.data()<<"timeout1="<<timeout1; |
|
|
@ -169,13 +175,13 @@ namespace proxy { |
|
|
|
} |
|
|
|
} |
|
|
|
//! If Qt Network is available you may check the proxies found
|
|
|
|
//! If Qt Network is available you may check the proxies found
|
|
|
|
/*! @copydoc proxy(const std::string&, int) */ |
|
|
|
/*! @copydoc proxy(const std::string&, int) */ |
|
|
|
void proxy(const QUrl& url, int timeout1=5000, int timeout2=30000) { |
|
|
|
void proxy(const QUrl& url, int timeout1=5000, int timeout2=5000) { |
|
|
|
PROXYFACE_LOG; |
|
|
|
PROXYFACE_LOG; |
|
|
|
proxy(url.toString().toStdString(), timeout1, timeout2); |
|
|
|
proxy(url.toString().toStdString(), timeout1, timeout2); |
|
|
|
} |
|
|
|
} |
|
|
|
//! If Qt Network is available you may check the proxies found
|
|
|
|
//! If Qt Network is available you may check the proxies found
|
|
|
|
/*! @copydoc proxy(const std::string&, int) */ |
|
|
|
/*! @copydoc proxy(const std::string&, int) */ |
|
|
|
void proxy(const QString& url, int timeout1=5000, int timeout2=30000) { |
|
|
|
void proxy(const QString& url, int timeout1=5000, int timeout2=5000) { |
|
|
|
PROXYFACE_LOG; |
|
|
|
PROXYFACE_LOG; |
|
|
|
proxy(url.toStdString(), timeout1, timeout2); |
|
|
|
proxy(url.toStdString(), timeout1, timeout2); |
|
|
|
} |
|
|
|
} |
|
|
|