File indexing completed on 2025-01-26 04:57:21
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 "webengineviewer_export.h" 0010 #include <QObject> 0011 #include <QUrl> 0012 #include <memory> 0013 0014 namespace WebEngineViewer 0015 { 0016 class CheckPhishingUrlCachePrivate; 0017 /** 0018 * @brief The CheckPhishingUrlCache class 0019 * @author Laurent Montel <montel@kde.org> 0020 */ 0021 class WEBENGINEVIEWER_EXPORT CheckPhishingUrlCache : public QObject 0022 { 0023 Q_OBJECT 0024 public: 0025 static CheckPhishingUrlCache *self(); 0026 0027 enum UrlStatus { 0028 UrlOk = 0, 0029 MalWare = 1, 0030 Unknown = 2, 0031 }; 0032 0033 explicit CheckPhishingUrlCache(QObject *parent = nullptr); 0034 ~CheckPhishingUrlCache() override; 0035 0036 /** 0037 * @brief addCheckingUrlResult cache url. If @p correctUrl is true we store as UrlOk otherwise MalWare 0038 * @param url 0039 * @param correctUrl 0040 */ 0041 void addCheckingUrlResult(const QUrl &url, bool correctUrl, uint cacheDuration = 0); 0042 /** 0043 * @brief urlStatus Return the status of cached Url. When we didn't stored it, it returns Unknown 0044 * @param url 0045 * @return the status of url 0046 */ 0047 [[nodiscard]] CheckPhishingUrlCache::UrlStatus urlStatus(const QUrl &url); 0048 0049 /** 0050 * @brief clearCache clear the cache and save result in config file. 0051 */ 0052 void clearCache(); 0053 0054 private: 0055 std::unique_ptr<CheckPhishingUrlCachePrivate> const d; 0056 }; 0057 } 0058 0059 Q_DECLARE_METATYPE(WebEngineViewer::CheckPhishingUrlCache::UrlStatus)