diff options
author | Peter Powell <petpow@saberuk.com> | 2019-04-19 12:29:30 +0100 |
---|---|---|
committer | Peter Powell <petpow@saberuk.com> | 2019-04-19 12:29:30 +0100 |
commit | 0f2341e76eb54fb38b97305609db9f025331d002 (patch) | |
tree | afbf54a53547dc2f79c651f38aec6b012082393f /src/coremods | |
parent | bf7664612b00dfcf84c1a03bae2b009b9f1e1d94 (diff) |
Promote cmd_mode to its own core module.
core_user was an inappropriate location for this as it contains
mode changing code which is used by channels as well as users.
Diffstat (limited to 'src/coremods')
-rw-r--r-- | src/coremods/core_mode.cpp (renamed from src/coremods/core_user/cmd_mode.cpp) | 55 | ||||
-rw-r--r-- | src/coremods/core_user/core_user.cpp | 2 | ||||
-rw-r--r-- | src/coremods/core_user/core_user.h | 34 |
3 files changed, 54 insertions, 37 deletions
diff --git a/src/coremods/core_user/cmd_mode.cpp b/src/coremods/core_mode.cpp index 228c352c0..fa20a6902 100644 --- a/src/coremods/core_user/cmd_mode.cpp +++ b/src/coremods/core_mode.cpp @@ -19,8 +19,42 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ + #include "inspircd.h" -#include "core_user.h" + +class CommandMode : public Command +{ + unsigned int sent[256]; + unsigned int seq; + + /** Show the list of one or more list modes to a user. + * @param user User to send to. + * @param chan Channel whose lists to show. + * @param mode_sequence Mode letters to show the lists of. + */ + void DisplayListModes(User* user, Channel* chan, const std::string& mode_sequence); + + /** Show the current modes of a channel or a user to a user. + * @param user User to show the modes to. + * @param targetuser User whose modes to show. NULL if showing the modes of a channel. + * @param targetchannel Channel whose modes to show. NULL if showing the modes of a user. + */ + void DisplayCurrentModes(User* user, User* targetuser, Channel* targetchannel); + + public: + /** Constructor for mode. + */ + CommandMode(Module* parent); + + /** Handle command. + * @param parameters The parameters to the command + * @param user The user issuing the command + * @return A value from CmdResult to indicate command success or failure. + */ + CmdResult Handle(User* user, const Params& parameters) CXX11_OVERRIDE; + + RouteDescriptor GetRouting(User* user, const Params& parameters) CXX11_OVERRIDE; +}; CommandMode::CommandMode(Module* parent) : Command(parent, "MODE", 1) @@ -221,3 +255,22 @@ void CommandMode::DisplayCurrentModes(User* user, User* targetuser, Channel* tar } } } + +class CoreModMode : public Module +{ + private: + CommandMode cmdmode; + + public: + CoreModMode() + : cmdmode(this) + { + } + + Version GetVersion() CXX11_OVERRIDE + { + return Version("Provides the MODE command", VF_VENDOR|VF_CORE); + } +}; + +MODULE_INIT(CoreModMode) diff --git a/src/coremods/core_user/core_user.cpp b/src/coremods/core_user/core_user.cpp index e4e7a5056..66622d34d 100644 --- a/src/coremods/core_user/core_user.cpp +++ b/src/coremods/core_user/core_user.cpp @@ -140,7 +140,6 @@ void MessageWrapper::ReadConfig(const char* prefixname, const char* suffixname, class CoreModUser : public Module { CommandAway cmdaway; - CommandMode cmdmode; CommandNick cmdnick; CommandPart cmdpart; CommandPass cmdpass; @@ -155,7 +154,6 @@ class CoreModUser : public Module public: CoreModUser() : cmdaway(this) - , cmdmode(this) , cmdnick(this) , cmdpart(this) , cmdpass(this) diff --git a/src/coremods/core_user/core_user.h b/src/coremods/core_user/core_user.h index 1365cd048..ea28176d4 100644 --- a/src/coremods/core_user/core_user.h +++ b/src/coremods/core_user/core_user.h @@ -70,40 +70,6 @@ class CommandAway : public Command RouteDescriptor GetRouting(User* user, const Params& parameters) CXX11_OVERRIDE; }; -class CommandMode : public Command -{ - unsigned int sent[256]; - unsigned int seq; - - /** Show the list of one or more list modes to a user. - * @param user User to send to. - * @param chan Channel whose lists to show. - * @param mode_sequence Mode letters to show the lists of. - */ - void DisplayListModes(User* user, Channel* chan, const std::string& mode_sequence); - - /** Show the current modes of a channel or a user to a user. - * @param user User to show the modes to. - * @param targetuser User whose modes to show. NULL if showing the modes of a channel. - * @param targetchannel Channel whose modes to show. NULL if showing the modes of a user. - */ - void DisplayCurrentModes(User* user, User* targetuser, Channel* targetchannel); - - public: - /** Constructor for mode. - */ - CommandMode(Module* parent); - - /** Handle command. - * @param parameters The parameters to the command - * @param user The user issuing the command - * @return A value from CmdResult to indicate command success or failure. - */ - CmdResult Handle(User* user, const Params& parameters) CXX11_OVERRIDE; - - RouteDescriptor GetRouting(User* user, const Params& parameters) CXX11_OVERRIDE; -}; - /** Handle /NICK. */ class CommandNick : public SplitCommand |