InspIRCd  3.0
cmd_whowas.h
1 /*
2  * InspIRCd -- Internet Relay Chat Daemon
3  *
4  * Copyright (C) 2009 Daniel De Graaf <[email protected]>
5  * Copyright (C) 2007 Dennis Friis <[email protected]>
6  * Copyright (C) 2006 Craig Edwards <[email protected]>
7  *
8  * This file is part of InspIRCd. InspIRCd is free software: you can
9  * redistribute it and/or modify it under the terms of the GNU General Public
10  * License as published by the Free Software Foundation, version 2.
11  *
12  * This program is distributed in the hope that it will be useful, but WITHOUT
13  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
15  * details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
21 
22 #pragma once
23 
24 #include "modules.h"
25 
26 namespace WhoWas
27 {
30  struct Entry
31  {
34  const std::string host;
35 
38  const std::string dhost;
39 
42  const std::string ident;
43 
46  const std::string server;
47 
50  const std::string gecos;
51 
54  const time_t signon;
55 
58  Entry(User* user);
59  };
60 
63  struct Nick : public insp::intrusive_list_node<Nick>
64  {
67  typedef std::deque<Entry*> List;
68 
71  List entries;
72 
75  const time_t addtime;
76 
79  const std::string nick;
80 
83  Nick(const std::string& nickname);
84 
87  ~Nick();
88  };
89 
90  class Manager
91  {
92  public:
93  struct Stats
94  {
97  size_t entrycount;
98  };
99 
103  void Add(User* user);
104 
108  Stats GetStats() const;
109 
112  void Maintain();
113 
121  void UpdateConfig(unsigned int NewGroupSize, unsigned int NewMaxGroups, unsigned int NewMaxKeep);
122 
127  const Nick* FindNick(const std::string& nick) const;
128 
132  bool IsEnabled() const;
133 
136  Manager();
137 
140  ~Manager();
141 
142  private:
146 
149  typedef TR1NS::unordered_map<std::string, WhoWas::Nick*, irc::insensitive, irc::StrHashComp> whowas_users;
150 
153  whowas_users whowas;
154 
157  FIFO whowas_fifo;
158 
161  unsigned int GroupSize;
162 
166  unsigned int MaxGroups;
167 
170  unsigned int MaxKeep;
171 
174  void Prune();
175 
179  void PurgeNick(whowas_users::iterator it);
180 
184  void PurgeNick(WhoWas::Nick* nick);
185  };
186 }
187 
193 class CommandWhowas : public Command
194 {
195  public:
199 
200  CommandWhowas(Module* parent);
206  CmdResult Handle(const std::vector<std::string>& parameters, User *user);
207 };
Definition: cmd_whowas.h:90
const std::string ident
Definition: cmd_whowas.h:42
Definition: intrusive_list.h:33
Entry(User *user)
Definition: users.h:224
const std::string gecos
Definition: cmd_whowas.h:50
Definition: typedefs.h:113
Definition: ctables.h:204
const std::string nick
Definition: cmd_whowas.h:79
List entries
Definition: cmd_whowas.h:71
const std::string host
Definition: cmd_whowas.h:34
Definition: cmd_whowas.h:63
const std::string dhost
Definition: cmd_whowas.h:38
const std::string server
Definition: cmd_whowas.h:46
Definition: modules.h:245
size_t entrycount
Definition: cmd_whowas.h:97
WhoWas::Manager manager
Definition: cmd_whowas.h:198
Definition: cmd_whowas.h:30
std::deque< Entry * > List
Definition: cmd_whowas.h:67
Definition: cmd_whowas.h:26
const time_t addtime
Definition: cmd_whowas.h:75
const time_t signon
Definition: cmd_whowas.h:54
Definition: cmd_whowas.h:193