#include "downloadmanager.h" #include 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 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(); }