diff options
Diffstat (limited to 'staging/adblock/filterlist.h')
-rw-r--r-- | staging/adblock/filterlist.h | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/staging/adblock/filterlist.h b/staging/adblock/filterlist.h new file mode 100644 index 0000000..24464c8 --- /dev/null +++ b/staging/adblock/filterlist.h @@ -0,0 +1,54 @@ +/* + * This file is part of smolbote. It's copyrighted by the contributors recorded + * in the version control history of the file, available from its original + * location: https://library.iserlohn-fortress.net/aqua/smolbote.git + * + * SPDX-License-Identifier: GPL-3.0 + */ + +#include "rule.h" +#include <QDateTime> +#include <QObject> +#include <QString> +#include <QStringList> +#include <QVector> +#include <smolbote/filterinterface.hpp> + +namespace AdblockPlus +{ +class FilterList : public Filter +{ +public: + explicit FilterList(QIODevice &from); + ~FilterList() + { + qDeleteAll(m_rules); + } + + bool filter(QWebEngineUrlRequestInfo &info) const override; + bool isUpToDate() const override + { + const auto current = QDateTime::currentDateTime(); + return expires > current; + } + + QDateTime modified() const + { + return lastModified; + } + QDateTime expiresOn() const + { + return expires; + } + + [[nodiscard]] static Rule *parseRule(const QByteArray &line); + +private: + void parseComment(const QString &line); + + QDateTime lastModified; + QDateTime expires; + QVector<AdblockPlus::Rule *> m_rules; +}; + +} // namespace AdblockPlus |