]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_spanningtree/protocolinterface.cpp
Only assign NewServices once the duplicate check is done.
[user/henk/code/inspircd.git] / src / modules / m_spanningtree / protocolinterface.cpp
index ee5e319844591cbafbf017096030cd0b67594265..aaf946333fcb3a472dfb447ea2b8c257d2b6f598 100644 (file)
@@ -1,8 +1,13 @@
 /*
  * InspIRCd -- Internet Relay Chat Daemon
  *
- *   Copyright (C) 2009 Daniel De Graaf <danieldg@inspircd.org>
- *   Copyright (C) 2008 Craig Edwards <craigedwards@brainbox.cc>
+ *   Copyright (C) 2018-2019 Sadie Powell <sadie@witchery.services>
+ *   Copyright (C) 2018 Matt Schatz <genius3000@g3k.solutions>
+ *   Copyright (C) 2012-2014 Attila Molnar <attilamolnar@hush.com>
+ *   Copyright (C) 2012 Robby <robby@chatbelgie.be>
+ *   Copyright (C) 2009-2010 Daniel De Graaf <danieldg@inspircd.org>
+ *   Copyright (C) 2008 Robin Burchell <robin+git@viroteck.net>
+ *   Copyright (C) 2008 Craig Edwards <brain@inspircd.org>
  *
  * This file is part of InspIRCd.  InspIRCd is free software: you can
  * redistribute it and/or modify it under the terms of the GNU General Public
@@ -38,13 +43,13 @@ void SpanningTreeProtocolInterface::GetServerList(ServerList& sl)
                ps.parentname = s ? s->GetName() : "";
                ps.usercount = i->second->UserCount;
                ps.opercount = i->second->OperCount;
-               ps.gecos = i->second->GetDesc();
+               ps.description = i->second->GetDesc();
                ps.latencyms = i->second->rtt;
                sl.push_back(ps);
        }
 }
 
-bool SpanningTreeProtocolInterface::SendEncapsulatedData(const std::string& targetmask, const std::string& cmd, const parameterlist& params, User* source)
+bool SpanningTreeProtocolInterface::SendEncapsulatedData(const std::string& targetmask, const std::string& cmd, const CommandBase::Params& params, User* source)
 {
        if (!source)
                source = ServerInstance->FakeClient;
@@ -65,12 +70,23 @@ bool SpanningTreeProtocolInterface::SendEncapsulatedData(const std::string& targ
                        return false;
 
                // Use the SID of the target in the message instead of the server name
-               encap.push(server->GetID()).push(cmd).insert(params).Unicast(server->ServerUser);
+               encap.push(server->GetId()).push(cmd).insert(params).Unicast(server->ServerUser);
        }
 
        return true;
 }
 
+void SpanningTreeProtocolInterface::BroadcastEncap(const std::string& cmd, const CommandBase::Params& params, User* source, User* omit)
+{
+       if (!source)
+               source = ServerInstance->FakeClient;
+
+       // If omit is non-NULL we pass the route belonging to the user to Forward(),
+       // otherwise we pass NULL, which is equivalent to Broadcast()
+       TreeServer* server = (omit ? TreeServer::Get(omit)->GetRoute() : NULL);
+       CmdBuilder(source, "ENCAP * ").push_raw(cmd).insert(params).Forward(server);
+}
+
 void SpanningTreeProtocolInterface::SendMetaData(User* u, const std::string& key, const std::string& data)
 {
        CommandMetadata::Builder(u, key, data).Broadcast();
@@ -91,54 +107,23 @@ void SpanningTreeProtocolInterface::Server::SendMetaData(const std::string& key,
        sock->WriteLine(CommandMetadata::Builder(key, data));
 }
 
-void SpanningTreeProtocolInterface::SendTopic(Channel* channel, std::string &topic)
-{
-       CommandFTopic::Builder(ServerInstance->FakeClient, channel).Broadcast();
-}
-
-void SpanningTreeProtocolInterface::SendMode(User* source, User* u, Channel* c, const std::vector<std::string>& modedata, const std::vector<TranslateType>& translate)
-{
-       if (u)
-       {
-               if (u->registered != REG_ALL)
-                       return;
-
-               CmdBuilder params(source, "MODE");
-               params.push_back(u->uuid);
-               params.insert(modedata);
-               params.Broadcast();
-       }
-       else
-       {
-               CmdBuilder params(source, "FMODE");
-               params.push_back(c->name);
-               params.push_back(ConvToStr(c->age));
-               params.push_back(CommandParser::TranslateUIDs(translate, modedata));
-               params.Broadcast();
-       }
-}
-
 void SpanningTreeProtocolInterface::SendSNONotice(char snomask, const std::string &text)
 {
        CmdBuilder("SNONOTICE").push(snomask).push_last(text).Broadcast();
 }
 
-void SpanningTreeProtocolInterface::PushToClient(User* target, const std::string &rawline)
-{
-       CmdBuilder("PUSH").push(target->uuid).push_last(rawline).Unicast(target);
-}
-
 void SpanningTreeProtocolInterface::SendMessage(Channel* target, char status, const std::string& text, MessageType msgtype)
 {
        const char* cmd = (msgtype == MSG_PRIVMSG ? "PRIVMSG" : "NOTICE");
        CUList exempt_list;
-       Utils->SendChannelMessage(ServerInstance->Config->GetSID(), target, text, status, exempt_list, cmd);
+       ClientProtocol::TagMap tags;
+       Utils->SendChannelMessage(ServerInstance->FakeClient, target, text, status, tags, exempt_list, cmd);
 }
 
 void SpanningTreeProtocolInterface::SendMessage(User* target, const std::string& text, MessageType msgtype)
 {
        CmdBuilder p(msgtype == MSG_PRIVMSG ? "PRIVMSG" : "NOTICE");
-       p.push_back(target->uuid);
+       p.push(target->uuid);
        p.push_last(text);
        p.Unicast(target);
 }