Changeset View
Changeset View
Standalone View
Standalone View
ksmserver/logout.cpp
Show First 20 Lines • Show All 70 Lines • ▼ Show 20 Line(s) | |||||
71 | #include <KLocalizedString> | 71 | #include <KLocalizedString> | ||
72 | #include <KUserTimestamp> | 72 | #include <KUserTimestamp> | ||
73 | #include <KNotification> | 73 | #include <KNotification> | ||
74 | #include <kdisplaymanager.h> | 74 | #include <kdisplaymanager.h> | ||
75 | #include "server.h" | 75 | #include "server.h" | ||
76 | #include "global.h" | 76 | #include "global.h" | ||
77 | #include "client.h" | 77 | #include "client.h" | ||
78 | 78 | | |||
79 | #include <solid/powermanagement.h> | | |||
80 | | ||||
81 | #include "logoutprompt_interface.h" | 79 | #include "logoutprompt_interface.h" | ||
82 | #include "shutdown_interface.h" | 80 | #include "shutdown_interface.h" | ||
83 | 81 | | |||
84 | #include <QDesktopWidget> | 82 | #include <QDesktopWidget> | ||
85 | #include <QX11Info> | 83 | #include <QX11Info> | ||
86 | #include <X11/Xutil.h> | 84 | #include <X11/Xutil.h> | ||
87 | #include <X11/Xatom.h> | 85 | #include <X11/Xatom.h> | ||
88 | 86 | | |||
▲ Show 20 Lines • Show All 90 Lines • ▼ Show 20 Line(s) | 176 | { | |||
179 | if( state >= Shutdown ) { // already performing shutdown | 177 | if( state >= Shutdown ) { // already performing shutdown | ||
180 | return; | 178 | return; | ||
181 | } | 179 | } | ||
182 | if (state != Idle) { | 180 | if (state != Idle) { | ||
183 | QTimer::singleShot(1000, this, &KSMServer::performLogout); | 181 | QTimer::singleShot(1000, this, &KSMServer::performLogout); | ||
184 | } | 182 | } | ||
185 | state = Shutdown; | 183 | state = Shutdown; | ||
186 | 184 | | |||
187 | // If the logout was confirmed, let's start a powermanagement inhibition. | | |||
188 | // We store the cookie so we can interrupt it if the logout will be canceled | | |||
189 | inhibitCookie = Solid::PowerManagement::beginSuppressingSleep(QStringLiteral("Shutting down system")); | | |||
190 | | ||||
191 | // shall we save the session on logout? | 185 | // shall we save the session on logout? | ||
192 | KConfigGroup cg(KSharedConfig::openConfig(), "General"); | 186 | KConfigGroup cg(KSharedConfig::openConfig(), "General"); | ||
193 | saveSession = ( cg.readEntry( "loginMode", | 187 | saveSession = ( cg.readEntry( "loginMode", | ||
194 | QStringLiteral( "restorePreviousLogout" ) ) | 188 | QStringLiteral( "restorePreviousLogout" ) ) | ||
195 | == QStringLiteral( "restorePreviousLogout" ) ); | 189 | == QStringLiteral( "restorePreviousLogout" ) ); | ||
196 | 190 | | |||
197 | qCDebug(KSMSERVER) << "saveSession is " << saveSession; | 191 | qCDebug(KSMSERVER) << "saveSession is " << saveSession; | ||
198 | 192 | | |||
▲ Show 20 Lines • Show All 188 Lines • ▼ Show 20 Line(s) | |||||
387 | void KSMServer::cancelShutdown( KSMClient* c ) | 381 | void KSMServer::cancelShutdown( KSMClient* c ) | ||
388 | { | 382 | { | ||
389 | clientInteracting = nullptr; | 383 | clientInteracting = nullptr; | ||
390 | qCDebug(KSMSERVER) << state; | 384 | qCDebug(KSMSERVER) << state; | ||
391 | if ( state == ClosingSubSession ) { | 385 | if ( state == ClosingSubSession ) { | ||
392 | clientsToKill.clear(); | 386 | clientsToKill.clear(); | ||
393 | clientsToSave.clear(); | 387 | clientsToSave.clear(); | ||
394 | emit subSessionCloseCanceled(); | 388 | emit subSessionCloseCanceled(); | ||
395 | } else { | 389 | } else { | ||
396 | Solid::PowerManagement::stopSuppressingSleep(inhibitCookie); | | |||
397 | qCDebug(KSMSERVER) << "Client " << c->program() << " (" << c->clientId() << ") canceled shutdown."; | 390 | qCDebug(KSMSERVER) << "Client " << c->program() << " (" << c->clientId() << ") canceled shutdown."; | ||
anthonyfieroni: Make job autodelete if not. | |||||
bruns: This is no KJob | |||||
398 | KNotification::event( QStringLiteral( "cancellogout" ), | 391 | KNotification::event( QStringLiteral( "cancellogout" ), | ||
399 | i18n( "Logout canceled by '%1'", c->program()), | 392 | i18n( "Logout canceled by '%1'", c->program()), | ||
400 | QPixmap() , nullptr , KNotification::DefaultEvent ); | 393 | QPixmap() , nullptr , KNotification::DefaultEvent ); | ||
401 | foreach( KSMClient* c, clients ) { | 394 | foreach( KSMClient* c, clients ) { | ||
402 | SmsShutdownCancelled( c->connection() ); | 395 | SmsShutdownCancelled( c->connection() ); | ||
403 | if( c->saveYourselfDone ) { | 396 | if( c->saveYourselfDone ) { | ||
404 | // Discard also saved state. | 397 | // Discard also saved state. | ||
405 | QStringList discard = c->discardCommand(); | 398 | QStringList discard = c->discardCommand(); | ||
▲ Show 20 Lines • Show All 301 Lines • Show Last 20 Lines |
Make job autodelete if not.