summaryrefslogtreecommitdiff
path: root/Network/NetworkAccessManager.hpp
diff options
context:
space:
mode:
authorChristoph Berg <myon@debian.org>2020-09-28 23:28:13 +0200
committerChristoph Berg <myon@debian.org>2020-09-28 23:28:13 +0200
commit7aa3c56b01768ba7d38fccedc17b30a4046b3fbb (patch)
treeda509a2cf3667b6f9855ea811f4a1f95d9e6f5ef /Network/NetworkAccessManager.hpp
parent28f34ff4908a90b1a7323b2988c33cdb1779fa06 (diff)
New upstream version 2.3.0~rc1+repackupstream/2.3.0_rc1+repack
Diffstat (limited to 'Network/NetworkAccessManager.hpp')
-rw-r--r--Network/NetworkAccessManager.hpp56
1 files changed, 7 insertions, 49 deletions
diff --git a/Network/NetworkAccessManager.hpp b/Network/NetworkAccessManager.hpp
index 1d1b79bc..d68ad215 100644
--- a/Network/NetworkAccessManager.hpp
+++ b/Network/NetworkAccessManager.hpp
@@ -4,8 +4,6 @@
#include <QNetworkAccessManager>
#include <QList>
#include <QSslError>
-#include <QNetworkReply>
-#include <QString>
#include "widgets/MessageBox.hpp"
@@ -18,58 +16,18 @@ class QWidget;
class NetworkAccessManager
: public QNetworkAccessManager
{
+ Q_OBJECT
+
public:
- NetworkAccessManager (QWidget * parent)
- : QNetworkAccessManager (parent)
- {
- // handle SSL errors that have not been cached as allowed
- // exceptions and offer them to the user to add to the ignored
- // exception cache
- connect (this, &QNetworkAccessManager::sslErrors, [this, &parent] (QNetworkReply * reply, QList<QSslError> const& errors) {
- QString message;
- QList<QSslError> new_errors;
- for (auto const& error: errors)
- {
- if (!allowed_ssl_errors_.contains (error))
- {
- new_errors << error;
- message += '\n' + reply->request ().url ().toDisplayString () + ": "
- + error.errorString ();
- }
- }
- if (new_errors.size ())
- {
- QString certs;
- for (auto const& cert : reply->sslConfiguration ().peerCertificateChain ())
- {
- certs += cert.toText () + '\n';
- }
- if (MessageBox::Ignore == MessageBox::query_message (parent, tr ("Network SSL Errors"), message, certs, MessageBox::Abort | MessageBox::Ignore))
- {
- // accumulate new SSL error exceptions that have been allowed
- allowed_ssl_errors_.append (new_errors);
- reply->ignoreSslErrors (allowed_ssl_errors_);
- }
- }
- else
- {
- // no new exceptions so silently ignore the ones already allowed
- reply->ignoreSslErrors (allowed_ssl_errors_);
- }
- });
- }
+ explicit NetworkAccessManager (QWidget * parent);
protected:
- QNetworkReply * createRequest (Operation operation, QNetworkRequest const& request, QIODevice * outgoing_data = nullptr) override
- {
- auto reply = QNetworkAccessManager::createRequest (operation, request, outgoing_data);
- // errors are usually certificate specific so passing all cached
- // exceptions here is ok
- reply->ignoreSslErrors (allowed_ssl_errors_);
- return reply;
- }
+ QNetworkReply * createRequest (Operation, QNetworkRequest const&, QIODevice * = nullptr) override;
private:
+ void filter_SSL_errors (QNetworkReply * reply, QList<QSslError> const& errors);
+
+ QWidget * parent_widget_;
QList<QSslError> allowed_ssl_errors_;
};