• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdelibs-4.14.38 API Reference
  • KDE Home
  • Contact Us
 

KDECore

  • kdecore
  • util
kuser.h
Go to the documentation of this file.
1/*
2 * KUser - represent a user/account
3 * Copyright (C) 2002-2003 Tim Jansen <tim@tjansen.de>
4 * Copyright (C) 2003 Oswald Buddenhagen <ossi@kde.org>
5 * Copyright (C) 2004 Jan Schaefer <j_schaef@informatik.uni-kl.de>
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Library General Public License for more details.
16 *
17 * You should have received a copy of the GNU Library General Public License
18 * along with this library; see the file COPYING.LIB. If not, write to
19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 * Boston, MA 02110-1301, USA.
21 */
22#ifndef KUSER_H
23#define KUSER_H
24
25#include <kdecore_export.h>
26#include <ksharedptr.h>
27
28#include <QtCore/QVariant>
29
30class KUserGroup;
31class QString;
32class QStringList;
33template <class T> class QList;
34
35#ifdef Q_OS_WIN
36typedef void *K_UID;
37typedef void *K_GID;
38#else
39#include <sys/types.h>
40typedef uid_t K_UID;
41typedef gid_t K_GID;
42struct passwd;
43struct group;
44#endif
45
46
59class KDECORE_EXPORT KUser {
60
61public:
62
63 enum UIDMode {
64 UseEffectiveUID,
65 UseRealUserID
66 };
67
81 explicit KUser(UIDMode mode = UseEffectiveUID);
82
88 explicit KUser(K_UID uid);
89
96 explicit KUser(const QString& name);
97
104 explicit KUser(const char* name);
105
106#ifndef Q_OS_WIN
113 explicit KUser(const passwd *p);
114#endif
115
120 KUser(const KUser & user);
121
127 KUser& operator =(const KUser& user);
128
133 bool operator ==(const KUser& user) const;
134
139 bool operator !=(const KUser &user) const;
140
146 bool isValid() const;
147
152 K_UID uid() const;
153
154#ifndef Q_OS_WIN
159 K_GID gid() const;
160#endif
161
166 bool isSuperUser() const;
167
172 QString loginName() const;
173
179#ifndef KDE_NO_DEPRECATED
180 KDE_DEPRECATED QString fullName() const;
181#endif
182
188 QString homeDir() const;
189
195 QString faceIconPath() const;
196
202 QString shell() const;
203
208 QList<KUserGroup> groups() const;
209
214 QStringList groupNames() const;
215
216 enum UserProperty { FullName, RoomNumber, WorkPhone, HomePhone };
217
226 QVariant property(UserProperty which) const;
227
231 ~KUser();
232
237 static QList<KUser> allUsers();
238
243 static QStringList allUserNames();
244
245private:
246 class Private;
247 KSharedPtr<Private> d;
248};
249
262class KDECORE_EXPORT KUserGroup {
263
264public:
265
271 explicit KUserGroup(const QString& name);
272
278 explicit KUserGroup(const char *name);
279
280#ifndef Q_OS_WIN
291 explicit KUserGroup(KUser::UIDMode mode = KUser::UseEffectiveUID);
292
298 explicit KUserGroup(K_GID gid);
299
305 explicit KUserGroup(const group *g);
306#endif
307
312 KUserGroup(const KUserGroup & group);
313
319 KUserGroup& operator =(const KUserGroup& group);
320
326 bool operator ==(const KUserGroup& group) const;
327
333 bool operator !=(const KUserGroup& group) const;
334
341 bool isValid() const;
342
343#ifndef Q_OS_WIN
348 K_GID gid() const;
349#endif
350
355 QString name() const;
356
361 QList<KUser> users() const;
362
367 QStringList userNames() const;
368
372 ~KUserGroup();
373
377 static QList<KUserGroup> allGroups();
378
382 static QStringList allGroupNames();
383
384private:
385 class Private;
386 KSharedPtr<Private> d;
387};
388
389#endif
KSharedPtr
Can be used to control the lifetime of an object that has derived QSharedData.
Definition: ksharedptr.h:64
KUserGroup
Represents a group on your system.
Definition: kuser.h:262
KUser
Represents a user on your system.
Definition: kuser.h:59
KUser::UserProperty
UserProperty
Definition: kuser.h:216
KUser::FullName
@ FullName
Definition: kuser.h:216
KUser::UIDMode
UIDMode
Definition: kuser.h:63
KUser::UseEffectiveUID
@ UseEffectiveUID
Use the effective user id.
Definition: kuser.h:64
QList
Definition: kaboutdata.h:33
QStringList
QString
QVariant
operator==
bool operator==(const KEntry &k1, const KEntry &k2)
Definition: kconfigdata.h:72
operator!=
bool operator!=(const KEntry &k1, const KEntry &k2)
Definition: kconfigdata.h:79
kdecore_export.h
ksharedptr.h
K_UID
void * K_UID
Definition: kuser.h:36
K_GID
void * K_GID
Definition: kuser.h:37
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Feb 20 2023 00:00:00 by doxygen 1.9.6 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KDECore

Skip menu "KDECore"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Modules
  • Related Pages

kdelibs-4.14.38 API Reference

Skip menu "kdelibs-4.14.38 API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal