InspIRCd  3.0
usermanager.h
1 /*
2  * InspIRCd -- Internet Relay Chat Daemon
3  *
4  * Copyright (C) 2008 Robin Burchell <[email protected]>
5  *
6  * This file is part of InspIRCd. InspIRCd is free software: you can
7  * redistribute it and/or modify it under the terms of the GNU General Public
8  * License as published by the Free Software Foundation, version 2.
9  *
10  * This program is distributed in the hope that it will be useful, but WITHOUT
11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
13  * details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 
20 #pragma once
21 
22 #include <list>
23 
24 class CoreExport UserManager : public fakederef<UserManager>
25 {
26  public:
27  struct CloneCounts
28  {
29  unsigned int global;
30  unsigned int local;
31  CloneCounts() : global(0), local(0) { }
32  };
33 
36  typedef std::map<irc::sockets::cidr_mask, CloneCounts> CloneMap;
37 
40  typedef std::vector<User*> OperList;
41 
45 
46  private:
49  CloneMap clonemap;
50 
53  const CloneCounts zeroclonecounts;
54 
57  LocalList local_users;
58 
62  already_sent_t already_sent_id;
63 
64  public:
67  UserManager();
68 
71  ~UserManager();
72 
75  user_hash clientlist;
76 
79  user_hash uuidlist;
80 
84 
88  unsigned int unregistered_count;
89 
93  void DoBackgroundUserStuff();
94 
106  void AddUser(int socket, ListenSocket* via, irc::sockets::sockaddrs* client, irc::sockets::sockaddrs* server);
107 
114  void QuitUser(User* user, const std::string& quitreason, const std::string* operreason = NULL);
115 
119  void AddClone(User* user);
120 
126  void RemoveCloneCounts(User *user);
127 
130  void RehashCloneCounts();
131 
138  const CloneCounts& GetCloneCounts(User* user) const;
139 
143  const CloneMap& GetCloneMap() const { return clonemap; }
144 
148  unsigned int UserCount() const { return this->clientlist.size(); }
149 
153  unsigned int RegisteredUserCount() { return this->clientlist.size() - this->UnregisteredUserCount(); }
154 
158  unsigned int OperCount() const { return this->all_opers.size(); }
159 
163  unsigned int UnregisteredUserCount() const { return this->unregistered_count; }
164 
168  unsigned int LocalUserCount() const { return (this->local_users.size() - this->UnregisteredUserCount()); }
169 
173  user_hash& GetUsers() { return clientlist; }
174 
178  const LocalList& GetLocalUsers() const { return local_users; }
179 
184  void ServerNoticeAll(const char* text, ...) CUSTOM_PRINTF(2, 3);
185 
189  already_sent_t NextAlreadySentId();
190 };
user_hash uuidlist
Definition: usermanager.h:79
unsigned int OperCount() const
Definition: usermanager.h:158
unsigned int UserCount() const
Definition: usermanager.h:148
Definition: usermanager.h:27
user_hash clientlist
Definition: usermanager.h:75
std::vector< User * > OperList
Definition: usermanager.h:40
Definition: users.h:224
const LocalList & GetLocalUsers() const
Definition: usermanager.h:178
Definition: socket.h:58
user_hash & GetUsers()
Definition: usermanager.h:173
std::map< irc::sockets::cidr_mask, CloneCounts > CloneMap
Definition: usermanager.h:36
unsigned int LocalUserCount() const
Definition: usermanager.h:168
Definition: usermanager.h:24
unsigned int unregistered_count
Definition: usermanager.h:88
Definition: inspircd.h:65
unsigned int RegisteredUserCount()
Definition: usermanager.h:153
insp::intrusive_list< LocalUser > LocalList
Definition: usermanager.h:44
const CloneMap & GetCloneMap() const
Definition: usermanager.h:143
unsigned int UnregisteredUserCount() const
Definition: usermanager.h:163
Definition: socket.h:141
OperList all_opers
Definition: usermanager.h:83