Polkit-Qt-1  0.95.0
polkitqt1-identity.h
1 /*
2  * This file is part of the Polkit-qt project
3  * Copyright (C) 2009 Lukas Tinkl <ltinkl@redhat.com>
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Library General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Library General Public License for more details.
14  *
15  * You should have received a copy of the GNU Library General Public License
16  * along with this library; see the file COPYING.LIB. If not, write to
17  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18  * Boston, MA 02110-1301, USA.
19  */
20 
21 #ifndef POLKITQT1_IDENTITY_H
22 #define POLKITQT1_IDENTITY_H
23 
24 #include "polkitqt1-export.h"
25 
26 #include <unistd.h>
27 
28 #include <QtCore/QObject>
29 #include <QtCore/QSharedData>
30 
31 typedef struct _PolkitIdentity PolkitIdentity;
32 typedef struct _PolkitUnixUser PolkitUnixUser;
33 typedef struct _PolkitUnixGroup PolkitUnixGroup;
34 
42 namespace PolkitQt1
43 {
44 
45 class UnixUserIdentity;
46 class UnixGroupIdentity;
47 
59 class POLKITQT1_EXPORT Identity
60 {
61 public:
62  typedef QList< Identity > List;
63 
64  Identity();
65  explicit Identity(PolkitIdentity *polkitIdentity);
66  Identity(const Identity &other);
67 
68  ~Identity();
69 
70  Identity &operator=(const Identity &other);
71 
72  bool isValid() const;
73 
79  QString toString() const;
80 
88  static Identity fromString(const QString &string);
89 
90  UnixUserIdentity toUnixUserIdentity();
91  UnixGroupIdentity toUnixGroupIdentity();
92 
100  PolkitIdentity *identity() const;
101 protected:
102  void setIdentity(PolkitIdentity *identity);
103 
104 private:
105  class Data;
106  QExplicitlySharedDataPointer< Data > d;
107 };
108 
117 class POLKITQT1_EXPORT UnixUserIdentity : public Identity
118 {
119 public:
126  explicit UnixUserIdentity(uid_t uid);
127 
133  explicit UnixUserIdentity(const QString &name);
134 
142  explicit UnixUserIdentity(PolkitUnixUser *pkUnixUser);
143 
149  uid_t uid() const;
150 
156  void setUid(uid_t uid);
157 };
158 
167 class POLKITQT1_EXPORT UnixGroupIdentity : public Identity
168 {
169 public:
176  explicit UnixGroupIdentity(gid_t gid);
177 
183  explicit UnixGroupIdentity(const QString &name);
184 
192  explicit UnixGroupIdentity(PolkitUnixGroup *pkUnixGroup);
193 
199  gid_t gid() const;
200 
206  void setGid(gid_t gid);
207 };
208 
209 }
210 
211 #endif // POLKIT_QT_IDENTITY_H
Abstract class representing identities.
Definition: polkitqt1-identity.h:59
Contains Macros for exporting symbols.
Namespace wrapping Polkit-Qt classes.
Definition: listeneradapter.cpp:26
UNIX group identity.
Definition: polkitqt1-identity.h:167
UNIX user identity.
Definition: polkitqt1-identity.h:117