kdecore Library API Documentation

kuser.h

00001 /*
00002  *  KUser - represent a user/account
00003  *  Copyright (C) 2002-2003 Tim Jansen <tim@tjansen.de>
00004  *  Copyright (C) 2003 Oswald Buddenhagen <ossi@kde.org>
00005  *  Copyright (C) 2004 Jan Schaefer <j_schaef@informatik.uni-kl.de>
00006  *
00007  *  $Id: kuser.h,v 1.12 2004/11/24 21:17:31 deller Exp $
00008  *
00009  *  This library is free software; you can redistribute it and/or
00010  *  modify it under the terms of the GNU Library General Public
00011  *  License as published by the Free Software Foundation; either
00012  *  version 2 of the License, or (at your option) any later version.
00013  *
00014  *  This library is distributed in the hope that it will be useful,
00015  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00017  *  Library General Public License for more details.
00018  *
00019  *  You should have received a copy of the GNU Library General Public License
00020  *  along with this library; see the file COPYING.LIB.  If not, write to
00021  *  the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00022  *  Boston, MA 02111-1307, USA.
00023  */
00024 #ifndef KUSER_H
00025 #define KUSER_H
00026 
00027 #include "ksharedptr.h"
00028 
00029 class KUserGroup;
00030 class QString;
00031 class QStringList;
00032 class KUserPrivate;
00033 struct passwd;
00034 template <class T> class QValueList;
00035 
00047 class KDECORE_EXPORT KUser {
00048 
00049 public:
00050 
00051   enum UIDMode { 
00052     UseEffectiveUID, 
00053     UseRealUserID    
00054   };
00055 
00069   // XXX KDE4: Make this explicit
00070   KUser(UIDMode mode = UseEffectiveUID);
00071 
00077   // XXX KDE4: Make this explicit; give parameter as uid_t instead of "long"
00078   KUser(long uid);
00079 
00086   // XXX KDE4: Make this explicit
00087   KUser(const QString& name);
00088 
00095   // XXX KDE4: Make this explicit
00096   KUser(const char *name);
00097 
00104   // XXX KDE4: Make this explicit
00105   KUser(struct passwd *p);
00106 
00111   KUser(const KUser & user);
00112   
00118   KUser& operator =(const KUser& user);
00119   
00124   bool operator ==(const KUser& user) const;
00125 
00130   bool operator !=(const KUser &user) const;
00131 
00137   bool isValid() const;
00138 
00143   // XXX KDE4: Make this return uid_t
00144   long uid() const;
00145 
00146 
00151   // XXX KDE4: Make this return gid_t
00152   long gid() const;
00153 
00158   bool isSuperUser() const;
00159 
00164   QString loginName() const;
00165 
00170   QString fullName() const;
00171 
00177   QString roomNumber() const;
00178 
00184   QString workPhone() const;
00185 
00191   QString homePhone() const;
00192 
00198   QString homeDir() const;
00199 
00205   QString shell() const;
00206 
00211   QValueList<KUserGroup> groups() const;
00212   
00217   QStringList groupNames() const;
00218   
00219   
00223   ~KUser();
00224 
00229   static QValueList<KUser> allUsers();
00230 
00235   static QStringList allUserNames();
00236 
00237 private:
00238   KSharedPtr<KUserPrivate> d;
00239   void fillPasswd(struct passwd* p);
00240   void fillName(const char* name);
00241 };
00242 
00243 class KUserGroupPrivate;
00244 
00245 struct group;
00246 
00258 class KDECORE_EXPORT KUserGroup {
00259 
00260 public:
00261 
00272   explicit KUserGroup(KUser::UIDMode mode = KUser::UseEffectiveUID);
00273   
00279   // XXX KDE4: Give parameter as gid_t instead of "long"
00280   explicit KUserGroup(long gid);
00281   
00287   explicit KUserGroup(const QString& name);
00288   
00294   explicit KUserGroup(const char *name);
00295   
00301   explicit KUserGroup(struct group *g);
00302   
00307   KUserGroup(const KUserGroup & group);
00308   
00314   KUserGroup& operator =(const KUserGroup& group);
00315   
00321   bool operator ==(const KUserGroup& group) const;
00322   
00328   bool operator !=(const KUserGroup& group) const;
00329   
00336   bool isValid() const;
00337   
00342   // XXX KDE4: Return gid_t instead of "long"
00343   long gid() const;
00344   
00349   QString name() const;
00350   
00355   const QValueList<KUser>& users() const;
00356   
00361   QStringList userNames() const;
00362   
00363   
00367   ~KUserGroup(); 
00368   
00372   static QValueList<KUserGroup> allGroups();
00373   
00377   static QStringList allGroupNames();
00378   
00379 private:
00380   KSharedPtr<KUserGroupPrivate> d;
00381   void fillGroup(struct group* g);
00382   void fillName(const char* name);
00383 };
00384 
00385 
00386 #endif
KDE Logo
This file is part of the documentation for kdecore Library Version 3.3.90.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Mar 30 10:09:41 2005 by doxygen 1.3.9.1 written by Dimitri van Heesch, © 1997-2003