2 * Copyright (c) 2007, Anthony Minessale II
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
12 * * Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
16 * * Neither the name of the original author; nor the names of any contributors
17 * may be used to endorse or promote products derived from this software
18 * without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
25 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
26 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
27 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
28 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
29 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
30 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
31 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
41 #endif /* defined(__cplusplus) */
51 ESL_EVENT_CHANNEL_CREATE,
52 ESL_EVENT_CHANNEL_DESTROY,
53 ESL_EVENT_CHANNEL_STATE,
54 ESL_EVENT_CHANNEL_ANSWER,
55 ESL_EVENT_CHANNEL_HANGUP,
56 ESL_EVENT_CHANNEL_EXECUTE,
57 ESL_EVENT_CHANNEL_EXECUTE_COMPLETE,
58 ESL_EVENT_CHANNEL_BRIDGE,
59 ESL_EVENT_CHANNEL_UNBRIDGE,
60 ESL_EVENT_CHANNEL_PROGRESS,
61 ESL_EVENT_CHANNEL_PROGRESS_MEDIA,
62 ESL_EVENT_CHANNEL_OUTGOING,
63 ESL_EVENT_CHANNEL_PARK,
64 ESL_EVENT_CHANNEL_UNPARK,
65 ESL_EVENT_CHANNEL_APPLICATION,
66 ESL_EVENT_CHANNEL_ORIGINATE,
67 ESL_EVENT_CHANNEL_UUID,
70 ESL_EVENT_INBOUND_CHAN,
71 ESL_EVENT_OUTBOUND_CHAN,
78 ESL_EVENT_SESSION_CRASH,
79 ESL_EVENT_MODULE_LOAD,
80 ESL_EVENT_MODULE_UNLOAD,
83 ESL_EVENT_PRESENCE_IN,
85 ESL_EVENT_PRESENCE_OUT,
86 ESL_EVENT_PRESENCE_PROBE,
87 ESL_EVENT_MESSAGE_WAITING,
88 ESL_EVENT_MESSAGE_QUERY,
91 ESL_EVENT_BACKGROUND_JOB,
92 ESL_EVENT_DETECTED_SPEECH,
93 ESL_EVENT_DETECTED_TONE,
94 ESL_EVENT_PRIVATE_COMMAND,
97 ESL_EVENT_ADD_SCHEDULE,
98 ESL_EVENT_DEL_SCHEDULE,
99 ESL_EVENT_EXE_SCHEDULE,
100 ESL_EVENT_RE_SCHEDULE,
103 ESL_EVENT_SEND_MESSAGE,
104 ESL_EVENT_RECV_MESSAGE,
105 ESL_EVENT_REQUEST_PARAMS,
106 ESL_EVENT_CHANNEL_DATA,
109 ESL_EVENT_SESSION_HEARTBEAT,
110 ESL_EVENT_CLIENT_DISCONNECTED,
111 ESL_EVENT_SERVER_DISCONNECTED,
121 /*! \brief An event Header */
122 struct esl_event_header {
123 /*! the header name */
125 /*! the header value */
127 /*! hash of the header name */
129 struct esl_event_header *next;
133 /*! \brief Representation of an event */
135 /*! the event id (descriptor) */
136 esl_event_types_t event_id;
137 /*! the priority of the event */
138 esl_priority_t priority;
139 /*! the owner of the event */
141 /*! the subclass of the event */
143 /*! the event headers */
144 esl_event_header_t *headers;
145 /*! the event headers tail pointer */
146 esl_event_header_t *last_header;
147 /*! the body of the event */
149 /*! user data from the subclass provider */
150 void *bind_user_data;
151 /*! user data from the event sender */
152 void *event_user_data;
155 struct esl_event *next;
160 #define ESL_EVENT_SUBCLASS_ANY NULL
163 \brief Create an event
164 \param event a NULL pointer on which to create the event
165 \param event_id the event id enumeration of the desired event
166 \param subclass_name the subclass name for custom event (only valid when event_id is ESL_EVENT_CUSTOM)
167 \return ESL_STATUS_SUCCESS on success
169 ESL_DECLARE(esl_status_t) esl_event_create_subclass(esl_event_t **event, esl_event_types_t event_id, const char *subclass_name);
172 \brief Set the priority of an event
173 \param event the event to set the priority on
174 \param priority the event priority
175 \return ESL_STATUS_SUCCESS
177 ESL_DECLARE(esl_status_t) esl_event_set_priority(esl_event_t *event, esl_priority_t priority);
180 \brief Retrieve a header value from an event
181 \param event the event to read the header from
182 \param header_name the name of the header to read
183 \return the value of the requested header
185 ESL_DECLARE(char *)esl_event_get_header(esl_event_t *event, const char *header_name);
188 \brief Retrieve the body value from an event
189 \param event the event to read the body from
190 \return the value of the body or NULL
192 ESL_DECLARE(char *)esl_event_get_body(esl_event_t *event);
195 \brief Add a header to an event
196 \param event the event to add the header to
197 \param stack the stack sense (stack it on the top or on the bottom)
198 \param header_name the name of the header to add
199 \param fmt the value of the header (varargs see standard sprintf family)
200 \return ESL_STATUS_SUCCESS if the header was added
202 ESL_DECLARE(esl_status_t) esl_event_add_header(esl_event_t *event, esl_stack_t stack,
203 const char *header_name, const char *fmt, ...); //PRINTF_FUNCTION(4, 5);
206 \brief Add a string header to an event
207 \param event the event to add the header to
208 \param stack the stack sense (stack it on the top or on the bottom)
209 \param header_name the name of the header to add
210 \param data the value of the header
211 \return ESL_STATUS_SUCCESS if the header was added
213 ESL_DECLARE(esl_status_t) esl_event_add_header_string(esl_event_t *event, esl_stack_t stack, const char *header_name, const char *data);
215 ESL_DECLARE(esl_status_t) esl_event_del_header(esl_event_t *event, const char *header_name);
218 \brief Destroy an event
219 \param event pointer to the pointer to event to destroy
221 ESL_DECLARE(void) esl_event_destroy(esl_event_t **event);
222 #define esl_event_safe_destroy(_event) if (_event) esl_event_destroy(_event)
225 \brief Duplicate an event
226 \param event a NULL pointer on which to duplicate the event
227 \param todup an event to duplicate
228 \return ESL_STATUS_SUCCESS if the event was duplicated
230 ESL_DECLARE(esl_status_t) esl_event_dup(esl_event_t **event, esl_event_t *todup);
233 \brief Render the name of an event id enumeration
234 \param event the event id to render the name of
235 \return the rendered name
237 ESL_DECLARE(const char *)esl_event_name(esl_event_types_t event);
240 \brief return the event id that matches a given event name
241 \param name the name of the event
242 \param type the event id to return
243 \return ESL_STATUS_SUCCESS if there was a match
245 ESL_DECLARE(esl_status_t) esl_name_event(const char *name, esl_event_types_t *type);
248 \brief Render a string representation of an event sutable for printing or network transport
249 \param event the event to render
250 \param str a string pointer to point at the allocated data
251 \param encode url encode the headers
252 \return ESL_STATUS_SUCCESS if the operation was successful
253 \note you must free the resulting string when you are finished with it
255 ESL_DECLARE(esl_status_t) esl_event_serialize(esl_event_t *event, char **str, esl_bool_t encode);
258 \brief Add a body to an event
259 \param event the event to add to body to
260 \param fmt optional body of the event (varargs see standard sprintf family)
261 \return ESL_STATUS_SUCCESS if the body was added to the event
262 \note the body parameter can be shadowed by the esl_event_reserve_subclass_detailed function
264 ESL_DECLARE(esl_status_t) esl_event_add_body(esl_event_t *event, const char *fmt, ...);
267 \brief Create a new event assuming it will not be custom event and therefore hiding the unused parameters
268 \param event a NULL pointer on which to create the event
269 \param id the event id enumeration of the desired event
270 \return ESL_STATUS_SUCCESS on success
272 #define esl_event_create(event, id) esl_event_create_subclass(event, id, ESL_EVENT_SUBCLASS_ANY)
274 ESL_DECLARE(const char *)esl_priority_name(esl_priority_t priority);
280 #endif /* defined(__cplusplus) */
282 #endif /* defined(ESL_EVENT_H) */
292 * vim:set softtabstop=4 shiftwidth=4 tabstop=4: