]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - include/users.h
Added some netsplit handling stuff (untested)
[user/henk/code/inspircd.git] / include / users.h
1 /*
2
3
4 */
5
6 #include "inspircd_config.h" 
7 #include "channels.h"
8 #include "connection.h"
9
10 #include <string>
11  
12 #ifndef __USERS_H__ 
13 #define __USERS_H__ 
14  
15 #define STATUS_OP       4
16 #define STATUS_HOP      2
17 #define STATUS_VOICE    1
18 #define STATUS_NORMAL   0
19
20 #define CC_ALLOW        0
21 #define CC_DENY         1
22
23 /** Holds a channel name to which a user has been invited.
24  */
25 class Invited : public classbase
26 {
27  public:
28         char channel[CHANMAX];
29 };
30
31
32 /** Holds information relevent to &lt;connect allow&gt; and &lt;connect deny&gt; tags in the config file.
33  */
34 class ConnectClass : public classbase
35 {
36  public:
37         /** Type of line, either CC_ALLOW or CC_DENY
38          */
39         int type;
40         /** Max time to register the connection in seconds
41          */
42         int registration_timeout;
43         /** Number of lines in buffer before excess flood is triggered
44          */
45         int flood;
46         /** Host mask for this line
47          */
48         char host[MAXBUF];
49         /** (Optional) Password for this line
50          */
51         char pass[MAXBUF];
52         
53         ConnectClass()
54         {
55                 registration_timeout = 0;
56                 flood = 0;
57                 strcpy(host,"");
58                 strcpy(pass,"");
59         }
60 };
61
62 /** Holds a complete list of all channels to which a user has been invited and has not yet joined.
63  */
64 typedef std::vector<Invited> InvitedList;
65
66
67
68 /** Holds a complete list of all allow and deny tags from the configuration file (connection classes)
69  */
70 typedef std::vector<ConnectClass> ClassVector;
71
72 /** Holds all information about a user
73  * This class stores all information about a user connected to the irc server. Everything about a
74  * connection is stored here primarily, from the user's socket ID (file descriptor) through to the
75  * user's nickname and hostname. Use the Find method of the server class to locate a specific user
76  * by nickname.
77  */
78 class userrec : public connection
79 {
80  private:
81
82         /** A list of channels the user has a pending invite to.
83          */
84         InvitedList invites;
85  public:
86         
87         /** The users nickname.
88          * An invalid nickname indicates an unregistered connection prior to the NICK command.
89          */
90         
91         char nick[NICKMAX];
92         
93         /** The users ident reply.
94          */
95         char ident[64];
96
97         /** The host displayed to non-opers (used for cloaking etc).
98          * This usually matches the value of userrec::host.
99          */
100         char dhost[256];
101         
102         /** The users full name.
103          */
104         char fullname[128];
105         
106         /** The user's mode string.
107          * This may contain any of the following RFC characters: o, w, s, i
108          * Your module may define other mode characters as it sees fit.
109          */
110         char modes[MAXBUF];
111         
112         ucrec chans[MAXCHANS];
113         
114         /** The server the user is connected to.
115          */
116         char server[256];
117         
118         /** The user's away message.
119          * If this string is empty, the user is not marked as away.
120          */
121         char awaymsg[512];
122         
123         /** Stores the result of the last GetFullHost or GetRealHost call.
124          * You may use this to increase the speed of use of this class.
125          */
126         char result[256];
127         
128         /** Number of lines the user can place into the buffer
129          * (up to the global NetBufferSize bytes) before they
130          * are disconnected for excess flood
131          */
132         int flood;
133         
134         /** Number of seconds this user is given to send USER/NICK
135          * If they do not send their details in this time limit they
136          * will be disconnected
137          */
138         unsigned long timeout;
139
140         userrec();
141         
142         virtual ~userrec() {  }
143         
144         /** Returns the full displayed host of the user
145          * This member function returns the hostname of the user as seen by other users
146          * on the server, in nick!ident&at;host form.
147          */
148         virtual char* GetFullHost();
149         
150         /** Returns the full real host of the user
151          * This member function returns the hostname of the user as seen by other users
152          * on the server, in nick!ident&at;host form. If any form of hostname cloaking is in operation,
153          * e.g. through a module, then this method will ignore it and return the true hostname.
154          */
155         virtual char* GetFullRealHost();
156         
157         /** Returns true if a user is invited to a channel.
158          */
159         virtual bool IsInvited(char* channel);
160         
161         /** Adds a channel to a users invite list (invites them to a channel)
162          */
163         virtual void InviteTo(char* channel);
164         
165         /** Removes a channel from a users invite list.
166          * This member function is called on successfully joining an invite only channel
167          * to which the user has previously been invited, to clear the invitation.
168          */
169         virtual void RemoveInvite(char* channel);
170         
171 };
172
173
174 #endif