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

KDECore

  • sources
  • kde-4.14
  • kdelibs
  • 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 
30 class KUserGroup;
31 class QString;
32 class QStringList;
33 template <class T> class QList;
34 
35 #ifdef Q_OS_WIN
36 typedef void *K_UID;
37 typedef void *K_GID;
38 #else
39 #include <sys/types.h>
40 typedef uid_t K_UID;
41 typedef gid_t K_GID;
42 struct passwd;
43 struct group;
44 #endif
45 
46 
59 class KDECORE_EXPORT KUser {
60 
61 public:
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
107 
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
155 
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 
245 private:
246  class Private;
247  KSharedPtr<Private> d;
248 };
249 
262 class KDECORE_EXPORT KUserGroup {
263 
264 public:
265 
271  explicit KUserGroup(const QString& name);
272 
278  explicit KUserGroup(const char *name);
279 
280 #ifndef Q_OS_WIN
281 
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
344 
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 
384 private:
385  class Private;
386  KSharedPtr<Private> d;
387 };
388 
389 #endif
KSharedPtr< Private >
ksharedptr.h
kdecore_export.h
KUser::UseEffectiveUID
Use the effective user id.
Definition: kuser.h:64
KMacroExpander::group
Definition: kmacroexpander_unix.cpp:34
KUserGroup
Represents a group on your system.
Definition: kuser.h:262
operator!=
bool operator!=(const KEntry &k1, const KEntry &k2)
Definition: kconfigdata.h:79
KUser
Represents a user on your system.
Definition: kuser.h:59
operator==
bool operator==(const KEntry &k1, const KEntry &k2)
Definition: kconfigdata.h:72
K_GID
void * K_GID
Definition: kuser.h:37
KUser::UserProperty
UserProperty
Definition: kuser.h:216
QString
QList
Definition: kaboutdata.h:33
QStringList
KShell::homeDir
QString homeDir(const QString &user)
Definition: kshell.cpp:29
KUser::UIDMode
UIDMode
Definition: kuser.h:63
K_UID
void * K_UID
Definition: kuser.h:33
KUser::WorkPhone
Definition: kuser.h:216
QVariant
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:22:12 by doxygen 1.8.7 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 API Reference

Skip menu "kdelibs 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

Search



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