1/* This file is part of the KDE libraries
2 Copyright (C) 1997 Matthias Kalle Dalheimer (kalle@kde.org)
3
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.
8
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.
13
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.
18*/
19
20#ifndef KWORKSPACE_H
21#define KWORKSPACE_H
22
23#include "kworkspace_export.h"
24
25namespace KWorkSpace
26{
27
28 /**
29 * The possible values for the @p confirm parameter of requestShutDown().
30 */
31 enum ShutdownConfirm {
32 /**
33 * Obey the user's confirmation setting.
34 */
35 ShutdownConfirmDefault = -1,
36 /**
37 * Don't confirm, shutdown without asking.
38 */
39 ShutdownConfirmNo = 0,
40 /**
41 * Always confirm, ask even if the user turned it off.
42 */
43 ShutdownConfirmYes = 1
44 };
45
46 /**
47 * The possible values for the @p sdtype parameter of requestShutDown().
48 */
49 enum ShutdownType {
50 /**
51 * Select previous action or the default if it's the first time.
52 */
53 ShutdownTypeDefault = -1,
54 /**
55 * Only log out
56 */
57 ShutdownTypeNone = 0,
58 /**
59 * Log out and reboot the machine.
60 */
61 ShutdownTypeReboot = 1,
62 /**
63 * Log out and halt the machine.
64 */
65 ShutdownTypeHalt = 2,
66 /**
67 * Temporary brain damage. Don't use. Same as ShutdownTypeNone
68 */
69 // KDE5: kill this
70 ShutdownTypeLogout = 3
71 };
72
73 /**
74 * The possible values for the @p sdmode parameter of requestShutDown().
75 */
76 // KDE5: this seems fairly useless
77 enum ShutdownMode {
78 /**
79 * Select previous mode or the default if it's the first time.
80 */
81 ShutdownModeDefault = -1,
82 /**
83 * Schedule a shutdown (halt or reboot) for the time all active sessions
84 * have exited.
85 */
86 ShutdownModeSchedule = 0,
87 /**
88 * Shut down, if no sessions are active. Otherwise do nothing.
89 */
90 ShutdownModeTryNow = 1,
91 /**
92 * Force shutdown. Kill any possibly active sessions.
93 */
94 ShutdownModeForceNow = 2,
95 /**
96 * Pop up a dialog asking the user what to do if sessions are still active.
97 */
98 ShutdownModeInteractive = 3
99 };
100
101 /**
102 * Asks the session manager to shut the session down.
103 *
104 * Using @p confirm == ShutdownConfirmYes or @p sdtype != ShutdownTypeDefault or
105 * @p sdmode != ShutdownModeDefault causes the use of ksmserver's DCOP
106 * interface. The remaining two combinations use the standard XSMP and
107 * will work with any session manager compliant with it.
108 *
109 * @param confirm Whether to ask the user if he really wants to log out.
110 * ShutdownConfirm
111 * @param sdtype The action to take after logging out. ShutdownType
112 * @param sdmode If/When the action should be taken. ShutdownMode
113 */
114 KWORKSPACE_EXPORT void requestShutDown( ShutdownConfirm confirm = ShutdownConfirmDefault,
115 ShutdownType sdtype = ShutdownTypeDefault,
116 ShutdownMode sdmode = ShutdownModeDefault );
117
118 /**
119 * Used to check whether a requestShutDown call with the same arguments
120 * has any chance of succeeding.
121 *
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.
124 *
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
127 * reboot.
128 */
129 KWORKSPACE_EXPORT bool canShutDown( ShutdownConfirm confirm = ShutdownConfirmDefault,
130 ShutdownType sdtype = ShutdownTypeDefault,
131 ShutdownMode sdmode = ShutdownModeDefault );
132
133 /**
134 * Propagates the network address of the session manager in the
135 * SESSION_MANAGER environment variable so that child processes can
136 * pick it up.
137 *
138 * If SESSION_MANAGER isn't defined yet, the address is searched in
139 * $HOME/.KSMserver.
140 *
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.
145 */
146 KWORKSPACE_EXPORT void propagateSessionManager();
147
148}
149
150#endif
151