Proof-reading - fixed one usage of the i18n plural form (it wasn't doing before,...
[kdeadmin.git] / kuser / ku_group.h
blobad29d82824fbf6479ec6dfae4d505ed3b9003250
1 /*
2 * Copyright (c) 1998 Denis Perchine <dyp@perchine.com>
3 * Copyright (c) 2004 Szombathelyi GyĂśrgy <gyurco@freemail.hu>
4 * Maintained by Adriaan de Groot <groot@kde.org>
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public
8 * License version 2 as published by the Free Software Foundation.
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.
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 **/
21 #ifndef _KU_GROUP_H_
22 #define _KU_GROUP_H_
24 #include <sys/types.h>
27 #include <QList>
28 #include <QSharedDataPointer>
30 #include "globals.h"
31 #include "ku_prefs.h"
32 #include "sid.h"
34 class KU_Group_Private : public QSharedData
36 public:
37 KU_Group_Private();
39 int Caps;
41 QString Name;
42 QString Pwd;
43 gid_t GID;
44 QStringList users;
46 //Samba
47 class SID SID;
48 int Type;
49 QString DisplayName;
50 QString Desc;
53 class KU_Group {
54 public:
55 KU_Group();
56 KU_Group(KU_Group *group);
57 ~KU_Group();
59 enum Cap {
60 Cap_Samba = 1
63 bool operator==(const KU_Group &other) const;
64 void copy(const KU_Group *group);
66 KU_PROPERTY(int, Caps);
68 KU_PROPERTY(QString, Name);
69 KU_PROPERTY(QString, Pwd);
70 KU_PROPERTY(gid_t, GID );
72 //Samba
73 KU_PROPERTY(SID, SID);
74 KU_PROPERTY(int, Type);
75 KU_PROPERTY(QString, DisplayName);
76 KU_PROPERTY(QString, Desc);
78 bool addUser(const QString &name);
79 bool removeUser(const QString &name);
80 bool lookup_user(const QString &name) const;
81 uint count() const;
82 QString user(uint i) const;
83 void clear();
84 private:
85 QSharedDataPointer<KU_Group_Private> d;
88 class KU_Groups : public QList<KU_Group> {
89 public:
90 enum Cap {
91 Cap_ReadOnly = 1,
92 Cap_Passwd = 2,
93 Cap_Shadow = 4,
94 Cap_Samba = 8
97 typedef QList<KU_Group> AddList;
98 typedef QList<int> DelList;
99 typedef QMap<int,KU_Group> ModList;
101 AddList mAddSucc;
102 DelList mDelSucc;
103 ModList mModSucc;
105 KU_Groups( KU_PrefsBase *cfg );
106 virtual ~KU_Groups();
108 int getCaps() const { return caps; }
109 const QString &getDOMSID() const;
111 int lookup( const QString &name ) const;
112 int lookup( gid_t gid ) const;
113 int lookup_sam( const SID &sid ) const;
114 int lookup_sam( const QString &sid ) const;
115 int lookup_sam( uint rid ) const;
117 void add(const KU_Group &group);
118 void del(int index);
119 void mod(int index, const KU_Group &newgroup);
120 void commit();
121 void cancelMods();
123 enum {
124 NO_FREE = (gid_t) -1
127 virtual gid_t first_free() const;
128 virtual uint first_free_sam() const;
129 virtual bool reload() = 0;
130 virtual bool dbcommit() = 0;
132 const QString &errorString() const { return mErrorString; }
133 const QString &errorDetails() const { return mErrorDetails; }
135 protected:
136 KU_PrefsBase *mCfg;
138 QString mErrorString, mErrorDetails;
140 AddList mAdd;
141 DelList mDel;
142 ModList mMod;
143 int caps;
144 QString domsid;
147 #endif // _KU_GROUP_H_