Discussion:
[Qlandkartegt-users] Proxy authentication issue
solitone
2012-09-13 14:41:41 UTC
Permalink
I access the Web through a corporate proxy.

I have configured QLandkarte GT with the proxy host and port.

However, I cannot load maps from OpenStreetMap.

I have then tried and searched a location, but QLandkarte GT complains
that my "proxy requires authentication", and I do not get any response
from the search service.

Unfortunately I do not find any parameter where I can specify
authentication data for the proxy.

Is there a way to circumvent this issue?

The strange thing is I also use JOSM, and I have not specified any user
and password in the proxy settings, but it nevertheless fetches data
from OSM.. I'm confused!
Oliver Eichler
2012-09-13 18:19:04 UTC
Permalink
Hi,

the proxy stuff is a mess. As I do not have such a setup, I wait for a
patch that fixes all proxy problems. I wait for a long time already :)


Oliver
Post by solitone
I access the Web through a corporate proxy.
I have configured QLandkarte GT with the proxy host and port.
However, I cannot load maps from OpenStreetMap.
I have then tried and searched a location, but QLandkarte GT complains
that my "proxy requires authentication", and I do not get any response
from the search service.
Unfortunately I do not find any parameter where I can specify
authentication data for the proxy.
Is there a way to circumvent this issue?
The strange thing is I also use JOSM, and I have not specified any user
and password in the proxy settings, but it nevertheless fetches data
from OSM.. I'm confused!
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Qlandkartegt-users mailing list
https://lists.sourceforge.net/lists/listinfo/qlandkartegt-users
Albrecht Dreß
2012-09-13 18:41:50 UTC
Permalink
Post by Oliver Eichler
the proxy stuff is a mess. As I do not have such a setup, I wait for a
patch that fixes all proxy problems. I wait for a long time already :)
Just a dumb question - wouldn't it be sufficient to just add the user name and password to the call of

QNetworkProxy::setApplicationProxy(QNetworkProxy(QNetworkProxy::HttpProxy,m_httpProxy,m_httpProxyPort));

in CResources::CResources()?

I also do not have a proxy w/ authentication, but 'solitone': might you want to try if the hardcoded user/passwd values in the sources (for testing) solve the issue for you (see <http://doc.qt.nokia.com/4.6/qnetworkproxy.html#QNetworkProxy-2> for the doc of the call)?

Adding two more config elements and optionally tweaking CResources::getHttpProxy() to pick up the authentication tokens from the environment (although the latter is not a good idea from the security pov) should then be trivial...

Just my € 0.01,
Cheers,
Albrecht.
solitone
2012-09-18 08:51:59 UTC
Permalink
Post by Albrecht Dreß
wouldn't it be sufficient to just add the user
name and password to the call of
QNetworkProxy::setApplicationProxy(QNetworkProxy(QNetworkProxy::HttpProxy,m_httpProxy,m_httpProxyPort));
in CResources::CResources()?
I also do not have a proxy w/ authentication, but 'solitone': might you
want to try if the hardcoded user/passwd values in the sources (for
testing) solve the issue for you
I tried Albrecht's suggestion, but unfortunately I still have the "proxy
requires authentication" issue when doing a google search.

Maybe I did something wrong?

The call to QNetworkProxy::setApplicationProxy seems correct to me, but
please let me know your thoughts.

Here's the code snippet I customized, in CResources.cpp:

-----------------------------------------------------------------------
if(m_useHttpProxy)
/* 2012.09.17 -- Davide Cavallari
*
* Test: proxy authentication
*
*/

QNetworkProxy::setApplicationProxy(QNetworkProxy(QNetworkProxy::HttpProxy,m_httpProxy,m_httpProxyPort,"my_username","my_password"));

//
QNetworkProxy::setApplicationProxy(QNetworkProxy(QNetworkProxy::HttpProxy,m_httpProxy,m_httpProxyPort));
else

QNetworkProxy::setApplicationProxy(QNetworkProxy(QNetworkProxy::NoProxy));
-----------------------------------------------------------------------
Oliver Eichler
2012-09-18 09:37:21 UTC
Permalink
Hm, I would have done it the same way. Fabrice played with that stuff once and had some issues, too. But I don't remember the details. Maybe probing with wireshark gives a bit of additional information on what's failing.

oliver


-------- Original-Nachricht --------
Datum: Tue, 18 Sep 2012 10:51:59 +0200
Betreff: Re: [Qlandkartegt-users] Proxy authentication issue
Post by Albrecht Dreß
wouldn't it be sufficient to just add the user
name and password to the call of
QNetworkProxy::setApplicationProxy(QNetworkProxy(QNetworkProxy::HttpProxy,m_httpProxy,m_httpProxyPort));
Post by Albrecht Dreß
in CResources::CResources()?
I also do not have a proxy w/ authentication, but 'solitone': might you
want to try if the hardcoded user/passwd values in the sources (for
testing) solve the issue for you
I tried Albrecht's suggestion, but unfortunately I still have the "proxy
requires authentication" issue when doing a google search.
Maybe I did something wrong?
The call to QNetworkProxy::setApplicationProxy seems correct to me, but
please let me know your thoughts.
-----------------------------------------------------------------------
if(m_useHttpProxy)
/* 2012.09.17 -- Davide Cavallari
*
* Test: proxy authentication
*
*/
QNetworkProxy::setApplicationProxy(QNetworkProxy(QNetworkProxy::HttpProxy,m_httpProxy,m_httpProxyPort,"my_username","my_password"));
//
QNetworkProxy::setApplicationProxy(QNetworkProxy(QNetworkProxy::HttpProxy,m_httpProxy,m_httpProxyPort));
else
QNetworkProxy::setApplicationProxy(QNetworkProxy(QNetworkProxy::NoProxy));
-----------------------------------------------------------------------
solitone
2012-09-18 11:13:47 UTC
Permalink
Post by Oliver Eichler
Hm, I would have done it the same way. Fabrice played with that stuff once and had some issues, too. But I don't remember the details. Maybe probing with wireshark gives a bit of additional information on what's failing.
First, let's have a look at what happens when proxy authentication does
work.

Here's an excerpt of HTTP packets exchanged between JOSM (which supports
proxy connectivity pretty well) and my proxy server, sniffed with wireshark:

-----------------------------------------------------------------------
359 18.882631000 10.11.44.241 10.11.21.150 HTTP 279 GET
Loading Image... HTTP/1.1
389 19.023897000 10.11.21.150 10.11.44.241 HTTP 1228 HTTP/1.1 407 Proxy
Authentication Required (text/html)
435 19.076748000 10.11.44.241 10.11.21.150 HTTP 387 GET
http://tile.openstreetmap.org/10/531/369.png HTTP/1.1 , NTLMSSP_NEGOTIATE
444 19.094588000 10.11.21.150 10.11.44.241 HTTP 178 HTTP/1.1 407 Proxy
Authentication Required , NTLMSSP_CHALLENGE (text/html)
461 19.105225000 10.11.44.241 10.11.21.150 HTTP 547 GET
Loading Image... HTTP/1.1 , NTLMSSP_AUTH,
User: MY_DOMAIN\my_user
500 19.351147000 10.11.21.150 10.11.44.241 HTTP 1371 HTTP/1.1 200 OK (PNG)
-----------------------------------------------------------------------

And here are details of packet 461, which contains authentication data
transmitted to the server:

-----------------------------------------------------------------------
[truncated] Proxy-authorization: NTLM
TlRMTVNTUAADAAAAGAAYAIQAAAAYABgAnAAAABQAFABIAAAAFAAUAFwAAAAUABQAcAAAAAAAAAC0AAAABYKIogUBKAoAAAAPRgBFAFIAUgBFAFIATwBOAEUAVABjAGEAdgBhAGwAZABhAHYAaQAxAEQASQBUAEEAMQA4ADIANgA2ADIA/pQZE5JCPIsAAAAAAAAAAAAAA
NTLM Secure Service Provider
NTLMSSP identifier: NTLMSSP
NTLM Message Type: NTLMSSP_AUTH (0x00000003)
Lan Manager Response: fe94191392423c8b00000000000000000000000000000000
NTLM Client Challenge: fe94191392423c8b
NTLM Response: 65a0133a269c38f849096f367ea73dbd3f3ab3256415d232
Domain name: MY_DOMAIN
User name: my_user
Host name: my_host
Session Key: Empty
Flags: 0xa2888205
Version 5.1 (Build 2600); NTLM Current Revision 15
-----------------------------------------------------------------------


By comparison, here's what I get when I perform a similar request with
QLandkarte GT (downloaded build version 1.5.1 for Windows). Please
notice that the client does not reply at all to the server's
authentication request:

-----------------------------------------------------------------------
212 13.366244000 10.11.44.241 10.11.21.151 HTTP 242 GET
Loading Image... HTTP/1.1
228 13.374234000 10.11.21.151 10.11.44.241 HTTP 1228 HTTP/1.1 407 Proxy
Authentication Required (text/html)
-----------------------------------------------------------------------


Finally, I'm sending the log when I try the same thing with the version
I recompiled, where I pass username and password to
QNetworkProxy::setApplicationProxy():

-----------------------------------------------------------------------
200 12.264664000 10.11.44.241 10.11.21.151 HTTP 242 GET
http://tile.openstreetmap.org/0/0/-1.png HTTP/1.1
216 12.273321000 10.11.21.151 10.11.44.241 HTTP 1228 HTTP/1.1 407 Proxy
Authentication Required (text/html)
253 12.284451000 10.11.44.241 10.11.21.151 HTTP 314 GET
http://tile.openstreetmap.org/0/0/-1.png HTTP/1.1 , NTLMSSP_NEGOTIATE
276 12.333578000 10.11.21.151 10.11.44.241 HTTP 178 HTTP/1.1 407 Proxy
Authentication Required , NTLMSSP_CHALLENGE (text/html)
298 12.340180000 10.11.44.241 10.11.21.151 HTTP 674 GET
Loading Image... HTTP/1.1 , NTLMSSP_AUTH, User:
MY_DOMAIN\
308 12.367010000 10.11.21.151 10.11.44.241 HTTP 1232 HTTP/1.1 407 Proxy
Authentication Required (text/html)
-----------------------------------------------------------------------

Details of packet 298:

-----------------------------------------------------------------------
[truncated] Proxy-Authorization: NTLM
TlRMTVNTUAADAAAAAAAAAFQAAADaANoAVAAAABQAFABAAAAAAAAAAFQAAAAAAAAAVAAAAAAAAAAAAAAAAQIAAEYARQBSAFIARQBSAE8ATgBFAFQAV12u0BfFzp5lcm7ma6MtJAEBAAAAAAAAgLQWjpmVzQFhMGMzZTFhOQAAAAACABQARgBFAFIAUgBFAFIATwBOAEUAV
NTLM Secure Service Provider
NTLMSSP identifier: NTLMSSP
NTLM Message Type: NTLMSSP_AUTH (0x00000003)
Lan Manager Response: Empty
NTLM Response: 575daed017c5ce9e65726ee66ba32d240101000000000000...
NTLM Client Challenge: 6130633365316139
Domain name: MY_DOMAIN
User name: NULL
Host name: NULL
Session Key: Empty
Flags: 0x00000201
-----------------------------------------------------------------------


