PolkitQt-1

polkitqt1-subject.h
1/*
2 This file is part of the PolKit1-qt project
3 SPDX-FileCopyrightText: 2009 Jaroslav Reznik <jreznik@redhat.com>
4
5 SPDX-License-Identifier: LGPL-2.0-or-later
6*/
7
8#ifndef POLKITQT1_SUBJECT_H
9#define POLKITQT1_SUBJECT_H
10
11#include "polkitqt1-core-export.h"
12
13#include <QObject>
14#include <QSharedData>
15
16typedef struct _PolkitSubject PolkitSubject;
17typedef struct _PolkitUnixProcess PolkitUnixProcess;
18typedef struct _PolkitSystemBusName PolkitSystemBusName;
19
20/**
21 * \namespace PolkitQt1 PolkitQt
22 *
23 * \brief Namespace wrapping PolicyKit-Qt classes
24 *
25 * This namespace wraps all PolicyKit-Qt classes.
26 */
27namespace PolkitQt1
28{
29
30class UnixUserIdentity;
31
32/**
33 * \class Subject polkitqt1-subject.h Subject
34 * \author Jaroslav Reznik <jreznik@redhat.com>
35 *
36 * \brief This class represents PolicyKit subjects
37 *
38 * This class encapsulates the PolkitSubject interface.
39 *
40 * \see UnixProcess
41 * \see SystemBusName
42 * \see UnixSession
43 */
44class POLKITQT1_CORE_EXPORT Subject
45{
46public:
47 Subject();
48 Subject(const Subject &other);
49 ~Subject();
50
51 Subject &operator=(const Subject &other);
52
53 bool isValid() const;
54
55 /**
56 * Serialization of object to the string
57 *
58 * \return Serialized Subject object
59 */
60 QString toString() const;
61
62 /**
63 * Creates the Subject object from string reprezentation
64 *
65 * \param string string reprezentation of the object
66 *
67 * \return Pointer to new Subject instance
68 */
69 static Subject fromString(const QString &string);
70
71 /**
72 * Gets PolkitSubject object.
73 *
74 * \warning It shouldn't be used directly unless you are completely aware of what are you doing
75 *
76 * \return Pointer to PolkitSubject instance
77 */
78 PolkitSubject *subject() const;
79
80protected:
81 Subject(PolkitSubject *subject);
82
83 void setSubject(PolkitSubject *subject);
84
85private:
86 class Data;
88};
89
90/**
91 * \class UnixProcessSubject polkitqt1-subject.h Subject
92 * \author Jaroslav Reznik <jreznik@redhat.com>
93 *
94 * \brief A class for representing a UNIX process.
95 *
96 * To uniquely identify processes, both the process
97 * id and the start time of the process (a monotonic
98 * increasing value representing the time since the
99 * kernel was started) is used.
100 *
101 * \sa Subject
102 */
103class POLKITQT1_CORE_EXPORT UnixProcessSubject : public Subject
104{
105public:
106 /**
107 * Subject constructor, takes one parameter - PID. The start time
108 * of process will be looked automatically.
109 *
110 * \param pid An Unix process PID.
111 */
112 explicit UnixProcessSubject(qint64 pid);
113
114 /**
115 * Subject constructor, takes two parameters - PID and start time.
116 *
117 * \param pid An Unix process PID.
118 * \param startTime An Unix process start time.
119 */
120 UnixProcessSubject(qint64 pid, quint64 startTime);
121
122 /**
123 * Subject constructor, it creates UnixProcess object from PolkitUnixProcess object
124 *
125 * \warning Use this only if you are completely aware of what are you doing!
126 *
127 * \param process PolkitUnixProcess object
128 */
129 explicit UnixProcessSubject(PolkitUnixProcess *process);
130
131 /**
132 * Returns Unix process PID.
133 *
134 * \return A PID of associated Unix process.
135 */
136 qint64 pid() const;
137
138 /**
139 * Returns Unix process start time.
140 *
141 * \return A start time of associated Unix process.
142 */
143 qint64 startTime() const;
144
145 /**
146 * Returns Unix process UID.
147 *
148 * \return A UID of associated Unix process.
149 */
150 qint64 uid() const;
151
152 /**
153 * Sets Unix process PID.
154 *
155 * \param pid An Unix process PID.
156 */
157 void setPid(qint64 pid);
158};
159
160/**
161 * \class SystemBusNameSubject polkitqt1-subject.h Subject
162 * \author Jaroslav Reznik <jreznik@redhat.com>
163 *
164 * \brief A class for representing a process owning a unique name on the system bus.
165 *
166 * \sa Subject
167 */
168class POLKITQT1_CORE_EXPORT SystemBusNameSubject : public Subject
169{
170public:
171 /**
172 * Subject constructor, takes one parameter - system bus name.
173 *
174 * \param name A unique system bus name.
175 */
176 explicit SystemBusNameSubject(const QString &name);
177
178 /**
179 * Subject constructor, it creates SystemBusName object from PolkitSystemBusName object
180 *
181 * \warning Use this only if you are completely aware of what are you doing!
182 *
183 * \param pkSystemBusName PolkitSystemBusName object
184 */
185 explicit SystemBusNameSubject(PolkitSystemBusName *pkSystemBusName);
186
187 /**
188 * Returns system bus name.
189 *
190 * \return A unique system bus name.
191 */
192 QString name() const;
193
194 /**
195 * Sets system bus name.
196 *
197 * \param name System bus name.
198 */
199 void setName(const QString &name);
200
201 /**
202 * Returns the UnixUserIdentity for this subject.
203 *
204 * \note This can be an invalid UnixUserIdentity so be sure to check before using it
205 *
206 * \since 0.113
207 **/
208 UnixUserIdentity user();
209};
210
211/**
212 * \class UnixSessionSubject polkitqt1-subject.h Subject
213 * \author Jaroslav Reznik <jreznik@redhat.com>
214 *
215 * \brief A class for representing unix session.
216 *
217 * The session id is an opaque string obtained from
218 * ConsoleKit.
219 *
220 * \sa Subject
221 */
222class POLKITQT1_CORE_EXPORT UnixSessionSubject : public Subject
223{
224public:
225 /**
226 * Subject constructor, takes one parameter - session id.
227 *
228 * \param sessionId The session id.
229 */
230 explicit UnixSessionSubject(const QString &sessionId);
231
232 /**
233 * Subject constructor, takes one parameter - pid of process.
234 *
235 * Synchronous!
236 *
237 * \param pid The session's process pid.
238 */
239 explicit UnixSessionSubject(qint64 pid);
240
241 /**
242 * Subject constructor, it creates UnixSession object from PolkitUnixSession object
243 *
244 * \warning Use this only if you are completely aware of what are you doing!
245 *
246 * \param pkUnixSession PolkitUnixSession object
247 */
248 explicit UnixSessionSubject(PolkitSystemBusName *pkUnixSession);
249
250 /**
251 * Returns session id.
252 *
253 * \return A session id.
254 */
255 QString sessionId() const;
256
257 /**
258 * Sets session id.
259 *
260 * \param sessionId A session id.
261 */
262 void setSessionId(const QString &sessionId);
263};
264
265}
266
267#endif
This class represents PolicyKit subjects.
A class for representing a process owning a unique name on the system bus.
A class for representing a UNIX process.
A class for representing unix session.
An object representing a user identity on a UNIX system.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Dec 27 2024 11:53:14 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.