-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.cpp
42 lines (34 loc) · 1.04 KB
/
main.cpp
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
32
33
34
35
36
37
38
39
40
41
42
#include "bot.h"
#include <QCoreApplication>
#include <string.h>
int main(int argc, char *argv[])
{
QCoreApplication app(argc, argv);
QString configurationFileName = "botSettings.ini";
if ( argc == 3 )
{
if ( strcmp( argv[1], "-c" ) == 0 )
{
configurationFileName = argv[2];
}
else
{
qDebug() <<"Usage is: ./bot -c configFile.ini ";
exit(1);
}
}
Bot bot( configurationFileName );
if (!QDBusConnection::sessionBus().isConnected()) {
fprintf(stderr, "Cannot connect to the D-Bus session bus.\n"
"To start it, run:\n"
"\teval `dbus-launch --auto-syntax`\n");
}
if (!QDBusConnection::sessionBus().registerService(bot.serviceName())) {
fprintf(stderr, "%s\n",
qPrintable(QDBusConnection::sessionBus().lastError().message()));
exit(1);
}
QDBusConnection::sessionBus().registerObject("/", &bot, QDBusConnection::ExportAllSlots);
qDebug() <<"Listening on DBUS...";
return app.exec();
}