diff options
Diffstat (limited to 'examples/client/main.cpp')
-rw-r--r-- | examples/client/main.cpp | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/examples/client/main.cpp b/examples/client/main.cpp new file mode 100644 index 0000000..b4cb081 --- /dev/null +++ b/examples/client/main.cpp | |||
@@ -0,0 +1,52 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2014 Aaron Seigo <aseigo@kde.org> | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or modify | ||
5 | * it under the terms of the GNU General Public License as published by | ||
6 | * the Free Software Foundation; either version 2 of the License, or | ||
7 | * (at your option) any later version. | ||
8 | * | ||
9 | * This program is distributed in the hope that it will be useful, | ||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | * GNU General Public License for more details. | ||
13 | * | ||
14 | * You should have received a copy of the GNU General Public License | ||
15 | * along with this program; if not, write to the | ||
16 | * Free Software Foundation, Inc., | ||
17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
18 | */ | ||
19 | |||
20 | #include <QApplication> | ||
21 | #include <QCommandLineParser> | ||
22 | |||
23 | #include "common/commands.h" | ||
24 | #include "common/console.h" | ||
25 | #include "common/resourceaccess.h" | ||
26 | |||
27 | int main(int argc, char *argv[]) | ||
28 | { | ||
29 | QApplication app(argc, argv); | ||
30 | |||
31 | new Akonadi2::Console("Akonadi2 Client"); | ||
32 | Akonadi2::Console::main()->log(QString("PID: %1").arg(QCoreApplication::applicationPid())); | ||
33 | |||
34 | QCommandLineParser cliOptions; | ||
35 | cliOptions.addPositionalArgument(QObject::tr("[resource]"), | ||
36 | QObject::tr("A resource to connect to")); | ||
37 | cliOptions.process(app); | ||
38 | QStringList resources = cliOptions.positionalArguments(); | ||
39 | if (resources.isEmpty()) { | ||
40 | resources << "org.kde.dummy"; | ||
41 | } | ||
42 | |||
43 | for (const QString &resource: resources) { | ||
44 | Akonadi2::ResourceAccess *resAccess = new Akonadi2::ResourceAccess(resource.toLatin1()); | ||
45 | QObject::connect(&app, &QCoreApplication::aboutToQuit, | ||
46 | resAccess, &Akonadi2::ResourceAccess::close); | ||
47 | resAccess->sendCommand(Akonadi2::Commands::SynchronizeCommand); | ||
48 | resAccess->open(); | ||
49 | } | ||
50 | |||
51 | return app.exec(); | ||
52 | } | ||