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