Commit 7981442e authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Returns actions from interceptor plugin

parent 6a8753bd
...@@ -57,7 +57,8 @@ public: ...@@ -57,7 +57,8 @@ public:
: mScamDetection(Q_NULLPTR), : mScamDetection(Q_NULLPTR),
mWebViewAccessKey(Q_NULLPTR), mWebViewAccessKey(Q_NULLPTR),
mExternalReference(Q_NULLPTR), mExternalReference(Q_NULLPTR),
mPageEngine(Q_NULLPTR) mPageEngine(Q_NULLPTR),
mNetworkAccessManager(Q_NULLPTR)
{ {
} }
...@@ -65,6 +66,7 @@ public: ...@@ -65,6 +66,7 @@ public:
MailWebEngineAccessKey *mWebViewAccessKey; MailWebEngineAccessKey *mWebViewAccessKey;
MessageViewer::LoadExternalReferencesUrlInterceptor *mExternalReference; MessageViewer::LoadExternalReferencesUrlInterceptor *mExternalReference;
MailWebEnginePage *mPageEngine; MailWebEnginePage *mPageEngine;
MessageViewer::NetworkAccessManagerWebEngine *mNetworkAccessManager;
}; };
MailWebEngineView::MailWebEngineView(KActionCollection *ac, QWidget *parent) MailWebEngineView::MailWebEngineView(KActionCollection *ac, QWidget *parent)
...@@ -79,9 +81,9 @@ MailWebEngineView::MailWebEngineView(KActionCollection *ac, QWidget *parent) ...@@ -79,9 +81,9 @@ MailWebEngineView::MailWebEngineView(KActionCollection *ac, QWidget *parent)
connect(d->mScamDetection, &ScamDetectionWebEngine::messageMayBeAScam, this, &MailWebEngineView::messageMayBeAScam); connect(d->mScamDetection, &ScamDetectionWebEngine::messageMayBeAScam, this, &MailWebEngineView::messageMayBeAScam);
connect(d->mWebViewAccessKey, &MailWebEngineAccessKey::openUrl, this, &MailWebEngineView::openUrl); connect(d->mWebViewAccessKey, &MailWebEngineAccessKey::openUrl, this, &MailWebEngineView::openUrl);
MessageViewer::NetworkAccessManagerWebEngine *networkAccessManager = new MessageViewer::NetworkAccessManagerWebEngine(this, ac, this); d->mNetworkAccessManager = new MessageViewer::NetworkAccessManagerWebEngine(this, ac, this);
d->mExternalReference = new MessageViewer::LoadExternalReferencesUrlInterceptor(this); d->mExternalReference = new MessageViewer::LoadExternalReferencesUrlInterceptor(this);
networkAccessManager->addInterceptor(d->mExternalReference); d->mNetworkAccessManager->addInterceptor(d->mExternalReference);
d->mPageEngine = new MailWebEnginePage(this); d->mPageEngine = new MailWebEnginePage(this);
setPage(d->mPageEngine); setPage(d->mPageEngine);
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include "webengine/urlinterceptor/networkurlinterceptormanager.h" #include "webengine/urlinterceptor/networkurlinterceptormanager.h"
#include "webengine/urlinterceptor/networkurlinterceptor.h" #include "webengine/urlinterceptor/networkurlinterceptor.h"
#include <QWebEngineProfile> #include <QWebEngineProfile>
#include <MessageViewer/NetworkPluginUrlInterceptorInterface>
using namespace MessageViewer; using namespace MessageViewer;
...@@ -58,3 +59,12 @@ void NetworkAccessManagerWebEngine::addInterceptor(MessageViewer::NetworkPluginU ...@@ -58,3 +59,12 @@ void NetworkAccessManagerWebEngine::addInterceptor(MessageViewer::NetworkPluginU
{ {
d->mNetworkUrlInterceptor->addInterceptor(interceptor); d->mNetworkUrlInterceptor->addInterceptor(interceptor);
} }
QList<QAction *> NetworkAccessManagerWebEngine::actions() const
{
QList<QAction *> actions;
Q_FOREACH (MessageViewer::NetworkPluginUrlInterceptorInterface *interface, d->mManager->interfaceList()) {
actions.append(interface->actions());
}
return actions;
}
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include "messageviewer_export.h" #include "messageviewer_export.h"
class KActionCollection; class KActionCollection;
class QWebEngineView; class QWebEngineView;
class QAction;
namespace MessageViewer namespace MessageViewer
{ {
class NetworkPluginUrlInterceptorInterface; class NetworkPluginUrlInterceptorInterface;
...@@ -33,6 +34,7 @@ public: ...@@ -33,6 +34,7 @@ public:
explicit NetworkAccessManagerWebEngine(QWebEngineView *webEngine, KActionCollection *ac, QObject *parent = Q_NULLPTR); explicit NetworkAccessManagerWebEngine(QWebEngineView *webEngine, KActionCollection *ac, QObject *parent = Q_NULLPTR);
~NetworkAccessManagerWebEngine(); ~NetworkAccessManagerWebEngine();
void addInterceptor(MessageViewer::NetworkPluginUrlInterceptorInterface *interceptor); void addInterceptor(MessageViewer::NetworkPluginUrlInterceptorInterface *interceptor);
QList<QAction *> actions() const;
private: private:
NetworkAccessManagerWebEnginePrivate *const d; NetworkAccessManagerWebEnginePrivate *const d;
}; };
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment