diff options
-rw-r--r-- | include/command_parse.h | 2 | ||||
-rw-r--r-- | include/inspircd.h | 1 | ||||
-rw-r--r-- | include/mode.h | 4 | ||||
-rw-r--r-- | include/modules.h | 4 | ||||
-rw-r--r-- | include/protocol.h | 8 | ||||
-rw-r--r-- | include/u_listmode.h | 8 | ||||
-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 |
15 files changed, 53 insertions, 54 deletions
diff --git a/include/command_parse.h b/include/command_parse.h index 21dae89dd..6f6b96ca1 100644 --- a/include/command_parse.h +++ b/include/command_parse.h @@ -203,7 +203,7 @@ class CoreExport CommandParser : public classbase */ int TranslateUIDs(TranslateType to, const std::string &source, std::string &dest); - int TranslateUIDs(const std::vector<TranslateType> to, const std::string &source, std::string &dest); + int TranslateUIDs(const std::deque<TranslateType> to, const std::deque<std::string> &source, std::string &dest); }; /** Command handler class for the RELOAD command. diff --git a/include/inspircd.h b/include/inspircd.h index fcd6849d5..5461adcca 100644 --- a/include/inspircd.h +++ b/include/inspircd.h @@ -721,7 +721,6 @@ class CoreExport InspIRCd : public classbase * The parameters provided are identical to that sent to the * handler for class cmd_mode. * @param parameters The mode parameters - * @param pcnt The number of items you have given in the first parameter * @param user The user to send error messages to */ void SendMode(const std::vector<std::string>& parameters, User *user); diff --git a/include/mode.h b/include/mode.h index 525a26208..94d9f3dfe 100644 --- a/include/mode.h +++ b/include/mode.h @@ -445,6 +445,8 @@ class CoreExport ModeParser : public classbase * Use GetLastParse() to get this value, to be used for display purposes. */ std::string LastParse; + std::deque<std::string> LastParseParams; + std::deque<TranslateType> LastParseTranslate; unsigned int sent[256]; @@ -486,6 +488,8 @@ class CoreExport ModeParser : public classbase * @return Last parsed string, as seen by users. */ const std::string& GetLastParse(); + const std::deque<std::string>& GetLastParseParams() { return LastParseParams; } + const std::deque<TranslateType>& GetLastParseTranslate() { return LastParseTranslate; } /** Add a mode to the mode parser. * @return True if the mode was successfully added. */ diff --git a/include/modules.h b/include/modules.h index 90aeb178e..b58cbbc20 100644 --- a/include/modules.h +++ b/include/modules.h @@ -741,7 +741,7 @@ class CoreExport Module : public Extensible * @param text The actual modes and their parameters if any * @param translate The translation types of the mode parameters */ - 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); /** Allows modules to alter or create server descriptions * Whenever a module requires a server description, for example for display in @@ -850,7 +850,7 @@ class CoreExport Module : public Extensible * @param modeline The modes and parameters to be sent * @param translate The translation types of the mode parameters */ - 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); /** Implemented by modules which provide the ability to link servers. * These modules will implement this method, which allows metadata (extra data added to diff --git a/include/protocol.h b/include/protocol.h index 4d6f8f27d..d9a2ce25d 100644 --- a/include/protocol.h +++ b/include/protocol.h @@ -68,7 +68,7 @@ class ProtocolInterface : public Extensible * @param target The channel name or user to send mode changes for. * @param The mode changes to send. */ - virtual void SendMode(const std::string &target, parameterlist &modedata) { } + virtual void SendMode(const std::string &target, const parameterlist &modedata, const std::deque<TranslateType> &translate) { } /** Convenience function, string wrapper around the above. */ @@ -76,10 +76,14 @@ class ProtocolInterface : public Extensible { irc::spacesepstream x(modeline); parameterlist n; + std::deque<TranslateType> types; std::string v; while (x.GetToken(v)) + { n.push_back(v); - SendMode(target, n); + types.push_back(TR_TEXT); + } + SendMode(target, n, types); } /** Send a notice to users with a given mode(s). diff --git a/include/u_listmode.h b/include/u_listmode.h index 88b5fb3ee..1e7d1cceb 100644 --- a/include/u_listmode.h +++ b/include/u_listmode.h @@ -423,21 +423,19 @@ class ListModeBase : public ModeHandler chan->GetExt(infokey, mlist); irc::modestacker modestack(ServerInstance, true); std::deque<std::string> stackresult; - std::vector<TranslateType> types; + std::deque<TranslateType> types; types.push_back(TR_TEXT); if (mlist) { for (modelist::iterator it = mlist->begin(); it != mlist->end(); it++) { modestack.Push(std::string(1, mode)[0], it->mask); - types.push_back(this->GetTranslateType()); } } while (modestack.GetStackedLine(stackresult)) { - irc::stringjoiner mode_join(" ", stackresult, 0, stackresult.size() - 1); - std::string line = mode_join.GetJoined(); - proto->ProtoSendMode(opaque, TYPE_CHANNEL, chan, line, types); + types.assign(stackresult.size(), this->GetTranslateType()); + proto->ProtoSendMode(opaque, TYPE_CHANNEL, chan, stackresult, types); } } 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); |