Commit 008d58cf authored by David Edmundson's avatar David Edmundson

[ksmserver] Split xsession logout and shutdown into separate classes

Summary:
This commit splits ksmserver's xsession shutdown logic from performing
the actual shutdown and running shutdown scripts and implement proposed
org.kde.Shutdown interface.

Intended longer term target is to move this to a separate executable.

KSMServer's existing logout dbus method still exists for compatibility
forwarding to the new interface.

There are 2 minor behavioural changes.

The shutdownMode property (which doesn't seem to do anything and is not
exposed in our UI) is not kept.

If you shutdown /whilst/ starting up somehow, previously we delayed
showing the logout prompt, we now delay performing the actual logout.

Test Plan:
Logged out / shut down using the old API
Logged out / shut down using the new DBus API

Reviewers: #plasma, apol, romangg

Reviewed By: #plasma, apol, romangg

Subscribers: romangg, apol, plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D16277
parent 722aff93
......@@ -22,6 +22,7 @@ set(ksmserver_KDEINIT_SRCS
legacy.cpp
startup.cpp
autostart.cpp
logout.cpp
shutdown.cpp
client.cpp
)
......@@ -45,8 +46,10 @@ qt5_add_dbus_interface( ksmserver_KDEINIT_SRCS ${klauncher_xml} klauncher_interf
qt5_add_dbus_interface( ksmserver_KDEINIT_SRCS ${KSCREENLOCKER_DBUS_INTERFACES_DIR}/org.kde.screensaver.xml kscreenlocker_interface )
qt5_add_dbus_interface( ksmserver_KDEINIT_SRCS org.kde.LogoutPrompt.xml logoutprompt_interface)
qt5_add_dbus_interface( ksmserver_KDEINIT_SRCS org.kde.Shutdown.xml shutdown_interface)
qt5_add_dbus_adaptor( ksmserver_KDEINIT_SRCS org.kde.KSMServerInterface.xml server.h KSMServer )
qt5_add_dbus_adaptor( ksmserver_KDEINIT_SRCS org.kde.Shutdown.xml shutdown.h Shutdown)
kf5_add_kdeinit_executable( ksmserver ${ksmserver_KDEINIT_SRCS})
......
This diff is collapsed.
......@@ -42,6 +42,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <ksmserver_debug.h>
#include "server.h"
#include "startup.h"
#include "shutdown.h"
#include <QX11Info>
#include <QApplication>
......@@ -313,6 +314,7 @@ extern "C" Q_DECL_EXPORT int kdemain( int argc, char* argv[] )
KSMServer *server = new KSMServer( wm, flags);
auto startup = new Startup(server);
new Shutdown(a);
// for the KDE-already-running check in startkde
KSelectionOwner kde_running( "_KDE_RUNNING", 0 );
......
<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
<node>
<interface name="org.kde.Shutdown">
<method name="logout"/>
<method name="logoutAndShutdown"/>
<method name="logoutAndReboot"/>
</interface>
</node>
......@@ -86,7 +86,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <KScreenLocker/KsldApp>
#include <kdisplaymanager.h>
#include <QX11Info>
#include <krandom.h>
#include <klauncher_interface.h>
......@@ -620,8 +619,6 @@ KSMServer::KSMServer( const QString& windowManager, InitFlags flags )
the_server = this;
clean = false;
shutdownType = KWorkSpace::ShutdownTypeNone;
state = Idle;
saveSession = false;
wmPhase1WaitingCount = 0;
......@@ -631,8 +628,6 @@ KSMServer::KSMServer( const QString& windowManager, InitFlags flags )
selectWm( windowManager );
connect(&pendingShutdown, &QTimer::timeout, this, &KSMServer::pendingShutdownTimeout);
only_local = flags.testFlag(InitFlag::OnlyLocal);
#ifdef HAVE__ICETRANSNOLISTEN
if (only_local)
......@@ -757,10 +752,6 @@ void KSMServer::cleanUp()
FreeAuthenticationData(numTransports, authDataEntries);
signal(SIGTERM, SIG_DFL);
signal(SIGINT, SIG_DFL);
runShutdownScripts();
KDisplayManager().shutdown( shutdownType, shutdownMode, bootOption );
}
......@@ -1269,28 +1260,3 @@ void KSMServer::openSwitchUserDialog()
OrgKdeScreensaverInterface iface(QStringLiteral("org.freedesktop.ScreenSaver"), QStringLiteral("/ScreenSaver"), QDBusConnection::sessionBus());
iface.SwitchUser();
}
void KSMServer::runShutdownScripts()
{
const QStringList shutdownFolders = QStandardPaths::locateAll(QStandardPaths::GenericConfigLocation, QStringLiteral("plasma-workspace/shutdown"), QStandardPaths::LocateDirectory);
foreach (const QString &shutDownFolder, shutdownFolders) {
QDir dir(shutDownFolder);
if (!dir.exists()) {
continue;
}
const QStringList entries = dir.entryList(QDir::Files);
foreach (const QString &file, entries) {
// Don't execute backup files
if (!file.endsWith(QLatin1Char('~')) && !file.endsWith(QStringLiteral(".bak")) &&
(file[0] != QLatin1Char('%') || !file.endsWith(QLatin1Char('%'))) &&
(file[0] != QLatin1Char('#') || !file.endsWith(QLatin1Char('#'))))
{
const QString fullPath = dir.absolutePath() + QLatin1Char('/') + file;
qCDebug(KSMSERVER) << "running shutdown script" << fullPath;
QProcess::execute(fullPath, QStringList());
}
}
}
}
......@@ -109,6 +109,7 @@ public:
void clientRegistered( const char* previousId );
// public API
void performLogout();
void restoreSession( const QString &sessionName );
void startDefaultSession();
void shutdown( KWorkSpace::ShutdownConfirm confirm,
......@@ -117,8 +118,10 @@ public:
Q_SIGNALS:
void windowManagerLoaded();
void logoutCancelled();
public Q_SLOTS:
void cleanUp();
private Q_SLOTS:
......@@ -129,7 +132,6 @@ private Q_SLOTS:
void timeoutQuit();
void timeoutWMQuit();
void pendingShutdownTimeout();
void wmProcessChange();
void defaultLogout();
......@@ -187,7 +189,6 @@ private:
void runShutdownScripts();
void performLogout();
// public dcop interface
......@@ -228,10 +229,6 @@ private:
int wmPhase1WaitingCount;
int saveType;
KWorkSpace::ShutdownType shutdownType;
KWorkSpace::ShutdownMode shutdownMode;
QString bootOption;
bool clean;
KSMClient* clientInteracting;
QString wm;
......@@ -242,12 +239,7 @@ private:
QTimer protectionTimer;
QTimer restoreTimer;
QString xonCommand;
QTimer pendingShutdown;
QWidget* logoutEffectWidget;
KWorkSpace::ShutdownConfirm pendingShutdown_confirm;
KWorkSpace::ShutdownType pendingShutdown_sdtype;
KWorkSpace::ShutdownMode pendingShutdown_sdmode;
// sequential startup
int appsToStart;
int lastAppStarted;
......
This diff is collapsed.
/*****************************************************************
ksmserver - the KDE session management server
Copyright 2018 David Edmundson <davidedmundson@kde.org>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
******************************************************************/
#pragma once
#include <QObject>
#include <kworkspace.h>
class Shutdown: public QObject
{
Q_OBJECT
public:
Shutdown(QObject *parent = nullptr);
void logout();
void logoutAndShutdown();
void logoutAndReboot();
private Q_SLOTS:
void logoutCancelled();
void logoutComplete();
private:
void startLogout(KWorkSpace::ShutdownType shutdownType);
void runShutdownScripts();
KWorkSpace::ShutdownType m_shutdownType;
};
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment