summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam- <Adam-@5417fbe8-f217-4b02-8779-1006273d7864>2009-10-13 21:26:38 +0000
committerAdam- <Adam-@5417fbe8-f217-4b02-8779-1006273d7864>2009-10-13 21:26:38 +0000
commitd3d64c27b199622c90075d6f59dd08e44acbb378 (patch)
tree68029e10dc754271235e2a4e3d04b3fb19ddd15c
parent1fd66851320e239b531720c27614a5ad4c604c97 (diff)
Complete rewrite of everything associated with modes, this breaks saving and reading mlocked modes from the databases until the new databases are implemented
git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@2560 5417fbe8-f217-4b02-8779-1006273d7864
-rw-r--r--include/extern.h57
-rw-r--r--include/modules.h7
-rw-r--r--include/regchannel.h131
-rw-r--r--include/services.h587
-rw-r--r--include/users.h29
-rw-r--r--lang/cat.l4
-rw-r--r--lang/de.l5
-rw-r--r--lang/en_us.l4
-rw-r--r--lang/es.l4
-rw-r--r--lang/fr.l4
-rw-r--r--lang/gr.l4
-rw-r--r--lang/hun.l4
-rw-r--r--lang/it.l4
-rw-r--r--lang/nl.l4
-rw-r--r--lang/pl.l6
-rw-r--r--lang/pt.l4
-rw-r--r--lang/ru.l4
-rw-r--r--lang/tr.l4
-rw-r--r--src/Makefile3
-rw-r--r--src/botserv.c26
-rw-r--r--src/channels.c927
-rw-r--r--src/chanserv.c584
-rw-r--r--src/core/cs_access.c2
-rw-r--r--src/core/cs_akick.c3
-rw-r--r--src/core/cs_ban.c4
-rw-r--r--src/core/cs_clear.c111
-rw-r--r--src/core/cs_drop.c4
-rw-r--r--src/core/cs_forbid.c21
-rw-r--r--src/core/cs_getkey.c5
-rw-r--r--src/core/cs_info.c7
-rw-r--r--src/core/cs_modes.c138
-rw-r--r--src/core/cs_register.c11
-rw-r--r--src/core/cs_set.c100
-rw-r--r--src/core/cs_xop.c4
-rw-r--r--src/core/os_chanlist.c29
-rw-r--r--src/core/os_clearmodes.c107
-rw-r--r--src/core/os_userlist.c27
-rw-r--r--src/ircd.c127
-rw-r--r--src/modes.cpp364
-rw-r--r--src/modules.c58
-rw-r--r--src/modules/cs_enforce.c9
-rw-r--r--src/modules/cs_tban.c4
-rw-r--r--src/nickserv.c4
-rw-r--r--src/operserv.c83
-rw-r--r--src/protocol/bahamut.c411
-rw-r--r--src/protocol/inspircd11.c423
-rw-r--r--src/protocol/inspircd12.cpp406
-rw-r--r--src/protocol/ratbox.c379
-rw-r--r--src/protocol/unreal32.c533
-rw-r--r--src/users.c82
50 files changed, 2487 insertions, 3375 deletions
diff --git a/include/extern.h b/include/extern.h
index 8a767ba39..6faae04c7 100644
--- a/include/extern.h
+++ b/include/extern.h
@@ -29,15 +29,7 @@ E char *uplink;
E IRCDVar *ircd;
E IRCDCAPAB *ircdcap;
-E char *flood_mode_char_set;
-E char *flood_mode_char_remove;
E int UseTSMODE; /* hack to get around bahamut clones that don't send TSMODE */
-EI unsigned long umodes[128];
-E char csmodes[128];
-E CMMode cmmodes[128];
-E CBMode cbmodes[128];
-E CBModeInfo *cbmodeinfos;
-E CUMode cumodes[128];
E char *IRCDModule;
E IRCDProto *ircdproto;
@@ -79,27 +71,11 @@ E void bot_raw_mode(User * requester, ChannelInfo * ci, const char *mode, char *
E Channel *chanlist[1024];
-E void add_ban(Channel * chan, const char *mask);
E void chan_adduser2(User * user, Channel * c);
-E void add_invite(Channel * chan, const char *mask);
E void chan_delete(Channel * c);
-E void del_ban(Channel * chan, const char *mask);
-E void chan_set_key(Channel * chan, const char *value);
-E void set_limit(Channel * chan, const char *value);
-E void del_invite(Channel * chan, const char *mask);
-E char *get_key(Channel * chan);
-E char *get_limit(Channel * chan);
E Channel *chan_create(const char *chan, time_t ts);
E Channel *join_user_update(User * user, Channel * chan, const char *name, time_t chants);
-E void add_exception(Channel * chan, const char *mask);
-E void del_exception(Channel * chan, const char *mask);
-E char *get_flood(Channel * chan);
-E void set_flood(Channel * chan, const char *value);
-E char *get_redirect(Channel * chan);
-E void set_redirect(Channel * chan, const char *value);
-
-
E void get_channel_stats(long *nrec, long *memuse);
E Channel *findchan(const char *chan);
E Channel *firstchan();
@@ -151,7 +127,6 @@ E long get_memuse(EList *list);
/**** chanserv.c ****/
E ChannelInfo *chanlists[256];
-E CSModeUtil csmodeutils[];
E LevelInfo levelinfo[];
E void get_chanserv_stats(long *nrec, long *memuse);
@@ -190,14 +165,6 @@ E int get_idealban(ChannelInfo * ci, User * u, char *ret, int retlen);
E AutoKick *is_stuck(ChannelInfo * ci, const char *mask);
E void stick_mask(ChannelInfo * ci, AutoKick * akick);
E void stick_all(ChannelInfo * ci);
-E char *cs_get_flood(ChannelInfo * ci);
-E void cs_set_flood(ChannelInfo * ci, const char *value);
-E char *cs_get_key(ChannelInfo * ci);
-E void cs_set_key(ChannelInfo * ci, const char *value);
-E char *cs_get_limit(ChannelInfo * ci);
-E void cs_set_limit(ChannelInfo * ci, const char *value);
-E char *cs_get_redirect(ChannelInfo * ci);
-E void cs_set_redirect(ChannelInfo * ci, const char *value);
E int levelinfo_maxwidth;
E ChannelInfo *makechan(const char *chan);
@@ -481,29 +448,7 @@ E void pmodule_ircd_proto(IRCDProto *);
E void pmodule_ircd_var(IRCDVar * ircdvar);
E void pmodule_ircd_cap(IRCDCAPAB * cap);
E void pmodule_ircd_version(const char *version);
-E void pmodule_ircd_cbmodeinfos(CBModeInfo * modeinfos);
-E void pmodule_ircd_cumodes(CUMode modes[128]);
-E void pmodule_ircd_flood_mode_char_set(const char *mode);
-E void pmodule_ircd_flood_mode_char_remove(const char *mode);
-E void pmodule_ircd_cbmodes(CBMode modes[128]);
-E void pmodule_ircd_cmmodes(CMMode modes[128]);
-E void pmodule_ircd_csmodes(char mode[128]);
E void pmodule_ircd_useTSMode(int use);
-E void pmodule_invis_umode(int mode);
-E void pmodule_oper_umode(int mode);
-E void pmodule_invite_cmode(int mode);
-E void pmodule_secret_cmode(int mode);
-E void pmodule_private_cmode(int mode);
-E void pmodule_key_mode(int mode);
-E void pmodule_limit_mode(int mode);
-
-E int anope_get_secret_mode();
-E int anope_get_invite_mode();
-E int anope_get_key_mode();
-E int anope_get_limit_mode();
-E int anope_get_private_mode();
-E int anope_get_invis_mode();
-E int anope_get_oper_mode();
/**** language.c ****/
@@ -735,8 +680,6 @@ E void SetOperType(NickCore *nc);
E SList akills, sglines, sqlines, szlines;
E int DefConModesSet;
-E uint32 DefConModesOn;
-E uint32 DefConModesOff;
E ChannelInfo DefConModesCI;
E void operserv(User *u, char *buf);
diff --git a/include/modules.h b/include/modules.h
index aea9011f7..15b650d72 100644
--- a/include/modules.h
+++ b/include/modules.h
@@ -1112,13 +1112,6 @@ int destroyMessage(Message *m); /* destroy a Message*/
MDE bool moduleMinVersion(int major,int minor,int patch,int build); /* Checks if the current version of anope is before or after a given verison */
-/*************************************************************************/
-/* Some IRCD protocol module support functions */
-
-/** Update the protect deatials, could be either protect or admin etc.. */
-MDE void updateProtectDetails(const char *level_info_protect_word, const char *level_info_protectme_word, const char *fant_protect_add, const char *fant_protect_del, const char *level_protect_word, const char *protect_set_mode, const char *protect_unset_mode);
-MDE void updateOwnerDetails(const char *fant_owner_add, const char *fant_owner_del, const char *owner_set_mode, const char *owner_del_mode);
-
/************************************************************************/
#endif
diff --git a/include/regchannel.h b/include/regchannel.h
index e3f9cd7fc..247371f05 100644
--- a/include/regchannel.h
+++ b/include/regchannel.h
@@ -9,8 +9,13 @@
*
*/
+#include "services.h"
+
class CoreExport ChannelInfo : public Extensible
{
+ private:
+ std::map<ChannelModeName, std::string> Params;
+
public:
ChannelInfo()
{
@@ -23,8 +28,7 @@ class CoreExport ChannelInfo : public Extensible
bantype = akickcount = 0;
levels = NULL;
akick = NULL;
- mlock_on = mlock_off = mlock_limit = 0;
- mlock_key = mlock_flood = mlock_redirect = entry_message = NULL;
+ entry_message = NULL;
c = NULL;
bi = NULL;
botflags = 0;
@@ -63,17 +67,14 @@ class CoreExport ChannelInfo : public Extensible
uint16 akickcount;
AutoKick *akick; /* List of users to kickban */
- uint32 mlock_on, mlock_off; /* See channel modes below */
- uint32 mlock_limit; /* 0 if no limit */
- char *mlock_key; /* NULL if no key */
- char *mlock_flood; /* NULL if no +f */
- char *mlock_redirect; /* NULL if no +L */
+ std::bitset<128> mlock_on;
+ std::bitset<128> mlock_off;
char *entry_message; /* Notice sent on entering channel */
MemoInfo memos;
- struct channel_ *c; /* Pointer to channel record (if *
+ Channel *c; /* Pointer to channel record (if *
* channel is currently in use) */
/* For BotServ */
@@ -175,4 +176,118 @@ class CoreExport ChannelInfo : public Extensible
while (access.begin() != access.end())
EraseAccess(0);
}
+
+ /** Check if a mode is mlocked
+ * @param Name The mode
+ * @param status True to check mlock on, false for mlock off
+ * @return true on success, false on fail
+ */
+ const bool HasMLock(ChannelModeName Name, bool status)
+ {
+ if (status)
+ return mlock_on[(size_t)Name];
+ else
+ return mlock_off[(size_t)Name];
+ }
+
+ /** Set a mlock
+ * @param Name The mode
+ * @param status True for mlock on, false for mlock off
+ */
+ void SetMLock(ChannelModeName Name, bool status)
+ {
+ size_t value = (size_t)Name;
+
+ if (status)
+ mlock_on[value] = true;
+ else
+ mlock_off[value] = true;
+ }
+
+ /** Remove a mlock
+ * @param Name The mode
+ * @param status True for mlock on, false for mlock off
+ */
+ void RemoveMLock(ChannelModeName Name, bool status)
+ {
+ size_t value = (size_t)Name;
+
+ if (status)
+ mlock_on[value] = false;
+ else
+ mlock_off[value] = false;
+ }
+
+ /** Clear all mlocks on the channel
+ */
+ void ClearMLock()
+ {
+ mlock_on.reset();
+ mlock_off.reset();
+ }
+
+ /** Set a channel mode param on the channel
+ * @param Name The mode
+ * @param param The param
+ * @param true on success
+ */
+ bool SetParam(ChannelModeName Name, std::string Value)
+ {
+ return Params.insert(std::make_pair(Name, Value)).second;
+ }
+
+ /** Unset a param from the channel
+ * @param Name The mode
+ */
+ void UnsetParam(ChannelModeName Name)
+ {
+ std::map<ChannelModeName, std::string>::iterator it = Params.find(Name);
+
+ if (it != Params.end())
+ {
+ Params.erase(it);
+ }
+ }
+
+ /** Get a param from the channel
+ * @param Name The mode
+ * @param Target a string to put the param into
+ * @return true on success
+ */
+ const bool GetParam(ChannelModeName Name, std::string *Target)
+ {
+ std::map<ChannelModeName, std::string>::iterator it = Params.find(Name);
+
+ (*Target).clear();
+
+ if (it != Params.end())
+ {
+ *Target = it->second;
+ return true;
+ }
+
+ return false;
+ }
+
+ /** Check if a mode is set and has a param
+ * @param Name The mode
+ */
+ const bool HasParam(ChannelModeName Name)
+ {
+ std::map<ChannelModeName, std::string>::iterator it = Params.find(Name);
+
+ if (it != Params.end())
+ {
+ return true;
+ }
+
+ return false;
+ }
+
+ /** Clear all the params from the channel
+ */
+ void ClearParams()
+ {
+ Params.clear();
+ }
};
diff --git a/include/services.h b/include/services.h
index 758c766e3..f320d8cc6 100644
--- a/include/services.h
+++ b/include/services.h
@@ -237,6 +237,7 @@ extern int strncasecmp(const char *, const char *, size_t);
#include <list>
#include <vector>
#include <deque>
+#include <bitset>
/** This class can be used on its own to represent an exception, or derived to represent a module-specific exception.
* When a module whishes to abort, e.g. within a constructor, it should throw an exception using ModuleException or
@@ -422,10 +423,9 @@ class CoreExport Extensible
/* forward declarations, mostly used by older code */
class User;
class ChannelInfo;
-
+class Channel;
typedef struct server_ Server;
-typedef struct channel_ Channel;
typedef struct c_elist EList;
typedef struct c_elist_entry Entry;
typedef struct memo_ Memo;
@@ -438,14 +438,43 @@ typedef struct sxline_ SXLine;
typedef struct hostcore_ HostCore;
typedef struct newsitem_ NewsItem;
typedef struct exception_ Exception;
-typedef struct cbmode_ CBMode;
-typedef struct cbmodeinfo_ CBModeInfo;
-typedef struct cmmode_ CMMode;
-typedef struct csmode_ CSMode;
-typedef struct cumode_ CUMode;
-typedef struct csmodeutil_ CSModeUtil;
typedef struct session_ Session;
+enum UserModeName
+{
+ UMODE_BEGIN,
+
+ /* Usermodes */
+ UMODE_SERV_ADMIN, UMODE_BOT, UMODE_CO_ADMIN, UMODE_FILTER, UMODE_HIDEOPER, UMODE_NETADMIN,
+ UMODE_REGPRIV, UMODE_PROTECTED, UMODE_NO_CTCP, UMODE_WEBTV, UMODE_WHOIS, UMODE_ADMIN, UMODE_DEAF,
+ UMODE_GLOBOPS, UMODE_HELPOP, UMODE_INVIS, UMODE_OPER, UMODE_PRIV, UMODE_GOD, UMODE_REGISTERED,
+ UMODE_SNOMASK, UMODE_VHOST, UMODE_WALLOPS, UMODE_CLOAK, UMODE_SSL, UMODE_CALLERID,
+
+ UMODE_END
+};
+
+enum ChannelModeName
+{
+ CMODE_BEGIN,
+
+ /* Channel modes */
+ CMODE_BLOCKCOLOR, CMODE_FLOOD, CMODE_INVITE, CMODE_KEY, CMODE_LIMIT, CMODE_MODERATED, CMODE_NOEXTERNAL,
+ CMODE_PRIVATE, CMODE_REGISTERED, CMODE_SECRET, CMODE_TOPIC, CMODE_AUDITORIUM, CMODE_SSL, CMODE_ADMINONLY,
+ CMODE_NOCTCP, CMODE_FILTER, CMODE_NOKNOCK, CMODE_REDIRECT, CMODE_REGMODERATED, CMODE_NONICK, CMODE_OPERONLY,
+ CMODE_NOKICK, CMODE_REGISTEREDONLY, CMODE_STRIPCOLOR, CMODE_NONOTICE, CMODE_NOINVITE, CMODE_ALLINVITE,
+ CMODE_BLOCKCAPS, CMODE_PERM,
+
+ /* b/e/I */
+ CMODE_BAN, CMODE_EXCEPT,
+ CMODE_INVITEOVERRIDE,
+
+ /* v/h/o/a/q */
+ CMODE_VOICE, CMODE_HALFOP, CMODE_OP,
+ CMODE_PROTECT, CMODE_OWNER,
+
+ CMODE_END
+};
+
#include "bots.h"
#include "opertype.h"
@@ -460,35 +489,22 @@ struct ircdvars_ {
const char *name; /* Name of the IRCd command */
const char *pseudoclient_mode; /* Mode used by BotServ Bots */
int max_symbols; /* Chan Max Symbols */
- const char *modestoremove; /* Channel Modes to remove */
const char *botchanumode; /* Modes set when botserv joins a channel */
int svsnick; /* Supports SVSNICK */
int vhost; /* Supports vhost */
- int owner; /* Supports Owner */
- const char *ownerset; /* Mode to set for owner */
- const char *ownerunset; /* Mode to unset for a owner */
- const char *adminset; /* Mode to set for admin */
- const char *adminunset; /* Mode to unset for admin */
const char *modeonunreg; /* Mode on Unregister */
int sgline; /* Supports SGline */
int sqline; /* Supports SQline */
int szline; /* Supports SZline */
- int halfop; /* Supports HalfOp */
int numservargs; /* Number of Server Args */
int join2set; /* Join 2 Set Modes */
int join2msg; /* Join 2 Message */
- int except; /* exception +e */
int topictsforward; /* TS on Topics Forward */
int topictsbackward; /* TS on Topics Backward */
- uint32 protectedumode; /* What is the Protected Umode */
- int admin; /* Has Admin */
int chansqline; /* Supports Channel Sqlines */
int quitonkill; /* IRCD sends QUIT when kill */
int svsmode_unban; /* svsmode can be used to unban */
- int protect; /* Has protect modes */
int reversekickcheck; /* Can reverse ban check */
- int chanreg; /* channel mode +r for register */
- uint32 regmode; /* Mode to use for +r */
int vident; /* Supports vidents */
int svshold; /* Supports svshold */
int tsonmode; /* Timestamp on mode changes */
@@ -497,28 +513,18 @@ struct ircdvars_ {
int umode; /* change user modes */
int nickvhost; /* Users vhost sent during NICK */
int chgreal; /* Change RealName */
- uint32 noknock; /* Channel Mode for no knock */
- uint32 adminmode; /* Admin Only Channel Mode */
- uint32 defmlock; /* Default mlock modes */
- uint32 vhostmode; /* Vhost mode */
- int fmode; /* +f */
- int Lmode; /* +L */
- uint32 chan_fmode; /* Mode */
- uint32 chan_lmode; /* Mode */
+ std::bitset<128> DefMLock; /* Default mlock modes */
int check_nick_id; /* On nick change check if they could be identified */
int knock_needs_i; /* Check if we needed +i when setting NOKNOCK */
char *chanmodes; /* If the ircd sends CHANMODE in CAPAB this is where we store it */
int token; /* Does Anope support the tokens for the ircd */
int sjb64; /* Base 64 encode TIMESTAMP */
- int invitemode; /* +I */
int sjoinbanchar; /* use single quotes to define it */
int sjoinexchar; /* use single quotes to define it */
int sjoininvchar; /* use single quotes to define it */
int svsmode_ucmode; /* Can remove User Channel Modes with SVSMODE */
int sglineenforce;
- const char *vhostchar; /* char used for vhosting */
int ts6; /* ircd is TS6 */
- int supporthelper; /* +h helper umodes */
int p10; /* ircd is P10 */
char *nickchars; /* character set */
int cidrchanbei; /* channel bans/excepts/invites support CIDR (syntax: +b *!*@192.168.0.0/15)
@@ -595,7 +601,6 @@ typedef struct {
} MemoInfo;
-
/*************************************************************************/
// For NickServ
@@ -784,17 +789,6 @@ struct badword_ {
/*************************************************************************/
-/* ChanServ mode utilities commands */
-
-struct csmodeutil_ {
- const char *name; /* Name of the ChanServ command */
- const char *bsname; /* Name of the BotServ fantasy command */
- const char *mode; /* Mode (ie. +o) */
- int32 notice; /* Notice flag (for the damn OPNOTICE) */
- int level; /* Level required to use the command */
- int levelself; /* Level required to use the command for himself */
-};
-
typedef struct {
int what;
const char *name;
@@ -830,47 +824,17 @@ struct server_ {
#define SERVER_ISUPLINK 0x0004
/*************************************************************************/
-#include "users.h"
-
-
-struct cbmode_ {
- uint32 flag; /* Long value that represents the mode */
- uint16 flags; /* Flags applying to this mode (CBM_* below) */
-
- /* Function to associate a value with the mode */
- void (*setvalue) (Channel *chan, const char *value);
- void (*cssetvalue) (ChannelInfo *ci, const char *value);
-};
-
-#define CBM_MINUS_NO_ARG 0x0001 /* No argument for unset */
-#define CBM_NO_MLOCK 0x0002 /* Can't be MLOCKed */
-#define CBM_NO_USER_MLOCK 0x0004 /* Can't be MLOCKed by non-opers */
-
-struct cbmodeinfo_ {
- char mode; /* The mode */
- uint32 flag; /* Long value that represents the mode */
- uint16 flags; /* CBM_* above */
- /* Function to retrieve the value associated to the mode (optional) */
- char * (*getvalue) (Channel *chan);
- char * (*csgetvalue) (ChannelInfo *ci);
-};
-
-struct cmmode_ {
- void (*addmask) (Channel *chan, const char *mask);
- void (*delmask) (Channel *chan, const char *mask);
-};
-
-struct cumode_ {
- int16 status; /* CUS_* below */
- int16 flags; /* CUF_* below */
-
- int (*is_valid) (User *user, Channel *chan, int servermode);
-};
+#define CUS_OP 0x0001
+#define CUS_VOICE 0x0002
+#define CUS_HALFOP 0x0004 /* Halfop (+h) */
+#define CUS_OWNER 0x0008 /* Owner/Founder (+q) */
+#define CUS_PROTECT 0x0010 /* Protected users (+a) */
+/* #define CUS_DEOPPED 0x0080 */ /* Removed due to IRCd checking it */
-/* Channel user mode flags */
+/*************************************************************************/
-#define CUF_PROTECT_BOTSERV 0x0001
+#include "users.h"
/* This structure stocks ban data since it must not be removed when
* user is kicked.
@@ -918,7 +882,21 @@ struct c_userlist {
UserData *ud;
};
-struct channel_ {
+class CoreExport Channel
+{
+ private:
+ /** A map of channel modes with their parameters set on this channel
+ */
+ std::map<ChannelModeName, std::string> Params;
+
+ public:
+ Channel() { }
+
+ ~Channel()
+ {
+ Params.clear();
+ }
+
Channel *next, *prev;
char name[CHANMAX];
ChannelInfo *ci; /* Corresponding ChannelInfo */
@@ -926,11 +904,8 @@ struct channel_ {
char *topic;
char topic_setter[NICKMAX]; /* Who set the topic */
time_t topic_time; /* When topic was set */
- uint32 mode; /* Binary modes only */
- uint32 limit; /* 0 if none */
- char *key; /* NULL if none */
- char *redirect; /* +L; NULL if none */
- char *flood; /* +f; NULL if none */
+ std::bitset<128> modes;
+
EList *bans;
EList *excepts;
EList *invites;
@@ -946,6 +921,81 @@ struct channel_ {
int16 chanserv_modecount; /* Number of check_mode()'s this sec */
int16 bouncy_modes; /* Did we fail to set modes here? */
int16 topic_sync; /* Is the topic in sync? */
+
+ /**
+ * See if a channel has a mode
+ * @param Name The mode name
+ * @return true or false
+ */
+ bool HasMode(ChannelModeName Name);
+
+ /**
+ * Set a mode on a channel
+ * @param Name The mode name
+ */
+ void SetMode(ChannelModeName Name);
+
+ /**
+ * Set a mode on a channel
+ * @param Mode The mode
+ */
+ void SetMode(char Mode);
+
+ /**
+ * Remove a mode from a channel
+ * @param Name The mode name
+ */
+ void RemoveMode(ChannelModeName Name);
+
+ /**
+ * Remove a mode from a channel
+ * @param Mode The mode
+ */
+ void RemoveMode(char Mode);
+
+ /** Clear all the modes from the channel
+ * @param client The client unsetting the modes
+ */
+ void ClearModes(char *client = NULL);
+
+ /** Clear all the bans from the channel
+ * @param client The client unsetting the modes
+ */
+ void ClearBans(char *client = NULL);
+
+ /** Clear all the excepts from the channel
+ * @param client The client unsetting the modes
+ */
+ void ClearExcepts(char *client = NULL);
+
+ /** Clear all the invites from the channel
+ * @param client The client unsetting the modes
+ */
+ void ClearInvites(char *client = NULL);
+
+ /** Set a channel mode param on the channel
+ * @param Name The mode
+ * @param param The param
+ * @param true on success
+ */
+ bool SetParam(ChannelModeName Name, std::string &param);
+
+ /** Unset a param from the channel
+ * @param Name The mode
+ */
+ void UnsetParam(ChannelModeName Name);
+
+ /** Get a param from the channel
+ * @param Name The mode
+ * @param Target a string to put the param into
+ * @return true on success
+ */
+ const bool GetParam(ChannelModeName Name, std::string *Target);
+
+ /** Check if a mode is set and has a param
+ * @param Name The mode
+ */
+ const bool HasParam(ChannelModeName Name);
};
struct c_elist {
@@ -1057,6 +1107,335 @@ struct exception_ {
/*************************************************************************/
+/** The different types of modes
+*/
+enum ModeType
+{
+ /* Regular mode */
+ MODE_REGULAR,
+ /* b/e/I */
+ MODE_LIST,
+ /* k/l etc */
+ MODE_PARAM,
+ /* v/h/o/a/q */
+ MODE_STATUS
+};
+
+/** This class is a user mode, all user modes use this/inherit from this
+ */
+class UserMode
+{
+ public:
+
+ /* Mode name */
+ UserModeName Name;
+ /* The mode char */
+ char ModeChar;
+
+ /** Default constructor
+ * @param nName The mode name
+ * @param mMode A value representing the mode
+ */
+ UserMode(UserModeName mName)
+ {
+ this->Name = mName;
+ }
+
+ /** Default destructor
+ */
+ virtual ~UserMode() { }
+};
+
+/** This class is a channel mode, all channel modes use this/inherit from this
+ */
+class ChannelMode
+{
+ public:
+
+ /* Mode name */
+ ChannelModeName Name;
+ /* Type of mode this is */
+ ModeType Type;
+ /* The mode char */
+ char ModeChar;
+
+ /** Default constructor
+ * @param mName The mode name
+ * @param mMode A value representing the mode
+ */
+ ChannelMode(ChannelModeName mName)
+ {
+ this->Name = mName;
+ this->Type = MODE_REGULAR;
+ }
+
+ /** Default destructor
+ */
+ virtual ~ChannelMode() { }
+
+ /** Can a user set this mode, used for mlock
+ * NOTE: User CAN be NULL, this is for checking if it can be locked with defcon
+ * @param u The user, or NULL
+ */
+ virtual bool CanSet(User *u) { return true; }
+};
+
+/** This is a mode for lists, eg b/e/I. These modes should inherit from this
+ */
+class ChannelModeList : public ChannelMode
+{
+ public:
+
+ /** Default constructor
+ * @param mName The mode name
+ */
+ ChannelModeList(ChannelModeName mName) : ChannelMode(mName)
+ {
+ this->Type = MODE_LIST;
+ }
+
+ /** Default destructor
+ */
+ virtual ~ChannelModeList() { }
+
+ /** Is the mask valid
+ * @param mask The mask
+ * @return true for yes, false for no
+ */
+ virtual bool IsValid(const char *mask) { return true; }
+
+ /** Add the mask to the channel, this should be overridden
+ * @param chan The channel
+ * @param mask The mask
+ */
+ virtual void AddMask(Channel *chan, const char *mask) { }
+
+ /** Delete the mask from the