Skip to content

Commit 9b4b12e

Browse files
committed
Revert removal of ConsoleKit support.
ConsoleKit has recently been forked for XFCE and Illumos is using ConsoleKit + LightDM. http://lists.freedesktop.org/archives/lightdm/2014-November/000731.html
1 parent cfceaf6 commit 9b4b12e

34 files changed

+1118
-42
lines changed

debian/control

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,11 @@ Conflicts: liblightdm-gobject-0-0,
4747
liblightdm-qt-0-0,
4848
Provides: x-display-manager
4949
Description: Display Manager
50-
LightDM is a display manager that:
51-
* Is cross-desktop - supports different desktops
52-
* Supports different display technologies
53-
* Is lightweight - low memory usage and fast performance
54-
* Has a comprehensive test suite
55-
* Has low code complexity
50+
LightDM is a X display manager that:
51+
* Has a lightweight codebase
52+
* Is standards compliant (PAM, ConsoleKit, etc)
53+
* Has a well defined interface between the server and user interface
54+
* Cross-desktop (greeters can be written in any toolkit)
5655

5756
Package: liblightdm-gobject-1-0
5857
Architecture: any

liblightdm-gobject/power.c

Lines changed: 63 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include "lightdm/power.h"
1717

1818
static GDBusProxy *upower_proxy = NULL;
19+
static GDBusProxy *ck_proxy = NULL;
1920
static GDBusProxy *login1_proxy = NULL;
2021

2122
static GVariant *
@@ -204,6 +205,36 @@ lightdm_hibernate (GError **error)
204205
return hibernated;
205206
}
206207

