]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_spanningtree/protocolinterface.cpp
Its ok to allow remote map to non-opers now, found the real culprit
[user/henk/code/inspircd.git] / src / modules / m_spanningtree / protocolinterface.cpp
index 48d0f78ebb447ed840fc8ab4ae9801d41ce409d5..cbffe92cc9a39542c3bf0b20b7fe9c3501546b07 100644 (file)
@@ -1,6 +1,8 @@
 #include "inspircd.h"
 #include "m_spanningtree/main.h"
 #include "m_spanningtree/utils.h"
+#include "m_spanningtree/treeserver.h"
+#include "m_spanningtree/treesocket.h"
 #include "m_spanningtree/protocolinterface.h"
 
 void SpanningTreeProtocolInterface::SendEncapsulatedData(parameterlist &encap)
@@ -47,9 +49,14 @@ void SpanningTreeProtocolInterface::SendMode(const std::string &target, paramete
        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], modedata[n]);
+       {
+               ServerInstance->Parser->TranslateUIDs(TR_NICK, modedata[n], outdata);
+               modedata[n] = outdata;
+       }
 
        std::string uidtarget;
        ServerInstance->Parser->TranslateUIDs(TR_NICK, target, uidtarget);
@@ -103,3 +110,56 @@ void SpanningTreeProtocolInterface::PushToClient(User* target, const std::string
        Utils->DoOneToOne(ServerInstance->Config->GetSID(), "PUSH", p, target->server);
 }
 
+void SpanningTreeProtocolInterface::SendChannel(Channel* target, char status, const std::string &text)
+{
+       std::string cname = target->name;
+       if (status)
+               cname = status + cname;
+       TreeServerList list;
+       CUList exempt_list;
+       Utils->GetListOfServersForChannel(target,list,status,exempt_list);
+       for (TreeServerList::iterator i = list.begin(); i != list.end(); i++)
+       {
+               TreeSocket* Sock = i->second->GetSocket();
+               if (Sock)
+                       Sock->WriteLine(text);
+       }
+}
+
+
+void SpanningTreeProtocolInterface::SendChannelPrivmsg(Channel* target, char status, const std::string &text)
+{
+       SendChannel(target, status, ":" + ServerInstance->Config->GetSID()+" PRIVMSG "+target->name+" :"+text);
+}
+
+void SpanningTreeProtocolInterface::SendChannelNotice(Channel* target, char status, const std::string &text)
+{
+       SendChannel(target, status, ":" + ServerInstance->Config->GetSID()+" NOTICE "+target->name+" :"+text);
+}
+
+void SpanningTreeProtocolInterface::SendUserPrivmsg(User* target, const std::string &text)
+{
+       TreeServer* serv = Utils->FindServer(target->server);
+       if (serv)
+       {
+               TreeSocket* sock = serv->GetSocket();
+               if (sock)
+               {
+                       sock->WriteLine(":" + ServerInstance->Config->GetSID() + " PRIVMSG " + target->nick + " :"+text);
+               }
+       }
+}
+
+void SpanningTreeProtocolInterface::SendUserNotice(User* target, const std::string &text)
+{
+       TreeServer* serv = Utils->FindServer(target->server);
+       if (serv)
+       {
+               TreeSocket* sock = serv->GetSocket();
+               if (sock)
+               {
+                       sock->WriteLine(":" + ServerInstance->Config->GetSID() + " NOTICE " + target->nick + " :"+text);
+               }
+       }
+}
+