summaryrefslogtreecommitdiffstats
path: root/client/main.cpp
blob: 4f86792b7bb79e7b055f4d9f3a6d390df63efc7c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <QApplication>
#include <QCommandLineParser>

#include "common/console.h"
#include "resourceaccess.h"

int main(int argc, char *argv[])
{
    QApplication app(argc, argv);

    new Akonadi2::Console("Akonadi2 Client");

    QCommandLineParser cliOptions;
    cliOptions.addPositionalArgument(QObject::tr("[resource]"),
                                     QObject::tr("A resource to connect to"));
    cliOptions.process(app);
    QStringList resources = cliOptions.positionalArguments();
    if (resources.isEmpty()) {
        resources << "toy";
    }

    for (const QString &resource: resources) {
        Akonadi2::ResourceAccess *resAccess = new Akonadi2::ResourceAccess(resource);
        QObject::connect(&app, &QCoreApplication::aboutToQuit,
                        resAccess, &Akonadi2::ResourceAccess::close);
        resAccess->open();
    }

    return app.exec();
}