summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMontel Laurent <montel@kde.org>2016-11-15 12:42:50 (GMT)
committerMontel Laurent <montel@kde.org>2016-11-15 12:42:50 (GMT)
commit530c8afa7057724c8bea88d4737a51df4406ec8d (patch)
treefc87b92463a9c2014e12ae31a9b77e057a615860
parent4a66bf75eec7fa7d0829dbf9ca5d7c7175d5b023 (diff)
Generate requests
-rw-r--r--webengineviewer/src/checkphishingurl/checkphishingurljob.cpp1
-rw-r--r--webengineviewer/src/checkphishingurl/createphishingurldatabasejob.cpp58
-rw-r--r--webengineviewer/src/checkphishingurl/createphishingurldatabasejob.h1
-rw-r--r--webengineviewer/src/checkphishingurl/tests/createphishingurldatabasegui.h2
4 files changed, 60 insertions, 2 deletions
diff --git a/webengineviewer/src/checkphishingurl/checkphishingurljob.cpp b/webengineviewer/src/checkphishingurl/checkphishingurljob.cpp
index c0d3f73..d5b0c9d 100644
--- a/webengineviewer/src/checkphishingurl/checkphishingurljob.cpp
+++ b/webengineviewer/src/checkphishingurl/checkphishingurljob.cpp
@@ -24,6 +24,7 @@
#include <QJsonDocument>
#include <webengineviewer_debug.h>
+//#define DEBUG_JSON_REQUEST 1
using namespace WebEngineViewer;
CheckPhishingUrlJob::CheckPhishingUrlJob(QObject *parent)
diff --git a/webengineviewer/src/checkphishingurl/createphishingurldatabasejob.cpp b/webengineviewer/src/checkphishingurl/createphishingurldatabasejob.cpp
index 8ddaaea..6ded519 100644
--- a/webengineviewer/src/checkphishingurl/createphishingurldatabasejob.cpp
+++ b/webengineviewer/src/checkphishingurl/createphishingurldatabasejob.cpp
@@ -21,8 +21,9 @@
#include "createphishingurldatabasejob.h"
#include "webengineviewer_debug.h"
+#include <QJsonDocument>
#include <QNetworkReply>
-
+//#define DEBUG_JSON_REQUEST 1
using namespace WebEngineViewer;
CreatePhishingUrlDataBaseJob::CreatePhishingUrlDataBaseJob(QObject *parent)
@@ -50,6 +51,61 @@ void CreatePhishingUrlDataBaseJob::start()
}
+QByteArray CreatePhishingUrlDataBaseJob::jsonRequest() const
+{
+#if 0
+ {
+ "client": {
+ "clientId": "yourcompanyname",
+ "clientVersion": "1.5.2"
+ },
+ "listUpdateRequests": [{
+ "threatType": "MALWARE",
+ "platformType": "WINDOWS",
+ "threatEntryType": "URL",
+ "state": "Gg4IBBADIgYQgBAiAQEoAQ==",
+ "constraints": {
+ "maxUpdateEntries": 2048,
+ "maxDatabaseEntries": 4096,
+ "region": "US",
+ "supportedCompressions": ["RAW"]
+ }
+ }]
+ }
+#endif
+ QVariantMap clientMap;
+ QVariantMap map;
+
+ clientMap.insert(QStringLiteral("clientId"), QStringLiteral("KDE"));
+ clientMap.insert(QStringLiteral("clientVersion"), QStringLiteral("5.4.0")); //FIXME
+ map.insert(QStringLiteral("client"), clientMap);
+
+ QVariantMap threatMap;
+ const QVariantList platformList = { QStringLiteral("WINDOWS") };
+ threatMap.insert(QStringLiteral("platformTypes"), platformList);
+ const QVariantList threatTypesList = { QStringLiteral("MALWARE") };
+ threatMap.insert(QStringLiteral("threatTypes"), threatTypesList);
+ const QVariantList threatEntryTypesList = { QStringLiteral("URL") };
+ threatMap.insert(QStringLiteral("threatEntryTypes"), threatEntryTypesList);
+
+ //Define state when we want to define update database. Empty is full.
+ threatMap.insert(QStringLiteral("state"), QString());
+
+ //TODO define contraints
+
+
+ map.insert(QStringLiteral("listUpdateRequests"), threatMap);
+
+ const QJsonDocument postData = QJsonDocument::fromVariant(map);
+#ifdef DEBUG_JSON_REQUEST
+ const QByteArray baPostData = postData.toJson();
+#else
+ const QByteArray baPostData = postData.toJson(QJsonDocument::Compact);
+#endif
+ return baPostData;
+}
+
+
void CreatePhishingUrlDataBaseJob::setDataBaseDownloadNeeded(CreatePhishingUrlDataBaseJob::DataBaseDownload type)
{
mDataBaseDownloadNeeded = type;
diff --git a/webengineviewer/src/checkphishingurl/createphishingurldatabasejob.h b/webengineviewer/src/checkphishingurl/createphishingurldatabasejob.h
index 0d3af63..45163ca 100644
--- a/webengineviewer/src/checkphishingurl/createphishingurldatabasejob.h
+++ b/webengineviewer/src/checkphishingurl/createphishingurldatabasejob.h
@@ -45,6 +45,7 @@ public:
void setDataBaseDownloadNeeded(WebEngineViewer::CreatePhishingUrlDataBaseJob::DataBaseDownload type);
+ QByteArray jsonRequest() const;
private:
void slotCheckUrlFinished(QNetworkReply *reply);
void slotSslErrors(QNetworkReply *reply, const QList<QSslError> &error);
diff --git a/webengineviewer/src/checkphishingurl/tests/createphishingurldatabasegui.h b/webengineviewer/src/checkphishingurl/tests/createphishingurldatabasegui.h
index 39b7a82..32d4c65 100644
--- a/webengineviewer/src/checkphishingurl/tests/createphishingurldatabasegui.h
+++ b/webengineviewer/src/checkphishingurl/tests/createphishingurldatabasegui.h
@@ -21,7 +21,7 @@
#define CREATEPHISHINGURLDATABASEGUI_H
#include <QWidget>
-class QLineEdit;
+#include "../createphishingurldatabasejob.h"
class QTextEdit;
class CreatePhisingUrlDataBaseGuioi : public QWidget
{