]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - include/commands/cmd_whowas.h
Move whowas containers into whowas class to avoid all cpp files including cmd_whowas...
[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-2006 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 MaintainTimer;
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 MaintainTimer* 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
58  */
59 class cmd_whowas : public command_t
60 {
61   private:
62         /** Whowas container, contains a map of vectors of users tracked by WHOWAS
63          */
64         whowas_users whowas;
65         
66         /** Whowas container, contains a map of time_t to users tracked by WHOWAS
67          */
68         whowas_users_fifo whowas_fifo;
69
70   public:
71         cmd_whowas(InspIRCd* Instance);
72         CmdResult Handle(const char** parameters, int pcnt, userrec *user);
73         CmdResult HandleInternal(const unsigned int id, const std::deque<classbase*> &parameters);
74         void AddToWhoWas(userrec* user);
75         void GetStats(Extensible* ext);
76         void PruneWhoWas(time_t t);
77         void MaintainWhoWas(time_t t);
78         virtual ~cmd_whowas();
79 };
80
81 /** Used to hold WHOWAS information
82  */
83 class WhoWasGroup : public classbase
84 {
85  public:
86         /** Real host
87          */
88         char* host;
89         /** Displayed host
90          */
91         char* dhost;
92         /** Ident
93          */
94         char* ident;
95         /** Server name
96          */
97         const char* server;
98         /** Fullname (GECOS)
99          */
100         char* gecos;
101         /** Signon time
102          */
103         time_t signon;
104
105         /** Initialize this WhoQasFroup with a user
106          */
107         WhoWasGroup(userrec* user);
108         /** Destructor
109          */
110         ~WhoWasGroup();
111 };
112
113 class MaintainTimer : public InspTimer
114 {
115   private:
116         InspIRCd* ServerInstance;
117   public:
118         MaintainTimer(InspIRCd* Instance, long interval)
119         : InspTimer(interval, Instance->Time()), ServerInstance(Instance)
120         {
121         }
122         virtual void Tick(time_t TIME);
123 };
124
125 #endif