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 
83  OperList all_opers;
84 
88  unsigned int unregistered_count;
89 
93  void DoBackgroundUserStuff();
94 
99  bool AllModulesReportReady(LocalUser* user);
100 
112  void AddUser(int socket, ListenSocket* via, irc::sockets::sockaddrs* client, irc::sockets::sockaddrs* server);
113 
120  void QuitUser(User* user, const std::string& quitreason, const std::string* operreason = NULL);
121 
125  void AddClone(User* user);
126 
132  void RemoveCloneCounts(User *user);
133 
136  void RehashCloneCounts();
137 
144  const CloneCounts& GetCloneCounts(User* user) const;
145 
149  const CloneMap& GetCloneMap() const { return clonemap; }
150 
154  unsigned int UserCount() const { return this->clientlist.size(); }
155 
159  unsigned int RegisteredUserCount() { return this->clientlist.size() - this->UnregisteredUserCount(); }
160 
164  unsigned int OperCount() const { return this->all_opers.size(); }
165 
169  unsigned int UnregisteredUserCount() const { return this->unregistered_count; }
170 
174  unsigned int LocalUserCount() const { return (this->local_users.size() - this->UnregisteredUserCount()); }
175 
179  user_hash& GetUsers() { return clientlist; }
180 
184  const LocalList& GetLocalUsers() const { return local_users; }
185 
190  void ServerNoticeAll(const char* text, ...) CUSTOM_PRINTF(2, 3);
191 
195  already_sent_t NextAlreadySentId();
196 };
user_hash uuidlist
Definition: usermanager.h:79
unsigned int OperCount() const
Definition: usermanager.h:164
unsigned int UserCount() const
Definition: usermanager.h:154
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:184
Definition: users.h:742
Definition: socket.h:57
user_hash & GetUsers()
Definition: usermanager.h:179
std::map< irc::sockets::cidr_mask, CloneCounts > CloneMap
Definition: usermanager.h:36
unsigned int LocalUserCount() const
Definition: usermanager.h:174
Definition: usermanager.h:24
unsigned int unregistered_count
Definition: usermanager.h:88
Definition: inspircd.h:59
unsigned int RegisteredUserCount()
Definition: usermanager.h:159
insp::intrusive_list< LocalUser > LocalList
Definition: usermanager.h:44
const CloneMap & GetCloneMap() const
Definition: usermanager.h:149
unsigned int UnregisteredUserCount() const
Definition: usermanager.h:169
Definition: socket.h:130
OperList all_opers
Definition: usermanager.h:83