summaryrefslogtreecommitdiff
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
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.)
-rw-r--r--include/inspircd.h21
-rw-r--r--include/mode.h32
-rw-r--r--include/protocol.h22
-rw-r--r--src/commands/cmd_mode.cpp2
-rw-r--r--src/mode.cpp9
-rw-r--r--src/modules.cpp7
-rw-r--r--src/modules/m_autoop.cpp2
-rw-r--r--src/modules/m_banredirect.cpp2
-rw-r--r--src/modules/m_channames.cpp2
-rw-r--r--src/modules/m_devoice.cpp2
-rw-r--r--src/modules/m_messageflood.cpp2
-rw-r--r--src/modules/m_namedmodes.cpp4
-rw-r--r--src/modules/m_ojoin.cpp2
-rw-r--r--src/modules/m_opermodes.cpp2
-rw-r--r--src/modules/m_operprefix.cpp2
-rw-r--r--src/modules/m_repeat.cpp2
-rw-r--r--src/modules/m_rmode.cpp2
-rw-r--r--src/modules/m_services_account.cpp2
-rw-r--r--src/modules/m_spanningtree/fjoin.cpp4
-rw-r--r--src/modules/m_spanningtree/fmode.cpp30
-rw-r--r--src/modules/m_spanningtree/main.cpp29
-rw-r--r--src/modules/m_spanningtree/main.h1
-rw-r--r--src/modules/m_spanningtree/protocolinterface.cpp39
-rw-r--r--src/modules/m_spanningtree/protocolinterface.h3
-rw-r--r--src/modules/m_timedbans.cpp2
25 files changed, 88 insertions, 139 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.
diff --git a/src/commands/cmd_mode.cpp b/src/commands/cmd_mode.cpp
index 746128a6b..adb1d483b 100644
--- a/src/commands/cmd_mode.cpp
+++ b/src/commands/cmd_mode.cpp
@@ -49,7 +49,7 @@ class CommandMode : public Command
*/
CmdResult CommandMode::Handle (const std::vector<std::string>& parameters, User *user)
{
- ServerInstance->Modes->Process(parameters, user, false);
+ ServerInstance->Modes->Process(parameters, user);
return CMD_SUCCESS;
}
diff --git a/src/mode.cpp b/src/mode.cpp
index 2f56c3327..63008f45c 100644
--- a/src/mode.cpp
+++ b/src/mode.cpp
@@ -331,7 +331,7 @@ ModeAction ModeParser::TryMode(User* user, User* targetuser, Channel* chan, bool
return MODEACTION_ALLOW;
}
-void ModeParser::Process(const std::vector<std::string>& parameters, User *user, bool merge)
+void ModeParser::Process(const std::vector<std::string>& parameters, User* user, ModeProcessFlag flags)
{
std::string target = parameters[0];
Channel* targetchannel = ServerInstance->FindChan(target);
@@ -411,7 +411,7 @@ void ModeParser::Process(const std::vector<std::string>& parameters, User *user,
/* Make sure the user isn't trying to slip in an invalid parameter */
if ((parameter.find(':') == 0) || (parameter.rfind(' ') != std::string::npos))
continue;
- if (merge && targetchannel && targetchannel->IsModeSet(modechar) && !mh->IsListMode())
+ if ((flags & MODE_MERGE) && targetchannel && targetchannel->IsModeSet(modechar) && !mh->IsListMode())
{
std::string ours = targetchannel->GetModeParameter(modechar);
if (!mh->ResolveModeConflict(parameter, ours, targetchannel))
@@ -465,6 +465,9 @@ void ModeParser::Process(const std::vector<std::string>& parameters, User *user,
LastParse.append(output_mode);
LastParse.append(output_parameters.str());
+ if (!(flags & MODE_LOCALONLY))
+ ServerInstance->PI->SendMode(user, targetuser, targetchannel, LastParseParams, LastParseTranslate);
+
if (targetchannel)
{
targetchannel->WriteChannel(user, "MODE %s", LastParse.c_str());
@@ -656,7 +659,7 @@ bool ModeParser::DelMode(ModeHandler* mh)
stackresult.push_back(chan->name);
while (stack.GetStackedLine(stackresult))
{
- ServerInstance->SendMode(stackresult, ServerInstance->FakeClient);
+ this->Process(stackresult, ServerInstance->FakeClient, MODE_LOCALONLY);
stackresult.erase(stackresult.begin() + 1, stackresult.end());
}
}
diff --git a/src/modules.cpp b/src/modules.cpp
index 8bd44ff68..039e01421 100644
--- a/src/modules.cpp
+++ b/src/modules.cpp
@@ -533,13 +533,6 @@ void dynamic_reference_base::resolve()
value = NULL;
}
-void InspIRCd::SendGlobalMode(const std::vector<std::string>& parameters, User *user)
-{
- Modes->Process(parameters, user);
- if (!Modes->GetLastParse().empty())
- this->PI->SendMode(parameters[0], Modes->GetLastParseParams(), Modes->GetLastParseTranslate());
-}
-
Module* ModuleManager::Find(const std::string &name)
{
std::map<std::string, Module*>::iterator modfind = Modules.find(name);
diff --git a/src/modules/m_autoop.cpp b/src/modules/m_autoop.cpp
index 85b14ba7a..9620a3a06 100644
--- a/src/modules/m_autoop.cpp
+++ b/src/modules/m_autoop.cpp
@@ -123,7 +123,7 @@ class ModuleAutoOp : public Module
for(std::string::size_type i = modeline.length(); i > 1; --i) // we use "i > 1" instead of "i" so we skip the +
modechange.push_back(memb->user->nick);
if(modechange.size() >= 3)
- ServerInstance->SendGlobalMode(modechange, ServerInstance->FakeClient);
+ ServerInstance->Modes->Process(modechange, ServerInstance->FakeClient);
}
}
diff --git a/src/modules/m_banredirect.cpp b/src/modules/m_banredirect.cpp
index 08b2244d4..a88324fe2 100644
--- a/src/modules/m_banredirect.cpp
+++ b/src/modules/m_banredirect.cpp
@@ -260,7 +260,7 @@ class ModuleBanRedirect : public Module
stackresult.push_back(chan->name);
while (modestack.GetStackedLine(stackresult))
{
- ServerInstance->Modes->Process(stackresult, ServerInstance->FakeClient);
+ ServerInstance->Modes->Process(stackresult, ServerInstance->FakeClient, ModeParser::MODE_LOCALONLY);
stackresult.erase(stackresult.begin() + 1, stackresult.end());
}
}
diff --git a/src/modules/m_channames.cpp b/src/modules/m_channames.cpp
index 52f781ae1..f1a4981c8 100644
--- a/src/modules/m_channames.cpp
+++ b/src/modules/m_channames.cpp
@@ -84,7 +84,7 @@ class ModuleChannelNames : public Module
modes.push_back(c->name);
modes.push_back("-P");
- ServerInstance->SendGlobalMode(modes, ServerInstance->FakeClient);
+ ServerInstance->Modes->Process(modes, ServerInstance->FakeClient);
}
const UserMembList* users = c->GetUsers();
for(UserMembCIter j = users->begin(); j != users->end(); )
diff --git a/src/modules/m_devoice.cpp b/src/modules/m_devoice.cpp
index 64604e90c..889658d20 100644
--- a/src/modules/m_devoice.cpp
+++ b/src/modules/m_devoice.cpp
@@ -46,7 +46,7 @@ class CommandDevoice : public Command
modes.push_back("-v");
modes.push_back(user->nick);
- ServerInstance->SendGlobalMode(modes, ServerInstance->FakeClient);
+ ServerInstance->Modes->Process(modes, ServerInstance->FakeClient);
return CMD_SUCCESS;
}
};
diff --git a/src/modules/m_messageflood.cpp b/src/modules/m_messageflood.cpp
index 65c3354a9..86296094b 100644
--- a/src/modules/m_messageflood.cpp
+++ b/src/modules/m_messageflood.cpp
@@ -156,7 +156,7 @@ class ModuleMsgFlood : public Module
parameters.push_back(dest->name);
parameters.push_back("+b");
parameters.push_back("*!*@" + user->dhost);
- ServerInstance->SendGlobalMode(parameters, ServerInstance->FakeClient);
+ ServerInstance->Modes->Process(parameters, ServerInstance->FakeClient);
}
const std::string kickMessage = "Channel flood triggered (limit is " + ConvToStr(f->lines) +
diff --git a/src/modules/m_namedmodes.cpp b/src/modules/m_namedmodes.cpp
index 3e27092a7..26b6339a3 100644
--- a/src/modules/m_namedmodes.cpp
+++ b/src/modules/m_namedmodes.cpp
@@ -82,7 +82,7 @@ class CommandProp : public Command
}
}
}
- ServerInstance->SendGlobalMode(modes, src);
+ ServerInstance->Modes->Process(modes, src);
return CMD_SUCCESS;
}
};
@@ -196,7 +196,7 @@ class ModuleNamedModes : public Module
}
}
newparms[1] = modelist;
- ServerInstance->Modes->Process(newparms, source, false);
+ ServerInstance->Modes->Process(newparms, source);
return MOD_RES_DENY;
}
};
diff --git a/src/modules/m_ojoin.cpp b/src/modules/m_ojoin.cpp
index 999cd5b64..4aec2933a 100644
--- a/src/modules/m_ojoin.cpp
+++ b/src/modules/m_ojoin.cpp
@@ -93,7 +93,7 @@ class CommandOjoin : public SplitCommand
modes.push_back(user->nick);
if (op)
modes.push_back(user->nick);
- ServerInstance->SendGlobalMode(modes, ServerInstance->FakeClient);
+ ServerInstance->Modes->Process(modes, ServerInstance->FakeClient);
}
return CMD_SUCCESS;
}
diff --git a/src/modules/m_opermodes.cpp b/src/modules/m_opermodes.cpp
index 5752ff48d..4d4fcd998 100644
--- a/src/modules/m_opermodes.cpp
+++ b/src/modules/m_opermodes.cpp
@@ -67,7 +67,7 @@ class ModuleModesOnOper : public Module
while (ss >> buf)
modes.push_back(buf);
- ServerInstance->SendMode(modes, u);
+ ServerInstance->Modes->Process(modes, u);
}
};
diff --git a/src/modules/m_operprefix.cpp b/src/modules/m_operprefix.cpp
index 9c15cf5b2..0f4cdbea1 100644
--- a/src/modules/m_operprefix.cpp
+++ b/src/modules/m_operprefix.cpp
@@ -108,7 +108,7 @@ class ModuleOperPrefixMode : public Module
for (UCListIter v = user->chans.begin(); v != user->chans.end(); v++)
{
modechange[0] = (*v)->name;
- ServerInstance->SendGlobalMode(modechange, ServerInstance->FakeClient);
+ ServerInstance->Modes->Process(modechange, ServerInstance->FakeClient);
}
}
diff --git a/src/modules/m_repeat.cpp b/src/modules/m_repeat.cpp
index 5be0fd622..86f26016d 100644
--- a/src/modules/m_repeat.cpp
+++ b/src/modules/m_repeat.cpp
@@ -401,7 +401,7 @@ class RepeatModule : public Module
parameters.push_back(memb->chan->name);
parameters.push_back("+b");
parameters.push_back("*!*@" + user->dhost);
- ServerInstance->SendGlobalMode(parameters, ServerInstance->FakeClient);
+ ServerInstance->Modes->Process(parameters, ServerInstance->FakeClient);
}
memb->chan->KickUser(ServerInstance->FakeClient, user, "Repeat flood");
diff --git a/src/modules/m_rmode.cpp b/src/modules/m_rmode.cpp
index 8259d406c..f5e6433bf 100644
--- a/src/modules/m_rmode.cpp
+++ b/src/modules/m_rmode.cpp
@@ -100,7 +100,7 @@ class CommandRMode : public Command
stackresult.push_back(chan->name);
while (modestack.GetStackedLine(stackresult))
{
- ServerInstance->SendMode(stackresult, user);
+ ServerInstance->Modes->Process(stackresult, user);
stackresult.erase(stackresult.begin() + 1, stackresult.end());
}
diff --git a/src/modules/m_services_account.cpp b/src/modules/m_services_account.cpp
index e42c02ff2..123132ca9 100644
--- a/src/modules/m_services_account.cpp
+++ b/src/modules/m_services_account.cpp
@@ -159,7 +159,7 @@ class ModuleServicesAccount : public Module
std::vector<std::string> modechange;
modechange.push_back(user->nick);
modechange.push_back("-r");
- ServerInstance->SendMode(modechange, ServerInstance->FakeClient);
+ ServerInstance->Modes->Process(modechange, ServerInstance->FakeClient, ModeParser::MODE_LOCALONLY);
}
}
diff --git a/src/modules/m_spanningtree/fjoin.cpp b/src/modules/m_spanningtree/fjoin.cpp
index b25444cda..faf534542 100644
--- a/src/modules/m_spanningtree/fjoin.cpp
+++ b/src/modules/m_spanningtree/fjoin.cpp
@@ -130,7 +130,7 @@ CmdResult CommandFJoin::Handle(const std::vector<std::string>& params, User *src
/* Remember, params[params.size() - 1] is userlist, and we don't want to apply *that* */
modelist.insert(modelist.end(), params.begin()+2, params.end()-1);
- ServerInstance->SendMode(modelist, srcuser);
+ ServerInstance->Modes->Process(modelist, srcuser, ModeParser::MODE_LOCALONLY | ModeParser::MODE_MERGE);
}
irc::modestacker modestack(true);
@@ -222,7 +222,7 @@ void CommandFJoin::ApplyModeStack(User* srcuser, Channel* c, irc::modestacker& s
while (stack.GetStackedLine(stackresult))
{
- ServerInstance->SendMode(stackresult, srcuser);
+ ServerInstance->Modes->Process(stackresult, srcuser, ModeParser::MODE_LOCALONLY);
stackresult.erase(stackresult.begin() + 1, stackresult.end());
}
}
diff --git a/src/modules/m_spanningtree/fmode.cpp b/src/modules/m_spanningtree/fmode.cpp
index 7be904faf..9a72c5f05 100644
--- a/src/modules/m_spanningtree/fmode.cpp
+++ b/src/modules/m_spanningtree/fmode.cpp
@@ -55,23 +55,25 @@ CmdResult CommandFMode::Handle(const std::vector<std::string>& params, User *who
ourTS = user->age;
}
- /* TS is equal or less: Merge the mode changes into ours and pass on.
+ /* If the TS is greater than ours, we drop the mode and don't pass it anywhere.
*/
- if (TS <= ourTS)
- {
- std::vector<std::string> modelist;
- modelist.reserve(params.size()-1);
- /* Insert everything into modelist except the TS (params[1]) */
- modelist.push_back(params[0]);
- modelist.insert(modelist.end(), params.begin()+2, params.end());
+ if (TS > ourTS)
+ return CMD_FAILURE;
- bool merge = (TS == ourTS) && IS_SERVER(who);
- ServerInstance->Modes->Process(modelist, who, merge);
- return CMD_SUCCESS;
- }
- /* If the TS is greater than ours, we drop the mode and dont pass it anywhere.
+ /* TS is equal or less: Merge the mode changes into ours and pass on.
*/
- return CMD_FAILURE;
+ std::vector<std::string> modelist;
+ modelist.reserve(params.size()-1);
+ /* Insert everything into modelist except the TS (params[1]) */
+ modelist.push_back(params[0]);
+ modelist.insert(modelist.end(), params.begin()+2, params.end());
+
+ ModeParser::ModeProcessFlag flags = ModeParser::MODE_LOCALONLY;
+ if ((TS == ourTS) && IS_SERVER(who))
+ flags |= ModeParser::MODE_MERGE;
+
+ ServerInstance->Modes->Process(modelist, who, flags);
+ return CMD_SUCCESS;
}
diff --git a/src/modules/m_spanningtree/main.cpp b/src/modules/m_spanningtree/main.cpp
index 9af4bfd0c..8c5439fbb 100644
--- a/src/modules/m_spanningtree/main.cpp
+++ b/src/modules/m_spanningtree/main.cpp
@@ -77,7 +77,7 @@ void ModuleSpanningTree::init()
I_OnUserMessage, I_OnBackgroundTimer, I_OnUserJoin,
I_OnChangeHost, I_OnChangeName, I_OnChangeIdent, I_OnUserPart, I_OnUnloadModule,
I_OnUserQuit, I_OnUserPostNick, I_OnUserKick, I_OnRehash, I_OnPreRehash,
- I_OnOper, I_OnAddLine, I_OnDelLine, I_OnMode, I_OnLoadModule, I_OnStats,
+ I_OnOper, I_OnAddLine, I_OnDelLine, I_OnLoadModule, I_OnStats,
I_OnSetAway, I_OnPostCommand, I_OnUserConnect, I_OnAcceptConnection
};
ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation));
@@ -793,33 +793,6 @@ void ModuleSpanningTree::OnDelLine(User* user, XLine *x)
}
}
-void ModuleSpanningTree::OnMode(User* user, void* dest, int target_type, const parameterlist &text, const std::vector<TranslateType> &translate)
-{
- if ((IS_LOCAL(user)) && (user->registered == REG_ALL))
- {
- parameterlist params;
- std::string output_text;
-
- ServerInstance->Parser->TranslateUIDs(translate, text, output_text);
-
- if (target_type == TYPE_USER)
- {
- User* u = (User*)dest;
- params.push_back(u->uuid);
- params.push_back(output_text);
- Utils->DoOneToMany(user->uuid, "MODE", params);
- }
- else
- {
- Channel* c = (Channel*)dest;
- params.push_back(c->name);
- params.push_back(ConvToStr(c->age));
- params.push_back(output_text);
- Utils->DoOneToMany(user->uuid, "FMODE", params);
- }
- }
-}
-
ModResult ModuleSpanningTree::OnSetAway(User* user, const std::string &awaymsg)
{
if (IS_LOCAL(user))
diff --git a/src/modules/m_spanningtree/main.h b/src/modules/m_spanningtree/main.h
index 22357aed4..28ebbc373 100644
--- a/src/modules/m_spanningtree/main.h
+++ b/src/modules/m_spanningtree/main.h
@@ -163,7 +163,6 @@ class ModuleSpanningTree : public Module
void OnLine(User* source, const std::string &host, bool adding, char linetype, long duration, const std::string &reason);
void OnAddLine(User *u, XLine *x) CXX11_OVERRIDE;
void OnDelLine(User *u, XLine *x) CXX11_OVERRIDE;
- void OnMode(User* user, void* dest, int target_type, const std::vector<std::string> &text, const std::vector<TranslateType> &translate) CXX11_OVERRIDE;
ModResult OnStats(char statschar, User* user, string_list &results) CXX11_OVERRIDE;
ModResult OnSetAway(User* user, const std::string &awaymsg) CXX11_OVERRIDE;
void ProtoSendMode(void* opaque, TargetTypeFlags target_type, void* target, const std::vector<std::string> &modeline, const std::vector<TranslateType> &translate);
diff --git a/src/modules/m_spanningtree/protocolinterface.cpp b/src/modules/m_spanningtree/protocolinterface.cpp
index 93a138758..ce824fef8 100644
--- a/src/modules/m_spanningtree/protocolinterface.cpp
+++ b/src/modules/m_spanningtree/protocolinterface.cpp
@@ -89,35 +89,28 @@ void SpanningTreeProtocolInterface::SendTopic(Channel* channel, std::string &top
Utils->DoOneToMany(ServerInstance->Config->GetSID(),"FTOPIC", params);
}
-void SpanningTreeProtocolInterface::SendMode(const std::string &target, const parameterlist &modedata, const std::vector<TranslateType> &translate)
+void SpanningTreeProtocolInterface::SendMode(User* source, User* u, Channel* c, const parameterlist& modedata, const std::vector<TranslateType>& translate)
{
- if (modedata.empty())
- return;
-
- std::string outdata;
- ServerInstance->Parser->TranslateUIDs(translate, modedata, outdata);
-
- std::string uidtarget;
- ServerInstance->Parser->TranslateUIDs(TR_NICK, target, uidtarget);
-
- parameterlist outlist;
- outlist.push_back(uidtarget);
- outlist.push_back(outdata);
+ parameterlist params;
- User* a = ServerInstance->FindNick(uidtarget);
- if (a)
+ if (u)
{
- Utils->DoOneToMany(ServerInstance->Config->GetSID(),"MODE",outlist);
- return;
+ if (u->registered != REG_ALL)
+ return;
+
+ params.push_back(u->uuid);
+ params.insert(params.end(), modedata.begin(), modedata.end());
+ Utils->DoOneToMany(source->uuid, "MODE", params);
}
else
{
- Channel* c = ServerInstance->FindChan(target);
- if (c)
- {
- outlist.insert(outlist.begin() + 1, ConvToStr(c->age));
- Utils->DoOneToMany(ServerInstance->Config->GetSID(),"FMODE",outlist);
- }
+ std::string output_text;
+ ServerInstance->Parser->TranslateUIDs(translate, modedata, output_text);
+
+ params.push_back(c->name);
+ params.push_back(ConvToStr(c->age));
+ params.push_back(output_text);
+ Utils->DoOneToMany(source->uuid, "FMODE", params);
}
}
diff --git a/src/modules/m_spanningtree/protocolinterface.h b/src/modules/m_spanningtree/protocolinterface.h
index 80a21c49b..2b4c4371f 100644
--- a/src/modules/m_spanningtree/protocolinterface.h
+++ b/src/modules/m_spanningtree/protocolinterface.h
@@ -25,14 +25,13 @@ class ModuleSpanningTree;
class SpanningTreeProtocolInterface : public ProtocolInterface
{
SpanningTreeUtilities* Utils;
- void SendChannel(Channel* target, char status, const std::string &text);
public:
SpanningTreeProtocolInterface(SpanningTreeUtilities* util) : Utils(util) { }
bool SendEncapsulatedData(const parameterlist &encap);
void SendMetaData(Extensible* target, const std::string &key, const std::string &data);
void SendTopic(Channel* channel, std::string &topic);
- void SendMode(const std::string &target, const parameterlist &modedata, const std::vector<TranslateType> &types);
+ void SendMode(User* source, User* usertarget, Channel* chantarget, const parameterlist& modedata, const std::vector<TranslateType>& types);
void SendSNONotice(const std::string &snomask, const std::string &text);
void PushToClient(User* target, const std::string &rawline);
void SendChannelPrivmsg(Channel* target, char status, const std::string &text);
diff --git a/src/modules/m_timedbans.cpp b/src/modules/m_timedbans.cpp
index a76d89c82..93245432d 100644
--- a/src/modules/m_timedbans.cpp
+++ b/src/modules/m_timedbans.cpp
@@ -195,7 +195,7 @@ class ModuleTimedBans : public Module
cr->WriteAllExcept(ServerInstance->FakeClient, true, '@', empty, "NOTICE %s :%s", cr->name.c_str(), expiry.c_str());
ServerInstance->PI->SendChannelNotice(cr, '@', expiry);
- ServerInstance->SendGlobalMode(setban, ServerInstance->FakeClient);
+ ServerInstance->Modes->Process(setban, ServerInstance->FakeClient);
}
}
}