KUser

Search for usage in LXR

#include <KUser>

Public Types

enum  UIDMode { UseEffectiveUID , UseRealUserID }
 
enum  UserProperty { FullName , RoomNumber , WorkPhone , HomePhone }
 

Public Member Functions

 KUser (const char *name)
 
 KUser (const KUser &user)
 
 KUser (const passwd *p)
 
 KUser (const QString &name)
 
 KUser (K_UID uid)
 
 KUser (KUserId uid)
 
 KUser (UIDMode mode=UseEffectiveUID)
 
 ~KUser ()
 
QString faceIconPath () const
 
KGroupId groupId () const
 
QStringList groupNames (uint maxCount=KCOREADDONS_UINT_MAX) const
 
QList< KUserGroupgroups (uint maxCount=KCOREADDONS_UINT_MAX) const
 
QString homeDir () const
 
bool isSuperUser () const
 
bool isValid () const
 
QString loginName () const
 
bool operator!= (const KUser &user) const
 
KUseroperator= (const KUser &user)
 
bool operator== (const KUser &user) const
 
QVariant property (UserProperty which) const
 
QString shell () const
 
KUserId userId () const
 

Static Public Member Functions

static QStringList allUserNames (uint maxCount=KCOREADDONS_UINT_MAX)
 
static QList< KUserallUsers (uint maxCount=KCOREADDONS_UINT_MAX)
 

Detailed Description

Represents a user on your system.

This class represents a user on your system. You can either get information about the current user, or fetch information about a user on the system. Instances of this class will be explicitly shared, so copying objects is very cheap and you can safely pass objects by value.

Author
Tim Jansen tim@t.nosp@m.jans.nosp@m.en.de

Definition at line 225 of file kuser.h.

Member Enumeration Documentation

◆ UIDMode

Enumerator
UseEffectiveUID 

Use the effective user id.

UseRealUserID 

Use the real user id.

Definition at line 228 of file kuser.h.

◆ UserProperty

enum KUser::UserProperty

Definition at line 371 of file kuser.h.

Constructor & Destructor Documentation

◆ KUser() [1/7]

KUser::KUser ( UIDMode mode = UseEffectiveUID)
explicit

Creates an object that contains information about the current user.

(as returned by getuid(2) or geteuid(2), taking $LOGNAME/$USER into account).

Parameters
modeif UseEffectiveUID is passed the effective user is returned. If UseRealUserID is passed the real user will be returned. The real UID will be different than the effective UID in setuid programs; in such a case use the effective UID for checking permissions, and the real UID for displaying information about the user.

Definition at line 151 of file kuser_unix.cpp.

◆ KUser() [2/7]

KUser::KUser ( K_UID uid)
explicit

Creates an object for the user with the given user id.

If the user does not exist isValid() will return false.

Parameters
uidthe user id

Definition at line 168 of file kuser_unix.cpp.

◆ KUser() [3/7]

KUser::KUser ( KUserId uid)
explicit

Creates an object for the user with the given user id.

If the KUserId object is invalid this one will be, too.

Parameters
uidthe user id

Definition at line 173 of file kuser_unix.cpp.

◆ KUser() [4/7]

KUser::KUser ( const QString & name)
explicit

Creates an object that contains information about the user with the given name.

If the user does not exist isValid() will return false.

Parameters
namethe name of the user

Definition at line 178 of file kuser_unix.cpp.

◆ KUser() [5/7]

KUser::KUser ( const char * name)
explicit

Creates an object that contains information about the user with the given name.

If the user does not exist isValid() will return false.

Parameters
namethe name of the user

Definition at line 183 of file kuser_unix.cpp.

◆ KUser() [6/7]

KUser::KUser ( const passwd * p)
explicit

Creates an object from a passwd structure.

If the pointer is null isValid() will return false.

Parameters
pthe passwd structure to create the user from

Definition at line 188 of file kuser_unix.cpp.