So, something has changed. Now authentication data is sent to server.
However, they are incomplete--user name is NULL!

I need to further investigate QNetworkProxy class.
solitone
2012-09-19 09:30:03 UTC
Permalink
Post by solitone
-----------------------------------------------------------------------
200 12.264664000 10.11.44.241 10.11.21.151 HTTP 242 GET
http://tile.openstreetmap.org/0/0/-1.png HTTP/1.1
216 12.273321000 10.11.21.151 10.11.44.241 HTTP 1228 HTTP/1.1 407 Proxy
Authentication Required (text/html)
253 12.284451000 10.11.44.241 10.11.21.151 HTTP 314 GET
http://tile.openstreetmap.org/0/0/-1.png HTTP/1.1 , NTLMSSP_NEGOTIATE
276 12.333578000 10.11.21.151 10.11.44.241 HTTP 178 HTTP/1.1 407 Proxy
Authentication Required , NTLMSSP_CHALLENGE (text/html)
298 12.340180000 10.11.44.241 10.11.21.151 HTTP 674 GET
MY_DOMAIN\
308 12.367010000 10.11.21.151 10.11.44.241 HTTP 1232 HTTP/1.1 407 Proxy
Authentication Required (text/html)
-----------------------------------------------------------------------
-----------------------------------------------------------------------
[truncated] Proxy-Authorization: NTLM
TlRMTVNTUAADAAAAAAAAAFQAAADaANoAVAAAABQAFABAAAAAAAAAAFQAAAAAAAAAVAAAAAAAAAAAAAAAAQIAAEYARQBSAFIARQBSAE8ATgBFAFQAV12u0BfFzp5lcm7ma6MtJAEBAAAAAAAAgLQWjpmVzQFhMGMzZTFhOQAAAAACABQARgBFAFIAUgBFAFIATwBOAEUAV
NTLM Secure Service Provider
NTLMSSP identifier: NTLMSSP
NTLM Message Type: NTLMSSP_AUTH (0x00000003)
Lan Manager Response: Empty
NTLM Response: 575daed017c5ce9e65726ee66ba32d240101000000000000...
NTLM Client Challenge: 6130633365316139
Domain name: MY_DOMAIN
User name: NULL
Host name: NULL
Session Key: Empty
Flags: 0x00000201
-----------------------------------------------------------------------
So, something has changed. Now authentication data is sent to server.
However, they are incomplete--user name is NULL!
I fear it's an issue of QT with NTLMv2. I found several reports of
problems with NTLMv2, but I still don't have a clear picture.

I'm not sure, as I don't have access to the proxy server, and so I don't
know whether my proxy is actually using NTLMv2 authentication--but I
suspect it is.
solitone
2012-09-25 16:35:22 UTC
Permalink
Post by Albrecht Dreß
Just a dumb question - wouldn't it be sufficient to just add the user
name and password to the call of
QNetworkProxy::setApplicationProxy(QNetworkProxy(QNetworkProxy::HttpProxy,m_httpProxy,m_httpProxyPort));
in CResources::CResources()?
After struggling with QT's proxy support (and reading the Getting
Started to QT Programming doc), I eventually found out that it's not
that straightforward.

In my scenario, it is pointless to pass username and password to the
QNetworkProxy constructor, as I pointed out in a previous message.

Instead, in every class using proxy, I had to add a connection between
the proxyAuthenticationRequired() signal and a slot that manages proxy
Post by Albrecht Dreß
connect(&networkAccessManager, SIGNAL(proxyAuthenticationRequired(const QNetworkProxy&, QAuthenticator*)),
this, SLOT(slotProxyAuthenticationRequired(const QNetworkProxy&, QAuthenticator*)));
The slot then picks up authentication data from my Windows registry, and
Post by Albrecht Dreß
void CSearchDB::slotProxyAuthenticationRequired(const QNetworkProxy &prox, QAuthenticator *auth)
{
QString user;
QString pwd;
CResources::self().getHttpProxyAuth(user,pwd);
auth->setUser(user);
auth->setPassword(pwd);
}
Here you can find a simple example of this technique:
http://qt-project.org/forums/viewthread/20539/#98842

I found the proxy is set up in 11 classes. These are the source files
Post by Albrecht Dreß
Search "setProxy" (12 hits in 11 files)
C:\usr\qlandkartegt-1.5.1\src\CCreateMapWMS.cpp (1 hits)
Line 72: server->setProxy(url,port);
C:\usr\qlandkartegt-1.5.1\src\CDlgMapWmsConfig.cpp (1 hits)
Line 147: accessManager->setProxy(QNetworkProxy(QNetworkProxy::DefaultProxy));
C:\usr\qlandkartegt-1.5.1\src\CMapTms.cpp (1 hits)
Line 87: accessManager->setProxy(QNetworkProxy(QNetworkProxy::DefaultProxy));
C:\usr\qlandkartegt-1.5.1\src\CMapWms.cpp (1 hits)
Line 158: accessManager->setProxy(QNetworkProxy(QNetworkProxy::DefaultProxy));
C:\usr\qlandkartegt-1.5.1\src\COsmTilesHash.cpp (1 hits)
Line 52: m_networkAccessManager->setProxy(QNetworkProxy(QNetworkProxy::DefaultProxy));
C:\usr\qlandkartegt-1.5.1\src\CRouteToolWidget.cpp (2 hits)
Line 64: m_networkAccessManager->setProxy(QNetworkProxy(QNetworkProxy::DefaultProxy,url,port));
Line 171: m_networkAccessManager->setProxy(QNetworkProxy(QNetworkProxy::DefaultProxy));
C:\usr\qlandkartegt-1.5.1\src\CSearchDB.cpp (1 hits)
Line 44: networkAccessManager.setProxy(QNetworkProxy(QNetworkProxy::DefaultProxy));
C:\usr\qlandkartegt-1.5.1\src\CTrack.cpp (1 hits)
Line 630: geonames->setProxy(QNetworkProxy(QNetworkProxy::DefaultProxy));
Hopefully I didn't miss any.
Post by Albrecht Dreß
Adding two more config elements and optionally tweaking
CResources::getHttpProxy() to pick up the authentication tokens from the
environment (although the latter is not a good idea from the security
pov) should then be trivial...
At the moment, I manually added two keys for my proxy username and
password to Windows registry. I understand your point on security, but I
am currently unaware of what other options might be explored.

Rather than changing the signature of CResources::getHttpProxy(), in the
Post by Albrecht Dreß
void CResources::getHttpProxyAuth(QString& user, QString& pwd)
{
// Proxy authentication support
user = m_httpProxyUser;
pwd = m_httpProxyPwd;
}
I tested it and everything seems to work just fine! OpenStreet/CycleMaps
are displayed, and both Google and OpenRouteService search do work as well.

Please let me know whether I could perform some other test.

The only thing missing is setting up proxy authentication data from the
GUI--and not by manually editing the registry. I'm not a C++ / GT
programmer, so it'll presumably take me some time.

I would share the changes I made to the code. I know there's a diff tool
that would be helpful, but I have to refresh my memory on how to take
advantage of it.

Any further suggestion is welcomed!
solitone
2012-09-26 14:23:16 UTC
Permalink
Post by solitone
The only thing missing is setting up proxy authentication data from the
GUI--and not by manually editing the registry. I'm not a C++ / GT
programmer, so it'll presumably take me some time.
I've done also this last thing, adding a couple of LineEdits in the
proxy configuration widget for user and password fields.
Post by solitone
I would share the changes I made to the code. I know there's a diff tool
that would be helpful, but I have to refresh my memory on how to take
advantage of it.
Here's the diff output. Please consider I'm not sure whether my changes
have an impact on locale translations..


diff --git "a/..\\..\\qlandkartegt-1.5.1.orig\\src/CCreateMapWMS.cpp"
b/./CCreateMapWMS.cpp
index eaa284b..94bc2c5 100644
--- "a/..\\..\\qlandkartegt-1.5.1.orig\\src/CCreateMapWMS.cpp"
+++ b/./CCreateMapWMS.cpp
@@ -24,7 +24,7 @@
#include "CMainWindow.h"

#include <QtGui>
-#include <QtNetwork/QHttp>
+#include <QtNetwork>
#include <QtXml/QDomDocument>
#include <projects.h>

@@ -70,6 +70,8 @@ void CCreateMapWMS::slotSetupLink()
if(enableProxy)
{
server->setProxy(url,port);
+ connect(server, SIGNAL(proxyAuthenticationRequired(const
QNetworkProxy&, QAuthenticator*)),
+ this, SLOT(slotProxyAuthenticationRequired(const QNetworkProxy&,
QAuthenticator*)));
}


connect(server,SIGNAL(requestStarted(int)),this,SLOT(slotRequestStarted(int)));
@@ -248,6 +250,18 @@ void CCreateMapWMS::slotRequestFinished(int , bool
error)
}


