diff --git a/src/Hooks.cpp b/src/Hooks.cpp index 0d3d0acbc..2a835c2b8 100644 --- a/src/Hooks.cpp +++ b/src/Hooks.cpp @@ -157,11 +157,18 @@ void Hooks::onExit () context.timer_hooks.start (); + std::vector changes; + context.tdb2.get_changes (changes); + + std::string input; + std::vector ::const_iterator t; + for (t = changes.begin (); t != changes.end (); ++t) + input += t->composeJSON () + "\n"; + std::vector matchingScripts = scripts ("on-exit"); std::vector ::iterator i; for (i = matchingScripts.begin (); i != matchingScripts.end (); ++i) { - std::string input; std::string output; std::vector args; int status = execute (*i, args, input, output); diff --git a/src/TDB2.cpp b/src/TDB2.cpp index 4340b35f4..64b9621ff 100644 --- a/src/TDB2.cpp +++ b/src/TDB2.cpp @@ -671,6 +671,8 @@ void TDB2::commit () dump (); context.timer_commit.start (); + gather_changes (); + pending.commit (); completed.commit (); undo.commit (); @@ -688,6 +690,30 @@ void TDB2::commit () context.timer_commit.stop (); } +//////////////////////////////////////////////////////////////////////////////// +void TDB2::gather_changes () +{ + _changes.clear (); + std::vector ::iterator i; + for (i = pending._added_tasks.begin (); i != pending._added_tasks.end (); ++i) + _changes.push_back (*i); + + for (i = pending._modified_tasks.begin (); i != pending._modified_tasks.end (); ++i) + _changes.push_back (*i); + + for (i = completed._added_tasks.begin (); i != completed._added_tasks.end (); ++i) + _changes.push_back (*i); + + for (i = completed._modified_tasks.begin (); i != completed._modified_tasks.end (); ++i) + _changes.push_back (*i); +} + +//////////////////////////////////////////////////////////////////////////////// +void TDB2::get_changes (std::vector & changes) +{ + changes = _changes; +} + //////////////////////////////////////////////////////////////////////////////// void TDB2::revert () { diff --git a/src/TDB2.h b/src/TDB2.h index 1170cf81a..172081079 100644 --- a/src/TDB2.h +++ b/src/TDB2.h @@ -103,6 +103,7 @@ public: void add (Task&, bool add_to_backlog = true); void modify (Task&, bool add_to_backlog = true); void commit (); + void get_changes (std::vector &); void revert (); int gc (); int next_id (); @@ -126,6 +127,7 @@ public: void dump (); private: + void gather_changes (); void update (const std::string&, Task&, const bool, std::vector &); bool verifyUniqueUUID (const std::string&); void show_diff (const std::string&, const std::string&, const std::string&); @@ -141,8 +143,9 @@ public: TF2 backlog; private: - std::string _location; - int _id; + std::string _location; + int _id; + std::vector _changes; }; #endif