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