-
Notifications
You must be signed in to change notification settings - Fork 0
/
nologind.cpp
41 lines (34 loc) · 1.34 KB
/
nologind.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
#include <QCoreApplication>
#include <QtDBus>
#include "manager.h"
#define LOGIN1_SERVICE "org.freedesktop.login1"
#define LOGIN1_PATH "/login1"
#define LOGIN1_FULL_PATH "/org/freedesktop/login1"
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
QCoreApplication::setOrganizationDomain("org");
QCoreApplication::setApplicationName("freedesktop.login1");
if (!QDBusConnection::systemBus().isConnected()) {
qWarning("Cannot connect to the D-Bus system bus.");
return 1;
}
if (!QDBusConnection::systemBus().registerService(LOGIN1_SERVICE)) {
qWarning() << QDBusConnection::systemBus().lastError().message();
return 1;
}
Manager man;
if (!QDBusConnection::systemBus().registerObject(LOGIN1_PATH,
&man,
QDBusConnection::ExportAllContents)) {
qWarning() << QDBusConnection::systemBus().lastError().message();
return 1;
}
if (!QDBusConnection::systemBus().registerObject(LOGIN1_FULL_PATH,
&man,
QDBusConnection::ExportAllContents)) {
qWarning() << QDBusConnection::systemBus().lastError().message();
return 1;
}
return a.exec();
}