summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMontel Laurent <montel@kde.org>2016-11-17 07:22:14 (GMT)
committerMontel Laurent <montel@kde.org>2016-11-17 07:22:14 (GMT)
commit336e8ca490ef5c6d50a65806b675264b48250d45 (patch)
treeb7d7e16a11cc1a05eca20d22f6eb72934e3de14b
parentc09a8f0929eef87299374f691db6b3bed1148f7c (diff)
Astyle kdelibs
-rw-r--r--webengineviewer/src/checkphishingurl/autotests/checkphishingurlfromlocaldatabasejobtest.cpp2
-rw-r--r--webengineviewer/src/checkphishingurl/autotests/createphishingurldatabasejobtest.cpp10
-rw-r--r--webengineviewer/src/checkphishingurl/checkphishingurlutil.h6
-rw-r--r--webengineviewer/src/checkphishingurl/createphishingurldatabasejob.cpp86
-rw-r--r--webengineviewer/src/checkphishingurl/createphishingurldatabasejob.h7
-rw-r--r--webengineviewer/src/checkphishingurl/localdatabasemanager.cpp3
-rw-r--r--webengineviewer/src/checkphishingurl/tests/createphishingurldatabasegui.cpp1
-rw-r--r--webengineviewer/src/webenginescript.cpp96
8 files changed, 105 insertions, 106 deletions
diff --git a/webengineviewer/src/checkphishingurl/autotests/checkphishingurlfromlocaldatabasejobtest.cpp b/webengineviewer/src/checkphishingurl/autotests/checkphishingurlfromlocaldatabasejobtest.cpp
index 9548956..09545bf 100644
--- a/webengineviewer/src/checkphishingurl/autotests/checkphishingurlfromlocaldatabasejobtest.cpp
+++ b/webengineviewer/src/checkphishingurl/autotests/checkphishingurlfromlocaldatabasejobtest.cpp
@@ -21,7 +21,6 @@
#include "../checkphishingurlfromlocaldatabasejob.h"
#include <QTest>
-
CheckPhishingUrlFromLocalDataBaseJobTest::CheckPhishingUrlFromLocalDataBaseJobTest(QObject *parent)
: QObject(parent)
{
@@ -33,5 +32,4 @@ CheckPhishingUrlFromLocalDataBaseJobTest::~CheckPhishingUrlFromLocalDataBaseJobT
}
-
QTEST_MAIN(CheckPhishingUrlFromLocalDataBaseJobTest)
diff --git a/webengineviewer/src/checkphishingurl/autotests/createphishingurldatabasejobtest.cpp b/webengineviewer/src/checkphishingurl/autotests/createphishingurldatabasejobtest.cpp
index db8828d..e6a376c 100644
--- a/webengineviewer/src/checkphishingurl/autotests/createphishingurldatabasejobtest.cpp
+++ b/webengineviewer/src/checkphishingurl/autotests/createphishingurldatabasejobtest.cpp
@@ -33,7 +33,6 @@ QByteArray readJsonFile(const QString &jsonFile)
return data;
}
-
CreatePhishingUrlDataBaseJobTest::CreatePhishingUrlDataBaseJobTest(QObject *parent)
: QObject(parent)
{
@@ -102,9 +101,9 @@ void CreatePhishingUrlDataBaseJobTest::shouldCreateRequest_data()
void CreatePhishingUrlDataBaseJobTest::shouldCreateRequest()
{
- QFETCH (QString, databasestate);
- QFETCH (WebEngineViewer::CreatePhishingUrlDataBaseJob::DataBaseDownload, downloadtype);
- QFETCH (QByteArray, request);
+ QFETCH(QString, databasestate);
+ QFETCH(WebEngineViewer::CreatePhishingUrlDataBaseJob::DataBaseDownload, downloadtype);
+ QFETCH(QByteArray, request);
WebEngineViewer::CreatePhishingUrlDataBaseJob job;
job.setDataBaseState(databasestate);
@@ -165,7 +164,7 @@ void CreatePhishingUrlDataBaseJobTest::shouldParseResult_data()
void CreatePhishingUrlDataBaseJobTest::shouldParseResult()
{
- QFETCH (QString, filename);
+ QFETCH(QString, filename);
QFETCH(WebEngineViewer::CreatePhishingUrlDataBaseJob::DataBaseDownloadResult, parseResult);
QFETCH(WebEngineViewer::UpdateDataBaseInfo, parseInfo);
const QByteArray ba = readJsonFile(filename);
@@ -177,5 +176,4 @@ void CreatePhishingUrlDataBaseJobTest::shouldParseResult()
QCOMPARE(spy1.at(0).at(0).value<WebEngineViewer::UpdateDataBaseInfo>(), parseInfo);
}
-
QTEST_MAIN(CreatePhishingUrlDataBaseJobTest)
diff --git a/webengineviewer/src/checkphishingurl/checkphishingurlutil.h b/webengineviewer/src/checkphishingurl/checkphishingurlutil.h
index 9ca2b8b..8271599 100644
--- a/webengineviewer/src/checkphishingurl/checkphishingurlutil.h
+++ b/webengineviewer/src/checkphishingurl/checkphishingurlutil.h
@@ -22,8 +22,10 @@
#include <QString>
-namespace WebEngineViewer {
-namespace CheckPhishingUrlUtil {
+namespace WebEngineViewer
+{
+namespace CheckPhishingUrlUtil
+{
QString apiKey();
}
}
diff --git a/webengineviewer/src/checkphishingurl/createphishingurldatabasejob.cpp b/webengineviewer/src/checkphishingurl/createphishingurldatabasejob.cpp
index bf8da1c..eb76550 100644
--- a/webengineviewer/src/checkphishingurl/createphishingurldatabasejob.cpp
+++ b/webengineviewer/src/checkphishingurl/createphishingurldatabasejob.cpp
@@ -17,7 +17,6 @@
Boston, MA 02110-1301, USA.
*/
-
#include "createphishingurldatabasejob.h"
#include "checkphishingurlutil.h"
#include "webengineviewer_debug.h"
@@ -87,22 +86,22 @@ QByteArray CreatePhishingUrlDataBaseJob::jsonRequest() const
{
#if 0
{
- "client": {
+ "client": {
"clientId": "yourcompanyname",
"clientVersion": "1.5.2"
- },
- "listUpdateRequests": [{
+ },
+ "listUpdateRequests": [{
"threatType": "MALWARE",
"platformType": "WINDOWS",
"threatEntryType": "URL",
"state": "Gg4IBBADIgYQgBAiAQEoAQ==",
"constraints": {
- "maxUpdateEntries": 2048,
- "maxDatabaseEntries": 4096,
- "region": "US",
- "supportedCompressions": ["RAW"]
- }
- }]
+ "maxUpdateEntries": 2048,
+ "maxDatabaseEntries": 4096,
+ "region": "US",
+ "supportedCompressions": ["RAW"]
+ }
+ }]
}
#endif
QVariantMap clientMap;
@@ -120,7 +119,7 @@ QByteArray CreatePhishingUrlDataBaseJob::jsonRequest() const
threatMap.insert(QStringLiteral("threatEntryType"), QStringLiteral("URL"));
//Define state when we want to define update database. Empty is full.
- switch(mDataBaseDownloadNeeded) {
+ switch (mDataBaseDownloadNeeded) {
case FullDataBase:
threatMap.insert(QStringLiteral("state"), QString());
break;
@@ -135,7 +134,6 @@ QByteArray CreatePhishingUrlDataBaseJob::jsonRequest() const
listUpdateRequests.append(threatMap);
//TODO define contraints
-
map.insert(QStringLiteral("listUpdateRequests"), listUpdateRequests);
const QJsonDocument postData = QJsonDocument::fromVariant(map);
@@ -143,7 +141,6 @@ QByteArray CreatePhishingUrlDataBaseJob::jsonRequest() const
return baPostData;
}
-
void CreatePhishingUrlDataBaseJob::setDataBaseDownloadNeeded(CreatePhishingUrlDataBaseJob::DataBaseDownload type)
{
mDataBaseDownloadNeeded = type;
@@ -160,7 +157,7 @@ void CreatePhishingUrlDataBaseJob::slotDownloadDataBaseFinished(QNetworkReply *r
QVector<Addition> CreatePhishingUrlDataBaseJob::parseAdditions(const QVariantList &lst)
{
QVector<Addition> additionList;
- Q_FOREACH(const QVariant &v, lst) {
+ Q_FOREACH (const QVariant &v, lst) {
if (v.canConvert<QVariantMap>()) {
QMapIterator<QString, QVariant> mapIt(v.toMap());
while (mapIt.hasNext()) {
@@ -192,7 +189,7 @@ QVector<Addition> CreatePhishingUrlDataBaseJob::parseAdditions(const QVariantLis
}
}
} else {
- qDebug() << " CreatePhishingUrlDataBaseJob::parseAdditions not parsing type "<<v.typeName();
+ qDebug() << " CreatePhishingUrlDataBaseJob::parseAdditions not parsing type " << v.typeName();
}
}
return additionList;
@@ -206,7 +203,7 @@ void CreatePhishingUrlDataBaseJob::setUseCompactJson(bool useCompactJson)
QVector<Removal> CreatePhishingUrlDataBaseJob::parseRemovals(const QVariantList &lst)
{
QVector<Removal> removalList;
- Q_FOREACH(const QVariant &v, lst) {
+ Q_FOREACH (const QVariant &v, lst) {
if (v.canConvert<QVariantMap>()) {
Removal tmp;
QMapIterator<QString, QVariant> mapIt(v.toMap());
@@ -223,7 +220,7 @@ QVector<Removal> CreatePhishingUrlDataBaseJob::parseRemovals(const QVariantList
if (rawIndicesIt.key() == QStringLiteral("indices")) {
const QVariantList lst = rawIndicesIt.value().toList();
QList<int> indexList;
- Q_FOREACH(const QVariant &var, lst) {
+ Q_FOREACH (const QVariant &var, lst) {
indexList.append(var.toInt());
}
tmp.indexes = indexList;
@@ -239,7 +236,7 @@ QVector<Removal> CreatePhishingUrlDataBaseJob::parseRemovals(const QVariantList
removalList.append(tmp);
}
} else {
- qDebug() << " CreatePhishingUrlDataBaseJob::parseRemovals not parsing type "<<v.typeName();
+ qDebug() << " CreatePhishingUrlDataBaseJob::parseRemovals not parsing type " << v.typeName();
}
}
return removalList;
@@ -254,7 +251,7 @@ void CreatePhishingUrlDataBaseJob::parseResult(const QByteArray &value)
} else {
const QVariantMap answer = document.toVariant().toMap();
if (answer.isEmpty()) {
- Q_EMIT finished(databaseInfo,InvalidData);
+ Q_EMIT finished(databaseInfo, InvalidData);
} else {
QMapIterator<QString, QVariant> i(answer);
while (i.hasNext()) {
@@ -309,7 +306,7 @@ void CreatePhishingUrlDataBaseJob::parseResult(const QByteArray &value)
} else if (i.key() == QLatin1String("minimumWaitDuration")) {
databaseInfo.minimumWaitDuration = i.value().toString();
} else {
- qDebug() <<" map key unknown " << i.key();
+ qDebug() << " map key unknown " << i.key();
}
}
Q_EMIT finished(databaseInfo, ValidData);
@@ -333,45 +330,48 @@ void UpdateDataBaseInfo::clear()
}
-bool UpdateDataBaseInfo::operator==(const UpdateDataBaseInfo &other) const {
+bool UpdateDataBaseInfo::operator==(const UpdateDataBaseInfo &other) const
+{
const bool val = (additionList == other.additionList) &&
- (removalList == other.removalList) &&
- (minimumWaitDuration == other.minimumWaitDuration) &&
- (threatType == other.threatType) &&
- (threatEntryType == other.threatEntryType) &&
- (responseType == other.responseType) &&
- (platformType == other.platformType) &&
- (newClientState == other.newClientState) &&
- (sha256 == other.sha256);
+ (removalList == other.removalList) &&
+ (minimumWaitDuration == other.minimumWaitDuration) &&
+ (threatType == other.threatType) &&
+ (threatEntryType == other.threatEntryType) &&
+ (responseType == other.responseType) &&
+ (platformType == other.platformType) &&
+ (newClientState == other.newClientState) &&
+ (sha256 == other.sha256);
if (!val) {
- qDebug() << " sha256 "<<sha256 << " other.sha256 "<< other.sha256;
- qDebug() << " minimumWaitDuration "<<minimumWaitDuration << " other.minimumWaitDuration "<< other.minimumWaitDuration;
- qDebug() << " threatType "<<threatType << " other.threatType "<< other.threatType;
- qDebug() << " threatEntryType "<<threatEntryType << " other.threatEntryType "<< other.threatEntryType;
- qDebug() << " responseType "<<responseType << " other.responseType "<< other.responseType;
- qDebug() << " platformType "<<platformType << " other.platformType "<< other.platformType;
- qDebug() << " newClientState "<<newClientState << " other.newClientState "<< other.newClientState;
- qDebug() << " threatType "<<threatType << " other.threatType "<< other.threatType;
+ qDebug() << " sha256 " << sha256 << " other.sha256 " << other.sha256;
+ qDebug() << " minimumWaitDuration " << minimumWaitDuration << " other.minimumWaitDuration " << other.minimumWaitDuration;
+ qDebug() << " threatType " << threatType << " other.threatType " << other.threatType;
+ qDebug() << " threatEntryType " << threatEntryType << " other.threatEntryType " << other.threatEntryType;
+ qDebug() << " responseType " << responseType << " other.responseType " << other.responseType;
+ qDebug() << " platformType " << platformType << " other.platformType " << other.platformType;
+ qDebug() << " newClientState " << newClientState << " other.newClientState " << other.newClientState;
+ qDebug() << " threatType " << threatType << " other.threatType " << other.threatType;
qDebug() << " removalList" << removalList.count() << " other.removalList " << other.removalList.count();
qDebug() << " additionList" << additionList.count() << " other.additionList " << other.additionList.count();
}
return val;
}
-bool Removal::operator==(const Removal &other) const {
+bool Removal::operator==(const Removal &other) const
+{
bool value = (indexes == other.indexes);
if (!value) {
- qDebug() << " indexes "<<indexes << " other.indexes " << other.indexes;
+ qDebug() << " indexes " << indexes << " other.indexes " << other.indexes;
}
return value;
}
-bool Addition::operator==(const Addition &other) const {
+bool Addition::operator==(const Addition &other) const
+{
bool value = (hashString == other.hashString) &&
- (prefixSize == other.prefixSize);
+ (prefixSize == other.prefixSize);
if (!value) {
- qDebug() << "hashString " << hashString << " other.hashString "<<other.hashString;
- qDebug() << "prefixSize " << prefixSize << " other.prefixSize "<<other.prefixSize;
+ qDebug() << "hashString " << hashString << " other.hashString " << other.hashString;
+ qDebug() << "prefixSize " << prefixSize << " other.prefixSize " << other.prefixSize;
}
return value;
}
diff --git a/webengineviewer/src/checkphishingurl/createphishingurldatabasejob.h b/webengineviewer/src/checkphishingurl/createphishingurldatabasejob.h
index ac9eb7f..48ba30e 100644
--- a/webengineviewer/src/checkphishingurl/createphishingurldatabasejob.h
+++ b/webengineviewer/src/checkphishingurl/createphishingurldatabasejob.h
@@ -17,7 +17,6 @@
Boston, MA 02110-1301, USA.
*/
-
#ifndef CREATEPHISHINGURLDATABASEJOB_H
#define CREATEPHISHINGURLDATABASEJOB_H
@@ -35,7 +34,8 @@ struct Addition {
{
}
- bool isValid() const {
+ bool isValid() const
+ {
return !hashString.isEmpty() && (prefixSize > 0);
}
bool operator==(const Addition &other) const;
@@ -51,7 +51,8 @@ struct Removal {
}
bool operator==(const Removal &other) const;
- bool isValid() const {
+ bool isValid() const
+ {
return !indexes.isEmpty();
}
QList<int> indexes;
diff --git a/webengineviewer/src/checkphishingurl/localdatabasemanager.cpp b/webengineviewer/src/checkphishingurl/localdatabasemanager.cpp
index 38fed95..5cf98b0 100644
--- a/webengineviewer/src/checkphishingurl/localdatabasemanager.cpp
+++ b/webengineviewer/src/checkphishingurl/localdatabasemanager.cpp
@@ -56,8 +56,9 @@ QSqlError LocalDataBaseManager::initDb()
QSqlDatabase db = QSqlDatabase::addDatabase(QStringLiteral("QSQLITE"));
db.setDatabaseName(QStringLiteral(":phishingurl:"));
- if (!db.open())
+ if (!db.open()) {
return db.lastError();
+ }
//TODO
return QSqlError();
}
diff --git a/webengineviewer/src/checkphishingurl/tests/createphishingurldatabasegui.cpp b/webengineviewer/src/checkphishingurl/tests/createphishingurldatabasegui.cpp
index d93e304..409aff5 100644
--- a/webengineviewer/src/checkphishingurl/tests/createphishingurldatabasegui.cpp
+++ b/webengineviewer/src/checkphishingurl/tests/createphishingurldatabasegui.cpp
@@ -33,7 +33,6 @@ CreatePhisingUrlDataBaseGui::CreatePhisingUrlDataBaseGui(QWidget *parent)
{
QVBoxLayout *layout = new QVBoxLayout(this);
-
mResult = new QTextEdit(this);
mResult->setReadOnly(true);
mResult->setAcceptRichText(false);
diff --git a/webengineviewer/src/webenginescript.cpp b/webengineviewer/src/webenginescript.cpp
index 519c041..7bbdae7 100644
--- a/webengineviewer/src/webenginescript.cpp
+++ b/webengineviewer/src/webenginescript.cpp
@@ -24,16 +24,16 @@ using namespace WebEngineViewer;
QString WebEngineScript::findAllImages()
{
const QString source = QStringLiteral("(function() {"
- "var out = [];"
- "var imgs = document.getElementsByTagName('img');"
- "for (var i = 0; i < imgs.length; ++i) {"
- " var e = imgs[i];"
- " out.push({"
- " src: e.src"
- " });"
- "}"
- "return out;"
- "})()");
+ "var out = [];"
+ "var imgs = document.getElementsByTagName('img');"
+ "for (var i = 0; i < imgs.length; ++i) {"
+ " var e = imgs[i];"
+ " out.push({"
+ " src: e.src"
+ " });"
+ "}"
+ "return out;"
+ "})()");
return source;
}
@@ -41,16 +41,16 @@ QString WebEngineScript::findAllImages()
QString WebEngineScript::findAllScripts()
{
const QString source = QStringLiteral("(function() {"
- "var out = [];"
- "var scripts = document.getElementsByTagName('script');"
- "for (var i = 0; i < scripts.length; ++i) {"
- " var e = scripts[i];"
- " out.push({"
- " src: e.src"
- " });"
- "}"
- "return out;"
- "})()");
+ "var out = [];"
+ "var scripts = document.getElementsByTagName('script');"
+ "for (var i = 0; i < scripts.length; ++i) {"
+ " var e = scripts[i];"
+ " out.push({"
+ " src: e.src"
+ " });"
+ "}"
+ "return out;"
+ "})()");
return source;
}
@@ -58,18 +58,18 @@ QString WebEngineScript::findAllScripts()
QString WebEngineScript::findAllAnchors()
{
const QString source = QStringLiteral("(function() {"
- "var out = [];"
- "var anchors = document.getElementsByTagName('a');"
- "for (var i = 0; i < anchors.length; ++i) {"
- " var r = anchors[i].getBoundingClientRect();"
- " out.push({"
- " src: anchors[i].href,"
- " title: anchors[i].title,"
- " boudingRect: [r.top, r.left, r.width, r.height]"
- " });"
- "}"
- "return out;"
- "})()");
+ "var out = [];"
+ "var anchors = document.getElementsByTagName('a');"
+ "for (var i = 0; i < anchors.length; ++i) {"
+ " var r = anchors[i].getBoundingClientRect();"
+ " out.push({"
+ " src: anchors[i].href,"
+ " title: anchors[i].title,"
+ " boudingRect: [r.top, r.left, r.width, r.height]"
+ " });"
+ "}"
+ "return out;"
+ "})()");
return source;
}
@@ -77,22 +77,22 @@ QString WebEngineScript::findAllAnchors()
QString WebEngineScript::findAllAnchorsAndForms()
{
const QString source = QStringLiteral("(function() {"
- "var res = [];"
- "var out = [];"
- "var anchors = document.getElementsByTagName('a');"
- "for (var i = 0; i < anchors.length; ++i) {"
- " out.push({"
- " src: anchors[i].href,"
- " title: anchors[i].title"
- " });"
- "}"
- "var forms = document.getElementsByTagName('form');"
- "res.push({"
- " anchors: out,"
- " forms: forms.length"
- " });"
- "return res;"
- "})()");
+ "var res = [];"
+ "var out = [];"
+ "var anchors = document.getElementsByTagName('a');"
+ "for (var i = 0; i < anchors.length; ++i) {"
+ " out.push({"
+ " src: anchors[i].href,"
+ " title: anchors[i].title"
+ " });"
+ "}"
+ "var forms = document.getElementsByTagName('form');"
+ "res.push({"
+ " anchors: out,"
+ " forms: forms.length"
+ " });"
+ "return res;"
+ "})()");
return source;
}