Commit daa530f4 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Simplify code

parent b94e51bc
Pipeline #55563 canceled with stage
......@@ -22,6 +22,9 @@ BlockMailTrackingUrlInterceptor::~BlockMailTrackingUrlInterceptor()
bool BlockMailTrackingUrlInterceptor::interceptRequest(QWebEngineUrlRequestInfo &info)
{
if (!mEnabledMailTrackingInterceptor) {
return false;
}
const QUrl urlRequestUrl(info.requestUrl());
for (int i = 0, total = mBackList.size(); i < total; ++i) {
const auto blackListinfo{mBackList.at(i)};
......@@ -60,3 +63,13 @@ void BlockMailTrackingUrlInterceptor::initializeList()
{QStringLiteral("ToutApp"), QStringLiteral("go.toutapp.com"), QStringLiteral("http://toutapp.com")},
{QStringLiteral("Outreach"), QStringLiteral("app.outreach.io"), QStringLiteral("http://outreach.io")}};
}
bool BlockMailTrackingUrlInterceptor::enabledMailTrackingInterceptor() const
{
return mEnabledMailTrackingInterceptor;
}
void BlockMailTrackingUrlInterceptor::setEnabledMailTrackingInterceptor(bool enabledMailTrackingInterceptor)
{
mEnabledMailTrackingInterceptor = enabledMailTrackingInterceptor;
}
......@@ -37,12 +37,16 @@ public:
~BlockMailTrackingUrlInterceptor() override;
Q_REQUIRED_RESULT bool interceptRequest(QWebEngineUrlRequestInfo &info) override;
Q_REQUIRED_RESULT bool enabledMailTrackingInterceptor() const;
void setEnabledMailTrackingInterceptor(bool enabledMailTrackingInterceptor);
Q_SIGNALS:
void trackingFound(const MessageViewer::BlockMailTrackingUrlInterceptor::MailTrackerBlackList &);
private:
void initializeList();
QVector<MailTrackerBlackList> mBackList;
bool mEnabledMailTrackingInterceptor = false;
};
}
Q_DECLARE_TYPEINFO(MessageViewer::BlockMailTrackingUrlInterceptor::MailTrackerBlackList, Q_MOVABLE_TYPE);
......
......@@ -92,6 +92,7 @@ MailWebEngineView::MailWebEngineView(KActionCollection *ac, QWidget *parent)
d->mBlockMailTrackingUrl = new MessageViewer::BlockMailTrackingUrlInterceptor(this);
connect(d->mBlockMailTrackingUrl, &BlockMailTrackingUrlInterceptor::trackingFound, this, &MailWebEngineView::mailTrackingFound);
d->mNetworkAccessManager->addInterceptor(d->mBlockMailTrackingUrl);
setFocusPolicy(Qt::WheelFocus);
connect(d->mPageEngine, &MailWebEnginePage::urlClicked, this, &MailWebEngineView::openUrl);
......@@ -105,11 +106,7 @@ MailWebEngineView::~MailWebEngineView()
void MailWebEngineView::readConfig()
{
if (MessageViewer::MessageViewerSettings::self()->mailTrackingUrlEnabled()) {
d->mNetworkAccessManager->addInterceptor(d->mBlockMailTrackingUrl);
} else {
d->mNetworkAccessManager->removeInterceptor(d->mBlockMailTrackingUrl);
}
d->mBlockMailTrackingUrl->setEnabledMailTrackingInterceptor(MessageViewer::MessageViewerSettings::self()->mailTrackingUrlEnabled());
}
void MailWebEngineView::setLinkHovered(const QUrl &url)
......
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