diff options
author | Adam <Adam@anope.org> | 2016-12-08 10:18:27 -0500 |
---|---|---|
committer | Adam <Adam@anope.org> | 2016-12-08 10:18:27 -0500 |
commit | ed08d1a31119adb379f8bec46d7ad47ee35c4c92 (patch) | |
tree | be5de3edeaf26ad7efbf23a3d6508645614f283e /modules/protocol/ngircd.cpp | |
parent | 0d112886980787ffd5c69e514eebe476bcec8343 (diff) |
Export protocol implementations into protocol module headers
Diffstat (limited to 'modules/protocol/ngircd.cpp')
-rw-r--r-- | modules/protocol/ngircd.cpp | 236 |
1 files changed, 116 insertions, 120 deletions
diff --git a/modules/protocol/ngircd.cpp b/modules/protocol/ngircd.cpp index 98509f9a1..1818c1021 100644 --- a/modules/protocol/ngircd.cpp +++ b/modules/protocol/ngircd.cpp @@ -24,149 +24,145 @@ #include "modules/protocol/rfc1459.h" #include "modules/protocol/ngircd.h" -class ngIRCdProto : public IRCDProto +void ngircd::Proto::SendSVSKill(const MessageSource &source, User *user, const Anope::string &buf) { - void SendSVSKill(const MessageSource &source, User *user, const Anope::string &buf) override - { - IRCDProto::SendSVSKill(source, user, buf); - user->KillInternal(source, buf); - } + IRCDProto::SendSVSKill(source, user, buf); + user->KillInternal(source, buf); +} - public: - ngIRCdProto(Module *creator) : IRCDProto(creator, "ngIRCd") - { - DefaultPseudoclientModes = "+oi"; - CanCertFP = true; - CanSVSNick = true; - CanSetVHost = true; - CanSetVIdent = true; - MaxModes = 5; - } +ngircd::Proto::Proto(Module *creator) : IRCDProto(creator, "ngIRCd") +{ + DefaultPseudoclientModes = "+oi"; + CanCertFP = true; + CanSVSNick = true; + CanSetVHost = true; + CanSetVIdent = true; + MaxModes = 5; +} - void SendAkill(User *u, XLine *x) override - { - // Calculate the time left before this would expire, capping it at 2 days - time_t timeleft = x->GetExpires() - Anope::CurTime; - if (timeleft > 172800 || !x->GetExpires()) - timeleft = 172800; - Uplink::Send(Me, "GLINE", x->GetMask(), timeleft, x->GetReason() + " (" + x->GetBy() + ")"); - } +void ngircd::Proto::SendAkill(User *u, XLine *x) +{ + // Calculate the time left before this would expire, capping it at 2 days + time_t timeleft = x->GetExpires() - Anope::CurTime; + if (timeleft > 172800 || !x->GetExpires()) + timeleft = 172800; + Uplink::Send(Me, "GLINE", x->GetMask(), timeleft, x->GetReason() + " (" + x->GetBy() + ")"); +} - void SendAkillDel(XLine *x) override - { - Uplink::Send(Me, "GLINE", x->GetMask()); - } +void ngircd::Proto::SendAkillDel(XLine *x) +{ + Uplink::Send(Me, "GLINE", x->GetMask()); +} - void SendChannel(Channel *c) override - { - Uplink::Send(Me, "CHANINFO", c->name, "+" + c->GetModes(true, true)); - } +void ngircd::Proto::SendChannel(Channel *c) +{ + Uplink::Send(Me, "CHANINFO", c->name, "+" + c->GetModes(true, true)); +} - // Received: :dev.anope.de NICK DukeP 1 ~DukePyro p57ABF9C9.dip.t-dialin.net 1 +i :DukePyrolator - void SendClientIntroduction(User *u) override - { - Anope::string modes = "+" + u->GetModes(); - Uplink::Send(Me, "NICK", u->nick, 1, u->GetIdent(), u->host, 1, modes, u->realname); - } +// Received: :dev.anope.de NICK DukeP 1 ~DukePyro p57ABF9C9.dip.t-dialin.net 1 +i :DukePyrolator +void ngircd::Proto::SendClientIntroduction(User *u) +{ + Anope::string modes = "+" + u->GetModes(); + Uplink::Send(Me, "NICK", u->nick, 1, u->GetIdent(), u->host, 1, modes, u->realname); +} - void SendConnect() override - { - Uplink::Send("PASS", Config->Uplinks[Anope::CurrentUplink].password, "0210-IRC+", "Anope|" + Anope::VersionShort(), "CLHMSo P"); - /* Make myself known to myself in the serverlist */ - SendServer(Me); - /* finish the enhanced server handshake and register the connection */ - Uplink::Send("376", "*", "End of MOTD command"); - } +void ngircd::Proto::SendConnect() +{ + Uplink::Send("PASS", Config->Uplinks[Anope::CurrentUplink].password, "0210-IRC+", "Anope|" + Anope::VersionShort(), "CLHMSo P"); + /* Make myself known to myself in the serverlist */ + SendServer(Me); + /* finish the enhanced server handshake and register the connection */ + Uplink::Send("376", "*", "End of MOTD command"); +} - void SendForceNickChange(User *u, const Anope::string &newnick, time_t when) override - { - Uplink::Send(Me, "SVSNICK", u->nick, newnick); - } +void ngircd::Proto::SendForceNickChange(User *u, const Anope::string &newnick, time_t when) +{ + Uplink::Send(Me, "SVSNICK", u->nick, newnick); +} - void SendGlobalNotice(ServiceBot *bi, Server *dest, const Anope::string &msg) override - { - Uplink::Send(bi, "NOTICE", "$" + dest->GetName(), msg); - } +void ngircd::Proto::SendGlobalNotice(ServiceBot *bi, Server *dest, const Anope::string &msg) +{ + Uplink::Send(bi, "NOTICE", "$" + dest->GetName(), msg); +} - void SendGlobalPrivmsg(ServiceBot *bi, Server *dest, const Anope::string &msg) override - { - Uplink::Send(bi, "PRIVMSG", "$" + dest->GetName(), msg); - } +void ngircd::Proto::SendGlobalPrivmsg(ServiceBot *bi, Server *dest, const Anope::string &msg) +{ + Uplink::Send(bi, "PRIVMSG", "$" + dest->GetName(), msg); +} - void SendGlobops(const MessageSource &source, const Anope::string &buf) override - { - Uplink::Send(source, "WALLOPS", buf); - } +void ngircd::Proto::SendGlobops(const MessageSource &source, const Anope::string &buf) +{ + Uplink::Send(source, "WALLOPS", buf); +} - void SendJoin(User *user, Channel *c, const ChannelStatus *status) override +void ngircd::Proto::SendJoin(User *user, Channel *c, const ChannelStatus *status) +{ + Uplink::Send(user, "JOIN", c->name); + if (status) { - Uplink::Send(user, "JOIN", c->name); - if (status) - { - /* First save the channel status incase uc->Status == status */ - ChannelStatus cs = *status; - /* If the user is internally on the channel with flags, kill them so that - * the stacker will allow this. - */ - ChanUserContainer *uc = c->FindUser(user); - if (uc != NULL) - uc->status.Clear(); - - ServiceBot *setter = ServiceBot::Find(user->GetUID()); - for (size_t i = 0; i < cs.Modes().length(); ++i) - c->SetMode(setter, ModeManager::FindChannelModeByChar(cs.Modes()[i]), user->GetUID(), false); - - if (uc != NULL) - uc->status = cs; - } - } + /* First save the channel status incase uc->Status == status */ + ChannelStatus cs = *status; + /* If the user is internally on the channel with flags, kill them so that + * the stacker will allow this. + */ + ChanUserContainer *uc = c->FindUser(user); + if (uc != NULL) + uc->status.Clear(); - void SendLogin(User *u, NickServ::Nick *na) override - { - Uplink::Send(Me, "METADATA", u->GetUID(), "accountname", na->GetAccount()->GetDisplay()); - } + ServiceBot *setter = ServiceBot::Find(user->GetUID()); + for (size_t i = 0; i < cs.Modes().length(); ++i) + c->SetMode(setter, ModeManager::FindChannelModeByChar(cs.Modes()[i]), user->GetUID(), false); - void SendLogout(User *u) override - { - Uplink::Send(Me, "METADATA", u->GetUID(), "accountname", ""); + if (uc != NULL) + uc->status = cs; } +} - /* SERVER name hop descript */ - void SendServer(Server *server) override - { - Uplink::Send("SERVER", server->GetName(), server->GetHops(), server->GetDescription()); - } +void ngircd::Proto::SendLogin(User *u, NickServ::Nick *na) +{ + Uplink::Send(Me, "METADATA", u->GetUID(), "accountname", na->GetAccount()->GetDisplay()); +} - void SendTopic(const MessageSource &source, Channel *c) override - { - Uplink::Send(source, "TOPIC", c->name, c->topic); - } +void ngircd::Proto::SendLogout(User *u) +{ + Uplink::Send(Me, "METADATA", u->GetUID(), "accountname", ""); +} - void SendVhost(User *u, const Anope::string &vIdent, const Anope::string &vhost) override - { - if (!vIdent.empty()) - Uplink::Send(Me, "METADATA", u->nick, "user", vIdent); +/* SERVER name hop descript */ +void ngircd::Proto::SendServer(Server *server) +{ + Uplink::Send("SERVER", server->GetName(), server->GetHops(), server->GetDescription()); +} - Uplink::Send(Me, "METADATA", u->nick, "cloakhost", vhost); - if (!u->HasMode("CLOAK")) - { - u->SetMode(Config->GetClient("HostServ"), "CLOAK"); - ModeManager::ProcessModes(); - } - } +void ngircd::Proto::SendTopic(const MessageSource &source, Channel *c) +{ + Uplink::Send(source, "TOPIC", c->name, c->topic); +} - void SendVhostDel(User *u) override - { - this->SendVhost(u, u->GetIdent(), ""); - } +void ngircd::Proto::SendVhost(User *u, const Anope::string &vIdent, const Anope::string &vhost) +{ + if (!vIdent.empty()) + Uplink::Send(Me, "METADATA", u->nick, "user", vIdent); - Anope::string Format(IRCMessage &message) + Uplink::Send(Me, "METADATA", u->nick, "cloakhost", vhost); + if (!u->HasMode("CLOAK")) { - if (message.GetSource().GetSource().empty()) - message.SetSource(Me); - return IRCDProto::Format(message); + u->SetMode(Config->GetClient("HostServ"), "CLOAK"); + ModeManager::ProcessModes(); } -}; +} + +void ngircd::Proto::SendVhostDel(User *u) +{ + this->SendVhost(u, u->GetIdent(), ""); +} + +Anope::string ngircd::Proto::Format(IRCMessage &message) +{ + if (message.GetSource().GetSource().empty()) + message.SetSource(Me); + return IRCDProto::Format(message); +} // Please see <http://www.irc.org/tech_docs/005.html> for details. void ngircd::Numeric005::Run(MessageSource &source, const std::vector<Anope::string> ¶ms) @@ -518,7 +514,7 @@ void ngircd::ServerMessage::Run(MessageSource &source, const std::vector<Anope:: class ProtongIRCd : public Module , public EventHook<Event::UserNickChange> { - ngIRCdProto ircd_proto; + ngircd::Proto ircd_proto; /* Core message handlers */ rfc1459::Capab message_capab; |