summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMontel Laurent <montel@kde.org>2016-11-16 07:03:44 (GMT)
committerMontel Laurent <montel@kde.org>2016-11-16 07:03:44 (GMT)
commit1b465059b1d843b5df92db0cca117e73be390d16 (patch)
tree51d2d86f6fddd55b147d83ff8146b17001c85eb5
parent3baeca18c5c029a5be865a2ce9fe0949de6972ee (diff)
Emit signal when we finished to parsing data
-rw-r--r--webengineviewer/src/checkphishingurl/createphishingurldatabasejob.cpp13
-rw-r--r--webengineviewer/src/checkphishingurl/createphishingurldatabasejob.h19
2 files changed, 24 insertions, 8 deletions
diff --git a/webengineviewer/src/checkphishingurl/createphishingurldatabasejob.cpp b/webengineviewer/src/checkphishingurl/createphishingurldatabasejob.cpp
index 66523f3..6a09f17 100644
--- a/webengineviewer/src/checkphishingurl/createphishingurldatabasejob.cpp
+++ b/webengineviewer/src/checkphishingurl/createphishingurldatabasejob.cpp
@@ -56,7 +56,7 @@ void CreatePhishingUrlDataBaseJob::slotSslErrors(QNetworkReply *reply, const QLi
void CreatePhishingUrlDataBaseJob::start()
{
if (!PimCommon::NetworkManager::self()->networkConfigureManager()->isOnline()) {
- Q_EMIT finished();
+ Q_EMIT finished(UnknownError);
deleteLater();
} else {
QUrl safeUrl = QUrl(QStringLiteral("https://safebrowsing.googleapis.com/v4/threatListUpdates:fetch"));
@@ -161,19 +161,17 @@ void CreatePhishingUrlDataBaseJob::slotDownloadDataBaseFinished(QNetworkReply *r
Q_EMIT debugJsonResult(returnValue);
parseResult(returnValue);
reply->deleteLater();
- //TODO deleteLater ?
}
void CreatePhishingUrlDataBaseJob::parseResult(const QByteArray &value)
{
QJsonDocument document = QJsonDocument::fromJson(value);
if (document.isNull()) {
- //TODO
- deleteLater();
+ Q_EMIT finished(InvalidData);
} else {
const QVariantMap answer = document.toVariant().toMap();
if (answer.isEmpty()) {
- //TODO
+ Q_EMIT finished(InvalidData);
} else {
QMapIterator<QString, QVariant> i(answer);
while (i.hasNext()) {
@@ -204,9 +202,7 @@ void CreatePhishingUrlDataBaseJob::parseResult(const QByteArray &value)
}
} else if (mapKey == QLatin1String("newClientState")) {
qDebug() << " newClientState " << mapIt.value().toString();
-
} else if (mapKey == QLatin1String("platformType")) {
-
qDebug() << " platformType " << mapIt.value().toString();
} else if (mapKey == QLatin1String("responseType")) {
qDebug() << " responseType " << mapIt.value().toString();
@@ -227,6 +223,9 @@ void CreatePhishingUrlDataBaseJob::parseResult(const QByteArray &value)
qDebug() <<" map key unknown " << i.key();
}
}
+ Q_EMIT finished(ValidData);
+
}
}
+ deleteLater();
}
diff --git a/webengineviewer/src/checkphishingurl/createphishingurldatabasejob.h b/webengineviewer/src/checkphishingurl/createphishingurldatabasejob.h
index d87dbf3..71bdeee 100644
--- a/webengineviewer/src/checkphishingurl/createphishingurldatabasejob.h
+++ b/webengineviewer/src/checkphishingurl/createphishingurldatabasejob.h
@@ -29,6 +29,17 @@
class QNetworkAccessManager;
namespace WebEngineViewer
{
+struct UpdateDataBaseInfo {
+ QList<int> indexToRemove;
+ QString minimumWaitDuration;
+ QString threatType;
+ QString threatEntryType;
+ QString responseType;
+ QString platformType;
+ QString newClientState;
+ QString sha256;
+};
+
/* https://developers.google.com/safe-browsing/v4/update-api */
class WEBENGINEVIEWER_EXPORT CreatePhishingUrlDataBaseJob : public QObject
{
@@ -39,6 +50,12 @@ public:
UpdateDataBase = 1
};
+ enum DataBaseDownloadResult {
+ InvalidData = 0,
+ ValidData = 1,
+ UnknownError = 2
+ };
+
explicit CreatePhishingUrlDataBaseJob(QObject *parent = Q_NULLPTR);
~CreatePhishingUrlDataBaseJob();
@@ -51,7 +68,7 @@ public:
QByteArray jsonRequest() const;
Q_SIGNALS:
- void finished();
+ void finished(WebEngineViewer::CreatePhishingUrlDataBaseJob::DataBaseDownloadResult status);
void debugJsonResult(const QByteArray &ba);
void debugJson(const QByteArray &ba);