File indexing completed on 2024-07-21 04:35:14

0001 /*
0002     SPDX-FileCopyrightText: 2024 Ralf Habacker ralf.habacker @freenet.de
0003 
0004     This file is part of libalkimia.
0005 
0006     SPDX-License-Identifier: LGPL-2.1-or-later
0007 */
0008 
0009 #include "alknewstuffengine.h"
0010 
0011 #include <QApplication>
0012 #include <QObject>
0013 #include <QtDebug>
0014 
0015 class TestReceiver : public QObject
0016 {
0017     Q_OBJECT
0018 Q_SIGNALS:
0019     void finished();
0020 
0021 public Q_SLOTS:
0022     void updatesAvailable(const AlkNewStuffEntryList &entries)
0023     {
0024         for (const AlkNewStuffEntry &entry : entries) {
0025             qDebug() << Q_FUNC_INFO << entry.name;
0026         }
0027         Q_EMIT finished();
0028     }
0029 };
0030 
0031 int main(int argc, char *argv[])
0032 {
0033     QCoreApplication app(argc, argv);
0034 
0035     QString configFile = QString("%1/%2").arg(KNSRC_DIR, "alkimia-quotes.knsrc");
0036 
0037     TestReceiver receiver;
0038     AlkNewStuffEngine engine(&receiver);
0039     QEventLoop loop;
0040 
0041 #if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
0042     QObject::connect(&engine, &AlkNewStuffEngine::updatesAvailable, &receiver, &TestReceiver::updatesAvailable);
0043     QObject::connect(&receiver, &TestReceiver::finished, &loop, &QEventLoop::quit);
0044 #else
0045     QObject::connect(&engine, SIGNAL(updatesAvailable(const AlkNewStuffEntryList &)), &receiver, SLOT(updatesAvailable(const AlkNewStuffEntryList &)));
0046     QObject::connect(&receiver, SIGNAL(finished()), &loop, SLOT(quit()));
0047 #endif
0048     engine.init(configFile);
0049     engine.checkForUpdates();
0050 
0051     loop.exec();
0052 }
0053 
0054 #include "alknewstuffenginetest.moc"