+void CCreateMapWMS::slotProxyAuthenticationRequired(const QNetworkProxy
&prox, QAuthenticator *auth)
+{
+ QString user;
+ QString pwd;
+
+ CResources::self().getHttpProxyAuth(user,pwd);
+
+ auth->setUser(user);
+ auth->setPassword(pwd);
+}
+
+
void CCreateMapWMS::slotSave()
{
QDomDocument dom;
diff --git "a/..\\..\\qlandkartegt-1.5.1.orig\\src/CCreateMapWMS.h"
b/./CCreateMapWMS.h
index 21cc9e5..5574573 100644
--- "a/..\\..\\qlandkartegt-1.5.1.orig\\src/CCreateMapWMS.h"
+++ b/./CCreateMapWMS.h
@@ -21,6 +21,7 @@
#define CCREATEMAPWMS_H

#include <QWidget>
+#include <QtNetwortk>
#include "ui_ICreateMapWMS.h"

class QHttp;
@@ -37,6 +38,7 @@ class CCreateMapWMS : public QWidget, private
Ui::ICreateMapWMS
void slotSetupLink();
void slotRequestStarted(int );
void slotRequestFinished(int , bool error);
+ void slotProxyAuthenticationRequired(const QNetworkProxy&,
QAuthenticator*);
void slotSave();
void slotSelectFile();

diff --git "a/..\\..\\qlandkartegt-1.5.1.orig\\src/CDlgConfig.cpp"
b/./CDlgConfig.cpp
index 5b86c61..34e0bfc 100644
--- "a/..\\..\\qlandkartegt-1.5.1.orig\\src/CDlgConfig.cpp"
+++ b/./CDlgConfig.cpp
@@ -67,6 +67,8 @@ void CDlgConfig::exec()
checkProxy->setChecked(resources.m_useHttpProxy);
lineProxyURL->setText(resources.m_httpProxy);
lineProxyPort->setText(QString("%1").arg(resources.m_httpProxyPort));
+ lineProxyUser->setText(resources.m_httpProxyUser);
+ lineProxyPwd->setText(resources.m_httpProxyPwd);

labelFont->setFont(resources.m_mapfont);
if(resources.unit->type == "metric")
@@ -160,6 +162,8 @@ void CDlgConfig::accept()
resources.m_useHttpProxy = checkProxy->isChecked();
resources.m_httpProxy = lineProxyURL->text();
resources.m_httpProxyPort = lineProxyPort->text().toUInt();
+ resources.m_httpProxyUser = lineProxyUser->text();
+ resources.m_httpProxyPwd = lineProxyPwd->text();

if(resources.m_useHttpProxy)

QNetworkProxy::setApplicationProxy(QNetworkProxy(QNetworkProxy::HttpProxy,resources.m_httpProxy,resources.m_httpProxyPort));
diff --git "a/..\\..\\qlandkartegt-1.5.1.orig\\src/CDlgMapWmsConfig.cpp"
b/./CDlgMapWmsConfig.cpp
index 5bf41d3..7e21aa9 100644
--- "a/..\\..\\qlandkartegt-1.5.1.orig\\src/CDlgMapWmsConfig.cpp"
+++ b/./CDlgMapWmsConfig.cpp
@@ -20,6 +20,7 @@
#include "CDlgMapWmsConfig.h"
#include "CMapWms.h"
#include "CMapDB.h"
+#include "CResources.h"

#include <QtGui>
#include <QtXml>
@@ -145,7 +146,10 @@ CDlgMapWmsConfig::CDlgMapWmsConfig(CMapWms &map)

accessManager = new QNetworkAccessManager(this);
accessManager->setProxy(QNetworkProxy(QNetworkProxy::DefaultProxy));
+

connect(accessManager,SIGNAL(finished(QNetworkReply*)),this,SLOT(slotRequestFinished(QNetworkReply*)));
+ connect(accessManager, SIGNAL(proxyAuthenticationRequired(const
QNetworkProxy&, QAuthenticator*)),
+ this, SLOT(slotProxyAuthenticationRequired(const QNetworkProxy&,
QAuthenticator*)));

QNetworkRequest request;
QUrl url(map.urlstr);
@@ -293,3 +297,15 @@ void
CDlgMapWmsConfig::slotRequestFinished(QNetworkReply* reply)
textCapabilities->setPlainText(dom.toString());
}
}
+
+
+void CDlgMapWmsConfig::slotProxyAuthenticationRequired(const
QNetworkProxy &prox, QAuthenticator *auth)
+{
+ QString user;
+ QString pwd;
+
+ CResources::self().getHttpProxyAuth(user,pwd);
+
+ auth->setUser(user);
+ auth->setPassword(pwd);
+}
diff --git "a/..\\..\\qlandkartegt-1.5.1.orig\\src/CDlgMapWmsConfig.h"
b/./CDlgMapWmsConfig.h
index 3af6843..c1c7016 100644
--- "a/..\\..\\qlandkartegt-1.5.1.orig\\src/CDlgMapWmsConfig.h"
+++ b/./CDlgMapWmsConfig.h
@@ -21,7 +21,7 @@
#define CDLGMAPWMSCONFIG_H

#include <QDialog>
-
+#include <QtNetwork>
#include "ui_IDlgMapWmsConfig.h"

class CMapWms;
@@ -41,6 +41,7 @@ class CDlgMapWmsConfig : public QDialog, private
Ui::IDlgMapWmsConfig

private slots:
void slotRequestFinished(QNetworkReply* reply);
+ void slotProxyAuthenticationRequired(const QNetworkProxy&,
QAuthenticator*);

private:
void updateEntry(QDomDocument& dom, QTreeWidgetItem* item,
QDomElement& elem, const QString& tag);
diff --git "a/..\\..\\qlandkartegt-1.5.1.orig\\src/CMapTms.cpp"
b/./CMapTms.cpp
index e8584bc..9925fe8 100644
--- "a/..\\..\\qlandkartegt-1.5.1.orig\\src/CMapTms.cpp"
+++ b/./CMapTms.cpp
@@ -85,7 +85,10 @@ CMapTms::CMapTms(const QString& key, CCanvas *parent)

accessManager = new QNetworkAccessManager(this);
accessManager->setProxy(QNetworkProxy(QNetworkProxy::DefaultProxy));
+

connect(accessManager,SIGNAL(finished(QNetworkReply*)),this,SLOT(slotRequestFinished(QNetworkReply*)));
+ connect(accessManager, SIGNAL(proxyAuthenticationRequired(const
QNetworkProxy&, QAuthenticator*)),
+ this, SLOT(slotProxyAuthenticationRequired(const QNetworkProxy&,
QAuthenticator*)));

if ( layers[0].strUrl.startsWith("file") )
{
@@ -659,6 +662,18 @@ void CMapTms::slotRequestFinished(QNetworkReply* reply)
}


+void CMapTms::slotProxyAuthenticationRequired(const QNetworkProxy
&prox, QAuthenticator *auth)
+{
+ QString user;
+ QString pwd;
+
+ CResources::self().getHttpProxyAuth(user,pwd);
+
+ auth->setUser(user);
+ auth->setPassword(pwd);
+}
+
+
void CMapTms::config()
{
CDlgMapTmsConfig dlg(*this);
diff --git "a/..\\..\\qlandkartegt-1.5.1.orig\\src/CMapTms.h" b/./CMapTms.h
index f2f88b4..a35a9a8 100644
--- "a/..\\..\\qlandkartegt-1.5.1.orig\\src/CMapTms.h"
+++ b/./CMapTms.h
@@ -27,6 +27,7 @@
#include <QSet>
#include <QtCore>
#include <IDiskCache.h>
+#include <QtNetwork>

class QNetworkAccessManager;
class QNetworkReply;
@@ -63,6 +64,7 @@ class CMapTms : public IMap

private slots:
void slotRequestFinished(QNetworkReply* reply);
+ void slotProxyAuthenticationRequired(const QNetworkProxy&,
QAuthenticator*);


private:
diff --git "a/..\\..\\qlandkartegt-1.5.1.orig\\src/CMapWms.cpp"
b/./CMapWms.cpp
index c2658f1..66ab8d5 100644
--- "a/..\\..\\qlandkartegt-1.5.1.orig\\src/CMapWms.cpp"
+++ b/./CMapWms.cpp
@@ -156,7 +156,10 @@ CMapWms::CMapWms(const QString &key, const QString
&filename, CCanvas *parent)

accessManager = new QNetworkAccessManager(this);
accessManager->setProxy(QNetworkProxy(QNetworkProxy::DefaultProxy));
+

connect(accessManager,SIGNAL(finished(QNetworkReply*)),this,SLOT(slotRequestFinished(QNetworkReply*)));
+ connect(accessManager, SIGNAL(proxyAuthenticationRequired(const
QNetworkProxy&, QAuthenticator*)),
+ this, SLOT(slotProxyAuthenticationRequired(const QNetworkProxy&,
QAuthenticator*)));

diskCache = new CDiskCache(false, this);

@@ -680,6 +683,19 @@ void CMapWms::slotRequestFinished(QNetworkReply* reply)
emit sigChanged();
}

+
+void CMapWms::slotProxyAuthenticationRequired(const QNetworkProxy
&prox, QAuthenticator *auth)
+{
+ QString user;
+ QString pwd;
+
+ CResources::self().getHttpProxyAuth(user,pwd);
+
+ auth->setUser(user);
+ auth->setPassword(pwd);
+}
+
+
void CMapWms::config()
{
CDlgMapWmsConfig dlg(*this);
diff --git "a/..\\..\\qlandkartegt-1.5.1.orig\\src/CMapWms.h" b/./CMapWms.h
index d2ece60..048703c 100644
--- "a/..\\..\\qlandkartegt-1.5.1.orig\\src/CMapWms.h"
+++ b/./CMapWms.h
@@ -25,6 +25,7 @@
#include <QHash>
#include <QQueue>
#include <QSet>
+#include <QtNetwork>

class QCheckBox;
class QNetworkAccessManager;
@@ -59,6 +60,7 @@ class CMapWms : public IMap

private slots:
void slotRequestFinished(QNetworkReply* reply);
+ void slotProxyAuthenticationRequired(const QNetworkProxy&,
QAuthenticator*);

private:
void convertPixel2M(double& u, double& v);
diff --git "a/..\\..\\qlandkartegt-1.5.1.orig\\src/COsmTilesHash.cpp"
b/./COsmTilesHash.cpp
index ccc69ce..b31dc58 100644
--- "a/..\\..\\qlandkartegt-1.5.1.orig\\src/COsmTilesHash.cpp"
+++ b/./COsmTilesHash.cpp
@@ -52,6 +52,8 @@ COsmTilesHash::COsmTilesHash(QString tileUrl, QObject
*parent)

m_networkAccessManager->setProxy(QNetworkProxy(QNetworkProxy::DefaultProxy));


connect(m_networkAccessManager,SIGNAL(finished(QNetworkReply*)),this,SLOT(slotRequestFinished(QNetworkReply*)));
+ connect(m_networkAccessManager,
SIGNAL(proxyAuthenticationRequired(const QNetworkProxy&, QAuthenticator*)),
+ this, SLOT(slotProxyAuthenticationRequired(const QNetworkProxy&,
QAuthenticator*)));
}


@@ -186,3 +188,16 @@ int COsmTilesHash::lat2tile(double lat, int z)
{
return (int)(qRound(256*(1.0 - log( tan(lat * M_PI/180.0) + 1.0 /
cos(lat * M_PI/180.0)) / M_PI) / 2.0 * pow(2.0, z)));
}
+
+
+void COsmTilesHash::slotProxyAuthenticationRequired(const QNetworkProxy
&prox, QAuthenticator *auth)
+{
+ QString user;
+ QString pwd;
+
+ CResources::self().getHttpProxyAuth(user,pwd);
+
+ auth->setUser(user);
+ auth->setPassword(pwd);
+}
+
diff --git "a/..\\..\\qlandkartegt-1.5.1.orig\\src/COsmTilesHash.h"
b/./COsmTilesHash.h
index 5512f7e..9ab241e 100644
--- "a/..\\..\\qlandkartegt-1.5.1.orig\\src/COsmTilesHash.h"
+++ b/./COsmTilesHash.h
@@ -41,6 +41,7 @@ class COsmTilesHash: public QObject

