26 Commits

Author SHA1 Message Date
Denis Rouzaud
758d7cff4a run sipify to update deprecation annotations 2019-10-15 13:17:38 +02:00
Julien Cabieces
0dfa77ddb3 Add a new settings noProxyUrls and change UI to edit this setting 2019-07-23 19:03:51 +10:00
Nyall Dawson
b6d66becab Sipify 2019-02-27 09:41:11 +10:00
Nyall Dawson
519a30f10c Standardise dox for signals 2019-02-26 03:24:31 +10:00
Nyall Dawson
4908ef1641 Revert "Revert QgsBlockingNetworkRequest"
With recent changes in QgsNetworkAccessManager this should be
safe to resurrect (fingers crossed!). Also simplify code a lot,
because now QgsNetworkAccessManager handles waking the worker
thread after the auth request is handled.

Add a lot more tests
2019-02-01 21:44:53 +11:00
Nyall Dawson
f1040efc03 Nicer API for network timeouts 2019-02-01 21:44:53 +11:00
Nyall Dawson
dcb6104f47 Dox++ 2019-02-01 21:44:53 +11:00
Nyall Dawson
cc6d88e265 Add signal for logging after network authentication details have been added 2019-02-01 21:44:53 +11:00
Nyall Dawson
8ee2e793f8 Make network authentication request handling thread safe, avoid
races and crashes when auth requests occur in non-main thread

Like the recent SSL error handling, this commit abstracts out
the network authentication handling into a thread safe approach.
2019-02-01 21:44:53 +11:00
Nyall Dawson
2e3a717e44 Make SSL error handling thread safe, avoid races and crashes when
SSL error occurs in non-main thread

This commit reworks how SSL errors are handled in QGIS. Previously,
ssl errors emitted by non-main thread QgsNetworkAccessManager instances
were handled by the main thread in QgisApp on next event loop. But
app (in the main thread) tried to pause the timeout timer for the
QNetworkReply containing the error, which doesn't work, because you
can't stop a timer in the main thread for a timer object created
in another thread. This meant that the reply could get deleted in
the background thread while the main thread was still using it
and waiting for users to respond to the SSL error. Now the timer
handling is done in the background thread's network access manager
instance, so in the thread matching the reply's timeout timer. We
then have to do some fancy thread locking using QWaitCondition,
because we need to "pause" that thread until the SSL error
is handled in the main thread -- if we don't pause the background
thread, Qt immediately resumes the QNetworkReply without ever
giving us the change to ignore ssl errors in the reply. Phew!

Additionally, the previous approach had a shortcoming in that
there was no way to notify background threads that ssl errors
had actually be handled. To do this we need a new signal which
can be fired after app has shown the ssl dialog and given users
a chance to respond. BUT... we can't safely do this -- if we
add a method to notify background threads when ssl errors have
been handled, then it CANNOT safely reside in app -- doing so
would break for QGIS server and QField etc, where theres no
app instance around to provide this notification. As a result
I've abstracted out the ssl error handling. By default there's
a simple error handler which just logs errors and returns
without ignoring them (i.e. default Qt behavior, an ssl error
cancels the request). App has a specific subclass of the ssl
error handler which presents the nice dialog and asks users to
choose what to do. Potentially server could decide to make
its own subclass too, which could e.g. ignore SSL warnings
if an environment variable is present (but at the moment
the behavior is effectively unchanged for server).

The end result is that SSL error handling should now be
totally thread safe, and we shouldn't hit any more deadlocks
and crashes when ssl errors occur in background threads.

I've also taken the opportunity to add a new signal which
is always emitted by the main thread QgsNetworkAccessManager
instance, which is emitted whenever ANY request on any
thread encounters an SSL error, and contains the requestId
so that the ssl error can be linked back to the originating
request. This is for debugging, and for use by the
network monitoring plugin to show ssl errors encountered
by requests.
2019-01-28 15:21:40 +11:00
Nyall Dawson
ca06d407a0 Add custom QNetworkRequest::Attributes for initiator network request class name and internal id
And allow these to be retrieved from QgsNetworkRequestParameters.
This allows logging code to identify the area of code where a request
originated from, making debugging much easier!

Tag all requests created with appropriate class name and IDs
2019-01-25 23:47:05 +11:00
Nyall Dawson
a491e90a04 Add QgsNetworkAccessManager signal for reply download progress
This signal is propagated to the main thread QgsNetworkAccessManager
instance, so it is necessary only to connect to the main thread's signal
in order to receive notifications about requests created in any thread.

Also includes the original requestId to allow linked download progress
to original request
2019-01-25 23:47:05 +11:00
Nyall Dawson
009ee572d8 Allow access to content of POST requests in QgsNetworkReplyContent 2019-01-25 11:06:31 +11:00
Nyall Dawson
535965ba8c Deprecate older thread-unsafe signals 2019-01-24 06:10:37 +11:00
Nyall Dawson
5824faf674 Add thread safe QgsNetworkAccessManager::requestTimedOut signal 2019-01-24 06:10:37 +11:00
Nyall Dawson
ea1971fdf8 Add an unique id to requests, which can be used to link them to responses 2019-01-24 06:10:37 +11:00
Nyall Dawson
b5379ce055 New class QgsNetworkReplyContent, which encapsulates the useful
information from a QNetworkReply in a container which is safe
and cheap to pass between threads

(QNetworkReplys are QObject based, so not safe to access or
pass between threads)

Use this new class in a thread safe QgsNetworkAccessManager::finished
signal, which is fired on the main thread QgsNetworkAccessManager instance
when responses are finished from any thread
2019-01-24 06:10:37 +11:00
Nyall Dawson
8a920e0bc2 Rework QgsNetworkAccessManager::requestAboutToBeCreated() to be thread
safe, and encapsulate more useful request information
2019-01-22 18:27:06 +11:00
Matthias Kuhn
402f3ffdd5
Regenerate sip with latest sipify 2018-06-14 09:54:00 +02:00
Matthias Kuhn
44e8f60a63
Add documentation 2018-06-14 09:52:28 +02:00
Matthias Kuhn
620d4d7abb
Use direct connection for NAM auth connections 2018-06-14 09:52:27 +02:00
Denis Rouzaud
65bb60e96c run sipify 2018-05-28 10:39:34 -08:00
Nyall Dawson
f8bc97030b Remove extra space added before first line of docstring 2018-05-28 08:22:11 +10:00
Nyall Dawson
c864d22d1f Add "get ..." to doxygen compliance blacklist
Should be "gets ..." for consistent tense, or better yet
"returns ..." for consistency.
2018-05-27 14:05:06 +10:00
Nyall Dawson
1c615c15cc More documentation compliance
Use Qt style "returns .." tense instead of "return ..", and lock
this in with a documentation compliance unit test
2018-05-25 15:09:00 +10:00
Denis Rouzaud
7df2593caf move auto generated sip file in dedicated folder 2018-05-14 10:23:37 -04:00