Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 468916
Collapse All | Expand All

(-)a/libs/kworkspace/kdisplaymanager.cpp (-83 / +334 lines)
Lines 40-45 Link Here
40
#include <errno.h>
40
#include <errno.h>
41
#include <stdio.h>
41
#include <stdio.h>
42
42
43
#define _DBUS_PROPERTIES_IFACE "org.freedesktop.DBus.Properties"
44
#define _DBUS_PROPERTIES_GET "Get"
45
46
#define DBUS_PROPERTIES_IFACE QLatin1String(_DBUS_PROPERTIES_IFACE)
47
#define DBUS_PROPERTIES_GET QLatin1String(_DBUS_PROPERTIES_GET)
48
49
#define _SYSTEMD_SERVICE "org.freedesktop.login1"
50
#define _SYSTEMD_BASE_PATH "/org/freedesktop/login1"
51
#define _SYSTEMD_MANAGER_IFACE _SYSTEMD_SERVICE ".Manager"
52
#define _SYSTEMD_SESSION_BASE_PATH _SYSTEMD_BASE_PATH "/Session"
53
#define _SYSTEMD_SEAT_IFACE _SYSTEMD_SERVICE ".Seat"
54
#define _SYSTEMD_SEAT_BASE_PATH _SYSTEMD_BASE_PATH "/Seat"
55
#define _SYSTEMD_SESSION_IFACE _SYSTEMD_SERVICE ".Session"
56
#define _SYSTEMD_USER_PROPERTY "User"
57
#define _SYSTEMD_SEAT_PROPERTY "Seat"
58
#define _SYSTEMD_SESSIONS_PROPERTY "Sessions"
59
#define _SYSTEMD_SWITCH_PROPERTY "Activate"
60
61
#define SYSTEMD_SERVICE QLatin1String(_SYSTEMD_SERVICE)
62
#define SYSTEMD_BASE_PATH QLatin1String(_SYSTEMD_BASE_PATH)
63
#define SYSTEMD_MANAGER_IFACE QLatin1String(_SYSTEMD_MANAGER_IFACE)
64
#define SYSTEMD_SESSION_BASE_PATH QLatin1String(_SYSTEMD_SESSION_BASE_PATH)
65
#define SYSTEMD_SEAT_IFACE QLatin1String(_SYSTEMD_SEAT_IFACE)
66
#define SYSTEMD_SEAT_BASE_PATH QLatin1String(_SYSTEMD_SEAT_BASE_PATH)
67
#define SYSTEMD_SESSION_IFACE QLatin1String(_SYSTEMD_SESSION_IFACE)
68
#define SYSTEMD_USER_PROPERTY QLatin1String(_SYSTEMD_USER_PROPERTY)
69
#define SYSTEMD_SEAT_PROPERTY QLatin1String(_SYSTEMD_SEAT_PROPERTY)
70
#define SYSTEMD_SESSIONS_PROPERTY QLatin1String(_SYSTEMD_SESSIONS_PROPERTY)
71
#define SYSTEMD_SWITCH_CALL QLatin1String(_SYSTEMD_SWITCH_PROPERTY)
72
73
struct NamedDBusObjectPath
74
{
75
    QString name;
76
    QDBusObjectPath path;
77
};
78
Q_DECLARE_METATYPE(NamedDBusObjectPath)
79
Q_DECLARE_METATYPE(QList<NamedDBusObjectPath>)
80
81
// Marshall the NamedDBusObjectPath data into a D-Bus argument
82
QDBusArgument &operator<<(QDBusArgument &argument, const NamedDBusObjectPath &namedPath)
83
{
84
    argument.beginStructure();
85
    argument << namedPath.name << namedPath.path;
86
    argument.endStructure();
87
    return argument;
88
}
89
90
// Retrieve the NamedDBusObjectPath data from the D-Bus argument
91
const QDBusArgument &operator>>(const QDBusArgument &argument, NamedDBusObjectPath &namedPath)
92
{
93
    argument.beginStructure();
94
    argument >> namedPath.name >> namedPath.path;
95
    argument.endStructure();
96
    return argument;
97
}
98
99
struct NumberedDBusObjectPath
100
{
101
    uint num;
102
    QDBusObjectPath path;
103
};
104
Q_DECLARE_METATYPE(NumberedDBusObjectPath)
105
106
// Marshall the NumberedDBusObjectPath data into a D-Bus argument
107
QDBusArgument &operator<<(QDBusArgument &argument, const NumberedDBusObjectPath &numberedPath)
108
{
109
    argument.beginStructure();
110
    argument << numberedPath.num << numberedPath.path;
111
    argument.endStructure();
112
    return argument;
113
}
114
115
// Retrieve the NumberedDBusObjectPath data from the D-Bus argument
116
const QDBusArgument &operator>>(const QDBusArgument &argument, NumberedDBusObjectPath &numberedPath)
117
{
118
    argument.beginStructure();
119
    argument >> numberedPath.num >> numberedPath.path;
120
    argument.endStructure();
121
    return argument;
122
}
123
124
class SystemdManager : public QDBusInterface
125
{
126
public:
127
    SystemdManager() :
128
        QDBusInterface(
129
                SYSTEMD_SERVICE,
130
                SYSTEMD_BASE_PATH,
131
                SYSTEMD_MANAGER_IFACE,
132
                QDBusConnection::systemBus()) {}
133
};
134
135
class SystemdSeat : public QDBusInterface
136
{
137
public:
138
    SystemdSeat(const QDBusObjectPath &path) :
139
        QDBusInterface(
140
                SYSTEMD_SERVICE,
141
                path.path(),
142
                SYSTEMD_SEAT_IFACE,
143
                QDBusConnection::systemBus()) {}
144
    /* HACK to be able to extract a(so) type from QDBus, property doesn't do the trick */
145
    QList<NamedDBusObjectPath> getSessions() {
146
        QDBusMessage message = QDBusMessage::createMethodCall(service(), path(), DBUS_PROPERTIES_IFACE, DBUS_PROPERTIES_GET);
147
        message <<  interface() << SYSTEMD_SESSIONS_PROPERTY;
148
        QDBusMessage reply = QDBusConnection::systemBus().call(message);
149
150
        QVariantList args = reply.arguments();
151
        if (!args.isEmpty()) {
152
            QList<NamedDBusObjectPath> namedPathList = qdbus_cast< QList<NamedDBusObjectPath> >(args.at(0).value<QDBusVariant>().variant().value<QDBusArgument>());
153
            return namedPathList;
154
        }
155
        return QList<NamedDBusObjectPath>();
156
    }
157
};
158
159
class SystemdSession : public QDBusInterface
160
{
161
public:
162
    SystemdSession(const QDBusObjectPath &path) :
163
        QDBusInterface(
164
                SYSTEMD_SERVICE,
165
                path.path(),
166
                SYSTEMD_SESSION_IFACE,
167
                QDBusConnection::systemBus()) {}
168
    /* HACK to be able to extract (so) type from QDBus, property doesn't do the trick */
169
    NamedDBusObjectPath getSeat() {
170
        QDBusMessage message = QDBusMessage::createMethodCall(service(), path(), DBUS_PROPERTIES_IFACE, DBUS_PROPERTIES_GET);
171
        message <<  interface() <<  SYSTEMD_SEAT_PROPERTY;
172
        QDBusMessage reply = QDBusConnection::systemBus().call(message);
173
174
        QVariantList args = reply.arguments();
175
        if (!args.isEmpty()) {
176
            NamedDBusObjectPath namedPath;
177
            args.at(0).value<QDBusVariant>().variant().value<QDBusArgument>() >> namedPath;
178
            return namedPath;
179
        }
180
        return NamedDBusObjectPath();
181
    }
182
    NumberedDBusObjectPath getUser() {
183
        QDBusMessage message = QDBusMessage::createMethodCall(service(), path(), DBUS_PROPERTIES_IFACE, DBUS_PROPERTIES_GET);
184
        message <<  interface() <<  SYSTEMD_USER_PROPERTY;
185
        QDBusMessage reply = QDBusConnection::systemBus().call(message);
186
187
        QVariantList args = reply.arguments();
188
        if (!args.isEmpty()) {
189
            NumberedDBusObjectPath numberedPath;
190
            args.at(0).value<QDBusVariant>().variant().value<QDBusArgument>() >> numberedPath;
191
            return numberedPath;
192
        }
193
        return NumberedDBusObjectPath();
194
    }
195
    void getSessionLocation(SessEnt &se)
196
    {
197
        se.tty = (property("Type").toString() != QLatin1String("x11"));
198
        se.display = property(se.tty ? "TTY" : "Display").toString();
199
        se.vt = property("VTNr").toInt();
200
    }
201
};
202
43
class CKManager : public QDBusInterface
203
class CKManager : public QDBusInterface
44
{
204
{
45
public:
205
public:
Lines 68-76 Link Here
68
    CKSession(const QDBusObjectPath &path) :
228
    CKSession(const QDBusObjectPath &path) :
69
        QDBusInterface(
229
        QDBusInterface(
70
                QLatin1String("org.freedesktop.ConsoleKit"),
230
                QLatin1String("org.freedesktop.ConsoleKit"),
71
            path.path(),
231
                path.path(),
72
                QLatin1String("org.freedesktop.ConsoleKit.Session"),
232
                QLatin1String("org.freedesktop.ConsoleKit.Session"),
73
                QDBusConnection::systemBus()) {}
233
                QDBusConnection::systemBus()) {}
234
    void getSessionLocation(SessEnt &se)
235
    {
236
        QString tty;
237
        QDBusReply<QString> r = call(QLatin1String("GetX11Display"));
238
        if (r.isValid() && !r.value().isEmpty()) {
239
            QDBusReply<QString> r2 = call(QLatin1String("GetX11DisplayDevice"));
240
            tty = r2.value();
241
            se.display = r.value();
242
            se.tty = false;
243
        } else {
244
            QDBusReply<QString> r2 = call(QLatin1String("GetDisplayDevice"));
245
            tty = r2.value();
246
            se.display = tty;
247
            se.tty = true;
248
        }
249
        se.vt = tty.mid(strlen("/dev/tty")).toInt();
250
    }
74
};
251
};
75
252
76
class GDMFactory : public QDBusInterface
253
class GDMFactory : public QDBusInterface
Lines 115-120 Link Here
115
    const char *ptr;
