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