diff --git a/ksmserver/CMakeLists.txt b/ksmserver/CMakeLists.txt index 910d6e21f..b2efcafdd 100644 --- a/ksmserver/CMakeLists.txt +++ b/ksmserver/CMakeLists.txt @@ -1,73 +1,73 @@ add_definitions(-DTRANSLATION_DOMAIN=\"ksmserver\") check_library_exists(ICE _IceTransNoListen "" HAVE__ICETRANSNOLISTEN) configure_file(config-ksmserver.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-ksmserver.h) add_definitions("-DQT_NO_CAST_FROM_ASCII -DQT_NO_CAST_TO_ASCII") add_definitions(-DQT_NO_NARROWING_CONVERSIONS_IN_CONNECT) add_definitions(-DQT_NO_URL_CAST_FROM_STRING) include_directories(${CMAKE_CURRENT_BINARY_DIR}) ########### next target ############### set(ksmserver_SRCS main.cpp server.cpp legacy.cpp logout.cpp client.cpp ) ecm_qt_declare_logging_category(ksmserver_SRCS HEADER ksmserver_debug.h IDENTIFIER KSMSERVER CATEGORY_NAME org.kde.kf5.ksmserver) qt5_add_dbus_adaptor( ksmserver_SRCS org.kde.KSMServerInterface.xml server.h KSMServer ) qt5_add_dbus_interface( ksmserver_SRCS ${KSCREENLOCKER_DBUS_INTERFACES_DIR}/org.kde.screensaver.xml kscreenlocker_interface ) qt5_add_dbus_interface( ksmserver_SRCS org.kde.LogoutPrompt.xml logoutprompt_interface) qt5_add_dbus_interface( ksmserver_SRCS org.kde.KWin.Session.xml kwinsession_interface) set(klauncher_xml ${KINIT_DBUS_INTERFACES_DIR}/kf5_org.kde.KLauncher.xml) qt5_add_dbus_interface( ksmserver_SRCS ${klauncher_xml} klauncher_interface ) qt5_add_dbus_interface( ksmserver_SRCS ../startkde/plasma-session/org.kde.Startup.xml startup_interface ) qt5_add_dbus_interface( ksmserver_SRCS ../startkde/plasma-shutdown/org.kde.Shutdown.xml shutdown_interface ) add_executable(ksmserver ${ksmserver_SRCS}) set(CMAKECONFIG_INSTALL_DIR "${KDE_INSTALL_CMAKEPACKAGEDIR}/KSMServerDBusInterface") configure_package_config_file(KSMServerDBusInterfaceConfig.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/KSMServerDBusInterfaceConfig.cmake PATH_VARS KDE_INSTALL_DBUSINTERFACEDIR INSTALL_DESTINATION ${CMAKECONFIG_INSTALL_DIR}) target_link_libraries(ksmserver PW::KScreenLocker PW::KWorkspace KF5::XmlGui KF5::GlobalAccel KF5::I18n KF5::KIOCore - KF5::KIOWidgets + KF5::KIOGui ${X11_LIBRARIES} ${X11_Xrender_LIB} Qt5::X11Extras KF5::Solid Qt5::Quick KF5::Declarative KF5::DBusAddons KF5::Notifications KF5::Package KF5::WindowSystem Qt5::Concurrent ) install(TARGETS ksmserver ${KDE_INSTALL_TARGETS_DEFAULT_ARGS}) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/KSMServerDBusInterfaceConfig.cmake DESTINATION ${CMAKECONFIG_INSTALL_DIR}) ########### install files ############### install( FILES org.kde.KSMServerInterface.xml DESTINATION ${KDE_INSTALL_DBUSINTERFACEDIR}) diff --git a/ksmserver/server.h b/ksmserver/server.h index 1b55cf832..8c8d35e92 100644 --- a/ksmserver/server.h +++ b/ksmserver/server.h @@ -1,250 +1,249 @@ /***************************************************************** ksmserver - the KDE session management server Copyright 2000 Matthias Ettrich 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. ******************************************************************/ #ifndef SERVER_H #define SERVER_H #define INT32 QINT32 #include #include #include extern "C" { #include #include #include #include #include } #include // needed to avoid clash with INT8 defined in X11/Xmd.h on solaris #define QT_CLEAN_NAMESPACE 1 #include #include #include #include #include #include #include #include #include #include #define SESSION_PREVIOUS_LOGOUT "saved at previous logout" #define SESSION_BY_USER "saved by user" class KProcess; class KSMListener; class KSMConnection; class KSMClient; class OrgKdeKWinSessionInterface; enum SMType { SM_ERROR, SM_WMCOMMAND, SM_WMSAVEYOURSELF }; struct SMData { SMType type; QStringList wmCommand; QString wmClientMachine; QString wmclass1, wmclass2; }; typedef QMap WindowMap; class KSMServer : public QObject, protected QDBusContext { Q_OBJECT public: enum class InitFlag { None = 0, OnlyLocal = 1 << 0, ImmediateLockScreen = 1 << 1, NoLockScreen = 1 << 2 }; Q_DECLARE_FLAGS(InitFlags, InitFlag) KSMServer(InitFlags flags ); ~KSMServer() override; static KSMServer* self(); void* watchConnection( IceConn iceConn ); void removeConnection( KSMConnection* conn ); KSMClient* newClient( SmsConn ); void deleteClient( KSMClient* client ); // callbacks void saveYourselfDone( KSMClient* client, bool success ); void interactRequest( KSMClient* client, int dialogType ); void interactDone( KSMClient* client, bool cancelShutdown ); void phase2Request( KSMClient* client ); // error handling void ioError( IceConn iceConn ); // notification void clientRegistered( const char* previousId ); // public API void performLogout(); void restoreSession(); void restoreSession( const QString &sessionName ); void startDefaultSession(); void shutdown( KWorkSpace::ShutdownConfirm confirm, KWorkSpace::ShutdownType sdtype, KWorkSpace::ShutdownMode sdmode ); void setupShortcuts(); Q_SIGNALS: void logoutCancelled(); public Q_SLOTS: void cleanUp(); private Q_SLOTS: void newConnection( int socket ); void processData( int socket ); void protectionTimeout(); void timeoutQuit(); void defaultLogout(); void logoutWithoutConfirmation(); void haltWithoutConfirmation(); void rebootWithoutConfirmation(); private: void handlePendingInteractions(); void completeShutdownOrCheckpoint(); void startKilling(); void startKillingSubSession(); void performStandardKilling(); void completeKilling(); void completeKillingSubSession(); void signalSubSessionClosed(); void cancelShutdown( KSMClient* c ); void killingCompleted(); void discardSession(); void storeSession(); void startProtection(); void endProtection(); - KProcess* startApplication( const QStringList& command, + void startApplication( const QStringList& command, const QString& clientMachine = QString(), - const QString& userId = QString(), - bool wm = false ); + const QString& userId = QString()); void executeCommand( const QStringList& command ); bool defaultSession() const; // empty session void setupXIOErrorHandler(); void performLegacySessionSave(); void storeLegacySession( KConfig* config ); void restoreLegacySession( KConfig* config ); void restoreLegacySessionInternal( KConfigGroup* config, char sep = ',' ); QStringList windowWmCommand(WId w); QString windowWmClientMachine(WId w); WId windowWmClientLeader(WId w); QByteArray windowSessionId(WId w, WId leader); void tryRestoreNext(); void startupDone(); void runShutdownScripts(); // public dcop interface public Q_SLOTS: //public dcop interface void logout( int, int, int ); bool canShutdown(); bool isShuttingDown() const; QString currentSession(); void saveCurrentSession(); void saveCurrentSessionAs( const QString & ); QStringList sessionList(); void saveSubSession( const QString &name, QStringList saveAndClose, QStringList saveOnly = QStringList() ); void restoreSubSession( const QString &name ); void openSwitchUserDialog(); bool closeSession(); Q_SIGNALS: void subSessionClosed(); void subSessionCloseCanceled(); void subSessionOpened(); void sessionRestored(); private: QList listener; QList clients; enum State { Idle, RestoringWMSession, Restoring, Shutdown, Checkpoint, Killing, WaitingForKNotify, // shutdown ClosingSubSession, KillingSubSession, RestoringSubSession }; State state; bool saveSession; int saveType; bool clean; KSMClient* clientInteracting; QString sessionGroup; QTimer protectionTimer; QTimer restoreTimer; QString xonCommand; // sequential startup int appsToStart; int lastAppStarted; QString lastIdStarted; QStringList excludeApps; WindowMap legacyWindows; QDBusMessage m_performLogoutCall; QDBusMessage m_restoreSessionCall; //subSession stuff QList clientsToKill; QList clientsToSave; OrgKdeKWinSessionInterface *m_kwinInterface; int sockets[2]; friend bool readFromPipe(int pipe); }; #endif