]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/include/openils/oils_utils.h
LP1831390: Fixing implementation of registerOnTouch
[Evergreen.git] / Open-ILS / include / openils / oils_utils.h
1 #include "opensrf/osrf_json.h"
2 #include "opensrf/log.h"
3
4 #ifndef OILS_UTILS_H
5 #define OILS_UTILS_H
6
7 // XXX replacing this with liboils_idl implementation
8 // #include "openils/fieldmapper_lookup.h"
9
10 #include "openils/idl_fieldmapper.h"
11
12 #include "oils_event.h"
13 #include "oils_constants.h"
14 #include "opensrf/osrf_app_session.h"
15 #include "opensrf/osrf_settings.h"
16 #include "opensrf/osrf_application.h"
17
18 #ifdef __cplusplus
19 extern "C" {
20 #endif
21
22 /**
23   Loads the IDL. Returns NULL on failure
24   or a pointer to the IDL data structure on success.
25   @param idl_filename If not provided, we'll fetch the 
26   filename from the settings server
27  */
28 osrfHash* oilsInitIDL( const char* idl_filename );
29
30 const char* oilsFMGetStringConst( const jsonObject* object, const char* field );
31
32 char* oilsFMGetString( const jsonObject* object, const char* field );
33
34 const jsonObject* oilsFMGetObject( const jsonObject* object, const char* field );
35
36 /**
37   Sets the given field in the given object to the given string
38   @param object The object to update
39   @param field The field to change
40   @param string The new data
41   @return 0 if the field was updated successfully, -1 on error
42   */
43 int oilsFMSetString( jsonObject* object, const char* field, const char* string );
44
45 /**
46  * Returns the data stored in the id field of the object if it exists
47  * returns -1 if the id field or the id value is not found
48  */
49 long oilsFMGetObjectId( const jsonObject* obj );
50
51
52 /**
53  * Checks if the user has each permission at the given org unit
54  * Passing in a -1 for the orgid means to use the top level org unit
55  * The first permission that fails causes the corresponding permission
56  * failure event to be returned
57  * returns NULL if all permissions succeed
58  */
59 oilsEvent* oilsUtilsCheckPerms( int userid, int orgid, char* permissions[], int size );
60
61
62 /**
63  * Performs a single request and returns the resulting data
64  * Caller is responsible for freeing the returned response object
65  */
66 jsonObject* oilsUtilsQuickReq( const char* service, const char* method,
67                 const jsonObject* params );
68
69 jsonObject* oilsUtilsQuickReqCtx( osrfMethodContext* ctx, const char* service,
70                 const char* method, const jsonObject* params );
71
72 jsonObject* oilsUtilsStorageReq( const char* method, const jsonObject* params );
73 jsonObject* oilsUtilsStorageReqCtx( osrfMethodContext* ctx, const char* method, const jsonObject* params );
74
75 jsonObject* oilsUtilsCStoreReq( const char* method, const jsonObject* params );
76 jsonObject* oilsUtilsCStoreReqCtx( osrfMethodContext* ctx, const char* method, const jsonObject* params );
77
78 /**
79  * Searches the storage server for a user with the given username 
80  * Caller is responsible for freeing the returned object
81  */
82 jsonObject* oilsUtilsFetchUserByUsername( osrfMethodContext* ctx, const char* name );
83
84
85 /**
86  * Returns the setting value
87  * Caller must free the returned string
88  */
89 char* oilsUtilsFetchOrgSetting( int orgid, const char* setting );
90
91
92 /**
93  * Logs into the auth server with the given username and password
94  * @return The authtoken string which must be de-allocated by the caller
95  */
96 char* oilsUtilsLogin( const char* uname, const char* passwd, const char* type, int orgId );
97
98
99 /**
100  * Fetches the requested workstation object by id
101  */
102 jsonObject* oilsUtilsFetchWorkstation( long id );
103
104 jsonObject* oilsUtilsFetchUserByBarcode(osrfMethodContext* ctx, const char* barcode);
105
106 jsonObject* oilsUtilsFetchWorkstationByName( const char* name );
107
108
109 int oilsUtilsIsDBTrue( const char* val );
110
111 long oilsUtilsIntervalToSeconds( const char* interval );
112
113 /**
114  * Creates actor.usr_activity entries
115  * @return The number of rows created.  0 or 1.
116  */
117 int oilsUtilsTrackUserActivity( osrfMethodContext* ctx, long usr, const char* ewho, const char* ewhat, const char* ehow );
118
119 /**
120  * Returns the ID of the root org unit (parent_ou = NULL)
121  */
122 int oilsUtilsGetRootOrgId();
123
124 #ifdef __cplusplus
125 }
126 #endif
127
128 #endif