Enhancement - Hooks

- Implemented pre-info-command, post-info-command hook.
This commit is contained in:
Paul Beckingham
2010-01-23 13:57:38 -05:00
parent d6daa336ca
commit c8d208b9be
3 changed files with 256 additions and 246 deletions

View File

@@ -185,7 +185,8 @@ bool Hooks::eventType (const std::string& event, std::string& type)
event == "pre-undo" || event == "post-undo" || event == "pre-undo" || event == "post-undo" ||
event == "pre-file-lock" || event == "post-file-lock" || event == "pre-file-lock" || event == "post-file-lock" ||
event == "pre-add-command" || event == "post-add-command" || event == "pre-add-command" || event == "post-add-command" ||
event == "pre-delete-command" || event == "post-delete-command") event == "pre-delete-command" || event == "post-delete-command" ||
event == "pre-info-command" || event == "post-info-command")
{ {
type = "program"; type = "program";
return true; return true;

View File

@@ -52,7 +52,8 @@ extern Context context;
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
int handleAdd (std::string &outs) int handleAdd (std::string &outs)
{ {
context.hooks.trigger ("pre-add-command"); if (context.hooks.trigger ("pre-add-command"))
{
std::stringstream out; std::stringstream out;
context.task.set ("uuid", uuid ()); context.task.set ("uuid", uuid ());
@@ -114,6 +115,8 @@ int handleAdd (std::string &outs)
outs = out.str (); outs = out.str ();
context.hooks.trigger ("post-add-command"); context.hooks.trigger ("post-add-command");
}
return 0; return 0;
} }

View File

@@ -300,6 +300,9 @@ int longUsage (std::string &outs)
int handleInfo (std::string &outs) int handleInfo (std::string &outs)
{ {
int rc = 0; int rc = 0;
if (context.hooks.trigger ("pre-info-command"))
{
// Get all the tasks. // Get all the tasks.
std::vector <Task> tasks; std::vector <Task> tasks;
context.tdb.lock (context.config.getBoolean ("locking")); context.tdb.lock (context.config.getBoolean ("locking"));
@@ -525,6 +528,9 @@ int handleInfo (std::string &outs)
} }
outs = out.str (); outs = out.str ();
context.hooks.trigger ("post-info-command");
}
return rc; return rc;
} }