aboutsummaryrefslogtreecommitdiff
path: root/src/modules
diff options
context:
space:
mode:
authorGravatar Sadie Powell2023-01-22 21:48:22 +0000
committerGravatar Sadie Powell2023-01-22 22:36:31 +0000
commitcadf228c3e66ce33c3599539b6650e26dfc3bff5 (patch)
tree5b4fc56f9e4e6a63900fedd128fe920af2d73349 /src/modules
parentFix some Doxygen comment issues. (diff)
Convert various enums to strongly typed scoped enums.
Diffstat (limited to 'src/modules')
-rw-r--r--src/modules/m_alias.cpp2
-rw-r--r--src/modules/m_anticaps.cpp43
-rw-r--r--src/modules/m_botmode.cpp4
-rw-r--r--src/modules/m_codepage.cpp29
-rw-r--r--src/modules/m_delaymsg.cpp2
-rw-r--r--src/modules/m_filter.cpp2
-rw-r--r--src/modules/m_hostchange.cpp21
-rw-r--r--src/modules/m_messageflood.cpp2
-rw-r--r--src/modules/m_nonotice.cpp2
-rw-r--r--src/modules/m_showfile.cpp2
-rw-r--r--src/modules/m_silence.cpp8
-rw-r--r--src/modules/m_spanningtree/main.cpp2
-rw-r--r--src/modules/m_spanningtree/protocolinterface.cpp4
13 files changed, 63 insertions, 60 deletions
diff --git a/src/modules/m_alias.cpp b/src/modules/m_alias.cpp
index c16c613a5..32b1ac72b 100644
--- a/src/modules/m_alias.cpp
+++ b/src/modules/m_alias.cpp
@@ -205,7 +205,7 @@ public:
if (active)
return;
- if ((target.type != MessageTarget::TYPE_CHANNEL) || (details.type != MSG_PRIVMSG))
+ if ((target.type != MessageTarget::TYPE_CHANNEL) || (details.type != MessageType::PRIVMSG))
{
return;
}
diff --git a/src/modules/m_anticaps.cpp b/src/modules/m_anticaps.cpp
index b1bd477cf..319e85cea 100644
--- a/src/modules/m_anticaps.cpp
+++ b/src/modules/m_anticaps.cpp
@@ -25,13 +25,14 @@
#include "modules/exemption.h"
#include "numerichelper.h"
-enum AntiCapsMethod
+enum class AntiCapsMethod
+ : uint8_t
{
- ACM_BAN,
- ACM_BLOCK,
- ACM_MUTE,
- ACM_KICK,
- ACM_KICK_BAN
+ BAN,
+ BLOCK,
+ MUTE,
+ KICK,
+ KICK_BAN,
};
class AntiCapsSettings final
@@ -60,15 +61,15 @@ private:
return false;
if (irc::equals(methodstr, "ban"))
- method = ACM_BAN;
+ method = AntiCapsMethod::BAN;
else if (irc::equals(methodstr, "block"))
- method = ACM_BLOCK;
+ method = AntiCapsMethod::BLOCK;
else if (irc::equals(methodstr, "mute"))
- method = ACM_MUTE;
+ method = AntiCapsMethod::MUTE;
else if (irc::equals(methodstr, "kick"))
- method = ACM_KICK;
+ method = AntiCapsMethod::KICK;
else if (irc::equals(methodstr, "kickban"))
- method = ACM_KICK_BAN;
+ method = AntiCapsMethod::KICK_BAN;
else
return false;
@@ -132,19 +133,19 @@ public:
{
switch (acs->method)
{
- case ACM_BAN:
+ case AntiCapsMethod::BAN:
out.append("ban");
break;
- case ACM_BLOCK:
+ case AntiCapsMethod::BLOCK:
out.append("block");
break;
- case ACM_MUTE:
+ case AntiCapsMethod::MUTE:
out.append("mute");
break;
- case ACM_KICK:
+ case AntiCapsMethod::KICK:
out.append("kick");
break;
- case ACM_KICK_BAN:
+ case AntiCapsMethod::KICK_BAN:
out.append("kickban");
break;
}
@@ -274,25 +275,25 @@ public:
switch (config->method)
{
- case ACM_BAN:
+ case AntiCapsMethod::BAN:
InformUser(channel, user, message);
CreateBan(channel, user, false);
break;
- case ACM_BLOCK:
+ case AntiCapsMethod::BLOCK:
InformUser(channel, user, message);
break;
- case ACM_MUTE:
+ case AntiCapsMethod::MUTE:
InformUser(channel, user, message);
CreateBan(channel, user, true);
break;
- case ACM_KICK:
+ case AntiCapsMethod::KICK:
channel->KickUser(ServerInstance->FakeClient, user, message);
break;
- case ACM_KICK_BAN:
+ case AntiCapsMethod::KICK_BAN:
CreateBan(channel, user, false);
channel->KickUser(ServerInstance->FakeClient, user, message);
break;
diff --git a/src/modules/m_botmode.cpp b/src/modules/m_botmode.cpp
index 5d309e58a..0060bb7da 100644
--- a/src/modules/m_botmode.cpp
+++ b/src/modules/m_botmode.cpp
@@ -85,7 +85,7 @@ public:
ModResult OnUserPreMessage(User* user, const MessageTarget& target, MessageDetails& details) override
{
// Allow sending if forcenotice is off, the user is not a bot, or if the message is a notice.
- if (!forcenotice || !user->IsModeSet(bm) || details.type == MSG_NOTICE)
+ if (!forcenotice || !user->IsModeSet(bm) || details.type == MessageType::NOTICE)
return MOD_RES_PASSTHRU;
// Allow sending PRIVMSGs to services pseudoclients.
@@ -93,7 +93,7 @@ public:
return MOD_RES_PASSTHRU;
// Force the message to be broadcast as a NOTICE.
- details.type = MSG_NOTICE;
+ details.type = MessageType::NOTICE;
return MOD_RES_PASSTHRU;
}
diff --git a/src/modules/m_codepage.cpp b/src/modules/m_codepage.cpp
index 586bcc2fb..83ae5a79d 100644
--- a/src/modules/m_codepage.cpp
+++ b/src/modules/m_codepage.cpp
@@ -23,16 +23,17 @@
class Codepage
{
public:
- enum AllowCharacterResult
+ enum class AllowCharacterResult
+ : uint8_t
{
// The character is allowed in a nick.
- ACR_OKAY,
+ OKAY,
// The character is never valid in a nick.
- ACR_NOT_VALID,
+ NOT_VALID,
// The character is not valid at the front of a nick.
- ACR_NOT_VALID_AT_FRONT
+ NOT_VALID_AT_FRONT,
};
// The mapping of lower case characters to upper case characters.
@@ -56,22 +57,22 @@ public:
// Nicknames can not begin with a number as that would collide with
// a user identifier.
if (character >= '0' && character <= '9')
- return ACR_NOT_VALID_AT_FRONT;
+ return AllowCharacterResult::NOT_VALID_AT_FRONT;
// Nicknames can not begin with a : as it has special meaning within
// the IRC message format.
if (character == ':')
- return ACR_NOT_VALID_AT_FRONT;
+ return AllowCharacterResult::NOT_VALID_AT_FRONT;
}
// Nicknames can never contain NUL, CR, LF, or SPACE as they are either
// banned within an IRC message or have special meaning within the IRC
// message format.
if (!character || character == '\n' || character == '\r' || character == ' ')
- return ACR_NOT_VALID;
+ return AllowCharacterResult::NOT_VALID;
// The character is probably okay?
- return ACR_OKAY;
+ return AllowCharacterResult::OKAY;
}
// Determines whether a nickname is valid.
@@ -99,17 +100,17 @@ public:
{
// Single byte codepage can, as their name suggests, only be one byte in size.
if (character > UCHAR_MAX)
- return ACR_NOT_VALID;
+ return AllowCharacterResult::NOT_VALID;
// Check the common allowed character rules.
AllowCharacterResult result = Codepage::AllowCharacter(character, front);
- if (result != ACR_OKAY)
+ if (result != AllowCharacterResult::OKAY)
return result;
// The character is okay.
allowedchars.set(character);
allowedfrontchars.set(character, front);
- return ACR_OKAY;
+ return AllowCharacterResult::OKAY;
}
bool IsValidNick(const std::string_view& nick) override
@@ -278,16 +279,16 @@ public:
// This cast could be unsafe but it's not obvious how to make it safe.
switch (newcodepage->AllowCharacter(static_cast<uint32_t>(pos), front))
{
- case Codepage::ACR_OKAY:
+ case Codepage::AllowCharacterResult::OKAY:
ServerInstance->Logs.Debug(MODNAME, "Marked %lu (%.4s) as allowed (front: %s)",
pos, reinterpret_cast<unsigned char*>(&pos), front ? "yes" : "no");
break;
- case Codepage::ACR_NOT_VALID:
+ case Codepage::AllowCharacterResult::NOT_VALID:
throw ModuleException(this, InspIRCd::Format("<cpchars> tag contains a forbidden character: %lu at %s",
pos, tag->source.str().c_str()));
- case Codepage::ACR_NOT_VALID_AT_FRONT:
+ case Codepage::AllowCharacterResult::NOT_VALID_AT_FRONT:
throw ModuleException(this, InspIRCd::Format("<cpchars> tag contains a forbidden front character: %lu at %s",
pos, tag->source.str().c_str()));
}
diff --git a/src/modules/m_delaymsg.cpp b/src/modules/m_delaymsg.cpp
index 4d0ef99e7..fedc45b6f 100644
--- a/src/modules/m_delaymsg.cpp
+++ b/src/modules/m_delaymsg.cpp
@@ -105,7 +105,7 @@ void ModuleDelayMsg::OnUserJoin(Membership* memb, bool sync, bool created, CULis
ModResult ModuleDelayMsg::OnUserPreMessage(User* user, const MessageTarget& target, MessageDetails& details)
{
- return HandleMessage(user, target, details.type == MSG_NOTICE);
+ return HandleMessage(user, target, details.type == MessageType::NOTICE);
}
ModResult ModuleDelayMsg::OnUserPreTagMessage(User* user, const MessageTarget& target, CTCTags::TagMessageDetails& details)
diff --git a/src/modules/m_filter.cpp b/src/modules/m_filter.cpp
index 30fd88622..9e26a1cf3 100644
--- a/src/modules/m_filter.cpp
+++ b/src/modules/m_filter.cpp
@@ -389,7 +389,7 @@ ModResult ModuleFilter::OnUserPreMessage(User* user, const MessageTarget& msgtar
if (!IS_LOCAL(user))
return MOD_RES_PASSTHRU;
- flags = (details.type == MSG_PRIVMSG) ? FLAG_PRIVMSG : FLAG_NOTICE;
+ flags = (details.type == MessageType::PRIVMSG) ? FLAG_PRIVMSG : FLAG_NOTICE;
const FilterResult* f = this->FilterMatch(user, details.text, flags);
if (f)
diff --git a/src/modules/m_hostchange.cpp b/src/modules/m_hostchange.cpp
index 0c6ee7744..22df16eee 100644
--- a/src/modules/m_hostchange.cpp
+++ b/src/modules/m_hostchange.cpp
@@ -30,16 +30,17 @@
class HostRule final
{
public:
- enum HostChangeAction
+ enum class HostChangeAction
+ : uint8_t
{
// Add the user's account name to their hostname.
- HCA_ADDACCOUNT,
+ ADD_ACCOUNT,
// Add the user's nickname to their hostname.
- HCA_ADDNICK,
+ ADD_NICK,
// Set the user's hostname to the specific value.
- HCA_SET
+ SET,
};
private:
@@ -71,7 +72,7 @@ private:
public:
HostRule(const std::shared_ptr<ConfigTag>& tag, const std::string& Mask, const std::string& Host)
- : action(HCA_SET)
+ : action(HostChangeAction::SET)
, host(Host)
, mask(Mask)
{
@@ -168,12 +169,12 @@ public:
if (stdalgo::string::equalsci(action, "addaccount"))
{
// The hostname is in the format [prefix]<account>[suffix].
- rules.emplace_back(tag, HostRule::HCA_ADDACCOUNT, mask, tag->getString("prefix"), tag->getString("suffix"));
+ rules.emplace_back(tag, HostRule::HostChangeAction::ADD_ACCOUNT, mask, tag->getString("prefix"), tag->getString("suffix"));
}
else if (stdalgo::string::equalsci(action, "addnick"))
{
// The hostname is in the format [prefix]<nick>[suffix].
- rules.emplace_back(tag, HostRule::HCA_ADDNICK, mask, tag->getString("prefix"), tag->getString("suffix"));
+ rules.emplace_back(tag, HostRule::HostChangeAction::ADD_NICK, mask, tag->getString("prefix"), tag->getString("suffix"));
}
else if (stdalgo::string::equalsci(action, "set"))
{
@@ -215,7 +216,7 @@ public:
continue;
std::string newhost;
- if (rule.GetAction() == HostRule::HCA_ADDACCOUNT)
+ if (rule.GetAction() == HostRule::HostChangeAction::ADD_ACCOUNT)
{
// Retrieve the account name.
const std::string* accountptr = accountapi ? accountapi->GetAccountName(user) : nullptr;
@@ -230,7 +231,7 @@ public:
// Create the hostname.
rule.Wrap(accountname, newhost);
}
- else if (rule.GetAction() == HostRule::HCA_ADDNICK)
+ else if (rule.GetAction() == HostRule::HostChangeAction::ADD_NICK)
{
// Remove invalid hostname characters.
const std::string nickname = CleanName(user->nick);
@@ -240,7 +241,7 @@ public:
// Create the hostname.
rule.Wrap(nickname, newhost);
}
- else if (rule.GetAction() == HostRule::HCA_SET)
+ else if (rule.GetAction() == HostRule::HostChangeAction::SET)
{
newhost.assign(rule.GetHost());
}
diff --git a/src/modules/m_messageflood.cpp b/src/modules/m_messageflood.cpp
index 02a81121f..ff919c4bc 100644
--- a/src/modules/m_messageflood.cpp
+++ b/src/modules/m_messageflood.cpp
@@ -186,7 +186,7 @@ public:
ModResult OnUserPreMessage(User* user, const MessageTarget& target, MessageDetails& details) override
{
- return HandleMessage(user, target, (details.type == MSG_PRIVMSG ? privmsg : notice));
+ return HandleMessage(user, target, (details.type == MessageType::PRIVMSG ? privmsg : notice));
}
ModResult OnUserPreTagMessage(User* user, const MessageTarget& target, CTCTags::TagMessageDetails& details) override
diff --git a/src/modules/m_nonotice.cpp b/src/modules/m_nonotice.cpp
index 8d7d697fa..cb722d74c 100644
--- a/src/modules/m_nonotice.cpp
+++ b/src/modules/m_nonotice.cpp
@@ -49,7 +49,7 @@ public:
ModResult OnUserPreMessage(User* user, const MessageTarget& target, MessageDetails& details) override
{
- if ((details.type == MSG_NOTICE) && (target.type == MessageTarget::TYPE_CHANNEL) && (IS_LOCAL(user)))
+ if ((details.type == MessageType::NOTICE) && (target.type == MessageTarget::TYPE_CHANNEL) && (IS_LOCAL(user)))
{
Channel* c = target.Get<Channel>();
diff --git a/src/modules/m_showfile.cpp b/src/modules/m_showfile.cpp
index c1387a269..4fee8b8e6 100644
--- a/src/modules/m_showfile.cpp
+++ b/src/modules/m_showfile.cpp
@@ -73,7 +73,7 @@ public:
LocalUser* const localuser = IS_LOCAL(user);
for (const auto& line : contents)
{
- ClientProtocol::Messages::Privmsg msg(ClientProtocol::Messages::Privmsg::nocopy, ServerInstance->FakeClient, localuser, line, ((method == SF_MSG) ? MSG_PRIVMSG : MSG_NOTICE));
+ ClientProtocol::Messages::Privmsg msg(ClientProtocol::Messages::Privmsg::nocopy, ServerInstance->FakeClient, localuser, line, ((method == SF_MSG) ? MessageType::PRIVMSG : MessageType::NOTICE));
localuser->Send(ServerInstance->GetRFCEvents().privmsg, msg);
}
}
diff --git a/src/modules/m_silence.cpp b/src/modules/m_silence.cpp
index 3d53f00e3..35c33133b 100644
--- a/src/modules/m_silence.cpp
+++ b/src/modules/m_silence.cpp
@@ -485,9 +485,9 @@ public:
{
if (is_ctcp)
flag = SilenceEntry::SF_CTCP_CHANNEL;
- else if (details.type == MSG_NOTICE)
+ else if (details.type == MessageType::NOTICE)
flag = SilenceEntry::SF_NOTICE_CHANNEL;
- else if (details.type == MSG_PRIVMSG)
+ else if (details.type == MessageType::PRIVMSG)
flag = SilenceEntry::SF_PRIVMSG_CHANNEL;
return BuildChannelExempts(user, target.Get<Channel>(), flag, details.exemptions);
@@ -496,9 +496,9 @@ public:
{
if (is_ctcp)
flag = SilenceEntry::SF_CTCP_USER;
- else if (details.type == MSG_NOTICE)
+ else if (details.type == MessageType::NOTICE)
flag = SilenceEntry::SF_NOTICE_USER;
- else if (details.type == MSG_PRIVMSG)
+ else if (details.type == MessageType::PRIVMSG)
flag = SilenceEntry::SF_PRIVMSG_USER;
if (!CanReceiveMessage(user, target.Get<User>(), flag))
diff --git a/src/modules/m_spanningtree/main.cpp b/src/modules/m_spanningtree/main.cpp
index 6f517afa2..138a369d6 100644
--- a/src/modules/m_spanningtree/main.cpp
+++ b/src/modules/m_spanningtree/main.cpp
@@ -417,7 +417,7 @@ void ModuleSpanningTree::OnUserPostMessage(User* user, const MessageTarget& targ
if (!IS_LOCAL(user))
return;
- const char* message_type = (details.type == MSG_PRIVMSG ? "PRIVMSG" : "NOTICE");
+ const char* message_type = (details.type == MessageType::PRIVMSG ? "PRIVMSG" : "NOTICE");
switch (target.type)
{
case MessageTarget::TYPE_USER:
diff --git a/src/modules/m_spanningtree/protocolinterface.cpp b/src/modules/m_spanningtree/protocolinterface.cpp
index 77e92f32e..efd47b70e 100644
--- a/src/modules/m_spanningtree/protocolinterface.cpp
+++ b/src/modules/m_spanningtree/protocolinterface.cpp
@@ -109,7 +109,7 @@ void SpanningTreeProtocolInterface::SendSNONotice(char snomask, const std::strin
void SpanningTreeProtocolInterface::SendMessage(const Channel* target, char status, const std::string& text, MessageType msgtype)
{
- const char* cmd = (msgtype == MSG_PRIVMSG ? "PRIVMSG" : "NOTICE");
+ const char* cmd = (msgtype == MessageType::PRIVMSG ? "PRIVMSG" : "NOTICE");
CUList exempt_list;
ClientProtocol::TagMap tags;
Utils->SendChannelMessage(ServerInstance->FakeClient, target, text, status, tags, exempt_list, cmd);
@@ -117,7 +117,7 @@ void SpanningTreeProtocolInterface::SendMessage(const Channel* target, char stat
void SpanningTreeProtocolInterface::SendMessage(const User* target, const std::string& text, MessageType msgtype)
{
- CmdBuilder p(msgtype == MSG_PRIVMSG ? "PRIVMSG" : "NOTICE");
+ CmdBuilder p(msgtype == MessageType::PRIVMSG ? "PRIVMSG" : "NOTICE");
p.push(target->uuid);
p.push_last(text);
p.Unicast(target);