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