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