mirror of
https://invent.kde.org/network/falkon.git
synced 2024-11-11 09:32:12 +01:00
Plugins: New method in API (createRequest in network manager)
This commit is contained in:
parent
f9b38c4376
commit
7fee7053d4
|
@ -193,7 +193,7 @@ void AdBlockManager::load()
|
|||
continue;
|
||||
}
|
||||
|
||||
const QString absolutePath = adblockDir.absoluteFilePath(fileName);
|
||||
const QString &absolutePath = adblockDir.absoluteFilePath(fileName);
|
||||
QFile file(absolutePath);
|
||||
if (!file.open(QFile::ReadOnly)) {
|
||||
continue;
|
||||
|
|
|
@ -69,7 +69,7 @@ public slots:
|
|||
AdBlockDialog* showDialog();
|
||||
|
||||
private:
|
||||
bool canBeBlocked(const QUrl &url) const;
|
||||
inline bool canBeBlocked(const QUrl &url) const;
|
||||
static AdBlockManager* s_adBlockManager;
|
||||
|
||||
bool m_loaded;
|
||||
|
|
|
@ -347,7 +347,7 @@ QNetworkReply* NetworkManager::createRequest(QNetworkAccessManager::Operation op
|
|||
QNetworkRequest req = request;
|
||||
QNetworkReply* reply = 0;
|
||||
|
||||
//SchemeHandlers
|
||||
// SchemeHandlers
|
||||
if (m_schemeHandlers.contains(req.url().scheme())) {
|
||||
reply = m_schemeHandlers[req.url().scheme()]->createRequest(op, req, outgoingData);
|
||||
if (reply) {
|
||||
|
@ -355,6 +355,12 @@ QNetworkReply* NetworkManager::createRequest(QNetworkAccessManager::Operation op
|
|||
}
|
||||
}
|
||||
|
||||
// Plugins
|
||||
reply = mApp->plugins()->createRequest(op, request, outgoingData);
|
||||
if (reply) {
|
||||
return reply;
|
||||
}
|
||||
|
||||
if (m_doNotTrack) {
|
||||
req.setRawHeader("DNT", QByteArray("1"));
|
||||
}
|
||||
|
|
|
@ -81,6 +81,8 @@ public:
|
|||
|
||||
virtual bool keyPress(const Qz::ObjectName &type, QObject* obj, QKeyEvent* event) { Q_UNUSED(type) Q_UNUSED(obj) Q_UNUSED(event) return false; }
|
||||
virtual bool keyRelease(const Qz::ObjectName &type, QObject* obj, QKeyEvent* event) { Q_UNUSED(type) Q_UNUSED(obj) Q_UNUSED(event) return false; }
|
||||
|
||||
virtual QNetworkReply* createRequest(QNetworkAccessManager::Operation op, const QNetworkRequest &request, QIODevice* outgoingData) { Q_UNUSED(op) Q_UNUSED(request) Q_UNUSED(outgoingData) return 0; }
|
||||
};
|
||||
|
||||
Q_DECLARE_INTERFACE(PluginInterface, "QupZilla.Browser.PluginInterface/1.1")
|
||||
|
|
|
@ -191,6 +191,18 @@ bool PluginProxy::processKeyRelease(const Qz::ObjectName &type, QObject* obj, QK
|
|||
return accepted;
|
||||
}
|
||||
|
||||
QNetworkReply* PluginProxy::createRequest(QNetworkAccessManager::Operation op, const QNetworkRequest &request, QIODevice* outgoingData)
|
||||
{
|
||||
foreach(PluginInterface * iPlugin, m_loadedPlugins) {
|
||||
QNetworkReply* reply = iPlugin->createRequest(op, request, outgoingData);
|
||||
if (reply) {
|
||||
return reply;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void PluginProxy::emitWebPageCreated(WebPage* page)
|
||||
{
|
||||
emit webPageCreated(page);
|
||||
|
|
|
@ -49,6 +49,8 @@ public:
|
|||
bool processKeyPress(const Qz::ObjectName &type, QObject* obj, QKeyEvent* event);
|
||||
bool processKeyRelease(const Qz::ObjectName &type, QObject* obj, QKeyEvent* event);
|
||||
|
||||
QNetworkReply* createRequest(QNetworkAccessManager::Operation op, const QNetworkRequest &request, QIODevice* outgoingData);
|
||||
|
||||
void emitWebPageCreated(WebPage* page);
|
||||
void emitWebPageDeleted(WebPage* page);
|
||||
|
||||
|
|
|
@ -33,6 +33,11 @@ QNetworkReply* FollowRedirectReply::reply() const
|
|||
return m_reply;
|
||||
}
|
||||
|
||||
QUrl FollowRedirectReply::originalUrl() const
|
||||
{
|
||||
return m_reply->request().url();
|
||||
}
|
||||
|
||||
QUrl FollowRedirectReply::url() const
|
||||
{
|
||||
return m_reply->url();
|
||||
|
|
|
@ -36,6 +36,7 @@ public:
|
|||
~FollowRedirectReply();
|
||||
|
||||
QNetworkReply* reply() const;
|
||||
QUrl originalUrl() const;
|
||||
QUrl url() const;
|
||||
|
||||
QNetworkReply::NetworkError error() const;
|
||||
|
|
|
@ -53,11 +53,13 @@ QPixmap qz_pixmapFromByteArray(const QByteArray &data)
|
|||
QByteArray qz_readAllFileContents(const QString &filename)
|
||||
{
|
||||
QFile file(filename);
|
||||
file.open(QFile::ReadOnly);
|
||||
QByteArray a = file.readAll();
|
||||
file.close();
|
||||
if (file.open(QFile::ReadOnly)) {
|
||||
QByteArray a = file.readAll();
|
||||
file.close();
|
||||
return a;
|
||||
}
|
||||
|
||||
return a;
|
||||
return QByteArray();
|
||||
}
|
||||
|
||||
void qz_centerWidgetOnScreen(QWidget* w)
|
||||
|
@ -176,23 +178,24 @@ QString qz_urlEncodeQueryString(const QUrl &url)
|
|||
return returnString;
|
||||
}
|
||||
|
||||
QString qz_ensureUniqueFilename(const QString &pathToFile)
|
||||
QString qz_ensureUniqueFilename(const QString &name, const QString &appendFormat)
|
||||
{
|
||||
if (!QFile::exists(pathToFile)) {
|
||||
return pathToFile;
|
||||
if (!QFile::exists(name)) {
|
||||
return name;
|
||||
}
|
||||
|
||||
QString tmpFileName = pathToFile;
|
||||
QString tmpFileName = name;
|
||||
int i = 1;
|
||||
while (QFile::exists(tmpFileName)) {
|
||||
tmpFileName = pathToFile;
|
||||
tmpFileName = name;
|
||||
int index = tmpFileName.lastIndexOf(".");
|
||||
|
||||
QString appendString = appendFormat.arg(i);
|
||||
if (index == -1) {
|
||||
tmpFileName.append("(" + QString::number(i) + ")");
|
||||
tmpFileName.append(appendString);
|
||||
}
|
||||
else {
|
||||
tmpFileName = tmpFileName.left(index) + "(" + QString::number(i) + ")" + tmpFileName.mid(index);
|
||||
tmpFileName = tmpFileName.left(index) + appendString + tmpFileName.mid(index);
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#define GLOBALFUNCTIONS_H
|
||||
|
||||
#include <QList>
|
||||
#include <QString>
|
||||
|
||||
#include "qz_namespace.h"
|
||||
|
||||
|
@ -43,7 +44,7 @@ QString QT_QUPZILLA_EXPORT qz_samePartOfStrings(const QString &one, const QStrin
|
|||
QUrl QT_QUPZILLA_EXPORT qz_makeRelativeUrl(const QUrl &baseUrl, const QUrl &rUrl);
|
||||
QString QT_QUPZILLA_EXPORT qz_urlEncodeQueryString(const QUrl &url);
|
||||
|
||||
QString QT_QUPZILLA_EXPORT qz_ensureUniqueFilename(const QString &name);
|
||||
QString QT_QUPZILLA_EXPORT qz_ensureUniqueFilename(const QString &name, const QString &appendFormat = QString("(%1)"));
|
||||
QString QT_QUPZILLA_EXPORT qz_getFileNameFromUrl(const QUrl &url);
|
||||
QString QT_QUPZILLA_EXPORT qz_filterCharsFromFilename(const QString &name);
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user