Hooks
- Stubbed new ::onAdd and ::onModify interfaces.
This commit is contained in:
@@ -197,8 +197,9 @@ void Hooks::onExit ()
|
||||
// - all emitted non-JSON lines are considered feedback messages if the exit
|
||||
// code is zero, otherwise they are considered errors.
|
||||
//
|
||||
void Hooks::onAdd (Task& after)
|
||||
void Hooks::onAdd (std::vector <Task>& changes)
|
||||
{
|
||||
/*
|
||||
context.timer_hooks.start ();
|
||||
if (! _enabled)
|
||||
return;
|
||||
@@ -249,6 +250,7 @@ void Hooks::onAdd (Task& after)
|
||||
}
|
||||
|
||||
context.timer_hooks.stop ();
|
||||
*/
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -266,8 +268,9 @@ void Hooks::onAdd (Task& after)
|
||||
// - all emitted non-JSON lines are considered feedback messages if the exit
|
||||
// code is zero, otherwise they are considered errors.
|
||||
//
|
||||
void Hooks::onModify (const Task& before, Task& after)
|
||||
void Hooks::onModify (const Task& before, std::vector <Task>& changes)
|
||||
{
|
||||
/*
|
||||
context.timer_hooks.start ();
|
||||
if (! _enabled)
|
||||
return;
|
||||
@@ -322,6 +325,7 @@ void Hooks::onModify (const Task& before, Task& after)
|
||||
}
|
||||
|
||||
context.timer_hooks.stop ();
|
||||
*/
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <Task.h>
|
||||
|
||||
class Hooks
|
||||
{
|
||||
@@ -43,8 +44,8 @@ public:
|
||||
|
||||
void onLaunch ();
|
||||
void onExit ();
|
||||
void onAdd (Task&);
|
||||
void onModify (const Task&, Task&);
|
||||
void onAdd (std::vector <Task>&);
|
||||
void onModify (const Task&, std::vector <Task>&);
|
||||
|
||||
std::vector <std::string> list ();
|
||||
|
||||
|
||||
12
src/TDB2.cpp
12
src/TDB2.cpp
@@ -570,9 +570,7 @@ void TDB2::add (Task& task, bool add_to_backlog /* = true */)
|
||||
// Create a vector tasks, as hooks can cause them to multiply.
|
||||
std::vector <Task> changes;
|
||||
changes.push_back (task);
|
||||
|
||||
// TODO call hooks.
|
||||
// context.hooks.onAdd (changes);
|
||||
context.hooks.onAdd (changes);
|
||||
|
||||
update (uuid, task, add_to_backlog, changes);
|
||||
}
|
||||
@@ -584,12 +582,14 @@ void TDB2::modify (Task& task, bool add_to_backlog /* = true */)
|
||||
task.validate (false);
|
||||
std::string uuid = task.get ("uuid");
|
||||
|
||||
// Get the unmodified task as reference, so the hook can compare.
|
||||
Task original;
|
||||
get (uuid, original);
|
||||
|
||||
// Create a vector tasks, as hooks can cause them to multiply.
|
||||
std::vector <Task> changes;
|
||||
changes.push_back (task);
|
||||
|
||||
// TODO call hooks.
|
||||
// context.hooks.onModify (changes);
|
||||
context.hooks.onModify (original, changes);
|
||||
|
||||
update (uuid, task, add_to_backlog, changes);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user