diff options
| author | Adam <Adam@anope.org> | 2013-01-21 22:31:16 -0500 |
|---|---|---|
| committer | Adam <Adam@anope.org> | 2013-01-21 22:31:16 -0500 |
| commit | ddaa001dafb5122e6e363e4acbbe6ce045b7b104 (patch) | |
| tree | 0364a76606ac6e2881ebd663601ce260f7c1101e /include | |
| parent | 51c049e1a738e9124bab3961f35b830906517421 (diff) | |
Merge usefulness of Flags and Extensible classes into Extensible, made most flags we have juse strings instead of defines/enums
Diffstat (limited to 'include')
| -rw-r--r-- | include/account.h | 102 | ||||
| -rw-r--r-- | include/anope.h | 110 | ||||
| -rw-r--r-- | include/bots.h | 20 | ||||
| -rw-r--r-- | include/channels.h | 19 | ||||
| -rw-r--r-- | include/commands.h | 24 | ||||
| -rw-r--r-- | include/config.h | 6 | ||||
| -rw-r--r-- | include/extensible.h | 85 | ||||
| -rw-r--r-- | include/memo.h | 14 | ||||
| -rw-r--r-- | include/modes.h | 113 | ||||
| -rw-r--r-- | include/modules.h | 8 | ||||
| -rw-r--r-- | include/protocol.h | 20 | ||||
| -rw-r--r-- | include/regchannel.h | 142 | ||||
| -rw-r--r-- | include/serialize.h | 1 | ||||
| -rw-r--r-- | include/servers.h | 32 | ||||
| -rw-r--r-- | include/sockets.h | 9 | ||||
| -rw-r--r-- | include/users.h | 14 |
16 files changed, 206 insertions, 513 deletions
diff --git a/include/account.h b/include/account.h index a44bd22d4..c3d5800b4 100644 --- a/include/account.h +++ b/include/account.h @@ -25,79 +25,19 @@ typedef Anope::hash_map<NickCore *> nickcore_map; extern CoreExport Serialize::Checker<nickalias_map> NickAliasList; extern CoreExport Serialize::Checker<nickcore_map> NickCoreList; -/** Flags set on NickAliases - */ -enum NickNameFlag -{ - NS_BEGIN, - - /* Nick never expires */ - NS_NO_EXPIRE, - /* This nick is being held after a kill by an enforcer client - * or is being SVSHeld. Used by ns_release to determin if something - * should be allowed to be released - */ - NS_HELD, - /* We are taking over this nick, either by SVSNICK or KILL. - * We are waiting for the confirmation of either of these actions to - * proceed. This is checked in NickAlias::OnCancel - */ - NS_COLLIDED, - - NS_END -}; - -/** Flags set on NickCores - */ -enum NickCoreFlag -{ - NI_BEGIN, - - /* Kill others who take this nick */ - NI_KILLPROTECT, - /* Dont recognize unless IDENTIFIED */ - NI_SECURE, - /* Use PRIVMSG instead of NOTICE */ - NI_MSG, - /* Don't allow user to change memo limit */ - NI_MEMO_HARDMAX, - /* Notify of memos at signon and un-away */ - NI_MEMO_SIGNON, - /* Notify of new memos when sent */ - NI_MEMO_RECEIVE, - /* Don't show in LIST to non-servadmins */ - NI_PRIVATE, - /* Don't show email in INFO */ - NI_HIDE_EMAIL, - /* Don't show last seen address in INFO */ - NI_HIDE_MASK, - /* Don't show last quit message in INFO */ - NI_HIDE_QUIT, - /* Kill in 20 seconds instead of in 60 */ - NI_KILL_QUICK, - /* Kill immediatly */ - NI_KILL_IMMED, - /* User gets email on memo */ - NI_MEMO_MAIL, - /* Don't show services access status */ - NI_HIDE_STATUS, - /* Nickname is suspended */ - NI_SUSPENDED, - /* Autoop nickname in channels */ - NI_AUTOOP, - /* If set means the nick core does not have their email addrses confirmed. - */ - NI_UNCONFIRMED, - /* Chanstats are enabled for this user */ - NI_STATS, - - NI_END -}; - /* A registered nickname. * It matters that Base is here before Extensible (it is inherited by Serializable) + * + * Possible flags: + * NO_EXPIRE - Nick never expires + * HELD - This nick is being held after a kill by an enforcer client + * or is being SVSHeld. + * COLLIDED - We are taking over this nick, either by SVSNICK or KILL + * and are waiting for the confirmation of either of these actions to + * proceed. This is checked in NickAlias::OnCancel + * */ -class CoreExport NickAlias : public Serializable, public Extensible, public Flags<NickNameFlag> +class CoreExport NickAlias : public Serializable, public Extensible { Anope::string vhost_ident, vhost_host, vhost_creator; time_t vhost_created; @@ -184,8 +124,28 @@ class CoreExport NickAlias : public Serializable, public Extensible, public Flag /* A registered account. Each account must have a NickAlias with the same nick as the * account's display. * It matters that Base is here before Extensible (it is inherited by Serializable) + * + * Possible flags: + * KILLPROTECT - Kill other users who try to take this nick + * SECURE - Don't recognize unless identified + * MSG - Use PRIVMSG instead of notice + * MEMO_HARDMAX - Don't allow user to change memo limit + * MEMO_SIGNON - Notify of memos at signon and unaway + * MEMO_RECEIEVE - Notify of new memos when sent + * PRIVATE - Don't show in LIST to non-servadmins + * HIDE_EMAIL - Don't show email in INFO + * HIDE_MASK - Don't show last seen address in INFO + * HIDE_QUIT - Don't show last quit message in INFO + * KILL_QUICK - Kill quicker + * KILL_IMMED - Kill immediately + * MEMO_MAIL - User gets email on memo + * HIDE_STATUS - Don't show services access status + * SUSPEND - Nickname is suspended + * AUTOOP - Autoop nickname in channels + * UNCONFIRMED - Account has not had email address confirmed + * STATS - ChanStats is enabled for this user */ -class CoreExport NickCore : public Serializable, public Extensible, public Flags<NickCoreFlag> +class CoreExport NickCore : public Serializable, public Extensible { public: /* Name of the account. Find(display)->nc == this. */ diff --git a/include/anope.h b/include/anope.h index 74f410e5d..1b978a8ba 100644 --- a/include/anope.h +++ b/include/anope.h @@ -762,114 +762,4 @@ template<typename T, typename O> inline T anope_dynamic_static_cast(O ptr) #endif } -/*************************************************************************/ - -/** Class with the ability to keep flags on items, they should extend from this - * where T is an enum. - */ -template<typename T> class Flags -{ - std::vector<bool> flags_values; - static const Anope::string *flags_strings; - - public: - /** Add a flag to this item - * @param value The flag - */ - void SetFlag(T value) - { - if (value < 0) - return; - - if (static_cast<unsigned>(value) >= flags_values.size()) - flags_values.resize(value + 1); - flags_values[value] = true; - } - - /** Remove a flag from this item - * @param value The flag - */ - void UnsetFlag(T value) - { - if (value >= 0 && static_cast<unsigned>(value) < flags_values.size()) - flags_values[value] = false; - } - - /** Check if this item has a flag - * @param value The flag - * @return true or false - */ - bool HasFlag(T value) const - { - if (value >= 0 && static_cast<unsigned>(value) < flags_values.size()) - return flags_values[value]; - return false; - } - - /** Check how many flags are set - * @return The number of flags set - */ - size_t FlagCount() const - { - size_t c = 0; - for (unsigned i = 0; i < flags_values.size(); ++i) - if (flags_values[i]) - ++c; - return c; - } - - /** Unset all of the flags - */ - void ClearFlags() - { - flags_values.clear(); - } - - static const Anope::string* GetFlagStrings() - { - return flags_strings; - } - - Anope::string ToString() const - { - std::vector<Anope::string> v = ToVector(); - Anope::string flag_buf; - for (unsigned i = 0; i < v.size(); ++i) - flag_buf += v[i] + " "; - flag_buf.trim(); - return flag_buf; - } - - void FromString(const Anope::string &str) - { - spacesepstream sep(str); - Anope::string buf; - std::vector<Anope::string> v; - - while (sep.GetToken(buf)) - v.push_back(buf); - - FromVector(v); - } - - std::vector<Anope::string> ToVector() const - { - std::vector<Anope::string> ret; - for (unsigned i = 0; this->flags_strings && !this->flags_strings[i].empty(); ++i) - if (this->HasFlag(static_cast<T>(i))) - ret.push_back(this->flags_strings[i]); - return ret; - } - - void FromVector(const std::vector<Anope::string> &strings) - { - this->ClearFlags(); - - for (unsigned i = 0; this->flags_strings && !this->flags_strings[i].empty(); ++i) - for (unsigned j = 0; j < strings.size(); ++j) - if (this->flags_strings[i] == strings[j]) - this->SetFlag(static_cast<T>(i)); - } -}; - #endif // ANOPE_H diff --git a/include/bots.h b/include/bots.h index afffc7689..3b42424bd 100644 --- a/include/bots.h +++ b/include/bots.h @@ -20,22 +20,8 @@ typedef Anope::map<BotInfo *> botinfo_map; extern CoreExport Serialize::Checker<botinfo_map> BotListByNick, BotListByUID; -/** Flags settable on a bot - */ -enum BotFlag -{ - BI_BEGIN, - - /* This bot can only be assigned by IRCops */ - BI_PRIVATE, - /* This bot is defined in the config */ - BI_CONF, - - BI_END -}; - /* A service bot (NickServ, ChanServ, a BotServ bot, etc). */ -class CoreExport BotInfo : public User, public Flags<BotFlag>, public Serializable +class CoreExport BotInfo : public User, public Serializable { public: time_t created; @@ -49,6 +35,10 @@ class CoreExport BotInfo : public User, public Flags<BotFlag>, public Serializab std::vector<Anope::string> botchannels; /* Whether or not this bot is introduced to the network */ bool introduced; + /* Bot can only be assigned by irc ops */ + bool oper_only; + /* Bot is defined in the configuration file */ + bool conf; /** Create a new bot. * @param nick The nickname to assign to the bot. diff --git a/include/channels.h b/include/channels.h index 298b39505..b66dc1c3d 100644 --- a/include/channels.h +++ b/include/channels.h @@ -40,10 +40,10 @@ enum ChannelFlag CH_SYNCING }; -class CoreExport Channel : public Base, public Extensible, public Flags<ChannelFlag> +class CoreExport Channel : public Base, public Extensible { public: - typedef std::multimap<ChannelModeName, Anope::string> ModeList; + typedef std::multimap<Anope::string, Anope::string> ModeList; private: /** A map of channel modes with their parameters set on this channel */ @@ -56,6 +56,7 @@ class CoreExport Channel : public Base, public Extensible, public Flags<ChannelF Serialize::Reference<ChannelInfo> ci; /* When the channel was created */ time_t creation_time; + std::set<ChannelFlag> flags; /* Users in the channel */ typedef std::list<ChanUserContainer *> ChanUserList; @@ -132,20 +133,20 @@ class CoreExport Channel : public Base, public Extensible, public Flags<ChannelF * @param name The mode name, eg CMODE_OP, CMODE_VOICE * @return true or false */ - bool HasUserStatus(const User *u, ChannelModeName name) const; + bool HasUserStatus(const User *u, const Anope::string &name) const; /** See if a channel has a mode * @param name The mode name * @return The number of modes set * @param param The optional mode param */ - size_t HasMode(ChannelModeName name, const Anope::string ¶m = ""); + size_t HasMode(const Anope::string &name, const Anope::string ¶m = ""); /** Get a list of modes on a channel * @param name A mode name to get the list of * @return a pair of iterators for the beginning and end of the list */ - std::pair<ModeList::iterator, ModeList::iterator> GetModeList(ChannelModeName name); + std::pair<ModeList::iterator, ModeList::iterator> GetModeList(const Anope::string &name); /** Set a mode internally on a channel, this is not sent out to the IRCd * @param setter The setter @@ -178,7 +179,7 @@ class CoreExport Channel : public Base, public Extensible, public Flags<ChannelF * @param param Optional param arg for the mode * @param enforce_mlock true if mlocks should be enforced, false to override mlock */ - void SetMode(BotInfo *bi, ChannelModeName name, const Anope::string ¶m = "", bool enforce_mlock = true); + void SetMode(BotInfo *bi, const Anope::string &name, const Anope::string ¶m = "", bool enforce_mlock = true); /** Remove a mode from a channel * @param bi The client setting the modes @@ -195,14 +196,14 @@ class CoreExport Channel : public Base, public Extensible, public Flags<ChannelF * @param param Optional param arg for the mode * @param enforce_mlock true if mlocks should be enforced, false to override mlock */ - void RemoveMode(BotInfo *bi, ChannelModeName name, const Anope::string ¶m = "", bool enforce_mlock = true); + void RemoveMode(BotInfo *bi, const Anope::string &name, const Anope::string ¶m = "", bool enforce_mlock = true); /** Get a modes parameter for the channel * @param name The mode * @param target a string to put the param into * @return true if the parameter was fetched, false if on error (mode not set) etc. */ - bool GetParam(ChannelModeName name, Anope::string &target) const; + bool GetParam(const Anope::string &name, Anope::string &target) const; /** Set a string of modes on the channel * @param bi The client setting the modes @@ -223,7 +224,7 @@ class CoreExport Channel : public Base, public Extensible, public Flags<ChannelF * @param list The mode of the list to check (eg CMODE_BAN) * @return true if the user matches the list */ - bool MatchesList(User *u, ChannelModeName list); + bool MatchesList(User *u, const Anope::string &list); /** Kick a user from a channel internally * @param source The sender of the kick diff --git a/include/commands.h b/include/commands.h index 9f7782102..207d2c444 100644 --- a/include/commands.h +++ b/include/commands.h @@ -16,15 +16,6 @@ #include "anope.h" #include "channels.h" -enum CommandFlag -{ - /* Command allow unidentified users to use it */ - CFLAG_ALLOW_UNREGISTERED, - - /* Command requires a user to execute */ - CFLAG_REQUIRE_USER -}; - struct CommandGroup { Anope::string name, description; @@ -98,10 +89,14 @@ class CoreExport CommandSource /** Every services command is a class, inheriting from Command. */ -class CoreExport Command : public Service, public Flags<CommandFlag> +class CoreExport Command : public Service { Anope::string desc; std::vector<Anope::string> syntax; + /* Allow unregistered users to use this command */ + bool allow_unregistered; + /* Command requires that a user is executing it */ + bool require_user; public: /* Maximum paramaters accepted by this command */ @@ -112,6 +107,7 @@ class CoreExport Command : public Service, public Flags<CommandFlag> /* Module which owns us */ Module *module; + protected: /** Create a new command. * @param owner The owner of the command * @param sname The command name @@ -121,6 +117,7 @@ class CoreExport Command : public Service, public Flags<CommandFlag> */ Command(Module *owner, const Anope::string &sname, size_t min_params, size_t max_params = 0); + public: virtual ~Command(); protected: @@ -130,7 +127,14 @@ class CoreExport Command : public Service, public Flags<CommandFlag> void SetSyntax(const Anope::string &s); void SendSyntax(CommandSource &); void SendSyntax(CommandSource &, const Anope::string &syntax); + + void AllowUnregistered(bool b); + void RequireUser(bool b); + public: + bool AllowUnregistered() const; + bool RequireUser() const; + /** Get the command description * @return The commands description */ diff --git a/include/config.h b/include/config.h index c69bc7b76..703f00b95 100644 --- a/include/config.h +++ b/include/config.h @@ -485,7 +485,7 @@ class CoreExport ServerConfig /* Don't allow nicks to use /ns group to regroup nicks */ bool NSNoGroupChange; /* Default flags for newly registered nicks */ - Flags<NickCoreFlag> NSDefFlags; + std::set<Anope::string> NSDefFlags; /* All languages Anope is aware about */ Anope::string Languages; /* Default language used by services */ @@ -546,7 +546,7 @@ class CoreExport ServerConfig /* Core ChanServ modules */ Anope::string ChanCoreModules; /* Default flags for newly registered channels */ - Flags<ChannelInfoFlag> CSDefFlags; + std::set<Anope::string> CSDefFlags; /* Max number of channels a user can own */ unsigned CSMaxReg; /* Time before a channel expires */ @@ -589,7 +589,7 @@ class CoreExport ServerConfig /* Core BotServ modules */ Anope::string BotCoreModules; /* Default BotServ flags */ - Flags<BotServFlag> BSDefFlags; + std::set<Anope::string> BSDefFlags; /* How long before botserv forgets a user. This is used for flood kickers etc */ time_t BSKeepData; /* Min number of users to have in the channel before the service bot joins */ diff --git a/include/extensible.h b/include/extensible.h index 75ab6f5ca..d47690da6 100644 --- a/include/extensible.h +++ b/include/extensible.h @@ -11,6 +11,7 @@ #define EXTENSIBLE_H #include "anope.h" +#include "serialize.h" /* All items added to Extensible must inherit from this. */ @@ -19,20 +20,29 @@ class CoreExport ExtensibleItem public: virtual ~ExtensibleItem() { } - /* Called when this ExtensibleItem is being deleted. This should - * clean up things (eg, delete this;) if necessary. - */ - virtual void OnDelete() { delete this; } + virtual const Anope::string *Serialize() { return NULL; } }; -/** Common class used to Extensible::Extend non-pointers from, as it doesn't delete - * itself when removed. Eg, obj->Extend(key, new ExtensibleItemClass<Anope::string>(value)); +/** Common class used to Extensible::Extend as it inherits from both ExtensibleItem + * and whatever basic object you're trying to store. + * Eg, obj->Extend(key, new ExtensibleItemClass<Anope::string>(value)); */ template<typename T> struct CoreExport ExtensibleItemClass : T, ExtensibleItem { ExtensibleItemClass(const T& t) : T(t) { } }; +/* Used to attach metadata to this object that is automatically saved + * when the object is saved (assuming the object's Serialize method + * correcly calls Extensible::ExtensibleSerialize). + */ +struct CoreExport ExtensibleMetadata : ExtensibleItemClass<Anope::string> +{ + ExtensibleMetadata(const Anope::string &t) : ExtensibleItemClass<Anope::string>(t) { } + + const Anope::string *Serialize() anope_override { return this; } +}; + /* Used to attach arbitrary objects to this object using unique keys */ class CoreExport Extensible { @@ -43,21 +53,12 @@ class CoreExport Extensible public: /** Default constructor */ - Extensible() : extension_items(NULL) { } + Extensible(); /** Destructor, deletes all of the extensible items in this object * then clears the map */ - virtual ~Extensible() - { - if (extension_items) - { - for (extensible_map::iterator it = extension_items->begin(), it_end = extension_items->end(); it != it_end; ++it) - if (it->second) - it->second->OnDelete(); - delete extension_items; - } - } + virtual ~Extensible(); /** Extend an Extensible class. * @@ -65,18 +66,11 @@ class CoreExport Extensible * @param p This parameter is a pointer to an ExtensibleItem or ExtensibleItemBase derived class * * You must provide a key to store the data as via the parameter 'key'. - * The data will be inserted into the map. If the data already exists, you may not insert it - * twice, Extensible::Extend will return false in this case. - * - * @return Returns true on success, false if otherwise + * The data will be inserted into the map. If the data already exists, it will be overwritten. */ - void Extend(const Anope::string &key, ExtensibleItem *p) - { - this->Shrink(key); - if (!extension_items) - extension_items = new extensible_map(); - (*this->extension_items)[key] = p; - } + void Extend(const Anope::string &key, ExtensibleItem *p = NULL); + + void ExtendMetadata(const Anope::string &key, const Anope::string &value = ""); /** Shrink an Extensible class. * @@ -86,25 +80,7 @@ class CoreExport Extensible * you provide a nonexistent key (case is important) then the function will return false. * @return Returns true on success. */ - bool Shrink(const Anope::string &key) - { - if (!extension_items) - return false; - - extensible_map::iterator it = this->extension_items->find(key); - if (it != this->extension_items->end()) - { - if (it->second != NULL) - it->second->OnDelete(); - /* map::size_type map::erase( const key_type& key ); - * returns the number of elements removed, std::map - * is single-associative so this should only be 0 or 1 - */ - return this->extension_items->erase(key) > 0; - } - - return false; - } + bool Shrink(const Anope::string &key); /** Get an extension item. * @@ -128,22 +104,17 @@ class CoreExport Extensible * @param key The key parameter is an arbitary string which identifies the extension data * @return True if the item was found. */ - bool HasExt(const Anope::string &key) const - { - return this->extension_items != NULL && this->extension_items->count(key) > 0; - } + bool HasExt(const Anope::string &key) const; /** Get a list of all extension items names. * @param list A deque of strings to receive the list * @return This function writes a list of all extension items stored * in this object by name into the given deque and returns void. */ - void GetExtList(std::deque<Anope::string> &list) const - { - if (extension_items) - for (extensible_map::const_iterator it = extension_items->begin(), it_end = extension_items->end(); it != it_end; ++it) - list.push_back(it->first); - } + void GetExtList(std::deque<Anope::string> &list) const; + + void ExtensibleSerialize(Serialize::Data &data) const; + void ExtensibleUnserialize(Serialize::Data &data); }; #endif // EXTENSIBLE_H diff --git a/include/memo.h b/include/memo.h index 6ea79d3c3..c8bf11f74 100644 --- a/include/memo.h +++ b/include/memo.h @@ -16,19 +16,11 @@ #include "anope.h" #include "serialize.h" -/** Memo Flags - */ -enum MemoFlag -{ - /* Memo is unread */ - MF_UNREAD, - /* Sender requests a receipt */ - MF_RECEIPT -}; - -class CoreExport Memo : public Flags<MemoFlag>, public Serializable +class CoreExport Memo : public Serializable { public: + bool unread; + bool receipt; Memo(); void Serialize(Serialize::Data &data) const anope_override; diff --git a/include/modes.h b/include/modes.h index 09d1c13e4..3aaf6d1ff 100644 --- a/include/modes.h +++ b/include/modes.h @@ -12,46 +12,6 @@ #include "anope.h" #include "base.h" -/** All of the valid user mode names - */ -enum UserModeName -{ - UMODE_BEGIN, - - UMODE_SERV_ADMIN, UMODE_BOT, UMODE_CO_ADMIN, UMODE_FILTER, UMODE_HIDEOPER, UMODE_NETADMIN, - UMODE_REGPRIV, UMODE_PROTECTED, UMODE_NOCTCP, UMODE_WEBTV, UMODE_WEBIRC, 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_SOFTCALLERID, UMODE_CALLERID, - UMODE_COMMONCHANS, UMODE_HIDDEN, UMODE_STRIPCOLOR, UMODE_INVISIBLE_OPER, UMODE_RESTRICTED, UMODE_HIDEIDLE, - - UMODE_END -}; - -/** All of the valid channel mode names - */ -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, CMODE_NICKFLOOD, CMODE_JOINFLOOD, CMODE_DELAYEDJOIN, CMODE_NOREJOIN, - CMODE_BANDWIDTH, - - /* 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 -}; - /** The different types of modes */ enum ModeType @@ -79,6 +39,8 @@ enum ModeClass class CoreExport Mode : public Base { public: + /* Mode name */ + Anope::string name; /* Class of mode this is (user/channel) */ ModeClass mclass; /* Mode char for this, eg 'b' */ @@ -87,11 +49,12 @@ class CoreExport Mode : public Base ModeType type; /** constructor + * @param mname The mode name * @param mclass The type of mode this is * @param mc The mode char * @param type The mode type */ - Mode(ModeClass mclass, char mc, ModeType type); + Mode(const Anope::string &mname, ModeClass mclass, char mc, ModeType type); virtual ~Mode(); }; @@ -100,19 +63,12 @@ class CoreExport Mode : public Base class CoreExport UserMode : public Mode { public: - /* Mode name */ - UserModeName name; - /** constructor * @param name The mode name * @param mc The mode char */ - UserMode(UserModeName name, char mc); + UserMode(const Anope::string &name, char mc); virtual ~UserMode(); - - /** Returns the mode name as a string - */ - const Anope::string NameAsString(); }; class CoreExport UserModeParam : public UserMode @@ -122,7 +78,7 @@ class CoreExport UserModeParam : public UserMode * @param name The mode name * @param mc The mode char */ - UserModeParam(UserModeName name, char mc); + UserModeParam(const Anope::string &name, char mc); /** Check if the param is valid * @param value The param @@ -136,14 +92,11 @@ class CoreExport UserModeParam : public UserMode class CoreExport ChannelMode : public Mode { public: - /* Mode name */ - ChannelModeName name; - /** constructor * @param name The mode name * @param mc The mode char */ - ChannelMode(ChannelModeName name, char mc); + ChannelMode(const Anope::string &name, char mc); virtual ~ChannelMode(); /** Can a user set this mode, used for mlock @@ -151,10 +104,6 @@ class CoreExport ChannelMode : public Mode * @param u The user, or NULL */ virtual bool CanSet(User *u) const; - - /** Returns the mode name as a string - */ - const Anope::string NameAsString(); }; @@ -167,7 +116,7 @@ class CoreExport ChannelModeList : public ChannelMode * @param name The mode name * @param mc The mode char */ - ChannelModeList(ChannelModeName name, char mc); + ChannelModeList(const Anope::string &name, char mc); /** destructor */ @@ -210,7 +159,7 @@ class CoreExport ChannelModeParam : public ChannelMode * @param mc The mode char * @param minus_no_arg true if this mode sends no arg when unsetting */ - ChannelModeParam(ChannelModeName name, char mc, bool minus_no_arg = false); + ChannelModeParam(const Anope::string &name, char mc, bool minus_no_arg = false); /** destructor */ @@ -244,7 +193,7 @@ class CoreExport ChannelModeStatus : public ChannelMode * @param mSymbol The symbol for the mode, eg @ % * @param mLevel A level for the mode, which is usually determined by the PREFIX capab */ - ChannelModeStatus(ChannelModeName name, char mc, char mSymbol, unsigned short mLevel = 0); + ChannelModeStatus(const Anope::string &name, char mc, char mSymbol, unsigned short mLevel = 0); /** destructor */ @@ -252,9 +201,10 @@ class CoreExport ChannelModeStatus : public ChannelMode }; /* The status a user has on a channel (+v, +h, +o) etc */ -class CoreExport ChannelStatus : public Flags<ChannelModeName> +class CoreExport ChannelStatus { public: + std::set<Anope::string> modes; Anope::string BuildCharPrefixList() const; Anope::string BuildModePrefixList() const; }; @@ -264,7 +214,7 @@ class CoreExport ChannelStatus : public Flags<ChannelModeName> class CoreExport ChannelModeKey : public ChannelModeParam { public: - ChannelModeKey(char mc) : ChannelModeParam(CMODE_KEY, mc) { } + ChannelModeKey(char mc) : ChannelModeParam("KEY", mc) { } bool IsValid(const Anope::string &value) const anope_override; }; @@ -275,7 +225,7 @@ class CoreExport ChannelModeKey : public ChannelModeParam class CoreExport ChannelModeAdmin : public ChannelMode { public: - ChannelModeAdmin(char mc) : ChannelMode(CMODE_ADMINONLY, mc) { } + ChannelModeAdmin(char mc) : ChannelMode("ADMINONLY", mc) { } /* Opers only */ bool CanSet(User *u) const anope_override; @@ -287,7 +237,7 @@ class CoreExport ChannelModeAdmin : public ChannelMode class CoreExport ChannelModeOper : public ChannelMode { public: - ChannelModeOper(char mc) : ChannelMode(CMODE_OPERONLY, mc) { } + ChannelModeOper(char mc) : ChannelMode("OPERONLY", mc) { } /* Opers only */ bool CanSet(User *u) const anope_override; @@ -299,7 +249,7 @@ class CoreExport ChannelModeOper : public ChannelMode class CoreExport ChannelModeRegistered : public ChannelMode { public: - ChannelModeRegistered(char mc) : ChannelMode(CMODE_REGISTERED, mc) { } + ChannelModeRegistered(char mc) : ChannelMode("REGISTERED", mc) { } /* No one mlocks +r */ bool CanSet(User *u) const anope_override; @@ -350,8 +300,8 @@ class CoreExport ModeManager /* Number of generic channel and user modes we are tracking */ static unsigned GenericChannelModes, GenericUserModes; /* Default channel mode lock */ - static std::list<std::pair<ChannelModeName, Anope::string> > ModeLockOn; - static std::list<ChannelModeName> ModeLockOff; + static std::list<std::pair<Anope::string, Anope::string> > ModeLockOn; + static std::list<Anope::string> ModeLockOff; /* Default modes bots have on channels */ static ChannelStatus DefaultBotModes; @@ -393,25 +343,13 @@ class CoreExport ModeManager * @param name The modename * @return The mode class */ - static ChannelMode *FindChannelModeByName(ChannelModeName name); + static ChannelMode *FindChannelModeByName(const Anope::string &name); /** Find a user mode * @param name The modename * @return The mode class */ - static UserMode *FindUserModeByName(UserModeName name); - - /** Find channel mode by string - * @param name The mode name - * @return The mode - */ - static ChannelMode *FindChannelModeByString(const Anope::string &name); - - /** Find user mode by string - * @param name The mode name - * @return The mode - */ - static UserMode *FindUserModeByString(const Anope::string &name); + static UserMode *FindUserModeByName(const Anope::string &name); /** Gets the channel mode char for a symbol (eg + returns v) * @param symbol The symbol @@ -458,7 +396,6 @@ class CoreExport ModeManager */ enum EntryType { - ENTRYTYPE_NONE, ENTRYTYPE_CIDR, ENTRYTYPE_NICK_WILD, ENTRYTYPE_NICK, @@ -470,20 +407,20 @@ enum EntryType /** Represents a mask set on a channel (b/e/I) */ -class CoreExport Entry : public Flags<EntryType> +class CoreExport Entry { - ChannelModeName modename; - + Anope::string name; public: + std::set<EntryType> types; unsigned char cidr_len; Anope::string mask; Anope::string nick, user, host; /** Constructor - * @param mode What mode this host is for - can be CMODE_BEGIN for unknown/no mode + * @param mode What mode this host is for, can be empty for unknown/no mode * @param host A full nick!ident@host/cidr mask */ - Entry(ChannelModeName mode, const Anope::string &host); + Entry(const Anope::string &mode, const Anope::string &host); /** Get the banned mask for this entry * @return The mask |
