summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMontel Laurent <montel@kde.org>2016-10-31 06:33:28 (GMT)
committerMontel Laurent <montel@kde.org>2016-10-31 06:33:50 (GMT)
commitace882f213f3319fb66891124664741454a4df30 (patch)
tree5bcb8b0fa0c7e4056cdfbbbe2017e87d52c8447d
parent350beeb1611d8c72702db396e0628dd12e42a0a9 (diff)
Continue to implement check url job
-rw-r--r--messageviewer/src/checkphishingurl/checkphishingurljob.cpp18
-rw-r--r--messageviewer/src/checkphishingurl/checkphishingurljob.h4
2 files changed, 20 insertions, 2 deletions
diff --git a/messageviewer/src/checkphishingurl/checkphishingurljob.cpp b/messageviewer/src/checkphishingurl/checkphishingurljob.cpp
index e6a6bbc..c25cde3 100644
--- a/messageviewer/src/checkphishingurl/checkphishingurljob.cpp
+++ b/messageviewer/src/checkphishingurl/checkphishingurljob.cpp
@@ -58,7 +58,15 @@ void CheckPhishingUrlJob::start()
Q_EMIT result(MessageViewer::CheckPhishingUrlJob::Unknown);
deleteLater();
} else {
- //TODO
+ QNetworkRequest request(QUrl(QStringLiteral("https://safebrowsing.googleapis.com/v4/threatMatches:find")));
+ //FIXME ?
+ request.setHeader(QNetworkRequest::ContentTypeHeader, QStringLiteral("application/x-www-form-urlencoded"));
+
+ QUrlQuery postData;
+ postData.addQueryItem(QStringLiteral("key"), QString() /*TODO*/);
+
+ QNetworkReply *reply = mNetworkAccessManager->post(request, postData.query(QUrl::FullyEncoded).toUtf8());
+ connect(reply, static_cast<void (QNetworkReply::*)(QNetworkReply::NetworkError)>(&QNetworkReply::error), this, &CheckPhishingUrlJob::slotError);
}
} else {
Q_EMIT result(MessageViewer::CheckPhishingUrlJob::Unknown);
@@ -66,6 +74,14 @@ void CheckPhishingUrlJob::start()
}
}
+void CheckPhishingUrlJob::slotError(QNetworkReply::NetworkError error)
+{
+ QNetworkReply *reply = qobject_cast<QNetworkReply *>(sender());
+ //mErrorMsg = reply->errorString();
+ //FIXME
+ deleteLater();
+}
+
bool CheckPhishingUrlJob::canStart() const
{
if (!mNetworkConfigurationManager->isOnline()) {
diff --git a/messageviewer/src/checkphishingurl/checkphishingurljob.h b/messageviewer/src/checkphishingurl/checkphishingurljob.h
index 4689fcc..966d3e3 100644
--- a/messageviewer/src/checkphishingurl/checkphishingurljob.h
+++ b/messageviewer/src/checkphishingurl/checkphishingurljob.h
@@ -22,11 +22,12 @@
#include <QObject>
#include <QUrl>
+#include <QNetworkReply>
#include "messageviewer_export.h"
class QNetworkAccessManager;
-class QNetworkReply;
class QNetworkConfigurationManager;
namespace MessageViewer {
+/* https://developers.google.com/safe-browsing/v4/lookup-api */
class MESSAGEVIEWER_EXPORT CheckPhishingUrlJob : public QObject
{
Q_OBJECT
@@ -50,6 +51,7 @@ Q_SIGNALS:
void result(MessageViewer::CheckPhishingUrlJob::UrlStatus status);
private:
+ void slotError(QNetworkReply::NetworkError error);
void slotCheckUrlFinished(QNetworkReply *reply);
QUrl mUrl;
QNetworkAccessManager *mNetworkAccessManager;