]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - include/channels.h
Added some netsplit handling stuff (untested)
[user/henk/code/inspircd.git] / include / channels.h
1 /*
2
3    
4 */
5
6 #include "inspircd_config.h"
7 #include "base.h"
8 #include <time.h>
9 #include <vector>
10 #include <string>
11
12 #ifndef __CHANNELS_H__
13 #define __CHANNELS_H__
14
15 /** Holds an entry for a ban list, exemption list, or invite list.
16  * This class contains a single element in a channel list, such as a banlist.
17  */
18 class HostItem : public classbase
19 {
20  public:
21         time_t set_time;
22         char set_by[NICKMAX];
23         char data[MAXBUF];
24
25         HostItem() { /* stub */ }
26         virtual ~HostItem() { /* stub */ }
27 };
28
29 // banlist is inherited from HostList mainly for readability
30 // reasons only
31
32 /** A subclass of HostItem designed to hold channel bans (+b)
33  */
34 class BanItem : public HostItem
35 {
36 };
37
38 // same with this...
39
40 /** A subclass of HostItem designed to hold channel exempts (+e)
41  */
42 class ExemptItem : public HostItem
43 {
44 };
45
46 // and this...
47
48 /** A subclass of HostItem designed to hold channel invites (+I)
49  */
50 class InviteItem : public HostItem
51 {
52 };
53
54
55 /** Holds a custom parameter to a module-defined channel mode
56   * e.g. for +L this would hold the channel name.
57   */
58
59 class ModeParameter : public classbase
60 {
61  public:
62         char mode;
63         char parameter[MAXBUF];
64         char channel[CHANMAX];
65 };
66
67 /** Holds a complete ban list
68  */
69 typedef std::vector<BanItem>    BanList;
70
71 /** Holds a complete exempt list
72  */
73 typedef std::vector<ExemptItem> ExemptList;
74
75 /** Holds a complete invite list
76  */
77 typedef std::vector<InviteItem> InviteList;
78
79 /** Holds all relevent information for a channel.
80  * This class represents a channel, and contains its name, modes, time created, topic, topic set time,
81  * etc, and an instance of the BanList type.
82  */
83 class chanrec : public classbase
84 {
85  public:
86         /** The channels name.
87          */
88         char name[CHANMAX]; /* channel name */
89         /** Custom modes for the channel.
90          * Plugins may use this field in any way they see fit.
91          */
92         char custom_modes[MAXMODES];     /* modes handled by modules */
93         
94         /** Channel topic.
95          * If this is an empty string, no channel topic is set.
96          */
97         char topic[MAXBUF];
98         /** Creation time.
99          */
100         time_t created;
101         /** Time topic was set.
102          * If no topic was ever set, this will be equal to chanrec::created
103          */
104         time_t topicset;
105         /** The last user to set the topic.
106          * If this member is an empty string, no topic was ever set.
107          */
108         char setby[NICKMAX];
109
110         /** Contains the channel user limit.
111          * If this value is zero, there is no limit in place.
112          */
113         long limit;
114         
115         /** Contains the channel key.
116          * If this value is an empty string, there is no channel key in place.
117          */
118         char key[32];
119         
120         /** Nonzero if the mode +t is set.
121          */
122         short int topiclock;
123         
124         /** Nonzero if the mode +n is set.
125          */
126         short int noexternal;
127         
128         /** Nonzero if the mode +i is set.
129          */
130         short int inviteonly;
131         
132         /** Nonzero if the mode +m is set.
133          */
134         short int moderated;
135         
136         /** Nonzero if the mode +s is set.
137          * This value cannot be set at the same time as chanrec::c_private
138          */
139         short int secret;
140         
141         /** Nonzero if the mode +p is set.
142          * This value cannot be set at the same time as chanrec::secret
143          */
144         short int c_private;
145         
146         /** The list of all bans set on the channel.
147          */
148         BanList bans;
149         
150         /** Sets or unsets a custom mode in the channels info
151          */
152         void SetCustomMode(char mode,bool mode_on);
153
154         /** Sets or unsets the parameters for a custom mode in a channels info
155          */
156         void SetCustomModeParam(char mode,char* parameter,bool mode_on);
157  
158         /** Returns true if a custom mode is set on a channel
159           */
160         bool IsCustomModeSet(char mode);
161
162         /** Returns the parameter for a custom mode on a channel.
163           * For example if "+L #foo" is set, and you pass this method
164           * 'L', it will return '#foo'. If the mode is not set on the
165           * channel, or the mode has no parameters associated with it,
166           * it will return an empty string.
167           */
168         std::string GetModeParameter(char mode);
169
170         /** Creates a channel record and initialises it with default values
171          */
172         chanrec();
173
174         virtual ~chanrec() { /* stub */ }
175 };
176
177 /* used to hold a channel and a users modes on that channel, e.g. +v, +h, +o
178  * needs to come AFTER struct chanrec */
179
180 #define UCMODE_OP      1
181 #define UCMODE_VOICE   2
182 #define UCMODE_HOP     4
183 #define UCMODE_PROTECT 8
184 #define UCMODE_FOUNDER 16
185  
186 /** Holds a user's modes on a channel
187  * This class associates a users privilages with a channel by creating a pointer link between
188  * a userrec and chanrec class. The uc_modes member holds a bitmask of which privilages the user
189  * has on the channel, such as op, voice, etc.
190  */
191 class ucrec : public classbase
192 {
193  public:
194         /** Contains a bitmask of the UCMODE_OP ... UCMODE_FOUNDER values.
195          * If this value is zero, the user has no privilages upon the channel.
196          */
197         long uc_modes;
198         
199         /** Points to the channel record where the given modes apply.
200          * If the record is not in use, this value will be NULL.
201          */
202         chanrec *channel;
203
204         ucrec() { /* stub */ }
205         virtual ~ucrec() { /* stub */ }
206 };
207
208 #endif
209