Commit 7b656c38 authored by Laurent Montel's avatar Laurent Montel 😁

Continue to implement adblock plugin

parent ea6b34ee
......@@ -8,6 +8,7 @@ add_library(messageviewer_adblockplugin MODULE ${messageviewer_webengineurlinter
target_link_libraries(messageviewer_adblockplugin
KF5::MessageViewer
Qt5::WebEngine Qt5::WebEngineWidgets
adblocklibprivate
)
install(TARGETS messageviewer_adblockplugin DESTINATION ${PLUGIN_INSTALL_DIR}/messageviewer)
......
......@@ -17,11 +17,12 @@
#include "adblockinterceptorinterface.h"
#include <QtWebEngineCore/qwebengineurlrequestinfo.h>
#include <lib/adblockmanager.h>
AdblockInterceptorInterface::AdblockInterceptorInterface(QObject *parent)
: MessageViewer::MailNetworkPluginUrlInterceptorInterface(parent)
{
mAdblockManager = new AdBlock::AdblockManager(this);
}
AdblockInterceptorInterface::~AdblockInterceptorInterface()
......@@ -31,9 +32,12 @@ AdblockInterceptorInterface::~AdblockInterceptorInterface()
void AdblockInterceptorInterface::interceptRequest(QWebEngineUrlRequestInfo &info)
{
if (!mAdblockManager->isEnabled()) {
return;
}
if (mAdblockManager->interceptRequest(info.requestUrl())) {
info.block(true);
}
//TODO enable/disable
const QString urlString = info.requestUrl().toString().toLower();
const QString host = info.requestUrl().host().toLower();
const QString scheme = info.requestUrl().scheme().toLower();
//TODO
}
......@@ -19,7 +19,10 @@
#define ADBLOCKINTERCEPTORINTERFACE_H
#include <MessageViewer/MailNetworkPluginUrlInterceptorInterface>
namespace AdBlock
{
class AdblockManager;
}
class AdblockInterceptorInterface : public MessageViewer::MailNetworkPluginUrlInterceptorInterface
{
Q_OBJECT
......@@ -28,6 +31,8 @@ public:
~AdblockInterceptorInterface();
void interceptRequest(QWebEngineUrlRequestInfo &info) Q_DECL_OVERRIDE;
private:
AdBlock::AdblockManager *mAdblockManager;
};
#endif // ADBLOCKINTERCEPTORINTERFACE_H
ecm_add_test(adblockmanagertest.cpp ../lib/adblockmanager.cpp
ecm_add_test(adblockmanagertest.cpp
TEST_NAME adblockmanagertest
NAME_PREFIX "messageviewer-urlinterceptor-"
LINK_LIBRARIES Qt5::Test Qt5::Widgets
LINK_LIBRARIES Qt5::Test Qt5::Widgets adblocklibprivate
)
......@@ -17,6 +17,7 @@
#include "adblockmanager.h"
#include <QUrl>
using namespace AdBlock;
......@@ -44,6 +45,10 @@ bool AdblockManager::isEnabled() const
bool AdblockManager::interceptRequest(const QUrl &url)
{
const QString urlString = url.toString().toLower();
const QString host = url.host().toLower();
const QString scheme = url.scheme().toLower();
//TODO
return false;
}
......@@ -19,10 +19,10 @@
#define ADBLOCKMANAGER_H
#include <QObject>
#include "adblocklib_export.h"
namespace AdBlock
{
class AdblockManager : public QObject
class ADBLOCKLIB_EXPORT AdblockManager : public QObject
{
Q_OBJECT
public:
......
Markdown is supported
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