File indexing completed on 2025-01-26 04:57:22
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 CheckPhishingUrlJobPrivate; 0017 /* https://developers.google.com/safe-browsing/v4/lookup-api */ 0018 /* example http://malware.testing.google.test/testing/malware/ */ 0019 /** 0020 * @brief The CheckPhishingUrlJob class 0021 * @author Laurent Montel <montel@kde.org> 0022 */ 0023 class WEBENGINEVIEWER_EXPORT CheckPhishingUrlJob : public QObject 0024 { 0025 Q_OBJECT 0026 public: 0027 explicit CheckPhishingUrlJob(QObject *parent = nullptr); 0028 ~CheckPhishingUrlJob() override; 0029 0030 void setUrl(const QUrl &url); 0031 0032 void start(); 0033 [[nodiscard]] bool canStart() const; 0034 0035 [[nodiscard]] QByteArray jsonRequest() const; 0036 void parse(const QByteArray &replyStr); 0037 0038 Q_SIGNALS: 0039 void result(WebEngineViewer::CheckPhishingUrlUtil::UrlStatus status, const QUrl &url, uint verifyCacheAfterThisTime = 0); 0040 void debugJson(const QByteArray &ba); 0041 0042 private: 0043 WEBENGINEVIEWER_NO_EXPORT void slotSslErrors(QNetworkReply *reply, const QList<QSslError> &error); 0044 WEBENGINEVIEWER_NO_EXPORT void slotError(QNetworkReply::NetworkError error); 0045 WEBENGINEVIEWER_NO_EXPORT void slotCheckUrlFinished(QNetworkReply *reply); 0046 std::unique_ptr<CheckPhishingUrlJobPrivate> const d; 0047 }; 0048 }