]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - include/commands/cmd_whowas.h
Remove InspIRCd* parameters and fields
[user/henk/code/inspircd.git] / include / commands / cmd_whowas.h
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  InspIRCd: (C) 2002-2009 InspIRCd Development Team
6  * See: http://wiki.inspircd.org/Credits
7  *
8  * This program is free but copyrighted software; see
9  *      the file COPYING for details.
10  *
11  * ---------------------------------------------------
12  */
13
14 #ifndef __CMD_WHOWAS_H__
15 #define __CMD_WHOWAS_H__
16 #include "modules.h"
17
18 struct WhowasRequest : public Request
19 {
20         /* list of available internal commands */
21         enum Internals
22         {
23                 WHOWAS_ADD = 1,
24                 WHOWAS_STATS = 2,
25                 WHOWAS_PRUNE = 3,
26                 WHOWAS_MAINTAIN = 4
27         };
28
29         const Internals type;
30         std::string value;
31         User* user;
32
33         WhowasRequest(Module* src, Module* whowas, Internals Type) : Request(src, whowas, "WHOWAS"), type(Type)
34         {}
35 };
36
37 /* Forward ref for timer */
38 class WhoWasMaintainTimer;
39
40 /* Forward ref for typedefs */
41 class WhoWasGroup;
42
43 /** Timer that is used to maintain the whowas list, called once an hour
44  */
45 extern WhoWasMaintainTimer* timer;
46
47 /** A group of users related by nickname
48  */
49 typedef std::deque<WhoWasGroup*> whowas_set;
50
51 /** Sets of users in the whowas system
52  */
53 typedef std::map<irc::string,whowas_set*> whowas_users;
54
55 /** Sets of time and users in whowas list
56  */
57 typedef std::deque<std::pair<time_t,irc::string> > whowas_users_fifo;
58
59 /** Handle /WHOWAS. These command handlers can be reloaded by the core,
60  * and handle basic RFC1459 commands. Commands within modules work
61  * the same way, however, they can be fully unloaded, where these
62  * may not.
63  */
64 class CommandWhowas : public Command
65 {
66   private:
67         /** Whowas container, contains a map of vectors of users tracked by WHOWAS
68          */
69         whowas_users whowas;
70
71         /** Whowas container, contains a map of time_t to users tracked by WHOWAS
72          */
73         whowas_users_fifo whowas_fifo;
74
75         /* String holding stats so it can be collected
76          */
77         std::string stats;
78
79   public:
80         CommandWhowas(Module* parent);
81         /** Handle command.
82          * @param parameters The parameters to the comamnd
83          * @param pcnt The number of parameters passed to teh command
84          * @param user The user issuing the command
85          * @return A value from CmdResult to indicate command success or failure.
86          */
87         CmdResult Handle(const std::vector<std::string>& parameters, User *user);
88         void AddToWhoWas(User* user);
89         std::string GetStats();
90         void PruneWhoWas(time_t t);
91         void MaintainWhoWas(time_t t);
92         ~CommandWhowas();
93 };
94
95 /** Used to hold WHOWAS information
96  */
97 class WhoWasGroup : public classbase
98 {
99  public:
100         /** Real host
101          */
102         std::string host;
103         /** Displayed host
104          */
105         std::string dhost;
106         /** Ident
107          */
108         std::string ident;
109         /** Server name
110          */
111         const char* server;
112         /** Fullname (GECOS)
113          */
114         std::string gecos;
115         /** Signon time
116          */
117         time_t signon;
118
119         /** Initialize this WhoQasFroup with a user
120          */
121         WhoWasGroup(User* user);
122         /** Destructor
123          */
124         ~WhoWasGroup();
125 };
126
127 class WhoWasMaintainTimer : public Timer
128 {
129   public:
130         WhoWasMaintainTimer(long interval)
131         : Timer(interval, ServerInstance->Time(), true)
132         {
133         }
134         virtual void Tick(time_t TIME);
135 };
136
137 #endif