diff options
| author | Adam <Adam@anope.org> | 2012-04-23 05:08:26 -0400 |
|---|---|---|
| committer | Adam <Adam@anope.org> | 2012-04-23 05:08:26 -0400 |
| commit | 573e49a7ead331219eb6f0d3ca9cf83e793a5c9c (patch) | |
| tree | e145e04fa3d041cf92ce46da4ac790b63231059c /include | |
| parent | 63c639e108a00d7dbb0d7ac9891684fc83a3b207 (diff) | |
Reworked live SQL support yet again
Diffstat (limited to 'include')
| -rw-r--r-- | include/access.h | 18 | ||||
| -rw-r--r-- | include/account.h | 28 | ||||
| -rw-r--r-- | include/anope.h | 4 | ||||
| -rw-r--r-- | include/base.h | 50 | ||||
| -rw-r--r-- | include/bots.h | 14 | ||||
| -rw-r--r-- | include/channels.h | 24 | ||||
| -rw-r--r-- | include/defs.h | 1 | ||||
| -rw-r--r-- | include/extensible.h | 16 | ||||
| -rw-r--r-- | include/extern.h | 14 | ||||
| -rw-r--r-- | include/logger.h | 18 | ||||
| -rw-r--r-- | include/mail.h | 4 | ||||
| -rw-r--r-- | include/memo.h | 10 | ||||
| -rw-r--r-- | include/modes.h | 14 | ||||
| -rw-r--r-- | include/modules.h | 56 | ||||
| -rw-r--r-- | include/oper.h | 18 | ||||
| -rw-r--r-- | include/protocol.h | 2 | ||||
| -rw-r--r-- | include/regchannel.h | 92 | ||||
| -rw-r--r-- | include/serialize.h | 189 | ||||
| -rw-r--r-- | include/servers.h | 2 | ||||
| -rw-r--r-- | include/service.h | 4 | ||||
| -rw-r--r-- | include/users.h | 27 |
21 files changed, 383 insertions, 222 deletions
diff --git a/include/access.h b/include/access.h index e19c15a76..18499b602 100644 --- a/include/access.h +++ b/include/access.h @@ -59,7 +59,7 @@ class CoreExport ChanAccess : public Serializable { public: AccessProvider *provider; - ChannelInfo *ci; + serialize_obj<ChannelInfo> ci; Anope::string mask; Anope::string creator; time_t last_seen; @@ -68,13 +68,13 @@ class CoreExport ChanAccess : public Serializable ChanAccess(AccessProvider *p); virtual ~ChanAccess(); - Anope::string serialize_name() const; - serialized_data serialize(); - static void unserialize(serialized_data &); + const Anope::string serialize_name() const anope_override; + Serialize::Data serialize() const anope_override; + static Serializable* unserialize(Serializable *obj, Serialize::Data &); - virtual bool Matches(User *u, NickCore *nc); + virtual bool Matches(const User *u, const NickCore *nc) const; virtual bool HasPriv(const Anope::string &name) const = 0; - virtual Anope::string Serialize() = 0; + virtual Anope::string Serialize() const = 0; virtual void Unserialize(const Anope::string &data) = 0; bool operator>(const ChanAccess &other) const; @@ -86,12 +86,12 @@ class CoreExport ChanAccess : public Serializable class CoreExport AccessGroup : public std::vector<ChanAccess *> { public: - ChannelInfo *ci; - NickCore *nc; + const ChannelInfo *ci; + const NickCore *nc; bool SuperAdmin, Founder; AccessGroup(); bool HasPriv(const Anope::string &priv) const; - ChanAccess *Highest() const; + const ChanAccess *Highest() const; bool operator>(const AccessGroup &other) const; bool operator<(const AccessGroup &other) const; bool operator>=(const AccessGroup &other) const; diff --git a/include/account.h b/include/account.h index 18bdcc876..756c97348 100644 --- a/include/account.h +++ b/include/account.h @@ -23,8 +23,8 @@ typedef Anope::insensitive_map<NickAlias *> nickalias_map; typedef Anope::insensitive_map<NickCore *> nickcore_map; -extern CoreExport nickalias_map NickAliasList; -extern CoreExport nickcore_map NickCoreList; +extern serialize_checker<nickalias_map> NickAliasList; +extern serialize_checker<nickcore_map> NickCoreList; /* NickServ nickname structures. */ @@ -109,7 +109,7 @@ const Anope::string NickCoreFlagStrings[] = { "MEMO_MAIL", "HIDE_STATUS", "SUSPENDED", "AUTOOP", "FORBIDDEN", "UNCONFIRMED", "STATS", "" }; -class CoreExport NickAlias : public Base, public Extensible, public Flags<NickNameFlag, NS_END>, public Serializable +class CoreExport NickAlias : public Extensible, public Flags<NickNameFlag, NS_END>, public Serializable { Anope::string vhost_ident, vhost_host, vhost_creator; time_t vhost_created; @@ -117,7 +117,7 @@ class CoreExport NickAlias : public Base, public Extensible, public Flags<NickNa public: /** Default constructor * @param nickname The nick - * @param nickcore The nickcofe for this nick + * @param nickcore The nickcore for this nick */ NickAlias(const Anope::string &nickname, NickCore *nickcore); @@ -132,11 +132,11 @@ class CoreExport NickAlias : public Base, public Extensible, public Flags<NickNa Anope::string last_realhost; /* Last uncloaked usermask, requires nickserv/auspex to see */ time_t time_registered; /* When the nick was registered */ time_t last_seen; /* When it was seen online for the last time */ - NickCore *nc; /* I'm an alias of this */ + serialize_obj<NickCore> nc; /* I'm an alias of this */ - Anope::string serialize_name() const anope_override; - serialized_data serialize() anope_override; - static void unserialize(serialized_data &); + const Anope::string serialize_name() const anope_override; + Serialize::Data serialize() const anope_override; + static Serializable* unserialize(Serializable *obj, Serialize::Data &); /** Release a nick * See the comment in users.cpp @@ -188,7 +188,7 @@ class CoreExport NickAlias : public Base, public Extensible, public Flags<NickNa time_t GetVhostCreated() const; }; -class CoreExport NickCore : public Base, public Extensible, public Flags<NickCoreFlag, NI_END>, public Serializable +class CoreExport NickCore : public Extensible, public Flags<NickCoreFlag, NI_END>, public Serializable { public: /** Default constructor @@ -216,11 +216,11 @@ class CoreExport NickCore : public Base, public Extensible, public Flags<NickCor /* Unsaved data */ uint16_t channelcount; /* Number of channels currently registered */ time_t lastmail; /* Last time this nick record got a mail */ - std::list<NickAlias *> aliases; /* List of aliases */ + std::list<serialize_obj<NickAlias> > aliases; /* List of aliases */ - Anope::string serialize_name() const anope_override; - serialized_data serialize() anope_override; - static void unserialize(serialized_data &); + const Anope::string serialize_name() const anope_override; + Serialize::Data serialize() const anope_override; + static Serializable* unserialize(Serializable *obj, Serialize::Data &); /** Checks whether this account is a services oper or not. * @return True if this account is a services oper, false otherwise. @@ -291,7 +291,7 @@ class CoreExport NickCore : public Base, public Extensible, public Flags<NickCor * * Search for an fingerprint within the cert list. */ - bool FindCert(const Anope::string &entry); + bool FindCert(const Anope::string &entry) const; /** Erase a fingerprint from the nick's certificate list * diff --git a/include/anope.h b/include/anope.h index b286d0fb6..c67b1decb 100644 --- a/include/anope.h +++ b/include/anope.h @@ -670,7 +670,7 @@ template<typename T, size_t Size = 32> class Flags Flag_Values.reset(); } - Anope::string ToString() + Anope::string ToString() const { std::vector<Anope::string> v = ToVector(); Anope::string flag_buf; @@ -692,7 +692,7 @@ template<typename T, size_t Size = 32> class Flags FromVector(v); } - std::vector<Anope::string> ToVector() + std::vector<Anope::string> ToVector() const { std::vector<Anope::string> ret; for (unsigned i = 0; this->Flag_Strings && !this->Flag_Strings[i].empty(); ++i) diff --git a/include/base.h b/include/base.h index 2a7cb5147..cc0e84bf9 100644 --- a/include/base.h +++ b/include/base.h @@ -30,6 +30,7 @@ class dynamic_reference_base bool invalid; public: dynamic_reference_base() : invalid(false) { } + dynamic_reference_base(const dynamic_reference_base &other) : invalid(other.invalid) { } virtual ~dynamic_reference_base() { } inline void Invalidate() { this->invalid = true; } }; @@ -40,66 +41,67 @@ class dynamic_reference : public dynamic_reference_base protected: T *ref; public: + dynamic_reference() : ref(NULL) + { + } + dynamic_reference(T *obj) : ref(obj) { if (ref) ref->AddReference(this); } - dynamic_reference(const dynamic_reference<T> &obj) : ref(obj.ref) + dynamic_reference(const dynamic_reference<T> &other) : dynamic_reference_base(other), ref(other.ref) { - if (ref) + if (*this) ref->AddReference(this); } virtual ~dynamic_reference() { - if (this->invalid) + if (*this) { - this->invalid = false; - this->ref = NULL; - } - else if (this->operator bool()) ref->DelReference(this); + } } virtual operator bool() { - if (this->invalid) - { - this->invalid = false; - this->ref = NULL; - } - return this->ref != NULL; + if (!this->invalid) + return this->ref != NULL; + return false; } - virtual inline operator T*() + virtual inline operator T*() const { - if (this->operator bool()) + if (!this->invalid) return this->ref; return NULL; } - virtual inline T *operator->() + virtual inline T* operator->() { - if (this->operator bool()) + if (!this->invalid) return this->ref; return NULL; } virtual inline void operator=(T *newref) { - if (this->invalid) - { - this->invalid = false; - this->ref = NULL; - } - else if (this->operator bool()) + if (*this) this->ref->DelReference(this); this->ref = newref; - if (this->operator bool()) + this->invalid = false; + if (*this) this->ref->AddReference(this); } + + virtual inline bool operator==(const dynamic_reference<T> &other) const + { + if (!this->invalid) + return this->ref == other; + return false; + } }; #endif // BASE_H diff --git a/include/bots.h b/include/bots.h index 8d39cd0b3..749e4c92d 100644 --- a/include/bots.h +++ b/include/bots.h @@ -14,9 +14,11 @@ #include "commands.h" -extern CoreExport Anope::insensitive_map<BotInfo *> BotListByNick; -extern CoreExport Anope::map<BotInfo *> BotListByUID; typedef Anope::insensitive_map<BotInfo *> botinfo_map; +typedef Anope::map<BotInfo *> botinfouid_map; + +extern serialize_checker<botinfo_map> BotListByNick; +extern serialize_checker<botinfouid_map> BotListByUID; /** Flags settable on a bot */ @@ -60,9 +62,9 @@ class CoreExport BotInfo : public User, public Flags<BotFlag, BI_END>, public Se */ virtual ~BotInfo(); - Anope::string serialize_name() const; - serialized_data serialize(); - static void unserialize(serialized_data &); + const Anope::string serialize_name() const; + Serialize::Data serialize() const; + static Serializable* unserialize(Serializable *obj, Serialize::Data &); void GenerateUID(); @@ -90,7 +92,7 @@ class CoreExport BotInfo : public User, public Flags<BotFlag, BI_END>, public Se /** Get the number of channels this bot is assigned to */ - unsigned GetChannelCount(); + unsigned GetChannelCount() const; /** Join this bot to a channel * @param c The channel diff --git a/include/channels.h b/include/channels.h index 43da37f51..a738f5b8b 100644 --- a/include/channels.h +++ b/include/channels.h @@ -12,7 +12,7 @@ #include "anope.h" #include "extensible.h" #include "modes.h" - +#include "serialize.h" typedef Anope::insensitive_map<Channel *> channel_map; extern CoreExport channel_map ChannelList; @@ -40,7 +40,7 @@ enum ChannelFlag const Anope::string ChannelFlagString[] = { "CH_INABIT", "CH_PERSIST", "CH_SYNCING", "" }; -class CoreExport Channel : public Base, public Extensible, public Flags<ChannelFlag, 3> +class CoreExport Channel : public virtual Base, public Extensible, public Flags<ChannelFlag, 3> { public: typedef std::multimap<ChannelModeName, Anope::string> ModeList; @@ -61,7 +61,7 @@ class CoreExport Channel : public Base, public Extensible, public Flags<ChannelF ~Channel(); Anope::string name; /* Channel name */ - ChannelInfo *ci; /* Corresponding ChannelInfo */ + serialize_obj<ChannelInfo> ci; /* Corresponding ChannelInfo */ time_t creation_time; /* When channel was created */ /* List of users in the channel */ @@ -104,14 +104,14 @@ class CoreExport Channel : public Base, public Extensible, public Flags<ChannelF * @param u The user * @return A user container if found, else NULL */ - UserContainer *FindUser(User *u); + UserContainer *FindUser(const User *u) const; /** Check if a user has a status on a channel * @param u The user * @param cms The status mode, or NULL to represent no status * @return true or false */ - bool HasUserStatus(User *u, ChannelModeStatus *cms) const; + bool HasUserStatus(const User *u, ChannelModeStatus *cms) const; /** Check if a user has a status on a channel * Use the overloaded function for ChannelModeStatus* to check for no status @@ -119,7 +119,7 @@ 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(User *u, ChannelModeName Name) const; + bool HasUserStatus(const User *u, ChannelModeName Name) const; /** See if a channel has a mode * @param Name The mode name @@ -156,7 +156,7 @@ class CoreExport Channel : public Base, public Extensible, public Flags<ChannelF * @param param Optional param arg for the mode * @param EnforceMLock true if mlocks should be enforced, false to override mlock */ - void SetMode(BotInfo *bi, ChannelMode *cm, const Anope::string ¶m = "", bool EnforceMLock = true); + void SetMode(const BotInfo *bi, ChannelMode *cm, const Anope::string ¶m = "", bool EnforceMLock = true); /** * Set a mode on a channel @@ -165,7 +165,7 @@ class CoreExport Channel : public Base, public Extensible, public Flags<ChannelF * @param param Optional param arg for the mode * @param EnforceMLock true if mlocks should be enforced, false to override mlock */ - void SetMode(BotInfo *bi, ChannelModeName Name, const Anope::string ¶m = "", bool EnforceMLock = true); + void SetMode(const BotInfo *bi, ChannelModeName Name, const Anope::string ¶m = "", bool EnforceMLock = true); /** Remove a mode from a channel * @param bi The client setting the modes @@ -173,7 +173,7 @@ class CoreExport Channel : public Base, public Extensible, public Flags<ChannelF * @param param Optional param arg for the mode * @param EnforceMLock true if mlocks should be enforced, false to override mlock */ - void RemoveMode(BotInfo *bi, ChannelMode *cm, const Anope::string ¶m = "", bool EnforceMLock = true); + void RemoveMode(const BotInfo *bi, ChannelMode *cm, const Anope::string ¶m = "", bool EnforceMLock = true); /** * Remove a mode from a channel @@ -182,7 +182,7 @@ class CoreExport Channel : public Base, public Extensible, public Flags<ChannelF * @param param Optional param arg for the mode * @param EnforceMLock true if mlocks should be enforced, false to override mlock */ - void RemoveMode(BotInfo *bi, ChannelModeName Name, const Anope::string ¶m = "", bool EnforceMLock = true); + void RemoveMode(const BotInfo *bi, ChannelModeName Name, const Anope::string ¶m = "", bool EnforceMLock = true); /** Get a param from the channel * @param Name The mode @@ -196,7 +196,7 @@ class CoreExport Channel : public Base, public Extensible, public Flags<ChannelF * @param EnforceMLock Should mlock be enforced on this mode change * @param cmodes The modes to set */ - void SetModes(BotInfo *bi, bool EnforceMLock, const char *cmodes, ...); + void SetModes(const BotInfo *bi, bool EnforceMLock, const char *cmodes, ...); /** Set a string of modes internally on a channel * @param setter the setter (if it is a user) @@ -255,6 +255,6 @@ extern void do_join(const Anope::string &source, const Anope::string &channels, extern void do_kick(const Anope::string &source, const Anope::string &channel, const Anope::string &users, const Anope::string &reason); extern void do_part(const Anope::string &source, const Anope::string &channels, const Anope::string &reason); -extern void chan_set_correct_modes(User *user, Channel *c, int give_modes); +extern void chan_set_correct_modes(const User *user, Channel *c, int give_modes); #endif // CHANNELS_H diff --git a/include/defs.h b/include/defs.h index 098f48edd..db3c801ed 100644 --- a/include/defs.h +++ b/include/defs.h @@ -36,6 +36,7 @@ class NickAlias; class NickCore; class OperType; class Regex; +class Serializable; class Server; class ServerConfig; class Socket; diff --git a/include/extensible.h b/include/extensible.h index 1416e1983..e0281c197 100644 --- a/include/extensible.h +++ b/include/extensible.h @@ -17,12 +17,6 @@ class CoreExport ExtensibleItem virtual void OnDelete(); }; -class ExtensibleString : public Anope::string, public ExtensibleItem -{ - public: - ExtensibleString(const Anope::string &s) : Anope::string(s), ExtensibleItem() { } -}; - class CoreExport Extensible { private: @@ -92,9 +86,9 @@ class CoreExport Extensible * @param key The key parameter is an arbitary string which identifies the extension data * @return The item found */ - template<typename T> T GetExt(const Anope::string &key) + template<typename T> T GetExt(const Anope::string &key) const { - extensible_map::iterator it = this->extension_items.find(key); + extensible_map::const_iterator it = this->extension_items.find(key); if (it != this->extension_items.end()) return debug_cast<T>(it->second); @@ -106,7 +100,7 @@ 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) + bool HasExt(const Anope::string &key) const { return this->extension_items.count(key) > 0; } @@ -116,9 +110,9 @@ class CoreExport Extensible * @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) + void GetExtList(std::deque<Anope::string> &list) const { - for (extensible_map::iterator it = extension_items.begin(), it_end = extension_items.end(); it != it_end; ++it) + for (extensible_map::const_iterator it = extension_items.begin(), it_end = extension_items.end(); it != it_end; ++it) list.push_back(it->first); } }; diff --git a/include/extern.h b/include/extern.h index aff091913..09d8e69ee 100644 --- a/include/extern.h +++ b/include/extern.h @@ -21,7 +21,7 @@ /**** actions.c ****/ E bool bad_password(User *u); -E void common_unban(ChannelInfo *ci, User *u, bool full = false); +E void common_unban(const ChannelInfo *ci, User *u, bool full = false); /**** channels.c ****/ @@ -34,7 +34,7 @@ E void do_join(const Anope::string &source, const Anope::string &channels, const E void do_kick(const Anope::string &source, const Anope::string &channel, const Anope::string &users, const Anope::string &reason); E void do_part(const Anope::string &source, const Anope::string &channels, const Anope::string &reason); -E void chan_set_correct_modes(User *user, Channel *c, int give_modes); +E void chan_set_correct_modes(const User *user, Channel *c, int give_modes); /**** encrypt.c ****/ @@ -57,7 +57,7 @@ E std::vector<Anope::string> domains; E void InitLanguages(); E const char *translate(const char *string); E const char *translate(User *u, const char *string); -E const char *translate(NickCore *nc, const char *string); +E const char *translate(const NickCore *nc, const char *string); E const char *anope_gettext(const char *lang, const char *string); /**** main.c ****/ @@ -115,9 +115,9 @@ E bool OnError(const Anope::string &, const std::vector<Anope::string> &); E bool IsFile(const Anope::string &filename); E time_t dotime(const Anope::string &s); -E Anope::string duration(const time_t &seconds, NickCore *nc = NULL); -E Anope::string expire_left(NickCore *nc, time_t expires); -E Anope::string do_strftime(const time_t &t, NickCore *nc = NULL, bool short_output = false); +E Anope::string duration(const time_t &seconds, const NickCore *nc = NULL); +E Anope::string expire_left(const NickCore *nc, time_t expires); +E Anope::string do_strftime(const time_t &t, const NickCore *nc = NULL, bool short_output = false); E bool IsValidIdent(const Anope::string &ident); E bool IsValidHost(const Anope::string &host); @@ -137,7 +137,7 @@ E Anope::string normalizeBuffer(const Anope::string &); /* Number of generic modes we support */ E unsigned GenericChannelModes, GenericUserModes; -E std::multimap<ChannelModeName, ModeLock> def_mode_locks; +E std::multimap<ChannelModeName, ModeLock *> def_mode_locks; E void SetDefaultMLock(ServerConfig *config); /**** process.c ****/ diff --git a/include/logger.h b/include/logger.h index a6e3ca113..8cb54a754 100644 --- a/include/logger.h +++ b/include/logger.h @@ -48,11 +48,11 @@ struct LogFile class CoreExport Log { public: - BotInfo *bi; - User *u; + const BotInfo *bi; + const User *u; Command *c; Channel *chan; - ChannelInfo *ci; + const ChannelInfo *ci; Server *s; LogType Type; Anope::string Category; @@ -60,21 +60,21 @@ class CoreExport Log std::stringstream buf; - Log(LogType type = LOG_NORMAL, const Anope::string &category = "", BotInfo *bi = NULL); + Log(LogType type = LOG_NORMAL, const Anope::string &category = "", const BotInfo *bi = NULL); /* LOG_COMMAND/OVERRIDE/ADMIN */ - Log(LogType type, User *u, Command *c, ChannelInfo *ci = NULL); + Log(LogType type, const User *u, Command *c, const ChannelInfo *ci = NULL); /* LOG_CHANNEL */ - Log(User *u, Channel *c, const Anope::string &category = ""); + Log(const User *u, Channel *c, const Anope::string &category = ""); /* LOG_USER */ - explicit Log(User *u, const Anope::string &category = "", BotInfo *bi = NULL); + explicit Log(const User *u, const Anope::string &category = "", const BotInfo *bi = NULL); /* LOG_SERVER */ - explicit Log(Server *s, const Anope::string &category = "", BotInfo *bi = NULL); + explicit Log(Server *s, const Anope::string &category = "", const BotInfo *bi = NULL); - explicit Log(BotInfo *b, const Anope::string &category = ""); + explicit Log(const BotInfo *b, const Anope::string &category = ""); ~Log(); diff --git a/include/mail.h b/include/mail.h index 06cfe4b39..baef45589 100644 --- a/include/mail.h +++ b/include/mail.h @@ -16,9 +16,9 @@ #include "anope.h" #include "threadengine.h" +#include "serialize.h" - -extern CoreExport bool Mail(User *u, NickCore *nc, BotInfo *service, const Anope::string &subject, const Anope::string &message); +extern CoreExport bool Mail(User *u, NickCore *nc, const BotInfo *service, const Anope::string &subject, const Anope::string &message); extern CoreExport bool Mail(NickCore *nc, const Anope::string &subject, const Anope::string &message); extern CoreExport bool MailValidate(const Anope::string &email); diff --git a/include/memo.h b/include/memo.h index 420def504..8ece00d6a 100644 --- a/include/memo.h +++ b/include/memo.h @@ -38,9 +38,9 @@ class CoreExport Memo : public Flags<MemoFlag>, public Serializable public: Memo(); - Anope::string serialize_name() const anope_override; - serialized_data serialize() anope_override; - static void unserialize(serialized_data &); + const Anope::string serialize_name() const anope_override; + Serialize::Data serialize() const anope_override; + static Serializable* unserialize(Serializable *obj, Serialize::Data &); Anope::string owner; time_t time; /* When it was sent */ @@ -51,9 +51,11 @@ class CoreExport Memo : public Flags<MemoFlag>, public Serializable struct CoreExport MemoInfo { int16_t memomax; - std::vector<Memo *> memos; + serialize_checker<std::vector<Memo *> > memos; std::vector<Anope::string> ignores; + MemoInfo(); + Memo *GetMemo(unsigned index) const; unsigned GetIndex(Memo *m) const; void Del(unsigned index); void Del(Memo *m); diff --git a/include/modes.h b/include/modes.h index c8ef794bd..0fb822b7e 100644 --- a/include/modes.h +++ b/include/modes.h @@ -113,7 +113,7 @@ enum ModeClass /** This class is the basis of all modes in Anope */ -class CoreExport Mode : public Base +class CoreExport Mode : public virtual Base { public: /* Class of mode this is */ @@ -231,7 +231,7 @@ class CoreExport ChannelModeList : public ChannelMode * @param e The entry to match against * @return true on match */ - virtual bool Matches(User *u, const Entry *e) { return false; } + virtual bool Matches(const User *u, const Entry *e) { return false; } /** Called when a mask is added to a channel * @param chan The channel @@ -359,7 +359,7 @@ class StackerInfo /* The type of object this stacker info is for */ StackerType Type; /* Bot this is sent from */ - BotInfo *bi; + const BotInfo *bi; /** Add a mode to this object * @param mode The mode @@ -401,7 +401,7 @@ class CoreExport ModeManager * @param Param A param, if there is one * @param Type The type this is, user or channel */ - static void StackerAddInternal(BotInfo *bi, Base *Object, Mode *mode, bool Set, const Anope::string &Param, StackerType Type); + static void StackerAddInternal(const BotInfo *bi, Base *Object, Mode *mode, bool Set, const Anope::string &Param, StackerType Type); public: /* List of all modes Anope knows about */ @@ -469,7 +469,7 @@ class CoreExport ModeManager * @param Set true for setting, false for removing * @param Param The param, if there is one */ - static void StackerAdd(BotInfo *bi, Channel *c, ChannelMode *cm, bool Set, const Anope::string &Param = ""); + static void StackerAdd(const BotInfo *bi, Channel *c, ChannelMode *cm, bool Set, const Anope::string &Param = ""); /** Add a mode to the stacker to be set on a user * @param bi The client to set the modes from @@ -478,7 +478,7 @@ class CoreExport ModeManager * @param Set true for setting, false for removing * @param param The param, if there is one */ - static void StackerAdd(BotInfo *bi, User *u, UserMode *um, bool Set, const Anope::string &Param = ""); + static void StackerAdd(const BotInfo *bi, User *u, UserMode *um, bool Set, const Anope::string &Param = ""); /** Process all of the modes in the stacker and send them to the IRCd to be set on channels/users */ @@ -531,7 +531,7 @@ class CoreExport Entry : public Flags<EntryType> * @param full True to match against a users real host and IP * @return true on match */ - bool Matches(User *u, bool full = false) const; + bool Matches(const User *u, bool full = false) const; }; #endif // MODES_H diff --git a/include/modules.h b/include/modules.h index 78ab24486..d44cbf8d9 100644 --- a/include/modules.h +++ b/include/modules.h @@ -9,14 +9,16 @@ * Based on the original code of Services by Andy Church. */ +#include "serialize.h" + #ifndef MODULES_H #define MODULES_H -#include "extensible.h" #include "base.h" #include "modes.h" #include "timers.h" #include "logger.h" +#include "extensible.h" /** This definition is used as shorthand for the various classes * and functions needed to make a module loadable by the OS. @@ -381,18 +383,13 @@ class CoreExport Module : public Extensible * @param ci The channel * @param bw The badword */ - virtual void OnBadWordAdd(ChannelInfo *ci, BadWord *bw) { } + virtual void OnBadWordAdd(ChannelInfo *ci, const BadWord *bw) { } /** Called before a badword is deleted from a channel * @param ci The channel * @param bw The badword */ - virtual void OnBadWordDel(ChannelInfo *ci, BadWord *bw) { } - - /** Called in findbot() - * @param nick The nick being looked up - */ - virtual void OnFindBot(const Anope::string &nick) { } + virtual void OnBadWordDel(ChannelInfo *ci, const BadWord *bw) { } /** Called before a bot kicks a user * @param bi The bot sending the kick @@ -513,14 +510,14 @@ class CoreExport Module : public Extensible * @param xlm The xline manager it was added to * @return EVENT_CONTINUE to let other modules decide, EVENT_STOP to halt the command and not process it */ - virtual EventReturn OnAddXLine(User *u, XLine *x, XLineManager *xlm) { return EVENT_CONTINUE; } + virtual EventReturn OnAddXLine(User *u, const XLine *x, XLineManager *xlm) { return EVENT_CONTINUE; } /** Called before a XLine is deleted * @param u The user deleting the XLine * @param x The XLine * @param xlm The xline manager it was deleted from */ - virtual void OnDelXLine(User *u, XLine *x, XLineManager *xlm) { } + virtual void OnDelXLine(User *u, const XLine *x, XLineManager *xlm) { } /** Called when a user is checked for whether they are a services oper * @param u The user @@ -632,14 +629,14 @@ class CoreExport Module : public Extensible * @param ci The channel * @param ak The akick */ - virtual void OnAkickAdd(User *u, ChannelInfo *ci, AutoKick *ak) { } + virtual void OnAkickAdd(User *u, ChannelInfo *ci, const AutoKick *ak) { } /** Called before removing an akick from a channel * @param u The user removing the akick * @param ci The channel * @param ak The akick */ - virtual void OnAkickDel(User *u, ChannelInfo *ci, AutoKick *ak) { } + virtual void OnAkickDel(User *u, ChannelInfo *ci, const AutoKick *ak) { } /** Called after a user join a channel when we decide whether to kick them or not * @param u The user @@ -657,11 +654,6 @@ class CoreExport Module : public Extensible */ virtual void OnChanInfo(CommandSource &source, ChannelInfo *ci, InfoFormatter &info, bool ShowHidden) { } - /** Called on cs_findchan() - * @param chname The name being looked up - */ - virtual void OnFindChan(const Anope::string &chname) { } - /** Checks if access has the channel privilege 'priv'. * @param access THe access struct * @param priv The privilege being checked for @@ -776,18 +768,6 @@ class CoreExport Module : public Extensible */ virtual void OnNickInfo(CommandSource &source, NickAlias *na, InfoFormatter &info, bool ShowHidden) { } - /** Called in findnick() - * Useful to modify the na returned by findnick() - * @param nick The nick being looked up - */ - virtual void OnFindNick(const Anope::string &nick) { } - - /** Called in findcore() - * Useful to modify the nc returned by findcore() - * @param nick The nick being looked up - */ - virtual void OnFindCore(const Anope::string &nick) { } - /** Check whether a users password is correct. * @param u The user * @param command The command the user is doing @@ -837,14 +817,14 @@ class CoreExport Module : public Extensible * @param mi The memo info * @param m The memo */ - virtual void OnMemoDel(const NickCore *nc, MemoInfo *mi, Memo *m) { } + virtual void OnMemoDel(NickCore *nc, MemoInfo *mi, const Memo *m) { } /** Called when a memo is deleted * @param ci The channel of the memo being deleted * @param mi The memo info * @param m The memo */ - virtual void |
