]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - include/usermanager.h
Route whois notices using ENCAP WHOISNOTICE to properly fix remote user PrivPermissio...
[user/henk/code/inspircd.git] / include / usermanager.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 __USERMANAGER_H
15 #define __USERMANAGER_H
16
17 #include <list>
18
19 /** A list of ip addresses cross referenced against clone counts */
20 typedef std::map<irc::string, unsigned int> clonemap;
21
22 class CoreExport UserManager : public Extensible
23 {
24  private:
25         InspIRCd *ServerInstance;
26
27         /** Map of local ip addresses for clone counting
28          */
29         clonemap local_clones;
30  public:
31         UserManager(InspIRCd *Instance) : ServerInstance(Instance)
32         {
33         }
34
35         ~UserManager()
36         {
37                 for (user_hash::iterator i = clientlist->begin();i != clientlist->end();i++)
38                 {
39                         delete i->second;
40                 }
41                 clientlist->clear();
42                 delete clientlist;
43                 delete uuidlist;
44         }
45
46         /** Client list, a hash_map containing all clients, local and remote
47          */
48         user_hash* clientlist;
49
50         /** Client list stored by UUID. Contains all clients, and is updated
51          * automatically by the constructor and destructor of User.
52          */
53         user_hash* uuidlist;
54
55         /** Local client list, a vector containing only local clients
56          */
57         std::vector<User*> local_users;
58
59         /** Oper list, a vector containing all local and remote opered users
60          */
61         std::list<User*> all_opers;
62
63         /** Number of unregistered users online right now.
64          * (Unregistered means before USER/NICK/dns)
65          */
66         int unregistered_count;
67
68         /** Map of global ip addresses for clone counting
69          * XXX - this should be private, but m_clones depends on it currently.
70          */
71         clonemap global_clones;
72
73         /** Add a client to the system.
74          * This will create a new User, insert it into the user_hash,
75          * initialize it as not yet registered, and add it to the socket engine.
76          * @param Instance a pointer to the server instance
77          * @param socket The socket id (file descriptor) this user is on
78          * @param iscached This variable is reserved for future use
79          * @param client The IP address and client port of the user
80          * @param server The server IP address and port used by the user
81          * @return This function has no return value, but a call to AddClient may remove the user.
82          */
83         void AddUser(InspIRCd* Instance, int socket, bool iscached, irc::sockets::sockaddrs* client, irc::sockets::sockaddrs* server);
84
85         /** Disconnect a user gracefully
86          * @param user The user to remove
87          * @param r The quit reason to show to normal users
88          * @param oreason The quit reason to show to opers
89          * @return Although this function has no return type, on exit the user provided will no longer exist.
90          */
91         void QuitUser(User *user, const std::string &quitreason, const char* operreason = "");
92
93         /** Add a user to the local clone map
94          * @param user The user to add
95          */
96         void AddLocalClone(User *user);
97
98         /** Add a user to the global clone map
99          * @param user The user to add
100          */
101         void AddGlobalClone(User *user);
102
103         /** Remove all clone counts from the user, you should
104          * use this if you change the user's IP address
105          * after they have registered.
106          * @param user The user to remove
107          */
108         void RemoveCloneCounts(User *user);
109
110         /** Return the number of global clones of this user
111          * @param user The user to get a count for
112          * @return The global clone count of this user
113          */
114         unsigned long GlobalCloneCount(User *user);
115
116         /** Return the number of local clones of this user
117          * @param user The user to get a count for
118          * @return The local clone count of this user
119          */
120         unsigned long LocalCloneCount(User *user);
121
122         /** Return a count of users, unknown and known connections
123          * @return The number of users
124          */
125         unsigned int UserCount();
126
127         /** Return a count of fully registered connections only
128          * @return The number of registered users
129          */
130         unsigned int RegisteredUserCount();
131
132         /** Return a count of opered (umode +o) users only
133          * @return The number of opers
134          */
135         unsigned int OperCount();
136
137         /** Return a count of unregistered (before NICK/USER) users only
138          * @return The number of unregistered (unknown) connections
139          */
140         unsigned int UnregisteredUserCount();
141
142         /** Return a count of local users on this server only
143          * @return The number of local users
144          */
145         unsigned int LocalUserCount();
146
147
148
149
150         /** Number of users with a certain mode set on them
151          */
152         int ModeCount(const char mode);
153
154         /** Send a server notice to all local users
155          * @param text The text format string to send
156          * @param ... The format arguments
157          */
158         void ServerNoticeAll(const char* text, ...) CUSTOM_PRINTF(2, 3);
159
160         /** Send a server message (PRIVMSG) to all local users
161          * @param text The text format string to send
162          * @param ... The format arguments
163          */
164         void ServerPrivmsgAll(const char* text, ...) CUSTOM_PRINTF(2, 3);
165
166         /** Send text to all users with a specific set of modes
167          * @param modes The modes to check against, without a +, e.g. 'og'
168          * @param flags one of WM_OR or WM_AND. If you specify WM_OR, any one of the
169          * mode characters in the first parameter causes receipt of the message, and
170          * if you specify WM_OR, all the modes must be present.
171          * @param text The text format string to send
172          * @param ... The format arguments
173          */
174         void WriteMode(const char* modes, int flags, const char* text, ...) CUSTOM_PRINTF(4, 5);
175 };
176
177 #endif