diff --git a/src/gui/formsettings.cpp b/src/gui/formsettings.cpp index ba93e44a8..329b651ca 100755 --- a/src/gui/formsettings.cpp +++ b/src/gui/formsettings.cpp @@ -457,6 +457,7 @@ void FormSettings::saveProxy() { settings->setValue(GROUP(Proxy), Proxy::Port, m_ui->m_spinProxyPort->value()); // Reload settings for all network access managers. + SilentNetworkAccessManager::instance()->loadSettings(); WebBrowserNetworkAccessManager::instance()->loadSettings(); } diff --git a/src/network-web/downloader.cpp b/src/network-web/downloader.cpp index ad0154946..ec41afcf4 100755 --- a/src/network-web/downloader.cpp +++ b/src/network-web/downloader.cpp @@ -31,7 +31,6 @@ Downloader::Downloader(QObject *parent) m_timer->setSingleShot(true); connect(m_timer, SIGNAL(timeout()), this, SLOT(timeout())); - //connect(m_downloadManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(finished(QNetworkReply*))); } Downloader::~Downloader() { diff --git a/src/network-web/downloadmanager.cpp b/src/network-web/downloadmanager.cpp index e219d6180..3e4c412da 100644 --- a/src/network-web/downloadmanager.cpp +++ b/src/network-web/downloadmanager.cpp @@ -24,7 +24,6 @@ #include "gui/tabwidget.h" #include "gui/messagebox.h" #include "network-web/silentnetworkaccessmanager.h" -#include "network-web/webbrowsernetworkaccessmanager.h" #include @@ -437,7 +436,7 @@ void DownloadItem::finished() { DownloadManager::DownloadManager(QWidget *parent) : TabContent(parent), m_ui(new Ui::DownloadManager), m_autoSaver(new AutoSaver(this)), m_model(new DownloadModel(this)), - m_networkManager(WebBrowserNetworkAccessManager::instance()), m_iconProvider(0), m_removePolicy(Never) { + m_networkManager(SilentNetworkAccessManager::instance()), m_iconProvider(0), m_removePolicy(Never) { m_ui->setupUi(this); m_ui->m_viewDownloads->setShowGrid(false); m_ui->m_viewDownloads->verticalHeader()->hide(); diff --git a/src/network-web/googlesuggest.cpp b/src/network-web/googlesuggest.cpp index fc6fb61e5..b21756f67 100755 --- a/src/network-web/googlesuggest.cpp +++ b/src/network-web/googlesuggest.cpp @@ -46,7 +46,7 @@ #include "network-web/googlesuggest.h" #include "definitions/definitions.h" -#include "network-web/webbrowsernetworkaccessmanager.h" +#include "network-web/silentnetworkaccessmanager.h" #include "gui/locationlineedit.h" #include @@ -171,7 +171,7 @@ void GoogleSuggest::autoSuggest() { QString str = QUrl::toPercentEncoding(editor->text()); QString url = QString(GOOGLE_SUGGEST_URL).arg(str); - connect(WebBrowserNetworkAccessManager::instance()->get(QNetworkRequest(QString(url))), SIGNAL(finished()), + connect(SilentNetworkAccessManager::instance()->get(QNetworkRequest(QString(url))), SIGNAL(finished()), this, SLOT(handleNetworkData())); } diff --git a/src/network-web/silentnetworkaccessmanager.cpp b/src/network-web/silentnetworkaccessmanager.cpp index 88e30d91a..d7acc324f 100644 --- a/src/network-web/silentnetworkaccessmanager.cpp +++ b/src/network-web/silentnetworkaccessmanager.cpp @@ -23,6 +23,8 @@ #include +QPointer SilentNetworkAccessManager::s_instance; + SilentNetworkAccessManager::SilentNetworkAccessManager(QObject *parent) : BaseNetworkAccessManager(parent) { connect(this, SIGNAL(authenticationRequired(QNetworkReply*,QAuthenticator*)), @@ -30,6 +32,15 @@ SilentNetworkAccessManager::SilentNetworkAccessManager(QObject *parent) } SilentNetworkAccessManager::~SilentNetworkAccessManager() { + qDebug("Destroying SilentNetworkAccessManager instance."); +} + +SilentNetworkAccessManager *SilentNetworkAccessManager::instance() { + if (s_instance.isNull()) { + s_instance = new SilentNetworkAccessManager(qApp); + } + + return s_instance; } void SilentNetworkAccessManager::onAuthenticationRequired(QNetworkReply *reply, QAuthenticator *authenticator) { diff --git a/src/network-web/silentnetworkaccessmanager.h b/src/network-web/silentnetworkaccessmanager.h index 85150757e..660fb9462 100644 --- a/src/network-web/silentnetworkaccessmanager.h +++ b/src/network-web/silentnetworkaccessmanager.h @@ -20,8 +20,11 @@ #include "network-web/basenetworkaccessmanager.h" +#include + // Network manager used for more communication for feeds. +// This network manager does not provide any GUI interaction options. class SilentNetworkAccessManager : public BaseNetworkAccessManager { Q_OBJECT @@ -30,9 +33,15 @@ class SilentNetworkAccessManager : public BaseNetworkAccessManager { explicit SilentNetworkAccessManager(QObject *parent = 0); virtual ~SilentNetworkAccessManager(); + // Returns pointer to global silent network manager + static SilentNetworkAccessManager *instance(); + protected slots: // This cannot do any GUI stuff. void onAuthenticationRequired(QNetworkReply * reply, QAuthenticator *authenticator); + + private: + static QPointer s_instance; }; #endif // SILENTNETWORKACCESSMANAGER_H diff --git a/src/network-web/webbrowsernetworkaccessmanager.cpp b/src/network-web/webbrowsernetworkaccessmanager.cpp index 6d9cc02d0..760dc8b4c 100755 --- a/src/network-web/webbrowsernetworkaccessmanager.cpp +++ b/src/network-web/webbrowsernetworkaccessmanager.cpp @@ -31,6 +31,7 @@ WebBrowserNetworkAccessManager::WebBrowserNetworkAccessManager(QObject *parent) } WebBrowserNetworkAccessManager::~WebBrowserNetworkAccessManager() { + qDebug("Destroying WebBrowserNetworkAccessManager instance."); } void WebBrowserNetworkAccessManager::onAuthenticationRequired(QNetworkReply *reply, QAuthenticator *authenticator) { diff --git a/src/network-web/webbrowsernetworkaccessmanager.h b/src/network-web/webbrowsernetworkaccessmanager.h index 8f7f41c1a..8f6099bce 100644 --- a/src/network-web/webbrowsernetworkaccessmanager.h +++ b/src/network-web/webbrowsernetworkaccessmanager.h @@ -37,7 +37,7 @@ class WebBrowserNetworkAccessManager : public BaseNetworkAccessManager { static WebBrowserNetworkAccessManager *instance(); protected slots: - void onAuthenticationRequired(QNetworkReply * reply, QAuthenticator *authenticator); + void onAuthenticationRequired(QNetworkReply *reply, QAuthenticator *authenticator); private: static QPointer s_instance;