File indexing completed on 2024-04-28 16:54:31

0001 /*
0002     SPDX-FileCopyrightText: 1997 Matthias Kalle Dalheimer <kalle@kde.org>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #pragma once
0008 
0009 #include "kworkspace_export.h"
0010 
0011 namespace KWorkSpace
0012 {
0013 /**
0014  * The possible values for the @p confirm parameter of requestShutDown().
0015  */
0016 enum ShutdownConfirm {
0017     /**
0018      * Obey the user's confirmation setting.
0019      */
0020     ShutdownConfirmDefault = -1,
0021     /**
0022      * Don't confirm, shutdown without asking.
0023      */
0024     ShutdownConfirmNo = 0,
0025     /**
0026      * Always confirm, ask even if the user turned it off.
0027      */
0028     ShutdownConfirmYes = 1,
0029 };
0030 
0031 /**
0032  * The possible values for the @p sdtype parameter of requestShutDown().
0033  */
0034 enum ShutdownType {
0035     /**
0036      * Select previous action or the default if it's the first time.
0037      */
0038     ShutdownTypeDefault = -1,
0039     /**
0040      * Only log out
0041      */
0042     ShutdownTypeNone = 0,
0043     /**
0044      * Log out and reboot the machine.
0045      */
0046     ShutdownTypeReboot = 1,
0047     /**
0048      * Log out and halt the machine.
0049      */
0050     ShutdownTypeHalt = 2,
0051     /**
0052      * Temporary brain damage. Don't use. Same as ShutdownTypeNone
0053      */
0054     // KDE5: kill this
0055     ShutdownTypeLogout = 3,
0056 };
0057 
0058 /**
0059  * The possible values for the @p sdmode parameter of requestShutDown().
0060  */
0061 // KDE5: this seems fairly useless
0062 enum ShutdownMode {
0063     /**
0064      * Select previous mode or the default if it's the first time.
0065      */
0066     ShutdownModeDefault = -1,
0067     /**
0068      * Schedule a shutdown (halt or reboot) for the time all active sessions
0069      * have exited.
0070      */
0071     ShutdownModeSchedule = 0,
0072     /**
0073      * Shut down, if no sessions are active. Otherwise do nothing.
0074      */
0075     ShutdownModeTryNow = 1,
0076     /**
0077      * Force shutdown. Kill any possibly active sessions.
0078      */
0079     ShutdownModeForceNow = 2,
0080     /**
0081      * Pop up a dialog asking the user what to do if sessions are still active.
0082      */
0083     ShutdownModeInteractive = 3,
0084 };
0085 
0086 /**
0087  * Asks the session manager to shut the session down.
0088  *
0089  * Using @p confirm == ShutdownConfirmYes or @p sdtype != ShutdownTypeDefault or
0090  * @p sdmode != ShutdownModeDefault causes the use of ksmserver's DCOP
0091  * interface. The remaining two combinations use the standard XSMP and
0092  * will work with any session manager compliant with it.
0093  *
0094  * @param confirm Whether to ask the user if he really wants to log out.
0095  * ShutdownConfirm
0096  * @param sdtype The action to take after logging out. ShutdownType
0097  * @param sdmode If/When the action should be taken. ShutdownMode
0098  * @deprecated
0099  */
0100 KWORKSPACE_EXPORT void
0101 requestShutDown(ShutdownConfirm confirm = ShutdownConfirmDefault, ShutdownType sdtype = ShutdownTypeDefault, ShutdownMode sdmode = ShutdownModeDefault);
0102 
0103 /**
0104  * Used to check whether a requestShutDown call with the same arguments
0105  * has any chance of succeeding.
0106  *
0107  * For example, if KDE's own session manager cannot be contacted, we can't
0108  * demand that the computer be shutdown, or force a confirmation dialog.
0109  *
0110  * Even if we can access the KDE session manager, the system or user
0111  * configuration may prevent the user from requesting a shutdown or
0112  * reboot.
0113  * @deprecated
0114  */
0115 KWORKSPACE_EXPORT bool
0116 canShutDown(ShutdownConfirm confirm = ShutdownConfirmDefault, ShutdownType sdtype = ShutdownTypeDefault, ShutdownMode sdmode = ShutdownModeDefault);
0117 
0118 /**
0119  * Used to check whether a shutdown is currently in progress
0120  */
0121 KWORKSPACE_EXPORT bool isShuttingDown();
0122 
0123 /**
0124  * Propagates the network address of the session manager in the
0125  * SESSION_MANAGER environment variable so that child processes can
0126  * pick it up.
0127  *
0128  * If SESSION_MANAGER isn't defined yet, the address is searched in
0129  * $HOME/.KSMserver.
0130  *
0131  * This function is called by clients that are started outside the
0132  * session ( i.e. before ksmserver is started), but want to launch
0133  * other processes that should participate in the session.  Examples
0134  * are kdesktop or kicker.
0135  */
0136 KWORKSPACE_EXPORT void propagateSessionManager();
0137 
0138 /**
0139  * Performs platform detection and adjusts QT_QPA_PLATFORM environment
0140  * variable to either xcb or wayland depending on the detected platform.
0141  *
0142  * The detection is based on the XDG_SESSION_TYPE environment variable.
0143  * The detection is skipped in case QT_QPA_PLATFORM is already set or
0144  * if one of the command line arguments contains the "-platform" variable.
0145  *
0146  * In order to make use of this function, it has to be invoked before the
0147  * QGuiApplication instance is constructed. Invoking after constructing the
0148  * QGuiApplication has no effect.
0149  * @since 5.13
0150  **/
0151 KWORKSPACE_EXPORT void detectPlatform(int argc, char **argv);
0152 
0153 }