]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-3497 --resolve
authorAnthony Minessale <anthm@freeswitch.org>
Wed, 10 Aug 2011 12:55:17 +0000 (07:55 -0500)
committerAnthony Minessale <anthm@freeswitch.org>
Wed, 10 Aug 2011 12:55:17 +0000 (07:55 -0500)
src/switch_event.c

index 629e67e9c3da1cea81695e90127105fa9a206da1..b469b9f7b7c9c123f99976675a6230ba29d68e27 100644 (file)
@@ -45,7 +45,7 @@ struct switch_event_node {
        /*! the event id enumeration to bind to */
        switch_event_types_t event_id;
        /*! 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 */
        switch_event_callback_t callback;
        /*! 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) {
                match++;
 
-               if (!node->subclass) {
+               if (!node->subclass_name) {
                        return match;
                }
        }
 
        if (match || event->event_id == node->event_id) {
 
-               if (event->subclass_name && node->subclass) {
-                       if (!strncasecmp(node->subclass->name, "file:", 5)) {
+               if (event->subclass_name && node->subclass_name) {
+                       if (!strncasecmp(node->subclass_name, "file:", 5)) {
                                char *file_header;
                                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;
                                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) {
-                               match = strstr(event->subclass_name, node->subclass->name) ? 1 : 0;
+                       } else if (event->subclass_name && node->subclass_name) {
+                               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;
                } else {
                        match = 0;
@@ -1732,7 +1732,9 @@ SWITCH_DECLARE(switch_status_t) switch_event_bind_removable(const char *id, swit
                /* <LOCKED> ----------------------------------------------- */
                event_node->id = DUP(id);
                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->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));
+                               FREE(n->subclass_name);
                                FREE(n->id);
                                FREE(n);
                                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;
                        }
                        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);
                        *node = NULL;