/*
 * This file is part of DesktopBSD, see the README file.
 *
 * Authors: Reinhard Pointner
 *          Peter Hofer <ph@desktopbsd.net>
 *          (C) 2004, 2005
 *
 * Copyright: BSD, see the COPYING file included in this distribution
 *
 */

#ifndef __USER_H
#define __USER_H

/* passwd */
#include <sys/types.h>
#include <pwd.h>

/* Qt */
#include <qstring.h>

class QStringList;

/** @brief Represents a user in the system. */
class User {
	friend class Users;

public:
	User &	operator = (const User &);

	uid_t		getUID()			const {	return  uid;		};
	gid_t		getGID()			const {	return  gid;		};
	QString	getShell()		const {	return  shell;		};
	QString	getHomeDir()	const {	return  homeDir;	};
	QString	getUsername()	const {	return  name;		};
	QString	getComment()	const {	return  comment;	};

	bool	setComment(const QString &);
	bool	setPassword(const QString &);
	bool	unsetPassword();

	bool	lock();
	bool	unlock();
	bool	isLocked() const;

	bool	isMemberOf(const QString &);
	bool	setGroupMemberships(const QStringList &);
	bool	removeGroupMembership(const QString &);
	bool	addGroupMembership(const QString &);
	QStringList	getGroupMemberships();

private:
	User(const struct passwd &);

	static QCString encrypt(const QCString &);

	bool     locked;
	uid_t    uid;
	gid_t    gid;
	QString  name;
	QString  comment;
	QString  homeDir;
	QString  shell;
};


#endif /* __USER_H */
