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