File indexing completed on 2025-01-26 04:57:23
0001 /* 0002 SPDX-FileCopyrightText: 2016-2024 Laurent Montel <montel@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #pragma once 0008 0009 #include "checkphishingurlutil.h" 0010 #include "webengineviewer_export.h" 0011 #include <QNetworkReply> 0012 #include <QObject> 0013 #include <QUrl> 0014 namespace WebEngineViewer 0015 { 0016 class SearchFullHashJobPrivate; 0017 /* https://developers.google.com/safe-browsing/v4/update-api */ 0018 /** 0019 * @brief The SearchFullHashJob class 0020 * @author Laurent Montel <montel@kde.org> 0021 */ 0022 class WEBENGINEVIEWER_EXPORT SearchFullHashJob : public QObject 0023 { 0024 Q_OBJECT 0025 public: 0026 explicit SearchFullHashJob(QObject *parent = nullptr); 0027 ~SearchFullHashJob() override; 0028 0029 void start(); 0030 [[nodiscard]] bool canStart() const; 0031 0032 void setDatabaseState(const QStringList &hash); 0033 void setSearchFullHashForUrl(const QUrl &url); 0034 0035 [[nodiscard]] QByteArray jsonRequest() const; 0036 void parse(const QByteArray &replyStr); 0037 0038 void setSearchHashs(const QHash<QByteArray, QByteArray> &hash); 0039 Q_SIGNALS: 0040 void result(WebEngineViewer::CheckPhishingUrlUtil::UrlStatus status, const QUrl &url); 0041 void debugJson(const QByteArray &ba); 0042 0043 private: 0044 WEBENGINEVIEWER_NO_EXPORT void slotSslErrors(QNetworkReply *reply, const QList<QSslError> &error); 0045 WEBENGINEVIEWER_NO_EXPORT void slotError(QNetworkReply::NetworkError error); 0046 WEBENGINEVIEWER_NO_EXPORT void slotCheckUrlFinished(QNetworkReply *reply); 0047 0048 Q_DISABLE_COPY(SearchFullHashJob) 0049 std::unique_ptr<SearchFullHashJobPrivate> const d; 0050 }; 0051 }