4 #include "treeserver.h"
5 #include "treesocket.h"
6 #include "protocolinterface.h"
9 * For documentation on this class, see include/protocol.h.
12 void SpanningTreeProtocolInterface::GetServerList(ProtoServerList &sl)
15 for (server_hash::iterator i = Utils->serverlist.begin(); i != Utils->serverlist.end(); i++)
18 ps.servername = i->second->GetName();
19 TreeServer* s = i->second->GetParent();
20 ps.parentname = s ? s->GetName() : "";
21 ps.usercount = i->second->GetUserCount();
22 ps.opercount = i->second->GetOperCount();
23 ps.gecos = i->second->GetDesc();
24 ps.latencyms = i->second->rtt;
29 void SpanningTreeProtocolInterface::SendEncapsulatedData(parameterlist &encap)
31 Utils->DoOneToMany(ServerInstance->Config->GetSID(), "ENCAP", encap);
34 void SpanningTreeProtocolInterface::SendMetaData(Extensible* target, const std::string &key, const std::string &data)
38 User* u = dynamic_cast<User*>(target);
39 Channel* c = dynamic_cast<Channel*>(target);
41 params.push_back(u->uuid);
43 params.push_back(c->name);
45 params.push_back("*");
47 params.push_back(key);
48 params.push_back(":" + data);
50 Utils->DoOneToMany(ServerInstance->Config->GetSID(),"METADATA",params);
53 void SpanningTreeProtocolInterface::SendTopic(Channel* channel, std::string &topic)
57 params.push_back(channel->name);
58 params.push_back(ConvToStr(ServerInstance->Time()));
59 params.push_back(ServerInstance->Config->ServerName);
60 params.push_back(":" + topic);
62 Utils->DoOneToMany(ServerInstance->Config->GetSID(),"FTOPIC", params);
65 void SpanningTreeProtocolInterface::SendMode(const std::string &target, const parameterlist &modedata, const std::vector<TranslateType> &translate)
71 ServerInstance->Parser->TranslateUIDs(translate, modedata, outdata);
73 std::string uidtarget;
74 ServerInstance->Parser->TranslateUIDs(TR_NICK, target, uidtarget);
76 parameterlist outlist;
77 outlist.push_back(uidtarget);
78 outlist.push_back(outdata);
80 User* a = ServerInstance->FindNick(uidtarget);
83 Utils->DoOneToMany(ServerInstance->Config->GetSID(),"MODE",outlist);
88 Channel* c = ServerInstance->FindChan(target);
91 outlist.insert(outlist.begin() + 1, ConvToStr(c->age));
92 Utils->DoOneToMany(ServerInstance->Config->GetSID(),"FMODE",outlist);
97 void SpanningTreeProtocolInterface::SendSNONotice(const std::string &snomask, const std::string &text)
100 p.push_back(snomask);
101 p.push_back(":" + text);
102 Utils->DoOneToMany(ServerInstance->Config->GetSID(), "SNONOTICE", p);
105 void SpanningTreeProtocolInterface::PushToClient(User* target, const std::string &rawline)
108 p.push_back(target->uuid);
109 p.push_back(":" + rawline);
110 Utils->DoOneToOne(ServerInstance->Config->GetSID(), "PUSH", p, target->server);
113 void SpanningTreeProtocolInterface::SendChannel(Channel* target, char status, const std::string &text)
115 std::string cname = target->name;
117 cname = status + cname;
120 Utils->GetListOfServersForChannel(target,list,status,exempt_list);
121 for (TreeServerList::iterator i = list.begin(); i != list.end(); i++)
123 TreeSocket* Sock = i->second->GetSocket();
125 Sock->WriteLine(text);
130 void SpanningTreeProtocolInterface::SendChannelPrivmsg(Channel* target, char status, const std::string &text)
132 SendChannel(target, status, ":" + ServerInstance->Config->GetSID()+" PRIVMSG "+target->name+" :"+text);
135 void SpanningTreeProtocolInterface::SendChannelNotice(Channel* target, char status, const std::string &text)
137 SendChannel(target, status, ":" + ServerInstance->Config->GetSID()+" NOTICE "+target->name+" :"+text);
140 void SpanningTreeProtocolInterface::SendUserPrivmsg(User* target, const std::string &text)
142 TreeServer* serv = Utils->FindServer(target->server);
145 TreeSocket* sock = serv->GetSocket();
148 sock->WriteLine(":" + ServerInstance->Config->GetSID() + " PRIVMSG " + target->nick + " :"+text);
153 void SpanningTreeProtocolInterface::SendUserNotice(User* target, const std::string &text)
155 TreeServer* serv = Utils->FindServer(target->server);
158 TreeSocket* sock = serv->GetSocket();
161 sock->WriteLine(":" + ServerInstance->Config->GetSID() + " NOTICE " + target->nick + " :"+text);