signals:
void newImageReady(const QPixmap& image, bool lastTileLoaded);
+
private:
QUrl m_tileUrl;
QString m_tilePath;
@@ -58,7 +59,9 @@ class COsmTilesHash: public QObject
QNetworkAccessManager *m_networkAccessManager;

void dequeue();
+
private slots:
void slotRequestFinished(QNetworkReply*);
+ void slotProxyAuthenticationRequired(const QNetworkProxy&,
QAuthenticator*);
};
#endif /* COSMTILESHASH_H_ */
diff --git "a/..\\..\\qlandkartegt-1.5.1.orig\\src/CResources.cpp"
b/./CResources.cpp
index 5776c2b..7134759 100644
--- "a/..\\..\\qlandkartegt-1.5.1.orig\\src/CResources.cpp"
+++ b/./CResources.cpp
@@ -106,8 +106,13 @@ CResources::CResources(QObject * parent)
m_httpProxy =
cfg.value("network/proxy/url",m_httpProxy).toString();
m_httpProxyPort =
cfg.value("network/proxy/port",m_httpProxyPort).toUInt();

+ // Proxy authentication support
+ m_httpProxyUser =
cfg.value("network/proxy/usr",m_httpProxyUser).toString();
+ m_httpProxyPwd =
cfg.value("network/proxy/pwd",m_httpProxyPwd).toString();
+
if(m_useHttpProxy)

QNetworkProxy::setApplicationProxy(QNetworkProxy(QNetworkProxy::HttpProxy,m_httpProxy,m_httpProxyPort));
+
else

QNetworkProxy::setApplicationProxy(QNetworkProxy(QNetworkProxy::NoProxy));

@@ -222,6 +227,9 @@ CResources::~CResources()
cfg.setValue("network/useProxy",m_useHttpProxy);
cfg.setValue("network/proxy/url",m_httpProxy);
cfg.setValue("network/proxy/port",m_httpProxyPort);
+ // Proxy authentication support
+ cfg.setValue("network/proxy/usr",m_httpProxyUser);
+ cfg.setValue("network/proxy/pwd",m_httpProxyPwd);


cfg.setValue("device/key",m_devKey);
@@ -279,9 +287,16 @@ bool CResources::getHttpProxy(QString& url,
quint16& port)

url = m_httpProxy;
port = m_httpProxyPort;
+
return m_useHttpProxy;
}

+void CResources::getHttpProxyAuth(QString& user, QString& pwd)
+{
+ // Proxy authentication support
+ user = m_httpProxyUser;
+ pwd = m_httpProxyPwd;
+}

IDevice * CResources::device()
{
@@ -352,5 +367,3 @@ QString CResources::charset()
else
return m_devCharset;
}
\ No newline at end of file
-
-
diff --git "a/..\\..\\qlandkartegt-1.5.1.orig\\src/CResources.h"
b/./CResources.h
index 47da89f..4709637 100644
--- "a/..\\..\\qlandkartegt-1.5.1.orig\\src/CResources.h"
+++ b/./CResources.h
@@ -45,6 +45,7 @@ class CResources : public QObject
@return The method will return true if the proxy is enabled.
*/
bool getHttpProxy(QString& url, quint16& port);
+ void getHttpProxyAuth(QString& user, QString& pwd);

/// get pointer to current device handler
IDevice * device();
@@ -102,6 +103,10 @@ class CResources : public QObject
/// the proxy port
quint16 m_httpProxyPort;

+ /// the proxy logon data
+ QString m_httpProxyUser;
+ QString m_httpProxyPwd;
+
/// font used by the map
QFont m_mapfont;

diff --git "a/..\\..\\qlandkartegt-1.5.1.orig\\src/CRouteToolWidget.cpp"
b/./CRouteToolWidget.cpp
index 4197c37..07899c9 100644
--- "a/..\\..\\qlandkartegt-1.5.1.orig\\src/CRouteToolWidget.cpp"
+++ b/./CRouteToolWidget.cpp
@@ -63,6 +63,7 @@ CRouteToolWidget::CRouteToolWidget(QTabWidget * parent)
{

m_networkAccessManager->setProxy(QNetworkProxy(QNetworkProxy::DefaultProxy,url,port));

}
+

connect(m_networkAccessManager,SIGNAL(finished(QNetworkReply*)),this,SLOT(slotRequestFinished(QNetworkReply*)));

connect(&CRouteDB::self(), SIGNAL(sigChanged()), this,
SLOT(slotDBChanged()));
@@ -169,6 +170,9 @@ CRouteToolWidget::CRouteToolWidget(QTabWidget * parent)


m_networkAccessManager->setProxy(QNetworkProxy(QNetworkProxy::DefaultProxy));

+ connect(m_networkAccessManager,
SIGNAL(proxyAuthenticationRequired(const QNetworkProxy&, QAuthenticator*)),
+ this, SLOT(slotProxyAuthenticationRequired(const QNetworkProxy&,
QAuthenticator*)));
+
timer = new QTimer(this);
timer->setSingleShot(true);

@@ -556,6 +560,18 @@ void CRouteToolWidget::addOpenLSPos(QDomDocument&
xml, QDomElement& Parent, CRou
}


+void CRouteToolWidget::slotProxyAuthenticationRequired(const
QNetworkProxy &prox, QAuthenticator *auth)
+{
+ QString user;
+ QString pwd;
+
+ CResources::self().getHttpProxyAuth(user,pwd);
+
+ auth->setUser(user);
+ auth->setPassword(pwd);
+}
+
+
void CRouteToolWidget::slotRequestFinished(QNetworkReply* reply)
{
QString key;
@@ -930,3 +946,6 @@ void
CRouteToolWidget::addMapQuestLocations(QDomDocument& xml, QDomElement& loca
locations.appendChild(location);
}
}
+
+
+
diff --git "a/..\\..\\qlandkartegt-1.5.1.orig\\src/CRouteToolWidget.h"
b/./CRouteToolWidget.h
index 269c60b..9a2adac 100644
--- "a/..\\..\\qlandkartegt-1.5.1.orig\\src/CRouteToolWidget.h"
+++ b/./CRouteToolWidget.h
@@ -21,9 +21,11 @@

#include <QWidget>
#include <QSet>
+#include <QtNetwork>
#include "CRoute.h"
#include "ui_IRouteToolWidget.h"

+
class CRoute;
class QDomDocument;
class QDomElement;
@@ -69,6 +71,8 @@ class CRouteToolWidget : public QWidget, private
Ui::IRouteToolWidget
void slotTimeout();
void slotServiceChanged(int);

+ void slotProxyAuthenticationRequired(const QNetworkProxy&,
QAuthenticator*);
+

private:
void startOpenRouteService(CRoute& rte);
diff --git "a/..\\..\\qlandkartegt-1.5.1.orig\\src/CSearchDB.cpp"
b/./CSearchDB.cpp
index 8af0836..579fed4 100644
--- "a/..\\..\\qlandkartegt-1.5.1.orig\\src/CSearchDB.cpp"
+++ b/./CSearchDB.cpp
@@ -42,7 +42,10 @@ CSearchDB::CSearchDB(QTabWidget * tb, QObject * parent)
toolview = new CSearchToolWidget(tb);


networkAccessManager.setProxy(QNetworkProxy(QNetworkProxy::DefaultProxy));
+

connect(&networkAccessManager,SIGNAL(finished(QNetworkReply*)),this,SLOT(slotRequestFinished(QNetworkReply*)));

+ connect(&networkAccessManager,
SIGNAL(proxyAuthenticationRequired(const QNetworkProxy&, QAuthenticator*)),
+ this, SLOT(slotProxyAuthenticationRequired(const QNetworkProxy&,
QAuthenticator*)));
}


@@ -364,6 +367,18 @@ void
CSearchDB::slotRequestFinishedMapQuest(QByteArray& data)
}


+void CSearchDB::slotProxyAuthenticationRequired(const QNetworkProxy
&prox, QAuthenticator *auth)
+{
+ QString user;
+ QString pwd;
+
+ CResources::self().getHttpProxyAuth(user,pwd);
+
+ auth->setUser(user);
+ auth->setPassword(pwd);
+}
+
+
CSearch * CSearchDB::getResultByKey(const QString& key)
{
if(!results.contains(key)) return 0;
@@ -431,4 +446,3 @@ void CSearchDB::selSearchByKey(const QString& key)
}


-
diff --git "a/..\\..\\qlandkartegt-1.5.1.orig\\src/CSearchDB.h"
b/./CSearchDB.h
index 3c16c9b..64c2b4d 100644
--- "a/..\\..\\qlandkartegt-1.5.1.orig\\src/CSearchDB.h"
+++ b/./CSearchDB.h
@@ -91,6 +91,7 @@ class CSearchDB : public IDB
void slotRequestFinishedGoogle(QByteArray& data);
void slotRequestFinishedOpenRouteService(QByteArray& data);
void slotRequestFinishedMapQuest(QByteArray& data);
+ void slotProxyAuthenticationRequired(const QNetworkProxy&,
QAuthenticator*);

private:
friend class CMainWindow;
diff --git "a/..\\..\\qlandkartegt-1.5.1.orig\\src/CTrack.cpp"
b/./CTrack.cpp
index fef74f7..3a1ded0 100644
--- "a/..\\..\\qlandkartegt-1.5.1.orig\\src/CTrack.cpp"
+++ b/./CTrack.cpp
@@ -631,7 +631,8 @@ CTrack::CTrack(QObject * parent)
geonames->setHost("ws.geonames.org");

connect(geonames,SIGNAL(requestStarted(int)),this,SLOT(slotRequestStarted(int)));

connect(geonames,SIGNAL(requestFinished(int,bool)),this,SLOT(slotRequestFinished(int,bool)));

-
+ connect(geonames, SIGNAL(proxyAuthenticationRequired(const
QNetworkProxy&, QAuthenticator*)),
+ this, SLOT(slotProxyAuthenticationRequired(const QNetworkProxy&,
QAuthenticator*)));
connect(&CWptDB::self(), SIGNAL(sigChanged()), this,
SLOT(slotScaleWpt2Track()));
}

@@ -703,6 +704,19 @@ void CTrack::replaceElevationByRemote(bool
replaceOrignalData)
}
}

+
+void CTrack::slotProxyAuthenticationRequired(const QNetworkProxy &prox,
QAuthenticator *auth)
+{
+ QString user;
+ QString pwd;
+
+ CResources::self().getHttpProxyAuth(user,pwd);
+
+ auth->setUser(user);
+ auth->setPassword(pwd);
+}
+
+
void CTrack::slotRequestStarted(int id)
{
// qDebug() << "void CTrack::slotRequestStarted(int id)" << id;
@@ -1577,4 +1591,3 @@ QDataStream& operator <<(QDataStream& s, CFlags& flag)
return s;
}

