diff options
Diffstat (limited to 'staging/filterlist')
-rw-r--r-- | staging/filterlist/downloadmanager.cpp | 53 | ||||
-rw-r--r-- | staging/filterlist/downloadmanager.h | 21 | ||||
-rw-r--r-- | staging/filterlist/meson.build | 24 | ||||
-rw-r--r-- | staging/filterlist/test/main.cpp | 44 | ||||
-rw-r--r-- | staging/filterlist/test/parser.cpp | 37 | ||||
-rw-r--r-- | staging/filterlist/test/sample-filters.txt | 12 |
6 files changed, 0 insertions, 191 deletions
diff --git a/staging/filterlist/downloadmanager.cpp b/staging/filterlist/downloadmanager.cpp deleted file mode 100644 index bbc9287..0000000 --- a/staging/filterlist/downloadmanager.cpp +++ /dev/null @@ -1,53 +0,0 @@ -/* - * 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 "downloadmanager.h" - -QString saveFileName(const QUrl &url, const QString &filename) -{ - if(!filename.isEmpty()) - return filename; - - QString path = url.path(); - QString basename = QFileInfo(path).fileName(); - - if(basename.isEmpty()) - basename = "download"; - - return basename; -} - -DownloadManager::DownloadManager(QObject *parent) - : QObject(parent) -{ -} - -QNetworkReply *DownloadManager::download(const QUrl &url, const QString &filename) -{ - auto *file = new QFile(saveFileName(url, filename), this); - if(!file->open(QIODevice::WriteOnly)) { - delete file; - return nullptr; - } - - QNetworkRequest request(url); - QNetworkReply *reply = manager.get(request); - - connect(reply, &QNetworkReply::readyRead, this, [reply, file]() { - file->write(reply->readAll()); - }); - - connect(reply, &QNetworkReply::finished, this, [reply, file]() { - file->write(reply->readAll()); - file->close(); - file->deleteLater(); - reply->deleteLater(); - }); - - return reply; -} diff --git a/staging/filterlist/downloadmanager.h b/staging/filterlist/downloadmanager.h deleted file mode 100644 index edc011d..0000000 --- a/staging/filterlist/downloadmanager.h +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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 <QtNetwork> - -class DownloadManager : public QObject -{ - Q_OBJECT - -public: - DownloadManager(QObject *parent = nullptr); - QNetworkReply *download(const QUrl &url, const QString &filename = QString()); - -private: - QNetworkAccessManager manager; -}; diff --git a/staging/filterlist/meson.build b/staging/filterlist/meson.build deleted file mode 100644 index eb5b61f..0000000 --- a/staging/filterlist/meson.build +++ /dev/null @@ -1,24 +0,0 @@ -dep_staging_utils = declare_dependency( - include_directories: include_directories('.'), - link_with: static_library('staging-utils', - [ 'downloadmanager.cpp', - mod_qt5.preprocess(moc_headers: 'downloadmanager.h') - ], - dependencies: dep_qt5 - ) -) - -executable('filterlist', - dependencies: [ dep_qt5, dep_staging_utils ], - sources: [ 'test/main.cpp' ] -) - -#test('adblockfilter: parser', -# executable('adblockfilter-parsefilter', -# dependencies: [ dep_qt5, dep_gtest, dep_adblockfilter ], -# sources: [ 'test/parser.cpp' ] -# ), -# workdir: meson.current_source_dir() / 'test', -# should_fail: true -#) - diff --git a/staging/filterlist/test/main.cpp b/staging/filterlist/test/main.cpp deleted file mode 100644 index ccaae47..0000000 --- a/staging/filterlist/test/main.cpp +++ /dev/null @@ -1,44 +0,0 @@ -#include "downloadmanager.h" -#include <QtCore> - -int main(int argc, char **argv) -{ - if(argc != 2) { - qDebug("Usage: %s filters.txt", argv[0]); - return 77; - } - - QCoreApplication app(argc, argv); - - DownloadManager manager; - QSettings listconf(argv[1], QSettings::IniFormat); - - QVector<QNetworkReply *> downloads; - - qDebug("Filters:"); - for(auto &g : listconf.childGroups()) { - listconf.beginGroup(g); - const auto url = listconf.value("Href").toUrl(); - qDebug("|%s |%s|", qUtf8Printable(g.leftJustified(16, ' ', true)), qUtf8Printable(listconf.value("Href").toString().leftJustified(100, ' ', true))); - auto *reply = manager.download(url); - downloads.append(reply); - - QObject::connect(reply, &QNetworkReply::finished, [&downloads, reply]() { - if(reply->error() == QNetworkReply::NoError) { - qDebug("downloaded %s", qUtf8Printable(reply->url().toString())); - } else { - qDebug("failed %s", qUtf8Printable(reply->url().toString())); - qDebug("error [%i]: %s", reply->error(), qUtf8Printable(reply->errorString())); - } - - downloads.removeAll(reply); - if(downloads.isEmpty()) { - QCoreApplication::instance()->quit(); - } - }); - listconf.endGroup(); - } - qDebug("---"); - - return app.exec(); -} diff --git a/staging/filterlist/test/parser.cpp b/staging/filterlist/test/parser.cpp deleted file mode 100644 index 2b925e0..0000000 --- a/staging/filterlist/test/parser.cpp +++ /dev/null @@ -1,37 +0,0 @@ -#include "filterlist.h" -#include <QFile> -#include <QTextStream> -#include "plugin/plugin.h" - -int main(int argc, char **argv) -{ - if(argc < 2) { - qDebug("usage: %s list1.txt ...", argv[0]); - return 77; - } - - for(int i = 1; i < argc; ++i) { - QFile f(argv[i]); - if(!f.open(QIODevice::ReadOnly | QIODevice::Text)) { - qDebug("could not open %s", argv[i]); - return -1; - } - - AdblockPlusFilterPlugin p; - auto *l = p.load(&f); -/* - AdblockPlus::FilterList list; - QTextStream stream(&f); - const auto result = list.parse(stream); - qDebug("[%s]: %s", argv[i], (result.state == AdblockPlus::FilterList::Ok) ? "okay" : "failed"); - qDebug(" total: %i\t\tmodified: %s", result.lines_total, qUtf8Printable(list.modified().toString())); - qDebug("comments: %i\t\t expires: %s", result.lines_comments, qUtf8Printable(list.expiresOn().toString())); - qDebug(" ignored: %i\t\t valid: %s", result.lines_ignored, list.isUpToDate() ? "yes" : "no"); - qDebug(" parsed: %i", result.lines_parsed); - qDebug(" failed: %i", result.lines_failed); - qDebug("-------- --------"); -*/ - f.close(); - } - return 0; -} diff --git a/staging/filterlist/test/sample-filters.txt b/staging/filterlist/test/sample-filters.txt deleted file mode 100644 index a7c04fa..0000000 --- a/staging/filterlist/test/sample-filters.txt +++ /dev/null @@ -1,12 +0,0 @@ -[easylist] -Title = -Href = https://easylist.to/easylist/easylist.txt -Updated = -Valid = - -[easylist-noelemhide] -Title = -Href = https://easylist-downloads.adblockplus.org/easylist_noelemhide.txt -Updated = -Valid = - |