208+
static GVariant *
209+
ck_call_function (const gchar *function, GError **error)
210+
{
211+
GVariant *r;
212+
213+
if (!ck_proxy)
214+
{
215+
ck_proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
216+
G_DBUS_PROXY_FLAGS_NONE,
217+
NULL,
218+
"org.freedesktop.ConsoleKit",
219+
"/org/freedesktop/ConsoleKit/Manager",
220+
"org.freedesktop.ConsoleKit.Manager",
221+
NULL,
222+
error);
223+
if (!ck_proxy)
224+
return FALSE;
225+
}
226+
227+
r = g_dbus_proxy_call_sync (ck_proxy,
228+
function,
229+
NULL,
230+
G_DBUS_CALL_FLAGS_NONE,
231+
-1,
232+
NULL,
233+
error);
234+
235+
return r;
236+
}
237+
207238
/**
208239
* lightdm_get_can_restart:
209240
*
@@ -226,8 +257,15 @@ lightdm_get_can_restart (void)
226257
g_variant_get (r, "(&s)", &result);
227258
can_restart = g_strcmp0 (result, "yes") == 0;
228259
}
260+
}
261+
else
262+
{
263+
r = ck_call_function ("CanRestart", NULL);
264+
if (r && g_variant_is_of_type (r, G_VARIANT_TYPE ("(b)")))
265+
g_variant_get (r, "(b)", &can_restart);
266+
}
267+
if (r)
229268
g_variant_unref (r);
230-
}
231269

232270
return can_restart;
233271
}
@@ -244,15 +282,19 @@ gboolean
244282
lightdm_restart (GError **error)
245283
{
246284
GVariant *r;
285+
gboolean restarted;
247286

248287
r = login1_call_function ("Reboot", g_variant_new("(b)", FALSE), error);
249-
if (r)
288+
if (!r)
250289
{
251-
g_variant_unref (r);
252-
return TRUE;
290+
g_clear_error (error);
291+
r = ck_call_function ("Restart", error);
253292
}
293+
restarted = r != NULL;
294+
if (r)
295+
g_variant_unref (r);
254296

255-
return FALSE;
297+
return restarted;
256298
}
257299

258300
/**
@@ -277,8 +319,15 @@ lightdm_get_can_shutdown (void)
277319
g_variant_get (r, "(&s)", &result);
278320
can_shutdown = g_strcmp0 (result, "yes") == 0;
279321
}
280-
g_variant_unref (r);
281322
}
323+
else
324+
{
325+
r = ck_call_function ("CanStop", NULL);
326+
if (r && g_variant_is_of_type (r, G_VARIANT_TYPE ("(b)")))
327+
g_variant_get (r, "(b)", &can_shutdown);
328+
}
329+
if (r)
330+
g_variant_unref (r);
282331

283332
return can_shutdown;
284333
}
@@ -295,13 +344,17 @@ gboolean
295344
lightdm_shutdown (GError **error)
296345
{
297346
GVariant *r;
347+
gboolean shutdown;
298348

299349
r = login1_call_function ("PowerOff", g_variant_new("(b)", FALSE), error);
300-
if (r)
350+
if (!r)
301351
{
302-
g_variant_unref (r);
303-
return TRUE;
352+
g_clear_error (error);
353+
r = ck_call_function ("Stop", error);
304354
}
355+
shutdown = r != NULL;
356+
if (r)
357+
g_variant_unref (r);
305358

306-
return FALSE;
359+
return shutdown;
307360
}

liblightdm-qt/power.cpp

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,13 @@ class PowerInterface::PowerInterfacePrivate
2626
public:
2727
PowerInterfacePrivate();
2828
QScopedPointer<QDBusInterface> powerManagementInterface;
29+
QScopedPointer<QDBusInterface> consoleKitInterface;
2930
QScopedPointer<QDBusInterface> login1Interface;
3031
};
3132

3233
PowerInterface::PowerInterfacePrivate::PowerInterfacePrivate() :
3334
powerManagementInterface(new QDBusInterface("org.freedesktop.UPower","/org/freedesktop/UPower", "org.freedesktop.UPower", QDBusConnection::systemBus())),
35+
consoleKitInterface(new QDBusInterface("org.freedesktop.ConsoleKit", "/org/freedesktop/ConsoleKit/Manager", "org.freedesktop.ConsoleKit.Manager", QDBusConnection::systemBus())),
3436
login1Interface(new QDBusInterface("org.freedesktop.login1", "/org/freedesktop/login1", "org.freedesktop.login1.Manager", QDBusConnection::systemBus()))
3537
{
3638
}
@@ -115,9 +117,17 @@ bool PowerInterface::hibernate()
115117

116118
bool PowerInterface::canShutdown()
117119
{
118-
QDBusReply<QString> reply1 = d->login1Interface->call("CanPowerOff");
119-
if (reply1.isValid()) {
120-
return reply1.value() == "yes";
120+
if (d->login1Interface->isValid()) {
121+
QDBusReply<QString> reply1 = d->login1Interface->call("CanPowerOff");
122+
if (reply1.isValid()) {
123+
return reply1.value() == "yes";
124+
}
125+
}
126+
qWarning() << d->login1Interface->lastError();
127+
128+
QDBusReply<bool> reply = d->consoleKitInterface->call("CanStop");
129+
if (reply.isValid()) {
130+
return reply.value();
121131
}
122132

123133
return false;
@@ -126,15 +136,26 @@ bool PowerInterface::canShutdown()
126136
bool PowerInterface::shutdown()
127137
{
128138
QDBusReply<void> reply;
129-
reply = d->login1Interface->call("PowerOff", false);
139+
if (d->login1Interface->isValid())
140+
reply = d->login1Interface->call("PowerOff", false);
141+
else
142+
reply = d->consoleKitInterface->call("Stop");
130143
return reply.isValid();
131144
}
132145

133146
bool PowerInterface::canRestart()
134147
{
135-
QDBusReply<QString> reply1 = d->login1Interface->call("CanReboot");
136-
if (reply1.isValid()) {
137-
return reply1.value() == "yes";
148+
if (d->login1Interface->isValid()) {
149+
QDBusReply<QString> reply1 = d->login1Interface->call("CanReboot");
150+
if (reply1.isValid()) {
151+
return reply1.value() == "yes";
152+
}
153+
}
154+
qWarning() << d->login1Interface->lastError();
155+
156+
QDBusReply<bool> reply = d->consoleKitInterface->call("CanRestart");
157+
if (reply.isValid()) {
158+
return reply.value();
138159
}
139160

140161
return false;
@@ -143,7 +164,10 @@ bool PowerInterface::canRestart()
143164
bool PowerInterface::restart()
144165
{
145166
QDBusReply<void> reply;
146-
reply = d->login1Interface->call("Reboot", false);
167+
if (d->login1Interface->isValid())
168+
reply = d->login1Interface->call("Reboot", false);
169+
else
170+
reply = d->consoleKitInterface->call("Restart");
147171
return reply.isValid();
148172
}
149173

src/Makefile.am

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ bin_PROGRAMS = dm-tool
44
lightdm_SOURCES = \
55
accounts.c \
66
accounts.h \
7+
console-kit.c \
8+
console-kit.h \
79
display-manager.c \
810
display-manager.h \
911
display-server.c \

0 commit comments

Comments
 (0)