1/*
2 SPDX-FileCopyrightText: 2020 Kai Uwe Broulik <kde@broulik.de>
3 SPDX-FileCopyrightText: 2021 David Edmundson <davidedmundson@kde.org>
4
5 SPDX-License-Identifier: LGPL-2.0-or-later
6*/
7
8#ifndef KUPDATELAUNCHENVIRONMENTJOB_H
9#define KUPDATELAUNCHENVIRONMENTJOB_H
10
11#include <kdbusaddons_export.h>
12
13#include <QProcessEnvironment>
14
15#include <memory>
16
17class QString;
18class KUpdateLaunchEnvironmentJobPrivate;
19
20/*!
21 * \class KUpdateLaunchEnvironmentJob
22 * \inmodule KDBusAddons
23 * \brief Job for updating the launch environment.
24 *
25 * This job adds or updates an environment variable in process environment that will be used
26 * when a process is launched. This includes:
27 *
28 * \list
29 * \li DBus activation
30 * \li Systemd units
31 * \li Plasma-session
32 * \endlist
33 *
34 * Environment variables are sanitized before uploading.
35 *
36 * This object deletes itself after completion, similar to KJobs.
37 *
38 * Example usage:
39 *
40 * \code
41 * QProcessEnvironment newEnv;
42 * newEnv.insert("VARIABLE"_s, "value"_s);
43 * auto job = new KUpdateLaunchEnvironmentJob(newEnv);
44 * QObject::connect(job, &KUpdateLaunchEnvironmentJob::finished, &SomeClass, &SomeClass::someSlot);
45 * \endcode
46 *
47 * Porting from KF5 to KF6:
48 *
49 * The class UpdateLaunchEnvironmentJob was renamed to KUpdateLaunchEnvironmentJob.
50 *
51 * \since 6.0
52 */
53class KDBUSADDONS_EXPORT KUpdateLaunchEnvironmentJob : public QObject
54{
55 Q_OBJECT
56
57public:
58 /*!
59 * Creates a new job for the given launch \a environment.
60 */
61 explicit KUpdateLaunchEnvironmentJob(const QProcessEnvironment &environment);
62 ~KUpdateLaunchEnvironmentJob() override;
63
64Q_SIGNALS:
65 /*!
66 * Emitted when the job is finished, before the object is automatically deleted.
67 */
68 void finished();
69
70private:
71 KDBUSADDONS_NO_EXPORT void start();
72
73private:
74 std::unique_ptr<KUpdateLaunchEnvironmentJobPrivate> const d;
75};
76
77#endif
78

source code of kdbusaddons/src/kupdatelaunchenvironmentjob.h