kdecore Library API Documentation

KUser Class Reference

Represents a user on your system. More...

#include <kuser.h>

Collaboration diagram for KUser:

Collaboration graph
[legend]
List of all members.

Public Types

enum  UIDMode { UseEffectiveUID, UseRealUserID }

Public Member Functions

 KUser (UIDMode mode=UseEffectiveUID)
 KUser (long uid)
 KUser (const QString &name)
 KUser (const char *name)
 KUser (struct passwd *p)
bool operator== (const KUser &user) const
bool operator!= (const KUser &user) const
bool isValid () const
long uid () const
long gid () const
bool isSuperUser () const
QString loginName () const
QString fullName () const
QString roomNumber () const
QString workPhone () const
QString homePhone () const
QString homeDir () const
QString shell () const
 ~KUser ()

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, of 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@tjansen.de>
Since:
3.2

Definition at line 44 of file kuser.h.


Member Enumeration Documentation

enum KUser::UIDMode
 

Enumeration values:
UseEffectiveUID  Use the effective user id.
UseRealUserID  Use the real user id.

Definition at line 48 of file kuser.h.


Constructor & Destructor Documentation

KUser::KUser UIDMode  mode = UseEffectiveUID  ) 
 

Creates an object that contains information about the current user.

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

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

Definition at line 66 of file kuser.cpp.

References uid(), and UseEffectiveUID.

KUser::KUser long  uid  ) 
 

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

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

Parameters:
uid the user id

Definition at line 80 of file kuser.cpp.

KUser::KUser const QString name  ) 
 

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

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

Parameters:
name the name of the user

Definition at line 84 of file kuser.cpp.

References KStdAction::name().

KUser::KUser const char *  name  ) 
 

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

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

Parameters:
name the name of the user

Definition at line 88 of file kuser.cpp.

References KStdAction::name().

KUser::KUser struct passwd *  p  ) 
 

Creates an object from a passwd structure.

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

Parameters:
p the passwd structure to create the user from

KUser::~KUser  ) 
 

Destructor.

Definition at line 199 of file kuser.cpp.


Member Function Documentation

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

Two KUser objects are equal if isValid() is true and the uid() are identical.

Definition at line 92 of file kuser.cpp.

References isValid(), and uid().

Referenced by operator!=().

bool KUser::operator!= const KUser user  )  const
 

Two KUser objects are not equal if either isValid() is not true or uid() are not identical.

Definition at line 101 of file kuser.cpp.

References operator==().

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 128 of file kuser.cpp.

Referenced by operator==().

long KUser::uid  )  const
 

Returns the user id of the user.

Returns:
the id of the user or -1 if user is invalid

Definition at line 132 of file kuser.cpp.

Referenced by isSuperUser(), KUser(), and operator==().

long KUser::gid  )  const
 

Returns the group id of the user.

Returns:
the id of the group or -1 if user is invalid

Definition at line 139 of file kuser.cpp.

bool KUser::isSuperUser  )  const
 

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

Returns:
true if the user is root

Definition at line 146 of file kuser.cpp.

References uid().

QString KUser::loginName  )  const
 

The login name of the user.

Returns:
the login name of the user or QString::null if user is invalid

Definition at line 150 of file kuser.cpp.

Referenced by KInstance::config().

QString KUser::fullName  )  const
 

The full name of the user.

Returns:
the full name of the user or QString::null if user is invalid

Definition at line 157 of file kuser.cpp.

QString KUser::roomNumber  )  const
 

The user's room number.

Returns:
the room number of the user or QString::null if not set or the user is invalid

Definition at line 164 of file kuser.cpp.

QString KUser::workPhone  )  const
 

The user's work phone.

Returns:
the work phone of the user or QString::null if not set or the user is invalid

Definition at line 171 of file kuser.cpp.

QString KUser::homePhone  )  const
 

The user's home phone.

Returns:
the home phone of the user or QString::null if not set or the user is invalid

Definition at line 178 of file kuser.cpp.

QString KUser::homeDir  )  const
 

The path to the user's home directory.

Returns:
the home phone of the user or QString::null if the user is invalid

Definition at line 185 of file kuser.cpp.

QString KUser::shell  )  const
 

The path to the user's login shell.

Returns:
the login shell of the user or QString::null if the user is invalid

Definition at line 192 of file kuser.cpp.


The documentation for this class was generated from the following files:
KDE Logo
This file is part of the documentation for kdecore Library Version 3.2.3.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Aug 4 05:23:33 2004 by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2003