summaryrefslogtreecommitdiff
path: root/src/commands/cmd_whowas.cpp
diff options
context:
space:
mode:
authordanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>2009-09-03 21:06:44 +0000
committerdanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>2009-09-03 21:06:44 +0000
commit17fd32bf7492aa40ce531b64c81754f039907ca7 (patch)
tree52fce21614c7697cee868135fe1c715be09dfe0e /src/commands/cmd_whowas.cpp
parent1c1c5fc3f01c42a09d34594989679bbc8fb21c0d (diff)
Remove HandleInternal and HandleServer, they are duplicated by Request* and FakeUser
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@11672 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/commands/cmd_whowas.cpp')
-rw-r--r--src/commands/cmd_whowas.cpp75
1 files changed, 42 insertions, 33 deletions
diff --git a/src/commands/cmd_whowas.cpp b/src/commands/cmd_whowas.cpp
index 5e77671a6..3df97086e 100644
--- a/src/commands/cmd_whowas.cpp
+++ b/src/commands/cmd_whowas.cpp
@@ -82,33 +82,7 @@ CmdResult CommandWhowas::Handle (const std::vector<std::string>& parameters, Use
return CMD_SUCCESS;
}
-CmdResult CommandWhowas::HandleInternal(const unsigned int id, const std::deque<classbase*> &parameters)
-{
- switch (id)
- {
- case WHOWAS_ADD:
- AddToWhoWas(static_cast<User*>(parameters[0]));
- break;
-
- case WHOWAS_STATS:
- GetStats(static_cast<Extensible*>(parameters[0]));
- break;
-
- case WHOWAS_PRUNE:
- PruneWhoWas(ServerInstance->Time());
- break;
-
- case WHOWAS_MAINTAIN:
- MaintainWhoWas(ServerInstance->Time());
- break;
-
- default:
- break;
- }
- return CMD_SUCCESS;
-}
-
-void CommandWhowas::GetStats(Extensible* ext)
+std::string CommandWhowas::GetStats()
{
int whowas_size = 0;
int whowas_bytes = 0;
@@ -123,7 +97,7 @@ void CommandWhowas::GetStats(Extensible* ext)
}
}
stats.assign("Whowas(MAPSETS) " +ConvToStr(whowas_size)+" ("+ConvToStr(whowas_bytes)+" bytes)");
- ext->Extend("stats", stats.c_str());
+ return stats;
}
void CommandWhowas::AddToWhoWas(User* user)
@@ -323,12 +297,47 @@ WhoWasGroup::~WhoWasGroup()
/* every hour, run this function which removes all entries older than Config->WhoWasMaxKeep */
void WhoWasMaintainTimer::Tick(time_t)
{
- Command* whowas_command = ServerInstance->Parser->GetHandler("WHOWAS");
- if (whowas_command)
+ Module* whowas = ServerInstance->Modules->Find("cmd_whowas.so");
+ if (whowas)
{
- std::deque<classbase*> params;
- whowas_command->HandleInternal(WHOWAS_MAINTAIN, params);
+ WhowasRequest(whowas, whowas, WhowasRequest::WHOWAS_MAINTAIN).Send();
}
}
-COMMAND_INIT(CommandWhowas)
+class ModuleWhoWas : public Module
+{
+ CommandWhowas cmd;
+ public:
+ ModuleWhoWas(InspIRCd *Me) : Module(Me), cmd(Me, this)
+ {
+ ServerInstance->AddCommand(&cmd);
+ }
+
+ const char* OnRequest(Request* request)
+ {
+ WhowasRequest* req = static_cast<WhowasRequest*>(request);
+ switch (req->type)
+ {
+ case WhowasRequest::WHOWAS_ADD:
+ cmd.AddToWhoWas(req->user);
+ break;
+ case WhowasRequest::WHOWAS_STATS:
+ req->value = cmd.GetStats();
+ break;
+ case WhowasRequest::WHOWAS_PRUNE:
+ cmd.PruneWhoWas(ServerInstance->Time());
+ break;
+ case WhowasRequest::WHOWAS_MAINTAIN:
+ cmd.MaintainWhoWas(ServerInstance->Time());
+ break;
+ }
+ return NULL;
+ }
+
+ Version GetVersion()
+ {
+ return Version("WHOWAS Command", VF_VENDOR);
+ }
+};
+
+MODULE_INIT(ModuleWhoWas)