1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2007 InspIRCd Development Team
6 * See: http://www.inspircd.org/wiki/index.php/Credits
8 * This program is free but copyrighted software; see
9 * the file COPYING for details.
11 * ---------------------------------------------------
14 #ifndef __CMD_WHOWAS_H__
15 #define __CMD_WHOWAS_H__
18 // include the common header files
23 /* list of available internal commands */
32 /* Forward ref for timer */
33 class WhoWasMaintainTimer;
35 /* Forward ref for typedefs */
38 /** InspTimer that is used to maintain the whowas list, called once an hour
40 extern WhoWasMaintainTimer* timer;
42 /** A group of users related by nickname
44 typedef std::deque<WhoWasGroup*> whowas_set;
46 /** Sets of users in the whowas system
48 typedef std::map<irc::string,whowas_set*> whowas_users;
50 /** Sets of time and users in whowas list
52 typedef std::deque<std::pair<time_t,irc::string> > whowas_users_fifo;
54 /** Handle /WHOWAS. These command handlers can be reloaded by the core,
55 * and handle basic RFC1459 commands. Commands within modules work
56 * the same way, however, they can be fully unloaded, where these
59 class cmd_whowas : public command_t
62 /** Whowas container, contains a map of vectors of users tracked by WHOWAS
66 /** Whowas container, contains a map of time_t to users tracked by WHOWAS
68 whowas_users_fifo whowas_fifo;
70 /* String holding stats so it can be collected
75 cmd_whowas(InspIRCd* Instance);
77 * @param parameters The parameters to the comamnd
78 * @param pcnt The number of parameters passed to teh command
79 * @param user The user issuing the command
80 * @return A value from CmdResult to indicate command success or failure.
82 CmdResult Handle(const char** parameters, int pcnt, userrec *user);
83 /** Handle an internal request from another command, the core, or a module
85 * @param Zero or more parameters, whos form is specified by the command ID.
86 * @return Return CMD_SUCCESS on success, or CMD_FAILURE on failure.
87 * If the command succeeds but should remain local to this server,
88 * return CMD_LOCALONLY.
90 CmdResult HandleInternal(const unsigned int id, const std::deque<classbase*> ¶meters);
91 void AddToWhoWas(userrec* user);
92 void GetStats(Extensible* ext);
93 void PruneWhoWas(time_t t);
94 void MaintainWhoWas(time_t t);
95 virtual ~cmd_whowas();
98 /** Used to hold WHOWAS information
100 class WhoWasGroup : public classbase
122 /** Initialize this WhoQasFroup with a user
124 WhoWasGroup(userrec* user);
130 class WhoWasMaintainTimer : public InspTimer
133 InspIRCd* ServerInstance;
135 WhoWasMaintainTimer(InspIRCd* Instance, long interval)
136 : InspTimer(interval, Instance->Time(), true), ServerInstance(Instance)
139 virtual void Tick(time_t TIME);