From f8b19b7485023ba94755bd606a384c80e80cc54b Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Mon, 21 Sep 2015 18:00:14 -0500 Subject: [PATCH] FS-8190 #resolve [When using nixevent, freeswitch stops sending us certain custom event that were NOT part of the nixevent command] --- src/include/switch_event.h | 2 + src/mod/applications/mod_avmd/mod_avmd.c | 9 ++ src/mod/applications/mod_bert/mod_bert.c | 22 ++++ .../mod_callcenter/mod_callcenter.c | 9 ++ src/mod/applications/mod_curl/mod_curl.c | 9 ++ src/mod/applications/mod_cv/mod_cv.cpp | 10 +- .../applications/mod_dptools/mod_dptools.c | 20 +++ src/mod/applications/mod_sms/mod_sms.c | 6 + src/mod/applications/mod_sonar/mod_sonar.c | 8 ++ .../applications/mod_spandsp/mod_spandsp.c | 45 ++++++- .../applications/mod_spandsp/mod_spandsp.h | 11 ++ .../mod_spandsp/mod_spandsp_fax.c | 10 -- src/mod/applications/mod_vmd/mod_vmd.c | 8 ++ src/mod/asr_tts/mod_unimrcp/mod_unimrcp.c | 20 +++ src/mod/endpoints/mod_loopback/mod_loopback.c | 9 ++ src/mod/endpoints/mod_rtmp/mod_rtmp.c | 49 ++++++++ src/mod/endpoints/mod_sofia/mod_sofia.c | 116 ++++++++++++++++++ src/mod/endpoints/mod_verto/mod_verto.c | 21 ++++ .../mod_event_socket/mod_event_socket.c | 38 +++++- src/mod/event_handlers/mod_rayo/mod_rayo.c | 9 ++ src/mod/xml_int/mod_xml_rpc/mod_xml_rpc.c | 8 ++ src/switch_event.c | 16 +++ 22 files changed, 442 insertions(+), 13 deletions(-) diff --git a/src/include/switch_event.h b/src/include/switch_event.h index 12f18a9b94..d13af7d471 100644 --- a/src/include/switch_event.h +++ b/src/include/switch_event.h @@ -254,6 +254,8 @@ SWITCH_DECLARE(void) switch_event_prep_for_delivery_detailed(const char *file, c SWITCH_DECLARE(switch_status_t) switch_event_bind(const char *id, switch_event_types_t event, const char *subclass_name, switch_event_callback_t callback, void *user_data); +SWITCH_DECLARE(switch_status_t) switch_event_get_custom_events(switch_console_callback_match_t **matches); + /*! \brief Bind an event callback to a specific event \param id an identifier token of the binder diff --git a/src/mod/applications/mod_avmd/mod_avmd.c b/src/mod/applications/mod_avmd/mod_avmd.c index 3722365397..a4a1c07815 100644 --- a/src/mod/applications/mod_avmd/mod_avmd.c +++ b/src/mod/applications/mod_avmd/mod_avmd.c @@ -216,6 +216,13 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_avmd_load) /* connect my internal structure to the blank pointer passed to me */ *module_interface = switch_loadable_module_create_module_interface(pool, modname); + + if (switch_event_reserve_subclass(AVMD_EVENT_BEEP) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't register subclass %s!\n", AVMD_EVENT_BEEP); + return SWITCH_STATUS_TERM; + } + + switch_log_printf( SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, @@ -322,6 +329,8 @@ SWITCH_STANDARD_APP(avmd_start_function) SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_avmd_shutdown) { + switch_event_free_subclass(AVMD_EVENT_BEEP); + #ifdef FASTMATH destroy_fast_acosf(); #endif diff --git a/src/mod/applications/mod_bert/mod_bert.c b/src/mod/applications/mod_bert/mod_bert.c index 35f7b87ab8..70badc1354 100644 --- a/src/mod/applications/mod_bert/mod_bert.c +++ b/src/mod/applications/mod_bert/mod_bert.c @@ -377,6 +377,24 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_bert_load) { switch_application_interface_t *app_interface = NULL; + if (switch_event_reserve_subclass(BERT_EVENT_TIMEOUT) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't register subclass %s!\n", BERT_EVENT_TIMEOUT); + return SWITCH_STATUS_TERM; + } + + + if (switch_event_reserve_subclass(BERT_EVENT_LOST_SYNC) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't register subclass %s!\n", BERT_EVENT_LOST_SYNC); + return SWITCH_STATUS_TERM; + } + + + if (switch_event_reserve_subclass(BERT_EVENT_IN_SYNC) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't register subclass %s!\n", BERT_EVENT_IN_SYNC); + return SWITCH_STATUS_TERM; + } + + *module_interface = switch_loadable_module_create_module_interface(pool, modname); SWITCH_ADD_APP(app_interface, "bert_test", "Start BERT Test", "Start BERT Test", bert_test_function, "", SAF_NONE); @@ -385,6 +403,10 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_bert_load) SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_bert_shutdown) { + switch_event_free_subclass(BERT_EVENT_TIMEOUT); + switch_event_free_subclass(BERT_EVENT_LOST_SYNC); + switch_event_free_subclass(BERT_EVENT_IN_SYNC); + return SWITCH_STATUS_UNLOAD; } diff --git a/src/mod/applications/mod_callcenter/mod_callcenter.c b/src/mod/applications/mod_callcenter/mod_callcenter.c index 594908dd4d..2b0e28a5e7 100644 --- a/src/mod/applications/mod_callcenter/mod_callcenter.c +++ b/src/mod/applications/mod_callcenter/mod_callcenter.c @@ -3421,6 +3421,12 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_callcenter_load) switch_api_interface_t *api_interface; switch_status_t status; + + if (switch_event_reserve_subclass(CALLCENTER_EVENT) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't register subclass %s!\n", CALLCENTER_EVENT); + return SWITCH_STATUS_TERM; + } + memset(&globals, 0, sizeof(globals)); globals.pool = pool; @@ -3495,6 +3501,9 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_callcenter_shutdown) switch_ssize_t keylen; int sanity = 0; + + switch_event_free_subclass(CALLCENTER_EVENT); + switch_mutex_lock(globals.mutex); if (globals.running == 1) { globals.running = 0; diff --git a/src/mod/applications/mod_curl/mod_curl.c b/src/mod/applications/mod_curl/mod_curl.c index 9b9c7cc12b..4499fe4cea 100644 --- a/src/mod/applications/mod_curl/mod_curl.c +++ b/src/mod/applications/mod_curl/mod_curl.c @@ -1014,6 +1014,12 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_curl_load) { switch_api_interface_t *api_interface; switch_application_interface_t *app_interface; + + if (switch_event_reserve_subclass(HTTP_SENDFILE_ACK_EVENT) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't register subclass %s!\n", HTTP_SENDFILE_ACK_EVENT); + return SWITCH_STATUS_TERM; + } + /* connect my internal structure to the blank pointer passed to me */ *module_interface = switch_loadable_module_create_module_interface(pool, modname); @@ -1037,6 +1043,9 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_curl_load) Macro expands to: switch_status_t mod_cidlookup_shutdown() */ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_curl_shutdown) { + + switch_event_free_subclass(HTTP_SENDFILE_ACK_EVENT); + /* Cleanup dynamically allocated config settings */ return SWITCH_STATUS_SUCCESS; } diff --git a/src/mod/applications/mod_cv/mod_cv.cpp b/src/mod/applications/mod_cv/mod_cv.cpp index 50dd5862b4..9f5d95dac0 100644 --- a/src/mod/applications/mod_cv/mod_cv.cpp +++ b/src/mod/applications/mod_cv/mod_cv.cpp @@ -1334,6 +1334,11 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_cv_load) switch_application_interface_t *app_interface; switch_api_interface_t *api_interface; + if (switch_event_reserve_subclass(MY_EVENT_VIDEO_DETECT) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't register subclass %s!\n", MY_EVENT_VIDEO_DETECT); + return SWITCH_STATUS_TERM; + } + *module_interface = switch_loadable_module_create_module_interface(pool, modname); MODULE_INTERFACE = *module_interface; @@ -1354,7 +1359,10 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_cv_load) SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_cv_shutdown) { - return SWITCH_STATUS_UNLOAD; + + switch_event_free_subclass(MY_EVENT_VIDEO_DETECT); + + return SWITCH_STATUS_UNLOAD; } diff --git a/src/mod/applications/mod_dptools/mod_dptools.c b/src/mod/applications/mod_dptools/mod_dptools.c index 8cc2947343..310aa302e4 100644 --- a/src/mod/applications/mod_dptools/mod_dptools.c +++ b/src/mod/applications/mod_dptools/mod_dptools.c @@ -5909,6 +5909,11 @@ SWITCH_STANDARD_APP(deduplicate_dtmf_app_function) SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_dptools_shutdown) { + + switch_event_free_subclass(FILE_STRING_CLOSE); + switch_event_free_subclass(FILE_STRING_FAIL); + switch_event_free_subclass(FILE_STRING_OPEN); + switch_event_unbind_callback(pickup_pres_event_handler); switch_mutex_destroy(globals.pickup_mutex); switch_core_hash_destroy(&globals.pickup_hash); @@ -5926,6 +5931,21 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_dptools_load) switch_chat_interface_t *chat_interface; switch_file_interface_t *file_interface; + if (switch_event_reserve_subclass(FILE_STRING_CLOSE) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't register subclass %s!\n", FILE_STRING_CLOSE); + return SWITCH_STATUS_TERM; + } + + if (switch_event_reserve_subclass(FILE_STRING_FAIL) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't register subclass %s!\n", FILE_STRING_FAIL); + return SWITCH_STATUS_TERM; + } + + if (switch_event_reserve_subclass(FILE_STRING_OPEN) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't register subclass %s!\n", FILE_STRING_OPEN); + return SWITCH_STATUS_TERM; + } + globals.pool = pool; switch_core_hash_init(&globals.pickup_hash); switch_mutex_init(&globals.pickup_mutex, SWITCH_MUTEX_NESTED, globals.pool); diff --git a/src/mod/applications/mod_sms/mod_sms.c b/src/mod/applications/mod_sms/mod_sms.c index 4529244b0d..9f10ef98a5 100644 --- a/src/mod/applications/mod_sms/mod_sms.c +++ b/src/mod/applications/mod_sms/mod_sms.c @@ -609,6 +609,10 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_sms_load) switch_chat_interface_t *chat_interface; switch_chat_application_interface_t *chat_app_interface; + if (switch_event_reserve_subclass(MY_EVENT_DELIVERY_REPORT) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't register subclass %s!\n", MY_EVENT_DELIVERY_REPORT); + return SWITCH_STATUS_TERM; + } if (switch_event_bind(modname, SWITCH_EVENT_CUSTOM, MY_EVENT_SEND_MESSAGE, event_handler, NULL) != SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't bind!\n"); @@ -640,6 +644,8 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_sms_shutdown) { switch_event_unbind_callback(event_handler); + switch_event_free_subclass(MY_EVENT_DELIVERY_REPORT); + return SWITCH_STATUS_SUCCESS; } diff --git a/src/mod/applications/mod_sonar/mod_sonar.c b/src/mod/applications/mod_sonar/mod_sonar.c index 2457703b55..ebf641a351 100644 --- a/src/mod/applications/mod_sonar/mod_sonar.c +++ b/src/mod/applications/mod_sonar/mod_sonar.c @@ -218,6 +218,12 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_sonar_load) { switch_application_interface_t *app_interface; + if (switch_event_reserve_subclass("sonar::ping") != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't register subclass %s!\n", "sonar::ping"); + return SWITCH_STATUS_TERM; + } + + /* connect my internal structure to the blank pointer passed to me */ *module_interface = switch_loadable_module_create_module_interface(pool, modname); @@ -233,6 +239,8 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_sonar_load) SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_sonar_shutdown) { + switch_event_free_subclass("sonar::ping"); + return SWITCH_STATUS_SUCCESS; } diff --git a/src/mod/applications/mod_spandsp/mod_spandsp.c b/src/mod/applications/mod_spandsp/mod_spandsp.c index 6f15ed79a3..fdbb44c5a6 100644 --- a/src/mod/applications/mod_spandsp/mod_spandsp.c +++ b/src/mod/applications/mod_spandsp/mod_spandsp.c @@ -772,6 +772,42 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_spandsp_init) switch_application_interface_t *app_interface; switch_api_interface_t *api_interface; + + if (switch_event_reserve_subclass(MY_EVENT_TDD_RECV_MESSAGE) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't register subclass %s!\n", MY_EVENT_TDD_RECV_MESSAGE); + return SWITCH_STATUS_TERM; + } + + if (switch_event_reserve_subclass(SPANDSP_EVENT_TXFAXNEGOCIATERESULT) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't register subclass %s!\n", SPANDSP_EVENT_TXFAXNEGOCIATERESULT); + return SWITCH_STATUS_TERM; + } + + if (switch_event_reserve_subclass(SPANDSP_EVENT_RXFAXNEGOCIATERESULT) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't register subclass %s!\n", SPANDSP_EVENT_RXFAXNEGOCIATERESULT); + return SWITCH_STATUS_TERM; + } + + if (switch_event_reserve_subclass(SPANDSP_EVENT_TXFAXPAGERESULT) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't register subclass %s!\n", SPANDSP_EVENT_TXFAXPAGERESULT); + return SWITCH_STATUS_TERM; + } + + if (switch_event_reserve_subclass(SPANDSP_EVENT_RXFAXPAGERESULT) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't register subclass %s!\n", SPANDSP_EVENT_RXFAXPAGERESULT); + return SWITCH_STATUS_TERM; + } + + if (switch_event_reserve_subclass(SPANDSP_EVENT_TXFAXRESULT) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't register subclass %s!\n", SPANDSP_EVENT_TXFAXRESULT); + return SWITCH_STATUS_TERM; + } + + if (switch_event_reserve_subclass(SPANDSP_EVENT_RXFAXRESULT) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't register subclass %s!\n", SPANDSP_EVENT_RXFAXRESULT); + return SWITCH_STATUS_TERM; + } + memset(&spandsp_globals, 0, sizeof(spandsp_globals)); spandsp_globals.pool = pool; @@ -855,7 +891,14 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_spandsp_shutdown) switch_event_unbind_callback(event_handler); switch_event_unbind_callback(tdd_event_handler); - + switch_event_free_subclass(MY_EVENT_TDD_RECV_MESSAGE); + switch_event_free_subclass(SPANDSP_EVENT_TXFAXNEGOCIATERESULT); + switch_event_free_subclass(SPANDSP_EVENT_RXFAXNEGOCIATERESULT); + switch_event_free_subclass(SPANDSP_EVENT_TXFAXPAGERESULT); + switch_event_free_subclass(SPANDSP_EVENT_RXFAXPAGERESULT); + switch_event_free_subclass(SPANDSP_EVENT_TXFAXRESULT); + switch_event_free_subclass(SPANDSP_EVENT_RXFAXRESULT); + mod_spandsp_fax_shutdown(); mod_spandsp_dsp_shutdown(); #if defined(MODEM_SUPPORT) diff --git a/src/mod/applications/mod_spandsp/mod_spandsp.h b/src/mod/applications/mod_spandsp/mod_spandsp.h index 183426e7eb..4e8f1d2427 100644 --- a/src/mod/applications/mod_spandsp/mod_spandsp.h +++ b/src/mod/applications/mod_spandsp/mod_spandsp.h @@ -49,6 +49,17 @@ typedef int zap_socket_t; #define SPANDSP_EXPOSE_INTERNAL_STRUCTURES #include +#define SPANDSP_EVENT_TXFAXRESULT "spandsp::txfaxresult" +#define SPANDSP_EVENT_RXFAXRESULT "spandsp::rxfaxresult" + +#define SPANDSP_EVENT_TXFAXPAGERESULT "spandsp::txfaxpageresult" +#define SPANDSP_EVENT_RXFAXPAGERESULT "spandsp::rxfaxpageresult" + +#define SPANDSP_EVENT_TXFAXNEGOCIATERESULT "spandsp::txfaxnegociateresult" +#define SPANDSP_EVENT_RXFAXNEGOCIATERESULT "spandsp::rxfaxnegociateresult" + + + /* The global stuff */ struct spandsp_globals { switch_memory_pool_t *pool; diff --git a/src/mod/applications/mod_spandsp/mod_spandsp_fax.c b/src/mod/applications/mod_spandsp/mod_spandsp_fax.c index 31bb3a74d7..3d175a18e5 100644 --- a/src/mod/applications/mod_spandsp/mod_spandsp_fax.c +++ b/src/mod/applications/mod_spandsp/mod_spandsp_fax.c @@ -42,16 +42,6 @@ #define DEFAULT_FEC_ENTRIES 3 #define DEFAULT_FEC_SPAN 3 -#define SPANDSP_EVENT_TXFAXRESULT "spandsp::txfaxresult" -#define SPANDSP_EVENT_RXFAXRESULT "spandsp::rxfaxresult" - -#define SPANDSP_EVENT_TXFAXPAGERESULT "spandsp::txfaxpageresult" -#define SPANDSP_EVENT_RXFAXPAGERESULT "spandsp::rxfaxpageresult" - -#define SPANDSP_EVENT_TXFAXNEGOCIATERESULT "spandsp::txfaxnegociateresult" -#define SPANDSP_EVENT_RXFAXNEGOCIATERESULT "spandsp::rxfaxnegociateresult" - - /***************************************************************************** OUR DEFINES AND STRUCTS *****************************************************************************/ diff --git a/src/mod/applications/mod_vmd/mod_vmd.c b/src/mod/applications/mod_vmd/mod_vmd.c index 89dcc76ab9..e1932cc0d1 100644 --- a/src/mod/applications/mod_vmd/mod_vmd.c +++ b/src/mod/applications/mod_vmd/mod_vmd.c @@ -508,6 +508,12 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_vmd_load) { switch_application_interface_t *app_interface; switch_api_interface_t *api_interface; + + if (switch_event_reserve_subclass(VMD_EVENT_BEEP) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't register subclass %s!\n", VMD_EVENT_BEEP); + return SWITCH_STATUS_TERM; + } + /* connect my internal structure to the blank pointer passed to me */ *module_interface = switch_loadable_module_create_module_interface(pool, modname); @@ -599,6 +605,8 @@ SWITCH_STANDARD_APP(vmd_start_function) */ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_vmd_shutdown) { + + switch_event_free_subclass(VMD_EVENT_BEEP); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Voicemail detection disabled\n"); return SWITCH_STATUS_SUCCESS; diff --git a/src/mod/asr_tts/mod_unimrcp/mod_unimrcp.c b/src/mod/asr_tts/mod_unimrcp/mod_unimrcp.c index e349ddfaa9..ea563869fb 100644 --- a/src/mod/asr_tts/mod_unimrcp/mod_unimrcp.c +++ b/src/mod/asr_tts/mod_unimrcp/mod_unimrcp.c @@ -4393,6 +4393,21 @@ static mrcp_client_t *mod_unimrcp_client_create(switch_memory_pool_t *mod_pool) */ SWITCH_MODULE_LOAD_FUNCTION(mod_unimrcp_load) { + if (switch_event_reserve_subclass(MY_EVENT_PROFILE_CREATE) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't register subclass %s!\n", MY_EVENT_PROFILE_CREATE); + return SWITCH_STATUS_TERM; + } + + if (switch_event_reserve_subclass(MY_EVENT_PROFILE_CLOSE) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't register subclass %s!\n", MY_EVENT_PROFILE_CLOSE); + return SWITCH_STATUS_TERM; + } + + if (switch_event_reserve_subclass(MY_EVENT_PROFILE_OPEN) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't register subclass %s!\n", MY_EVENT_PROFILE_OPEN); + return SWITCH_STATUS_TERM; + } + /* connect my internal structure to the blank pointer passed to me */ *module_interface = switch_loadable_module_create_module_interface(pool, modname); @@ -4449,6 +4464,11 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_unimrcp_load) */ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_unimrcp_shutdown) { + + switch_event_free_subclass(MY_EVENT_PROFILE_CREATE); + switch_event_free_subclass(MY_EVENT_PROFILE_CLOSE); + switch_event_free_subclass(MY_EVENT_PROFILE_OPEN); + synth_shutdown(); recog_shutdown(); diff --git a/src/mod/endpoints/mod_loopback/mod_loopback.c b/src/mod/endpoints/mod_loopback/mod_loopback.c index 4bcd0c7d3e..99e83add97 100644 --- a/src/mod/endpoints/mod_loopback/mod_loopback.c +++ b/src/mod/endpoints/mod_loopback/mod_loopback.c @@ -1206,6 +1206,12 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_loopback_load) { switch_application_interface_t *app_interface; + if (switch_event_reserve_subclass("loopback::bowout") != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't register subclass %s!\n", "loopback::bowout"); + return SWITCH_STATUS_TERM; + } + + memset(&globals, 0, sizeof(globals)); /* connect my internal structure to the blank pointer passed to me */ @@ -1223,6 +1229,9 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_loopback_load) SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_loopback_shutdown) { + + switch_event_free_subclass("loopback::bowout"); + return SWITCH_STATUS_SUCCESS; } diff --git a/src/mod/endpoints/mod_rtmp/mod_rtmp.c b/src/mod/endpoints/mod_rtmp/mod_rtmp.c index d4e0c218c9..9066148566 100644 --- a/src/mod/endpoints/mod_rtmp/mod_rtmp.c +++ b/src/mod/endpoints/mod_rtmp/mod_rtmp.c @@ -1979,6 +1979,46 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_rtmp_load) switch_api_interface_t *api_interface; rtmp_globals.pool = pool; + if (switch_event_reserve_subclass(RTMP_EVENT_CONNECT) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't register subclass %s!\n", RTMP_EVENT_CONNECT); + return SWITCH_STATUS_TERM; + } + + if (switch_event_reserve_subclass(RTMP_EVENT_DISCONNECT) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't register subclass %s!\n", RTMP_EVENT_DISCONNECT); + return SWITCH_STATUS_TERM; + } + + if (switch_event_reserve_subclass(RTMP_EVENT_REGISTER) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't register subclass %s!\n", RTMP_EVENT_REGISTER); + return SWITCH_STATUS_TERM; + } + + if (switch_event_reserve_subclass(RTMP_EVENT_UNREGISTER) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't register subclass %s!\n", RTMP_EVENT_UNREGISTER); + return SWITCH_STATUS_TERM; + } + + if (switch_event_reserve_subclass(RTMP_EVENT_LOGIN) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't register subclass %s!\n", RTMP_EVENT_LOGIN); + return SWITCH_STATUS_TERM; + } + + if (switch_event_reserve_subclass(RTMP_EVENT_LOGOUT) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't register subclass %s!\n", RTMP_EVENT_LOGOUT); + return SWITCH_STATUS_TERM; + } + + if (switch_event_reserve_subclass(RTMP_EVENT_DETACH) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't register subclass %s!\n", RTMP_EVENT_DETACH); + return SWITCH_STATUS_TERM; + } + + if (switch_event_reserve_subclass(RTMP_EVENT_ATTACH) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't register subclass %s!\n", RTMP_EVENT_ATTACH); + return SWITCH_STATUS_TERM; + } + memset(&rtmp_globals, 0, sizeof(rtmp_globals)); switch_mutex_init(&rtmp_globals.mutex, SWITCH_MUTEX_NESTED, pool); @@ -2070,6 +2110,15 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_rtmp_shutdown) { switch_hash_index_t *hi = NULL; + switch_event_free_subclass(RTMP_EVENT_CONNECT); + switch_event_free_subclass(RTMP_EVENT_DISCONNECT); + switch_event_free_subclass(RTMP_EVENT_REGISTER); + switch_event_free_subclass(RTMP_EVENT_UNREGISTER); + switch_event_free_subclass(RTMP_EVENT_LOGIN); + switch_event_free_subclass(RTMP_EVENT_LOGOUT); + switch_event_free_subclass(RTMP_EVENT_DETACH); + switch_event_free_subclass(RTMP_EVENT_ATTACH); + switch_mutex_lock(rtmp_globals.mutex); while ((hi = switch_core_hash_first_iter(rtmp_globals.profile_hash, hi))) { void *val; diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.c b/src/mod/endpoints/mod_sofia/mod_sofia.c index 8c663622e8..8b141ef2eb 100644 --- a/src/mod/endpoints/mod_sofia/mod_sofia.c +++ b/src/mod/endpoints/mod_sofia/mod_sofia.c @@ -5749,6 +5749,102 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_sofia_load) switch_application_interface_t *app_interface; struct in_addr in; + + if (switch_event_reserve_subclass(MY_EVENT_NOTIFY_REFER) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't register subclass %s!\n", MY_EVENT_NOTIFY_REFER); + return SWITCH_STATUS_TERM; + } + + if (switch_event_reserve_subclass(MY_EVENT_NOTIFY_WATCHED_HEADER) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't register subclass %s!\n", MY_EVENT_NOTIFY_WATCHED_HEADER); + return SWITCH_STATUS_TERM; + } + + if (switch_event_reserve_subclass(MY_EVENT_UNREGISTER) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't register subclass %s!\n", MY_EVENT_UNREGISTER); + return SWITCH_STATUS_TERM; + } + + if (switch_event_reserve_subclass(MY_EVENT_PROFILE_START) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't register subclass %s!\n", MY_EVENT_PROFILE_START); + return SWITCH_STATUS_TERM; + } + + if (switch_event_reserve_subclass(MY_EVENT_REINVITE) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't register subclass %s!\n", MY_EVENT_REINVITE); + return SWITCH_STATUS_TERM; + } + + if (switch_event_reserve_subclass(MY_EVENT_REPLACED) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't register subclass %s!\n", MY_EVENT_REPLACED); + return SWITCH_STATUS_TERM; + } + + if (switch_event_reserve_subclass(MY_EVENT_TRANSFEROR) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't register subclass %s!\n", MY_EVENT_TRANSFEROR); + return SWITCH_STATUS_TERM; + } + + if (switch_event_reserve_subclass(MY_EVENT_TRANSFEREE) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't register subclass %s!\n", MY_EVENT_TRANSFEREE); + return SWITCH_STATUS_TERM; + } + + if (switch_event_reserve_subclass(MY_EVENT_ERROR) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't register subclass %s!\n", MY_EVENT_ERROR); + return SWITCH_STATUS_TERM; + } + + if (switch_event_reserve_subclass(MY_EVENT_INTERCEPTED) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't register subclass %s!\n", MY_EVENT_INTERCEPTED); + return SWITCH_STATUS_TERM; + } + + if (switch_event_reserve_subclass(MY_EVENT_GATEWAY_STATE) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't register subclass %s!\n", MY_EVENT_GATEWAY_STATE); + return SWITCH_STATUS_TERM; + } + + if (switch_event_reserve_subclass(MY_EVENT_SIP_USER_STATE) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't register subclass %s!\n", MY_EVENT_SIP_USER_STATE); + return SWITCH_STATUS_TERM; + } + + if (switch_event_reserve_subclass(MY_EVENT_GATEWAY_DEL) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't register subclass %s!\n", MY_EVENT_GATEWAY_DEL); + return SWITCH_STATUS_TERM; + } + + if (switch_event_reserve_subclass(MY_EVENT_EXPIRE) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't register subclass %s!\n", MY_EVENT_EXPIRE); + return SWITCH_STATUS_TERM; + } + + if (switch_event_reserve_subclass(MY_EVENT_REGISTER_ATTEMPT) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't register subclass %s!\n", MY_EVENT_REGISTER_ATTEMPT); + return SWITCH_STATUS_TERM; + } + + if (switch_event_reserve_subclass(MY_EVENT_REGISTER_FAILURE) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't register subclass %s!\n", MY_EVENT_REGISTER_FAILURE); + return SWITCH_STATUS_TERM; + } + + if (switch_event_reserve_subclass(MY_EVENT_PRE_REGISTER) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't register subclass %s!\n", MY_EVENT_PRE_REGISTER); + return SWITCH_STATUS_TERM; + } + + if (switch_event_reserve_subclass(MY_EVENT_REGISTER) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't register subclass %s!\n", MY_EVENT_REGISTER); + return SWITCH_STATUS_TERM; + } + + if (switch_event_reserve_subclass(MY_EVENT_GATEWAY_ADD) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't register subclass %s!\n", MY_EVENT_GATEWAY_ADD); + return SWITCH_STATUS_TERM; + } + memset(&mod_sofia_globals, 0, sizeof(mod_sofia_globals)); mod_sofia_globals.destroy_private.destroy_nh = 1; mod_sofia_globals.destroy_private.is_static = 1; @@ -5957,6 +6053,26 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_sofia_shutdown) int i; switch_status_t st; + switch_event_free_subclass(MY_EVENT_NOTIFY_REFER); + switch_event_free_subclass(MY_EVENT_NOTIFY_WATCHED_HEADER); + switch_event_free_subclass(MY_EVENT_UNREGISTER); + switch_event_free_subclass(MY_EVENT_PROFILE_START); + switch_event_free_subclass(MY_EVENT_REINVITE); + switch_event_free_subclass(MY_EVENT_REPLACED); + switch_event_free_subclass(MY_EVENT_TRANSFEROR); + switch_event_free_subclass(MY_EVENT_TRANSFEREE); + switch_event_free_subclass(MY_EVENT_ERROR); + switch_event_free_subclass(MY_EVENT_INTERCEPTED); + switch_event_free_subclass(MY_EVENT_GATEWAY_STATE); + switch_event_free_subclass(MY_EVENT_SIP_USER_STATE); + switch_event_free_subclass(MY_EVENT_GATEWAY_DEL); + switch_event_free_subclass(MY_EVENT_EXPIRE); + switch_event_free_subclass(MY_EVENT_REGISTER_ATTEMPT); + switch_event_free_subclass(MY_EVENT_REGISTER_FAILURE); + switch_event_free_subclass(MY_EVENT_PRE_REGISTER); + switch_event_free_subclass(MY_EVENT_REGISTER); + switch_event_free_subclass(MY_EVENT_GATEWAY_ADD); + switch_console_del_complete_func("::sofia::list_profiles"); switch_console_set_complete("del sofia"); diff --git a/src/mod/endpoints/mod_verto/mod_verto.c b/src/mod/endpoints/mod_verto/mod_verto.c index eea514822d..a2aaed5a64 100644 --- a/src/mod/endpoints/mod_verto/mod_verto.c +++ b/src/mod/endpoints/mod_verto/mod_verto.c @@ -5605,6 +5605,22 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_verto_load) switch_cache_db_handle_t *dbh; //switch_application_interface_t *app_interface = NULL; + + if (switch_event_reserve_subclass(MY_EVENT_LOGIN) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't register subclass %s!\n", MY_EVENT_LOGIN); + return SWITCH_STATUS_TERM; + } + + if (switch_event_reserve_subclass(MY_EVENT_CLIENT_DISCONNECT) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't register subclass %s!\n", MY_EVENT_CLIENT_DISCONNECT); + return SWITCH_STATUS_TERM; + } + + if (switch_event_reserve_subclass(MY_EVENT_CLIENT_CONNECT) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't register subclass %s!\n", MY_EVENT_CLIENT_CONNECT); + return SWITCH_STATUS_TERM; + } + memset(&globals, 0, sizeof(globals)); globals.pool = pool; #ifndef WIN32 @@ -5695,6 +5711,11 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_verto_load) Macro expands to: switch_status_t mod_verto_shutdown() */ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_verto_shutdown) { + + switch_event_free_subclass(MY_EVENT_LOGIN); + switch_event_free_subclass(MY_EVENT_CLIENT_DISCONNECT); + switch_event_free_subclass(MY_EVENT_CLIENT_CONNECT); + json_cleanup(); switch_core_hash_destroy(&json_GLOBALS.store_hash); diff --git a/src/mod/event_handlers/mod_event_socket/mod_event_socket.c b/src/mod/event_handlers/mod_event_socket/mod_event_socket.c index 8d1b1d5567..2bce7703f1 100644 --- a/src/mod/event_handlers/mod_event_socket/mod_event_socket.c +++ b/src/mod/event_handlers/mod_event_socket/mod_event_socket.c @@ -1650,6 +1650,35 @@ static switch_bool_t auth_api_command(listener_t *listener, const char *api_cmd, } +static void set_all_custom(listener_t *listener) +{ + switch_console_callback_match_t *events = NULL; + switch_console_callback_match_node_t *m; + + if (switch_event_get_custom_events(&events) == SWITCH_STATUS_SUCCESS) { + for (m = events->head; m; m = m->next) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG1, "ADDING CUSTOM EVENT: %s\n", m->val); + switch_core_hash_insert(listener->event_hash, m->val, MARKER); + } + + switch_console_free_matches(&events); + } +} + +static void set_allowed_custom(listener_t *listener) +{ + switch_hash_index_t *hi = NULL; + const void *var; + void *val; + + switch_assert(listener->allowed_event_hash); + + for (hi = switch_core_hash_first(listener->allowed_event_hash); hi; hi = switch_core_hash_next(&hi)) { + switch_core_hash_this(hi, &var, NULL, &val); + switch_core_hash_insert(listener->event_hash, (char *)var, MARKER); + } +} + static switch_status_t parse_command(listener_t *listener, switch_event_t **event, char *reply, uint32_t reply_len) { switch_status_t status = SWITCH_STATUS_SUCCESS; @@ -2450,6 +2479,13 @@ static switch_status_t parse_command(listener_t *listener, switch_event_t **even for (x = 0; x < SWITCH_EVENT_ALL; x++) { listener->event_list[x] = 1; } + + if (!listener->allowed_event_hash) { + set_all_custom(listener); + } else { + set_allowed_custom(listener); + } + } if (type <= SWITCH_EVENT_ALL) { listener->event_list[type] = 1; @@ -2481,7 +2517,7 @@ static switch_status_t parse_command(listener_t *listener, switch_event_t **even uint8_t custom = 0; strip_cr(cmd); - cur = cmd + 5; + cur = cmd + 8; if (cur && (cur = strchr(cur, ' '))) { for (cur++; cur; count++) { diff --git a/src/mod/event_handlers/mod_rayo/mod_rayo.c b/src/mod/event_handlers/mod_rayo/mod_rayo.c index 4a008e9b84..60224cd9db 100644 --- a/src/mod/event_handlers/mod_rayo/mod_rayo.c +++ b/src/mod/event_handlers/mod_rayo/mod_rayo.c @@ -5158,6 +5158,13 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_rayo_load) switch_api_interface_t *api_interface; switch_application_interface_t *app_interface; + + if (switch_event_reserve_subclass("rayo::cpa") != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't register subclass %s!\n", "rayo::cpa"); + return SWITCH_STATUS_TERM; + } + + *module_interface = switch_loadable_module_create_module_interface(pool, modname); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Loading module\n"); @@ -5267,6 +5274,8 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_rayo_load) */ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_rayo_shutdown) { + switch_event_free_subclass("rayo::cpa"); + switch_status_t result = do_shutdown(); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Module shutdown\n"); return result; diff --git a/src/mod/xml_int/mod_xml_rpc/mod_xml_rpc.c b/src/mod/xml_int/mod_xml_rpc/mod_xml_rpc.c index 3871993078..a71726c357 100644 --- a/src/mod/xml_int/mod_xml_rpc/mod_xml_rpc.c +++ b/src/mod/xml_int/mod_xml_rpc/mod_xml_rpc.c @@ -160,6 +160,12 @@ static switch_status_t do_config(void) SWITCH_MODULE_LOAD_FUNCTION(mod_xml_rpc_load) { + + if (switch_event_reserve_subclass("websocket::stophook") != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't register subclass %s!\n", "websocket::stophook"); + return SWITCH_STATUS_TERM; + } + /* connect my internal structure to the blank pointer passed to me */ *module_interface = switch_loadable_module_create_module_interface(pool, modname); @@ -1268,6 +1274,8 @@ void stop_all_websockets() SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_xml_rpc_shutdown) { + switch_event_free_subclass("websocket::stophook"); + /* Cann't find a way to stop the websockets, use this for a workaround before finding the real one that works */ stop_all_websockets(); diff --git a/src/switch_event.c b/src/switch_event.c index ae73436306..89f1b74cf2 100644 --- a/src/switch_event.c +++ b/src/switch_event.c @@ -1993,6 +1993,22 @@ SWITCH_DECLARE(switch_status_t) switch_event_fire_detailed(const char *file, con return SWITCH_STATUS_SUCCESS; } +SWITCH_DECLARE(switch_status_t) switch_event_get_custom_events(switch_console_callback_match_t **matches) +{ + switch_hash_index_t *hi = NULL; + const void *var; + void *val; + int x = 0; + + for (hi = switch_core_hash_first(CUSTOM_HASH); hi; hi = switch_core_hash_next(&hi)) { + switch_core_hash_this(hi, &var, NULL, &val); + switch_console_push_match(matches, (const char *) var); + x++; + } + + return x ? SWITCH_STATUS_SUCCESS : SWITCH_STATUS_FALSE; +} + SWITCH_DECLARE(switch_status_t) switch_event_bind_removable(const char *id, switch_event_types_t event, const char *subclass_name, switch_event_callback_t callback, void *user_data, switch_event_node_t **node) {