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