Messagelib

createphishingurldatabasejob.h
1 /*
2  SPDX-FileCopyrightText: 2016-2023 Laurent Montel <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6 
7 #pragma once
8 
9 #include <QNetworkReply>
10 #include <QObject>
11 #include <QSslError>
12 
13 #include "webengineviewer_export.h"
14 namespace WebEngineViewer
15 {
16 struct UpdateDataBaseInfo;
17 class CreatePhishingUrlDataBaseJobPrivate;
18 /* https://developers.google.com/safe-browsing/v4/update-api */
19 /**
20  * @brief The CreatePhishingUrlDataBaseJob class
21  * @author Laurent Montel <[email protected]>
22  */
23 class WEBENGINEVIEWER_EXPORT CreatePhishingUrlDataBaseJob : public QObject
24 {
25  Q_OBJECT
26 public:
27  enum DataBaseDownloadType {
28  FullDataBase = 0,
29  UpdateDataBase = 1,
30  };
31 
32  enum DataBaseDownloadResult {
33  InvalidData = 0,
34  ValidData = 1,
35  UnknownError = 2,
36  BrokenNetwork = 3,
37  };
38 
39  enum ContraintsCompressionType { RawCompression = 0, RiceCompression = 1 };
40 
41  explicit CreatePhishingUrlDataBaseJob(QObject *parent = nullptr);
42  ~CreatePhishingUrlDataBaseJob() override;
43 
44  void start();
45 
46  void setDataBaseState(const QString &value);
47 
48  void setDataBaseDownloadNeeded(WebEngineViewer::CreatePhishingUrlDataBaseJob::DataBaseDownloadType type);
49 
50  Q_REQUIRED_RESULT QByteArray jsonRequest() const;
51 
52  void parseResult(const QByteArray &value);
53 
54  void setContraintsCompressionType(CreatePhishingUrlDataBaseJob::ContraintsCompressionType type);
55 
56 Q_SIGNALS:
57  void finished(const WebEngineViewer::UpdateDataBaseInfo &infoDataBase, WebEngineViewer::CreatePhishingUrlDataBaseJob::DataBaseDownloadResult status);
58  void debugJsonResult(const QByteArray &ba);
59  void debugJson(const QByteArray &ba);
60 
61 private:
62  void slotDownloadDataBaseFinished(QNetworkReply *reply);
63  void slotSslErrors(QNetworkReply *reply, const QList<QSslError> &error);
64  void slotError(QNetworkReply::NetworkError error);
65 
66  std::unique_ptr<CreatePhishingUrlDataBaseJobPrivate> const d;
67 };
68 }
69 Q_DECLARE_METATYPE(WebEngineViewer::CreatePhishingUrlDataBaseJob::DataBaseDownloadType)
70 Q_DECLARE_METATYPE(WebEngineViewer::CreatePhishingUrlDataBaseJob::DataBaseDownloadResult)
71 Q_DECLARE_METATYPE(WebEngineViewer::CreatePhishingUrlDataBaseJob::ContraintsCompressionType)
Q_SCRIPTABLE Q_NOREPLY void start()
Q_SCRIPTABLE CaptureState status()
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Fri Mar 24 2023 04:08:31 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.