summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/cmd_modules.cpp3
-rw-r--r--src/command_parse.cpp13
-rw-r--r--src/modules.cpp1
-rw-r--r--src/modules/m_spanningtree.cpp22
4 files changed, 25 insertions, 14 deletions
diff --git a/src/cmd_modules.cpp b/src/cmd_modules.cpp
index fe6fa0258..f3f12eaed 100644
--- a/src/cmd_modules.cpp
+++ b/src/cmd_modules.cpp
@@ -33,7 +33,8 @@ char* itab[] = {
"OnCheckKey", "OnCheckLimit", "OnCheckBan", "OnStats", "OnChangeLocalUserHost", "OnChangeLocalUserGecos", "OnLocalTopicChange",
"OnPostLocalTopicChange", "OnEvent", "OnRequest", "OnOperCompre", "OnGlobalOper", "OnPostConnect", "OnAddBan", "OnDelBan",
"OnRawSocketAccept", "OnRawSocketClose", "OnRawSocketWrite", "OnRawSocketRead", "OnChangeLocalUserGECOS", "OnUserRegister",
- "OnOperCompare", "OnChannelDelete", "OnPostOper", "OnSyncOtherMetaData", "OnSetAway", "OnCancelAway", "OnNamesList", NULL
+ "OnOperCompare", "OnChannelDelete", "OnPostOper", "OnSyncOtherMetaData", "OnSetAway", "OnCancelAway", "OnNamesList",
+ "OnPostCommand", NULL
};
diff --git a/src/command_parse.cpp b/src/command_parse.cpp
index 4c58d9b60..11f4b4635 100644
--- a/src/command_parse.cpp
+++ b/src/command_parse.cpp
@@ -284,7 +284,7 @@ bool CommandParser::IsValidCommand(const std::string &commandname, int pcnt, use
// calls a handler function for a command
-bool CommandParser::CallHandler(const std::string &commandname,const char** parameters, int pcnt, userrec *user)
+CmdResult CommandParser::CallHandler(const std::string &commandname,const char** parameters, int pcnt, userrec *user)
{
nspace::hash_map<std::string,command_t*>::iterator n = cmdlist.find(commandname);
@@ -298,19 +298,17 @@ bool CommandParser::CallHandler(const std::string &commandname,const char** para
{
if ((user->HasPermission(commandname)) || (!IS_LOCAL(user)))
{
- n->second->Handle(parameters,pcnt,user);
- return true;
+ return n->second->Handle(parameters,pcnt,user);
}
}
else
{
- n->second->Handle(parameters,pcnt,user);
- return true;
+ return n->second->Handle(parameters,pcnt,user);
}
}
}
}
- return false;
+ return CMD_INVALID;
}
void CommandParser::ProcessCommand(userrec *user, std::string &cmd)
@@ -383,8 +381,9 @@ void CommandParser::ProcessCommand(userrec *user, std::string &cmd)
* command handler call, as the handler
* may free the user structure!
*/
+ CmdResult result = cm->second->Handle(command_p,items,user);
- cm->second->Handle(command_p,items,user);
+ FOREACH_MOD(I_OnPostCommand,OnPostCommand(command, command_p, items, user, result));
return;
}
else
diff --git a/src/modules.cpp b/src/modules.cpp
index d3db06d45..f5e83c093 100644
--- a/src/modules.cpp
+++ b/src/modules.cpp
@@ -132,6 +132,7 @@ void Module::OnLoadModule(Module* mod,const std::string &name) { };
void Module::OnUnloadModule(Module* mod,const std::string &name) { };
void Module::OnBackgroundTimer(time_t curtime) { };
int Module::OnPreCommand(const std::string &command, const char** parameters, int pcnt, userrec *user, bool validated) { return 0; };
+void Module::OnPostCommand(const std::string &command, const char** parameters, int pcnt, userrec *user, CmdResult result) { };
bool Module::OnCheckReady(userrec* user) { return true; };
void Module::OnUserRegister(userrec* user) { };
int Module::OnUserPreKick(userrec* source, userrec* user, chanrec* chan, const std::string &reason) { return 0; };
diff --git a/src/modules/m_spanningtree.cpp b/src/modules/m_spanningtree.cpp
index b9113dfc5..c102209c5 100644
--- a/src/modules/m_spanningtree.cpp
+++ b/src/modules/m_spanningtree.cpp
@@ -3185,10 +3185,17 @@ class TreeSocket : public InspSocket
{
strparams[q] = params[q].c_str();
}
- if (!this->Instance->CallCommandHandler(command.c_str(), strparams, params.size(), who))
+ switch (this->Instance->CallCommandHandler(command.c_str(), strparams, params.size(), who))
{
- this->WriteLine("ERROR :Unrecognised command '"+std::string(command.c_str())+"' -- possibly loaded mismatched modules");
- return false;
+ case CMD_INVALID:
+ this->WriteLine("ERROR :Unrecognised command '"+std::string(command.c_str())+"' -- possibly loaded mismatched modules");
+ return false;
+ break;
+ case CMD_FAILURE:
+ return true;
+ break;
+ default:
+ break;
}
}
else
@@ -4279,7 +4286,11 @@ class ModuleSpanningTree : public Module
this->HandleVersion(parameters,pcnt,user);
return 1;
}
- else if (ServerInstance->IsValidModuleCommand(command, pcnt, user))
+ }
+
+ virtual void OnPostCommand(const std::string &command, const char** parameters, int pcnt, userrec *user, CmdResult result)
+ {
+ if ((result == CMD_SUCCESS) && (ServerInstance->IsValidModuleCommand(command, pcnt, user)))
{
// this bit of code cleverly routes all module commands
// to all remote severs *automatically* so that modules
@@ -4302,7 +4313,6 @@ class ModuleSpanningTree : public Module
ServerInstance->Log(DEBUG,"Globally route '%s'",command.c_str());
DoOneToMany(user->nick,command,params);
}
- return 0;
}
virtual void OnGetServerDescription(const std::string &servername,std::string &description)
@@ -4830,7 +4840,7 @@ class ModuleSpanningTree : public Module
List[I_OnUserQuit] = List[I_OnUserPostNick] = List[I_OnUserKick] = List[I_OnRemoteKill] = List[I_OnRehash] = 1;
List[I_OnOper] = List[I_OnAddGLine] = List[I_OnAddZLine] = List[I_OnAddQLine] = List[I_OnAddELine] = 1;
List[I_OnDelGLine] = List[I_OnDelZLine] = List[I_OnDelQLine] = List[I_OnDelELine] = List[I_ProtoSendMode] = List[I_OnMode] = 1;
- List[I_OnStats] = List[I_ProtoSendMetaData] = List[I_OnEvent] = List[I_OnSetAway] = List[I_OnCancelAway] = 1;
+ List[I_OnStats] = List[I_ProtoSendMetaData] = List[I_OnEvent] = List[I_OnSetAway] = List[I_OnCancelAway] = List[I_OnPostCommand] = 1;
}
/* It is IMPORTANT that m_spanningtree is the last module in the chain