-
diff --git "a/..\\..\\qlandkartegt-1.5.1.orig\\src/CTrack.h" b/./CTrack.h
index d35ea10..ccd05fa 100644
--- "a/..\\..\\qlandkartegt-1.5.1.orig\\src/CTrack.h"
+++ b/./CTrack.h
@@ -27,6 +27,7 @@
#include <QDateTime>
#include <QMap>
#include <QList>
+#include <QtNetwork>
#include <QPointer>
#include "CWpt.h"
#include "IItem.h"
@@ -38,6 +39,7 @@
#define MAX_TRACK_SIZE 10000
#define WPT_TO_TRACK_DIST 2500

+
class QHttp;
class QProgressDialog;

@@ -280,8 +282,7 @@ class CTrack : public IItem
private slots:
void slotRequestStarted(int );
void slotRequestFinished(int , bool error);
-
-
+ void slotProxyAuthenticationRequired(const QNetworkProxy&,
QAuthenticator*);

private:
friend class CTrackDB;
diff --git "a/..\\..\\qlandkartegt-1.5.1.orig\\src/IDlgConfig.ui"
b/./IDlgConfig.ui
index 227d822..86d4173 100644
--- "a/..\\..\\qlandkartegt-1.5.1.orig\\src/IDlgConfig.ui"
+++ b/./IDlgConfig.ui
@@ -271,6 +271,34 @@
</item>
</layout>
</item>
+ <item>
+ <layout class="QHBoxLayout">
+ <item>
+ <widget class="QLabel" name="labelProxyUser">
+ <property name="text">
+ <string>User</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLineEdit" name="lineProxyUser"/>
+ </item>
+ <item>
+ <widget class="QLabel" name="labelProxyPwd">
+ <property name="text">
+ <string>Password</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLineEdit" name="lineProxyPwd">
+ <property name="echoMode">
+ <enum>QLineEdit::Password</enum>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
</layout>
</widget>
</item>
Oliver Eichler
2012-09-26 17:18:45 UTC
Permalink
Hi solitone,

sorry for the late reply. First let me thank you for investigating on
that problem. Looks like you solved it.

Concerning the password: Imho it's a better practice to ask for the
login once each session and to keep the provided information in RAM.
Thus you will be asked for login only once every QLGT startup. I
wouldn't store that stuff in a registry or any other config file. Can
you change that? It's removing the setup from the config dialog and to
use QInputDialog::getText() if there is no login and password yet defined.


And please use the command "svn diff > patch.txt" and send the resulting
patch.txt That's much easier to handle for me and you :)


