1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * Inspire is copyright (C) 2002-2004 ChatSpike-Dev.
7 * <brain@chatspike.net>
8 * <Craig@chatspike.net>
10 * Written by Craig Edwards, Craig McLure, and others.
11 * This program is free but copyrighted software; see
12 * the file COPYING for details.
14 * ---------------------------------------------------
17 #include "inspircd_config.h"
23 #ifndef __CHANNELS_H__
24 #define __CHANNELS_H__
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.
29 class HostItem : public classbase
36 HostItem() { /* stub */ }
37 virtual ~HostItem() { /* stub */ }
40 // banlist is inherited from HostList mainly for readability
43 /** A subclass of HostItem designed to hold channel bans (+b)
45 class BanItem : public HostItem
51 /** A subclass of HostItem designed to hold channel exempts (+e)
53 class ExemptItem : public HostItem
59 /** A subclass of HostItem designed to hold channel invites (+I)
61 class InviteItem : public HostItem
66 /** Holds a custom parameter to a module-defined channel mode
67 * e.g. for +L this would hold the channel name.
70 class ModeParameter : public classbase
74 char parameter[MAXBUF];
75 char channel[CHANMAX];
78 /** Holds a complete ban list
80 typedef std::vector<BanItem> BanList;
82 /** Holds a complete exempt list
84 typedef std::vector<ExemptItem> ExemptList;
86 /** Holds a complete invite list
88 typedef std::vector<InviteItem> InviteList;
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.
94 class chanrec : public Extensible
97 /** The channels name.
99 char name[CHANMAX]; /* channel name */
100 /** Custom modes for the channel.
101 * Plugins may use this field in any way they see fit.
103 char custom_modes[MAXMODES]; /* modes handled by modules */
105 /** Count of users on the channel used for fast user counting
110 * If this is an empty string, no channel topic is set.
116 /** Time topic was set.
117 * If no topic was ever set, this will be equal to chanrec::created
120 /** The last user to set the topic.
121 * If this member is an empty string, no topic was ever set.
125 /** Contains the channel user limit.
126 * If this value is zero, there is no limit in place.
130 /** Contains the channel key.
131 * If this value is an empty string, there is no channel key in place.
135 /** Nonzero if the mode +t is set.
139 /** Nonzero if the mode +n is set.
141 short int noexternal;
143 /** Nonzero if the mode +i is set.
145 short int inviteonly;
147 /** Nonzero if the mode +m is set.
151 /** Nonzero if the mode +s is set.
152 * This value cannot be set at the same time as chanrec::c_private
156 /** Nonzero if the mode +p is set.
157 * This value cannot be set at the same time as chanrec::secret
161 /** The list of all bans set on the channel.
165 /** Sets or unsets a custom mode in the channels info
167 void SetCustomMode(char mode,bool mode_on);
169 /** Sets or unsets the parameters for a custom mode in a channels info
171 void SetCustomModeParam(char mode,char* parameter,bool mode_on);
173 /** Returns true if a custom mode is set on a channel
175 bool IsCustomModeSet(char mode);
177 /** Returns the parameter for a custom mode on a channel.
178 * For example if "+L #foo" is set, and you pass this method
179 * 'L', it will return '#foo'. If the mode is not set on the
180 * channel, or the mode has no parameters associated with it,
181 * it will return an empty string.
183 std::string GetModeParameter(char mode);
185 void IncUserCounter();
186 void DecUserCounter();
187 long GetUserCounter();
190 /** Creates a channel record and initialises it with default values
194 virtual ~chanrec() { /* stub */ }
197 /* used to hold a channel and a users modes on that channel, e.g. +v, +h, +o
198 * needs to come AFTER struct chanrec */
201 #define UCMODE_VOICE 2
203 #define UCMODE_PROTECT 8
204 #define UCMODE_FOUNDER 16
206 /** Holds a user's modes on a channel
207 * This class associates a users privilages with a channel by creating a pointer link between
208 * a userrec and chanrec class. The uc_modes member holds a bitmask of which privilages the user
209 * has on the channel, such as op, voice, etc.
211 class ucrec : public classbase
214 /** Contains a bitmask of the UCMODE_OP ... UCMODE_FOUNDER values.
215 * If this value is zero, the user has no privilages upon the channel.
219 /** Points to the channel record where the given modes apply.
220 * If the record is not in use, this value will be NULL.
224 ucrec() { /* stub */ }
225 virtual ~ucrec() { /* stub */ }