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