Changeset View
Changeset View
Standalone View
Standalone View
libkworkspace/kdisplaymanager.cpp
Show First 20 Lines • Show All 460 Lines • ▼ Show 20 Line(s) | 432 | { | |||
---|---|---|---|---|---|
461 | return false; | 461 | return false; | ||
462 | } | 462 | } | ||
463 | 463 | | |||
464 | static QList<QDBusObjectPath> getSessionsForSeat(const QDBusObjectPath &path) | 464 | static QList<QDBusObjectPath> getSessionsForSeat(const QDBusObjectPath &path) | ||
465 | { | 465 | { | ||
466 | if (path.path().startsWith(SYSTEMD_BASE_PATH)) { // systemd path incoming | 466 | if (path.path().startsWith(SYSTEMD_BASE_PATH)) { // systemd path incoming | ||
467 | SystemdSeat seat(path); | 467 | SystemdSeat seat(path); | ||
468 | if (seat.isValid()) { | 468 | if (seat.isValid()) { | ||
469 | QList<NamedDBusObjectPath> r = seat.getSessions(); | 469 | const QList<NamedDBusObjectPath> r = seat.getSessions(); | ||
470 | QList<QDBusObjectPath> result; | 470 | QList<QDBusObjectPath> result; | ||
471 | foreach (const NamedDBusObjectPath &namedPath, r) | 471 | for (const NamedDBusObjectPath &namedPath : r) | ||
472 | result.append(namedPath.path); | 472 | result.append(namedPath.path); | ||
473 | // This pretty much can't contain any other than local sessions as the seat is retrieved from the current session | 473 | // This pretty much can't contain any other than local sessions as the seat is retrieved from the current session | ||
474 | return result; | 474 | return result; | ||
475 | } | 475 | } | ||
476 | } | 476 | } | ||
477 | else if (path.path().startsWith(QLatin1String("/org/freedesktop/ConsoleKit"))) { | 477 | else if (path.path().startsWith(QLatin1String("/org/freedesktop/ConsoleKit"))) { | ||
478 | CKSeat seat(path); | 478 | CKSeat seat(path); | ||
479 | if (seat.isValid()) { | 479 | if (seat.isValid()) { | ||
▲ Show 20 Lines • Show All 198 Lines • ▼ Show 20 Line(s) | 677 | if (DMType == OldKDM) | |||
678 | return false; | 678 | return false; | ||
679 | 679 | | |||
680 | if (DMType == NewGDM || DMType == LightDM) { | 680 | if (DMType == NewGDM || DMType == LightDM) { | ||
681 | QDBusObjectPath currentSession, currentSeat; | 681 | QDBusObjectPath currentSession, currentSeat; | ||
682 | if (getCurrentSeat(¤tSession, ¤tSeat)) { | 682 | if (getCurrentSeat(¤tSession, ¤tSeat)) { | ||
683 | // we'll divide the code in two branches to reduce the overhead of calls to non-existent services | 683 | // we'll divide the code in two branches to reduce the overhead of calls to non-existent services | ||
684 | // systemd part // preferred | 684 | // systemd part // preferred | ||
685 | if (QDBusConnection::systemBus().interface()->isServiceRegistered(SYSTEMD_SERVICE)) { | 685 | if (QDBusConnection::systemBus().interface()->isServiceRegistered(SYSTEMD_SERVICE)) { | ||
686 | foreach (const QDBusObjectPath &sp, getSessionsForSeat(currentSeat)) { | 686 | const auto sessions = getSessionsForSeat(currentSeat); | ||
687 | for (const QDBusObjectPath &sp : sessions) { | ||||
687 | SystemdSession lsess(sp); | 688 | SystemdSession lsess(sp); | ||
688 | if (lsess.isValid()) { | 689 | if (lsess.isValid()) { | ||
689 | SessEnt se; | 690 | SessEnt se; | ||
690 | lsess.getSessionLocation(se); | 691 | lsess.getSessionLocation(se); | ||
691 | if ((lsess.property("Class").toString() != QLatin1String("greeter")) && | 692 | if ((lsess.property("Class").toString() != QLatin1String("greeter")) && | ||
692 | (lsess.property("State").toString() == QLatin1String("online") || | 693 | (lsess.property("State").toString() == QLatin1String("online") || | ||
693 | lsess.property("State").toString() == QLatin1String("active"))) { | 694 | lsess.property("State").toString() == QLatin1String("active"))) { | ||
694 | NumberedDBusObjectPath numberedPath = lsess.getUser(); | 695 | NumberedDBusObjectPath numberedPath = lsess.getUser(); | ||
Show All 10 Lines | |||||
705 | se.tty = !lsess.property("TTY").toString().isEmpty(); | 706 | se.tty = !lsess.property("TTY").toString().isEmpty(); | ||
706 | } | 707 | } | ||
707 | list.append(se); | 708 | list.append(se); | ||
708 | } | 709 | } | ||
709 | } | 710 | } | ||
710 | } | 711 | } | ||
711 | // ConsoleKit part | 712 | // ConsoleKit part | ||
712 | else if (QDBusConnection::systemBus().interface()->isServiceRegistered(QStringLiteral("org.freedesktop.ConsoleKit"))) { | 713 | else if (QDBusConnection::systemBus().interface()->isServiceRegistered(QStringLiteral("org.freedesktop.ConsoleKit"))) { | ||
713 | foreach (const QDBusObjectPath &sp, getSessionsForSeat(currentSeat)) { | 714 | const auto sessions = getSessionsForSeat(currentSeat); | ||
715 | for (const QDBusObjectPath &sp : sessions) { | ||||
714 | CKSession lsess(sp); | 716 | CKSession lsess(sp); | ||
715 | if (lsess.isValid()) { | 717 | if (lsess.isValid()) { | ||
716 | SessEnt se; | 718 | SessEnt se; | ||
717 | lsess.getSessionLocation(se); | 719 | lsess.getSessionLocation(se); | ||
718 | // "Warning: we haven't yet defined the allowed values for this property. | 720 | // "Warning: we haven't yet defined the allowed values for this property. | ||
719 | // It is probably best to avoid this until we do." | 721 | // It is probably best to avoid this until we do." | ||
720 | QDBusReply<QString> r = lsess.call(QStringLiteral("GetSessionType")); | 722 | QDBusReply<QString> r = lsess.call(QStringLiteral("GetSessionType")); | ||
721 | if (r.value() != QLatin1String("LoginWindow")) { | 723 | if (r.value() != QLatin1String("LoginWindow")) { | ||
▲ Show 20 Lines • Show All 87 Lines • ▼ Show 20 Line(s) | |||||
809 | bool | 811 | bool | ||
810 | KDisplayManager::switchVT(int vt) | 812 | KDisplayManager::switchVT(int vt) | ||
811 | { | 813 | { | ||
812 | if (DMType == NewGDM || DMType == LightDM) { | 814 | if (DMType == NewGDM || DMType == LightDM) { | ||
813 | QDBusObjectPath currentSeat; | 815 | QDBusObjectPath currentSeat; | ||
814 | if (getCurrentSeat(nullptr, ¤tSeat)) { | 816 | if (getCurrentSeat(nullptr, ¤tSeat)) { | ||
815 | // systemd part // preferred | 817 | // systemd part // preferred | ||
816 | if (QDBusConnection::systemBus().interface()->isServiceRegistered(SYSTEMD_SERVICE)) { | 818 | if (QDBusConnection::systemBus().interface()->isServiceRegistered(SYSTEMD_SERVICE)) { | ||
817 | foreach (const QDBusObjectPath &sp, getSessionsForSeat(currentSeat)) { | 819 | const auto sessions = getSessionsForSeat(currentSeat); | ||
820 | for (const QDBusObjectPath &sp : sessions) { | ||||
818 | SystemdSession lsess(sp); | 821 | SystemdSession lsess(sp); | ||
819 | if (lsess.isValid()) { | 822 | if (lsess.isValid()) { | ||
820 | SessEnt se; | 823 | SessEnt se; | ||
821 | lsess.getSessionLocation(se); | 824 | lsess.getSessionLocation(se); | ||
822 | if (se.vt == vt) { | 825 | if (se.vt == vt) { | ||
823 | lsess.call(SYSTEMD_SWITCH_CALL); | 826 | lsess.call(SYSTEMD_SWITCH_CALL); | ||
824 | return true; | 827 | return true; | ||
825 | } | 828 | } | ||
826 | } | 829 | } | ||
827 | } | 830 | } | ||
828 | } | 831 | } | ||
829 | // ConsoleKit part | 832 | // ConsoleKit part | ||
830 | else if (QDBusConnection::systemBus().interface()->isServiceRegistered(QStringLiteral("org.freedesktop.ConsoleKit"))) { | 833 | else if (QDBusConnection::systemBus().interface()->isServiceRegistered(QStringLiteral("org.freedesktop.ConsoleKit"))) { | ||
831 | foreach (const QDBusObjectPath &sp, getSessionsForSeat(currentSeat)) { | 834 | const auto sessions = getSessionsForSeat(currentSeat); | ||
835 | for (const QDBusObjectPath &sp : sessions) { | ||||
832 | CKSession lsess(sp); | 836 | CKSession lsess(sp); | ||
833 | if (lsess.isValid()) { | 837 | if (lsess.isValid()) { | ||
834 | SessEnt se; | 838 | SessEnt se; | ||
835 | lsess.getSessionLocation(se); | 839 | lsess.getSessionLocation(se); | ||
836 | if (se.vt == vt) { | 840 | if (se.vt == vt) { | ||
837 | if (se.tty) // ConsoleKit simply ignores these | 841 | if (se.tty) // ConsoleKit simply ignores these | ||
838 | return false; | 842 | return false; | ||
839 | lsess.call(QStringLiteral("Activate")); | 843 | lsess.call(QStringLiteral("Activate")); | ||
▲ Show 20 Lines • Show All 69 Lines • Show Last 20 Lines |