[kde-workspace] Fixed SystemD support in kdisplaymanager.cpp (for switching users)

Martin Briza mbriza at fedoraproject.org
Mon Oct 8 14:33:29 UTC 2012


commit 5ef7edfe76063c23e132acd768046450be93bb1d
Author: Martin Briza <mbriza at redhat.com>
Date:   Mon Oct 8 16:22:12 2012 +0200

    Fixed SystemD support in kdisplaymanager.cpp (for switching users)

 kde-workspace-4.9.2-systemd-switch-user.patch |  112 +++++++++++++++++++++++++
 kde-workspace.spec                            |    9 ++-
 2 files changed, 120 insertions(+), 1 deletions(-)
---
diff --git a/kde-workspace-4.9.2-systemd-switch-user.patch b/kde-workspace-4.9.2-systemd-switch-user.patch
new file mode 100644
index 0000000..77cdeb5
--- /dev/null
+++ b/kde-workspace-4.9.2-systemd-switch-user.patch
@@ -0,0 +1,112 @@
+--- kde-workspace-4.9.2/libs/kworkspace/kdisplaymanager.cpp.moje	2012-10-08 15:27:57.172066523 +0200
++++ kde-workspace-4.9.1/libs/kworkspace/kdisplaymanager.cpp	2012-10-08 15:28:42.494886559 +0200
+@@ -112,6 +112,19 @@ public:
+                 path.path(),
+                 QLatin1String("org.freedesktop.login1.Seat"),
+                 QDBusConnection::systemBus()) {}
++    /* HACK to be able to extract a(so) type from QDBus, property doesn't do the trick */
++    QList<NamedDBusObjectPath> getSessions() {
++        QDBusMessage message = QDBusMessage::createMethodCall(service(), path(), QLatin1String("org.freedesktop.DBus.Properties"), QLatin1String("Get"));
++        message <<  interface() <<  QLatin1String("Sessions");
++        QDBusMessage reply = QDBusConnection::systemBus().call(message);
++
++        QVariantList args = reply.arguments();
++        if (!args.isEmpty()) {
++            QList<NamedDBusObjectPath> namedPathList = qdbus_cast< QList<NamedDBusObjectPath> >(args.at(0).value<QDBusVariant>().variant().value<QDBusArgument>());
++            return namedPathList;
++        }
++        return QList<NamedDBusObjectPath>();
++    }
+ };
+ 
+ class SystemdSession : public QDBusInterface
+@@ -123,6 +136,33 @@ public:
+                 path.path(),
+                 QLatin1String("org.freedesktop.login1.Session"),
+                 QDBusConnection::systemBus()) {}
++    /* HACK to be able to extract (so) type from QDBus, property doesn't do the trick */
++    NamedDBusObjectPath getSeat() {
++        QDBusMessage message = QDBusMessage::createMethodCall(service(), path(), QLatin1String("org.freedesktop.DBus.Properties"), QLatin1String("Get"));
++        message <<  interface() <<  QLatin1String("Seat");
++        QDBusMessage reply = QDBusConnection::systemBus().call(message);
++
++        QVariantList args = reply.arguments();
++        if (!args.isEmpty()) {
++            NamedDBusObjectPath namedPath;
++            args.at(0).value<QDBusVariant>().variant().value<QDBusArgument>() >> namedPath;
++            return namedPath;
++        }
++        return NamedDBusObjectPath();
++    }
++    NumberedDBusObjectPath getUser() {
++        QDBusMessage message = QDBusMessage::createMethodCall(service(), path(), QLatin1String("org.freedesktop.DBus.Properties"), QLatin1String("Get"));
++        message <<  interface() <<  QLatin1String("User");
++        QDBusMessage reply = QDBusConnection::systemBus().call(message);
++
++        QVariantList args = reply.arguments();
++        if (!args.isEmpty()) {
++            NumberedDBusObjectPath numberedPath;
++            args.at(0).value<QDBusVariant>().variant().value<QDBusArgument>() >> numberedPath;
++            return numberedPath;
++        }
++        return NumberedDBusObjectPath();
++    }
+ };
+ #else
+ class CKManager : public QDBusInterface
+@@ -339,14 +379,11 @@ static bool getCurrentSeat(QDBusObjectPa
+     if (r.isValid()) {
+         SystemdSession sess(r.value());
+         if (sess.isValid()) {
+-            QVariant p = sess.property("Seat");
+-            if (p.canConvert<NamedDBusObjectPath>()) {
+-                NamedDBusObjectPath namedPath = p.value<NamedDBusObjectPath>();
+-                if (currentSession)
+-                    *currentSession = r.value();
+-                *currentSeat = namedPath.path;
+-                return true;
+-            }
++            NamedDBusObjectPath namedPath = sess.getSeat();
++            if (currentSession)
++                *currentSession = r.value();
++            *currentSeat = namedPath.path;
++            return true;
+         }
+     }
+ #else
+@@ -373,17 +410,14 @@ static QList<QDBusObjectPath> getSession
+ #ifdef KWORKSPACE_USE_SYSTEMD
+     SystemdSeat seat(path);
+     if (seat.isValid()) {
+-        QVariant p = seat.property("Sessions");
+-        if (p.canConvert<QList<NamedDBusObjectPath> >()) {
+-            QList<NamedDBusObjectPath> r = p.value<QList<NamedDBusObjectPath> >();
+-            QList<QDBusObjectPath> result;
+-            foreach (const NamedDBusObjectPath &namedPath, r)
+-                result.append(namedPath.path);
+-            // This will contain only local sessions:
+-            // - this is only ever called when isSwitchable() is true => local seat
+-            // - remote logins into the machine are assigned to other seats
+-            return result;
+-        }
++        QList<NamedDBusObjectPath> r = seat.getSessions();
++        QList<QDBusObjectPath> result;
++        foreach (const NamedDBusObjectPath &namedPath, r)
++            result.append(namedPath.path);
++        // This will contain only local sessions:
++        // - this is only ever called when isSwitchable() is true => local seat
++        // - remote logins into the machine are assigned to other seats
++        return result;
+     }
+ #else
+     CKSeat seat(path);
+@@ -633,8 +667,7 @@ KDisplayManager::localSessions(SessList
+                     SessEnt se;
+                     getSessionLocation(lsess, se);
+                     if (lsess.property("Class").toString() != QLatin1String("greeter")) {
+-                        QVariant p = lsess.property("User");
+-                        NumberedDBusObjectPath numberedPath = p.value<NumberedDBusObjectPath>();
++                        NumberedDBusObjectPath numberedPath = lsess.getUser();
+                         se.user = KUser(K_UID(numberedPath.num)).loginName();
+                         se.session = "<unknown>";
+                     }
diff --git a/kde-workspace.spec b/kde-workspace.spec
index 2d1fa4f..04665b3 100644
--- a/kde-workspace.spec
+++ b/kde-workspace.spec
@@ -11,7 +11,7 @@
 Summary: KDE Workspace
 Name:    kde-workspace
 Version: 4.9.2
-Release: 4%{?dist}
+Release: 5%{?dist}
 
 License: GPLv2
 URL:     https://projects.kde.org/projects/kde/kde-workspace
@@ -117,6 +117,9 @@ Patch58: kde-workspace-4.8.0-systemd-shutdown.patch
 # http://svnweb.mageia.org/packages/cauldron/kdebase4-workspace/current/SOURCES/kdebase-workspace-4.9.0-fontconfigdir.patch
 Patch59: kde-workspace-4.9.0-fontconfigdir.patch
 
+# Support for switching users with systemd - #859347
+Patch60: kde-workspace-4.9.2-systemd-switch-user.patch
+
 ## upstream patches
 # systemd_inhibit work-in-progress
 Patch100: kde-workspace-4.9.2-systemd_inhibit.patch
@@ -455,6 +458,7 @@ Requires: akonadi
 %patch57 -p1 -b .bug796969
 %patch58 -p1 -b .systemd-shutdown
 %patch59 -p1 -b fontconfigdir
+%patch60 -p1 -b .systemd-switch-user
 
 # upstream patches
 %patch100 -p1 -b .systemd_inhibit
@@ -1009,6 +1013,9 @@ fi
 
 
 %changelog
+* Mon Oct 08 2012 Martin Briza <mbriza at redhat.com> 4.9.2-5
+- Fixing user switching with SystemD (#859347), for LightDM
+
 * Thu Oct 04 2012 Rex Dieter <rdieter at fedoraproject.org> 4.9.2-4
 - ongoing systemd_inhibit work (#859227) 
 


More information about the scm-commits mailing list