FS-3497 --resolve

This commit is contained in:
Anthony Minessale 2011-08-10 07:55:17 -05:00
parent 895b505fd6
commit 3696ced792

View File

@ -45,7 +45,7 @@ struct switch_event_node {
/*! the event id enumeration to bind to */ /*! the event id enumeration to bind to */
switch_event_types_t event_id; switch_event_types_t event_id;
/*! the event subclass to bind to for custom events */ /*! the event subclass to bind to for custom events */
switch_event_subclass_t *subclass; char *subclass_name;
/*! a callback function to execute when the event is triggered */ /*! a callback function to execute when the event is triggered */
switch_event_callback_t callback; switch_event_callback_t callback;
/*! private data */ /*! private data */
@ -205,28 +205,28 @@ static int switch_events_match(switch_event_t *event, switch_event_node_t *node)
if (node->event_id == SWITCH_EVENT_ALL) { if (node->event_id == SWITCH_EVENT_ALL) {
match++; match++;
if (!node->subclass) { if (!node->subclass_name) {
return match; return match;
} }
} }
if (match || event->event_id == node->event_id) { if (match || event->event_id == node->event_id) {
if (event->subclass_name && node->subclass) { if (event->subclass_name && node->subclass_name) {
if (!strncasecmp(node->subclass->name, "file:", 5)) { if (!strncasecmp(node->subclass_name, "file:", 5)) {
char *file_header; char *file_header;
if ((file_header = switch_event_get_header(event, "file")) != 0) { if ((file_header = switch_event_get_header(event, "file")) != 0) {
match = strstr(node->subclass->name + 5, file_header) ? 1 : 0; match = strstr(node->subclass_name + 5, file_header) ? 1 : 0;
} }
} else if (!strncasecmp(node->subclass->name, "func:", 5)) { } else if (!strncasecmp(node->subclass_name, "func:", 5)) {
char *func_header; char *func_header;
if ((func_header = switch_event_get_header(event, "function")) != 0) { if ((func_header = switch_event_get_header(event, "function")) != 0) {
match = strstr(node->subclass->name + 5, func_header) ? 1 : 0; match = strstr(node->subclass_name + 5, func_header) ? 1 : 0;
} }
} else if (event->subclass_name && node->subclass->name) { } else if (event->subclass_name && node->subclass_name) {
match = strstr(event->subclass_name, node->subclass->name) ? 1 : 0; match = strstr(event->subclass_name, node->subclass_name) ? 1 : 0;
} }
} else if ((event->subclass_name && !node->subclass) || (!event->subclass_name && !node->subclass)) { } else if ((event->subclass_name && !node->subclass_name) || (!event->subclass_name && !node->subclass_name)) {
match = 1; match = 1;
} else { } else {
match = 0; match = 0;
@ -1732,7 +1732,9 @@ SWITCH_DECLARE(switch_status_t) switch_event_bind_removable(const char *id, swit
/* <LOCKED> ----------------------------------------------- */ /* <LOCKED> ----------------------------------------------- */
event_node->id = DUP(id); event_node->id = DUP(id);
event_node->event_id = event; event_node->event_id = event;
event_node->subclass = subclass; if (subclass_name) {
event_node->subclass_name = DUP(subclass_name);
}
event_node->callback = callback; event_node->callback = callback;
event_node->user_data = user_data; event_node->user_data = user_data;
@ -1786,6 +1788,7 @@ SWITCH_DECLARE(switch_status_t) switch_event_unbind_callback(switch_event_callba
} }
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Event Binding deleted for %s:%s\n", n->id, switch_event_name(n->event_id)); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Event Binding deleted for %s:%s\n", n->id, switch_event_name(n->event_id));
FREE(n->subclass_name);
FREE(n->id); FREE(n->id);
FREE(n); FREE(n);
status = SWITCH_STATUS_SUCCESS; status = SWITCH_STATUS_SUCCESS;
@ -1825,7 +1828,7 @@ SWITCH_DECLARE(switch_status_t) switch_event_unbind(switch_event_node_t **node)
EVENT_NODES[n->event_id] = n->next; EVENT_NODES[n->event_id] = n->next;
} }
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Event Binding deleted for %s:%s\n", n->id, switch_event_name(n->event_id)); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Event Binding deleted for %s:%s\n", n->id, switch_event_name(n->event_id));
n->subclass = NULL; FREE(n->subclass_name);
FREE(n->id); FREE(n->id);
FREE(n); FREE(n);
*node = NULL; *node = NULL;