From b0da5ba755127ef5af202fbfc757a3c4dbd39092 Mon Sep 17 00:00:00 2001 From: David Rosca Date: Tue, 29 Sep 2015 11:45:39 +0200 Subject: [PATCH] Bring back NetworkManager class --- src/lib/app/browserwindow.cpp | 1 - src/lib/app/mainapplication.cpp | 5 +- src/lib/app/mainapplication.h | 5 +- src/lib/lib.pro | 6 +- src/lib/network/networkmanager.cpp | 11 +++- src/lib/network/networkmanager.h | 12 ++++ src/lib/network/networkmanagerproxy.cpp | 63 --------------------- src/lib/network/networkmanagerproxy.h | 47 --------------- src/lib/opensearch/searchenginesmanager.cpp | 1 + src/lib/tools/iconprovider.cpp | 1 + src/lib/webengine/webinspector.cpp | 1 + src/lib/webengine/webpage.cpp | 1 - 12 files changed, 32 insertions(+), 122 deletions(-) delete mode 100644 src/lib/network/networkmanagerproxy.cpp delete mode 100644 src/lib/network/networkmanagerproxy.h diff --git a/src/lib/app/browserwindow.cpp b/src/lib/app/browserwindow.cpp index 003b56e88..81377856d 100644 --- a/src/lib/app/browserwindow.cpp +++ b/src/lib/app/browserwindow.cpp @@ -34,7 +34,6 @@ #include "clearprivatedata.h" #include "sourceviewer.h" #include "autofill.h" -#include "networkmanagerproxy.h" #include "mainapplication.h" #include "checkboxdialog.h" #include "adblockmanager.h" diff --git a/src/lib/app/mainapplication.cpp b/src/lib/app/mainapplication.cpp index ca241a736..6bf224f92 100644 --- a/src/lib/app/mainapplication.cpp +++ b/src/lib/app/mainapplication.cpp @@ -34,6 +34,7 @@ #include "iconprovider.h" #include "browserwindow.h" #include "checkboxdialog.h" +#include "networkmanager.h" #include "profilemanager.h" #include "adblockmanager.h" #include "restoremanager.h" @@ -537,10 +538,10 @@ BrowsingLibrary* MainApplication::browsingLibrary() return m_browsingLibrary; } -QNetworkAccessManager* MainApplication::networkManager() +NetworkManager *MainApplication::networkManager() { if (!m_networkManager) { - m_networkManager = new QNetworkAccessManager(this); + m_networkManager = new NetworkManager(this); } return m_networkManager; } diff --git a/src/lib/app/mainapplication.h b/src/lib/app/mainapplication.h index 926b91265..dfa34865e 100644 --- a/src/lib/app/mainapplication.h +++ b/src/lib/app/mainapplication.h @@ -40,6 +40,7 @@ class AutoSaver; class ProxyStyle; class PluginProxy; class BrowserWindow; +class NetworkManager; class BrowsingLibrary; class DownloadManager; class UserAgentManager; @@ -99,7 +100,7 @@ public: PluginProxy* plugins(); BrowsingLibrary* browsingLibrary(); - QNetworkAccessManager* networkManager(); + NetworkManager* networkManager(); RestoreManager* restoreManager(); DownloadManager* downloadManager(); UserAgentManager* userAgentManager(); @@ -165,7 +166,7 @@ private: PluginProxy* m_plugins; BrowsingLibrary* m_browsingLibrary; - QNetworkAccessManager* m_networkManager; + NetworkManager* m_networkManager; RestoreManager* m_restoreManager; DownloadManager* m_downloadManager; UserAgentManager* m_userAgentManager; diff --git a/src/lib/lib.pro b/src/lib/lib.pro index 6e752e505..e65b92eb9 100644 --- a/src/lib/lib.pro +++ b/src/lib/lib.pro @@ -130,8 +130,7 @@ SOURCES += \ navigation/siteicon.cpp \ navigation/websearchbar.cpp \ #network/cabundleupdater.cpp \ - #network/networkmanager.cpp \ - network/networkmanagerproxy.cpp \ + network/networkmanager.cpp \ network/networkproxyfactory.cpp \ network/pac/pacmanager.cpp \ network/pac/proxyautoconfig.cpp \ @@ -325,8 +324,7 @@ HEADERS += \ navigation/siteicon.h \ navigation/websearchbar.h \ #network/cabundleupdater.h \ - #network/networkmanager.h \ - network/networkmanagerproxy.h \ + network/networkmanager.h \ network/networkproxyfactory.h \ network/pac/pacdatetime.h \ network/pac/pacmanager.h \ diff --git a/src/lib/network/networkmanager.cpp b/src/lib/network/networkmanager.cpp index 692b80358..36b8cbe29 100644 --- a/src/lib/network/networkmanager.cpp +++ b/src/lib/network/networkmanager.cpp @@ -15,6 +15,15 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . * ============================================================ */ +#include "networkmanager.h" + +NetworkManager::NetworkManager(QObject *parent) + : QNetworkAccessManager(parent) +{ +} + +#if QTWEBENGINE_DISABLED + #include "browserwindow.h" #include "autofill.h" #include "networkmanagerproxy.h" @@ -51,8 +60,6 @@ #include #include -#if QTWEBENGINE_DISABLED - static QString fileNameForCert(const QSslCertificate &cert) { QString certFileName = CertificateInfoWidget::certificateItemText(cert); diff --git a/src/lib/network/networkmanager.h b/src/lib/network/networkmanager.h index 3881a27cc..6375121df 100644 --- a/src/lib/network/networkmanager.h +++ b/src/lib/network/networkmanager.h @@ -18,6 +18,18 @@ #ifndef NETWORKMANAGER_H #define NETWORKMANAGER_H +#include + +#include "qzcommon.h" + +class QUPZILLA_EXPORT NetworkManager : public QNetworkAccessManager +{ + Q_OBJECT + +public: + explicit NetworkManager(QObject *parent = Q_NULLPTR); +}; + #if QTWEBENGINE_DISABLED #include diff --git a/src/lib/network/networkmanagerproxy.cpp b/src/lib/network/networkmanagerproxy.cpp deleted file mode 100644 index dfeeafbf8..000000000 --- a/src/lib/network/networkmanagerproxy.cpp +++ /dev/null @@ -1,63 +0,0 @@ -/* ============================================================ -* QupZilla - WebKit based browser -* Copyright (C) 2010-2014 David Rosca -* -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -* ============================================================ */ -#include "networkmanagerproxy.h" -#include "networkmanager.h" -#include "webpage.h" -#include "cookiejar.h" -#include "mainapplication.h" - -#include - -#if QTWEBENGINE_DISABLED - -NetworkManagerProxy::NetworkManagerProxy(QObject* parent) - : QNetworkAccessManager(parent) - , m_page(0) - , m_manager(0) -{ - setCookieJar(mApp->cookieJar()); - - // CookieJar is shared between NetworkManagers - mApp->cookieJar()->setParent(0); -} - -void NetworkManagerProxy::setPrimaryNetworkAccessManager(NetworkManager* manager) -{ - Q_ASSERT(manager); - m_manager = manager; - - connect(this, SIGNAL(authenticationRequired(QNetworkReply*,QAuthenticator*)), m_manager, SIGNAL(authenticationRequired(QNetworkReply*,QAuthenticator*))); - connect(this, SIGNAL(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*)), m_manager, SIGNAL(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*))); - connect(this, SIGNAL(finished(QNetworkReply*)), m_manager, SIGNAL(finished(QNetworkReply*))); - connect(this, SIGNAL(sslErrors(QNetworkReply*,QList)), m_manager, SIGNAL(sslErrors(QNetworkReply*,QList))); -} - -QNetworkReply* NetworkManagerProxy::createRequest(QNetworkAccessManager::Operation op, const QNetworkRequest &request, QIODevice* outgoingData) -{ - if (m_manager) { - QNetworkRequest pageRequest = request; - if (m_page) { - m_page->populateNetworkRequest(pageRequest); - } - return m_manager->createRequest(op, pageRequest, outgoingData); - } - - return QNetworkAccessManager::createRequest(op, request, outgoingData); -} - -#endif diff --git a/src/lib/network/networkmanagerproxy.h b/src/lib/network/networkmanagerproxy.h deleted file mode 100644 index a23085ca3..000000000 --- a/src/lib/network/networkmanagerproxy.h +++ /dev/null @@ -1,47 +0,0 @@ -/* ============================================================ -* QupZilla - WebKit based browser -* Copyright (C) 2010-2014 David Rosca -* -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -* ============================================================ */ -#ifndef NETWORKMANAGERPROXY_H -#define NETWORKMANAGERPROXY_H - -#if QTWEBENGINE_DISABLED - -#include - -#include "qzcommon.h" - -class WebPage; -class NetworkManager; - -class QUPZILLA_EXPORT NetworkManagerProxy : public QNetworkAccessManager -{ -public: - explicit NetworkManagerProxy(QObject* parent = 0); - - void setPage(WebPage* page) { m_page = page; } - void setPrimaryNetworkAccessManager(NetworkManager* manager); - - QNetworkReply* createRequest(QNetworkAccessManager::Operation op, const QNetworkRequest &request, QIODevice* outgoingData); - -private: - WebPage* m_page; - NetworkManager* m_manager; -}; - -#endif - -#endif // NETWORKMANAGERPROXY_H diff --git a/src/lib/opensearch/searchenginesmanager.cpp b/src/lib/opensearch/searchenginesmanager.cpp index 5ad937c3a..4732406a5 100644 --- a/src/lib/opensearch/searchenginesmanager.cpp +++ b/src/lib/opensearch/searchenginesmanager.cpp @@ -18,6 +18,7 @@ #include "searchenginesmanager.h" #include "searchenginesdialog.h" #include "editsearchengine.h" +#include "networkmanager.h" #include "iconprovider.h" #include "mainapplication.h" #include "opensearchreader.h" diff --git a/src/lib/tools/iconprovider.cpp b/src/lib/tools/iconprovider.cpp index 63eb3d0a0..fb7474b84 100644 --- a/src/lib/tools/iconprovider.cpp +++ b/src/lib/tools/iconprovider.cpp @@ -17,6 +17,7 @@ * ============================================================ */ #include "iconprovider.h" #include "mainapplication.h" +#include "networkmanager.h" #include "followredirectreply.h" #include "sqldatabase.h" #include "autosaver.h" diff --git a/src/lib/webengine/webinspector.cpp b/src/lib/webengine/webinspector.cpp index 9a0f00838..cbc9f86c6 100644 --- a/src/lib/webengine/webinspector.cpp +++ b/src/lib/webengine/webinspector.cpp @@ -17,6 +17,7 @@ * ============================================================ */ #include "webinspector.h" #include "mainapplication.h" +#include "networkmanager.h" #include #include diff --git a/src/lib/webengine/webpage.cpp b/src/lib/webengine/webpage.cpp index 8ec6c209f..a6031cbc9 100644 --- a/src/lib/webengine/webpage.cpp +++ b/src/lib/webengine/webpage.cpp @@ -28,7 +28,6 @@ #include "autofill.h" #include "popupwebview.h" #include "popupwindow.h" -#include "networkmanagerproxy.h" #include "adblockicon.h" #include "adblockmanager.h" #include "iconprovider.h"