File indexing completed on 2024-05-12 05:11:13

0001 /*
0002     SPDX-FileCopyrightText: 2009 Constantin Berzan <exit3219@gmail.com>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #include "abort.h"
0008 
0009 #include <QTimer>
0010 
0011 #include <QApplication>
0012 #include <QDebug>
0013 
0014 #include <Akonadi/Control>
0015 
0016 #include <Akonadi/DispatcherInterface>
0017 
0018 using namespace Akonadi;
0019 using namespace Akonadi;
0020 
0021 Runner::Runner()
0022 {
0023     Control::start();
0024 
0025     QTimer::singleShot(0, this, &Runner::sendAbort);
0026 }
0027 
0028 void Runner::sendAbort()
0029 {
0030     const AgentInstance mda = DispatcherInterface().dispatcherInstance();
0031     if (!mda.isValid()) {
0032         qDebug() << "Invalid instance; waiting.";
0033         QTimer::singleShot(1000, this, &Runner::sendAbort);
0034         return;
0035     }
0036 
0037     mda.abortCurrentTask();
0038     qDebug() << "Told the MDA to abort.";
0039     QApplication::exit(0);
0040 }
0041 
0042 int main(int argc, char **argv)
0043 {
0044     QApplication::setApplicationName(QStringLiteral("Abort"));
0045     QApplication app(argc, argv);
0046 
0047     new Runner();
0048     return app.exec();
0049 }
0050 
0051 #include "moc_abort.cpp"