]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - include/usermanager.h
Commit -Wformat=2 -Wmissing-format-attributes, printf-like functions in inspircd...
[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 AddClient(InspIRCd* Instance, int socket, int port, bool iscached, int socketfamily, sockaddr* ip, const std::string &targetip);
75
76         /** Add a user to the local clone map
77          * @param user The user to add
78          */
79         void AddLocalClone(User *user);
80
81         /** Add a user to the global clone map
82          * @param user The user to add
83          */
84         void AddGlobalClone(User *user);
85
86         /** Remove all clone counts from the user, you should
87          * use this if you change the user's IP address 
88          * after they have registered.
89          * @param user The user to remove
90          */
91         void RemoveCloneCounts(User *user);
92
93         /** Return the number of global clones of this user
94          * @param user The user to get a count for
95          * @return The global clone count of this user
96          */
97         unsigned long GlobalCloneCount(User *user);
98
99         /** Return the number of local clones of this user
100          * @param user The user to get a count for
101          * @return The local clone count of this user
102          */
103         unsigned long LocalCloneCount(User *user);
104
105         /** Return a count of users, unknown and known connections
106          * @return The number of users
107          */
108         unsigned int UserCount();
109
110         /** Return a count of fully registered connections only
111          * @return The number of registered users
112          */
113         unsigned int RegisteredUserCount();
114
115         /** Return a count of opered (umode +o) users only
116          * @return The number of opers
117          */
118         unsigned int OperCount();
119
120         /** Return a count of unregistered (before NICK/USER) users only
121          * @return The number of unregistered (unknown) connections
122          */
123         unsigned int UnregisteredUserCount();
124
125         /** Return a count of local users on this server only
126          * @return The number of local users
127          */
128         unsigned int LocalUserCount();
129
130
131
132
133         /** Number of users with a certain mode set on them
134          */
135         int ModeCount(const char mode);
136
137         /** Send a server notice to all local users
138          * @param text The text format string to send
139          * @param ... The format arguments
140          */
141         void ServerNoticeAll(const char* text, ...) CUSTOM_PRINTF(2, 3);
142
143         /** Send a server message (PRIVMSG) to all local users
144          * @param text The text format string to send
145          * @param ... The format arguments
146          */
147         void ServerPrivmsgAll(const char* text, ...) CUSTOM_PRINTF(2, 3);
148
149         /** Send text to all users with a specific set of modes
150          * @param modes The modes to check against, without a +, e.g. 'og'
151          * @param flags one of WM_OR or WM_AND. If you specify WM_OR, any one of the
152          * mode characters in the first parameter causes receipt of the message, and
153          * if you specify WM_OR, all the modes must be present.
154          * @param text The text format string to send
155          * @param ... The format arguments
156          */
157         void WriteMode(const char* modes, int flags, const char* text, ...) CUSTOM_PRINTF(4, 5);
158 };
159
160 #endif