Plasma-workspace

login1_manager_interface.cpp
1/*
2 SPDX-FileCopyrightText: 2019 David Edmundson <daviedmundson@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-only
5*/
6
7// This file overrides the auto-generated login1_manager_interface.cpp in order
8// change the interface name and act as a completely transparent Logind1 / CK2 wrapper
9
10#include "login1_manager_interface.h"
11#include "sessionmanagementbackend.h"
12
13enum LogindProvider {
14 Unknown,
15 None,
16 ConsoleKit2,
17 Logind1,
18};
19static LogindProvider s_mode = Unknown;
20
21static LogindProvider getLogindMode()
22{
23 if (s_mode != Unknown) {
24 return s_mode;
25 }
26 if (QDBusConnection::systemBus().interface()->isServiceRegistered(QStringLiteral("org.freedesktop.login1"))) {
27 s_mode = Logind1;
28 } else if (QDBusConnection::systemBus().interface()->isServiceRegistered(QStringLiteral("org.freedesktop.ConsoleKit"))) {
29 s_mode = ConsoleKit2;
30 } else {
31 s_mode = None;
32 }
33 return s_mode;
34}
35
36bool LogindSessionBackend::exists()
37{
38 return getLogindMode() != None;
39}
40
41OrgFreedesktopLogin1ManagerInterface::OrgFreedesktopLogin1ManagerInterface(const QString &, const QString &, const QDBusConnection &connection, QObject *parent)
42 : QDBusAbstractInterface(getLogindMode() == Logind1 ? QStringLiteral("org.freedesktop.login1") : QStringLiteral("org.freedesktop.ConsoleKit"),
43 getLogindMode() == Logind1 ? QStringLiteral("/org/freedesktop/login1") : QStringLiteral("/org/freedesktop/ConsoleKit/Manager"),
44 getLogindMode() == Logind1 ? "org.freedesktop.login1.Manager" : "org.freedesktop.ConsoleKit.Manager",
45 connection,
46 parent)
47{
48}
49
50OrgFreedesktopLogin1ManagerInterface::~OrgFreedesktopLogin1ManagerInterface()
51{
52}
53
54#include "login1_manager_interface.moc"
55
56#include "moc_login1_manager_interface.cpp"
QDBusConnection systemBus()
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Dec 20 2024 12:00:00 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.