]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Split out ModeParser::ModeParamsToChangeList()
authorAttila Molnar <attilamolnar@hush.com>
Wed, 3 Sep 2014 13:03:38 +0000 (15:03 +0200)
committerAttila Molnar <attilamolnar@hush.com>
Wed, 3 Sep 2014 13:03:38 +0000 (15:03 +0200)
include/mode.h
src/mode.cpp

index 2833d75a2cd8504c19661ea8c5f02bb9f1e81f6f..66f003b998ff690c4135b4b60d6f70715d552690 100644 (file)
@@ -692,6 +692,19 @@ class CoreExport ModeParser : public fakederef<ModeParser>
         */
        void ProcessSingle(User* user, Channel* targetchannel, User* targetuser, Modes::ChangeList& changelist, ModeProcessFlag flags = MODE_NONE);
 
+       /** Turn a list of parameters compatible with the format of the MODE command into
+        * Modes::ChangeList form. All modes are processed, regardless of max modes. Unknown modes
+        * are skipped.
+        * @param user The source of the mode change, can be a server user. Error numerics are sent to
+        * this user.
+        * @param type MODETYPE_USER if this is a user mode change or MODETYPE_CHANNEL if this
+        * is a channel mode change.
+        * @param parameters List of strings describing the mode change to convert to a ChangeList.
+        * Must be using the same format as the parameters of a MODE command.
+        * @param changelist ChangeList object to populate.
+        */
+       void ModeParamsToChangeList(User* user, ModeType type, const std::vector<std::string>& parameters, Modes::ChangeList& changelist);
+
        /** Find the mode handler for a given mode name and type.
         * @param modename The mode name to search for.
         * @param mt Type of mode to search for, user or channel.
index ac7ee97d6304066a6a015b5f4903745ca591e27b..9b27a3d131924299585790e4243f887243ddbfc4 100644 (file)
@@ -390,6 +390,7 @@ void ModeParser::Process(const std::vector<std::string>& parameters, User* user,
 
        // Populate a temporary Modes::ChangeList with the parameters
        Modes::ChangeList changelist;
+       ModeParamsToChangeList(user, type, parameters, changelist);
 
        ModResult MOD_RESULT;
        FIRST_MOD_RESULT(OnPreMode, MOD_RESULT, (user, targetuser, targetchannel, parameters));
@@ -413,6 +414,19 @@ void ModeParser::Process(const std::vector<std::string>& parameters, User* user,
                        return; // Entire mode change denied by a module
        }
 
+       ProcessSingle(user, targetchannel, targetuser, changelist, flags);
+
+       if ((LastParse.empty()) && (targetchannel) && (parameters.size() == 2))
+       {
+               /* Special case for displaying the list for listmodes,
+                * e.g. MODE #chan b, or MODE #chan +b without a parameter
+                */
+               this->DisplayListModes(user, targetchannel, parameters[1]);
+       }
+}
+
+void ModeParser::ModeParamsToChangeList(User* user, ModeType type, const std::vector<std::string>& parameters, Modes::ChangeList& changelist)
+{
        const std::string& mode_sequence = parameters[1];
 
        bool adding = true;
@@ -441,16 +455,6 @@ void ModeParser::Process(const std::vector<std::string>& parameters, User* user,
 
                changelist.push(mh, adding, parameter);
        }
-
-       ProcessSingle(user, targetchannel, targetuser, changelist, flags);
-
-       if ((LastParse.empty()) && (targetchannel) && (parameters.size() == 2))
-       {
-               /* Special case for displaying the list for listmodes,
-                * e.g. MODE #chan b, or MODE #chan +b without a parameter
-                */
-               this->DisplayListModes(user, targetchannel, mode_sequence);
-       }
 }
 
 static bool IsModeParamValid(User* user, Channel* targetchannel, User* targetuser, const Modes::Change& item)