summaryrefslogtreecommitdiff
path: root/src/modules/hs_request.c
diff options
context:
space:
mode:
authorcyberbotx <cyberbotx@5417fbe8-f217-4b02-8779-1006273d7864>2009-04-03 00:16:15 +0000
committercyberbotx <cyberbotx@5417fbe8-f217-4b02-8779-1006273d7864>2009-04-03 00:16:15 +0000
commitc6ef1e0390abe38404742d2355145d6f671ca2dc (patch)
tree07a5ae72de7c61f282895efa3e03f11ce5faca5e /src/modules/hs_request.c
parent48ef6617acff38cdce32233d447c4317b61ab048 (diff)
Added service argument to OnPreCommand, added OnPostCommand event, changed the following modules to use On[Pre|Post]Command instead of hooking into existing commands: hs_request, ns_maxemail, and os_info.
git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@2242 5417fbe8-f217-4b02-8779-1006273d7864
Diffstat (limited to 'src/modules/hs_request.c')
-rw-r--r--src/modules/hs_request.c81
1 files changed, 34 insertions, 47 deletions
diff --git a/src/modules/hs_request.c b/src/modules/hs_request.c
index a5e8a016a..9d043e6d0 100644
--- a/src/modules/hs_request.c
+++ b/src/modules/hs_request.c
@@ -366,27 +366,6 @@ class HSListBase : public Command
}
};
-class CommandHSList : public HSListBase
-{
- public:
- CommandHSList() : HSListBase("LIST", 0, 1)
- {
- }
-
- CommandReturn Execute(User *u, std::vector<std::string> &params)
- {
- const char *key = params.size() ? params[0].c_str() : NULL;
-
- if (!key)
- return MOD_CONT;
-
- if (stricmp(key, "+req"))
- return MOD_CONT;
-
- return this->DoList(u, params);
- }
-};
-
class CommandHSWaiting : public HSListBase
{
public:
@@ -412,29 +391,6 @@ class CommandHSWaiting : public HSListBase
}
};
-class CommandNSDrop : public Command
-{
- public:
- CommandNSDrop() : Command("DROP", 0, 0)
- {
- }
-
- CommandReturn Execute(User *u, std::vector<std::string> &params)
- {
- HostCore *tmp;
- bool found = false;
- NickAlias *na;
-
- na = findnick(u->nick);
- tmp = findHostCore(hs_request_head, u->nick, &found);
-
- if (found && na)
- hs_request_head = deleteHostCore(hs_request_head, tmp);
-
- return MOD_CONT;
- }
-};
-
class HSRequest : public Module
{
public:
@@ -446,10 +402,8 @@ class HSRequest : public Module
this->AddCommand(HOSTSERV, new CommandHSActivate(), MOD_HEAD);
this->AddCommand(HOSTSERV, new CommandHSReject(), MOD_HEAD);
this->AddCommand(HOSTSERV, new CommandHSWaiting(), MOD_HEAD);
- this->AddCommand(HOSTSERV, new CommandHSList(), MOD_HEAD);
-
- this->AddCommand(NICKSERV, new CommandNSDrop(), MOD_HEAD);
+ ModuleManager::Attach(I_OnPreCommand, this);
ModuleManager::Attach(I_OnSaveDatabase, this);
ModuleManager::Attach(I_OnBackupDatabase, this);
@@ -731,6 +685,39 @@ class HSRequest : public Module
delete [] HSRequestDBName;
}
+ EventReturn OnPreCommand(User *u, const std::string &service, const std::string &command, const std::vector<std::string> &params)
+ {
+ if (service == s_HostServ)
+ {
+ if (command == "LIST")
+ {
+ const char *key = params.size() ? params[0].c_str() : NULL;
+
+ if (key && !stricmp(key, "+req"))
+ {
+ std::vector<std::string> emptyParams;
+ Command *c = findCommand(HOSTSERV, "WAITING");
+ c->Execute(u, emptyParams);
+ return EVENT_STOP;
+ }
+ }
+ }
+ else if (service == s_NickServ)
+ {
+ if (command == "DROP")
+ {
+ bool found = false;
+ NickAlias *na = findnick(u->nick);
+ HostCore *tmp = findHostCore(hs_request_head, u->nick, &found);
+
+ if (found && na)
+ hs_request_head = deleteHostCore(hs_request_head, tmp);
+ }
+ }
+
+ return EVENT_CONTINUE;
+ }
+
void OnSaveDatabase()
{
FILE *fp;