1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
|
/*
* This file is part of the PolKit-tqt project
* Copyright (C) 2009 Jaroslav Reznik <jreznik@redhat.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef POLKIT_TQT_SUBJECT_H
#define POLKIT_TQT_SUBJECT_H
#include "polkit-tqt-export.h"
typedef struct _PolkitSubject PolkitSubject;
typedef struct _PolkitUnixProcess PolkitUnixProcess;
typedef struct _PolkitSystemBusName PolkitSystemBusName;
class TQString;
/**
* \namespace PolkitTQt PolkitTQt
*
* \brief Namespace wrapping PolicyKit-TQt classes
*
* This namespace wraps all PolicyKit-TQt classes.
*/
namespace PolkitTQt
{
/**
* \class Subject polkit-tqt-subject.h Subject
* \author Jaroslav Reznik <jreznik@redhat.com>
*
* \brief This class represents PolicyKit subjects
*
* This class encapsulates the PolkitSubject interface.
*
* \see UnixProcess
* \see SystemBusName
* \see UnixSession
*/
class POLKIT_TQT_EXPORT Subject
{
public:
Subject();
Subject(const Subject &other);
~Subject();
/**
* Creates a Subject object from PolkitSubject
*
* \warning It shouldn't be used directly unless you are completely aware of what are you doing
*
* \param pkSubject PolkitSubject object
*/
explicit Subject(PolkitSubject *pkSubject);
Subject& operator=(const Subject &other);
/**
* Check whether a subject is valid
*
* \return true is the subject is valid
*/
bool isValid() const;
/**
* Serialization of object to the string
*
* \return Serialized Subject object
*/
TQString toString() const;
/**
* Creates the Subject object from string representation
*
* \param string string representation of the object
*
* \return the new Subject instance
*/
static Subject fromString(const TQString &string);
/**
* Gets PolkitSubject object.
*
* \warning It shouldn't be used directly unless you are completely aware of what are you doing
*
* \return Pointer to PolkitSubject instance
*/
PolkitSubject* subject() const;
void setSubject(PolkitSubject *subject);
private:
class Data;
Data *d;
};
/**
* \class UnixProcessSubject polkit-tqt-subject.h Subject
* \author Jaroslav Reznik <jreznik@redhat.com>
*
* \brief A class for representing a UNIX process.
*
* To uniquely identify processes, both the process
* id and the start time of the process (a monotonic
* increasing value representing the time since the
* kernel was started) is used.
*
* \sa Subject
*/
class POLKIT_TQT_EXPORT UnixProcessSubject : public Subject
{
public:
/**
* Subject constructor, takes one parameter - PID. The start time
* of process will be looked automatically.
*
* \param pid An Unix process PID.
*/
explicit UnixProcessSubject(TQ_LONG pid);
/**
* Subject constructor, takes two parameters - PID and start time.
*
* \param pid An Unix process PID.
* \param startTime An Unix process start time.
*/
UnixProcessSubject(TQ_LONG pid, TQ_ULONG startTime);
/**
* Subject constructor, it creates UnixProcess object from PolkitUnixProcess object
*
* \warning Use this only if you are completely aware of what are you doing!
*
* \param process PolkitUnixProcess object
*/
explicit UnixProcessSubject(PolkitUnixProcess *process);
/**
* Returns Unix process PID.
*
* \return A PID of associated Unix process.
*/
TQ_LONG pid() const;
/**
* Returns Unix process start time.
*
* \return A start time of associated Unix process.
*/
TQ_LONG startTime() const;
/**
* Sets Unix process PID.
*
* \param pid An Unix process PID.
*/
void setPid(TQ_LONG pid);
};
/**
* \class SystemBusNameSubject polkit-tqt-subject.h Subject
* \author Jaroslav Reznik <jreznik@redhat.com>
*
* \brief A class for representing a process owning a unique name on the system bus.
*
* \sa Subject
*/
class POLKIT_TQT_EXPORT SystemBusNameSubject : public Subject
{
public:
/**
* Subject constructor, takes one parameter - system bus name.
*
* \param name A unique system bus name.
*/
explicit SystemBusNameSubject(const TQString &name);
/**
* Subject constructor, it creates SystemBusName object from PolkitSystemBusName object
*
* \warning Use this only if you are completely aware of what are you doing!
*
* \param pkSystemBusName PolkitSystemBusName object
*/
explicit SystemBusNameSubject(PolkitSystemBusName *pkSystemBusName);
/**
* Returns system bus name.
*
* \return A unique system bus name.
*/
TQString name() const;
/**
* Sets system bus name.
*
* \param name System bus name.
*/
void setName(const TQString &name);
};
/**
* \class UnixSessionSubject polkit-tqt-subject.h Subject
* \author Jaroslav Reznik <jreznik@redhat.com>
*
* \brief A class for representing unix session.
*
* \sa Subject
*/
class POLKIT_TQT_EXPORT UnixSessionSubject : public Subject
{
public:
/**
* Subject constructor, takes one parameter - session id.
*
* \param sessionId The session id.
*/
explicit UnixSessionSubject(const TQString &sessionId);
/**
* Subject constructor, takes one parameter - pid of process.
*
* Synchronous!
*
* \param pid The session's process pid.
*/
explicit UnixSessionSubject(TQ_LONG pid);
/**
* Subject constructor, it creates UnixSession object from PolkitUnixSession object
*
* \warning Use this only if you are completely aware of what are you doing!
*
* \param pkUnixSession PolkitUnixSession object
*/
explicit UnixSessionSubject(PolkitSystemBusName *pkUnixSession);
/**
* Returns session id.
*
* \return A session id.
*/
TQString sessionId() const;
/**
* Sets session id.
*
* \param sessionId A session id.
*/
void setSessionId(const TQString &sessionId);
};
}
#endif
|