]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/include/openils/oils_event.h
Patch from Scott McKellar:
[Evergreen.git] / Open-ILS / include / openils / oils_event.h
1 #ifndef OILS_EVENT_HEADER
2 #define OILS_EVENT_HEADER
3 #include "objson/object.h"
4 #include "opensrf/utils.h"
5 #include "opensrf/log.h"
6 #include "opensrf/osrf_hash.h"
7
8
9 /* OILS Event structure */
10 struct _oilsEventStruct {
11         char* event;                    /* the event name */
12         char* perm;                             /* the permission error name */
13         int permloc;                    /* the permission location id */
14         jsonObject* payload;    /* the payload */
15         jsonObject* json;               /* the event as a jsonObject */
16         char* file;
17         int line;
18 };
19 typedef struct _oilsEventStruct oilsEvent;
20
21
22 /** Creates a new event.  User is responsible for freeing event with oilsEventFree */
23 oilsEvent* oilsNewEvent( const char* file, int line, const char* event );
24
25 /** Creates a new event with payload.  
26  * User is responsible for freeing event with oilsEventFree */
27 oilsEvent* oilsNewEvent2( const char* file, int line, const char* event,
28                 const jsonObject* payload );
29
30 /** Creates a new event with permission and permission location.  
31  * User is responsible for freeing event with oilsEventFree */
32 oilsEvent* oilsNewEvent3( const char* file, int line, const char* event,
33                 const char* perm, int permloc );
34
35 /** Creates a new event with permission, permission location, and payload.  
36  * User is responsible for freeing event with oilsEventFree */
37 oilsEvent* oilsNewEvent4( const char* file, int line, const char* event,
38                 const char* perm, int permloc, const jsonObject* payload );
39
40 /** Sets the permission info for the event */
41 void oilsEventSetPermission( oilsEvent* event, const char* perm, int permloc );
42
43 /* Sets the payload for the event 
44  * This clones the payload, so the user is responsible
45  * for handling the payload object's memory
46  * */
47 void oilsEventSetPayload( oilsEvent* event, const jsonObject* payload );
48
49 /** Creates the JSON associated with an event.  The JSON should NOT be
50  * freed by the user.  It will be freed by oilsEventFree */
51 jsonObject* oilsEventToJSON( oilsEvent* event );
52
53 /* Frees an event object */
54 void oilsEventFree( oilsEvent* event );
55
56
57
58 #endif