]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - include/commands/cmd_whowas.h
Add comments
[user/henk/code/inspircd.git] / include / commands / cmd_whowas.h
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  InspIRCd is copyright (C) 2002-2007 ChatSpike-Dev.
6  *                     E-mail:
7  *              <brain@chatspike.net>
8  *              <Craig@chatspike.net>
9  *
10  * Written by Craig Edwards, Craig McLure, and others.
11  * This program is free but copyrighted software; see
12  *          the file COPYING for details.
13  *
14  * ---------------------------------------------------
15  */
16
17 #ifndef __CMD_WHOWAS_H__
18 #define __CMD_WHOWAS_H__
19
20
21 // include the common header files
22
23 #include "users.h"
24 #include "channels.h"
25
26 /* list of available internal commands */
27 enum Internals
28 {
29         WHOWAS_ADD = 1,
30         WHOWAS_STATS = 2,
31         WHOWAS_PRUNE = 3,
32         WHOWAS_MAINTAIN = 4
33 };
34
35 /* Forward ref for timer */
36 class WhoWasMaintainTimer;
37
38 /* Forward ref for typedefs */
39 class WhoWasGroup;
40
41 /** InspTimer that is used to maintain the whowas list, called once an hour
42  */
43 extern WhoWasMaintainTimer* timer;
44
45 /** A group of users related by nickname
46  */
47 typedef std::deque<WhoWasGroup*> whowas_set;
48
49 /** Sets of users in the whowas system
50  */
51 typedef std::map<irc::string,whowas_set*> whowas_users;
52
53 /** Sets of time and users in whowas list
54  */
55 typedef std::deque<std::pair<time_t,irc::string> > whowas_users_fifo;
56
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
60  * may not.
61  */
62 class cmd_whowas : public command_t
63 {
64   private:
65         /** Whowas container, contains a map of vectors of users tracked by WHOWAS
66          */
67         whowas_users whowas;
68         
69         /** Whowas container, contains a map of time_t to users tracked by WHOWAS
70          */
71         whowas_users_fifo whowas_fifo;
72
73         /* String holding stats so it can be collected
74          */
75         std::string stats;
76
77   public:
78         cmd_whowas(InspIRCd* Instance);
79         CmdResult Handle(const char** parameters, int pcnt, userrec *user);
80         CmdResult HandleInternal(const unsigned int id, const std::deque<classbase*> &parameters);
81         void AddToWhoWas(userrec* user);
82         void GetStats(Extensible* ext);
83         void PruneWhoWas(time_t t);
84         void MaintainWhoWas(time_t t);
85         virtual ~cmd_whowas();
86 };
87
88 /** Used to hold WHOWAS information
89  */
90 class WhoWasGroup : public classbase
91 {
92  public:
93         /** Real host
94          */
95         char* host;
96         /** Displayed host
97          */
98         char* dhost;
99         /** Ident
100          */
101         char* ident;
102         /** Server name
103          */
104         const char* server;
105         /** Fullname (GECOS)
106          */
107         char* gecos;
108         /** Signon time
109          */
110         time_t signon;
111
112         /** Initialize this WhoQasFroup with a user
113          */
114         WhoWasGroup(userrec* user);
115         /** Destructor
116          */
117         ~WhoWasGroup();
118 };
119
120 class WhoWasMaintainTimer : public InspTimer
121 {
122   private:
123         InspIRCd* ServerInstance;
124   public:
125         WhoWasMaintainTimer(InspIRCd* Instance, long interval)
126         : InspTimer(interval, Instance->Time(), true), ServerInstance(Instance)
127         {
128         }
129         virtual void Tick(time_t TIME);
130 };
131
132 #endif