◆ KUser() [7/7]

KUser::KUser ( const KUser & user)

Creates an object from another KUser object.

Parameters
userthe user to create the new object from

Definition at line 193 of file kuser_unix.cpp.

◆ ~KUser()

KUser::~KUser ( )

Destructor.

Definition at line 382 of file kuser_unix.cpp.

Member Function Documentation

◆ allUserNames()

QStringList KUser::allUserNames ( uint maxCount = KCOREADDONS_UINT_MAX)
static
Parameters
maxCountthe maximum number of users to return
Returns
all user names of the system.

Definition at line 367 of file kuser_unix.cpp.

◆ allUsers()

QList< KUser > KUser::allUsers ( uint maxCount = KCOREADDONS_UINT_MAX)
static
Parameters
maxCountthe maximum number of users to return
Returns
all users of the system.

Definition at line 351 of file kuser_unix.cpp.

◆ faceIconPath()

QString KUser::faceIconPath ( ) const

The path to the user's face file.

Returns
the path to the user's face file or QString() if no face has been set

Definition at line 239 of file kuser_unix.cpp.

◆ groupId()

KGroupId KUser::groupId ( ) const
Returns
the native user id of the user.

Definition at line 219 of file kuser_unix.cpp.

◆ groupNames()

QStringList KUser::groupNames ( uint maxCount = KCOREADDONS_UINT_MAX) const
Parameters
maxCountthe maximum number of groups to return
Returns
all group names of the user

Definition at line 337 of file kuser_unix.cpp.

◆ groups()

QList< KUserGroup > KUser::groups ( uint maxCount = KCOREADDONS_UINT_MAX) const
Parameters
maxCountthe maximum number of groups to return
Returns
all groups of the user

Definition at line 328 of file kuser_unix.cpp.

◆ homeDir()

QString KUser::homeDir ( ) const

The path to the user's home directory.

Returns
the home directory of the user or QString() if the user is invalid

Definition at line 234 of file kuser_unix.cpp.

◆ isSuperUser()

bool KUser::isSuperUser ( ) const

Checks whether the user is the super user (root).

Returns
true if the user is root

Definition at line 224 of file kuser_unix.cpp.

◆ isValid()

bool KUser::isValid ( ) const

Returns true if the user is valid.

A KUser object can be invalid if you created it with an non-existing uid or name.

Returns
true if the user is valid

Definition at line 209 of file kuser_unix.cpp.

◆ loginName()

QString KUser::loginName ( ) const

The login name of the user.

Returns
the login name of the user or QString() if user is invalid

Definition at line 229 of file kuser_unix.cpp.

◆ operator!=()

bool KUser::operator!= ( const KUser & user) const
inline

Two KUser objects are not equal if userId() are not identical.

Invalid users always compare unequal.

Definition at line 608 of file kuser.h.

◆ operator=()

KUser & KUser::operator= ( const KUser & user)

Copies a user.

Parameters
userthe user to copy
Returns
this object

Definition at line 198 of file kuser_unix.cpp.

◆ operator==()

bool KUser::operator== ( const KUser & user) const

Two KUser objects are equal if the userId() are identical.

Invalid users never compare equal.

Definition at line 204 of file kuser_unix.cpp.

◆ property()

QVariant KUser::property ( UserProperty which) const

Returns an extended property.

Under Windows, RoomNumber, WorkPhone and HomePhone are unsupported.

Returns
a QVariant with the value of the property or an invalid QVariant, if the property is not set

Definition at line 346 of file kuser_unix.cpp.

◆ shell()

QString KUser::shell ( ) const

The path to the user's login shell.

Returns
the login shell of the user or QString() if the user is invalid

Definition at line 259 of file kuser_unix.cpp.

◆ userId()

KUserId KUser::userId ( ) const
Returns
the native user id of the user.

Definition at line 214 of file kuser_unix.cpp.


The documentation for this class was generated from the following files:
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:13:31 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.