summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMontel Laurent <montel@kde.org>2016-11-04 12:21:16 (GMT)
committerMontel Laurent <montel@kde.org>2016-11-04 13:03:36 (GMT)
commitb80c3450a29aa5b874470d7e4a8624ae4eac942d (patch)
treeedcd1fc234de8203ec2b8dae7b1f033c995bd4de
parent44bff4e0b28280c8b6ecbb7e5d8373c25d2d71ae (diff)
Add specific mailcheckphishingurljob
-rw-r--r--messageviewer/src/CMakeLists.txt1
-rw-r--r--messageviewer/src/viewer/mailcheckphishingurljob.cpp58
-rw-r--r--messageviewer/src/viewer/mailcheckphishingurljob.h53
-rw-r--r--messageviewer/src/viewer/viewer_p.cpp12
-rw-r--r--messageviewer/src/viewer/viewer_p.h2
5 files changed, 119 insertions, 7 deletions
diff --git a/messageviewer/src/CMakeLists.txt b/messageviewer/src/CMakeLists.txt
index 0546ec7..b9210ad 100644
--- a/messageviewer/src/CMakeLists.txt
+++ b/messageviewer/src/CMakeLists.txt
@@ -69,6 +69,7 @@ set(libmessageviewer_viewer_SRCS
viewer/urlhandlermanager.cpp
viewer/mimeparttree/mimeparttreeview.cpp
viewer/mimeparttree/mimetreemodel.cpp
+ viewer/mailcheckphishingurljob.cpp
)
set(libmessageviewer_widgets_SRCS
diff --git a/messageviewer/src/viewer/mailcheckphishingurljob.cpp b/messageviewer/src/viewer/mailcheckphishingurljob.cpp
new file mode 100644
index 0000000..f0b46de
--- /dev/null
+++ b/messageviewer/src/viewer/mailcheckphishingurljob.cpp
@@ -0,0 +1,58 @@
+/*
+ Copyright (C) 2016 Laurent Montel <montel@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "mailcheckphishingurljob.h"
+
+using namespace MessageViewer;
+
+MailCheckPhishingUrlJob::MailCheckPhishingUrlJob(QObject *parent)
+ : QObject(parent)
+{
+ mCheckPhishingJob = new WebEngineViewer::CheckPhishingUrlJob;
+ connect(mCheckPhishingJob.data(), &WebEngineViewer::CheckPhishingUrlJob::result, this, &MailCheckPhishingUrlJob::slotCheckPhishingUrlDone);
+}
+
+MailCheckPhishingUrlJob::~MailCheckPhishingUrlJob()
+{
+ if (mCheckPhishingJob) {
+ disconnect(mCheckPhishingJob.data(), &WebEngineViewer::CheckPhishingUrlJob::result, this, &MailCheckPhishingUrlJob::slotCheckPhishingUrlDone);
+ mCheckPhishingJob = Q_NULLPTR;
+ }
+}
+
+void MailCheckPhishingUrlJob::start()
+{
+ mCheckPhishingJob->start();
+}
+
+void MailCheckPhishingUrlJob::setItem(const Akonadi::Item &item)
+{
+ mItem = item;
+}
+
+void MailCheckPhishingUrlJob::setUrl(const QUrl &url)
+{
+ mCheckPhishingJob->setUrl(url);
+}
+
+void MailCheckPhishingUrlJob::slotCheckPhishingUrlDone(WebEngineViewer::CheckPhishingUrlJob::UrlStatus status, const QUrl &url)
+{
+ Q_EMIT result(status, url, mItem);
+ deleteLater();
+}
diff --git a/messageviewer/src/viewer/mailcheckphishingurljob.h b/messageviewer/src/viewer/mailcheckphishingurljob.h
new file mode 100644
index 0000000..45198ad
--- /dev/null
+++ b/messageviewer/src/viewer/mailcheckphishingurljob.h
@@ -0,0 +1,53 @@
+/*
+ Copyright (C) 2016 Laurent Montel <montel@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef MAILCHECKPHISHINGURLJOB_H
+#define MAILCHECKPHISHINGURLJOB_H
+
+#include <QObject>
+#include <AkonadiCore/Item>
+#include <WebEngineViewer/CheckPhishingUrlJob>
+#include <QPointer>
+
+namespace MessageViewer
+{
+class MailCheckPhishingUrlJob : public QObject
+{
+ Q_OBJECT
+public:
+ explicit MailCheckPhishingUrlJob(QObject *parent);
+ ~MailCheckPhishingUrlJob();
+
+ void start();
+
+ void setItem(const Akonadi::Item &item);
+ void setUrl(const QUrl &url);
+
+Q_SIGNALS:
+ void result(WebEngineViewer::CheckPhishingUrlJob::UrlStatus status, const QUrl &url, const Akonadi::Item &item);
+
+private Q_SLOTS:
+ void slotCheckPhishingUrlDone(WebEngineViewer::CheckPhishingUrlJob::UrlStatus status, const QUrl &url);
+
+private:
+ Akonadi::Item mItem;
+ QPointer<WebEngineViewer::CheckPhishingUrlJob> mCheckPhishingJob;
+};
+}
+#endif // MAILCHECKPHISHINGURLJOB_H
diff --git a/messageviewer/src/viewer/viewer_p.cpp b/messageviewer/src/viewer/viewer_p.cpp
index 3d9c67c..f8aee0a 100644
--- a/messageviewer/src/viewer/viewer_p.cpp
+++ b/messageviewer/src/viewer/viewer_p.cpp
@@ -40,6 +40,7 @@
#include "job/attachmenteditjob.h"
#include "job/modifymessagedisplayformatjob.h"
#include "config-messageviewer.h"
+#include "mailcheckphishingurljob.h"
#include "viewerplugins/viewerplugintoolmanager.h"
#include <WebEngineViewer/WebEnginePrintMessageBox>
#include <KContacts/VCardConverter>
@@ -1996,10 +1997,10 @@ void ViewerPrivate::slotUrlOpen(const QUrl &url)
return;
}
#if 0
- //TODO add check url
- WebEngineViewer::CheckPhishingUrlJob *job = new WebEngineViewer::CheckPhishingUrlJob(this);
- connect(job, &CheckPhishingUrlJob::result, this, &ViewerPrivate::slotCheckUrl);
+ MessageViewer::MailCheckPhishingUrlJob *job = new MessageViewer::MailCheckPhishingUrlJob(this);
+ connect(job, &MessageViewer::MailCheckPhishingUrlJob::result, this, &ViewerPrivate::slotCheckUrl);
job->setUrl(mClickedUrl);
+ job->setItem(mMessageItem);
job->start();
#else
Q_EMIT urlClicked(mMessageItem, mClickedUrl);
@@ -2007,7 +2008,7 @@ void ViewerPrivate::slotUrlOpen(const QUrl &url)
}
-void ViewerPrivate::slotCheckUrl(WebEngineViewer::CheckPhishingUrlJob::UrlStatus status, const QUrl &url)
+void ViewerPrivate::slotCheckUrl(WebEngineViewer::CheckPhishingUrlJob::UrlStatus status, const QUrl &url, const Akonadi::Item &item)
{
switch (status) {
case WebEngineViewer::CheckPhishingUrlJob::BrokenNetwork:
@@ -2027,8 +2028,7 @@ void ViewerPrivate::slotCheckUrl(WebEngineViewer::CheckPhishingUrlJob::UrlStatus
qCWarning(MESSAGEVIEWER_LOG) << "WebEngineViewer::CheckPhishingUrlJob unknown error ";
break;
}
- //TODO fix me.
- Q_EMIT urlClicked(mMessageItem, url);
+ Q_EMIT urlClicked(item, url);
}
void ViewerPrivate::slotUrlOn(const QString &link)
diff --git a/messageviewer/src/viewer/viewer_p.h b/messageviewer/src/viewer/viewer_p.h
index 10cd1ea..46790f9 100644
--- a/messageviewer/src/viewer/viewer_p.h
+++ b/messageviewer/src/viewer/viewer_p.h
@@ -474,7 +474,7 @@ private Q_SLOTS:
void slotHandlePagePrinted(bool result);
void slotLoadStarted();
void slotDisableEmoticon();
- void slotCheckUrl(WebEngineViewer::CheckPhishingUrlJob::UrlStatus status, const QUrl &url);
+ void slotCheckUrl(WebEngineViewer::CheckPhishingUrlJob::UrlStatus status, const QUrl &url, const Akonadi::Item &item);
public Q_SLOTS:
/** An URL has been activate with a click. */
void slotUrlOpen(const QUrl &url = QUrl());