1
mirror of https://invent.kde.org/network/falkon.git synced 2024-12-20 18:56:34 +01:00

Bring back NetworkManager class

This commit is contained in:
David Rosca 2015-09-29 11:45:39 +02:00
parent f3fda02820
commit b0da5ba755
12 changed files with 32 additions and 122 deletions

View File

@ -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"

View File

@ -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;
}

View File

@ -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;

View File

@ -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 \

View File

@ -15,6 +15,15 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* ============================================================ */
#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 <QAuthenticator>
#include <QDirIterator>
#if QTWEBENGINE_DISABLED
static QString fileNameForCert(const QSslCertificate &cert)
{
QString certFileName = CertificateInfoWidget::certificateItemText(cert);

View File

@ -18,6 +18,18 @@
#ifndef NETWORKMANAGER_H
#define NETWORKMANAGER_H
#include <QNetworkAccessManager>
#include "qzcommon.h"
class QUPZILLA_EXPORT NetworkManager : public QNetworkAccessManager
{
Q_OBJECT
public:
explicit NetworkManager(QObject *parent = Q_NULLPTR);
};
#if QTWEBENGINE_DISABLED
#include <QSslError>

View File

@ -1,63 +0,0 @@
/* ============================================================
* QupZilla - WebKit based browser
* Copyright (C) 2010-2014 David Rosca <nowrep@gmail.com>
*
* 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 <http://www.gnu.org/licenses/>.
* ============================================================ */
#include "networkmanagerproxy.h"
#include "networkmanager.h"
#include "webpage.h"
#include "cookiejar.h"
#include "mainapplication.h"
#include <QNetworkRequest>
#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<QSslError>)), m_manager, SIGNAL(sslErrors(QNetworkReply*,QList<QSslError>)));
}
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

View File

@ -1,47 +0,0 @@
/* ============================================================
* QupZilla - WebKit based browser
* Copyright (C) 2010-2014 David Rosca <nowrep@gmail.com>
*
* 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 <http://www.gnu.org/licenses/>.
* ============================================================ */
#ifndef NETWORKMANAGERPROXY_H
#define NETWORKMANAGERPROXY_H
#if QTWEBENGINE_DISABLED
#include <QNetworkAccessManager>
#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

View File

@ -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"

View File

@ -17,6 +17,7 @@
* ============================================================ */
#include "iconprovider.h"
#include "mainapplication.h"
#include "networkmanager.h"
#include "followredirectreply.h"
#include "sqldatabase.h"
#include "autosaver.h"

View File

@ -17,6 +17,7 @@
* ============================================================ */
#include "webinspector.h"
#include "mainapplication.h"
#include "networkmanager.h"
#include <QJsonArray>
#include <QJsonObject>

View File

@ -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"