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

KDECore

Public Types | Public Member Functions | Static Public Member Functions | List of all members
KUser Class Reference

#include <KUser>

Public Types

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

Public Member Functions

 KUser (UIDMode mode=UseEffectiveUID)
 
 KUser (K_UID uid)
 
 KUser (const QString &name)
 
 KUser (const char *name)
 
 KUser (const KUser &user)
 
 ~KUser ()
 
QString faceIconPath () const
 
QString fullName () const
 
QStringList groupNames () const
 
QList< KUserGroup > groups () const
 
QString homeDir () const
 
bool isSuperUser () const
 
bool isValid () const
 
QString loginName () const
 
bool operator!= (const KUser &user) const
 
KUser & operator= (const KUser &user)
 
bool operator== (const KUser &user) const
 
QVariant property (UserProperty which) const
 
QString shell () const
 
K_UID uid () const
 

Static Public Member Functions

static QStringList allUserNames ()
 
static QList< KUser > allUsers ()
 

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@t.nosp@m.jans.nosp@m.en.de

Definition at line 59 of file kuser.h.

Member Enumeration Documentation

enum KUser::UIDMode
Enumerator
UseEffectiveUID 

Use the effective user id.

UseRealUserID 

Use the real user id.

Definition at line 63 of file kuser.h.

enum KUser::UserProperty
Enumerator
FullName 
RoomNumber 
WorkPhone 
HomePhone 

Definition at line 216 of file kuser.h.

Constructor & Destructor Documentation

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 74 of file kuser_unix.cpp.

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 89 of file kuser_unix.cpp.

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 94 of file kuser_unix.cpp.

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 99 of file kuser_unix.cpp.

KUser::KUser ( const KUser &  user)

Creates an object from another KUser object.

Parameters
userthe user to create the new object from

Definition at line 109 of file kuser_unix.cpp.

KUser::~KUser ( )

Destructor.

Definition at line 231 of file kuser_unix.cpp.

Member Function Documentation

QStringList KUser::allUserNames ( )
static

Returns all user names of the system.

Returns
all user names of the system.

Definition at line 218 of file kuser_unix.cpp.

QList< KUser > KUser::allUsers ( )
static

Returns all users of the system.

Returns
all users of the system.

Definition at line 204 of file kuser_unix.cpp.

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 158 of file kuser_unix.cpp.

QString KUser::fullName ( ) const

The full name of the user.

Returns
the full name of the user or QString() if user is invalid
Deprecated:
use property(KUser::FullName) instead

Definition at line 149 of file kuser_unix.cpp.

QStringList KUser::groupNames ( ) const

Returns all group names of the user.

Returns
all group names of the user

Definition at line 186 of file kuser_unix.cpp.

QList< KUserGroup > KUser::groups ( ) const

Returns all groups of the user.

Returns
all groups of the user

Definition at line 173 of file kuser_unix.cpp.

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 154 of file kuser_unix.cpp.

bool KUser::isSuperUser ( ) const

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

Returns
true if the user is root

Definition at line 140 of file kuser_unix.cpp.

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_unix.cpp.

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 144 of file kuser_unix.cpp.

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

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

Invalid users always compare unequal.

Definition at line 124 of file kuser_unix.cpp.

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

Copies a user.

Parameters
userthe user to copy
Returns
this object

Definition at line 114 of file kuser_unix.cpp.

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

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

Invalid users never compare equal.

Definition at line 120 of file kuser_unix.cpp.

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 199 of file kuser_unix.cpp.

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 169 of file kuser_unix.cpp.

K_UID 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_unix.cpp.


The documentation for this class was generated from the following files:
  • kuser.h
  • kuser_unix.cpp
  • kuser_win.cpp
  • kuser_wince.cpp
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:47:11 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
  • kjsembed
  •   WTF
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Nepomuk-Core
  • 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