summaryrefslogtreecommitdiff
path: root/src/modules
diff options
context:
space:
mode:
authorAttila Molnar <attilamolnar@hush.com>2015-04-28 15:16:22 +0200
committerAttila Molnar <attilamolnar@hush.com>2015-04-28 15:16:22 +0200
commit8f34594cb7d600ccff100dff1817b69b03756ea2 (patch)
treefecbd61c35bd75add033a71b42043a0c99624c99 /src/modules
parent04eb0e182dec8518d1dfd15a09b8054d1501a4ef (diff)
Move OnWhois* events to core_whois, add Whois::Context
Remove InspIRCd::SendWhoisLine()
Diffstat (limited to 'src/modules')
-rw-r--r--src/modules/m_botmode.cpp11
-rw-r--r--src/modules/m_customtitle.cpp12
-rw-r--r--src/modules/m_helpop.cpp12
-rw-r--r--src/modules/m_services_account.cpp10
-rw-r--r--src/modules/m_servprotect.cpp11
-rw-r--r--src/modules/m_showwhois.cpp12
-rw-r--r--src/modules/m_sslinfo.cpp16
-rw-r--r--src/modules/m_swhois.cpp12
8 files changed, 55 insertions, 41 deletions
diff --git a/src/modules/m_botmode.cpp b/src/modules/m_botmode.cpp
index 56c94c7c7..419af0153 100644
--- a/src/modules/m_botmode.cpp
+++ b/src/modules/m_botmode.cpp
@@ -29,12 +29,13 @@ class BotMode : public SimpleUserModeHandler
BotMode(Module* Creator) : SimpleUserModeHandler(Creator, "bot", 'B') { }
};
-class ModuleBotMode : public Module
+class ModuleBotMode : public Module, public Whois::EventListener
{
BotMode bm;
public:
ModuleBotMode()
- : bm(this)
+ : Whois::EventListener(this)
+ , bm(this)
{
}
@@ -43,11 +44,11 @@ class ModuleBotMode : public Module
return Version("Provides user mode +B to mark the user as a bot",VF_VENDOR);
}
- void OnWhois(User* src, User* dst) CXX11_OVERRIDE
+ void OnWhois(Whois::Context& whois) CXX11_OVERRIDE
{
- if (dst->IsModeSet(bm))
+ if (whois.GetTarget()->IsModeSet(bm))
{
- ServerInstance->SendWhoisLine(src, dst, 335, ":is a bot on "+ServerInstance->Config->Network);
+ whois.SendLine(335, ":is a bot on " + ServerInstance->Config->Network);
}
}
};
diff --git a/src/modules/m_customtitle.cpp b/src/modules/m_customtitle.cpp
index 6f9380506..b86bf1809 100644
--- a/src/modules/m_customtitle.cpp
+++ b/src/modules/m_customtitle.cpp
@@ -70,26 +70,28 @@ class CommandTitle : public Command
};
-class ModuleCustomTitle : public Module
+class ModuleCustomTitle : public Module, public Whois::LineEventListener
{
CommandTitle cmd;
public:
- ModuleCustomTitle() : cmd(this)
+ ModuleCustomTitle()
+ : Whois::LineEventListener(this)
+ , cmd(this)
{
}
// :kenny.chatspike.net 320 Brain Azhrarn :is getting paid to play games.
- ModResult OnWhoisLine(User* user, User* dest, int &numeric, std::string &text) CXX11_OVERRIDE
+ ModResult OnWhoisLine(Whois::Context& whois, unsigned int& numeric, std::string& text) CXX11_OVERRIDE
{
/* We use this and not OnWhois because this triggers for remote, too */
if (numeric == 312)
{
/* Insert our numeric before 312 */
- const std::string* ctitle = cmd.ctitle.get(dest);
+ const std::string* ctitle = cmd.ctitle.get(whois.GetTarget());
if (ctitle)
{
- ServerInstance->SendWhoisLine(user, dest, 320, ":%s", ctitle->c_str());
+ whois.SendLine(320, ":%s", ctitle->c_str());
}
}
/* Don't block anything */
diff --git a/src/modules/m_helpop.cpp b/src/modules/m_helpop.cpp
index 4c0af15af..ef9ae5e22 100644
--- a/src/modules/m_helpop.cpp
+++ b/src/modules/m_helpop.cpp
@@ -94,14 +94,16 @@ class CommandHelpop : public Command
}
};
-class ModuleHelpop : public Module
+class ModuleHelpop : public Module, public Whois::EventListener
{
CommandHelpop cmd;
Helpop ho;
public:
ModuleHelpop()
- : cmd(this), ho(this)
+ : Whois::EventListener(this)
+ , cmd(this)
+ , ho(this)
{
}
@@ -139,11 +141,11 @@ class ModuleHelpop : public Module
helpop_map.swap(help);
}
- void OnWhois(User* src, User* dst) CXX11_OVERRIDE
+ void OnWhois(Whois::Context& whois) CXX11_OVERRIDE
{
- if (dst->IsModeSet(ho))
+ if (whois.GetTarget()->IsModeSet(ho))
{
- ServerInstance->SendWhoisLine(src, dst, 310, ":is available for help.");
+ whois.SendLine(310, ":is available for help.");
}
}
diff --git a/src/modules/m_services_account.cpp b/src/modules/m_services_account.cpp
index 1af06846e..4ad339fcb 100644
--- a/src/modules/m_services_account.cpp
+++ b/src/modules/m_services_account.cpp
@@ -156,19 +156,19 @@ class ModuleServicesAccount : public Module
}
/* <- :twisted.oscnet.org 330 w00t2 w00t2 w00t :is logged in as */
- void OnWhois(User* source, User* dest) CXX11_OVERRIDE
+ void OnWhois(Whois::Context& whois) CXX11_OVERRIDE
{
- std::string *account = accountname.get(dest);
+ std::string* account = accountname.get(whois.GetTarget());
if (account)
{
- ServerInstance->SendWhoisLine(source, dest, 330, "%s :is logged in as", account->c_str());
+ whois.SendLine(330, "%s :is logged in as", account->c_str());
}
- if (dest->IsModeSet(m5))
+ if (whois.GetTarget()->IsModeSet(m5))
{
/* user is registered */
- ServerInstance->SendWhoisLine(source, dest, 307, ":is a registered nick");
+ whois.SendLine(307, ":is a registered nick");
}
}
diff --git a/src/modules/m_servprotect.cpp b/src/modules/m_servprotect.cpp
index edad324d1..2ed37b9e4 100644
--- a/src/modules/m_servprotect.cpp
+++ b/src/modules/m_servprotect.cpp
@@ -42,12 +42,13 @@ class ServProtectMode : public ModeHandler
}
};
-class ModuleServProtectMode : public Module
+class ModuleServProtectMode : public Module, public Whois::EventListener
{
ServProtectMode bm;
public:
ModuleServProtectMode()
- : bm(this)
+ : Whois::EventListener(this)
+ , bm(this)
{
}
@@ -56,11 +57,11 @@ class ModuleServProtectMode : public Module
return Version("Provides usermode +k to protect services from kicks, kills, and mode changes.", VF_VENDOR);
}
- void OnWhois(User* user, User* dest) CXX11_OVERRIDE
+ void OnWhois(Whois::Context& whois) CXX11_OVERRIDE
{
- if (dest->IsModeSet(bm))
+ if (whois.GetTarget()->IsModeSet(bm))
{
- ServerInstance->SendWhoisLine(user, dest, 310, ":is a Network Service on "+ServerInstance->Config->Network);
+ whois.SendLine(310, ":is a Network Service on " + ServerInstance->Config->Network);
}
}
diff --git a/src/modules/m_showwhois.cpp b/src/modules/m_showwhois.cpp
index ba17942cb..3cb85f3fb 100644
--- a/src/modules/m_showwhois.cpp
+++ b/src/modules/m_showwhois.cpp
@@ -69,7 +69,7 @@ class WhoisNoticeCmd : public Command
}
};
-class ModuleShowwhois : public Module
+class ModuleShowwhois : public Module, public Whois::EventListener
{
bool ShowWhoisFromOpers;
SeeWhois sw;
@@ -78,7 +78,9 @@ class ModuleShowwhois : public Module
public:
ModuleShowwhois()
- : sw(this), cmd(this)
+ : Whois::EventListener(this)
+ , sw(this)
+ , cmd(this)
{
}
@@ -95,9 +97,11 @@ class ModuleShowwhois : public Module
return Version("Allows opers to set +W to see when a user uses WHOIS on them",VF_OPTCOMMON|VF_VENDOR);
}
- void OnWhois(User* source, User* dest) CXX11_OVERRIDE
+ void OnWhois(Whois::Context& whois) CXX11_OVERRIDE
{
- if (!dest->IsModeSet(sw) || source == dest)
+ User* const source = whois.GetSource();
+ User* const dest = whois.GetTarget();
+ if (!dest->IsModeSet(sw) || whois.IsSelfWhois())
return;
if (!ShowWhoisFromOpers && source->IsOper())
diff --git a/src/modules/m_sslinfo.cpp b/src/modules/m_sslinfo.cpp
index 03e9bed96..523d52abb 100644
--- a/src/modules/m_sslinfo.cpp
+++ b/src/modules/m_sslinfo.cpp
@@ -139,14 +139,16 @@ class UserCertificateAPIImpl : public UserCertificateAPIBase
}
};
-class ModuleSSLInfo : public Module
+class ModuleSSLInfo : public Module, public Whois::EventListener
{
CommandSSLInfo cmd;
UserCertificateAPIImpl APIImpl;
public:
ModuleSSLInfo()
- : cmd(this), APIImpl(this, cmd.CertExt)
+ : Whois::EventListener(this)
+ , cmd(this)
+ , APIImpl(this, cmd.CertExt)
{
}
@@ -155,15 +157,15 @@ class ModuleSSLInfo : public Module
return Version("SSL Certificate Utilities", VF_VENDOR);
}
- void OnWhois(User* source, User* dest) CXX11_OVERRIDE
+ void OnWhois(Whois::Context& whois) CXX11_OVERRIDE
{
- ssl_cert* cert = cmd.CertExt.get(dest);
+ ssl_cert* cert = cmd.CertExt.get(whois.GetTarget());
if (cert)
{
- ServerInstance->SendWhoisLine(source, dest, 671, ":is using a secure connection");
+ whois.SendLine(671, ":is using a secure connection");
bool operonlyfp = ServerInstance->Config->ConfValue("sslinfo")->getBool("operonly");
- if ((!operonlyfp || source == dest || source->IsOper()) && !cert->fingerprint.empty())
- ServerInstance->SendWhoisLine(source, dest, 276, ":has client certificate fingerprint %s", cert->fingerprint.c_str());
+ if ((!operonlyfp || whois.IsSelfWhois() || whois.GetSource()->IsOper()) && !cert->fingerprint.empty())
+ whois.SendLine(276, ":has client certificate fingerprint %s", cert->fingerprint.c_str());
}
}
diff --git a/src/modules/m_swhois.cpp b/src/modules/m_swhois.cpp
index ddc3726be..e75921a80 100644
--- a/src/modules/m_swhois.cpp
+++ b/src/modules/m_swhois.cpp
@@ -81,26 +81,28 @@ class CommandSwhois : public Command
};
-class ModuleSWhois : public Module
+class ModuleSWhois : public Module, public Whois::LineEventListener
{
CommandSwhois cmd;
public:
- ModuleSWhois() : cmd(this)
+ ModuleSWhois()
+ : Whois::LineEventListener(this)
+ , cmd(this)
{
}
// :kenny.chatspike.net 320 Brain Azhrarn :is getting paid to play games.
- ModResult OnWhoisLine(User* user, User* dest, int &numeric, std::string &text) CXX11_OVERRIDE
+ ModResult OnWhoisLine(Whois::Context& whois, unsigned int& numeric, std::string& text) CXX11_OVERRIDE
{
/* We use this and not OnWhois because this triggers for remote, too */
if (numeric == 312)
{
/* Insert our numeric before 312 */
- std::string* swhois = cmd.swhois.get(dest);
+ std::string* swhois = cmd.swhois.get(whois.GetTarget());
if (swhois)
{
- ServerInstance->SendWhoisLine(user, dest, 320, ":%s", swhois->c_str());
+ whois.SendLine(320, ":%s", swhois->c_str());
}
}