Oliver
Post by solitone
Post by solitone
The only thing missing is setting up proxy authentication data from the
GUI--and not by manually editing the registry. I'm not a C++ / GT
programmer, so it'll presumably take me some time.
I've done also this last thing, adding a couple of LineEdits in the
proxy configuration widget for user and password fields.
Post by solitone
I would share the changes I made to the code. I know there's a diff tool
that would be helpful, but I have to refresh my memory on how to take
advantage of it.
Here's the diff output. Please consider I'm not sure whether my changes
have an impact on locale translations..
diff --git "a/..\\..\\qlandkartegt-1.5.1.orig\\src/CCreateMapWMS.cpp"
b/./CCreateMapWMS.cpp
index eaa284b..94bc2c5 100644
--- "a/..\\..\\qlandkartegt-1.5.1.orig\\src/CCreateMapWMS.cpp"
+++ b/./CCreateMapWMS.cpp
@@ -24,7 +24,7 @@
#include "CMainWindow.h"
#include <QtGui>
-#include <QtNetwork/QHttp>
+#include <QtNetwork>
#include <QtXml/QDomDocument>
#include <projects.h>
@@ -70,6 +70,8 @@ void CCreateMapWMS::slotSetupLink()
if(enableProxy)
{
server->setProxy(url,port);
+ connect(server, SIGNAL(proxyAuthenticationRequired(const
QNetworkProxy&, QAuthenticator*)),
+ this, SLOT(slotProxyAuthenticationRequired(const QNetworkProxy&,
QAuthenticator*)));
}
connect(server,SIGNAL(requestStarted(int)),this,SLOT(slotRequestStarted(int)));
@@ -248,6 +250,18 @@ void CCreateMapWMS::slotRequestFinished(int , bool
error)
}
+void CCreateMapWMS::slotProxyAuthenticationRequired(const QNetworkProxy
&prox, QAuthenticator *auth)
+{
+ QString user;
+ QString pwd;
+
+ CResources::self().getHttpProxyAuth(user,pwd);
+
+ auth->setUser(user);
+ auth->setPassword(pwd);
+}
+
+
void CCreateMapWMS::slotSave()
{
QDomDocument dom;
diff --git "a/..\\..\\qlandkartegt-1.5.1.orig\\src/CCreateMapWMS.h"
b/./CCreateMapWMS.h
index 21cc9e5..5574573 100644
--- "a/..\\..\\qlandkartegt-1.5.1.orig\\src/CCreateMapWMS.h"
+++ b/./CCreateMapWMS.h
@@ -21,6 +21,7 @@
#define CCREATEMAPWMS_H
#include <QWidget>
+#include <QtNetwortk>
#include "ui_ICreateMapWMS.h"
class QHttp;
@@ -37,6 +38,7 @@ class CCreateMapWMS : public QWidget, private
Ui::ICreateMapWMS
void slotSetupLink();
void slotRequestStarted(int );
void slotRequestFinished(int , bool error);
+ void slotProxyAuthenticationRequired(const QNetworkProxy&,
QAuthenticator*);
void slotSave();
void slotSelectFile();
diff --git "a/..\\..\\qlandkartegt-1.5.1.orig\\src/CDlgConfig.cpp"
b/./CDlgConfig.cpp
index 5b86c61..34e0bfc 100644
--- "a/..\\..\\qlandkartegt-1.5.1.orig\\src/CDlgConfig.cpp"
+++ b/./CDlgConfig.cpp
@@ -67,6 +67,8 @@ void CDlgConfig::exec()
checkProxy->setChecked(resources.m_useHttpProxy);
lineProxyURL->setText(resources.m_httpProxy);
lineProxyPort->setText(QString("%1").arg(resources.m_httpProxyPort));
+ lineProxyUser->setText(resources.m_httpProxyUser);
+ lineProxyPwd->setText(resources.m_httpProxyPwd);
labelFont->setFont(resources.m_mapfont);
if(resources.unit->type == "metric")
@@ -160,6 +162,8 @@ void CDlgConfig::accept()
resources.m_useHttpProxy = checkProxy->isChecked();
resources.m_httpProxy = lineProxyURL->text();
resources.m_httpProxyPort = lineProxyPort->text().toUInt();
+ resources.m_httpProxyUser = lineProxyUser->text();
+ resources.m_httpProxyPwd = lineProxyPwd->text();
if(resources.m_useHttpProxy)
QNetworkProxy::setApplicationProxy(QNetworkProxy(QNetworkProxy::HttpProxy,resources.m_httpProxy,resources.m_httpProxyPort));
diff --git "a/..\\..\\qlandkartegt-1.5.1.orig\\src/CDlgMapWmsConfig.cpp"
b/./CDlgMapWmsConfig.cpp
index 5bf41d3..7e21aa9 100644
--- "a/..\\..\\qlandkartegt-1.5.1.orig\\src/CDlgMapWmsConfig.cpp"
+++ b/./CDlgMapWmsConfig.cpp
@@ -20,6 +20,7 @@
#include "CDlgMapWmsConfig.h"
#include "CMapWms.h"
#include "CMapDB.h"
+#include "CResources.h"
#include <QtGui>
#include <QtXml>
@@ -145,7 +146,10 @@ CDlgMapWmsConfig::CDlgMapWmsConfig(CMapWms &map)
accessManager = new QNetworkAccessManager(this);
accessManager->setProxy(QNetworkProxy(QNetworkProxy::DefaultProxy));
+
connect(accessManager,SIGNAL(finished(QNetworkReply*)),this,SLOT(slotRequestFinished(QNetworkReply*)));
+ connect(accessManager, SIGNAL(proxyAuthenticationRequired(const
QNetworkProxy&, QAuthenticator*)),
+ this, SLOT(slotProxyAuthenticationRequired(const QNetworkProxy&,
QAuthenticator*)));
QNetworkRequest request;
QUrl url(map.urlstr);
@@ -293,3 +297,15 @@ void
CDlgMapWmsConfig::slotRequestFinished(QNetworkReply* reply)
textCapabilities->setPlainText(dom.toString());
}
}
+
+
+void CDlgMapWmsConfig::slotProxyAuthenticationRequired(const
QNetworkProxy &prox, QAuthenticator *auth)
+{
+ QString user;
+ QString pwd;
+
+ CResources::self().getHttpProxyAuth(user,pwd);
+
+ auth->setUser(user);
+ auth->setPassword(pwd);
+}
diff --git "a/..\\..\\qlandkartegt-1.5.1.orig\\src/CDlgMapWmsConfig.h"
b/./CDlgMapWmsConfig.h
index 3af6843..c1c7016 100644
--- "a/..\\..\\qlandkartegt-1.5.1.orig\\src/CDlgMapWmsConfig.h"
+++ b/./CDlgMapWmsConfig.h
@@ -21,7 +21,7 @@
#define CDLGMAPWMSCONFIG_H
#include <QDialog>
-
+#include <QtNetwork>
#include "ui_IDlgMapWmsConfig.h"
class CMapWms;
@@ -41,6 +41,7 @@ class CDlgMapWmsConfig : public QDialog, private
Ui::IDlgMapWmsConfig
void slotRequestFinished(QNetworkReply* reply);
+ void slotProxyAuthenticationRequired(const QNetworkProxy&,
QAuthenticator*);
void updateEntry(QDomDocument& dom, QTreeWidgetItem* item,
QDomElement& elem, const QString& tag);
diff --git "a/..\\..\\qlandkartegt-1.5.1.orig\\src/CMapTms.cpp"
b/./CMapTms.cpp
index e8584bc..9925fe8 100644
--- "a/..\\..\\qlandkartegt-1.5.1.orig\\src/CMapTms.cpp"
+++ b/./CMapTms.cpp
@@ -85,7 +85,10 @@ CMapTms::CMapTms(const QString& key, CCanvas *parent)
accessManager = new QNetworkAccessManager(this);
accessManager->setProxy(QNetworkProxy(QNetworkProxy::DefaultProxy));
+
connect(accessManager,SIGNAL(finished(QNetworkReply*)),this,SLOT(slotRequestFinished(QNetworkReply*)));
+ connect(accessManager, SIGNAL(proxyAuthenticationRequired(const
QNetworkProxy&, QAuthenticator*)),
+ this, SLOT(slotProxyAuthenticationRequired(const QNetworkProxy&,
QAuthenticator*)));
if ( layers[0].strUrl.startsWith("file") )
{
@@ -659,6 +662,18 @@ void CMapTms::slotRequestFinished(QNetworkReply* reply)
}
+void CMapTms::slotProxyAuthenticationRequired(const QNetworkProxy
&prox, QAuthenticator *auth)
+{
+ QString user;
+ QString pwd;
+
+ CResources::self().getHttpProxyAuth(user,pwd);
+
+ auth->setUser(user);
+ auth->setPassword(pwd);
+}
+
+
void CMapTms::config()
{
CDlgMapTmsConfig dlg(*this);
diff --git "a/..\\..\\qlandkartegt-1.5.1.orig\\src/CMapTms.h" b/./CMapTms.h
index f2f88b4..a35a9a8 100644
--- "a/..\\..\\qlandkartegt-1.5.1.orig\\src/CMapTms.h"
+++ b/./CMapTms.h
@@ -27,6 +27,7 @@
#include <QSet>
#include <QtCore>
#include <IDiskCache.h>
+#include <QtNetwork>
class QNetworkAccessManager;
class QNetworkReply;
@@ -63,6 +64,7 @@ class CMapTms : public IMap
void slotRequestFinished(QNetworkReply* reply);
+ void slotProxyAuthenticationRequired(const QNetworkProxy&,
QAuthenticator*);
diff --git "a/..\\..\\qlandkartegt-1.5.1.orig\\src/CMapWms.cpp"
b/./CMapWms.cpp
index c2658f1..66ab8d5 100644
--- "a/..\\..\\qlandkartegt-1.5.1.orig\\src/CMapWms.cpp"
+++ b/./CMapWms.cpp
@@ -156,7 +156,10 @@ CMapWms::CMapWms(const QString &key, const QString
&filename, CCanvas *parent)
accessManager = new QNetworkAccessManager(this);
accessManager->setProxy(QNetworkProxy(QNetworkProxy::DefaultProxy));
+
connect(accessManager,SIGNAL(finished(QNetworkReply*)),this,SLOT(slotRequestFinished(QNetworkReply*)));
+ connect(accessManager, SIGNAL(proxyAuthenticationRequired(const
QNetworkProxy&, QAuthenticator*)),
+ this, SLOT(slotProxyAuthenticationRequired(const QNetworkProxy&,
QAuthenticator*)));
diskCache = new CDiskCache(false, this);
@@ -680,6 +683,19 @@ void CMapWms::slotRequestFinished(QNetworkReply* reply)
emit sigChanged();
}
+
+void CMapWms::slotProxyAuthenticationRequired(const QNetworkProxy
&prox, QAuthenticator *auth)
+{
+ QString user;
+ QString pwd;
+
+ CResources::self().getHttpProxyAuth(user,pwd);
+
+ auth->setUser(user);
+ auth->setPassword(pwd);
+}
+
+
void CMapWms::config()
{
CDlgMapWmsConfig dlg(*this);
diff --git "a/..\\..\\qlandkartegt-1.5.1.orig\\src/CMapWms.h" b/./CMapWms.h
index d2ece60..048703c 100644
--- "a/..\\..\\qlandkartegt-1.5.1.orig\\src/CMapWms.h"
+++ b/./CMapWms.h
@@ -25,6 +25,7 @@
#include <QHash>
#include <QQueue>
#include <QSet>
+#include <QtNetwork>
class QCheckBox;
class QNetworkAccessManager;
@@ -59,6 +60,7 @@ class CMapWms : public IMap
void slotRequestFinished(QNetworkReply* reply);
+ void slotProxyAuthenticationRequired(const QNetworkProxy&,
QAuthenticator*);
void convertPixel2M(double& u, double& v);
diff --git "a/..\\..\\qlandkartegt-1.5.1.orig\\src/COsmTilesHash.cpp"
b/./COsmTilesHash.cpp
index ccc69ce..b31dc58 100644
--- "a/..\\..\\qlandkartegt-1.5.1.orig\\src/COsmTilesHash.cpp"
+++ b/./COsmTilesHash.cpp
@@ -52,6 +52,8 @@ COsmTilesHash::COsmTilesHash(QString tileUrl, QObject
*parent)
m_networkAccessManager->setProxy(QNetworkProxy(QNetworkProxy::DefaultProxy));
connect(m_networkAccessManager,SIGNAL(finished(QNetworkReply*)),this,SLOT(slotRequestFinished(QNetworkReply*)));
+ connect(m_networkAccessManager,
SIGNAL(proxyAuthenticationRequired(const QNetworkProxy&, QAuthenticator*)),
+ this, SLOT(slotProxyAuthenticationRequired(const QNetworkProxy&,
QAuthenticator*)));
}
@@ -186,3 +188,16 @@ int COsmTilesHash::lat2tile(double lat, int z)
{
return (int)(qRound(256*(1.0 - log( tan(lat * M_PI/180.0) + 1.0 /
cos(lat * M_PI/180.0)) / M_PI) / 2.0 * pow(2.0, z)));
}
+
+
+void COsmTilesHash::slotProxyAuthenticationRequired(const QNetworkProxy
&prox, QAuthenticator *auth)
+{
+ QString user;
+ QString pwd;
+
+ CResources::self().getHttpProxyAuth(user,pwd);
+
+ auth->setUser(user);
+ auth->setPassword(pwd);
+}
+
diff --git "a/..\\..\\qlandkartegt-1.5.1.orig\\src/COsmTilesHash.h"
b/./COsmTilesHash.h
index 5512f7e..9ab241e 100644
--- "a/..\\..\\qlandkartegt-1.5.1.orig\\src/COsmTilesHash.h"
+++ b/./COsmTilesHash.h
@@ -41,6 +41,7 @@ class COsmTilesHash: public QObject
void newImageReady(const QPixmap& image, bool lastTileLoaded);
+
QUrl m_tileUrl;
QString m_tilePath;
@@ -58,7 +59,9 @@ class COsmTilesHash: public QObject
QNetworkAccessManager *m_networkAccessManager;
void dequeue();
+
void slotRequestFinished(QNetworkReply*);
+ void slotProxyAuthenticationRequired(const QNetworkProxy&,
QAuthenticator*);
};
#endif /* COSMTILESHASH_H_ */
diff --git "a/..\\..\\qlandkartegt-1.5.1.orig\\src/CResources.cpp"
b/./CResources.cpp
index 5776c2b..7134759 100644
--- "a/..\\..\\qlandkartegt-1.5.1.orig\\src/CResources.cpp"
+++ b/./CResources.cpp
@@ -106,8 +106,13 @@ CResources::CResources(QObject * parent)
m_httpProxy =
cfg.value("network/proxy/url",m_httpProxy).toString();
m_httpProxyPort =
cfg.value("network/proxy/port",m_httpProxyPort).toUInt();
+ // Proxy authentication support
+ m_httpProxyUser =
cfg.value("network/proxy/usr",m_httpProxyUser).toString();
+ m_httpProxyPwd =
cfg.value("network/proxy/pwd",m_httpProxyPwd).toString();
+
if(m_useHttpProxy)
QNetworkProxy::setApplicationProxy(QNetworkProxy(QNetworkProxy::HttpProxy,m_httpProxy,m_httpProxyPort));
+
else
QNetworkProxy::setApplicationProxy(QNetworkProxy(QNetworkProxy::NoProxy));
@@ -222,6 +227,9 @@ CResources::~CResources()
cfg.setValue("network/useProxy",m_useHttpProxy);
cfg.setValue("network/proxy/url",m_httpProxy);
cfg.setValue("network/proxy/port",m_httpProxyPort);
+ // Proxy authentication support
+ cfg.setValue("network/proxy/usr",m_httpProxyUser);
+ cfg.setValue("network/proxy/pwd",m_httpProxyPwd);
cfg.setValue("device/key",m_devKey);
@@ -279,9 +287,16 @@ bool CResources::getHttpProxy(QString& url,
quint16& port)
url = m_httpProxy;
port = m_httpProxyPort;
+
return m_useHttpProxy;
}
+void CResources::getHttpProxyAuth(QString& user, QString& pwd)
+{
+ // Proxy authentication support
+ user = m_httpProxyUser;
+ pwd = m_httpProxyPwd;
+}
IDevice * CResources::device()
{
@@ -352,5 +367,3 @@ QString CResources::charset()
else
return m_devCharset;
}
\ No newline at end of file
-
-
diff --git "a/..\\..\\qlandkartegt-1.5.1.orig\\src/CResources.h"
b/./CResources.h
index 47da89f..4709637 100644
--- "a/..\\..\\qlandkartegt-1.5.1.orig\\src/CResources.h"
+++ b/./CResources.h
@@ -45,6 +45,7 @@ class CResources : public QObject
@return The method will return true if the proxy is enabled.
*/
bool getHttpProxy(QString& url, quint16& port);
+ void getHttpProxyAuth(QString& user, QString& pwd);
/// get pointer to current device handler
IDevice * device();
@@ -102,6 +103,10 @@ class CResources : public QObject
/// the proxy port
quint16 m_httpProxyPort;
+ /// the proxy logon data
+ QString m_httpProxyUser;
+ QString m_httpProxyPwd;
+
/// font used by the map
QFont m_mapfont;
diff --git "a/..\\..\\qlandkartegt-1.5.1.orig\\src/CRouteToolWidget.cpp"
b/./CRouteToolWidget.cpp
index 4197c37..07899c9 100644
--- "a/..\\..\\qlandkartegt-1.5.1.orig\\src/CRouteToolWidget.cpp"
+++ b/./CRouteToolWidget.cpp
@@ -63,6 +63,7 @@ CRouteToolWidget::CRouteToolWidget(QTabWidget * parent)
{
m_networkAccessManager->setProxy(QNetworkProxy(QNetworkProxy::DefaultProxy,url,port));
}
+
connect(m_networkAccessManager,SIGNAL(finished(QNetworkReply*)),this,SLOT(slotRequestFinished(QNetworkReply*)));
connect(&CRouteDB::self(), SIGNAL(sigChanged()), this,
SLOT(slotDBChanged()));
@@ -169,6 +170,9 @@ CRouteToolWidget::CRouteToolWidget(QTabWidget * parent)
m_networkAccessManager->setProxy(QNetworkProxy(QNetworkProxy::DefaultProxy));
+ connect(m_networkAccessManager,
SIGNAL(proxyAuthenticationRequired(const QNetworkProxy&, QAuthenticator*)),
+ this, SLOT(slotProxyAuthenticationRequired(const QNetworkProxy&,
QAuthenticator*)));
+
timer = new QTimer(this);
timer->setSingleShot(true);
@@ -556,6 +560,18 @@ void CRouteToolWidget::addOpenLSPos(QDomDocument&
xml, QDomElement& Parent, CRou
}
+void CRouteToolWidget::slotProxyAuthenticationRequired(const
QNetworkProxy &prox, QAuthenticator *auth)
+{
+ QString user;
+ QString pwd;
+
+ CResources::self().getHttpProxyAuth(user,pwd);
+
+ auth->setUser(user);
+ auth->setPassword(pwd);
+}
+
+
void CRouteToolWidget::slotRequestFinished(QNetworkReply* reply)
{
QString key;
@@ -930,3 +946,6 @@ void
CRouteToolWidget::addMapQuestLocations(QDomDocument& xml, QDomElement& loca
locations.appendChild(location);
}
}
+
+
+
diff --git "a/..\\..\\qlandkartegt-1.5.1.orig\\src/CRouteToolWidget.h"
b/./CRouteToolWidget.h
index 269c60b..9a2adac 100644
--- "a/..\\..\\qlandkartegt-1.5.1.orig\\src/CRouteToolWidget.h"
+++ b/./CRouteToolWidget.h
@@ -21,9 +21,11 @@
#include <QWidget>
#include <QSet>
+#include <QtNetwork>
#include "CRoute.h"
#include "ui_IRouteToolWidget.h"
+
class CRoute;
class QDomDocument;
class QDomElement;
@@ -69,6 +71,8 @@ class CRouteToolWidget : public QWidget, private
Ui::IRouteToolWidget
void slotTimeout();
void slotServiceChanged(int);
+ void slotProxyAuthenticationRequired(const QNetworkProxy&,
QAuthenticator*);
+
void startOpenRouteService(CRoute& rte);
diff --git "a/..\\..\\qlandkartegt-1.5.1.orig\\src/CSearchDB.cpp"
b/./CSearchDB.cpp
index 8af0836..579fed4 100644
--- "a/..\\..\\qlandkartegt-1.5.1.orig\\src/CSearchDB.cpp"
+++ b/./CSearchDB.cpp
@@ -42,7 +42,10 @@ CSearchDB::CSearchDB(QTabWidget * tb, QObject * parent)
toolview = new CSearchToolWidget(tb);
networkAccessManager.setProxy(QNetworkProxy(QNetworkProxy::DefaultProxy));
+
connect(&networkAccessManager,SIGNAL(finished(QNetworkReply*)),this,SLOT(slotRequestFinished(QNetworkReply*)));
+ connect(&networkAccessManager,
SIGNAL(proxyAuthenticationRequired(const QNetworkProxy&, QAuthenticator*)),
+ this, SLOT(slotProxyAuthenticationRequired(const QNetworkProxy&,
QAuthenticator*)));
}
@@ -364,6 +367,18 @@ void
CSearchDB::slotRequestFinishedMapQuest(QByteArray& data)
}
+void CSearchDB::slotProxyAuthenticationRequired(const QNetworkProxy
&prox, QAuthenticator *auth)
+{
+ QString user;
+ QString pwd;
+
+ CResources::self().getHttpProxyAuth(user,pwd);
+
+ auth->setUser(user);
+ auth->setPassword(pwd);
+}
+
+
CSearch * CSearchDB::getResultByKey(const QString& key)
{
if(!results.contains(key)) return 0;
@@ -431,4 +446,3 @@ void CSearchDB::selSearchByKey(const QString& key)
}
-
diff --git "a/..\\..\\qlandkartegt-1.5.1.orig\\src/CSearchDB.h"
b/./CSearchDB.h
index 3c16c9b..64c2b4d 100644
--- "a/..\\..\\qlandkartegt-1.5.1.orig\\src/CSearchDB.h"
+++ b/./CSearchDB.h
@@ -91,6 +91,7 @@ class CSearchDB : public IDB
void slotRequestFinishedGoogle(QByteArray& data);
void slotRequestFinishedOpenRouteService(QByteArray& data);
void slotRequestFinishedMapQuest(QByteArray& data);
+ void slotProxyAuthenticationRequired(const QNetworkProxy&,
QAuthenticator*);
friend class CMainWindow;
diff --git "a/..\\..\\qlandkartegt-1.5.1.orig\\src/CTrack.cpp"
b/./CTrack.cpp
index fef74f7..3a1ded0 100644
--- "a/..\\..\\qlandkartegt-1.5.1.orig\\src/CTrack.cpp"
+++ b/./CTrack.cpp
@@ -631,7 +631,8 @@ CTrack::CTrack(QObject * parent)
geonames->setHost("ws.geonames.org");
connect(geonames,SIGNAL(requestStarted(int)),this,SLOT(slotRequestStarted(int)));
connect(geonames,SIGNAL(requestFinished(int,bool)),this,SLOT(slotRequestFinished(int,bool)));
-
+ connect(geonames, SIGNAL(proxyAuthenticationRequired(const
QNetworkProxy&, QAuthenticator*)),
+ this, SLOT(slotProxyAuthenticationRequired(const QNetworkProxy&,
QAuthenticator*)));
connect(&CWptDB::self(), SIGNAL(sigChanged()), this,
SLOT(slotScaleWpt2Track()));
}
@@ -703,6 +704,19 @@ void CTrack::replaceElevationByRemote(bool
replaceOrignalData)
}
}
+
+void CTrack::slotProxyAuthenticationRequired(const QNetworkProxy &prox,
QAuthenticator *auth)
+{
+ QString user;
+ QString pwd;
+
+ CResources::self().getHttpProxyAuth(user,pwd);
+
+ auth->setUser(user);
+ auth->setPassword(pwd);
+}
+
+
void CTrack::slotRequestStarted(int id)
{
// qDebug() << "void CTrack::slotRequestStarted(int id)" << id;
@@ -1577,4 +1591,3 @@ QDataStream& operator <<(QDataStream& s, CFlags& flag)
return s;
}
-
diff --git "a/..\\..\\qlandkartegt-1.5.1.orig\\src/CTrack.h" b/./CTrack.h
index d35ea10..ccd05fa 100644
--- "a/..\\..\\qlandkartegt-1.5.1.orig\\src/CTrack.h"
+++ b/./CTrack.h
@@ -27,6 +27,7 @@
#include <QDateTime>
#include <QMap>
#include <QList>
+#include <QtNetwork>
#include <QPointer>
#include "CWpt.h"
#include "IItem.h"
@@ -38,6 +39,7 @@
#define MAX_TRACK_SIZE 10000
#define WPT_TO_TRACK_DIST 2500
+
class QHttp;
class QProgressDialog;
@@ -280,8 +282,7 @@ class CTrack : public IItem
void slotRequestStarted(int );
void slotRequestFinished(int , bool error);
-
-
+ void slotProxyAuthenticationRequired(const QNetworkProxy&,
QAuthenticator*);
friend class CTrackDB;
diff --git "a/..\\..\\qlandkartegt-1.5.1.orig\\src/IDlgConfig.ui"
b/./IDlgConfig.ui
index 227d822..86d4173 100644
--- "a/..\\..\\qlandkartegt-1.5.1.orig\\src/IDlgConfig.ui"
+++ b/./IDlgConfig.ui
@@ -271,6 +271,34 @@
</item>
</layout>
</item>
+ <item>
+ <layout class="QHBoxLayout">
+ <item>
+ <widget class="QLabel" name="labelProxyUser">
+ <property name="text">
+ <string>User</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLineEdit" name="lineProxyUser"/>
+ </item>
+ <item>
+ <widget class="QLabel" name="labelProxyPwd">
+ <property name="text">
+ <string>Password</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLineEdit" name="lineProxyPwd">
+ <property name="echoMode">
+ <enum>QLineEdit::Password</enum>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
</layout>
</widget>
</item>
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Qlandkartegt-users mailing list
https://lists.sourceforge.net/lists/listinfo/qlandkartegt-users
solitone
2012-09-27 15:46:38 UTC
Permalink
Hi Oliver, and thanks for your suggestions!
Post by Oliver Eichler
Concerning the password: Imho it's a better practice to ask for the
login once each session and to keep the provided information in RAM.
Thus you will be asked for login only once every QLGT startup. I
wouldn't store that stuff in a registry or any other config file.
Yes, I do agree, much better.
Post by Oliver Eichler
Can you change that? It's removing the setup from the config dialog and to
use QInputDialog::getText() if there is no login and password yet defined.
I managed to use an input widget, but I'm having some difficulties in
getting the result I want.

