diff options
author | Adam <Adam@anope.org> | 2011-12-27 23:11:14 -0500 |
---|---|---|
committer | Adam <Adam@anope.org> | 2011-12-27 23:11:14 -0500 |
commit | 150831c1a6538938c13c06a10f1eede2079a8aa4 (patch) | |
tree | 9bfbd7323e79c8e21cc2c02c2e51047ca942f31e | |
parent | 1a4157b7f40f928fb1f3092cc9069f4b359f8a40 (diff) |
Made capab management a bit simplier
-rw-r--r-- | include/servers.h | 24 | ||||
-rw-r--r-- | modules/commands/os_stats.cpp | 7 | ||||
-rw-r--r-- | modules/extra/m_xmlrpc_main.cpp | 7 | ||||
-rw-r--r-- | modules/protocol/bahamut.cpp | 2 | ||||
-rw-r--r-- | modules/protocol/inspircd11.cpp | 2 | ||||
-rw-r--r-- | modules/protocol/inspircd12.cpp | 2 | ||||
-rw-r--r-- | modules/protocol/inspircd20.cpp | 2 | ||||
-rw-r--r-- | src/protocol.cpp | 19 | ||||
-rw-r--r-- | src/servers.cpp | 15 |
9 files changed, 15 insertions, 65 deletions
diff --git a/include/servers.h b/include/servers.h index f63c747e3..acdbfaa06 100644 --- a/include/servers.h +++ b/include/servers.h @@ -9,29 +9,7 @@ extern CoreExport void do_server(const Anope::string &source, const Anope::strin extern CoreExport const Anope::string ts6_uid_retrieve(); extern CoreExport const Anope::string ts6_sid_retrieve(); -/* Types of capab - */ -enum CapabType -{ - CAPAB_BEGIN, - - CAPAB_NOQUIT, - CAPAB_TSMODE, - CAPAB_UNCONNECT, - CAPAB_QS, - - CAPAB_END -}; - -/* CAPAB stuffs */ -struct CapabInfo -{ - Anope::string Token; - CapabType Flag; -}; - -extern CoreExport Flags<CapabType, CAPAB_END> Capab; -extern CoreExport CapabInfo Capab_Info[]; +extern CoreExport std::set<Anope::string> Capab; /** Flags set on servers */ diff --git a/modules/commands/os_stats.cpp b/modules/commands/os_stats.cpp index 813e59f5f..8f41947a6 100644 --- a/modules/commands/os_stats.cpp +++ b/modules/commands/os_stats.cpp @@ -122,11 +122,8 @@ class CommandOSStats : public Command void DoStatsUplink(CommandSource &source) { Anope::string buf; - - for (unsigned j = 0; !Capab_Info[j].Token.empty(); ++j) - if (Capab.HasFlag(Capab_Info[j].Flag)) - buf += " " + Capab_Info[j].Token; - + for (std::set<Anope::string>::iterator it = Capab.begin(); it != Capab.end(); ++it) + buf += *it; if (!buf.empty()) buf.erase(buf.begin()); diff --git a/modules/extra/m_xmlrpc_main.cpp b/modules/extra/m_xmlrpc_main.cpp index a8294b576..98677761c 100644 --- a/modules/extra/m_xmlrpc_main.cpp +++ b/modules/extra/m_xmlrpc_main.cpp @@ -135,9 +135,10 @@ class MyXMLRPCEvent : public XMLRPCEvent request->reply("uplinkname", Me->GetLinks().front()->GetName()); { Anope::string buf; - for (unsigned j = 0; !Capab_Info[j].Token.empty(); ++j) - if (Capab.HasFlag(Capab_Info[j].Flag)) - buf += " " + Capab_Info[j].Token; + for (std::set<Anope::string>::iterator it = Capab.begin(); it != Capab.end(); ++it) + buf += " " + *it; + if (!buf.empty()) + buf.erase(buf.begin()); request->reply("uplinkcapab", buf); } request->reply("usercount", stringify(usercnt)); diff --git a/modules/protocol/bahamut.cpp b/modules/protocol/bahamut.cpp index c4b7b1bf0..b4e4467dc 100644 --- a/modules/protocol/bahamut.cpp +++ b/modules/protocol/bahamut.cpp @@ -49,7 +49,7 @@ class BahamutIRCdProto : public IRCDProto { void SendModeInternal(const BotInfo *source, const Channel *dest, const Anope::string &buf) { - if (Capab.HasFlag(CAPAB_TSMODE)) + if (Capab.count("TSMODE") > 0) UplinkSocket::Message(source ? source->nick : Config->ServerName) << "MODE " << dest->name << " " << dest->creation_time << " " << buf; else UplinkSocket::Message(source ? source->nick : Config->ServerName) << "MODE " << dest->name << " " << buf; diff --git a/modules/protocol/inspircd11.cpp b/modules/protocol/inspircd11.cpp index adb6ee1fa..63fd7e754 100644 --- a/modules/protocol/inspircd11.cpp +++ b/modules/protocol/inspircd11.cpp @@ -921,7 +921,7 @@ class ProtoInspIRCd : public Module pmodule_ircd_proto(&this->ircd_proto); pmodule_ircd_message(&this->ircd_message); - Capab.SetFlag(CAPAB_NOQUIT); + Capab.insert("NOQUIT"); this->AddModes(); diff --git a/modules/protocol/inspircd12.cpp b/modules/protocol/inspircd12.cpp index 1af63c37b..438955bb5 100644 --- a/modules/protocol/inspircd12.cpp +++ b/modules/protocol/inspircd12.cpp @@ -712,7 +712,7 @@ class ProtoInspIRCd : public Module pmodule_ircd_proto(&this->ircd_proto); pmodule_ircd_message(&this->ircd_message); - Capab.SetFlag(CAPAB_NOQUIT); + Capab.insert("NOQUIT"); Implementation i[] = { I_OnUserNickChange, I_OnServerSync }; ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation)); diff --git a/modules/protocol/inspircd20.cpp b/modules/protocol/inspircd20.cpp index 1e1eff8fd..a3db7f7a3 100644 --- a/modules/protocol/inspircd20.cpp +++ b/modules/protocol/inspircd20.cpp @@ -725,7 +725,7 @@ class ProtoInspIRCd : public Module pmodule_ircd_proto(&this->ircd_proto); pmodule_ircd_message(&this->ircd_message); - Capab.SetFlag(CAPAB_NOQUIT); + Capab.insert("NOQUIT"); Implementation i[] = { I_OnUserNickChange, I_OnServerSync }; ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation)); diff --git a/src/protocol.cpp b/src/protocol.cpp index d855e41d8..218478757 100644 --- a/src/protocol.cpp +++ b/src/protocol.cpp @@ -478,7 +478,7 @@ bool IRCdMessage::OnSQuit(const Anope::string &source, const std::vector<Anope:: Anope::string buf = s->GetName() + " " + s->GetUplink()->GetName(); - if (s->GetUplink() == Me && Capab.HasFlag(CAPAB_UNCONNECT)) + if (s->GetUplink() == Me && Capab.count("UNCONNECT") > 0) { Log(LOG_DEBUG) << "Sending UNCONNECT SQUIT for " << s->GetName(); /* need to fix */ @@ -516,22 +516,7 @@ bool IRCdMessage::OnWhois(const Anope::string &source, const std::vector<Anope:: bool IRCdMessage::OnCapab(const Anope::string &, const std::vector<Anope::string> ¶ms) { for (unsigned i = 0; i < params.size(); ++i) - { - spacesepstream sep(params[i]); - Anope::string token; - - while (sep.GetToken(token)) - for (unsigned j = 0; !Capab_Info[j].Token.empty(); ++j) - { - if (Capab_Info[j].Token.equals_ci(token)) - { - Capab.SetFlag(Capab_Info[j].Flag); - Log(LOG_DEBUG) << "Capab: Enabling " << Capab_Info[j].Token; - break; - } - } - } - + Capab.insert(params[i]); return true; } diff --git a/src/servers.cpp b/src/servers.cpp index 51a7608e1..6e4622b29 100644 --- a/src/servers.cpp +++ b/src/servers.cpp @@ -16,18 +16,7 @@ /* Anope */ Server *Me = NULL; -CapabInfo Capab_Info[] = { - {"NOQUIT", CAPAB_NOQUIT}, - {"TSMODE", CAPAB_TSMODE}, - {"UNCONNECT", CAPAB_UNCONNECT}, - {"QS", CAPAB_QS}, - {"", CAPAB_END} -}; - -const Anope::string CapabFlags[] = { - "NOQUIT", "TSMODE", "UNCONNECT", "QS", "" -}; -Flags<CapabType, CAPAB_END> Capab(CapabFlags); +std::set<Anope::string> Capab; /** Constructor * @param uplink The uplink this server is from, is only NULL when creating Me @@ -125,7 +114,7 @@ Server::~Server() { Log(this, "quit") << "quit from " << (this->UplinkServer ? this->UplinkServer->GetName() : "no uplink") << " for " << this->QReason; - if (Capab.HasFlag(CAPAB_NOQUIT) || Capab.HasFlag(CAPAB_QS)) + if (Capab.count("NOQUIT") > 0 || Capab.count("QS") > 0) { for (Anope::insensitive_map<User *>::const_iterator it = UserListByNick.begin(); it != UserListByNick.end();) { |