summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMontel Laurent <montel@kde.org>2016-11-18 07:14:37 (GMT)
committerMontel Laurent <montel@kde.org>2016-11-18 07:14:37 (GMT)
commite7d0883ed18a89b1f67b290d4d40ce3690e08390 (patch)
treedddb2fda5faa914cc52935e2f5b81e1ea148562f
parent6e144aec8af7eb7cb18f977bc8e6c6406f98a425 (diff)
Use a enum type
-rw-r--r--webengineviewer/src/checkphishingurl/autotests/createphishingurldatabasejobtest.cpp6
-rw-r--r--webengineviewer/src/checkphishingurl/createphishingurldatabasejob.cpp12
-rw-r--r--webengineviewer/src/checkphishingurl/createphishingurldatabasejob.h14
-rw-r--r--webengineviewer/src/checkphishingurl/localdatabasemanager.cpp2
4 files changed, 27 insertions, 7 deletions
diff --git a/webengineviewer/src/checkphishingurl/autotests/createphishingurldatabasejobtest.cpp b/webengineviewer/src/checkphishingurl/autotests/createphishingurldatabasejobtest.cpp
index e6a376c..09451eb 100644
--- a/webengineviewer/src/checkphishingurl/autotests/createphishingurldatabasejobtest.cpp
+++ b/webengineviewer/src/checkphishingurl/autotests/createphishingurldatabasejobtest.cpp
@@ -71,7 +71,7 @@ void CreatePhishingUrlDataBaseJobTest::shouldClearUpdateDataBaseInfo()
value.minimumWaitDuration = QStringLiteral("593.440s");
value.threatType = QStringLiteral("MALWARE");
value.threatEntryType = QStringLiteral("URL");
- value.responseType = QStringLiteral("PARTIAL_UPDATE");
+ value.responseType = WebEngineViewer::UpdateDataBaseInfo::PartialUpdate;
value.platformType = QStringLiteral("WINDOWS");
value.newClientState = QStringLiteral("ChAIBRADGAEiAzAwMSiAEDABEAFGpqhd");
value.sha256 = QStringLiteral("YSgoRtsRlgHDqDA3LAhM1gegEpEzs1TjzU33vqsR8iM=");
@@ -132,7 +132,7 @@ void CreatePhishingUrlDataBaseJobTest::shouldParseResult_data()
value.minimumWaitDuration = QStringLiteral("593.440s");
value.threatType = QStringLiteral("MALWARE");
value.threatEntryType = QStringLiteral("URL");
- value.responseType = QStringLiteral("PARTIAL_UPDATE");
+ value.responseType = WebEngineViewer::UpdateDataBaseInfo::PartialUpdate;
value.platformType = QStringLiteral("WINDOWS");
value.newClientState = QStringLiteral("ChAIBRADGAEiAzAwMSiAEDABEAFGpqhd");
value.sha256 = QStringLiteral("YSgoRtsRlgHDqDA3LAhM1gegEpEzs1TjzU33vqsR8iM=");
@@ -153,7 +153,7 @@ void CreatePhishingUrlDataBaseJobTest::shouldParseResult_data()
value.minimumWaitDuration = QStringLiteral("1786.932s");
value.threatType = QStringLiteral("MALWARE");
value.threatEntryType = QStringLiteral("URL");
- value.responseType = QStringLiteral("FULL_UPDATE");
+ value.responseType = WebEngineViewer::UpdateDataBaseInfo::FullUpdate;
value.platformType = QStringLiteral("WINDOWS");
value.newClientState = QStringLiteral("Cg0IARAGGAEiAzAwMTABELmwARoCGAUmgN3G");
value.sha256 = QStringLiteral("ANcYWR8Umuoir+uNs1AhfxqW0iXEPDkxN6Pp2QF8dSs=");
diff --git a/webengineviewer/src/checkphishingurl/createphishingurldatabasejob.cpp b/webengineviewer/src/checkphishingurl/createphishingurldatabasejob.cpp
index 1686d82..12c30b5 100644
--- a/webengineviewer/src/checkphishingurl/createphishingurldatabasejob.cpp
+++ b/webengineviewer/src/checkphishingurl/createphishingurldatabasejob.cpp
@@ -292,7 +292,15 @@ void CreatePhishingUrlDataBaseJob::parseResult(const QByteArray &value)
} else if (mapKey == QLatin1String("platformType")) {
databaseInfo.platformType = mapIt.value().toString();
} else if (mapKey == QLatin1String("responseType")) {
- databaseInfo.responseType = mapIt.value().toString();
+ const QString str = mapIt.value().toString();
+ if (str == QLatin1String("FULL_UPDATE")) {
+ databaseInfo.responseType = UpdateDataBaseInfo::FullUpdate;
+ } else if (str == QLatin1String("PARTIAL_UPDATE")) {
+ databaseInfo.responseType = UpdateDataBaseInfo::PartialUpdate;
+ } else {
+ qDebug() << " unknow responsetype " << str;
+ databaseInfo.responseType = UpdateDataBaseInfo::Unknown;
+ }
} else if (mapKey == QLatin1String("threatEntryType")) {
databaseInfo.threatEntryType = mapIt.value().toString();
} else if (mapKey == QLatin1String("threatType")) {
@@ -323,7 +331,7 @@ void UpdateDataBaseInfo::clear()
minimumWaitDuration.clear();
threatType.clear();
threatEntryType.clear();
- responseType.clear();
+ responseType = UpdateDataBaseInfo::Unknown;
platformType.clear();
newClientState.clear();
sha256.clear();
diff --git a/webengineviewer/src/checkphishingurl/createphishingurldatabasejob.h b/webengineviewer/src/checkphishingurl/createphishingurldatabasejob.h
index a264e7d..40910f9 100644
--- a/webengineviewer/src/checkphishingurl/createphishingurldatabasejob.h
+++ b/webengineviewer/src/checkphishingurl/createphishingurldatabasejob.h
@@ -44,12 +44,24 @@ struct Removal {
};
struct UpdateDataBaseInfo {
+ UpdateDataBaseInfo()
+ : responseType(Unknown)
+ {
+
+ }
+
+ enum ResponseType {
+ Unknown = 0,
+ FullUpdate = 1,
+ PartialUpdate = 2
+ };
+
QVector<Addition> additionList;
QVector<Removal> removalList;
QString minimumWaitDuration;
QString threatType;
QString threatEntryType;
- QString responseType;
+ ResponseType responseType;
QString platformType;
QString newClientState;
QString sha256;
diff --git a/webengineviewer/src/checkphishingurl/localdatabasemanager.cpp b/webengineviewer/src/checkphishingurl/localdatabasemanager.cpp
index 10b09d6..78933ff 100644
--- a/webengineviewer/src/checkphishingurl/localdatabasemanager.cpp
+++ b/webengineviewer/src/checkphishingurl/localdatabasemanager.cpp
@@ -170,7 +170,7 @@ void LocalDataBaseManager::slotDownloadDataBaseFinished(const WebEngineViewer::U
break;
}
if (mDataBaseOk) {
- if ((infoDataBase.responseType == QLatin1String("PARTIAL_UPDATE")) &&
+ if ((infoDataBase.responseType == WebEngineViewer::UpdateDataBaseInfo::PartialUpdate) &&
(mNewClientState == infoDataBase.newClientState)) {
qDebug() << "No update necessary ";
} else {