I would prompt for user name and password only if proxy does require
authentication. In case username or password is incorrect, I would
prompt the user again.

But, in my current implementation, if I insert the wrong username, it
continues to send that wrong username to the proxy (monitored through
WireShark), and no response is got.

I'll try to correct this behaviour in the next days.
Post by Oliver Eichler
And please use the command "svn diff > patch.txt" and send the resulting
patch.txt That's much easier to handle for me and you :)
Right! ;^)

Is it ok if I use "git diff --no-prefix > patch.txt" ? It should result
in the same output, I think.

Thanks,
Davide
solitone
2012-09-28 10:38:18 UTC
Permalink
Post by solitone
I managed to use an input widget, but I'm having some difficulties in
getting the result I want.
I would prompt for user name and password only if proxy does require
authentication. In case username or password is incorrect, I would
prompt the user again.
But, in my current implementation, if I insert the wrong username, it
continues to send that wrong username to the proxy (monitored through
WireShark), and no response is got.
I'll try to correct this behaviour in the next days.
Just an update and a question.

Now the user is prompted again if he or she enters an invalid
username/password.

However, if you query a different service (e.g. you request some tiles
form OSM, and you previously did a Google search), you are promted again
for authentication, even though you have already entered valid
authentication data (for Google search).

I believe this depends on the several network access managers used for
sending different requests. I'm thinking of trying and changing this and
using just on network access manager for each and every request.

Now the question.

When QLKGT starts up, WireShark logs the following request:

POST http://www.qlandkarte.org:80/webservice/qlandkartegt.php HTTP/1.1\r\n

for which no proxy authentication dialog box is shown. Hence, proxy
authentication fails.

Inspecting the code, I didn't find where this call is done. Could you
please give me a hint? Perhaps I forgot to manage proxy authentication
properly for that code block, and I want to check it.

Thanks,
Davide
Oliver Eichler
2012-09-29 10:38:44 UTC
Permalink
Hi Davide,
Post by solitone
I believe this depends on the several network access managers used for
sending different requests. I'm thinking of trying and changing this and
using just on network access manager for each and every request.
Hm I am not sure if that is a good idea. The several network managers
separate the different urls and requests. Is there a way to detect if
the login fails? If there is you can reset the login in CResources.
Post by solitone
Now the question.
POST http://www.qlandkarte.org:80/webservice/qlandkartegt.php HTTP/1.1\r\n
for which no proxy authentication dialog box is shown. Hence, proxy
authentication fails.
This is to probe the actual version on sf.net. If it differs from the
local one, a small message is shown in the status bar. Thus it's nothing
really important.
Post by solitone
Inspecting the code, I didn't find where this call is done. Could you
please give me a hint? Perhaps I forgot to manage proxy authentication
properly for that code block, and I want to check it.
see CMainWindow::slotUpdate() and CMainWindow::slotGetResponse().

