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