292
    const char *ptr;
116
    struct sockaddr_un sa;
293
    struct sockaddr_un sa;
117
294
295
    qDBusRegisterMetaType<NamedDBusObjectPath>();
296
    qDBusRegisterMetaType<QList<NamedDBusObjectPath> >();
297
    qDBusRegisterMetaType<NumberedDBusObjectPath>();
298
118
    if (DMType == Dunno) {
299
    if (DMType == Dunno) {
119
        if (!(dpy = ::getenv("DISPLAY")))
300
        if (!(dpy = ::getenv("DISPLAY")))
120
            DMType = NoDM;
301
            DMType = NoDM;
Lines 242-258 Link Here
242
423
243
static bool getCurrentSeat(QDBusObjectPath *currentSession, QDBusObjectPath *currentSeat)
424
static bool getCurrentSeat(QDBusObjectPath *currentSession, QDBusObjectPath *currentSeat)
244
{
425
{
245
    CKManager man;
426
    SystemdManager man;
246
    QDBusReply<QDBusObjectPath> r = man.call(QLatin1String("GetCurrentSession"));
427
    QDBusReply<QDBusObjectPath> r = man.call(QLatin1String("GetSessionByPID"), (uint) QCoreApplication::applicationPid());
247
    if (r.isValid()) {
428
    if (r.isValid()) {
248
        CKSession sess(r.value());
429
        SystemdSession sess(r.value());
249
        if (sess.isValid()) {
430
        if (sess.isValid()) {
250
            QDBusReply<QDBusObjectPath> r2 = sess.call(QLatin1String("GetSeatId"));
431
            NamedDBusObjectPath namedPath = sess.getSeat();
251
            if (r2.isValid()) {
432
            if (currentSession)
252
                if (currentSession)
433
                *currentSession = r.value();
253
                    *currentSession = r.value();
434
            *currentSeat = namedPath.path;
254
                *currentSeat = r2.value();
435
            return true;
255
                return true;
436
        }
437
    }
438
    else {
439
        CKManager man;
440
        QDBusReply<QDBusObjectPath> r = man.call(QLatin1String("GetCurrentSession"));
441
        if (r.isValid()) {
442
            CKSession sess(r.value());
443
            if (sess.isValid()) {
444
                QDBusReply<QDBusObjectPath> r2 = sess.call(QLatin1String("GetSeatId"));
445
                if (r2.isValid()) {
446
                    if (currentSession)
447
                        *currentSession = r.value();
448
                    *currentSeat = r2.value();
449
                    return true;
450
                }
256
            }
451
            }
257
        }
452
        }
258
    }
453
    }
Lines 261-304 Link Here
261
456
262
static QList<QDBusObjectPath> getSessionsForSeat(const QDBusObjectPath &path)
457
static QList<QDBusObjectPath> getSessionsForSeat(const QDBusObjectPath &path)
263
{
458
{
264
    CKSeat seat(path);
459
    if (path.path().startsWith(SYSTEMD_BASE_PATH)) { // systemd path incoming
265
    if (seat.isValid()) {
460
        SystemdSeat seat(path);
266
        QDBusReply<QList<QDBusObjectPath> > r = seat.call(QLatin1String("GetSessions"));
461
        if (seat.isValid()) {
267
        if (r.isValid()) {
462
            QList<NamedDBusObjectPath> r = seat.getSessions();
268
            // This will contain only local sessions:
463
            QList<QDBusObjectPath> result;
269
            // - this is only ever called when isSwitchable() is true => local seat
464
            foreach (const NamedDBusObjectPath &namedPath, r)
270
            // - remote logins into the machine are assigned to other seats
465
                result.append(namedPath.path);
271
            return r.value();
466
            // This pretty much can't contain any other than local sessions as the seat is retrieved from the current session
467
            return result;
468
        }
469
    }
470
    else if (path.path().startsWith("/org/freedesktop/ConsoleKit")) {
471
        CKSeat seat(path);
472
        if (seat.isValid()) {
473
            QDBusReply<QList<QDBusObjectPath> > r = seat.call(QLatin1String("GetSessions"));
474
            if (r.isValid()) {
475
                // This will contain only local sessions:
476
                // - this is only ever called when isSwitchable() is true => local seat
477
                // - remote logins into the machine are assigned to other seats
478
                return r.value();
479
            }
272
        }
480
        }
273
    }
481
    }
274
    return QList<QDBusObjectPath>();
482
    return QList<QDBusObjectPath>();
275
}
483
}
276
484
277
static void getSessionLocation(CKSession &lsess, SessEnt &se)
278
{
279
    QString tty;
280
    QDBusReply<QString> r = lsess.call(QLatin1String("GetX11Display"));
281
    if (r.isValid() && !r.value().isEmpty()) {
282
        QDBusReply<QString> r2 = lsess.call(QLatin1String("GetX11DisplayDevice"));
283
        tty = r2.value();
284
        se.display = r.value();
285
        se.tty = false;
286
    } else {
287
        QDBusReply<QString> r2 = lsess.call(QLatin1String("GetDisplayDevice"));
288
        tty = r2.value();
289
        se.display = tty;
290
        se.tty = true;
291
    }
292
    se.vt = tty.mid(strlen("/dev/tty")).toInt();
293
}
294
295
#ifndef KDM_NO_SHUTDOWN
485
#ifndef KDM_NO_SHUTDOWN
296
bool
486
bool
297
KDisplayManager::canShutdown()
487
KDisplayManager::canShutdown()
298
{
488
{
299
    if (DMType == NewGDM || DMType == NoDM || DMType == LightDM) {
489
    if (DMType == NewGDM || DMType == NoDM || DMType == LightDM) {
490
        QDBusReply<QString> canPowerOff = SystemdManager().call(QLatin1String("CanPowerOff"));
491
        if (canPowerOff.isValid())
492
            return canPowerOff.value() != QLatin1String("no");
300
        QDBusReply<bool> canStop = CKManager().call(QLatin1String("CanStop"));
493
        QDBusReply<bool> canStop = CKManager().call(QLatin1String("CanStop"));
301
        return (canStop.isValid() && canStop.value());
494
        if (canStop.isValid())
495
            return canStop.value();
496
        return false;
302
    }
497
    }
303
498
304
    if (DMType == OldKDM)
499
    if (DMType == OldKDM)
Lines 329-337 Link Here
329
            return;
524
            return;
330
525
331
        if (DMType == NewGDM || DMType == NoDM || DMType == LightDM) {
526
        if (DMType == NewGDM || DMType == NoDM || DMType == LightDM) {
332
            // FIXME: entirely ignoring shutdownMode
527
            // systemd supports only 2 modes:
333
            CKManager().call(QLatin1String(
528
            // * interactive = true: brings up a PolicyKit prompt if other sessions are active
334
                    shutdownType == KWorkSpace::ShutdownTypeReboot ? "Restart" : "Stop"));
529
            // * interactive = false: rejects the shutdown if other sessions are active
530
            // There are no schedule or force modes.
531
            // We try to map our 4 shutdown modes in the sanest way.
532
            bool interactive = (shutdownMode == KWorkSpace::ShutdownModeInteractive
533
                                || shutdownMode == KWorkSpace::ShutdownModeForceNow);
534
            QDBusReply<QString> check = SystemdManager().call(QLatin1String(
535
                    shutdownType == KWorkSpace::ShutdownTypeReboot ? "Reboot" : "PowerOff"), interactive);
536
            if (!check.isValid()) {
537
                // FIXME: entirely ignoring shutdownMode
538
                CKManager().call(QLatin1String(
539
                        shutdownType == KWorkSpace::ShutdownTypeReboot ? "Restart" : "Stop"));
540
                // if even CKManager call fails, there is nothing more to be done
541
            }
335
            return;
542
            return;
336
        }
543
        }
337
544
Lines 406-414 Link Here
406
    if (DMType == NewGDM || DMType == LightDM) {
613
    if (DMType == NewGDM || DMType == LightDM) {
407
        QDBusObjectPath currentSeat;
614
        QDBusObjectPath currentSeat;
408
        if (getCurrentSeat(0, &currentSeat)) {
615
        if (getCurrentSeat(0, &currentSeat)) {
409
            CKSeat seat(currentSeat);
616
            SystemdSeat SDseat(currentSeat);
410
            if (seat.isValid()) {
617
            if (SDseat.isValid()) {
411
                QDBusReply<bool> r = seat.call(QLatin1String("CanActivateSessions"));
618
                QVariant prop = SDseat.property("CanMultiSession");
619
                if (prop.isValid())
620
                    return prop.toBool();
621
            }
622
            CKSeat CKseat(currentSeat);
623
            if (CKseat.isValid()) {
624
                QDBusReply<bool> r = CKseat.call(QLatin1String("CanActivateSessions"));
412
                if (r.isValid())
625
                if (r.isValid())
413
                    return r.value();
626
                    return r.value();
414
            }
627
            }
Lines 465-490 Link Here
465
    if (DMType == OldKDM)
678
    if (DMType == OldKDM)
466
        return false;
679
        return false;
467
680
468
    if (DMType == NewGDM || DMType == LightDM) {
681
    // FIXME TODO WARNING HACK beware of this workaround, will get rid of it in a few days (if it's not spring 2013 and this line is still here, please smack mbriza-at-redhat-dot-com)
682
    if (DMType != OldGDM) {
469
        QDBusObjectPath currentSession, currentSeat;
683
        QDBusObjectPath currentSession, currentSeat;
470
        if (getCurrentSeat(&currentSession, &currentSeat)) {
684
        if (getCurrentSeat(&currentSession, &currentSeat)) {
471
            foreach (const QDBusObjectPath &sp, getSessionsForSeat(currentSeat)) {
685
            // we'll divide the code in two branches to reduce the overhead of calls to non-existent services
472
                CKSession lsess(sp);
686
            // systemd part // preferred
473
                if (lsess.isValid()) {
687
            if (QDBusConnection::systemBus().interface()->isServiceRegistered(SYSTEMD_SERVICE)) {
474
                    SessEnt se;
688
                foreach (const QDBusObjectPath &sp, getSessionsForSeat(currentSeat)) {
475
                    getSessionLocation(lsess, se);
689
                    SystemdSession lsess(sp);
476
                    // "Warning: we haven't yet defined the allowed values for this property.
690
                    if (lsess.isValid()) {
477
                    // It is probably best to avoid this until we do."
691
                        SessEnt se;
478
                    QDBusReply<QString> r = lsess.call(QLatin1String("GetSessionType"));
692
                        lsess.getSessionLocation(se);
479
                    if (r.value() != QLatin1String("LoginWindow")) {
693
                        if ((lsess.property("Class").toString() != QLatin1String("greeter")) &&
480
                        QDBusReply<unsigned> r2 = lsess.call(QLatin1String("GetUnixUser"));
694
                             (lsess.property("State").toString() == QLatin1String("online") ||
481
                        se.user = KUser(K_UID(r2.value())).loginName();
695
                              lsess.property("State").toString() == QLatin1String("active"))) {
482
                        se.session = "<unknown>";
696
                            NumberedDBusObjectPath numberedPath = lsess.getUser();
697
                            se.display = lsess.property("Display").toString();
698
                            se.vt = lsess.property("VTNr").toInt();
699
                            se.user = KUser(K_UID(numberedPath.num)).loginName();
700
                            /* TODO:
701
                             * regarding the session name in this, it IS possible to find it out - logind tracks the session leader PID
702
                             * the problem is finding out the name of the process, I could come only with reading /proc/PID/comm which
703
                             * doesn't seem exactly... right to me --mbriza
704
                             */
705
                            se.session = "<unknown>";
706
                            se.self = lsess.property("Display").toString() == ::getenv("DISPLAY"); /* Bleh once again */
707
                            se.tty = !lsess.property("TTY").toString().isEmpty();
708
                        }
709
                        list.append(se);
710
                    }
711
                }
712
            }
713
            // ConsoleKit part
714
            else if (QDBusConnection::systemBus().interface()->isServiceRegistered("org.freedesktop.ConsoleKit")) {
715
                foreach (const QDBusObjectPath &sp, getSessionsForSeat(currentSeat)) {
716
                    CKSession lsess(sp);
717
                    if (lsess.isValid()) {
718
                        SessEnt se;
719
                        lsess.getSessionLocation(se);
720
                        // "Warning: we haven't yet defined the allowed values for this property.
721
                        // It is probably best to avoid this until we do."
722
                        QDBusReply<QString> r = lsess.call(QLatin1String("GetSessionType"));
723
                        if (r.value() != QLatin1String("LoginWindow")) {
724
                            QDBusReply<unsigned> r2 = lsess.call(QLatin1String("GetUnixUser"));
725
                            se.user = KUser(K_UID(r2.value())).loginName();
726
                            se.session = "<unknown>";
727
                        }
728
                        se.self = (sp == currentSession);
729
                        list.append(se);
483
                    }
730
                    }
484
                    se.self = (sp == currentSession);
485
                    list.append(se);
486
                }
731
                }
487
            }
732
            }
733
            else {
734
                return false;
735
            }
488
            return true;
736
            return true;
489
        }
737
        }
490
        return false;
738
        return false;
Lines 507-527 Link Here
507
            se.tty = false;
755
            se.tty = false;
508
            list.append(se);
756
            list.append(se);
509
        }
757
        }
510
    } else {
511
        if (!exec("list\talllocal\n", re))
512
            return false;
513
        const QStringList sess = QString(re.data() + 3).split(QChar('\t'), QString::SkipEmptyParts);
514
        for (QStringList::ConstIterator it = sess.constBegin(); it != sess.constEnd(); ++it) {
515
            QStringList ts = (*it).split(QChar(','));
516
            SessEnt se;
517
            se.display = ts[0];
518
            se.vt = ts[1].mid(2).toInt();
519
            se.user = ts[2];
520
            se.session = ts[3];
521
            se.self = (ts[4].indexOf('*') >= 0);
522
            se.tty = (ts[4].indexOf('t') >= 0);
523
            list.append(se);
524
        }
525
    }
758
    }
526
    return true;
759
    return true;
527
}
760
}
Lines 566-581 Link Here
566
    if (DMType == NewGDM || DMType == LightDM) {
799
    if (DMType == NewGDM || DMType == LightDM) {
567
        QDBusObjectPath currentSeat;
800
        QDBusObjectPath currentSeat;
568
        if (getCurrentSeat(0, &currentSeat)) {
801
        if (getCurrentSeat(0, &currentSeat)) {
569
            foreach (const QDBusObjectPath &sp, getSessionsForSeat(currentSeat)) {
802
            // systemd part // preferred
570
                CKSession lsess(sp);
803
            if (QDBusConnection::systemBus().interface()->isServiceRegistered(SYSTEMD_SERVICE)) {
571
                if (lsess.isValid()) {
804
                foreach (const QDBusObjectPath &sp, getSessionsForSeat(currentSeat)) {
572
                    SessEnt se;
805
                    SystemdSession lsess(sp);
573
                    getSessionLocation(lsess, se);
806
                    if (lsess.isValid()) {
574
                    if (se.vt == vt) {
807
                        SessEnt se;
575
                        if (se.tty) // ConsoleKit simply ignores these
808
                        lsess.getSessionLocation(se);
576
                            return false;
809
                        if (se.vt == vt) {
577
                        lsess.call(QLatin1String("Activate"));
810
                            lsess.call(SYSTEMD_SWITCH_CALL);
578
                        return true;
811
                            return true;
812
                        }
813
                    }
814
                }
815
            }
816
            // ConsoleKit part
817
            else if (QDBusConnection::systemBus().interface()->isServiceRegistered("org.freedesktop.ConsoleKit")) {
818
                foreach (const QDBusObjectPath &sp, getSessionsForSeat(currentSeat)) {
819
                    CKSession lsess(sp);
820
                    if (lsess.isValid()) {
821
                        SessEnt se;
822
                        lsess.getSessionLocation(se);
823
                        if (se.vt == vt) {
824
                            if (se.tty) // ConsoleKit simply ignores these
825
                                return false;
826
                            lsess.call(QLatin1String("Activate"));
827
                            return true;
828
                        }
579
                    }
829
                    }
580
                }
830
                }
581
            }
831
            }
Lines 643-645 Link Here
643
}
893
}
644
894
645
#endif // Q_WS_X11
895
#endif // Q_WS_X11
896

Return to bug 468916