diff --git a/proxyface/autoproxy.hxx b/proxyface/autoproxy.hxx index 0655faf..6595ba1 100644 --- a/proxyface/autoproxy.hxx +++ b/proxyface/autoproxy.hxx @@ -122,7 +122,7 @@ namespace proxy { _requests.clear(); } //! Network Ping: Check access to a given address using default proxy. - void ping(const std::string& url, int timeout2=5000) { + void ping(const std::string& url, int timeout2=30000) { if (_requests.size() || _timeout1.isActive() || _timeout2.isActive()) // detection is already running, wait for that, don't restart return; @@ -135,10 +135,10 @@ namespace proxy { setupProxyCheck(defaultProxy, url); _timeout2.start(); } - void ping(const QUrl& url, int timeout2=5000) { + void ping(const QUrl& url, int timeout2=30000) { ping(url.toString().toStdString(), timeout2); } - void ping(const QString& url, int timeout2=5000) { + void ping(const QString& url, int timeout2=30000) { ping(url.toStdString(), timeout2); } //! If Qt Network is available you may check the proxies found @@ -153,7 +153,7 @@ namespace proxy { @param url the url to find a proxy for @param timeout [ms] time to give up search */ void proxy(const std::string& url, - int timeout1=5000, int timeout2=5000) { + int timeout1=5000, int timeout2=30000) { PROXYFACE_LOG; qDebug()<<"Search proxy for URL, direct and default" <<"url="< +# ifdef WIN32 +# ifdef QT_NETWORK_LIB +// use Qt if available +# include namespace proxy { - typedef Qt Face; + typedef QtProxy Face; } -#else -# error no QT_WEBKIT_LIB -*/ -# ifdef WIN32 -// use windoze proprietary winhttp -# include +# else +// use windoze proprietary winhttp +# include namespace proxy { typedef Windoze Face; } +# endif # else -// normal operating systems: use http://code.google.com/p/libproxy -#include +# if defined(QT_NETWORK_LIB) && defined(Q_OS_MAC) +// use Qt if available (not yet linux) +# include +namespace proxy { + typedef QtProxy Face; +} +# else +// no Qt support, nor proprietary: use http://code.google.com/p/libproxy +# include namespace proxy { typedef Unix Face; } +# endif # endif -//#endif #endif diff --git a/proxyface/indicator.gif b/proxyface/indicator.gif new file mode 100644 index 0000000..3288d10 Binary files /dev/null and b/proxyface/indicator.gif differ diff --git a/proxyface/makefile.am b/proxyface/makefile.am index 2dde3c0..e6f37a1 100644 --- a/proxyface/makefile.am +++ b/proxyface/makefile.am @@ -16,7 +16,7 @@ EXTRA_DIST = ${UISOURCES} $(pkgconfig_DATA).in BUILT_SOURCES = ${UIHEADER} ${MOCSOURCES} ${LANGUAGES} proxyfacedir = ${includedir}/proxyface -proxyface_HEADERS = unix.hxx windoze.hxx plainqt.hxx \ +proxyface_HEADERS = unix.hxx windoze.hxx qtproxy.hxx \ ${MOCHEADER} ${UIHEADER} lib_LTLIBRARIES = libproxyface.la diff --git a/proxyface/plainqt.hxx b/proxyface/plainqt.hxx deleted file mode 100644 index ee10b69..0000000 --- a/proxyface/plainqt.hxx +++ /dev/null @@ -1,38 +0,0 @@ -/*! @file - - @id $Id$ -*/ -// 1 2 3 4 5 6 7 8 -// 45678901234567890123456789012345678901234567890123456789012345678901234567890 - -#ifndef PROXY_QT -#define PROXY_QT - -#include - -#include - -namespace proxy { - - class Qt: public Interface { - - public: - - Qt() {} - - virtual ~Qt() {} - - //! Implements WPAD using Qt Network and Qt Webkit - virtual List proxies(const std::string& url) { - List res; - qDebug()<<"Hostname: "< #include +#include #include #include #include @@ -26,32 +27,41 @@ namespace gui { public: - Proxy(QString testUrl, QWidget* p=0): QDialog(p), _testUrl(testUrl){ - setupUi(this); - QSettings s("SwissSign", "ProxySettings"); - _type->setCurrentIndex(s.value("default-type", 0).toInt()); - _url->setText(s.value("default-server", QString()).toString()); - _port->setValue(s.value("default-port", 0).toInt()); - connect(&_auto, SIGNAL(proxyFound(const QUrl&, const QNetworkProxy&)), - SIGNAL(proxyFound(const QUrl&, const QNetworkProxy&))); - connect(&_auto, SIGNAL(proxyFound(const QUrl&, const QNetworkProxy&)), - SLOT(proxyFoundSlot(const QUrl&, const QNetworkProxy&))); - connect(&_auto, SIGNAL(proxyError(QNetworkReply::NetworkError)), - SIGNAL(proxyError(QNetworkReply::NetworkError))); - connect(&_auto, SIGNAL(temporaryError(QNetworkReply::NetworkError, + Proxy(QString testUrl, QWidget* p=0): + QDialog(p), _lastDefaultProxy(QNetworkProxy()) { + setupUi(this); + _testUrl->insertItem(0, testUrl); + QMovie *m(new QMovie(":/icons/indicator.gif")); + _internetWait->setMovie(m); + m->start(); + QSettings s("SwissSign", "ProxySettings"); + _type->setCurrentIndex(s.value("default-type", 0).toInt()); + _url->setText(s.value("default-server", QString()).toString()); + _port->setValue(s.value("default-port", 0).toInt()); + connect(&_auto, SIGNAL(proxyFound(const QUrl&, const QNetworkProxy&)), + SIGNAL(proxyFound(const QUrl&, const QNetworkProxy&))); + connect(&_auto, SIGNAL(proxyFound(const QUrl&, const QNetworkProxy&)), + SLOT(proxyFoundSlot(const QUrl&, const QNetworkProxy&))); + connect(&_auto, SIGNAL(proxyError(QNetworkReply::NetworkError)), + SIGNAL(proxyError(QNetworkReply::NetworkError))); + connect(&_auto, SIGNAL(proxyError(QNetworkReply::NetworkError)), + SLOT(proxyErrorSlot(QNetworkReply::NetworkError))); + connect(&_auto, SIGNAL(temporaryError(QNetworkReply::NetworkError, QString, QString)), - SIGNAL(temporaryError(QNetworkReply::NetworkError, - QString, QString))); - acceptValues(); - } + SIGNAL(temporaryError(QNetworkReply::NetworkError, + QString, QString))); + acceptValues(); + } void checkUrl(const QString& url) { - _testUrl = url; + if (_testUrl->findText(url)==-1) + _testUrl->addItem(url); + _testUrl->setCurrentIndex(_testUrl->findText(url)); acceptValues(); } void ping() { - _auto.ping(_testUrl); + _auto.ping(_testUrl->currentText()); } void retry() { @@ -59,35 +69,32 @@ namespace gui { } void acceptValues(bool retry=false) { - _auto.reset(); - QNetworkProxy::ProxyType type(QNetworkProxy::NoProxy); + on__test_clicked(); switch (_type->currentIndex()) { case 0: try { _url->setEnabled(false); _port->setEnabled(false); _url->setText(""); _port->setValue(0); - type=QNetworkProxy::NoProxy; - QNetworkProxy::setApplicationProxy(QNetworkProxy(type)); - _auto.proxy(_testUrl); } catch (...) {} break; - case 1: { - type=QNetworkProxy::HttpProxy; - QNetworkProxy::setApplicationProxy - (QNetworkProxy(type, _url->text(), _port->value())); - _auto.ping(_testUrl); - } break; - case 2: { - type=QNetworkProxy::Socks5Proxy; - QNetworkProxy::setApplicationProxy - (QNetworkProxy(type, _url->text(), _port->value())); - _auto.ping(_testUrl); - } break; } + if (_save->isChecked()) { + QSettings s("SwissSign", "ProxySettings"); + s.setValue("default-type", _type->currentIndex()); + s.setValue("default-server", _url->text()); + s.setValue("default-port", _port->value()); + } else { + QSettings s("SwissSign", "ProxySettings"); + s.clear(); + } + _lastDefaultProxy = QNetworkProxy(); _lastType = _type->currentIndex(); _lastUrl = _url->text(); _lastPort = _port->value(); - if (!retry) detecting(); + if (!retry) { + _stackInternet->setCurrentIndex(WAITING_FOR_SERVER); + detecting(); + } } Q_SIGNALS: @@ -100,6 +107,7 @@ namespace gui { public Q_SLOTS: void proxyFoundSlot(const QUrl&, const QNetworkProxy& p) { + _stackInternet->setCurrentIndex(SERVER_FOUND); QNetworkProxy prx(p.type()==QNetworkProxy::DefaultProxy ?QNetworkProxy::applicationProxy():p); if (prx.type()==QNetworkProxy::DefaultProxy) return; @@ -109,26 +117,36 @@ namespace gui { QNetworkProxy::setApplicationProxy(prx); } + void proxyErrorSlot(QNetworkReply::NetworkError){ + _stackInternet->setCurrentIndex(SERVER_NOT_FOUND); + } + void on__type_currentIndexChanged(int index) { _url->setEnabled(index!=0); _port->setEnabled(index!=0); } - - void on__save_clicked(bool=false) { - QSettings s("SwissSign", "ProxySettings"); - s.setValue("default-type", _type->currentIndex()); - s.setValue("default-server", _url->text()); - s.setValue("default-port", _port->value()); - acceptValues(); - } - - void on__clear_clicked(bool=false) { - QSettings s("SwissSign", "ProxySettings"); - s.clear(); - _type->setCurrentIndex(0); - _url->setText(""); - _port->setValue(80); - acceptValues(); + + void on__test_clicked() { + _auto.reset(); + switch (_type->currentIndex()) { + case 0: try { + QNetworkProxy::setApplicationProxy + (QNetworkProxy(QNetworkProxy::NoProxy)); + _auto.proxy(_testUrl->currentText()); + } catch (...) {} break; + case 1: { + QNetworkProxy::setApplicationProxy + (QNetworkProxy + (QNetworkProxy::HttpProxy, _url->text(), _port->value())); + _auto.ping(_testUrl->currentText()); + } break; + case 2: { + QNetworkProxy::setApplicationProxy + (QNetworkProxy + (QNetworkProxy::Socks5Proxy, _url->text(), _port->value())); + _auto.ping(_testUrl->currentText()); + } break; + } } virtual void accept() { @@ -140,16 +158,21 @@ namespace gui { _type->setCurrentIndex(_lastType); _url->setText(_lastUrl); _port->setValue(_lastPort); + QNetworkProxy::setApplicationProxy(_lastDefaultProxy); QDialog::reject(); } + private: + + enum Network {SERVER_FOUND = 0, SERVER_NOT_FOUND, WAITING_FOR_SERVER}; + private: proxy::Face _auto; - QUrl _testUrl; int _lastType; QString _lastUrl; int _lastPort; + QNetworkProxy _lastDefaultProxy; }; diff --git a/proxyface/proxy.ui b/proxyface/proxy.ui index b927c2c..8841d1e 100644 --- a/proxyface/proxy.ui +++ b/proxyface/proxy.ui @@ -1,107 +1,123 @@ - + + Proxy - - + + 0 0 - 486 - 340 + 496 + 350 - - + + 0 0 - - Proxy Konfiguration + + Netzwerk Einstellungen - + - - + + Proxy Konfiguration - + - - + + true - - - - + + + QFormLayout::ExpandingFieldsGrow + + + + Typ: + + _type + - - + + + + + 0 + 0 + + - + direkt oder automatisch - + HTTP - + Socks5 - - - - + + + + 0 0 - - URL: + + Port: - - _url + + _port - - - - + + + + 0 0 - - - - + + + + 0 0 - - Port: + + Host: + + + _url - - - + + + 10000 - + 80 @@ -113,11 +129,190 @@ - - + + + Verbindung testen + + + + + + + + Test-URL: + + + _testUrl + + + + + + + + 0 + 0 + + + + true + + + + http://update.swisssign.com + + + + + http://google.com + + + + + http://heise.de + + + + + + + + Testen + + + + + + + + + + 0 + 0 + + + + 2 + + + + + + + + 0 + 0 + + + + <span style="color:green;font-size:x-large">✔</span> + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + + + + + + + + 0 + 0 + + + + Internetverbindung vorhanden + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + + + + + + + + + + + + 0 + 0 + + + + <span style="color:red;font-size:x-large">✘</span> + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + + + + + + + + 0 + 0 + + + + Keine Internetverbindung + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + + + + + + + + + + + + 0 + 0 + + + + <span style=" font-size:x-large; color:red;">?</span> + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + + + + + + + + 0 + 0 + + + + Prüfe Internetverbindung ... + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + + + + + + + + + + + + + Qt::Vertical - + 20 0 @@ -126,56 +321,36 @@ - - - Einstellungen lokal speichern + + + Einstellungen speichern - - - - - Speichern - - - - - - - Wenn Sie die Einstellungen speichern, werden sie auf diesem Computer in Ihrem Profil abgelegt. - - - Qt::PlainText - - - true - - - - - - - Loeschen - - - - - - + + Qt::Horizontal - + QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - true + + false + + _type + _url + _port + _testUrl + _test + _save + _buttons + @@ -184,11 +359,11 @@ Proxy accept() - - 338 - 752 + + 342 + 345 - + 157 274 @@ -200,11 +375,11 @@ Proxy reject() - - 406 - 752 + + 410 + 345 - + 286 274 diff --git a/proxyface/proxy_de.ts b/proxyface/proxy_de.ts index d874de9..ebddbc0 100644 --- a/proxyface/proxy_de.ts +++ b/proxyface/proxy_de.ts @@ -4,72 +4,150 @@ Proxy - - - - + + + Netzwerk Einstellungen + + + + + Proxy Konfiguration Proxy Einstellungen - - + + Typ: Typ: - - + + direkt oder automatisch automatisch - - + + HTTP HTTP - - + + Socks5 Socks5 - - + + + Host: + + + + + + Verbindung testen + + + + + + Test-URL: + + + + + + http://update.swisssign.com + + + + + + http://google.com + + + + + + http://heise.de + + + + + + Testen + + + + + + <span style="color:green;font-size:x-large">✔</span> + + + + + + Internetverbindung vorhanden + + + + + + <span style="color:red;font-size:x-large">✘</span> + + + + + + Keine Internetverbindung + + + + + + <span style=" font-size:x-large; color:red;">?</span> + + + + + + Prüfe Internetverbindung ... + + + + + + Einstellungen speichern + + + URL: - Adresse: + Adresse: - - + + Port: Port: - - Einstellungen lokal speichern - Einstellungen lokal speichern + Einstellungen lokal speichern - - Speichern - Speichern + Speichern - - Wenn Sie die Einstellungen speichern, werden sie auf diesem Computer in Ihrem Profil abgelegt. - Einstellungen werden nur auf diesem Computer gespeichert. + Einstellungen werden nur auf diesem Computer gespeichert. - - Loeschen - Entfernen + Entfernen diff --git a/proxyface/proxy_en.ts b/proxyface/proxy_en.ts index 3368eaf..308453a 100644 --- a/proxyface/proxy_en.ts +++ b/proxyface/proxy_en.ts @@ -4,72 +4,150 @@ Proxy - - - - + + + Netzwerk Einstellungen + + + + + Proxy Konfiguration Proxy Settings - - + + Typ: Type: - - + + direkt oder automatisch automatic - - + + HTTP HTTP - - + + Socks5 Socks5 - - + + + Host: + + + + + + Verbindung testen + + + + + + Test-URL: + + + + + + http://update.swisssign.com + + + + + + http://google.com + + + + + + http://heise.de + + + + + + Testen + + + + + + <span style="color:green;font-size:x-large">✔</span> + + + + + + Internetverbindung vorhanden + + + + + + <span style="color:red;font-size:x-large">✘</span> + + + + + + Keine Internetverbindung + + + + + + <span style=" font-size:x-large; color:red;">?</span> + + + + + + Prüfe Internetverbindung ... + + + + + + Einstellungen speichern + + + URL: - Address: + Address: - - + + Port: Port: - - Einstellungen lokal speichern - Save settings locally + Save settings locally - - Speichern - Save + Save - - Wenn Sie die Einstellungen speichern, werden sie auf diesem Computer in Ihrem Profil abgelegt. - Settings will be saved on this computer only. + Settings will be saved on this computer only. - - Loeschen - Remove + Remove diff --git a/proxyface/proxy_fr.ts b/proxyface/proxy_fr.ts index 3572fc6..42d8ed4 100644 --- a/proxyface/proxy_fr.ts +++ b/proxyface/proxy_fr.ts @@ -4,72 +4,150 @@ Proxy - - - - + + + Netzwerk Einstellungen + + + + + Proxy Konfiguration Paramétrages du Proxy - - + + Typ: Type: - - + + direkt oder automatisch automatique - - + + HTTP HTTP - - + + Socks5 Socks5 - - + + + Host: + + + + + + Verbindung testen + + + + + + Test-URL: + + + + + + http://update.swisssign.com + + + + + + http://google.com + + + + + + http://heise.de + + + + + + Testen + + + + + + <span style="color:green;font-size:x-large">✔</span> + + + + + + Internetverbindung vorhanden + + + + + + <span style="color:red;font-size:x-large">✘</span> + + + + + + Keine Internetverbindung + + + + + + <span style=" font-size:x-large; color:red;">?</span> + + + + + + Prüfe Internetverbindung ... + + + + + + Einstellungen speichern + + + URL: - Adresse: + Adresse: - - + + Port: Port: - - Einstellungen lokal speichern - Enregistrer les paramètres localement + Enregistrer les paramètres localement - - Speichern - Salve + Salve - - Wenn Sie die Einstellungen speichern, werden sie auf diesem Computer in Ihrem Profil abgelegt. - Les paramètres seront enregistre seulement sur cet ordinateur. + Les paramètres seront enregistre seulement sur cet ordinateur. - - Loeschen - Enlever + Enlever diff --git a/proxyface/proxy_it.ts b/proxyface/proxy_it.ts index ce398fd..f6c5352 100644 --- a/proxyface/proxy_it.ts +++ b/proxyface/proxy_it.ts @@ -4,72 +4,150 @@ Proxy - - - - + + + Netzwerk Einstellungen + + + + + Proxy Konfiguration Impostazioni proxy - - + + Typ: Typo: - - + + direkt oder automatisch automatico - - + + HTTP HTTP - - + + Socks5 Socks5 - - + + + Host: + + + + + + Verbindung testen + + + + + + Test-URL: + + + + + + http://update.swisssign.com + + + + + + http://google.com + + + + + + http://heise.de + + + + + + Testen + + + + + + <span style="color:green;font-size:x-large">✔</span> + + + + + + Internetverbindung vorhanden + + + + + + <span style="color:red;font-size:x-large">✘</span> + + + + + + Keine Internetverbindung + + + + + + <span style=" font-size:x-large; color:red;">?</span> + + + + + + Prüfe Internetverbindung ... + + + + + + Einstellungen speichern + + + URL: - Indirizzo: + Indirizzo: - - + + Port: Porta: - - Einstellungen lokal speichern - Salvare i parametri localmente + Salvare i parametri localmente - - Speichern - Salve + Salve - - Wenn Sie die Einstellungen speichern, werden sie auf diesem Computer in Ihrem Profil abgelegt. - I parametri verranno salvati solo su questo computer. + I parametri verranno salvati solo su questo computer. - - Loeschen - Eliminazione + Eliminazione diff --git a/proxyface/windoze.hxx b/proxyface/windoze.hxx index 4ab8312..ad8e4d4 100644 --- a/proxyface/windoze.hxx +++ b/proxyface/windoze.hxx @@ -25,8 +25,9 @@ namespace proxy { //! Implemented using M$ WinHTTP virtual List proxies(const std::string& url) { - + List res; + WINHTTP_PROXY_INFO proxyInfo; ZeroMemory(&proxyInfo, sizeof(proxyInfo)); HINTERNET hHttpSession(WinHttpOpen(L"WinHTTP AutoProxy/1.0", @@ -45,7 +46,8 @@ namespace proxy { AutoProxyOptions.fAutoLogonIfChallenged = FALSE; if (!WinHttpGetProxyForUrl(hHttpSession, - std::wstring(url.begin(), url.end()).data(), + std::wstring(url.begin(), + url.end()).data(), &AutoProxyOptions, &proxyInfo)) throw exc::error(); @@ -80,6 +82,7 @@ namespace proxy { if (hHttpSession) WinHttpCloseHandle(hHttpSession); if (!res.size()) res.push_back(Proxy()); // try direct acces } + return res; } };