From a1b74f4dfb2393c0baff25101c6366588975fa27 Mon Sep 17 00:00:00 2001 From: Attila Molnar Date: Thu, 4 Sep 2014 13:11:48 +0200 Subject: core_user Expand the MODE handler into its own file --- src/coremods/core_user/cmd_mode.cpp | 37 ++++++++++++++++++++++++++++++++++++ src/coremods/core_user/core_user.cpp | 28 --------------------------- src/coremods/core_user/core_user.h | 17 +++++++++++++++++ 3 files changed, 54 insertions(+), 28 deletions(-) create mode 100644 src/coremods/core_user/cmd_mode.cpp diff --git a/src/coremods/core_user/cmd_mode.cpp b/src/coremods/core_user/cmd_mode.cpp new file mode 100644 index 000000000..b154f5e22 --- /dev/null +++ b/src/coremods/core_user/cmd_mode.cpp @@ -0,0 +1,37 @@ +/* + * InspIRCd -- Internet Relay Chat Daemon + * + * Copyright (C) 2014 Attila Molnar + * + * This file is part of InspIRCd. InspIRCd is free software: you can + * redistribute it and/or modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation, version 2. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "inspircd.h" +#include "core_user.h" + +CommandMode::CommandMode(Module* parent) + : Command(parent, "MODE", 1) +{ + syntax = " {}"; +} + +CmdResult CommandMode::Handle(const std::vector& parameters, User* user) +{ + ServerInstance->Modes->Process(parameters, user, (IS_LOCAL(user) ? ModeParser::MODE_NONE : ModeParser::MODE_LOCALONLY)); + return CMD_SUCCESS; +} + +RouteDescriptor CommandMode::GetRouting(User* user, const std::vector& parameters) +{ + return (IS_LOCAL(user) ? ROUTE_LOCALONLY : ROUTE_BROADCAST); +} diff --git a/src/coremods/core_user/core_user.cpp b/src/coremods/core_user/core_user.cpp index 103880a6e..ffa6aa2ff 100644 --- a/src/coremods/core_user/core_user.cpp +++ b/src/coremods/core_user/core_user.cpp @@ -20,34 +20,6 @@ #include "inspircd.h" #include "core_user.h" -class CommandMode : public Command -{ - public: - /** Constructor for mode. - */ - CommandMode(Module* parent) - : Command(parent, "MODE", 1) - { - syntax = " {}"; - } - - /** 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(const std::vector& parameters, User* user) - { - ServerInstance->Modes->Process(parameters, user, (IS_LOCAL(user) ? ModeParser::MODE_NONE : ModeParser::MODE_LOCALONLY)); - return CMD_SUCCESS; - } - - RouteDescriptor GetRouting(User* user, const std::vector& parameters) - { - return (IS_LOCAL(user) ? ROUTE_LOCALONLY : ROUTE_BROADCAST); - } -}; - /** Handle /PASS. */ class CommandPass : public SplitCommand diff --git a/src/coremods/core_user/core_user.h b/src/coremods/core_user/core_user.h index a529e0ccf..7cc3d1e05 100644 --- a/src/coremods/core_user/core_user.h +++ b/src/coremods/core_user/core_user.h @@ -62,6 +62,23 @@ class CommandAway : public Command RouteDescriptor GetRouting(User* user, const std::vector& parameters); }; +class CommandMode : public Command +{ + 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(const std::vector& parameters, User* user); + + RouteDescriptor GetRouting(User* user, const std::vector& parameters); +}; + /** Handle /NICK. */ class CommandNick : public SplitCommand -- cgit v1.2.3