1 From e74a5303f2357f4a9915bb91038a2e326323db3c Mon Sep 17 00:00:00 2001
2 From: Alexander Barton <alex@barton.de>
3 Date: Fri, 25 Nov 2011 19:16:37 +0100
4 Subject: [PATCH 09/16] ngircd: Update protocol module for current Anope 1.9
7 This changes are rquired by:
9 - b14f5ea88: Fixed accidentally clearing botmodes when joins are sent
10 - cef3eb78d: Remove send_cmd and replace it with a stringstream
11 - ddc3c2f38: Added options:nonicknameownership config option
13 modules/protocol/ngircd.cpp | 54 ++++++++++++++++++++++--------------------
14 1 files changed, 28 insertions(+), 26 deletions(-)
16 diff --git a/modules/protocol/ngircd.cpp b/modules/protocol/ngircd.cpp
17 index 2774168..55cb8d7 100644
18 --- a/modules/protocol/ngircd.cpp
19 +++ b/modules/protocol/ngircd.cpp
20 @@ -54,16 +54,22 @@ class ngIRCdProto : public IRCDProto
22 void SendGlobopsInternal(const BotInfo *source, const Anope::string &buf)
24 - send_cmd(source ? source->nick : Config->ServerName, "WALLOPS :%s", buf.c_str());
25 + UplinkSocket::Message(source ? source->nick : Config->ServerName) << "WALLOPS :" << buf;
28 - void SendJoin(User *user, Channel *c, ChannelStatus *status)
29 + void SendJoin(User *user, Channel *c, const ChannelStatus *status)
31 - send_cmd(user->nick, "JOIN %s", c->name.c_str());
32 + UplinkSocket::Message(user->nick) << "JOIN " << c->name;
35 + /* First save the channel status incase uc->Status == status */
36 ChannelStatus cs = *status;
37 - status->ClearFlags();
38 + /* If the user is internally on the channel with flags, kill them so that
39 + * the stacker will allow this.
41 + UserContainer *uc = c->FindUser(user);
43 + uc->Status->ClearFlags();
45 BotInfo *setter = findbot(user->nick);
46 for (unsigned i = 0; i < ModeManager::ChannelModes.size(); ++i)
47 @@ -74,18 +80,18 @@ class ngIRCdProto : public IRCDProto
49 void SendSVSKillInternal(const BotInfo *source, const User *user, const Anope::string &buf)
51 - send_cmd(source ? source->nick : Config->ServerName, "KILL %s :%s", user->nick.c_str(), buf.c_str());
52 + UplinkSocket::Message(source ? source->nick : Config->ServerName) << "KILL " << user->nick << " :" << buf;
55 /* SERVER name hop descript */
56 void SendServer(const Server *server)
58 - send_cmd("", "SERVER %s %d :%s", server->GetName().c_str(), server->GetHops(), server->GetDescription().c_str());
59 + UplinkSocket::Message() << "SERVER " << server->GetName() << " " << server->GetHops() << " :" << server->GetDescription();
64 - send_cmd("", "PASS %s 0210-IRC+ Anope|%s:CLHSo P", Config->Uplinks[CurrentUplink]->password.c_str(), Anope::VersionShort().c_str());
65 + UplinkSocket::Message() << "PASS " << Config->Uplinks[CurrentUplink]->password << " 0210-IRC+ Anope|" << Anope::VersionShort() << ":CLHSo P";
66 /* Make myself known to myself in the serverlist */
68 /* finish the enhanced server handshake and register the connection */
69 @@ -98,56 +104,52 @@ class ngIRCdProto : public IRCDProto
70 Anope::string modes = "+" + u->GetModes();
71 XLine x(u->nick, "Reserved for services");
72 ircdproto->SendSQLine(NULL, &x);
73 - send_cmd(Config->ServerName, "NICK %s 1 %s %s 1 %s :%s", u->nick.c_str(), u->GetIdent().c_str(), u->host.c_str(), modes.c_str(), u->realname.c_str());
74 + UplinkSocket::Message(Config->ServerName) << "NICK " << u->nick << " 1 " << u->GetIdent() << " " << u->host << " 1 " << modes << " :" << u->realname;
77 void SendPartInternal(const BotInfo *bi, const Channel *chan, const Anope::string &buf)
80 - send_cmd(bi->nick, "PART %s :%s", chan->name.c_str(), buf.c_str());
81 + UplinkSocket::Message(bi->nick) << "PART " << chan->name << " :" << buf;
83 - send_cmd(bi->nick, "PART %s", chan->name.c_str());
84 + UplinkSocket::Message(bi->nick) << "PART " << chan->name;
87 void SendModeInternal(const BotInfo *bi, const Channel *dest, const Anope::string &buf)
89 -Log(LOG_DEBUG) << "SendModeInternal 1";
90 - send_cmd(bi ? bi->nick : Config->ServerName, "MODE %s %s", dest->name.c_str(), buf.c_str());
91 + UplinkSocket::Message(bi ? bi->nick : Config->ServerName) << "MODE " << dest->name << " " << buf;
94 void SendModeInternal(const BotInfo *bi, const User *u, const Anope::string &buf)
96 -Log(LOG_DEBUG) << "SendModeInternal 2";
97 - send_cmd(bi ? bi->nick : Config->ServerName, "MODE %s %s", u->nick.c_str(), buf.c_str());
98 + UplinkSocket::Message(bi ? bi->nick : Config->ServerName) << "MODE " << u->nick << " " << buf;
101 void SendKickInternal(const BotInfo *bi, const Channel *chan, const User *user, const Anope::string &buf)
104 - send_cmd(bi->nick, "KICK %s %s :%s", chan->name.c_str(), user->nick.c_str(), buf.c_str());
105 + UplinkSocket::Message(bi->nick) << "KICK " << chan->name << " " << user->nick << " :" << buf;
107 - send_cmd(bi->nick, "KICK %s %s", chan->name.c_str(), user->nick.c_str());
108 + UplinkSocket::Message(bi->nick) << "KICK " << chan->name << " " << user->nick;
111 - void SendNoticeChanopsInternal(const BotInfo *source, const Channel *dest, const Anope::string &buf)
112 + void SendChannel(Channel *c)
114 - send_cmd(source->nick, "NOTICE @%s :%s", dest->name.c_str(), buf.c_str());
115 + Anope::string modes = c->GetModes(true, true);
116 + UplinkSocket::Message(Config->ServerName) << "CHANINFO " << c->name << " +" << modes;
120 - void SendInvite(BotInfo *source, const Anope::string &chan, const Anope::string &nick)
121 + void SendTopic(BotInfo *bi, Channel *c)
123 - send_cmd(source->nick, "INVITE %s %s", nick.c_str(), chan.c_str());
124 + UplinkSocket::Message(bi->nick) << "TOPIC " << c->name << " :" << c->topic;
127 - void SendChannel(Channel *c)
128 + void SendLogin(User *u)
130 - Anope::string modes = c->GetModes(true, true);
131 - send_cmd(Config->ServerName, "CHANINFO %s +%s", c->name.c_str(), modes.c_str());
133 - void SendTopic(BotInfo *bi, Channel *c)
135 + void SendLogout(User *u)
137 - send_cmd(bi->nick, "TOPIC %s :%s", c->name.c_str(), c->topic.c_str());