14#include <kcoreaddons_export.h>
16#include <QSharedDataPointer>
19#include <qcontainerfwd.h>
27struct WindowsSIDWrapper;
40#define KCOREADDONS_UINT_MAX (std::numeric_limits<uint>::max)()
71 KUserOrGroupId &operator=(
const KUserOrGroupId<T> &other);
109KUserOrGroupId<void *>::~KUserOrGroupId();
133struct KCOREADDONS_EXPORT
KUserId :
public KUserOrGroupId<K_UID> {
140 : KUserOrGroupId(uid)
153 static KUserId fromName(
const QString &name);
155 static KUserId currentUserId();
160 static KUserId currentEffectiveUserId();
168struct KCOREADDONS_EXPORT
KGroupId :
public KUserOrGroupId<K_GID> {
175 : KUserOrGroupId(gid)
188 static KGroupId fromName(
const QString &name);
190 static KGroupId currentGroupId();
195 static KGroupId currentEffectiveGroupId();
199inline size_t qHash(
const KUserId &
id,
size_t seed = 0)
201 return qHash(
id.nativeId(), seed);
203inline size_t qHash(
const KGroupId &
id,
size_t seed = 0)
205 return qHash(
id.nativeId(), seed);
209KCOREADDONS_EXPORT
size_t qHash(
const KUserId &
id,
size_t seed = 0);
210KCOREADDONS_EXPORT
size_t qHash(
const KGroupId &
id,
size_t seed = 0);
246 explicit KUser(UIDMode mode = UseEffectiveUID);
253 explicit KUser(K_UID uid);
276 explicit KUser(
const char *name);
285 explicit KUser(
const passwd *p);
305 bool operator==(
const KUser &user)
const;
311 bool operator!=(
const KUser &user)
const;
318 bool isValid()
const;
330 bool isSuperUser()
const;
369 QStringList groupNames(uint maxCount = KCOREADDONS_UINT_MAX)
const;
386 QVariant property(UserProperty which)
const;
397 static QList<KUser> allUsers(uint maxCount = KCOREADDONS_UINT_MAX);
403 static QStringList allUserNames(uint maxCount = KCOREADDONS_UINT_MAX);
406 QExplicitlySharedDataPointer<class KUserPrivate> d;
409Q_DECLARE_TYPEINFO(
KUser, Q_RELOCATABLE_TYPE);
552Q_DECLARE_TYPEINFO(
KUserGroup, Q_RELOCATABLE_TYPE);
554#if !defined(Q_OS_WIN)
559 return id != NativeType(-1);
564 return id == other.id;
569 return id != other.id;
603inline KUserOrGroupId<T>::~KUserOrGroupId()
Represents a group on your system.
KUserGroup(const group *g)
Creates an object from a group structure.
QStringList userNames(uint maxCount=KCOREADDONS_UINT_MAX) const
static QList< KUserGroup > allGroups(uint maxCount=KCOREADDONS_UINT_MAX)
QString name() const
The name of the group.
KUserGroup(const QString &name)
Create an object from a group name.
bool isValid() const
Returns whether the group is valid.
bool operator!=(const KUserGroup &group) const
Two KUserGroup objects are not equal if their gid()s are not identical.
QList< KUser > users(uint maxCount=KCOREADDONS_UINT_MAX) const
bool operator==(const KUserGroup &group) const
Two KUserGroup objects are equal if their gid()s are identical.
static QStringList allGroupNames(uint maxCount=KCOREADDONS_UINT_MAX)
KUserGroup & operator=(const KUserGroup &group)
Copies a group.
Represents a user on your system.
KUser(UIDMode mode=UseEffectiveUID)
Creates an object that contains information about the current user.
bool operator!=(const KUser &user) const
Two KUser objects are not equal if userId() are not identical.
bool operator==(const KUser &user) const
Two KUser objects are equal if the userId() are identical.
@ UseEffectiveUID
Use the effective user id.
@ UseRealUserID
Use the real user id.
QString number(double n, char format, int precision)
A platform independent group ID.
KGroupId()
Creates an invalid KGroupId.
KGroupId(K_GID gid)
Creates an KGroupId from the native group ID type.
A platform independent user ID.
KUserId()
Creates an invalid KUserId.
KUserId(K_UID uid)
Creates an KUserId from the native user ID type.
A platform independent user or group ID.
bool operator==(const KUserOrGroupId &other) const
NativeType nativeId() const
KUserOrGroupId(NativeType nativeId)
Creates a KUserOrGroupId from a native user/group ID.
bool operator!=(const KUserOrGroupId &other) const
KUserOrGroupId(const KUserOrGroupId< T > &other)
Copy constructor.
KUserOrGroupId()
Creates an invalid KUserOrGroupId.