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 <sitter@kde.org>
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 */
15namespace KSandbox
16{
17
18/// @returns whether the application is inside one of the supported sandboxes
19KCOREADDONS_EXPORT bool isInside();
20
21/// @returns whether the application is inside a flatpak sandbox
22KCOREADDONS_EXPORT bool isFlatpak();
23
24/// @returns whether the application is inside a snap sandbox
25KCOREADDONS_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 */
40KCOREADDONS_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 */
46KCOREADDONS_EXPORT void startHostProcess(QProcess &process, QProcess::OpenMode mode = QProcess::ReadWrite);
47
48} // namespace KSandbox
49
50#endif // KSANDBOX_H
Utility functions for use inside application sandboxes such as flatpak or snap.
Definition ksandbox.h:16
KCOREADDONS_EXPORT bool isFlatpak()
Definition ksandbox.cpp:17
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 isInside()
Definition ksandbox.cpp:11
KCOREADDONS_EXPORT KSandbox::ProcessContext makeHostContext(const QProcess &process)
Definition ksandbox.cpp:39
KCOREADDONS_EXPORT bool isSnap()
Definition ksandbox.cpp:23
typedef OpenMode
Container for host process startup context.
Definition ksandbox.h:31
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:13:31 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.