KCoreAddons

ksandbox.h
1 // SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
2 // SPDX-FileCopyrightText: 2022 Harald Sitter <[email protected]>
3 
4 #ifndef KSANDBOX_H
5 #define KSANDBOX_H
6 
7 #include <QProcess>
8 
9 #include <kcoreaddons_export.h>
10 
11 /**
12  * @brief Utility functions for use inside application sandboxes such as flatpak or snap.
13  * @since 5.95
14  */
15 namespace KSandbox
16 {
17 
18 /// @returns whether the application is inside one of the supported sandboxes
19 KCOREADDONS_EXPORT bool isInside();
20 
21 /// @returns whether the application is inside a flatpak sandbox
22 KCOREADDONS_EXPORT bool isFlatpak();
23 
24 /// @returns whether the application is inside a snap sandbox
25 KCOREADDONS_EXPORT bool isSnap();
26 
27 /**
28  * @brief Container for host process startup context
29  * @since 5.97
30  */
32  const QString program;
33  const QStringList arguments;
34 };
35 
36 /**
37  * @returns the actual program and arguments for running the QProcess on the host (e.g. a flatpak-spawn-wrapped argument list)
38  * @since 5.97
39  */
40 KCOREADDONS_EXPORT KSandbox::ProcessContext makeHostContext(const QProcess &process);
41 
42 /**
43  * Starts the QProcess on the host (if the current context is inside a sandbox, otherwise it simply runs QProcess::start)
44  * @since 5.97
45  */
46 KCOREADDONS_EXPORT void startHostProcess(QProcess &process, QProcess::OpenMode mode = QProcess::ReadWrite);
47 
48 } // namespace KSandbox
49 
50 #endif // KSANDBOX_H
KCOREADDONS_EXPORT bool isSnap()
Definition: ksandbox.cpp:23
typedef OpenMode
Utility functions for use inside application sandboxes such as flatpak or snap.
Definition: ksandbox.h:15
Container for host process startup context.
Definition: ksandbox.h:31
KCOREADDONS_EXPORT void startHostProcess(QProcess &process, QProcess::OpenMode mode=QProcess::ReadWrite)
Starts the QProcess on the host (if the current context is inside a sandbox, otherwise it simply runs...
Definition: ksandbox.cpp:70
KCOREADDONS_EXPORT bool isFlatpak()
Definition: ksandbox.cpp:17
KCOREADDONS_EXPORT KSandbox::ProcessContext makeHostContext(const QProcess &process)
Definition: ksandbox.cpp:39
KCOREADDONS_EXPORT bool isInside()
Definition: ksandbox.cpp:11
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Tue Feb 7 2023 04:11:52 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.