inspircd/include/channels.h

1 line
19 KiB
C
Raw Normal View History

/* +------------------------------------+ * | Inspire Internet Relay Chat Daemon | * +------------------------------------+ * * InspIRCd: (C) 2002-2007 InspIRCd Development Team * See: http://www.inspircd.org/wiki/index.php/Credits * * This program is free but copyrighted software; see * the file COPYING for details. * * --------------------------------------------------- */ #ifndef __CHANNELS_H__ #define __CHANNELS_H__ #include "inspircd_config.h" #include "base.h" #include <time.h> #include <vector> #include <string> #include <map> /** RFC1459 channel modes */ enum ChannelModes { CM_TOPICLOCK = 't'-65, /* +t: Only operators can change topic */ CM_NOEXTERNAL = 'n'-65, /* +n: Only users in the channel can message it */ CM_INVITEONLY = 'i'-65, /* +i: Invite only */ CM_MODERATED = 'm'-65, /* +m: Only voices and above can talk */ CM_SECRET = 's'-65, /* +s: Secret channel */ CM_PRIVATE = 'p'-65, /* +p: Private channel */ CM_KEY = 'k'-65, /* +k: Keyed channel */ CM_LIMIT = 'l'-65 /* +l: Maximum user limit */ }; /* Forward declarations - needed */ class userrec; class chanrec; /** Holds an entry for a ban list, exemption list, or invite list. * This class contains a single element in a channel list, such as a banlist. */ class HostItem : public classbase { public: /** Time the item was added */ time_t set_time; /** Who added the item */ char set_by[NICKMAX]; /** The actual item data */ char data[MAXBUF]; HostItem() { /* stub */ } virtual ~HostItem() { /* stub */ } }; /** A subclass of HostItem designed to hold channel bans (+b) */ class BanItem : public HostItem { }; /** Holds a complete ban list */ typedef std::vector<BanItem> BanList; /** A list of users on a channel */ typedef std::map<userrec*,std::string> CUList; /** Shorthand for CUList::iterator */ typedef CUList::iterator CUListIter; /** Shorthand for CUList::const_iterator */ typedef CUList::const_iterator CUListConstIter; /** A list of custom modes parameters on a channel */ typedef std::map<char,char*> CustomModeList; /** used to hold a channel and a users modes on that channel, e.g. +v, +h, +o */ enum UserChannelModes { UCMODE_OP = 1, /* Opped user */ UCMODE_VOICE = 2, /* Voiced user */ UCMODE_HOP = 4 /* Halfopped user */ }; /* Forward declaration -- required */ class InspIRCd; /** A stored prefix and its rank */ typedef std::pair<char, unsigned int> prefixtype; /** A list of prefixes set on a user in a channel */ typedef std::vector<prefixtype> pfxcontainer; /** A list of users with zero or more prefixes set on them */ typedef std::map<userrec*, std::vector<prefixtype> > prefixlist; /** Holds all relevent information for a channel. * This class represents a channel, and contains its name, modes, time created, topic, topic set time, * etc, and an instance of the BanList type. */ class CoreExport chanrec : public Extensible { private: /** Pointer to creator object */ InspIRCd* ServerInstance; /** Connect a chanrec to a userrec */ static chanrec* ForceChan(InspIRCd* Instance, chanrec* Ptr, userrec* user, const std::string &privs); /** Set default modes for the channel on creation */ void SetDefaultModes(); /** A list of prefixes associated with each user in the channel * (e.g. &%+ etc) */ prefixlist prefixes; /** Maximum number of bans (cached) */ int maxbans; public: /** The channel's name. */ char name[CHANMAX]; /** Modes for the channel. * This is not a null terminated string! It is a hash where * each item in it represents if a mode is set. For example * for mode +A, index 0. Use modechar-65 to calculate which * field to check. */ char modes[64]; /** User lists. * There are four user lists, one for * all the users, one for the ops, one for * the halfops and another for the voices. */ CUList internal_userlist; /** Opped users. * There are four user lists, one for * all the users, one for the ops, one for * the halfops and another for the voices. */ CUList internal_op_userlist; /** Halfopped