diff options
author | danieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7> | 2009-03-07 01:29:45 +0000 |
---|---|---|
committer | danieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7> | 2009-03-07 01:29:45 +0000 |
commit | 96a4a1d41e42dba806c2e9954e148ed838262511 (patch) | |
tree | 3d1b2679437012f10133182d0aa8a8d9b7479350 /src | |
parent | 526f5a4a02882b19056fe755dff1f64b764ff313 (diff) |
Include explicit parameter list in ProtocolInterface::SendMode
Also leave the strings split into deque, there's no need to pack it into a
string just to unpack it during the translate.
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@11181 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src')
-rw-r--r-- | src/command_parse.cpp | 11 | ||||
-rw-r--r-- | src/mode.cpp | 13 | ||||
-rw-r--r-- | src/modules.cpp | 4 | ||||
-rw-r--r-- | src/modules/m_opermodes.cpp | 6 | ||||
-rw-r--r-- | src/modules/m_samode.cpp | 15 | ||||
-rw-r--r-- | src/modules/m_spanningtree/main.cpp | 4 | ||||
-rw-r--r-- | src/modules/m_spanningtree/main.h | 4 | ||||
-rw-r--r-- | src/modules/m_spanningtree/protocolinterface.cpp | 21 | ||||
-rw-r--r-- | src/modules/m_spanningtree/protocolinterface.h | 2 |
9 files changed, 37 insertions, 43 deletions
diff --git a/src/command_parse.cpp b/src/command_parse.cpp index d0b114816..92428fd32 100644 --- a/src/command_parse.cpp +++ b/src/command_parse.cpp @@ -609,19 +609,20 @@ void CommandParser::SetupCommandTable() this->CreateCommand(new CommandReload(ServerInstance)); } -int CommandParser::TranslateUIDs(const std::vector<TranslateType> to, const std::string &source, std::string &dest) +int CommandParser::TranslateUIDs(const std::deque<TranslateType> to, const std::deque<std::string> &source, std::string &dest) { - irc::spacesepstream items(source); - std::vector<TranslateType>::const_iterator types = to.begin(); + std::deque<std::string>::const_iterator items = source.begin(); + std::deque<TranslateType>::const_iterator types = to.begin(); User* user = NULL; - std::string item; int translations = 0; dest.clear(); - while (items.GetToken(item)) + while (items != source.end() && types != to.end()) { TranslateType t = *types; + std::string item = *items; types++; + items++; switch (t) { diff --git a/src/mode.cpp b/src/mode.cpp index da8f10294..40bd70963 100644 --- a/src/mode.cpp +++ b/src/mode.cpp @@ -371,6 +371,8 @@ void ModeParser::Process(const std::vector<std::string>& parameters, User *user, User* targetuser = ServerInstance->FindNick(parameters[0]); LastParse.clear(); + LastParseParams.clear(); + LastParseTranslate.clear(); /* Special case for displaying the list for listmodes, * e.g. MODE #chan b, or MODE #chan +b without a parameter @@ -503,14 +505,13 @@ void ModeParser::Process(const std::vector<std::string>& parameters, User *user, std::string mode_sequence = parameters[1]; std::string parameter; std::ostringstream parameter_list; - std::vector<TranslateType> parameter_xlate; - parameter_xlate.push_back(TR_TEXT); std::string output_sequence; bool adding = true, state_change = false; unsigned char handler_id = 0; unsigned int parameter_counter = 2; /* Index of first parameter */ unsigned int parameter_count = 0; bool last_successful_state_change = false; + LastParseTranslate.push_back(TR_TEXT); /* A mode sequence that doesnt start with + or -. Assume +. - Thanks for the suggestion spike (bug#132) */ if ((*mode_sequence.begin() != '+') && (*mode_sequence.begin() != '-')) @@ -717,7 +718,8 @@ void ModeParser::Process(const std::vector<std::string>& parameters, User *user, if ((modehandlers[handler_id]->GetNumParams(adding)) && (!parameter.empty())) { parameter_list << " " << parameter; - parameter_xlate.push_back(modehandlers[handler_id]->GetTranslateType()); + LastParseParams.push_back(parameter); + LastParseTranslate.push_back(modehandlers[handler_id]->GetTranslateType()); parameter_count++; /* Does this mode have a prefix? */ if (modehandlers[handler_id]->GetPrefix() && targetchannel) @@ -773,16 +775,17 @@ void ModeParser::Process(const std::vector<std::string>& parameters, User *user, } else { + LastParseParams.push_front(output_sequence); if (type == MODETYPE_CHANNEL) { targetchannel->WriteChannel(user, "MODE %s %s%s", targetchannel->name.c_str(), output_sequence.c_str(), parameter_list.str().c_str()); - FOREACH_MOD(I_OnMode,OnMode(user, targetchannel, TYPE_CHANNEL, output_sequence + parameter_list.str(), parameter_xlate)); + FOREACH_MOD(I_OnMode,OnMode(user, targetchannel, TYPE_CHANNEL, LastParseParams, LastParseTranslate)); this->LastParse = targetchannel->name; } else { user->WriteTo(targetuser, "MODE %s %s%s", targetuser->nick.c_str(), output_sequence.c_str(), parameter_list.str().c_str()); - FOREACH_MOD(I_OnMode,OnMode(user, targetuser, TYPE_USER, output_sequence + parameter_list.str(), parameter_xlate)); + FOREACH_MOD(I_OnMode,OnMode(user, targetuser, TYPE_USER, LastParseParams, LastParseTranslate)); this->LastParse = targetuser->nick; } } diff --git a/src/modules.cpp b/src/modules.cpp index 2d8c9387f..7bce6161b 100644 --- a/src/modules.cpp +++ b/src/modules.cpp @@ -116,7 +116,7 @@ void Module::OnPostJoin(User*, Channel*) { } void Module::OnUserPart(User*, Channel*, std::string&, bool&) { } void Module::OnRehash(User*, const std::string&) { } int Module::OnUserPreJoin(User*, Channel*, const char*, std::string&, const std::string&) { return 0; } -void Module::OnMode(User*, void*, int, const std::string&, const std::vector<TranslateType>&) { } +void Module::OnMode(User*, void*, int, const std::deque<std::string>&, const std::deque<TranslateType>&) { } Version Module::GetVersion() { return Version("Misconfigured", VF_VENDOR, -1); } void Module::OnOper(User*, const std::string&) { } void Module::OnPostOper(User*, const std::string&, const std::string &) { } @@ -170,7 +170,7 @@ void Module::OnPostLocalTopicChange(User*, Channel*, const std::string&) { } void Module::OnGetServerDescription(const std::string&, std::string&) { } void Module::OnSyncUser(User*, Module*, void*) { } void Module::OnSyncChannel(Channel*, Module*, void*) { } -void Module::ProtoSendMode(void*, TargetTypeFlags, void*, const std::string&, const std::vector<TranslateType>&) { } +void Module::ProtoSendMode(void*, TargetTypeFlags, void*, const std::deque<std::string>&, const std::deque<TranslateType>&) { } void Module::OnSyncChannelMetaData(Channel*, Module*, void*, const std::string&, bool) { } void Module::OnSyncUserMetaData(User*, Module*, void*, const std::string&, bool) { } void Module::OnSyncOtherMetaData(Module*, void*, bool) { } diff --git a/src/modules/m_opermodes.cpp b/src/modules/m_opermodes.cpp index 2e947809a..f72f007c4 100644 --- a/src/modules/m_opermodes.cpp +++ b/src/modules/m_opermodes.cpp @@ -109,10 +109,14 @@ class ModuleModesOnOper : public Module } std::deque<std::string> n; + std::deque<TranslateType> t; for (unsigned int j = 1; j < tokens.size(); j++) + { n.push_back(modes[j]); + t.push_back(TR_TEXT); + } - ServerInstance->PI->SendMode(u->uuid, n); + ServerInstance->PI->SendMode(u->uuid, n, t); ServerInstance->SendMode(modes, u); } }; diff --git a/src/modules/m_samode.cpp b/src/modules/m_samode.cpp index 82055dad3..fdc107466 100644 --- a/src/modules/m_samode.cpp +++ b/src/modules/m_samode.cpp @@ -37,20 +37,9 @@ class CommandSamode : public Command { ServerInstance->SNO->WriteToSnoMask('A', std::string(user->nick) + " used SAMODE: " + ServerInstance->Modes->GetLastParse()); - std::deque<std::string> n; - irc::spacesepstream spaced(ServerInstance->Modes->GetLastParse()); - std::string one; - while (spaced.GetToken(one)) - n.push_back(one); + std::string channel = parameters[0]; + ServerInstance->PI->SendMode(channel, ServerInstance->Modes->GetLastParseParams(), ServerInstance->Modes->GetLastParseTranslate()); - std::string channel = n[0]; - n.pop_front(); - ServerInstance->PI->SendMode(channel, n); - - /* XXX: Yes, this is right. We dont want to propagate the - * actual SAMODE command, just the MODE command generated - * by the Protocol Interface - */ return CMD_LOCALONLY; } else diff --git a/src/modules/m_spanningtree/main.cpp b/src/modules/m_spanningtree/main.cpp index 51a9eb025..3d2056eb6 100644 --- a/src/modules/m_spanningtree/main.cpp +++ b/src/modules/m_spanningtree/main.cpp @@ -800,7 +800,7 @@ void ModuleSpanningTree::OnDelLine(User* user, XLine *x) } } -void ModuleSpanningTree::OnMode(User* user, void* dest, int target_type, const std::string &text, const std::vector<TranslateType> &translate) +void ModuleSpanningTree::OnMode(User* user, void* dest, int target_type, const std::deque<std::string> &text, const std::deque<TranslateType> &translate) { if ((IS_LOCAL(user)) && (user->registered == REG_ALL)) { @@ -851,7 +851,7 @@ int ModuleSpanningTree::OnSetAway(User* user, const std::string &awaymsg) return 0; } -void ModuleSpanningTree::ProtoSendMode(void* opaque, TargetTypeFlags target_type, void* target, const std::string &modeline, const std::vector<TranslateType> &translate) +void ModuleSpanningTree::ProtoSendMode(void* opaque, TargetTypeFlags target_type, void* target, const std::deque<std::string> &modeline, const std::deque<TranslateType> &translate) { TreeSocket* s = (TreeSocket*)opaque; std::string output_text; diff --git a/src/modules/m_spanningtree/main.h b/src/modules/m_spanningtree/main.h index 19ec2d43c..a0900dd33 100644 --- a/src/modules/m_spanningtree/main.h +++ b/src/modules/m_spanningtree/main.h @@ -174,10 +174,10 @@ class ModuleSpanningTree : public Module void OnLine(User* source, const std::string &host, bool adding, char linetype, long duration, const std::string &reason); virtual void OnAddLine(User *u, XLine *x); virtual void OnDelLine(User *u, XLine *x); - virtual void OnMode(User* user, void* dest, int target_type, const std::string &text, const std::vector<TranslateType> &translate); + virtual void OnMode(User* user, void* dest, int target_type, const std::deque<std::string> &text, const std::deque<TranslateType> &translate); virtual int OnStats(char statschar, User* user, string_list &results); virtual int OnSetAway(User* user, const std::string &awaymsg); - virtual void ProtoSendMode(void* opaque, TargetTypeFlags target_type, void* target, const std::string &modeline, const std::vector<TranslateType> &translate); + virtual void ProtoSendMode(void* opaque, TargetTypeFlags target_type, void* target, const std::deque<std::string> &modeline, const std::deque<TranslateType> &translate); virtual void ProtoSendMetaData(void* opaque, TargetTypeFlags target_type, void* target, const std::string &extname, const std::string &extdata); virtual void OnEvent(Event* event); virtual void OnLoadModule(Module* mod,const std::string &name); diff --git a/src/modules/m_spanningtree/protocolinterface.cpp b/src/modules/m_spanningtree/protocolinterface.cpp index 9f32963a0..cfc9bbea7 100644 --- a/src/modules/m_spanningtree/protocolinterface.cpp +++ b/src/modules/m_spanningtree/protocolinterface.cpp @@ -68,28 +68,25 @@ void SpanningTreeProtocolInterface::SendTopic(Channel* channel, std::string &top Utils->DoOneToMany(ServerInstance->Config->GetSID(),"FTOPIC", params); } -void SpanningTreeProtocolInterface::SendMode(const std::string &target, parameterlist &modedata) +void SpanningTreeProtocolInterface::SendMode(const std::string &target, const parameterlist &modedata, const std::deque<TranslateType> &translate) { if (modedata.empty()) return; std::string outdata; - - /* Warning: in-place translation is only safe for type TR_NICK */ - for (size_t n = 0; n < modedata.size(); n++) - { - ServerInstance->Parser->TranslateUIDs(TR_NICK, modedata[n], outdata); - modedata[n] = outdata; - } + ServerInstance->Parser->TranslateUIDs(translate, modedata, outdata); std::string uidtarget; ServerInstance->Parser->TranslateUIDs(TR_NICK, target, uidtarget); - modedata.insert(modedata.begin(), uidtarget); + + parameterlist outlist; + outlist.push_back(uidtarget); + outlist.push_back(outdata); User* a = ServerInstance->FindNick(uidtarget); if (a) { - Utils->DoOneToMany(ServerInstance->Config->GetSID(),"MODE",modedata); + Utils->DoOneToMany(ServerInstance->Config->GetSID(),"MODE",outlist); return; } else @@ -97,8 +94,8 @@ void SpanningTreeProtocolInterface::SendMode(const std::string &target, paramete Channel* c = ServerInstance->FindChan(target); if (c) { - modedata.insert(modedata.begin() + 1, ConvToStr(c->age)); - Utils->DoOneToMany(ServerInstance->Config->GetSID(),"FMODE",modedata); + outlist.insert(outlist.begin() + 1, ConvToStr(c->age)); + Utils->DoOneToMany(ServerInstance->Config->GetSID(),"FMODE",outlist); } } } diff --git a/src/modules/m_spanningtree/protocolinterface.h b/src/modules/m_spanningtree/protocolinterface.h index 50db7bf05..24b0cee20 100644 --- a/src/modules/m_spanningtree/protocolinterface.h +++ b/src/modules/m_spanningtree/protocolinterface.h @@ -16,7 +16,7 @@ class SpanningTreeProtocolInterface : public ProtocolInterface virtual void SendEncapsulatedData(parameterlist &encap); virtual void SendMetaData(void* target, TargetTypeFlags type, const std::string &key, const std::string &data); virtual void SendTopic(Channel* channel, std::string &topic); - virtual void SendMode(const std::string &target, parameterlist &modedata); + virtual void SendMode(const std::string &target, const parameterlist &modedata, const std::deque<TranslateType> &types); virtual void SendModeNotice(const std::string &modes, const std::string &text); virtual void SendSNONotice(const std::string &snomask, const std::string &text); virtual void PushToClient(User* target, const std::string &rawline); |