Source: UserData.h


Annotated List
Files
Globals
Hierarchy
Index
/***************************************************************************
 *
 * File:    UserData.h
 * Created: Tue Dec 14 1999
 * (C) 1999 by David M. <captjay@superlink.net>
 *
 ***************************************************************************/
/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/
#ifndef USERDATA_H
#define USERDATA_H

#include <qobject.h>
#include <qstring.h>
#include <qdatetime.h>
#include <qdict.h>

class AccessData;

typedef QDict<AccessData> AccessList;
typedef QDictIterator<AccessData> AccessIterator;

/**
* @author David M.
* @short Encapsulate user and access information.
*
* This class is used to represent internal data about a user's access
* in the bot.
*/
class UserData : public QObject  {
public: 
	/**
	* Get the internal user index of the current UserData object.
	* @return The internal user index.
	*/
	int getUserIdx() const;
	/**
	* Get the login (username) of the current UserData object.
	* @return The username of the current user.
	*/
	const QString& getLogin() const;
	/**
	* Determine if pass matches the password of the current UserData object.
	* The comparison is case-sensitive.
	* @param pass The password to test against the user's password.
	* @return true if the passwords match exactly, false otherwise.
	*/
	bool passwordMatches(QString pass) const;
	/**
	* Get the last time the user was seen.
	* @return A QDateTime object representing the last time the user was seen.
	*/
	const QDateTime& getLastSeen() const;
	/**
	* Get the last IP the user was seen on.
	* @return A string the last IP the user was seen on.
	*/
	const QString& getLastIP() const;
	/**
	* Get the username of the user who made the last modification to
	* this access.
	* @return The username of the last modifying user.
	*/
	const QString& getLastModifBy() const;
	/**
	* Get the date & time of the last modification to this access.
	* @return The date & time of the last modification.
	*/
	const QDateTime& getLastModifTS() const;
	/**
	* Get the name of the last command that modified this access.
	* @return The name of the last command modifying this access.
	*/
	const QString& getLastModif() const;
	
	/**
	* Get the user's console.
	* @return An int containing the sum of the activated @ref DCCUser
	* flags for console settings.
	*/
	int getConsole() const;
	/**
	* Get the infoline the user specified, if any.
	* @return The infoline of the user, or an empty string if there is none set.
	*/
	const QString& getInfoLine() const;
	
	/**
	* Get the name of the channel the user wishes to authenticate by default.
	* @return The name of the user's default channel.
	*/
	const QString& getDefaultChannel() const;
	
	/**
	* Create an iterator over the user's access list. This can be used to
	* go through the whole list. The access list is in arbitrary order.
	* The calling method is responsible for freeing memory allocated
	* by createAccessIterator.
	*
	* PRECONDITIONS: _accessDict != 0
	*
	* @return A new AccessIterator object pointing to the first access in
	* the user's access list.
	*/
	AccessIterator* createAccessIterator() const;
	
	/**
	* Find an access for a specific channel in the user's access list.
	* @param channel The name of the channel to find (case-insensitive).
	*
	* PRECONDITIONS: _accessDict != 0
	*
	* @return A const pointer to the @ref AccessData object representing
	* the access on the requested channel, or 0 if the user does not
	* have access to that channel.
	*/
	const AccessData* findAccess(QString channel) const;
	~UserData();
protected:
  /**
  * Create a new USerData object with the given values. All the values
  * can be obtained from the database. This constructor is private,
  * allowing only friend classes to create UserData objects.
  * @param userIdx The internal user index of the user.
  * @param login The username of the user.
  * @param pass The user's password.
  * @param lastSeen Date & time the user was last seen.
  * @param lastIP Last IP the user was seen on.
  * @param lastModifBy Username of the user who last modified this user.
  * @param lastModifTS Date & time of the last modification on this user.
  * @param lastModif Name of the command that last modified this user.
  * @param console Console settings for this user.
  * @param infoline The user's infoline.
  * @param defChan Name of the channel the user authenticates on by default.
  */
	UserData(int userIdx,QString login, QString pass, QDateTime lastSeen,
	         QString lastIP, QString lastModifBy, QDateTime lastModifTS,
	         QString lastModif, int console, QString infoline, QString defChan);
  /**
  * Set the internal access list to the one specified in parameter.
  * Once set, this list cannot be changed.
  *
  * PRECONDITIONS: pAccess != 0 ; _accessDict == 0
  * @param pAccess A created and filled list of accesses to be attached
  * to this user.
  */
  void setAccessList(AccessList* pAccess);
  friend class DataAccessC;
private:
  int     _userIdx;
  QString _login;
  QString _password;
  QDateTime _lastSeen;
  QString _lastIP;
  QString _lastModifBy;
  QDateTime _lastModifTS;
  QString _lastModif;
  int     _console;
  QString _infoline;
  QString _defChan;
  AccessList* _accessDict;
};

#endif

Generated by: nightsky@centauri on Sat Jan 15 23:06:10 2000, using kdoc 2.0a30.