1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd is copyright (C) 2002-2007 ChatSpike-Dev.
7 * <brain@chatspike.net>
8 * <Craig@chatspike.net>
10 * Written by Craig Edwards, Craig McLure, and others.
11 * This program is free but copyrighted software; see
12 * the file COPYING for details.
14 * ---------------------------------------------------
17 #ifndef __CMD_WHOWAS_H__
18 #define __CMD_WHOWAS_H__
21 // include the common header files
26 /* list of available internal commands */
35 /* Forward ref for timer */
36 class WhoWasMaintainTimer;
38 /* Forward ref for typedefs */
41 /** InspTimer that is used to maintain the whowas list, called once an hour
43 extern WhoWasMaintainTimer* timer;
45 /** A group of users related by nickname
47 typedef std::deque<WhoWasGroup*> whowas_set;
49 /** Sets of users in the whowas system
51 typedef std::map<irc::string,whowas_set*> whowas_users;
53 /** Sets of time and users in whowas list
55 typedef std::deque<std::pair<time_t,irc::string> > whowas_users_fifo;
57 /** Handle /WHOWAS. These command handlers can be reloaded by the core,
58 * and handle basic RFC1459 commands. Commands within modules work
59 * the same way, however, they can be fully unloaded, where these
62 class cmd_whowas : public command_t
65 /** Whowas container, contains a map of vectors of users tracked by WHOWAS
69 /** Whowas container, contains a map of time_t to users tracked by WHOWAS
71 whowas_users_fifo whowas_fifo;
73 /* String holding stats so it can be collected
78 cmd_whowas(InspIRCd* Instance);
80 * @param parameters The parameters to the comamnd
81 * @param pcnt The number of parameters passed to teh command
82 * @param user The user issuing the command
83 * @return A value from CmdResult to indicate command success or failure.
85 CmdResult Handle(const char** parameters, int pcnt, userrec *user);
87 * @param parameters The parameters to the comamnd
88 * @param pcnt The number of parameters passed to teh command
89 * @param user The user issuing the command
90 * @return A value from CmdResult to indicate command success or failure.
92 CmdResult HandleInternal(const unsigned int id, const std::deque<classbase*> ¶meters);
93 void AddToWhoWas(userrec* user);
94 void GetStats(Extensible* ext);
95 void PruneWhoWas(time_t t);
96 void MaintainWhoWas(time_t t);
97 virtual ~cmd_whowas();
100 /** Used to hold WHOWAS information
102 class WhoWasGroup : public classbase
124 /** Initialize this WhoQasFroup with a user
126 WhoWasGroup(userrec* user);
132 class WhoWasMaintainTimer : public InspTimer
135 InspIRCd* ServerInstance;
137 WhoWasMaintainTimer(InspIRCd* Instance, long interval)
138 : InspTimer(interval, Instance->Time(), true), ServerInstance(Instance)
141 virtual void Tick(time_t TIME);