summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMontel Laurent <montel@kde.org>2016-11-08 06:55:48 (GMT)
committerMontel Laurent <montel@kde.org>2016-11-08 06:55:48 (GMT)
commitcc7c23837beba4a7a6f2caf8c02584e5462c9837 (patch)
treeb97bd840005d17aa933016e7a08d9de853cfdd3a
parent5fb54f0da8ef1bbe2210b59a61b203a098e06191 (diff)
Parse answer
-rw-r--r--webengineviewer/src/checkphishingurl/checkphishingurljob.cpp19
1 files changed, 15 insertions, 4 deletions
diff --git a/webengineviewer/src/checkphishingurl/checkphishingurljob.cpp b/webengineviewer/src/checkphishingurl/checkphishingurljob.cpp
index 1394965..9c04fd2 100644
--- a/webengineviewer/src/checkphishingurl/checkphishingurljob.cpp
+++ b/webengineviewer/src/checkphishingurl/checkphishingurljob.cpp
@@ -51,18 +51,29 @@ QString CheckPhishingUrlJob::secretKey() const
void CheckPhishingUrlJob::parse(const QByteArray &replyStr)
{
QJsonDocument document = QJsonDocument::fromJson(replyStr);
- qDebug() << " info : " << document.toJson();
if (document.isNull()) {
Q_EMIT result(WebEngineViewer::CheckPhishingUrlJob::Unknown, mUrl);
} else {
const QVariantMap answer = document.toVariant().toMap();
if (answer.isEmpty()) {
Q_EMIT result(WebEngineViewer::CheckPhishingUrlJob::Ok, mUrl);
+ return;
} else {
- const QVariantMap info = answer.value(QStringLiteral("matches")).toMap();
- qDebug() << " INFO "<<info;
+ const QVariantList info = answer.value(QStringLiteral("matches")).toList();
+ if (info.count() == 1) {
+ QVariantMap map = info.at(0).toMap();
+ if (map[QStringLiteral("threatType")] == QStringLiteral("MALWARE")) {
+ QVariantMap urlMap = map[QStringLiteral("threat")].toMap();
+ if (urlMap.count() == 1) {
+ if (urlMap[QStringLiteral("url")].toString() == mUrl.toString()) {
+ Q_EMIT result(WebEngineViewer::CheckPhishingUrlJob::MalWare, mUrl);
+ return;
+ }
+ }
+ }
+ }
+ Q_EMIT result(WebEngineViewer::CheckPhishingUrlJob::Unknown, mUrl);
}
- qDebug() << " answer" <<answer;
}
}