]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Add protocol api functions: PI->WriteChannelPrivmsg() and PI->WriteChannelNotice...
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>
Fri, 4 Apr 2008 14:37:23 +0000 (14:37 +0000)
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>
Fri, 4 Apr 2008 14:37:23 +0000 (14:37 +0000)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@9308 e03df62e-2008-0410-955e-edbf42e46eb7

include/protocol.h
src/modules/m_spanningtree/protocolinterface.cpp
src/modules/m_spanningtree/protocolinterface.h

index 44964e1e82e8e4f9ccc7c3a798e9df59a22b0cde..6f9cf8022eba3664e7a0fec5e9d4fdeca608c019 100644 (file)
@@ -54,6 +54,10 @@ class ProtocolInterface : public Extensible
        virtual void SendSNONotice(const std::string &snomask, const std::string &text) { }
 
        virtual void PushToClient(User* target, const std::string &rawline) { }
+
+       virtual void SendChannelPrivmsg(Channel* target, char status, const std::string &text) { }
+
+       virtual void SendChannelNotice(Channel* target, char status, const std::string &text) { }
 };
 
 #endif
index 48d0f78ebb447ed840fc8ab4ae9801d41ce409d5..d10f7f98143ec1c594747534eca24171f8031561 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)
@@ -103,3 +105,30 @@ 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);
+}
+
index 754e1bf6fb8888e1d6ce0ce5ca85d417a996401a..29d669da9f805983f6fc3545e68c51d3af0df973 100644 (file)
@@ -9,6 +9,7 @@ class SpanningTreeProtocolInterface : public ProtocolInterface
 {
        SpanningTreeUtilities* Utils;
        ModuleSpanningTree* Module;
+       void SendChannel(Channel* target, char status, const std::string &text);
  public:
         SpanningTreeProtocolInterface(ModuleSpanningTree* mod, SpanningTreeUtilities* util, InspIRCd* Instance) : ProtocolInterface(Instance), Utils(util), Module(mod) { }
         virtual ~SpanningTreeProtocolInterface() { }
@@ -21,6 +22,8 @@ class SpanningTreeProtocolInterface : public ProtocolInterface
         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);
+       virtual void SendChannelPrivmsg(Channel* target, char status, const std::string &text);
+       virtual void SendChannelNotice(Channel* target, char status, const std::string &text);
 };
 
 #endif