]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - include/users.h
Fixed paths and makefile locations
[user/henk/code/inspircd.git] / include / users.h
1 /*
2
3 $Log$
4 Revision 1.1  2003/01/23 19:45:58  brain
5 Initial revision
6
7 Revision 1.9  2003/01/22 00:44:26  brain
8 Added documentation comments
9
10 Revision 1.8  2003/01/21 21:11:17  brain
11 Added documentation
12
13 Revision 1.7  2003/01/17 13:21:38  brain
14 Added CONNECT ALLOW and CONNECT DENY config tags
15 Added PASS command
16
17 Revision 1.6  2003/01/17 10:37:55  brain
18 Added /INVITE command and relevent structures
19
20 Revision 1.5  2003/01/16 20:11:56  brain
21 fixed some ugly pointer bugs (thanks dblack and a|KK|y!)
22
23 Revision 1.4  2003/01/15 22:47:44  brain
24 Changed user and channel structs to classes (finally)
25
26 Revision 1.3  2003/01/14 21:14:30  brain
27 added /ISON command (for mIRC etc basic notify)
28
29
30 */
31
32 #include "inspircd_config.h" 
33 #include "channels.h"
34
35 #include <string>
36  
37 #ifndef __USERS_H__ 
38 #define __USERS_H__ 
39  
40 #define STATUS_OP       4
41 #define STATUS_HOP      2
42 #define STATUS_VOICE    1
43 #define STATUS_NORMAL   0
44
45 #define CC_ALLOW        0
46 #define CC_DENY         1
47
48 /** Holds a channel name to which a user has been invited.
49  */
50 class Invited
51 {
52  public:
53         char channel[CHANMAX];
54 };
55
56
57 /** Holds information relevent to &lt;connect allow&gt; and &lt;connect deny&gt; tags in the config file.
58  */
59 class ConnectClass
60 {
61  public:
62         int type;
63         char host[MAXBUF];
64         char pass[MAXBUF];
65 };
66
67 /** Holds a complete list of all channels to which a user has been invited and has not yet joined.
68  */
69 typedef vector<Invited> InvitedList;
70
71
72
73 /** Holds a complete list of all allow and deny tags from the configuration file (connection classes)
74  */
75 typedef vector<ConnectClass> ClassVector;
76
77 /** Holds all information about a user
78  * This class stores all information about a user connected to the irc server. Everything about a
79  * connection is stored here primarily, from the user's socket ID (file descriptor) through to the
80  * user's nickname and hostname. Use the Find method of the server class to locate a specific user
81  * by nickname.
82  */
83 class userrec
84 {
85  private:
86
87         /** A list of channels the user has a pending invite to.
88          */
89         InvitedList invites;
90  public:
91         
92         /** The users nickname.
93          * An invalid nickname indicates an unregistered connection prior to the NICK command.
94          */
95         
96         char nick[NICKMAX];
97         
98         /** The users ip address in network order.
99          */
100         unsigned long ip;
101
102         /** The users ident reply.
103          */
104         char ident[64];
105
106         /** The users hostname, or ip address in string form.
107          */
108         char host[256];
109         
110         /** The host displayed to non-opers (used for cloaking etc).
111          * This usually matches the value of userrec::host.
112          */
113         char dhost[256];
114         
115         /** The users full name.
116          */
117         char fullname[128];
118         
119         /** The users file descriptor.
120          * If this is zero, the socket has been closed and the core has not yet
121          * realised and removed the record from memory.
122          */
123         int fd;
124         
125         /** The user's mode string.
126          * This may contain any of the following RFC characters: o, w, s, i
127          * Your module may define other mode characters as it sees fit.
128          */
129         char modes[32];
130         
131         /** The users input buffer.
132          * Used by the C recv() function.
133          */
134         char inbuf[MAXBUF];
135         
136         /** The last time the user was pinged by the core.
137          * When this value is more than 120 seconds difference from 'time(NULL)', a ping is sent
138          * to the client. If the user has an outstanding PING request the next time this
139          * event occurs after 4 total minutes, they are disconnected.
140          */
141         time_t lastping;
142         
143         /** The users signon time.
144          */
145         time_t signon;
146         
147         /** The time the user last sent a message.
148          * See also userrec::lastping and userrec::signon
149          */
150         time_t idle_lastmsg;
151         
152         /** True if the user replied to their last ping.
153          * If this is true, the user can be sent another ping at the specified time, otherwise
154          * they will be discnnected. See also userrec::lastping
155          */
156         time_t nping;
157         
158         /** Bit 1 is set if the user sent a NICK command, bit 2 is set if the user sent a USER command.
159          * If both bits are set then the connection is awaiting MOTD. Sending of MOTD sets bit 3, and
160          * makes the value of userrec::registered == 7, showing a fully established client session.
161          */
162         int registered;
163         
164         /** A list of the channels the user is currently on.
165          * If any of these values are NULL, the record is not in use and may be associated with
166          * a channel by the JOIN command. see RFC 1459.
167          */
168         ucrec chans[MAXCHANS];
169         
170         /** The server the user is connected to.
171          */
172         char server[256];
173         
174         /** The user's away message.
175          * If this string is empty, the user is not marked as away.
176          */
177         char awaymsg[512];
178         
179         /** The port that the user connected to.
180          */
181         int port;
182         
183         /** Stores the number of incoming bytes from the connection.
184          * Used by /STATS
185          */
186         long bytes_in;
187         
188         /** Stores the number of outgoing bytes to the connection.
189          * Used by /STATS
190          */
191         long bytes_out;
192         
193         /** Stores the number of incoming commands from the connection.
194          * Used by /STATS
195          */
196         long cmds_in;
197         
198         /** Stores the number of outgoing commands to the connection.
199          * Used by /STATS
200          */
201         long cmds_out;
202         
203         /** Stores the result of the last GetFullHost or GetRealHost call.
204          * You may use this to increase the speed of use of this class.
205          */
206         char result[256];
207         
208         /** True if a correct password has been given using PASS command.
209          * If the user is a member of a connection class that does not require a password,
210          * the value stored here is of no use.
211          */
212         bool haspassed;
213
214         userrec();
215         
216         virtual ~userrec() {  }
217         
218         /** Returns the full displayed host of the user
219          * This member function returns the hostname of the user as seen by other users
220          * on the server, in nick!ident&at;host form.
221          */
222         virtual char* GetFullHost();
223         
224         /** Returns the full real host of the user
225          * This member function returns the hostname of the user as seen by other users
226          * on the server, in nick!ident&at;host form. If any form of hostname cloaking is in operation,
227          * e.g. through a module, then this method will ignore it and return the true hostname.
228          */
229         virtual char* GetFullRealHost();
230         
231         /** Returns true if a user is invited to a channel.
232          */
233         virtual bool IsInvited(char* channel);
234         
235         /** Adds a channel to a users invite list (invites them to a channel)
236          */
237         virtual void InviteTo(char* channel);
238         
239         /** Removes a channel from a users invite list.
240          * This member function is called on successfully joining an invite only channel
241          * to which the user has previously been invited, to clear the invitation.
242          */
243         virtual void RemoveInvite(char* channel);
244         
245 };
246
247
248 #endif