2 #include "m_spanningtree/main.h"
3 #include "m_spanningtree/utils.h"
4 #include "m_spanningtree/treeserver.h"
5 #include "m_spanningtree/treesocket.h"
6 #include "m_spanningtree/protocolinterface.h"
8 void SpanningTreeProtocolInterface::SendEncapsulatedData(parameterlist &encap)
10 Utils->DoOneToMany(ServerInstance->Config->GetSID(), "ENCAP", encap);
13 void SpanningTreeProtocolInterface::SendMetaData(void* target, int type, const std::string &key, const std::string &data)
20 params.push_back(((User*)target)->uuid);
23 params.push_back(((Channel*)target)->name);
26 params.push_back("*");
29 params.push_back(key);
30 params.push_back(":" + data);
32 Utils->DoOneToMany(ServerInstance->Config->GetSID(),"METADATA",params);
35 void SpanningTreeProtocolInterface::SendTopic(Channel* channel, std::string &topic)
39 params.push_back(channel->name);
40 params.push_back(ConvToStr(ServerInstance->Time()));
41 params.push_back(ServerInstance->Config->ServerName);
42 params.push_back(":" + topic);
44 Utils->DoOneToMany(ServerInstance->Config->GetSID(),"FTOPIC", params);
47 void SpanningTreeProtocolInterface::SendMode(const std::string &target, parameterlist &modedata)
52 /* Warning: in-place translation is only safe for type TR_NICK */
53 for (size_t n = 0; n < modedata.size(); n++)
54 ServerInstance->Parser->TranslateUIDs(TR_NICK, modedata[n], modedata[n]);
56 std::string uidtarget;
57 ServerInstance->Parser->TranslateUIDs(TR_NICK, target, uidtarget);
58 modedata.insert(modedata.begin(), uidtarget);
60 User* a = ServerInstance->FindNick(uidtarget);
63 Utils->DoOneToMany(ServerInstance->Config->GetSID(),"MODE",modedata);
68 Channel* c = ServerInstance->FindChan(target);
71 modedata.insert(modedata.begin() + 1, ConvToStr(c->age));
72 Utils->DoOneToMany(ServerInstance->Config->GetSID(),"FMODE",modedata);
77 void SpanningTreeProtocolInterface::SendOperNotice(const std::string &text)
80 p.push_back(":" + text);
81 Utils->DoOneToMany(ServerInstance->Config->GetSID(), "OPERNOTICE", p);
84 void SpanningTreeProtocolInterface::SendModeNotice(const std::string &modes, const std::string &text)
88 p.push_back(":" + text);
89 Utils->DoOneToMany(ServerInstance->Config->GetSID(), "MODENOTICE", p);
92 void SpanningTreeProtocolInterface::SendSNONotice(const std::string &snomask, const std::string &text)
96 p.push_back(":" + text);
97 Utils->DoOneToMany(ServerInstance->Config->GetSID(), "SNONOTICE", p);
100 void SpanningTreeProtocolInterface::PushToClient(User* target, const std::string &rawline)
103 p.push_back(target->uuid);
104 p.push_back(rawline);
105 Utils->DoOneToOne(ServerInstance->Config->GetSID(), "PUSH", p, target->server);
108 void SpanningTreeProtocolInterface::SendChannel(Channel* target, char status, const std::string &text)
110 std::string cname = target->name;
112 cname = status + cname;
115 Utils->GetListOfServersForChannel(target,list,status,exempt_list);
116 for (TreeServerList::iterator i = list.begin(); i != list.end(); i++)
118 TreeSocket* Sock = i->second->GetSocket();
120 Sock->WriteLine(text);
125 void SpanningTreeProtocolInterface::SendChannelPrivmsg(Channel* target, char status, const std::string &text)
127 SendChannel(target, status, ":" + ServerInstance->Config->GetSID()+" PRIVMSG "+target->name+" :"+text);
130 void SpanningTreeProtocolInterface::SendChannelNotice(Channel* target, char status, const std::string &text)
132 SendChannel(target, status, ":" + ServerInstance->Config->GetSID()+" NOTICE "+target->name+" :"+text);
135 void SpanningTreeProtocolInterface::SendUserPrivmsg(User* target, const std::string &text)
137 TreeServer* serv = Utils->FindServer(target->server);
140 TreeSocket* sock = serv->GetSocket();
143 sock->WriteLine(":" + ServerInstance->Config->GetSID() + " PRIVMSG " + target->nick + " :"+text);
148 void SpanningTreeProtocolInterface::SendUserNotice(User* target, const std::string &text)
150 TreeServer* serv = Utils->FindServer(target->server);
153 TreeSocket* sock = serv->GetSocket();
156 sock->WriteLine(":" + ServerInstance->Config->GetSID() + " NOTICE " + target->nick + " :"+text);