aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorGravatar attilamolnar2013-05-26 23:23:47 +0200
committerGravatar attilamolnar2013-05-27 01:07:29 +0200
commit9bb24d3f458274b7485554bc95f1274900a69ec2 (patch)
tree33ab45d74813198ba1377eab83b6a9904a91801e /include
parentClean up the FileReader class and all of the modules that use it. (diff)
Deduplicate RemoveMode() implementations
The default (core) implementation can now remove prefix modes The modestacker parameter is now mandatory
Diffstat (limited to 'include')
-rw-r--r--include/builtinmodes.h4
-rw-r--r--include/listmode.h7
-rw-r--r--include/mode.h18
3 files changed, 18 insertions, 11 deletions
diff --git a/include/builtinmodes.h b/include/builtinmodes.h
index a4a950922..46bfe282b 100644
--- a/include/builtinmodes.h
+++ b/include/builtinmodes.h
@@ -52,11 +52,9 @@ class ModeChannelKey : public ModeHandler
public:
ModeChannelKey();
ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string &parameter, bool adding);
- void RemoveMode(Channel* channel, irc::modestacker* stack = NULL);
void RemoveMode(User* user, irc::modestacker* stack = NULL);
};
-
/** Channel mode +l
*/
class ModeChannelLimit : public ParamChannelModeHandler
@@ -96,7 +94,6 @@ class ModeChannelOp : public ModeHandler
ModeChannelOp();
ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string &parameter, bool adding);
unsigned int GetPrefixRank();
- void RemoveMode(Channel* channel, irc::modestacker* stack = NULL);
void RemoveMode(User* user, irc::modestacker* stack = NULL);
};
@@ -140,7 +137,6 @@ class ModeChannelVoice : public ModeHandler
ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string &parameter, bool adding);
unsigned int GetPrefixRank();
void RemoveMode(User* user, irc::modestacker* stack = NULL);
- void RemoveMode(Channel* channel, irc::modestacker* stack = NULL);
};
/** User mode +i
diff --git a/include/listmode.h b/include/listmode.h
index 1c6f70d6f..b4601fcbd 100644
--- a/include/listmode.h
+++ b/include/listmode.h
@@ -144,10 +144,13 @@ class CoreExport ListModeBase : public ModeHandler
virtual void DisplayEmptyList(User* user, Channel* channel);
/** Remove all instances of the mode from a channel.
- * See mode.h
+ * Populates the given modestack with modes that remove every instance of
+ * this mode from the channel.
+ * See mode.h for more details.
* @param channel The channel to remove all instances of the mode from
+ * @param stack The mode stack to add the mode change to
*/
- virtual void RemoveMode(Channel* channel, irc::modestacker* stack);
+ virtual void RemoveMode(Channel* channel, irc::modestacker& stack);
/** Listmodes don't get set on users, no-op
*/
diff --git a/include/mode.h b/include/mode.h
index b2e06257f..6afd00a86 100644
--- a/include/mode.h
+++ b/include/mode.h
@@ -100,6 +100,13 @@ enum ParamSpec
*/
class CoreExport ModeHandler : public ServiceProvider
{
+ /**
+ * Removes this prefix mode from all users on the given channel
+ * @param channel The channel which the server wants to remove your mode from
+ * @param stack The mode stack to add the mode change to
+ */
+ void RemovePrefixMode(Channel* chan, irc::modestacker& stack);
+
protected:
/**
* The mode parameter translation type
@@ -280,14 +287,15 @@ class CoreExport ModeHandler : public ServiceProvider
/**
* When a MODETYPE_CHANNEL mode handler is being removed, the server will call this method for every channel on the server.
- * Your mode handler should remove its user mode from the channel by sending the appropriate server modes using
- * InspIRCd::SendMode(). The default implementation of this method can remove simple modes which have no parameters,
- * and can be used when your mode is of this type, otherwise you must implement a more advanced version of it to remove
- * your mode properly from each channel. Note that in the case of listmodes, you should remove the entire list of items.
+ * The mode handler has to populate the given modestacker with mode changes that remove the mode from the channel.
+ * The default implementation of this method can remove all kinds of channel modes except listmodes.
+ * In the case of listmodes, the entire list of items must be added to the modestacker (which is handled by ListModeBase,
+ * so if you inherit from it or your mode can be removed by the default implementation then you do not have to implement
+ * this function).
* @param channel The channel which the server wants to remove your mode from
* @param stack The mode stack to add the mode change to
*/
- virtual void RemoveMode(Channel* channel, irc::modestacker* stack = NULL);
+ virtual void RemoveMode(Channel* channel, irc::modestacker& stack);
inline unsigned int GetLevelRequired() const { return levelrequired; }
};