PolkitQt-1

polkitqt1-identity.h
1/*
2 This file is part of the Polkit-qt project
3 SPDX-FileCopyrightText: 2009 Lukas Tinkl <ltinkl@redhat.com>
4
5 SPDX-License-Identifier: LGPL-2.0-or-later
6*/
7
8#ifndef POLKITQT1_IDENTITY_H
9#define POLKITQT1_IDENTITY_H
10
11#include "polkitqt1-core-export.h"
12
13#include <unistd.h>
14
15#include <QObject>
16#include <QSharedData>
17
18typedef struct _PolkitIdentity PolkitIdentity;
19typedef struct _PolkitUnixUser PolkitUnixUser;
20typedef struct _PolkitUnixGroup PolkitUnixGroup;
21
22/**
23 * \namespace PolkitQt1 PolkitQt
24 *
25 * \brief Namespace wrapping Polkit-Qt classes
26 *
27 * This namespace wraps all Polkit-Qt classes.
28 */
29namespace PolkitQt1
30{
31
32class UnixUserIdentity;
33class UnixGroupIdentity;
34
35/**
36 * \class Identity polkitqt1-identity.h Identity
37 * \author Lukas Tinkl <ltinkl@redhat.com>
38 *
39 * This class encapsulates the PolkitIdentity interface.
40 *
41 * \brief Abstract class representing identities
42 *
43 * \see UnixGroup
44 * \see UnixUser
45 */
46class POLKITQT1_CORE_EXPORT Identity
47{
48public:
49 typedef QList< Identity > List;
50
51 Identity();
52 explicit Identity(PolkitIdentity *polkitIdentity);
53 Identity(const Identity &other);
54
55 ~Identity();
56
57 Identity &operator=(const Identity &other);
58
59 bool isValid() const;
60
61 /**
62 * Serialization of object to the string
63 *
64 * \return Serialized Identity object
65 */
66 QString toString() const;
67
68 /**
69 * Creates the Identity object from string representation
70 *
71 * \param string string representation of the object
72 *
73 * \return Pointer to new Identity instance
74 */
75 static Identity fromString(const QString &string);
76
77 UnixUserIdentity toUnixUserIdentity();
78 UnixGroupIdentity toUnixGroupIdentity();
79
80 /**
81 * Gets PolkitIdentity object.
82 *
83 * \warning It shouldn't be used directly unless you are completely aware of what are you doing
84 *
85 * \return Pointer to PolkitIdentity instance
86 */
87 PolkitIdentity *identity() const;
88protected:
89 void setIdentity(PolkitIdentity *identity);
90
91private:
92 class Data;
94};
95
96/**
97 * \class UnixUserIdentity polkitqt1-identity.h Identity
98 *
99 * An object representing a user identity on a UNIX system.
100 *
101 * \brief UNIX user identity
102 * \sa Identity
103 */
104class POLKITQT1_CORE_EXPORT UnixUserIdentity : public Identity
105{
106public:
108 /**
109 * Creates UnixUser object by UID of the user
110 *
111 * \param uid user id
112 */
113 explicit UnixUserIdentity(uid_t uid);
114
115 /**
116 * Creates UnixUser object by unix name of the user
117 *
118 * \param name Unix name
119 */
120 explicit UnixUserIdentity(const QString &name);
121
122 /**
123 * Creates UnixUser object from PolkitUnixUser object
124 *
125 * \warning Use this only if you are completely aware of what are you doing!
126 *
127 * \param pkUnixUser The PolkitUnixUser object
128 */
129 explicit UnixUserIdentity(PolkitUnixUser *pkUnixUser);
130
131 /**
132 * Gets an user id
133 *
134 * \return user id
135 */
136 uid_t uid() const;
137
138 /**
139 * Sets the id of user
140 *
141 * \param uid user id
142 */
143 void setUid(uid_t uid);
144};
145
146/**
147 * \class UnixGroupIdentity polkitqt1-identity.h Identity
148 *
149 * An object representing a group identity on a UNIX system.
150 *
151 * \brief UNIX group identity
152 * \sa Identity
153 */
154class POLKITQT1_CORE_EXPORT UnixGroupIdentity : public Identity
155{
156public:
158 /**
159 * Creates UnixGroup object by GID of the group
160 *
161 * \param gid group id
162 */
163 explicit UnixGroupIdentity(gid_t gid);
164
165 /**
166 * Creates UnixGroup object by unix name of the group
167 *
168 * \param name group name
169 */
170 explicit UnixGroupIdentity(const QString &name);
171
172 /**
173 * Creates UnixGroup object from PolkitUnixGroup object
174 *
175 * \warning Use this only if you are completely aware of what are you doing!
176 *
177 * \param pkUnixGroup The PolkitUnixGroup object
178 */
179 explicit UnixGroupIdentity(PolkitUnixGroup *pkUnixGroup);
180
181 /**
182 * Gets a group id
183 *
184 * \return group id
185 */
186 gid_t gid() const;
187
188 /**
189 * Sets the id of group
190 *
191 * \param gid group id
192 */
193 void setGid(gid_t gid);
194};
195
196}
197
198#endif // POLKIT_QT_IDENTITY_H
Abstract class representing identities.
An object representing a group identity on a UNIX system.
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 Mon Nov 18 2024 12:13:57 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.