#include "numericbuilder.h"
#include "modules/whois.h"
-#include "modules/stats.h"
I_OnUserPostNick, I_OnPreMode, I_On005Numeric, I_OnKill, I_OnLoadModule,
I_OnUnloadModule, I_OnBackgroundTimer, I_OnPreCommand, I_OnCheckReady, I_OnCheckInvite,
I_OnRawMode, I_OnCheckKey, I_OnCheckLimit, I_OnCheckBan, I_OnCheckChannelBan, I_OnExtBanCheck,
- I_OnStats, I_OnChangeLocalUserHost, I_OnPreTopicChange,
+ I_OnChangeLocalUserHost, I_OnPreTopicChange,
I_OnPostTopicChange, I_OnPostConnect,
I_OnChangeLocalUserGECOS, I_OnUserRegister, I_OnChannelPreDelete, I_OnChannelDelete,
I_OnPostOper, I_OnSetAway, I_OnPostCommand, I_OnPostJoin,
*/
virtual ModResult OnExtBanCheck(User* user, Channel* chan, char type);
- /** Called on all /STATS commands
- * This method is triggered for all /STATS use, including stats symbols handled by the core.
- * @param stats Context of the /STATS request, contains requesting user, list of answer rows etc.
- * @return 1 to block the /STATS from being processed by the core, 0 to allow it
- */
- virtual ModResult OnStats(Stats::Context& stats);
-
/** Called whenever a change of a local users displayed host is attempted.
* Return 1 to deny the host change, or 0 to allow it.
* @param user The user whos host will be changed
#pragma once
+#include "event.h"
+
namespace Stats
{
class Context;
+ class EventListener;
class Row;
}
+class Stats::EventListener : public Events::ModuleEventListener
+{
+ public:
+ EventListener(Module* mod)
+ : ModuleEventListener(mod, "event/stats")
+ {
+ }
+
+ /** Called when the STATS command is executed.
+ * @param stats Context of the /STATS request, contains requesting user, list of answer rows etc.
+ * @return MOD_RES_DENY if the stats request has been fulfilled. Otherwise, MOD_RES_PASSTHRU.
+ */
+ virtual ModResult OnStats(Stats::Context& stats) = 0;
+};
+
class Stats::Row : public Numeric::Numeric
{
public:
#include "inspircd.h"
#include "xline.h"
+#include "modules/stats.h"
#ifdef _WIN32
#include <psapi.h>
*/
class CommandStats : public Command
{
+ Events::ModuleEventProvider statsevprov;
void DoStats(Stats::Context& stats);
+
public:
/** Constructor for stats.
*/
- CommandStats ( Module* parent) : Command(parent,"STATS",1,2) { allow_empty_last_param = false; syntax = "<stats-symbol> [<servername>]"; }
+ CommandStats(Module* Creator)
+ : Command(Creator, "STATS", 1, 2)
+ , statsevprov(Creator, "event/stats")
+ {
+ allow_empty_last_param = false;
+ syntax = "<stats-symbol> [<servername>]";
+ }
+
/** Handle command.
* @param parameters The parameters to the command
* @param user The user issuing the command
}
ModResult MOD_RESULT;
- FIRST_MOD_RESULT(OnStats, MOD_RESULT, (stats));
+ FIRST_MOD_RESULT_CUSTOM(statsevprov, Stats::EventListener, OnStats, MOD_RESULT, (stats));
if (MOD_RESULT == MOD_RES_DENY)
{
stats.AddRow(219, statschar, "End of /STATS report");
#include "inspircd.h"
#include "commands/cmd_whowas.h"
+#include "modules/stats.h"
enum
{
stdalgo::delete_all(entries);
}
-class ModuleWhoWas : public Module
+class ModuleWhoWas : public Module, public Stats::EventListener
{
CommandWhowas cmd;
public:
- ModuleWhoWas() : cmd(this)
+ ModuleWhoWas()
+ : Stats::EventListener(this)
+ , cmd(this)
{
}
ModResult Module::OnCheckChannelBan(User*, Channel*) { DetachEvent(I_OnCheckChannelBan); return MOD_RES_PASSTHRU; }
ModResult Module::OnCheckBan(User*, Channel*, const std::string&) { DetachEvent(I_OnCheckBan); return MOD_RES_PASSTHRU; }
ModResult Module::OnExtBanCheck(User*, Channel*, char) { DetachEvent(I_OnExtBanCheck); return MOD_RES_PASSTHRU; }
-ModResult Module::OnStats(Stats::Context&) { DetachEvent(I_OnStats); return MOD_RES_PASSTHRU; }
ModResult Module::OnChangeLocalUserHost(LocalUser*, const std::string&) { DetachEvent(I_OnChangeLocalUserHost); return MOD_RES_PASSTHRU; }
ModResult Module::OnChangeLocalUserGECOS(LocalUser*, const std::string&) { DetachEvent(I_OnChangeLocalUserGECOS); return MOD_RES_PASSTHRU; }
ModResult Module::OnPreTopicChange(User*, Channel*, const std::string&) { DetachEvent(I_OnPreTopicChange); return MOD_RES_PASSTHRU; }
#include "inspircd.h"
#include "xline.h"
+#include "modules/stats.h"
// Fix warnings about the use of commas at end of enumerator lists on C++03.
#if defined __clang__
RPL_WHOISCOUNTRY = 344
};
-class ModuleGeoIP : public Module, public Whois::EventListener
+class ModuleGeoIP : public Module, public Stats::EventListener, public Whois::EventListener
{
StringExtItem ext;
bool extban;
public:
ModuleGeoIP()
- : Whois::EventListener(this)
+ : Stats::EventListener(this)
+ , Whois::EventListener(this)
, ext("geoip_cc", ExtensionItem::EXT_USER, this)
, extban(true)
, gi(NULL)
#include "inspircd.h"
#include "xline.h"
+#include "modules/stats.h"
/** Holds a CBAN item
*/
}
};
-class ModuleCBan : public Module
+class ModuleCBan : public Module, public Stats::EventListener
{
CommandCBan mycommand;
CBanFactory f;
public:
- ModuleCBan() : mycommand(this)
+ ModuleCBan()
+ : Stats::EventListener(this)
+ , mycommand(this)
{
}
#include "inspircd.h"
#include "xline.h"
#include "modules/dns.h"
+#include "modules/stats.h"
/* Class holding data for a single entry */
class DNSBLConfEntry : public refcountbase
}
};
-class ModuleDNSBL : public Module
+class ModuleDNSBL : public Module, public Stats::EventListener
{
std::vector<reference<DNSBLConfEntry> > DNSBLConfEntries;
dynamic_reference<DNS::Manager> DNS;
}
public:
ModuleDNSBL()
- : DNS(this, "DNS")
+ : Stats::EventListener(this)
+ , DNS(this, "DNS")
, nameExt("dnsbl_match", ExtensionItem::EXT_USER, this)
, countExt("dnsbl_pending", ExtensionItem::EXT_USER, this)
{
#include "modules/regex.h"
#include "modules/server.h"
#include "modules/shun.h"
+#include "modules/stats.h"
enum FilterFlags
{
}
};
-class ModuleFilter : public Module, public ServerEventListener
+class ModuleFilter : public Module, public ServerEventListener, public Stats::EventListener
{
typedef insp::flat_set<std::string, irc::insensitive_swo> ExemptTargetSet;
ModuleFilter::ModuleFilter()
: ServerEventListener(this)
+ , Stats::EventListener(this)
, initing(true)
, filtcommand(this)
, RegexEngine(this, "regex")
#include "inspircd.h"
+#include "modules/stats.h"
/** Handles user mode +H
*/
}
};
-class ModuleHideOper : public Module, public Whois::LineEventListener
+class ModuleHideOper : public Module, public Stats::EventListener, public Whois::LineEventListener
{
HideOper hm;
bool active;
public:
ModuleHideOper()
- : Whois::LineEventListener(this)
+ : Stats::EventListener(this)
+ , Whois::LineEventListener(this)
, hm(this)
, active(false)
{
#include "inspircd.h"
#include "modules/regex.h"
+#include "modules/stats.h"
#include "xline.h"
static bool ZlineOnMatch = false;
}
};
-class ModuleRLine : public Module
+class ModuleRLine : public Module, public Stats::EventListener
{
dynamic_reference<RegexFactory> rxfactory;
RLineFactory f;
public:
ModuleRLine()
- : rxfactory(this, "regex"), f(rxfactory), r(this, f)
+ : Stats::EventListener(this)
+ , rxfactory(this, "regex")
+ , f(rxfactory)
+ , r(this, f)
, initing(true)
{
}
#include "inspircd.h"
#include "xline.h"
#include "modules/shun.h"
+#include "modules/stats.h"
/** An XLineFactory specialized to generate shun pointers
}
};
-class ModuleShun : public Module
+class ModuleShun : public Module, public Stats::EventListener
{
CommandShun cmd;
ShunFactory f;
bool affectopers;
public:
- ModuleShun() : cmd(this)
+ ModuleShun()
+ : Stats::EventListener(this)
+ , cmd(this)
{
}
#include "translate.h"
ModuleSpanningTree::ModuleSpanningTree()
- : rconnect(this), rsquit(this), map(this)
+ : Stats::EventListener(this)
+ , rconnect(this)
+ , rsquit(this)
+ , map(this)
, commands(this)
, currmembid(0)
, eventprov(this, "event/server")
#include "inspircd.h"
#include "event.h"
#include "modules/dns.h"
+#include "modules/stats.h"
#include "servercommand.h"
#include "commands.h"
#include "protocolinterface.h"
/** This is the main class for the spanningtree module
*/
-class ModuleSpanningTree : public Module
+class ModuleSpanningTree : public Module, public Stats::EventListener
{
/** Client to server commands, registered in the core
*/
#include "inspircd.h"
#include "xline.h"
+#include "modules/stats.h"
namespace
{
}
};
-class ModuleSVSHold : public Module
+class ModuleSVSHold : public Module, public Stats::EventListener
{
CommandSvshold cmd;
SVSHoldFactory s;
public:
- ModuleSVSHold() : cmd(this)
+ ModuleSVSHold()
+ : Stats::EventListener(this)
+ , cmd(this)
{
}
#include "inspircd.h"
#include "xline.h"
+#include "modules/stats.h"
/** An XLineFactory specialized to generate GLine* pointers
*/