summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMontel Laurent <montel@kde.org>2016-11-15 12:29:37 (GMT)
committerMontel Laurent <montel@kde.org>2016-11-15 12:29:37 (GMT)
commit4a66bf75eec7fa7d0829dbf9ca5d7c7175d5b023 (patch)
tree4622895affb30646f272ae5512938ce928a19461
parent201a577cac7557f386cdc08201e59960dacf5cc9 (diff)
Improve job
-rw-r--r--webengineviewer/src/checkphishingurl/createphishingurldatabasejob.cpp27
-rw-r--r--webengineviewer/src/checkphishingurl/createphishingurldatabasejob.h18
2 files changed, 42 insertions, 3 deletions
diff --git a/webengineviewer/src/checkphishingurl/createphishingurldatabasejob.cpp b/webengineviewer/src/checkphishingurl/createphishingurldatabasejob.cpp
index c0792f6..8ddaaea 100644
--- a/webengineviewer/src/checkphishingurl/createphishingurldatabasejob.cpp
+++ b/webengineviewer/src/checkphishingurl/createphishingurldatabasejob.cpp
@@ -19,13 +19,19 @@
#include "createphishingurldatabasejob.h"
+#include "webengineviewer_debug.h"
+
+#include <QNetworkReply>
using namespace WebEngineViewer;
CreatePhishingUrlDataBaseJob::CreatePhishingUrlDataBaseJob(QObject *parent)
- : QObject(parent)
+ : QObject(parent),
+ mDataBaseDownloadNeeded(FullDataBase)
{
-
+ mNetworkAccessManager = new QNetworkAccessManager(this);
+ connect(mNetworkAccessManager, &QNetworkAccessManager::finished, this, &CreatePhishingUrlDataBaseJob::slotCheckUrlFinished);
+ connect(mNetworkAccessManager, &QNetworkAccessManager::sslErrors, this, &CreatePhishingUrlDataBaseJob::slotSslErrors);
}
CreatePhishingUrlDataBaseJob::~CreatePhishingUrlDataBaseJob()
@@ -33,7 +39,24 @@ CreatePhishingUrlDataBaseJob::~CreatePhishingUrlDataBaseJob()
}
+void CreatePhishingUrlDataBaseJob::slotSslErrors(QNetworkReply *reply, const QList<QSslError> &error)
+{
+ qCDebug(WEBENGINEVIEWER_LOG) << " void CreatePhishingUrlDataBaseJob::slotSslErrors(QNetworkReply *reply, const QList<QSslError> &error)" << error.count();
+ reply->ignoreSslErrors(error);
+}
+
void CreatePhishingUrlDataBaseJob::start()
{
}
+
+void CreatePhishingUrlDataBaseJob::setDataBaseDownloadNeeded(CreatePhishingUrlDataBaseJob::DataBaseDownload type)
+{
+ mDataBaseDownloadNeeded = type;
+}
+
+void CreatePhishingUrlDataBaseJob::slotCheckUrlFinished(QNetworkReply *reply)
+{
+ reply->deleteLater();
+ deleteLater();
+}
diff --git a/webengineviewer/src/checkphishingurl/createphishingurldatabasejob.h b/webengineviewer/src/checkphishingurl/createphishingurldatabasejob.h
index e740922..0d3af63 100644
--- a/webengineviewer/src/checkphishingurl/createphishingurldatabasejob.h
+++ b/webengineviewer/src/checkphishingurl/createphishingurldatabasejob.h
@@ -22,19 +22,35 @@
#define CREATEPHISHINGURLDATABASEJOB_H
#include <QObject>
+#include <QSslError>
#include "webengineviewer_export.h"
-
+class QNetworkAccessManager;
+class QNetworkReply;
namespace WebEngineViewer
{
class WEBENGINEVIEWER_EXPORT CreatePhishingUrlDataBaseJob : public QObject
{
Q_OBJECT
public:
+ enum DataBaseDownload {
+ FullDataBase = 0,
+ UpdateDataBase = 1
+ };
+
explicit CreatePhishingUrlDataBaseJob(QObject *parent = Q_NULLPTR);
~CreatePhishingUrlDataBaseJob();
void start();
+
+ void setDataBaseDownloadNeeded(WebEngineViewer::CreatePhishingUrlDataBaseJob::DataBaseDownload type);
+
+private:
+ void slotCheckUrlFinished(QNetworkReply *reply);
+ void slotSslErrors(QNetworkReply *reply, const QList<QSslError> &error);
+
+ DataBaseDownload mDataBaseDownloadNeeded;
+ QNetworkAccessManager *mNetworkAccessManager;
};
}
#endif // CREATEPHISHINGURLDATABASEJOB_H