Commit 7950fdd4 authored by Laurent Montel's avatar Laurent Montel 😁

Start to implement adblock lib

parent e633679d
......@@ -7,6 +7,7 @@ add_library(messageviewer_adblockplugin MODULE ${messageviewer_webengineurlinter
target_link_libraries(messageviewer_adblockplugin
KF5::MessageViewer
Qt5::WebEngine Qt5::WebEngineWidgets
)
install(TARGETS messageviewer_adblockplugin DESTINATION ${PLUGIN_INSTALL_DIR}/messageviewer)
......
......@@ -16,6 +16,7 @@
*/
#include "adblockinterceptorinterface.h"
#include <QtWebEngineCore/qwebengineurlrequestinfo.h>
AdblockInterceptorInterface::AdblockInterceptorInterface(QObject *parent)
: MessageViewer::MailNetworkPluginUrlInterceptorInterface(parent)
......@@ -30,5 +31,9 @@ AdblockInterceptorInterface::~AdblockInterceptorInterface()
void AdblockInterceptorInterface::interceptRequest(QWebEngineUrlRequestInfo &info)
{
//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
}
/*
Copyright (c) 2016 Montel Laurent <montel@kde.org>
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License, version 2, as
published by the Free Software Foundation.
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, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "adblockmanagertest.h"
#include <QTest>
AdblockManagerTest::AdblockManagerTest(QObject *parent)
: QObject(parent)
{
}
AdblockManagerTest::~AdblockManagerTest()
{
}
QTEST_MAIN(AdblockManagerTest)
/*
Copyright (c) 2016 Montel Laurent <montel@kde.org>
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License, version 2, as
published by the Free Software Foundation.
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, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef ADBLOCKMANAGERTEST_H
#define ADBLOCKMANAGERTEST_H
#include <QObject>
class AdblockManagerTest : public QObject
{
Q_OBJECT
public:
explicit AdblockManagerTest(QObject *parent = Q_NULLPTR);
~AdblockManagerTest();
};
#endif // ADBLOCKMANAGERTEST_H
/*
Copyright (c) 2016 Montel Laurent <montel@kde.org>
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License, version 2, as
published by the Free Software Foundation.
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, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "adblockmanager.h"
using namespace AdBlock;
AdblockManager::AdblockManager(QObject *parent)
: QObject(parent),
mEnabled(false)
{
}
AdblockManager::~AdblockManager()
{
}
void AdblockManager::reloadConfig()
{
//TODO
}
bool AdblockManager::isEnabled() const
{
return mEnabled;
}
bool AdblockManager::interceptRequest(const QString &urlEncoded, const QString &host, const&scheme)
{
//TODO
return false;
}
/*
Copyright (c) 2016 Montel Laurent <montel@kde.org>
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License, version 2, as
published by the Free Software Foundation.
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, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef ADBLOCKMANAGER_H
#define ADBLOCKMANAGER_H
#include <QObject>
namespace AdBlock
{
class AdblockManager : public QObject
{
Q_OBJECT
public:
explicit AdblockManager(QObject *parent = Q_NULLPTR);
~AdblockManager();
void reloadConfig();
bool isEnabled() const;
bool interceptRequest(const QString &urlEncoded, const QString &host, const &scheme);
private:
bool mEnabled;
};
}
#endif // ADBLOCKMANAGER_H
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