X-Git-Url: https://gitweb.stoutner.com/?a=blobdiff_plain;f=src%2Fhelpers%2FFilterListHelper.h;fp=src%2Fhelpers%2FFilterListHelper.h;h=5bd9ad261c146e2e0d01e17a162c33f10f5ebb55;hb=a44e607fb5398c80c5de2629017865ae749e8fbf;hp=0000000000000000000000000000000000000000;hpb=c5706a6ff3fbc42418e60b79fbe3f5c19396f7d2;p=PrivacyBrowserPC.git diff --git a/src/helpers/FilterListHelper.h b/src/helpers/FilterListHelper.h new file mode 100644 index 0000000..5bd9ad2 --- /dev/null +++ b/src/helpers/FilterListHelper.h @@ -0,0 +1,106 @@ +/* + * Copyright 2024 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. + * + * 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. + * + * You should have received a copy of the GNU General Public License + * along with Privacy Browser PC. If not, see . + */ + +#ifndef FILTERLISTHELPER_H +#define FILTERLISTHELPER_H + +// Application headers. +#include "structs/FilterListStruct.h" +#include "structs/RequestStruct.h" + +// Qt framework headers. +#include +#include + +class FilterListHelper +{ +public: + // The default constructor. + FilterListHelper(); + + // The public static disposition constant integers. + static const int DEFAULT = 0; + static const int ALLOWED = 1; + static const int BLOCKED = 2; + + // The public static sublist constant integers. + static const int MAIN_BLOCKLIST = 0; + + // The public variables. + FilterListStruct *easyListStructPointer; + FilterListStruct *easyPrivacyStructPointer; + FilterListStruct *fanboyAnnoyanceStructPointer; + FilterListStruct *ultraListStructPointer; + FilterListStruct *ultraPrivacyStructPointer; + + // The public functions. + bool checkFilterLists(QWebEngineUrlRequestInfo &urlRequestInfo, RequestStruct *requestStructPointer) const; + QString getDispositionString(int dispositionInt) const; + QString getNavigationTypeString(int navigationTypeInt) const; + QString getResourceTypeString(int resourceTypeInt) const; + QString getSublistName(int sublistInt) const; + +private: + // The private translated disposition strings. + QString DEFAULT_STRING; + QString ALLOWED_STRING; + QString BLOCKED_STRING; + + // The private translated navigation type strings. + QString NAVIGATION_TYPE_LINK; + QString NAVIGATION_TYPE_TYPED; + QString NAVIGATION_TYPE_FORM_SUBMITTED; + QString NAVIGATION_TYPE_BACK_FORWARD; + QString NAVIGATION_TYPE_RELOAD; + QString NAVIGATION_TYPE_REDIRECT; + QString NAVIGATION_TYPE_OTHER; + + // The private translated resource type strings. + QString RESOURCE_TYPE_MAIN_FRAME; + QString RESOURCE_TYPE_SUB_FRAME; + QString RESOURCE_TYPE_STYLESHEET; + QString RESOURCE_TYPE_SCRIPT; + QString RESOURCE_TYPE_IMAGE; + QString RESOURCE_TYPE_FONT_RESOURCE; + QString RESOURCE_TYPE_SUB_RESOURCE; + QString RESOURCE_TYPE_OBJECT; + QString RESOURCE_TYPE_MEDIA; + QString RESOURCE_TYPE_WORKER; + QString RESOURCE_TYPE_SHARED_WORKER; + QString RESOURCE_TYPE_PREFETCH; + QString RESOURCE_TYPE_FAVICON; + QString RESOURCE_TYPE_XHR; + QString RESOURCE_TYPE_PING; + QString RESOURCE_TYPE_SERVICE_WORKER; + QString RESOURCE_TYPE_CSP_REPORT; + QString RESOURCE_TYPE_PLUGIN_RESOURCE; + QString RESOURCE_TYPE_NAVIGATION_PRELOAD_MAIN_FRAME; + QString RESOURCE_TYPE_NAVIGATION_PRELOAD_SUB_FRAME; + QString RESOURCE_TYPE_UNKNOWN; + + // The private translated sublist strings. + QString MAIN_BLOCKLIST_STRING; + + // The private functions. + bool checkIndividualList(QWebEngineUrlRequestInfo &urlRequestInfo, RequestStruct *requestStructPointer, FilterListStruct *filterListStruct) const; + FilterListStruct* populateFilterList(const QString &filterListFileName) const; + void populateRequestStruct(RequestStruct *requestStructPointer, const int disposition, const QString &filterListTitle, const int sublistInt, const QString &appliedEntry, + const QString &originalEntry) const; +}; +#endif