Oliver
solitone
2012-10-01 16:28:31 UTC
Permalink
Hi Oliver,
Post by Oliver Eichler
Post by solitone
I believe this depends on the several network access managers used for
sending different requests. I'm thinking of trying and changing this and
using just on network access manager for each and every request.
Hm I am not sure if that is a good idea. The several network managers
separate the different urls and requests. Is there a way to detect if
the login fails? If there is you can reset the login in CResources.
Unfortunately I feel there is no way to detect a proxy login failure.
For the time being proxy authentication data will not be cached in
CResources. The only drawback is you might need to enter proxy
credential several times, but I believe it is not a big issue.
Post by Oliver Eichler
Post by solitone
POST http://www.qlandkarte.org:80/webservice/qlandkartegt.php HTTP/1.1\r\n
for which no proxy authentication dialog box is shown. Hence, proxy
authentication fails.
This is to probe the actual version on sf.net. If it differs from the
local one, a small message is shown in the status bar. Thus it's nothing
really important.
It seems to me it is not possible to set up proxy parameters for QtSoap.
So, when passing through a proxy it will not be possible to check for
the last version..

A worse thing is that connecting to www.geonames.org fails as well, so
elevation data are not downloaded. I have to investigate this issue.
Perhaps I simply forgot to change the code that implement this
functionality, so proxy authentication does not work.
Oliver Eichler
2012-10-03 12:44:37 UTC
Permalink
Hi Davide,
Post by solitone
A worse thing is that connecting to www.geonames.org fails as well, so
elevation data are not downloaded. I have to investigate this issue.
Perhaps I simply forgot to change the code that implement this
functionality, so proxy authentication does not work.
That is because the code still uses QHttp instead of QAccessManager.
See CTrack::replaceElevationByRemote().

If you feel that your patch is a feasible and stable solution to the
authentication problem send a patch and I will review it. If there is no
real caveat I will add it to svn.


Oliver
solitone
2012-10-03 13:10:54 UTC
Permalink
Post by Oliver Eichler
Post by solitone
A worse thing is that connecting to www.geonames.org fails as well, so
elevation data are not downloaded. I have to investigate this issue.
Perhaps I simply forgot to change the code that implement this
functionality, so proxy authentication does not work.
That is because the code still uses QHttp instead of QAccessManager.
See CTrack::replaceElevationByRemote().
If you feel that your patch is a feasible and stable solution to the
authentication problem send a patch and I will review it. If there is no
real caveat I will add it to svn.
That's what I was thinking.

I thought the proxyAuthenticationRequired() signal would be raised
nevertheless, but apparently it's not.

Is there any drawback to switching to QNetworkAccessManager and
QNetworkReply?

Apart from the issue above, the other network functionalities seem to
work. I would still try something in order to cache authentication info
in CResources. I'll send you the patch After this attempt

Cheers, Davide
Oliver Eichler
2012-10-03 13:30:30 UTC
Permalink
Post by solitone
Is there any drawback to switching to QNetworkAccessManager and
QNetworkReply?
You mean for geonames service. No. It's just not done yet. Years ago it
was QHttp to use and then QNetworkAccessManager kicked in. Thus each
time I came across QHttp and had to alter the code anyway I changed it
to QNetworkAccessManager. And that particular part slipped my attention
so far :)


Oliver
solitone
2012-10-08 10:31:02 UTC
Permalink
Hi Oliver,

I sent my patch to your inbox, let me know if the diff file is right.

Please notice in my version proxy authentication doesn't work as far as
geonames service is concerned.

I believe QNetworkAccessManager and QNetworkReply should be used,
similarly to other pieces of code, but I didn't manage to change it.

Cheers,
Davide
solitone
2012-10-08 10:28:53 UTC
Permalink
Here's my patch, let me know if the diff file is right.

Please notice in my version proxy authentication doesn't work as far as
geonames service is concerned.

I believe QNetworkAccessManager and QNetworkReply should be used,
similarly to other pieces of code, but I didn't manage to change it.

Cheers,
Davide
Oliver Eichler
2012-10-08 16:09:39 UTC
Permalink
Hi Davide,

I just made a little chnage to your dialog and committed the patch to
svn. Please svn up and test. If everything is ok I will make a release.

Oliver
Post by solitone
Here's my patch, let me know if the diff file is right.
Please notice in my version proxy authentication doesn't work as far as
geonames service is concerned.
I believe QNetworkAccessManager and QNetworkReply should be used,
similarly to other pieces of code, but I didn't manage to change it.
Cheers,
Davide
------------------------------------------------------------------------------
Don't let slow site performance ruin your business. Deploy New Relic APM
Deploy New Relic app performance management and know exactly
what is happening inside your Ruby, Python, PHP, Java, and .NET app
Try New Relic at no cost today and get our sweet Data Nerd shirt too!
http://p.sf.net/sfu/newrelic-dev2dev
_______________________________________________
Qlandkartegt-users mailing list
https://lists.sourceforge.net/lists/listinfo/qlandkartegt-users
solitone
2012-10-11 14:29:19 UTC
Permalink
I just made a little change to your dialog and committed the patch to
svn. Please svn up and test. If everything is ok I will make a release.
I tried to compile revision 3482, but I get an error while compiling
CWptDB.cpp--it complains it cannot find identifier 'isnam'.
solitone
2012-10-11 15:49:18 UTC
Permalink
Post by solitone
I just made a little change to your dialog and committed the patch to
svn. Please svn up and test. If everything is ok I will make a release.
I tried to compile revision 3482, but I get an error while compiling
CWptDB.cpp--it complains it cannot find identifier 'isnam'.
Apparently VC++ doesn't use isnan(), but _isnan().

So I added the following code in CWptDB.cpp:

--------------------------------------------------------------------
#ifdef WIN32
#include <float.h> // for _isnan() on VC++
#define isnan(x) _isnan(x) // VC++ uses _isnan() instead of isnan()
#endif
--------------------------------------------------------------------

Besides, I also had an issue with CTrackDB.cpp--on my platform it
wouldn't compile because no abs() function supports quint32 arguments.

I therefore used qAbs() instead of abs():

--------------------------------------------------------------------
foreach(const CTrack::pt_t& trkpt, trkpts)
{
if (qAbs(timestamp - trkpt.timestamp) < delta)
//(abs(timestamp - trkpt.timestamp) < delta)
{
delta = qAbs(timestamp - trkpt.timestamp);
//abs(timestamp - trkpt.timestamp);
if(delta < maxDelta)
{
selTrkPt = &trkpt;
}
}
}
--------------------------------------------------------------------
solitone
2012-10-12 15:27:29 UTC
Permalink
Post by solitone
I also had an issue with CTrackDB.cpp--on my platform it
wouldn't compile because no abs() function supports quint32 arguments.
--------------------------------------------------------------------
foreach(const CTrack::pt_t& trkpt, trkpts)
{
if (qAbs(timestamp - trkpt.timestamp) < delta)
//(abs(timestamp - trkpt.timestamp) < delta)
{
delta = qAbs(timestamp - trkpt.timestamp);
//abs(timestamp - trkpt.timestamp);
if(delta < maxDelta)
{
selTrkPt = &trkpt;
}
}
}
--------------------------------------------------------------------
Does this make sense?

Would this change work for all platforms, or is it specific to Win32,
and so I'd need to use #ifdef macros?
Oliver Eichler
2012-10-12 15:42:36 UTC
Permalink
Hi Davide

that should be fine to get the code compiled. Just concentrate on the proxy. Helmut will heal the code for win32 when he is doing the binary for the release.

Oliver


-------- Original-Nachricht --------
Datum: Fri, 12 Oct 2012 17:27:29 +0200
Betreff: Re: [Qlandkartegt-users] Proxy authentication issue
Post by solitone
I also had an issue with CTrackDB.cpp--on my platform it
wouldn't compile because no abs() function supports quint32 arguments.
--------------------------------------------------------------------
foreach(const CTrack::pt_t& trkpt, trkpts)
{
if (qAbs(timestamp - trkpt.timestamp) < delta)
//(abs(timestamp - trkpt.timestamp) < delta)
{
delta = qAbs(timestamp - trkpt.timestamp);
//abs(timestamp - trkpt.timestamp);
if(delta < maxDelta)
{
selTrkPt = &trkpt;
}
}
}
--------------------------------------------------------------------
Does this make sense?
Would this change work for all platforms, or is it specific to Win32,
and so I'd need to use #ifdef macros?
------------------------------------------------------------------------------
Don't let slow site performance ruin your business. Deploy New Relic APM
Deploy New Relic app performance management and know exactly
what is happening inside your Ruby, Python, PHP, Java, and .NET app
Try New Relic at no cost today and get our sweet Data Nerd shirt too!
http://p.sf.net/sfu/newrelic-dev2dev
_______________________________________________
Qlandkartegt-users mailing list
https://lists.sourceforge.net/lists/listinfo/qlandkartegt-users
solitone
2012-10-12 15:54:13 UTC
Permalink
Post by Oliver Eichler
that should be fine to get the code compiled. Just concentrate on the proxy. Helmut will heal the code for win32 when he is doing the binary for the release.
Hi Oliver,

I tested it and proxy seems to work properly--apart from elevation data
that, as I told, are not fetched through proxy.

Davide
Oliver Eichler
2012-10-13 11:21:27 UTC
Permalink
Post by solitone
Post by Oliver Eichler
that should be fine to get the code compiled. Just concentrate on the proxy. Helmut will heal the code for win32 when he is doing the binary for the release.
Hi Oliver,
I tested it and proxy seems to work properly--apart from elevation data
that, as I told, are not fetched through proxy.
Hi Davide,

I took care of that. svn up

Oliver
solitone
2012-10-15 16:11:43 UTC
Permalink
Post by Oliver Eichler
Post by solitone
I tested it and proxy seems to work properly--apart from elevation data
that, as I told, are not fetched through proxy.
Hi Davide,
I took care of that. svn up
Hi Oliver,

sorry for my late feedback. I've just installed new version 1.5.2 and
proxy works fine, also when downloading elevation data.

Nice!

Cheers,
Davide

Albrecht Dreß
2012-10-03 12:48:41 UTC
Permalink
Post by solitone
Unfortunately I feel there is no way to detect a proxy login failure.
Just open a dummy HTTP connection to http://sourceforge.net/ after entering the authentication data, and check if you get an error?

Just a dumb idea...

Cheers, Albrecht.
solitone
2012-10-05 16:18:43 UTC
Permalink
Post by Albrecht Dreß
Post by solitone
Unfortunately I feel there is no way to detect a proxy login failure.
Just open a dummy HTTP connection to http://sourceforge.net/ after
entering the authentication data, and check if you get an error?
Didn't manage. Never mind, it's not a big issue in my opinion.

I'll send the patch briefly.

Cheers,
Davide
Continue reading on narkive:
Loading...