1 /* This file is part of the KDE libraries
2 Copyright (C) 1997 Matthias Kalle Dalheimer (kalle@kde.org)
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 Boston, MA 02110-1301, USA.
23 #include <kdemacros.h>
29 * The possible values for the @p confirm parameter of requestShutDown().
31 enum ShutdownConfirm
{
33 * Obey the user's confirmation setting.
35 ShutdownConfirmDefault
= -1,
37 * Don't confirm, shutdown without asking.
39 ShutdownConfirmNo
= 0,
41 * Always confirm, ask even if the user turned it off.
43 ShutdownConfirmYes
= 1
47 * The possible values for the @p sdtype parameter of requestShutDown().
51 * Select previous action or the default if it's the first time.
53 ShutdownTypeDefault
= -1,
55 * Only show log out dialog
59 * Log out and reboot the machine.
61 ShutdownTypeReboot
= 1,
63 * Log out and halt the machine.
69 ShutdownTypeLogout
= 3
73 * The possible values for the @p sdmode parameter of requestShutDown().
77 * Select previous mode or the default if it's the first time.
79 ShutdownModeDefault
= -1,
81 * Schedule a shutdown (halt or reboot) for the time all active sessions
84 ShutdownModeSchedule
= 0,
86 * Shut down, if no sessions are active. Otherwise do nothing.
88 ShutdownModeTryNow
= 1,
90 * Force shutdown. Kill any possibly active sessions.
92 ShutdownModeForceNow
= 2,
94 * Pop up a dialog asking the user what to do if sessions are still active.
96 ShutdownModeInteractive
= 3
100 * Asks the session manager to shut the session down.
102 * Using @p confirm == ShutdownConfirmYes or @p sdtype != ShutdownTypeDefault or
103 * @p sdmode != ShutdownModeDefault causes the use of ksmserver's DCOP
104 * interface. The remaining two combinations use the standard XSMP and
105 * will work with any session manager compliant with it.
107 * @param confirm Whether to ask the user if he really wants to log out.
109 * @param sdtype The action to take after logging out. ShutdownType
110 * @param sdmode If/When the action should be taken. ShutdownMode
111 * @return true on success, false if the session manager could not be
114 KDE_EXPORT
bool requestShutDown( ShutdownConfirm confirm
= ShutdownConfirmDefault
,
115 ShutdownType sdtype
= ShutdownTypeDefault
,
116 ShutdownMode sdmode
= ShutdownModeDefault
);
119 * Used to check whether a requestShutDown call with the same arguments
120 * has any chance of succeeding.
122 * For example, if KDE's own session manager cannot be contacted, we can't
123 * demand that the computer be shutdown, or force a confirmation dialog.
125 * Even if we can access the KDE session manager, the system or user
126 * configuration may prevent the user from requesting a shutdown or
129 KDE_EXPORT
bool canShutDown( ShutdownConfirm confirm
= ShutdownConfirmDefault
,
130 ShutdownType sdtype
= ShutdownTypeDefault
,
131 ShutdownMode sdmode
= ShutdownModeDefault
);
134 * Propagates the network address of the session manager in the
135 * SESSION_MANAGER environment variable so that child processes can
138 * If SESSION_MANAGER isn't defined yet, the address is searched in
141 * This function is called by clients that are started outside the
142 * session ( i.e. before ksmserver is started), but want to launch
143 * other processes that should participate in the session. Examples
144 * are kdesktop or kicker.
146 KDE_EXPORT
void propagateSessionManager();