Debian Codegraph @

src/librssguard/network-web/silentnetworkaccessmanager.cpp

raw symbols SCIP
1 // For license of this file, see <project-root-folder>/LICENSE.md.
2
3 #include "network-web/silentnetworkaccessmanager.h"
4
5 #include "definitions/definitions.h"
6
7 #include <QAuthenticator>
8 #include <QNetworkReply>
9
10 SilentNetworkAccessManager::SilentNetworkAccessManager(QObject* parent) : BaseNetworkAccessManager(parent) {
11 connect(this,
12 &SilentNetworkAccessManager::authenticationRequired,
13 this,
14 &SilentNetworkAccessManager::onAuthenticationRequired,
15 Qt::DirectConnection);
16 }
17
18 SilentNetworkAccessManager::~SilentNetworkAccessManager() {
19 qDebugNN << LOGSEC_NETWORK << "Destroying SilentNetworkAccessManager instance.";
20 }
21
22 void SilentNetworkAccessManager::onAuthenticationRequired(QNetworkReply* reply, QAuthenticator* authenticator) {
23 if (reply->property("protected").toBool()) {
24 // This feed contains authentication information, it is good.
25 authenticator->setUser(reply->property("username").toString());
26 authenticator->setPassword(reply->property("password").toString());
27 reply->setProperty("authentication-given", true);
28 qDebugNN << LOGSEC_NETWORK << "URL" << QUOTE_W_SPACE(reply->url().toString())
29 << "requested authentication and got it.";
30 }
31 else {
32 reply->setProperty("authentication-given", false);
33
34 // Authentication is required but this item does not contain it.
35 qWarningNN << LOGSEC_NETWORK << "Item" << QUOTE_W_SPACE(reply->url().toString())
36 << "requested authentication but username/password is not available.";
37 }
38 }