summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMontel Laurent <montel@kde.org>2016-11-08 08:14:50 (GMT)
committerMontel Laurent <montel@kde.org>2016-11-08 08:14:50 (GMT)
commit90a674d19c631441366cdc84b17bbe06f88e5461 (patch)
treeda6ebade50948c69e68033f5b7a5201ba77dd6c8
parent9e8beaad47a696a6b5b7ef7860227575adb9d21e (diff)
Activate check phishing url
-rw-r--r--messageviewer/src/viewer/urlhandlermanager.cpp6
-rw-r--r--messageviewer/src/viewer/viewer_p.cpp23
-rw-r--r--messageviewer/src/viewer/viewer_p.h3
-rw-r--r--webengineviewer/src/checkphishingurl/checkphishingurljob.cpp14
-rw-r--r--webengineviewer/src/checkphishingurl/checkphishingurljob.h3
5 files changed, 30 insertions, 19 deletions
diff --git a/messageviewer/src/viewer/urlhandlermanager.cpp b/messageviewer/src/viewer/urlhandlermanager.cpp
index 6c4ed17..bf4f0c2 100644
--- a/messageviewer/src/viewer/urlhandlermanager.cpp
+++ b/messageviewer/src/viewer/urlhandlermanager.cpp
@@ -1104,11 +1104,7 @@ bool KRunURLHandler::handleClick(const QUrl &url, ViewerPrivate *w) const
return true;
}
}
- if (!MessageViewer::Util::handleUrlWithQDesktopServices(url)) {
- KRun *runner = new KRun(url, w->viewer()); // will delete itself
- runner->setRunExecutables(false);
- }
-
+ w->checkPhishingUrl();
return true;
} else {
return false;
diff --git a/messageviewer/src/viewer/viewer_p.cpp b/messageviewer/src/viewer/viewer_p.cpp
index eb076a3..6ec0083 100644
--- a/messageviewer/src/viewer/viewer_p.cpp
+++ b/messageviewer/src/viewer/viewer_p.cpp
@@ -2009,24 +2009,33 @@ void ViewerPrivate::slotUrlOpen(const QUrl &url)
if (URLHandlerManager::instance()->handleClick(mClickedUrl, this)) {
return;
}
-#if 0
- if (MessageViewer::MessageViewerSettings::self()->checkPhishingUrl()) {
+ Q_EMIT urlClicked(mMessageItem, mClickedUrl);
+}
+
+void ViewerPrivate::checkPhishingUrl()
+{
+ if (MessageViewer::MessageViewerSettings::self()->checkPhishingUrl() && (mClickedUrl.scheme() != QLatin1String("mailto"))) {
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);
+ executeRunner(mClickedUrl);
}
-#else
- Q_EMIT urlClicked(mMessageItem, mClickedUrl);
-#endif
+}
+void ViewerPrivate::executeRunner(const QUrl &url)
+{
+ if (!MessageViewer::Util::handleUrlWithQDesktopServices(url)) {
+ KRun *runner = new KRun(url, viewer()); // will delete itself
+ runner->setRunExecutables(false);
+ }
}
void ViewerPrivate::slotCheckUrl(WebEngineViewer::CheckPhishingUrlJob::UrlStatus status, const QUrl &url, const Akonadi::Item &item)
{
+ Q_UNUSED(item);
switch (status) {
case WebEngineViewer::CheckPhishingUrlJob::BrokenNetwork:
KMessageBox::error(mMainWindow, i18n("The network is broken."), i18n("Check Phishing Url"));
@@ -2045,7 +2054,7 @@ void ViewerPrivate::slotCheckUrl(WebEngineViewer::CheckPhishingUrlJob::UrlStatus
qCWarning(MESSAGEVIEWER_LOG) << "WebEngineViewer::CheckPhishingUrlJob unknown error ";
break;
}
- Q_EMIT urlClicked(item, url);
+ executeRunner(mClickedUrl);
}
void ViewerPrivate::slotUrlOn(const QString &link)
diff --git a/messageviewer/src/viewer/viewer_p.h b/messageviewer/src/viewer/viewer_p.h
index 21414e8..239064c 100644
--- a/messageviewer/src/viewer/viewer_p.h
+++ b/messageviewer/src/viewer/viewer_p.h
@@ -429,6 +429,9 @@ public:
void setPrintElementBackground(bool printElementBackground);
bool showEmoticons() const;
+ void checkPhishingUrl();
+ void executeRunner(const QUrl &url);
+
private Q_SLOTS:
void slotActivatePlugin(MessageViewer::ViewerPluginInterface *interface);
diff --git a/webengineviewer/src/checkphishingurl/checkphishingurljob.cpp b/webengineviewer/src/checkphishingurl/checkphishingurljob.cpp
index 30283b4..331a125 100644
--- a/webengineviewer/src/checkphishingurl/checkphishingurljob.cpp
+++ b/webengineviewer/src/checkphishingurl/checkphishingurljob.cpp
@@ -32,20 +32,22 @@ CheckPhishingUrlJob::CheckPhishingUrlJob(QObject *parent)
{
mNetworkAccessManager = new QNetworkAccessManager(this);
connect(mNetworkAccessManager, &QNetworkAccessManager::finished, this, &CheckPhishingUrlJob::slotCheckUrlFinished);
+ connect(mNetworkAccessManager, &QNetworkAccessManager::sslErrors, this, &CheckPhishingUrlJob::slotSslErrors);
}
CheckPhishingUrlJob::~CheckPhishingUrlJob()
{
}
-QString CheckPhishingUrlJob::apiKey() const
+void CheckPhishingUrlJob::slotSslErrors(QNetworkReply *reply, const QList<QSslError> &error)
{
- return QStringLiteral("AIzaSyBS62pXATjabbH2RM_jO2EzDg1mTMHlnyo");
+ qCDebug(WEBENGINEVIEWER_LOG) << " void StorageServiceAbstractJob::slotSslErrors(QNetworkReply *reply, const QList<QSslError> &error)" << error.count();
+ reply->ignoreSslErrors(error);
}
-QString CheckPhishingUrlJob::secretKey() const
+QString CheckPhishingUrlJob::apiKey() const
{
- return QStringLiteral("mdT1DjzohxN3npUUzkENT0gO");
+ return QStringLiteral("AIzaSyBS62pXATjabbH2RM_jO2EzDg1mTMHlnyo");
}
void CheckPhishingUrlJob::parse(const QByteArray &replyStr)
@@ -165,9 +167,9 @@ void CheckPhishingUrlJob::start()
void CheckPhishingUrlJob::slotError(QNetworkReply::NetworkError error)
{
QNetworkReply *reply = qobject_cast<QNetworkReply *>(sender());
- qCDebug(WEBENGINEVIEWER_LOG)<<" error "<<error << " error string : "<< reply->errorString();
+ qDebug()<<" error "<<error << " error string : "<< reply->errorString();
reply->deleteLater();
- Q_EMIT result(WebEngineViewer::CheckPhishingUrlJob::Unknown, mUrl);
+ //Q_EMIT result(WebEngineViewer::CheckPhishingUrlJob::Unknown, mUrl);
deleteLater();
}
diff --git a/webengineviewer/src/checkphishingurl/checkphishingurljob.h b/webengineviewer/src/checkphishingurl/checkphishingurljob.h
index 5d965b5..9eefd39 100644
--- a/webengineviewer/src/checkphishingurl/checkphishingurljob.h
+++ b/webengineviewer/src/checkphishingurl/checkphishingurljob.h
@@ -54,9 +54,10 @@ Q_SIGNALS:
void result(WebEngineViewer::CheckPhishingUrlJob::UrlStatus status, const QUrl &url);
void debugJson(const QByteArray &ba);
+private Q_SLOTS:
+ void slotSslErrors(QNetworkReply *reply, const QList<QSslError> &error);
private:
QString apiKey() const;
- QString secretKey() const;
void slotError(QNetworkReply::NetworkError error);
void slotCheckUrlFinished(QNetworkReply *reply);
QUrl mUrl;