From 22658d63bdb1e52a66f4514af45fa55ca5891345 Mon Sep 17 00:00:00 2001 From: Adam Date: Sun, 26 May 2013 17:13:11 -0400 Subject: Get rid of the remaining references in the core to specific services. Move more stuff out of the core to the proper modules. --- include/account.h | 14 +------------ include/bots.h | 2 -- include/channels.h | 11 +++-------- include/config.h | 3 +++ include/modes.h | 28 -------------------------- include/module.h | 8 ++++---- include/modules.h | 33 ++++++++++++++++++++++--------- include/modules/chanserv.h | 18 ----------------- include/modules/global.h | 20 ------------------- include/modules/memoserv.h | 34 -------------------------------- include/modules/nickserv.h | 16 --------------- include/modules/pseudoclients/chanserv.h | 18 +++++++++++++++++ include/modules/pseudoclients/global.h | 20 +++++++++++++++++++ include/modules/pseudoclients/memoserv.h | 34 ++++++++++++++++++++++++++++++++ include/modules/pseudoclients/nickserv.h | 17 ++++++++++++++++ include/regchannel.h | 11 ----------- include/users.h | 6 ------ 17 files changed, 124 insertions(+), 169 deletions(-) delete mode 100644 include/modules/chanserv.h delete mode 100644 include/modules/global.h delete mode 100644 include/modules/memoserv.h delete mode 100644 include/modules/nickserv.h create mode 100644 include/modules/pseudoclients/chanserv.h create mode 100644 include/modules/pseudoclients/global.h create mode 100644 include/modules/pseudoclients/memoserv.h create mode 100644 include/modules/pseudoclients/nickserv.h (limited to 'include') diff --git a/include/account.h b/include/account.h index b5edd7ec2..4d6bd714f 100644 --- a/include/account.h +++ b/include/account.h @@ -65,18 +65,6 @@ class CoreExport NickAlias : public Serializable, public Extensible void Serialize(Serialize::Data &data) const anope_override; static Serializable* Unserialize(Serializable *obj, Serialize::Data &); - /** Release a nick - * See the comment in users.cpp - */ - void Release(); - - /** This function is called when a user on this nick either disconnects or changes nick. - * Note that the user isnt necessarially identified to this nick - * See the comment in users.cpp - * @param u The user - */ - void OnCancel(User *u); - /** Set a vhost for the user * @param ident The ident * @param host The host @@ -306,7 +294,7 @@ class CoreExport NickCore : public Serializable, public Extensible }; /* A request to check if an account/password is valid. These can exist for - * extended periods of time due to some authentication modules take. + * extended periods due to the time some authentication modules take. */ class CoreExport IdentifyRequest { diff --git a/include/bots.h b/include/bots.h index 42345d8ea..ef05c11e0 100644 --- a/include/bots.h +++ b/include/bots.h @@ -131,6 +131,4 @@ class CoreExport BotInfo : public User, public Serializable static BotInfo* Find(const Anope::string &nick, bool nick_only = false); }; -extern CoreExport BotInfo *BotServ, *ChanServ, *Global, *HostServ, *MemoServ, *NickServ, *OperServ; - #endif // BOTS_H diff --git a/include/channels.h b/include/channels.h index 7d1918f08..25bd95097 100644 --- a/include/channels.h +++ b/include/channels.h @@ -30,12 +30,6 @@ struct ChanUserContainer : public Extensible ChanUserContainer(User *u, Channel *c) : user(u), chan(c) { } }; -/* Possible flags: - * - * INHABIT - ChanServ is currently holding the channel - * PERSIST - Channel still exists when emptied (IRCd enforced) - * SYNCING - Channel is syncing users (channel was just created) and it should not be deleted - */ class CoreExport Channel : public Base, public Extensible { public: @@ -52,6 +46,8 @@ class CoreExport Channel : public Base, public Extensible Serialize::Reference ci; /* When the channel was created */ time_t creation_time; + /* If the channel has just been created in a netjoin */ + bool syncing; /* Users in the channel */ typedef std::map ChanUserList; @@ -272,9 +268,8 @@ class CoreExport Channel : public Base, public Extensible * for the specified user. * @param user The user to give/remove modes to/from * @param give_modes if true modes may be given to the user - * @param check_noop if true, CI_NOAUTOOP is checked before giving modes */ - void SetCorrectModes(User *u, bool give_mode, bool check_noop); + void SetCorrectModes(User *u, bool give_modes); /** Unbans a user from this channel. * @param u The user to unban diff --git a/include/config.h b/include/config.h index bd76ca8a5..0ea30e5f6 100644 --- a/include/config.h +++ b/include/config.h @@ -124,6 +124,7 @@ namespace Configuration /* module configuration blocks */ std::map modules; + Anope::map bots; Conf(); @@ -131,6 +132,8 @@ namespace Configuration Block *GetModule(Module *); Block *GetModule(const Anope::string &name); + + BotInfo *GetClient(const Anope::string &name); }; struct Uplink diff --git a/include/modes.h b/include/modes.h index 2d9755817..1e5d7f7c1 100644 --- a/include/modes.h +++ b/include/modes.h @@ -262,24 +262,6 @@ class CoreExport ChannelModeRegistered : public ChannelMode bool CanSet(User *u) const anope_override; }; -class StackerInfo -{ - public: - /* Modes to be added */ - std::list > AddModes; - /* Modes to be deleted */ - std::list > DelModes; - /* Bot this is sent from */ - const BotInfo *bi; - - /** Add a mode to this object - * @param mode The mode - * @param set true if setting, false if unsetting - * @param param The param for the mode - */ - void AddMode(Mode *mode, bool set, const Anope::string ¶m); -}; - /** This is the mode manager * It contains functions for adding modes to Anope so Anope can track them * and do things such as MLOCK. @@ -289,16 +271,6 @@ class StackerInfo class CoreExport ModeManager { protected: - /* List of pairs of user/channels and their stacker info */ - static std::map UserStackerObjects; - static std::map ChannelStackerObjects; - - /** Build a list of mode strings to send to the IRCd from the mode stacker - * @param info The stacker info for a channel or user - * @return a list of strings - */ - static std::list BuildModeStrings(StackerInfo *info); - /* Array of all modes Anope knows about. Modes are in this array at position * modechar. Additionally, status modes are in this array (again) at statuschar. */ diff --git a/include/module.h b/include/module.h index d2b365bd7..39ef3403f 100644 --- a/include/module.h +++ b/include/module.h @@ -46,9 +46,9 @@ #include "users.h" #include "xline.h" -#include "modules/chanserv.h" -#include "modules/global.h" -#include "modules/memoserv.h" -#include "modules/nickserv.h" +#include "modules/pseudoclients/chanserv.h" +#include "modules/pseudoclients/global.h" +#include "modules/pseudoclients/memoserv.h" +#include "modules/pseudoclients/nickserv.h" #endif // MODULE_H diff --git a/include/modules.h b/include/modules.h index 641f6f80e..3f99a9114 100644 --- a/include/modules.h +++ b/include/modules.h @@ -363,9 +363,8 @@ class CoreExport Module : public Extensible virtual void OnPostCommand(CommandSource &source, Command *command, const std::vector ¶ms) { } /** Called when the databases are saved - * @return EVENT_CONTINUE to let other modules continue saving, EVENT_STOP to stop */ - virtual EventReturn OnSaveDatabase() { return EVENT_CONTINUE; } + virtual void OnSaveDatabase() { } /** Called when the databases are loaded * @return EVENT_CONTINUE to let other modules continue loading, EVENT_STOP to stop @@ -714,11 +713,16 @@ class CoreExport Module : public Extensible */ virtual void OnNickGroup(User *u, NickAlias *target) { } - /** Called when a user identifies + /** Called when a user identifies to a nick * @param u The user */ virtual void OnNickIdentify(User *u) { } + /** Called when a user is logged into an account + * @param u The user + */ + virtual void OnUserLogin(User *u) { } + /** Called when a nick logs out * @param u The nick */ @@ -985,8 +989,9 @@ class CoreExport Module : public Extensible * @param chan The channel * @param access The user's access on the channel * @param give_modes If giving modes is desired + * @param take_modes If taking modes is desired */ - virtual void OnSetCorrectModes(User *user, Channel *chan, AccessGroup &access, bool give_modes) { } + virtual void OnSetCorrectModes(User *user, Channel *chan, AccessGroup &access, bool &give_modes, bool &take_modes) { } virtual void OnSerializeCheck(Serialize::Type *) { } virtual void OnSerializableConstruct(Serializable *) { } @@ -1025,6 +1030,13 @@ class CoreExport Module : public Extensible * @param cm The mode */ virtual EventReturn OnCanSet(User *u, const ChannelMode *cm) { return EVENT_CONTINUE; } + + virtual EventReturn OnCheckDelete(Channel *) { return EVENT_CONTINUE; } + + /** Called every options:expiretimeout seconds. Should be used to expire nicks, + * channels, etc. + */ + virtual void OnExpireTick() { } }; /** Implementation-specific flags which may be set in ModuleManager::Attach() @@ -1036,13 +1048,13 @@ enum Implementation I_OnPreNickExpire, I_OnNickExpire, I_OnNickForbidden, I_OnNickGroup, I_OnNickLogout, I_OnNickIdentify, I_OnNickDrop, I_OnNickRegister, I_OnNickSuspended, I_OnNickUnsuspended, I_OnDelNick, I_OnNickCoreCreate, I_OnDelCore, I_OnChangeCoreDisplay, I_OnNickClearAccess, I_OnNickAddAccess, I_OnNickEraseAccess, I_OnNickClearCert, I_OnNickAddCert, I_OnNickEraseCert, - I_OnNickInfo, I_OnCheckAuthentication, I_OnNickUpdate, I_OnSetNickOption, + I_OnNickInfo, I_OnCheckAuthentication, I_OnNickUpdate, I_OnSetNickOption, I_OnUserLogin, /* ChanServ */ I_OnChanSuspend, I_OnChanDrop, I_OnPreChanExpire, I_OnChanExpire, I_OnAccessAdd, I_OnAccessDel, I_OnAccessClear, I_OnLevelChange, I_OnChanRegistered, I_OnChanUnsuspend, I_OnCreateChan, I_OnDelChan, I_OnChannelCreate, - I_OnChannelDelete, I_OnAkickAdd, I_OnAkickDel, I_OnCheckKick, I_OnCheckModes, - I_OnChanInfo, I_OnCheckPriv, I_OnGroupCheckPriv, I_OnSetChannelOption, I_OnChannelSync, I_OnSetCorrectModes, + I_OnAkickAdd, I_OnAkickDel, I_OnCheckKick, I_OnCheckModes, + I_OnChanInfo, I_OnCheckPriv, I_OnGroupCheckPriv, I_OnSetChannelOption, I_OnSetCorrectModes, /* BotServ */ I_OnCreateBot, I_OnDelBot, @@ -1055,6 +1067,9 @@ enum Implementation /* MemoServ */ I_OnMemoSend, I_OnMemoDel, + /* Channels */ + I_OnChannelModeSet, I_OnChannelModeUnset, I_OnChannelDelete, I_OnChannelSync, I_OnCheckDelete, + /* Users */ I_OnUserConnect, I_OnUserNickChange, I_OnUserQuit, I_OnPreUserLogoff, I_OnPostUserLogoff, I_OnJoinChannel, I_OnPrePartChannel, I_OnPartChannel, I_OnLeaveChannel, I_OnFingerprint, I_OnUserAway, I_OnInvite, @@ -1074,9 +1089,9 @@ enum Implementation I_OnPreHelp, I_OnPostHelp, I_OnPreCommand, I_OnPostCommand, I_OnRestart, I_OnShutdown, I_OnServerQuit, I_OnTopicUpdated, I_OnEncrypt, I_OnDecrypt, - I_OnChannelModeSet, I_OnChannelModeUnset, I_OnUserModeSet, I_OnUserModeUnset, I_OnChannelModeAdd, I_OnUserModeAdd, + I_OnUserModeSet, I_OnUserModeUnset, I_OnChannelModeAdd, I_OnUserModeAdd, I_OnMLock, I_OnUnMLock, I_OnServerSync, I_OnUplinkSync, I_OnBotPrivmsg, I_OnPrivmsg, I_OnLog, I_OnDnsRequest, - I_OnMessage, I_OnCanSet, + I_OnMessage, I_OnCanSet, I_OnExpireTick, I_OnSerializeCheck, I_OnSerializableConstruct, I_OnSerializableDestruct, I_OnSerializableUpdate, I_OnSerializeTypeCreate, I_END diff --git a/include/modules/chanserv.h b/include/modules/chanserv.h deleted file mode 100644 index e1c3849fd..000000000 --- a/include/modules/chanserv.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef CHANSERV_H -#define CHANSERV_H - -class ChanServService : public Service -{ - public: - ChanServService(Module *m) : Service(m, "ChanServService", "ChanServ") - { - } - - /* Have ChanServ hold the channel, that is, join and set +nsti and wait - * for a few minutes so no one can join or rejoin. - */ - virtual void Hold(Channel *c) = 0; -}; - -#endif // CHANSERV_H - diff --git a/include/modules/global.h b/include/modules/global.h deleted file mode 100644 index 52afc4a23..000000000 --- a/include/modules/global.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef GLOBAL_H -#define GLOBAL_H - -class GlobalService : public Service -{ - public: - GlobalService(Module *m) : Service(m, "GlobalService", "Global") - { - } - - /** Send out a global message to all users - * @param sender Our client which should send the global - * @param source The sender of the global - * @param message The message - */ - virtual void SendGlobal(const BotInfo *sender, const Anope::string &source, const Anope::string &message) = 0; -}; - -#endif // GLOBAL_H - diff --git a/include/modules/memoserv.h b/include/modules/memoserv.h deleted file mode 100644 index d35d3f8a0..000000000 --- a/include/modules/memoserv.h +++ /dev/null @@ -1,34 +0,0 @@ -#ifndef MEMOSERV_H -#define MEMOSERV_H - -class MemoServService : public Service -{ - public: - enum MemoResult - { - MEMO_SUCCESS, - MEMO_INVALID_TARGET, - MEMO_TOO_FAST, - MEMO_TARGET_FULL - }; - - MemoServService(Module *m) : Service(m, "MemoServService", "MemoServ") - { - } - - /** Sends a memo. - * @param source The source of the memo, can be anythin. - * @param target The target of the memo, nick or channel. - * @param message Memo text - * @param force true to force the memo, restrictions/delays etc are not checked - */ - virtual MemoResult Send(const Anope::string &source, const Anope::string &target, const Anope::string &message, bool force = false) = 0; - - /** Check for new memos and notify the user if there are any - * @param u The user - */ - virtual void Check(User *u) = 0; -}; - -#endif // MEMOSERV_H - diff --git a/include/modules/nickserv.h b/include/modules/nickserv.h deleted file mode 100644 index b20d6ebd1..000000000 --- a/include/modules/nickserv.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef NICKSERV_H -#define NICKSERV_H - -class NickServService : public Service -{ - public: - NickServService(Module *m) : Service(m, "NickServService", "NickServ") - { - } - - virtual void Validate(User *u) = 0; - virtual void Login(User *u, NickAlias *na) = 0; -}; - -#endif // NICKSERV_H - diff --git a/include/modules/pseudoclients/chanserv.h b/include/modules/pseudoclients/chanserv.h new file mode 100644 index 000000000..e1c3849fd --- /dev/null +++ b/include/modules/pseudoclients/chanserv.h @@ -0,0 +1,18 @@ +#ifndef CHANSERV_H +#define CHANSERV_H + +class ChanServService : public Service +{ + public: + ChanServService(Module *m) : Service(m, "ChanServService", "ChanServ") + { + } + + /* Have ChanServ hold the channel, that is, join and set +nsti and wait + * for a few minutes so no one can join or rejoin. + */ + virtual void Hold(Channel *c) = 0; +}; + +#endif // CHANSERV_H + diff --git a/include/modules/pseudoclients/global.h b/include/modules/pseudoclients/global.h new file mode 100644 index 000000000..52afc4a23 --- /dev/null +++ b/include/modules/pseudoclients/global.h @@ -0,0 +1,20 @@ +#ifndef GLOBAL_H +#define GLOBAL_H + +class GlobalService : public Service +{ + public: + GlobalService(Module *m) : Service(m, "GlobalService", "Global") + { + } + + /** Send out a global message to all users + * @param sender Our client which should send the global + * @param source The sender of the global + * @param message The message + */ + virtual void SendGlobal(const BotInfo *sender, const Anope::string &source, const Anope::string &message) = 0; +}; + +#endif // GLOBAL_H + diff --git a/include/modules/pseudoclients/memoserv.h b/include/modules/pseudoclients/memoserv.h new file mode 100644 index 000000000..d35d3f8a0 --- /dev/null +++ b/include/modules/pseudoclients/memoserv.h @@ -0,0 +1,34 @@ +#ifndef MEMOSERV_H +#define MEMOSERV_H + +class MemoServService : public Service +{ + public: + enum MemoResult + { + MEMO_SUCCESS, + MEMO_INVALID_TARGET, + MEMO_TOO_FAST, + MEMO_TARGET_FULL + }; + + MemoServService(Module *m) : Service(m, "MemoServService", "MemoServ") + { + } + + /** Sends a memo. + * @param source The source of the memo, can be anythin. + * @param target The target of the memo, nick or channel. + * @param message Memo text + * @param force true to force the memo, restrictions/delays etc are not checked + */ + virtual MemoResult Send(const Anope::string &source, const Anope::string &target, const Anope::string &message, bool force = false) = 0; + + /** Check for new memos and notify the user if there are any + * @param u The user + */ + virtual void Check(User *u) = 0; +}; + +#endif // MEMOSERV_H + diff --git a/include/modules/pseudoclients/nickserv.h b/include/modules/pseudoclients/nickserv.h new file mode 100644 index 000000000..c0238ecfc --- /dev/null +++ b/include/modules/pseudoclients/nickserv.h @@ -0,0 +1,17 @@ +#ifndef NICKSERV_H +#define NICKSERV_H + +class NickServService : public Service +{ + public: + NickServService(Module *m) : Service(m, "NickServService", "NickServ") + { + } + + virtual void Validate(User *u) = 0; + virtual void Collide(User *u, NickAlias *na) = 0; + virtual void Release(NickAlias *na) = 0; +}; + +#endif // NICKSERV_H + diff --git a/include/regchannel.h b/include/regchannel.h index 91cc90ffa..08fae12b3 100644 --- a/include/regchannel.h +++ b/include/regchannel.h @@ -399,17 +399,6 @@ class CoreExport ChannelInfo : public Serializable, public Extensible */ bool CheckKick(User *user); - /** Check the channel topic - * If topic lock is enabled will change the topic back, else it records - * the new topic in the ChannelInfo - */ - void CheckTopic(); - - /** Restore the channel topic, used on channel creation when not syncing with the uplink - * and after uplink sync - */ - void RestoreTopic(); - /** Get the level for a privilege * @param priv The privilege name * @return the level diff --git a/include/users.h b/include/users.h index 00ff5e410..768b6dfa1 100644 --- a/include/users.h +++ b/include/users.h @@ -187,12 +187,6 @@ class CoreExport User : public virtual Base, public Extensible, public CommandRe void SendMessage(const BotInfo *source, const char *fmt, ...); void SendMessage(const BotInfo *source, const Anope::string &msg) anope_override; - /** Collide a nick - * See the comment in users.cpp - * @param na The nick - */ - void Collide(NickAlias *na); - /** Identify the user to the Nick * updates last_seen, logs the user in, * send messages, checks for mails, set vhost and more -- cgit