X-Git-Url: https://gitweb.stoutner.com/?a=blobdiff_plain;f=src%2Fhelpers%2FFilterListHelper.h;h=5bd9ad261c146e2e0d01e17a162c33f10f5ebb55;hb=refs%2Fheads%2Fmaster;hp=f8bfdf1cc887810e37a6764c8f2b3b11b6fa2ada;hpb=f8f8d907d0caa128abf73696f812f8e92db812b7;p=PrivacyBrowserPC.git diff --git a/src/helpers/FilterListHelper.h b/src/helpers/FilterListHelper.h index f8bfdf1..4115ae1 100644 --- a/src/helpers/FilterListHelper.h +++ b/src/helpers/FilterListHelper.h @@ -1,29 +1,29 @@ -/* - * Copyright 2024 Soren Stoutner . +/* SPDX-License-Identifier: GPL-3.0-or-later + * SPDX-FileCopyrightText: 2024-2025 Soren Stoutner * * This file is part of Privacy Browser PC . * - * Privacy Browser PC is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. + * This program is free software: you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free Software + * Foundation, either version 3 of the License, or (at your option) any later + * version. * - * Privacy Browser PC is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. * - * You should have received a copy of the GNU General Public License - * along with Privacy Browser PC. If not, see . + * You should have received a copy of the GNU General Public License along with + * this program. If not, see . */ -#ifndef FILTERLISTHELPER_H -#define FILTERLISTHELPER_H +#ifndef FILTER_LIST_HELPER_H +#define FILTER_LIST_HELPER_H // Application headers. #include "structs/FilterListStruct.h" #include "structs/RequestStruct.h" -#include "structs/UrlStruct.h" +#include "widgets/PrivacyWebEngineView.h" // Qt framework headers. #include @@ -42,8 +42,11 @@ public: // The public static sublist constant integers. static const int MAIN_ALLOWLIST = 0; - static const int MAIN_BLOCKLIST = 1; - static const int INITIAL_DOMAIN_BLOCKLIST = 2; + static const int INITIAL_DOMAIN_ALLOWLIST = 1; + static const int REGULAR_EXPRESSION_ALLOWLIST = 2; + static const int MAIN_BLOCKLIST = 3; + static const int INITIAL_DOMAIN_BLOCKLIST = 4; + static const int REGULAR_EXPRESSION_BLOCKLIST = 5; // The public variables. FilterListStruct *easyListStructPointer; @@ -53,10 +56,10 @@ public: FilterListStruct *ultraPrivacyStructPointer; // The public functions. - bool checkFilterLists(QWebEngineUrlRequestInfo &urlRequestInfo, RequestStruct *requestStructPointer) const; + bool checkFilterLists(PrivacyWebEngineView *privacyWebEngineViewPointer, QWebEngineUrlRequestInfo &urlRequestInfo, RequestStruct *requestStructPointer) const; QString getDispositionString(int dispositionInt) const; - QString getFilterOptionDispositionString(const FilterOptionEnum::Disposition filterOptionDisposition) const; QString getNavigationTypeString(int navigationTypeInt) const; + QString getRequestOptionDispositionString(const FilterOptionDisposition filterOptionDisposition) const; QString getResourceTypeString(int resourceTypeInt) const; QString getSublistName(int sublistInt) const; @@ -80,7 +83,7 @@ private: QString NAVIGATION_TYPE_REDIRECT; QString NAVIGATION_TYPE_OTHER; - // The private translated resource type strings. + // The private translated resource type strings (in order of their values ). QString RESOURCE_TYPE_MAIN_FRAME; QString RESOURCE_TYPE_SUB_FRAME; QString RESOURCE_TYPE_STYLESHEET; @@ -101,22 +104,31 @@ private: QString RESOURCE_TYPE_PLUGIN_RESOURCE; QString RESOURCE_TYPE_NAVIGATION_PRELOAD_MAIN_FRAME; QString RESOURCE_TYPE_NAVIGATION_PRELOAD_SUB_FRAME; + QString RESOURCE_TYPE_WEB_SOCKET; QString RESOURCE_TYPE_UNKNOWN; + QString RESOURCE_TYPE_JSON; // The private translated sublist strings. QString MAIN_ALLOWLIST_STRING; + QString INITIAL_DOMAIN_ALLOWLIST_STRING; + QString REGULAR_EXPRESSION_ALLOWLIST_STRING; QString MAIN_BLOCKLIST_STRING; QString INITIAL_DOMAIN_BLOCKLIST_STRING; + QString REGULAR_EXPRESSION_BLOCKLIST_STRING; // The private functions. - bool blockRequest(QWebEngineUrlRequestInfo &urlRequestInfo, RequestStruct *requestStructPointer, const QString &filterListTitle, const int sublistInt, EntryStruct *entryStructPointer) const; - bool checkIndividualList(QWebEngineUrlRequestInfo &urlRequestInfo, UrlStruct &urlStruct, RequestStruct *requestStructPointer, FilterListStruct *filterListStructPointer) const; - bool checkThirdParty(QWebEngineUrlRequestInfo &urlRequestInfo, RequestStruct *requestStructPointer, const bool isThirdPartyRequest, const QString &filterListTitle, const int sublistInt, - EntryStruct *entryStructPointer) const; + bool checkAppliedEntry(QWebEngineUrlRequestInfo &urlRequestInfo, RequestStruct *requestStructPointer, const QString &filterListTitle, const int sublistInt, QString urlString, + const RequestUrlType requestUrlType, EntryStruct *entryStructPointer) const; + bool checkDomain(QWebEngineUrlRequestInfo &urlRequestInfo, RequestStruct *requestStructPointer, const QString &filterListTitle, const int sublistInt, + EntryStruct *entryStructPointer) const; + bool checkIndividualList(QWebEngineUrlRequestInfo &urlRequestInfo, RequestStruct *requestStructPointer, FilterListStruct *filterListStructPointer) const; + bool checkRegularExpression(QWebEngineUrlRequestInfo &urlRequestInfo, RequestStruct *requestStructPointer, const QString &filterListTitle, const int sublistInt, + EntryStruct *entryStructPointer) const; + bool checkRequestOptions(QWebEngineUrlRequestInfo &urlRequestInfo, RequestStruct *requestStructPointer, const QString &filterListTitle, const int sublistInt, + EntryStruct *entryStructPointer) const; + bool checkThirdParty(QWebEngineUrlRequestInfo &urlRequestInfo, RequestStruct *requestStructPointer, const QString &filterListTitle, const int sublistInt, EntryStruct *entryStructPointer) const; FilterListStruct* populateFilterList(const QString &filterListFileName) const; - void populateRequestStruct(RequestStruct *requestStructPointer, const int disposition, const QString &filterListTitle, const int sublistInt, EntryStruct *entryStructPointer) const; - bool processFilterOptions(QWebEngineUrlRequestInfo &urlRequestInfo, RequestStruct *requestStructPointer, const QString &filterListTitle, const int sublistInt, - EntryStruct *entryStructPointer) const; - void removeInitialAndTrailingAsterisks(QString &filterListEntry) const; + void prepareFilterListString(QString &filterListString, EntryStruct *entryStructPointer) const; + bool processRequest(QWebEngineUrlRequestInfo &urlRequestInfo, RequestStruct *requestStructPointer, const QString &filterListTitle, const int sublistInt, EntryStruct *entryStructPointer) const; }; #endif