blockmailtrackingurlinterceptor.h 1.48 KB
Newer Older
1
/*
Laurent Montel's avatar
Laurent Montel committed
2
   SPDX-FileCopyrightText: 2017-2021 Laurent Montel <montel@kde.org>
3

4
   SPDX-License-Identifier: LGPL-2.0-or-later
5
6
*/

Laurent Montel's avatar
Laurent Montel committed
7
#pragma once
8

Laurent Montel's avatar
Laurent Montel committed
9
#include "messageviewer_export.h"
Laurent Montel's avatar
Laurent Montel committed
10
#include <QVector>
Laurent Montel's avatar
Laurent Montel committed
11
12
13
#include <WebEngineViewer/NetworkPluginUrlInterceptorInterface>
namespace MessageViewer
{
14
15
16
17
/**
 * @brief The BlockMailTrackingUrlInterceptor class
 * @author Laurent Montel <montel@kde.org>
 */
Laurent Montel's avatar
Laurent Montel committed
18
class MESSAGEVIEWER_EXPORT BlockMailTrackingUrlInterceptor : public WebEngineViewer::NetworkPluginUrlInterceptorInterface
19
20
21
{
    Q_OBJECT
public:
Laurent Montel's avatar
Laurent Montel committed
22
    struct MailTrackerBlackList {
23
        MailTrackerBlackList() = default;
Laurent Montel's avatar
Laurent Montel committed
24
        MailTrackerBlackList(const QString &company, const QString &pattern, const QString &url)
Laurent Montel's avatar
Laurent Montel committed
25
26
27
            : mCompanyName(company)
            , mCompanyUrl(url)
            , mPattern(pattern)
Laurent Montel's avatar
Laurent Montel committed
28
29
        {
        }
Laurent Montel's avatar
Laurent Montel committed
30

Laurent Montel's avatar
Laurent Montel committed
31
32
33
34
35
        QString mCompanyName;
        QString mCompanyUrl;
        QString mPattern;
    };

36
    explicit BlockMailTrackingUrlInterceptor(QObject *parent = nullptr);
Laurent Montel's avatar
Laurent Montel committed
37
    ~BlockMailTrackingUrlInterceptor() override;
38
    Q_REQUIRED_RESULT bool interceptRequest(QWebEngineUrlRequestInfo &info) override;
39
40

Q_SIGNALS:
Laurent Montel's avatar
Laurent Montel committed
41
    void trackingFound(const MessageViewer::BlockMailTrackingUrlInterceptor::MailTrackerBlackList &);
Laurent Montel's avatar
Laurent Montel committed
42

Laurent Montel's avatar
Laurent Montel committed
43
44
45
private:
    void initializeList();
    QVector<MailTrackerBlackList> mBackList;
46
47
};
}
Laurent Montel's avatar
Laurent Montel committed
48
Q_DECLARE_TYPEINFO(MessageViewer::BlockMailTrackingUrlInterceptor::MailTrackerBlackList, Q_MOVABLE_TYPE);
49
Q_DECLARE_METATYPE(MessageViewer::BlockMailTrackingUrlInterceptor::MailTrackerBlackList)