diff --git a/src/core/feedsmodelstandardfeed.cpp b/src/core/feedsmodelstandardfeed.cpp index 8cd6ec3f9..a046d70ee 100755 --- a/src/core/feedsmodelstandardfeed.cpp +++ b/src/core/feedsmodelstandardfeed.cpp @@ -106,9 +106,10 @@ void FeedsModelStandardFeed::update() { // TODO: Provide download time-measures debugging // outputs here. - QNetworkReply::NetworkError download_result = NetworkFactory::downloadFile(url(), - download_timeout, - feed_contents); + QNetworkReply::NetworkError download_result = NetworkFactory::downloadFeedFile(url(), + download_timeout, + feed_contents, + this); if (download_result != QNetworkReply::NoError) { qWarning("Error during fetching of new messages for feed '%s' (id %d).", diff --git a/src/core/networkfactory.cpp b/src/core/networkfactory.cpp index c781b63eb..95c2778e4 100644 --- a/src/core/networkfactory.cpp +++ b/src/core/networkfactory.cpp @@ -9,9 +9,10 @@ NetworkFactory::NetworkFactory() { } -QNetworkReply::NetworkError NetworkFactory::downloadFile(const QString &url, - int timeout, - QByteArray &output) { +QNetworkReply::NetworkError NetworkFactory::downloadFeedFile(const QString &url, + int timeout, + QByteArray &output, + FeedsModelStandardFeed *feed) { // Original asynchronous behavior of QNetworkAccessManager // is replaced by synchronous behavior in order to make // process of downloading of a file easier to understand. @@ -22,6 +23,11 @@ QNetworkReply::NetworkError NetworkFactory::downloadFile(const QString &url, QTimer timer; QNetworkRequest request; QNetworkReply *reply; + QObject originatingObject; + + // Set feed as originating object. + originatingObject.setProperty("feed", QVariant::fromValue((void*) feed)); + request.setOriginatingObject(&originatingObject); // Set url for this reques. request.setUrl(url); diff --git a/src/core/networkfactory.h b/src/core/networkfactory.h index 524b754be..edc04a1f1 100644 --- a/src/core/networkfactory.h +++ b/src/core/networkfactory.h @@ -4,6 +4,8 @@ #include +class FeedsModelStandardFeed; + class NetworkFactory { private: // Constructor. @@ -12,9 +14,10 @@ class NetworkFactory { public: // Performs SYNCHRONOUS download of file with given URL // and given timeout. - static QNetworkReply::NetworkError downloadFile(const QString &url, - int timeout, - QByteArray &output); + static QNetworkReply::NetworkError downloadFeedFile(const QString &url, + int timeout, + QByteArray &output, + FeedsModelStandardFeed *feed); }; #endif // NETWORKFACTORY_H diff --git a/src/core/silentnetworkaccessmanager.cpp b/src/core/silentnetworkaccessmanager.cpp index 0e6fd62f7..ff7b8d335 100644 --- a/src/core/silentnetworkaccessmanager.cpp +++ b/src/core/silentnetworkaccessmanager.cpp @@ -1,6 +1,9 @@ #include "core/silentnetworkaccessmanager.h" +#include "core/feedsmodelstandardfeed.h" + #include +#include SilentNetworkAccessManager::SilentNetworkAccessManager(QObject *parent) @@ -16,7 +19,7 @@ SilentNetworkAccessManager::~SilentNetworkAccessManager() { } void SilentNetworkAccessManager::onSslErrors(QNetworkReply *reply, - const QList &error) { + const QList &error) { qDebug("SSL errors for '%s': '%s' (code %d).", qPrintable(reply->url().toString()), qPrintable(reply->errorString()), @@ -27,8 +30,17 @@ void SilentNetworkAccessManager::onSslErrors(QNetworkReply *reply, void SilentNetworkAccessManager::onAuthenticationRequired(QNetworkReply *reply, QAuthenticator *authenticator) { - Q_UNUSED(authenticator) + FeedsModelStandardFeed *feed = static_cast(reply->request().originatingObject()->property("feed").value()); - qDebug("Autorization problems for '%s'.", + // TODO: tady do autenticatoru dosadit udaje z feedu + // pokud je obsahuje + // a taky promyslet zda to delat takhle vubec, ale funguje + // to + /* + *authenticator->setUser("rotter.martinos"); + *authenticator->setPassword("gorottin0151"); + */ + + qDebug("Authentication problems for '%s'.", qPrintable(reply->url().toString())); }