Changeset View
Changeset View
Standalone View
Standalone View
ksmserver/server.cpp
Show First 20 Lines • Show All 80 Lines • ▼ Show 20 Line(s) | |||||
81 | #include <kdesktopfile.h> | 81 | #include <kdesktopfile.h> | ||
82 | #include <QTemporaryFile> | 82 | #include <QTemporaryFile> | ||
83 | #include <kconfiggroup.h> | 83 | #include <kconfiggroup.h> | ||
84 | #include <kprocess.h> | 84 | #include <kprocess.h> | ||
85 | #include <kshell.h> | 85 | #include <kshell.h> | ||
86 | 86 | | |||
87 | #include <KScreenLocker/KsldApp> | 87 | #include <KScreenLocker/KsldApp> | ||
88 | 88 | | |||
89 | #include <kdisplaymanager.h> | | |||
90 | #include <QX11Info> | 89 | #include <QX11Info> | ||
91 | #include <krandom.h> | 90 | #include <krandom.h> | ||
92 | #include <klauncher_interface.h> | 91 | #include <klauncher_interface.h> | ||
93 | #include <qstandardpaths.h> | 92 | #include <qstandardpaths.h> | ||
94 | 93 | | |||
95 | #include "kscreenlocker_interface.h" | 94 | #include "kscreenlocker_interface.h" | ||
96 | 95 | | |||
97 | KSMServer* the_server = nullptr; | 96 | KSMServer* the_server = nullptr; | ||
▲ Show 20 Lines • Show All 517 Lines • ▼ Show 20 Line(s) | 603 | { | |||
615 | QSocketNotifier* n = new QSocketNotifier(sockets[1], QSocketNotifier::Read, this); | 614 | QSocketNotifier* n = new QSocketNotifier(sockets[1], QSocketNotifier::Read, this); | ||
616 | qApp->connect(n, &QSocketNotifier::activated, &QApplication::quit); | 615 | qApp->connect(n, &QSocketNotifier::activated, &QApplication::quit); | ||
617 | 616 | | |||
618 | new KSMServerInterfaceAdaptor( this ); | 617 | new KSMServerInterfaceAdaptor( this ); | ||
619 | QDBusConnection::sessionBus().registerObject(QStringLiteral("/KSMServer"), this); | 618 | QDBusConnection::sessionBus().registerObject(QStringLiteral("/KSMServer"), this); | ||
620 | the_server = this; | 619 | the_server = this; | ||
621 | clean = false; | 620 | clean = false; | ||
622 | 621 | | |||
623 | shutdownType = KWorkSpace::ShutdownTypeNone; | | |||
624 | | ||||
625 | state = Idle; | 622 | state = Idle; | ||
626 | saveSession = false; | 623 | saveSession = false; | ||
627 | wmPhase1WaitingCount = 0; | 624 | wmPhase1WaitingCount = 0; | ||
628 | KConfigGroup config(KSharedConfig::openConfig(), "General"); | 625 | KConfigGroup config(KSharedConfig::openConfig(), "General"); | ||
629 | clientInteracting = nullptr; | 626 | clientInteracting = nullptr; | ||
630 | xonCommand = config.readEntry( "xonCommand", "xon" ); | 627 | xonCommand = config.readEntry( "xonCommand", "xon" ); | ||
631 | 628 | | |||
632 | selectWm( windowManager ); | 629 | selectWm( windowManager ); | ||
633 | 630 | | |||
634 | connect(&pendingShutdown, &QTimer::timeout, this, &KSMServer::pendingShutdownTimeout); | | |||
635 | | ||||
636 | only_local = flags.testFlag(InitFlag::OnlyLocal); | 631 | only_local = flags.testFlag(InitFlag::OnlyLocal); | ||
637 | #ifdef HAVE__ICETRANSNOLISTEN | 632 | #ifdef HAVE__ICETRANSNOLISTEN | ||
638 | if (only_local) | 633 | if (only_local) | ||
639 | _IceTransNoListen("tcp"); | 634 | _IceTransNoListen("tcp"); | ||
640 | #else | 635 | #else | ||
641 | only_local = false; | 636 | only_local = false; | ||
642 | #endif | 637 | #endif | ||
643 | 638 | | |||
▲ Show 20 Lines • Show All 108 Lines • ▼ Show 20 Line(s) | 746 | while( (i = display.indexOf(QLatin1Char('/'))) >= 0) | |||
752 | display[i] = '_'; | 747 | display[i] = '_'; | ||
753 | 748 | | |||
754 | fName += '_'+display.toLocal8Bit(); | 749 | fName += '_'+display.toLocal8Bit(); | ||
755 | ::unlink(fName.data()); | 750 | ::unlink(fName.data()); | ||
756 | 751 | | |||
757 | FreeAuthenticationData(numTransports, authDataEntries); | 752 | FreeAuthenticationData(numTransports, authDataEntries); | ||
758 | signal(SIGTERM, SIG_DFL); | 753 | signal(SIGTERM, SIG_DFL); | ||
759 | signal(SIGINT, SIG_DFL); | 754 | signal(SIGINT, SIG_DFL); | ||
760 | | ||||
761 | runShutdownScripts(); | | |||
762 | | ||||
763 | KDisplayManager().shutdown( shutdownType, shutdownMode, bootOption ); | | |||
764 | } | 755 | } | ||
765 | 756 | | |||
766 | 757 | | |||
767 | 758 | | |||
768 | void* KSMServer::watchConnection( IceConn iceConn ) | 759 | void* KSMServer::watchConnection( IceConn iceConn ) | ||
769 | { | 760 | { | ||
770 | KSMConnection* conn = new KSMConnection( iceConn ); | 761 | KSMConnection* conn = new KSMConnection( iceConn ); | ||
771 | connect(conn, &KSMConnection::activated, this, &KSMServer::processData); | 762 | connect(conn, &KSMConnection::activated, this, &KSMServer::processData); | ||
▲ Show 20 Lines • Show All 492 Lines • ▼ Show 20 Line(s) | |||||
1264 | } | 1255 | } | ||
1265 | 1256 | | |||
1266 | void KSMServer::openSwitchUserDialog() | 1257 | void KSMServer::openSwitchUserDialog() | ||
1267 | { | 1258 | { | ||
1268 | //this method exists only for compatibility. Users should ideally call this directly | 1259 | //this method exists only for compatibility. Users should ideally call this directly | ||
1269 | OrgKdeScreensaverInterface iface(QStringLiteral("org.freedesktop.ScreenSaver"), QStringLiteral("/ScreenSaver"), QDBusConnection::sessionBus()); | 1260 | OrgKdeScreensaverInterface iface(QStringLiteral("org.freedesktop.ScreenSaver"), QStringLiteral("/ScreenSaver"), QDBusConnection::sessionBus()); | ||
1270 | iface.SwitchUser(); | 1261 | iface.SwitchUser(); | ||
1271 | } | 1262 | } | ||
1272 | | ||||
1273 | void KSMServer::runShutdownScripts() | | |||
1274 | { | | |||
1275 | const QStringList shutdownFolders = QStandardPaths::locateAll(QStandardPaths::GenericConfigLocation, QStringLiteral("plasma-workspace/shutdown"), QStandardPaths::LocateDirectory); | | |||
1276 | foreach (const QString &shutDownFolder, shutdownFolders) { | | |||
1277 | QDir dir(shutDownFolder); | | |||
1278 | if (!dir.exists()) { | | |||
1279 | continue; | | |||
1280 | } | | |||
1281 | | ||||
1282 | const QStringList entries = dir.entryList(QDir::Files); | | |||
1283 | foreach (const QString &file, entries) { | | |||
1284 | // Don't execute backup files | | |||
1285 | if (!file.endsWith(QLatin1Char('~')) && !file.endsWith(QStringLiteral(".bak")) && | | |||
1286 | (file[0] != QLatin1Char('%') || !file.endsWith(QLatin1Char('%'))) && | | |||
1287 | (file[0] != QLatin1Char('#') || !file.endsWith(QLatin1Char('#')))) | | |||
1288 | { | | |||
1289 | const QString fullPath = dir.absolutePath() + QLatin1Char('/') + file; | | |||
1290 | | ||||
1291 | qCDebug(KSMSERVER) << "running shutdown script" << fullPath; | | |||
1292 | QProcess::execute(fullPath, QStringList()); | | |||
1293 | } | | |||
1294 | } | | |||
1295 | } | | |||
1296 | } | |