2005-12-16 18:10:38 +00:00
|
|
|
/* +------------------------------------+
|
|
|
|
* | Inspire Internet Relay Chat Daemon |
|
|
|
|
* +------------------------------------+
|
|
|
|
*
|
2007-05-15 16:11:12 +00:00
|
|
|
* InspIRCd is copyright (C) 2002-2007 ChatSpike-Dev.
|
2005-12-16 18:10:38 +00:00
|
|
|
* E-mail:
|
2006-01-15 15:59:11 +00:00
|
|
|
* <brain@chatspike.net>
|
|
|
|
* <Craig@chatspike.net>
|
2005-12-16 18:10:38 +00:00
|
|
|
*
|
|
|
|
* Written by Craig Edwards, Craig McLure, and others.
|
|
|
|
* This program is free but copyrighted software; see
|
|
|
|
* the file COPYING for details.
|
|
|
|
*
|
|
|
|
* ---------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __CMD_WHOWAS_H__
|
|
|
|
#define __CMD_WHOWAS_H__
|
|
|
|
|
2007-01-07 21:14:17 +00:00
|
|
|
|
2005-12-16 18:10:38 +00:00
|
|
|
// include the common header files
|
|
|
|
|
|
|
|
#include "users.h"
|
|
|
|
#include "channels.h"
|
|
|
|
|
2007-01-08 04:07:04 +00:00
|
|
|
/* list of available internal commands */
|
|
|
|
enum Internals
|
|
|
|
{
|
|
|
|
WHOWAS_ADD = 1,
|
|
|
|
WHOWAS_STATS = 2,
|
|
|
|
WHOWAS_PRUNE = 3,
|
|
|
|
WHOWAS_MAINTAIN = 4
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Forward ref for timer */
|
2007-05-19 15:56:42 +00:00
|
|
|
class WhoWasMaintainTimer;
|
2007-01-07 21:14:17 +00:00
|
|
|
|
2007-01-08 04:07:04 +00:00
|
|
|
/* Forward ref for typedefs */
|
|
|
|
class WhoWasGroup;
|
|
|
|
|
2007-01-07 21:14:17 +00:00
|
|
|
/** InspTimer that is used to maintain the whowas list, called once an hour
|
|
|
|
*/
|
2007-05-19 15:56:42 +00:00
|
|
|
extern WhoWasMaintainTimer* timer;
|
2007-01-07 21:14:17 +00:00
|
|
|
|
2007-01-08 04:07:04 +00:00
|
|
|
/** A group of users related by nickname
|
|
|
|
*/
|
|
|
|
typedef std::deque<WhoWasGroup*> whowas_set;
|
|
|
|
|
|
|
|
/** Sets of users in the whowas system
|
|
|
|
*/
|
|
|
|
typedef std::map<irc::string,whowas_set*> whowas_users;
|
|
|
|
|
|
|
|
/** Sets of time and users in whowas list
|
|
|
|
*/
|
|
|
|
typedef std::deque<std::pair<time_t,irc::string> > whowas_users_fifo;
|
|
|
|
|
2006-09-15 15:06:51 +00:00
|
|
|
/** Handle /WHOWAS
|
|
|
|
*/
|
2005-12-16 18:10:38 +00:00
|
|
|
class cmd_whowas : public command_t
|
2007-01-07 21:14:17 +00:00
|
|
|
{
|
2007-01-08 04:07:04 +00:00
|
|
|
private:
|
|
|
|
/** Whowas container, contains a map of vectors of users tracked by WHOWAS
|
|
|
|
*/
|
|
|
|
whowas_users whowas;
|
|
|
|
|
|
|
|
/** Whowas container, contains a map of time_t to users tracked by WHOWAS
|
|
|
|
*/
|
|
|
|
whowas_users_fifo whowas_fifo;
|
|
|
|
|
2007-01-07 21:14:17 +00:00
|
|
|
public:
|
|
|
|
cmd_whowas(InspIRCd* Instance);
|
|
|
|
CmdResult Handle(const char** parameters, int pcnt, userrec *user);
|
|
|
|
CmdResult HandleInternal(const unsigned int id, const std::deque<classbase*> ¶meters);
|
|
|
|
void AddToWhoWas(userrec* user);
|
|
|
|
void GetStats(Extensible* ext);
|
|
|
|
void PruneWhoWas(time_t t);
|
2007-01-08 04:07:04 +00:00
|
|
|
void MaintainWhoWas(time_t t);
|
2007-01-07 21:14:17 +00:00
|
|
|
virtual ~cmd_whowas();
|
|
|
|
};
|
|
|
|
|
|
|
|
/** Used to hold WHOWAS information
|
|
|
|
*/
|
|
|
|
class WhoWasGroup : public classbase
|
2005-12-16 18:10:38 +00:00
|
|
|
{
|
|
|
|
public:
|
2007-01-07 21:14:17 +00:00
|
|
|
/** Real host
|
|
|
|
*/
|
|
|
|
char* host;
|
|
|
|
/** Displayed host
|
|
|
|
*/
|
|
|
|
char* dhost;
|
|
|
|
/** Ident
|
|
|
|
*/
|
|
|
|
char* ident;
|
|
|
|
/** Server name
|
|
|
|
*/
|
|
|
|
const char* server;
|
|
|
|
/** Fullname (GECOS)
|
|
|
|
*/
|
|
|
|
char* gecos;
|
|
|
|
/** Signon time
|
|
|
|
*/
|
|
|
|
time_t signon;
|
|
|
|
|
|
|
|
/** Initialize this WhoQasFroup with a user
|
|
|
|
*/
|
|
|
|
WhoWasGroup(userrec* user);
|
|
|
|
/** Destructor
|
|
|
|
*/
|
|
|
|
~WhoWasGroup();
|
|
|
|
};
|
|
|
|
|
2007-05-19 15:56:42 +00:00
|
|
|
class WhoWasMaintainTimer : public InspTimer
|
2007-01-07 21:14:17 +00:00
|
|
|
{
|
|
|
|
private:
|
|
|
|
InspIRCd* ServerInstance;
|
|
|
|
public:
|
2007-05-19 15:56:42 +00:00
|
|
|
WhoWasMaintainTimer(InspIRCd* Instance, long interval)
|
2007-01-08 19:58:16 +00:00
|
|
|
: InspTimer(interval, Instance->Time(), true), ServerInstance(Instance)
|
2007-01-07 21:14:17 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
virtual void Tick(time_t TIME);
|
2005-12-16 18:10:38 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|