mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-27 10:07:19 +02:00
Enhancement - Hooks
- Implemented API::callTaskHook. - Implemented Hook object inside Hooks.cpp, not Hooks.h. - Implemented Hooks.setTaskId to provide context for task hooks. - Implemented pre-tag, post-tag, pre-detag, post-detag events. - Implemented pre-file-lock, post-file-lock, pre-file-unlock, post-file-unlock events.
This commit is contained in:
parent
21d5607af2
commit
03f7e0686f
6 changed files with 137 additions and 58 deletions
47
src/Hooks.h
47
src/Hooks.h
|
@ -32,42 +32,14 @@
|
|||
#include "API.h"
|
||||
#include "auto.h"
|
||||
|
||||
// Hook class representing a single hook.
|
||||
// Hook class representing a single hook, which is just a three-way map.
|
||||
class Hook
|
||||
{
|
||||
public:
|
||||
Hook ()
|
||||
: event ("")
|
||||
, file ("")
|
||||
, function ("")
|
||||
{
|
||||
}
|
||||
|
||||
Hook (const std::string& e, const std::string& f, const std::string& fn)
|
||||
: event (e)
|
||||
, file (f)
|
||||
, function (fn)
|
||||
{
|
||||
}
|
||||
|
||||
Hook (const Hook& other)
|
||||
{
|
||||
event = other.event;
|
||||
file = other.file;
|
||||
function = other.function;
|
||||
}
|
||||
|
||||
Hook& operator= (const Hook& other)
|
||||
{
|
||||
if (this != &other)
|
||||
{
|
||||
event = other.event;
|
||||
file = other.file;
|
||||
function = other.function;
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
Hook ();
|
||||
Hook (const std::string&, const std::string&, const std::string&);
|
||||
Hook (const Hook&);
|
||||
Hook& operator= (const Hook&);
|
||||
|
||||
public:
|
||||
std::string event;
|
||||
|
@ -85,7 +57,13 @@ public:
|
|||
Hooks& operator= (const Hooks&); // Deliberately unimplemented
|
||||
|
||||
void initialize ();
|
||||
|
||||
void setTaskId (int);
|
||||
// void setField (const std::string&, const std::string&);
|
||||
// void setTaskList (const std::vector <int>&);
|
||||
bool trigger (const std::string&);
|
||||
|
||||
private:
|
||||
bool eventType (const std::string&, std::string&);
|
||||
|
||||
private:
|
||||
|
@ -93,6 +71,9 @@ private:
|
|||
API api;
|
||||
#endif
|
||||
std::vector <Hook> all; // All current hooks.
|
||||
#ifdef HAVE_LIBLUA
|
||||
int task_id;
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue