summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorattilamolnar <attilamolnar@hush.com>2013-06-13 18:15:34 +0200
committerattilamolnar <attilamolnar@hush.com>2013-06-13 18:15:34 +0200
commit3624c137a6db85eaab0372550c9dca79d6d21e55 (patch)
treecdfd14b2522583e057db26a2104397c05dc56c68 /include
parentb390ded3f3924cbd16a5dab53a981be279360124 (diff)
Introduce ModeProcessFlags, can be passed to ModeParser::Process() to indicate local only mode changes and mode merges
Change ProtocolInterface::SendMode() to take source and destination parameters, and call it from the mode parser whenever the mode change is global This deprecates the ambiguous InspIRCd::SendMode() and InspIRCd::SendGlobalMode() interface (the latter sent mode changes originating from local users twice, etc.)
Diffstat (limited to 'include')
-rw-r--r--include/inspircd.h21
-rw-r--r--include/mode.h32
-rw-r--r--include/protocol.h22
3 files changed, 31 insertions, 44 deletions
diff --git a/include/inspircd.h b/include/inspircd.h
index 22a0bfaa5..aa6be2dee 100644
--- a/include/inspircd.h
+++ b/include/inspircd.h
@@ -554,22 +554,6 @@ class CoreExport InspIRCd
Modules->AddService(*f);
}
- /** Send a modechange.
- * The parameters provided are identical to that sent to the
- * handler for class cmd_mode.
- * @param parameters The mode parameters
- * @param user The user to send error messages to
- */
- void SendMode(const std::vector<std::string>& parameters, User *user);
-
- /** Send a modechange and route it to the network.
- * The parameters provided are identical to that sent to the
- * handler for class cmd_mode.
- * @param parameters The mode parameters
- * @param user The user to send error messages to
- */
- void SendGlobalMode(const std::vector<std::string>& parameters, User *user);
-
/** Match two strings using pattern matching, optionally, with a map
* to check case against (may be NULL). If map is null, match will be case insensitive.
* @param str The literal string to match against
@@ -763,8 +747,3 @@ class CommandModule : public Module
return Version(cmd.name, VF_VENDOR|VF_CORE);
}
};
-
-inline void InspIRCd::SendMode(const std::vector<std::string>& parameters, User* user)
-{
- this->Modes->Process(parameters, user);
-}
diff --git a/include/mode.h b/include/mode.h
index 3805b174b..9b8d07877 100644
--- a/include/mode.h
+++ b/include/mode.h
@@ -471,6 +471,29 @@ class CoreExport ModeParser
std::string Cached004ModeList;
public:
+ typedef unsigned int ModeProcessFlag;
+ enum ModeProcessFlags
+ {
+ /** If only this flag is specified, the mode change will be global
+ * and parameter modes will have their parameters explicitly set
+ * (not merged). This is the default.
+ */
+ MODE_NONE = 0,
+
+ /** If this flag is set then the parameters of non-listmodes will be
+ * merged according to their conflict resolution rules.
+ * Does not affect user modes, channel modes without a parameter and
+ * listmodes.
+ */
+ MODE_MERGE = 1,
+
+ /** If this flag is set then the mode change won't be handed over to
+ * the linking module to be sent to other servers, but will be processed
+ * locally and sent to local user(s) as usual.
+ */
+ MODE_LOCALONLY = 2
+ };
+
ModeParser();
~ModeParser();
@@ -533,12 +556,11 @@ class CoreExport ModeParser
/** Process a set of mode changes from a server or user.
* @param parameters The parameters of the mode change, in the format
* they would be from a MODE command.
- * @param user The user setting or removing the modes. When the modes are set
- * by a server, an 'uninitialized' User is used, where *user\::nick == NULL
- * and *user->server == NULL.
- * @param merge Should the mode parameters be merged?
+ * @param user The source of the mode change, can be a server user.
+ * @param flags Optional flags controlling how the mode change is processed,
+ * defaults to MODE_NONE.
*/
- void Process(const std::vector<std::string>& parameters, User *user, bool merge = false);
+ void Process(const std::vector<std::string>& parameters, User* user, ModeProcessFlag flags = MODE_NONE);
/** Find the mode handler for a given mode and type.
* @param modeletter mode letter to search for
diff --git a/include/protocol.h b/include/protocol.h
index 4488fcea4..eedca50ec 100644
--- a/include/protocol.h
+++ b/include/protocol.h
@@ -68,27 +68,13 @@ class ProtocolInterface
virtual void SendTopic(Channel* channel, std::string &topic) { }
/** Send mode changes for an object.
- * @param target The channel name or user to send mode changes for.
+ * @param source The source of the mode change
+ * @param usertarget The target user, NULL if the target is a channel
+ * @param chantarget The target channel, NULL if the target is a user
* @param modedata The mode changes to send.
* @param translate A list of translation types
*/
- virtual void SendMode(const std::string &target, const parameterlist &modedata, const std::vector<TranslateType> &translate) { }
-
- /** Convenience function, string wrapper around the above.
- */
- virtual void SendModeStr(const std::string &target, const std::string &modeline)
- {
- irc::spacesepstream x(modeline);
- parameterlist n;
- std::vector<TranslateType> types;
- std::string v;
- while (x.GetToken(v))
- {
- n.push_back(v);
- types.push_back(TR_TEXT);
- }
- SendMode(target, n, types);
- }
+ virtual void SendMode(User* source, User* usertarget, Channel* chantarget, const parameterlist& modedata, const std::vector<TranslateType>& translate) { }
/** Send a notice to users with a given snomask.
* @param snomask The snomask required for the message to be sent.