diff --git a/src/include/switch_event.h b/src/include/switch_event.h index a34e0571b4..75658d74d9 100644 --- a/src/include/switch_event.h +++ b/src/include/switch_event.h @@ -208,7 +208,7 @@ SWITCH_DECLARE(switch_status_t) switch_event_fire_detailed(char *file, char *fun \param user_data optional user specific data to pass whenever the callback is invoked \return SWITCH_STATUS_SUCCESS if the event was binded */ -SWITCH_DECLARE(switch_status_t) switch_event_bind(char *id, switch_event_types_t event, char *subclass_name, switch_event_callback_t callback, +SWITCH_DECLARE(switch_status_t) switch_event_bind(const char *id, switch_event_types_t event, char *subclass_name, switch_event_callback_t callback, void *user_data); /*! diff --git a/src/mod/asr_tts/mod_cepstral/mod_cepstral.c b/src/mod/asr_tts/mod_cepstral/mod_cepstral.c index abc40429e7..ad658be912 100644 --- a/src/mod/asr_tts/mod_cepstral/mod_cepstral.c +++ b/src/mod/asr_tts/mod_cepstral/mod_cepstral.c @@ -402,33 +402,9 @@ static void cepstral_float_param_tts(switch_speech_handle_t *sh, char *param, do } -static switch_speech_interface_t cepstral_speech_interface = { - /*.interface_name */ "cepstral", - /*.speech_open */ cepstral_speech_open, - /*.speech_close */ cepstral_speech_close, - /*.speech_feed_tts */ cepstral_speech_feed_tts, - /*.speech_read_tts */ cepstral_speech_read_tts, - /*.speech_flush_tts */ cepstral_speech_flush_tts, - /*.speech_text_param_tts */ cepstral_text_param_tts, - /*.speech_numeric_param_tts */ cepstral_numeric_param_tts, - /*.speech_numeric_param_tts */ cepstral_float_param_tts -}; - -static switch_loadable_module_interface_t cepstral_module_interface = { - /*.module_name */ modname, - /*.endpoint_interface */ NULL, - /*.timer_interface */ NULL, - /*.dialplan_interface */ NULL, - /*.codec_interface */ NULL, - /*.application_interface */ NULL, - /*.api_interface */ NULL, - /*.file_interface */ NULL, - /*.speech_interface */ &cepstral_speech_interface, - /*.directory_interface */ NULL -}; - SWITCH_MODULE_LOAD_FUNCTION(mod_cepstral_load) { + switch_speech_interface_t *speech_interface; /* Open the Swift TTS Engine */ if (SWIFT_FAILED(engine = swift_engine_open(NULL))) { @@ -437,7 +413,17 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_cepstral_load) } /* connect my internal structure to the blank pointer passed to me */ - *module_interface = &cepstral_module_interface; + *module_interface = switch_loadable_module_create_module_interface(pool, modname); + speech_interface = switch_loadable_module_create_interface(*module_interface, SWITCH_SPEECH_INTERFACE); + speech_interface->interface_name = "cepstral"; + speech_interface->speech_open = cepstral_speech_open; + speech_interface->speech_close = cepstral_speech_close; + speech_interface->speech_feed_tts = cepstral_speech_feed_tts; + speech_interface->speech_read_tts = cepstral_speech_read_tts; + speech_interface->speech_flush_tts = cepstral_speech_flush_tts; + speech_interface->speech_text_param_tts = cepstral_text_param_tts; + speech_interface->speech_numeric_param_tts = cepstral_numeric_param_tts; + speech_interface->speech_float_param_tts = cepstral_float_param_tts; /* indicate that the module should continue to be loaded */ return SWITCH_STATUS_SUCCESS; diff --git a/src/mod/directories/mod_ldap/mod_ldap.c b/src/mod/directories/mod_ldap/mod_ldap.c index 978de1d0e4..1654bbce19 100644 --- a/src/mod/directories/mod_ldap/mod_ldap.c +++ b/src/mod/directories/mod_ldap/mod_ldap.c @@ -198,33 +198,19 @@ static switch_status_t mod_ldap_next_pair(switch_directory_handle_t *dh, char ** } -static switch_directory_interface_t ldap_directory_interface = { - /*.interface_name */ "ldap", - /*.directory_open */ mod_ldap_open, - /*.directory_close */ mod_ldap_close, - /*.directory_query */ mod_ldap_query, - /*.directory_next */ mod_ldap_next, - /*.directory_next_pair */ mod_ldap_next_pair -}; - - -static switch_loadable_module_interface_t ldap_module_interface = { - /*.module_name */ modname, - /*.endpoint_interface */ NULL, - /*.timer_interface */ NULL, - /*.dialplan_interface */ NULL, - /*.codec_interface */ NULL, - /*.application_interface */ NULL, - /*.api_interface */ NULL, - /*.file_interface */ NULL, - /*.speech_interface */ NULL, - /*.directory_interface */ &ldap_directory_interface -}; - SWITCH_MODULE_LOAD_FUNCTION(mod_ldap_load) { + switch_directory_interface_t *dir_interface; + /* connect my internal structure to the blank pointer passed to me */ - *module_interface = &ldap_module_interface; + *module_interface = switch_loadable_module_create_module_interface(pool, modname); + dir_interface = switch_loadable_module_create_interface(*module_interface, SWITCH_DIRECTORY_INTERFACE); + dir_interface->interface_name = "ldap"; + dir_interface->directory_open = mod_ldap_open; + dir_interface->directory_close = mod_ldap_close; + dir_interface->directory_query = mod_ldap_query; + dir_interface->directory_next = mod_ldap_next; + dir_interface->directory_next_pair = mod_ldap_next_pair; /* indicate that the module should continue to be loaded */ return SWITCH_STATUS_SUCCESS; diff --git a/src/mod/endpoints/mod_dingaling/mod_dingaling.c b/src/mod/endpoints/mod_dingaling/mod_dingaling.c index 6f1848e945..d3b360d8cf 100644 --- a/src/mod/endpoints/mod_dingaling/mod_dingaling.c +++ b/src/mod/endpoints/mod_dingaling/mod_dingaling.c @@ -48,6 +48,7 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_dingaling_shutdown); SWITCH_MODULE_DEFINITION(mod_dingaling, mod_dingaling_load, mod_dingaling_shutdown, NULL); static switch_memory_pool_t *module_pool = NULL; +static switch_endpoint_interface_t *channel_endpoint_interface; static char sub_sql[] = "CREATE TABLE jabber_subscriptions (\n" @@ -1590,65 +1591,6 @@ static switch_io_routines_t channel_io_routines = { /*.receive_event */ channel_receive_event }; -static switch_endpoint_interface_t channel_endpoint_interface = { - /*.interface_name */ "dingaling", - /*.io_routines */ &channel_io_routines, - /*.event_handlers */ &channel_event_handlers, - /*.private */ NULL, - /*.next */ NULL -}; - - -static switch_api_interface_t debug_api_interface = { - /*.interface_name */ "dl_debug", - /*.desc */ "DingaLing Debug", - /*.function */ dl_debug, - /*.syntax */ "dl_debug [true|false]", - /*.next */ NULL -}; - -static switch_api_interface_t pres_api_interface = { - /*.interface_name */ "dl_pres", - /*.desc */ "DingaLing Presence", - /*.function */ dl_pres, - /*.syntax */ "dl_pres ", - /*.next */ &debug_api_interface -}; - -static switch_api_interface_t logout_api_interface = { - /*.interface_name */ "dl_logout", - /*.desc */ "DingaLing Logout", - /*.function */ dl_logout, - /*.syntax */ "dl_logout ", - /*.next */ &pres_api_interface -}; - -static switch_api_interface_t login_api_interface = { - /*.interface_name */ "dl_login", - /*.desc */ "DingaLing Login", - /*.function */ dl_login, - /*.syntax */ "dl_login ", - /*.next */ &logout_api_interface -}; - -static switch_chat_interface_t channel_chat_interface = { - /*.name */ MDL_CHAT_PROTO, - /*.chat_send */ chat_send, -}; - -static switch_loadable_module_interface_t channel_module_interface = { - /*.module_name */ modname, - /*.endpoint_interface */ &channel_endpoint_interface, - /*.timer_interface */ NULL, - /*.dialplan_interface */ NULL, - /*.codec_interface */ NULL, - /*.application_interface */ NULL, - /*.api_interface */ &login_api_interface, - /*.file_interface */ NULL, - /*.speech_interface */ NULL, - /*.directory_interface */ NULL, - /*.chat_interface */ &channel_chat_interface -}; /* Make sure when you have 2 sessions in the same scope that you pass the appropriate one to the routines @@ -1658,7 +1600,7 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi switch_caller_profile_t *outbound_profile, switch_core_session_t **new_session, switch_memory_pool_t **pool) { - if ((*new_session = switch_core_session_request(&channel_endpoint_interface, pool)) != 0) { + if ((*new_session = switch_core_session_request(channel_endpoint_interface, pool)) != 0) { struct private_object *tech_pvt; switch_channel_t *channel; switch_caller_profile_t *caller_profile = NULL; @@ -1828,11 +1770,10 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi SWITCH_MODULE_LOAD_FUNCTION(mod_dingaling_load) { + switch_chat_interface_t *chat_interface; + switch_api_interface_t *api_interface; - if (switch_core_new_memory_pool(&module_pool) != SWITCH_STATUS_SUCCESS) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "OH OH no pool\n"); - return SWITCH_STATUS_TERM; - } + module_pool = pool; load_config(); @@ -1873,7 +1814,22 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_dingaling_load) } /* connect my internal structure to the blank pointer passed to me */ - *module_interface = &channel_module_interface; + *module_interface = switch_loadable_module_create_module_interface(pool, modname); + channel_endpoint_interface = switch_loadable_module_create_interface(*module_interface, SWITCH_ENDPOINT_INTERFACE); + channel_endpoint_interface->interface_name = modname; + channel_endpoint_interface->io_routines = &channel_io_routines; + channel_endpoint_interface->state_handler = &channel_event_handlers; + +#define PRES_SYNTAX "dl_pres " +#define LOGOUT_SYNTAX "dl_logout " +#define LOGIN_SYNTAX "dl_login " +#define DEBUG_SYNTAX "dl_debug [true|false]" + + SWITCH_ADD_API(api_interface, "dl_debug", "DingaLing Debug", dl_debug, DEBUG_SYNTAX); + SWITCH_ADD_API(api_interface, "dl_pres", "DingaLing Presence", dl_pres, PRES_SYNTAX); + SWITCH_ADD_API(api_interface, "dl_logout", "DingaLing Logout", dl_logout, LOGOUT_SYNTAX); + SWITCH_ADD_API(api_interface, "dl_login", "DingaLing Login", dl_login, LOGIN_SYNTAX); + SWITCH_ADD_CHAT(chat_interface, MDL_CHAT_PROTO, chat_send); /* indicate that the module should continue to be loaded */ return SWITCH_STATUS_SUCCESS; @@ -2059,7 +2015,7 @@ SWITCH_STANDARD_API(dl_pres) } if (!cmd) { - stream->write_function(stream, "USAGE: %s\n", pres_api_interface.syntax); + stream->write_function(stream, "USAGE: %s\n", PRES_SYNTAX); return SWITCH_STATUS_SUCCESS; } @@ -2086,7 +2042,7 @@ SWITCH_STANDARD_API(dl_logout) } if (!cmd) { - stream->write_function(stream, "USAGE: %s\n", logout_api_interface.syntax); + stream->write_function(stream, "USAGE: %s\n", LOGOUT_SYNTAX); return SWITCH_STATUS_SUCCESS; } @@ -2113,7 +2069,7 @@ SWITCH_STANDARD_API(dl_login) } if (switch_strlen_zero(cmd)) { - stream->write_function(stream, "USAGE: %s\n", login_api_interface.syntax); + stream->write_function(stream, "USAGE: %s\n", LOGIN_SYNTAX); return SWITCH_STATUS_SUCCESS; } @@ -2122,7 +2078,7 @@ SWITCH_STANDARD_API(dl_login) argc = switch_separate_string(myarg, ';', argv, (sizeof(argv) / sizeof(argv[0]))); if (switch_strlen_zero(cmd) || argc != 1) { - stream->write_function(stream, "USAGE: %s\n", login_api_interface.syntax); + stream->write_function(stream, "USAGE: %s\n", LOGIN_SYNTAX); return SWITCH_STATUS_SUCCESS; } @@ -2603,7 +2559,7 @@ static ldl_status handle_signalling(ldl_handle_t * handle, ldl_session_t * dlses status = LDL_STATUS_FALSE; goto done; } - if ((session = switch_core_session_request(&channel_endpoint_interface, NULL)) != 0) { + if ((session = switch_core_session_request(channel_endpoint_interface, NULL)) != 0) { switch_core_session_add_stream(session, NULL); diff --git a/src/mod/endpoints/mod_portaudio/mod_portaudio.c b/src/mod/endpoints/mod_portaudio/mod_portaudio.c index 8dd7e2e4fa..71bd27bbd6 100644 --- a/src/mod/endpoints/mod_portaudio/mod_portaudio.c +++ b/src/mod/endpoints/mod_portaudio/mod_portaudio.c @@ -44,7 +44,7 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_portaudio_shutdown); SWITCH_MODULE_DEFINITION(mod_portaudio, mod_portaudio_load, mod_portaudio_shutdown, NULL); static switch_memory_pool_t *module_pool = NULL; -//static int running = 1; +static switch_endpoint_interface_t *channel_endpoint_interface; #define SAMPLE_TYPE paInt16 //#define SAMPLE_TYPE paFloat32 @@ -734,54 +734,6 @@ static switch_status_t channel_receive_message(switch_core_session_t *session, s return SWITCH_STATUS_SUCCESS; } -static switch_api_interface_t send_dtmf_interface = { - /*.interface_name */ "padtmf", - /*.desc */ "DEPRICATED (see 'pa')", - /*.function */ padep, - /*.syntax */ "DEPRICATED (see 'pa')", - /*.next */ NULL -}; - -static switch_api_interface_t answer_call_interface = { - /*.interface_name */ "paoffhook", - /*.desc */ "DEPRICATED (see 'pa')", - /*.function */ padep, - /*.syntax */ "DEPRICATED (see 'pa')", - /*.next */ &send_dtmf_interface -}; - -static switch_api_interface_t channel_info_interface = { - /*.interface_name */ "painfo", - /*.desc */ "DEPRICATED (see 'pa')", - /*.function */ padep, - /*.syntax */ "DEPRICATED (see 'pa')", - /*.next */ &answer_call_interface -}; - -static switch_api_interface_t channel_hup_interface = { - /*.interface_name */ "pahup", - /*.desc */ "DEPRICATED (see 'pa')", - /*.function */ padep, - /*.syntax */ "DEPRICATED (see 'pa')", - /*.next */ &channel_info_interface -}; - -static switch_api_interface_t channel_call_interface = { - /*.interface_name */ "pacall", - /*.desc */ "DEPRICATED (see 'pa')", - /*.function */ padep, - /*.syntax */ "DEPRICATED (see 'pa')", - /*.next */ &channel_hup_interface -}; - -static switch_api_interface_t channel_api_interface = { - /*.interface_name */ "pa", - /*.desc */ "PortAudio", - /*.function */ pa_cmd, - /*.syntax */ " []", - /*.next */ &channel_call_interface -}; - static switch_state_handler_table_t channel_event_handlers = { /*.on_init */ channel_on_init, /*.on_ring */ channel_on_ring, @@ -802,24 +754,6 @@ static switch_io_routines_t channel_io_routines = { /*.receive_message */ channel_receive_message }; -static switch_endpoint_interface_t channel_endpoint_interface = { - /*.interface_name */ "portaudio", - /*.io_routines */ &channel_io_routines, - /*.event_handlers */ &channel_event_handlers, - /*.private */ NULL, - /*.next */ NULL -}; - -static switch_loadable_module_interface_t channel_module_interface = { - /*.module_name */ modname, - /*.endpoint_interface */ &channel_endpoint_interface, - /*.timer_interface */ NULL, - /*.dialplan_interface */ NULL, - /*.codec_interface */ NULL, - /*.application_interface */ NULL, - /*.api_interface */ &channel_api_interface -}; - /* Make sure when you have 2 sessions in the same scope that you pass the appropriate one to the routines that allocate memory or you will have 1 channel with memory allocated from another channel's pool! */ @@ -828,7 +762,7 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi switch_core_session_t **new_session, switch_memory_pool_t **pool) { - if ((*new_session = switch_core_session_request(&channel_endpoint_interface, pool)) != 0) { + if ((*new_session = switch_core_session_request(channel_endpoint_interface, pool)) != 0) { private_t *tech_pvt; switch_channel_t *channel; switch_caller_profile_t *caller_profile; @@ -876,13 +810,10 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi SWITCH_MODULE_LOAD_FUNCTION(mod_portaudio_load) { - switch_status_t status; + switch_api_interface_t *api_interface; - if (switch_core_new_memory_pool(&module_pool) != SWITCH_STATUS_SUCCESS) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "OH OH no pool\n"); - return SWITCH_STATUS_TERM; - } + module_pool = pool; Pa_Initialize(); @@ -921,7 +852,13 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_portaudio_load) switch_set_flag((&globals.cng_frame), SFF_CNG); /* connect my internal structure to the blank pointer passed to me */ - *module_interface = &channel_module_interface; + *module_interface = switch_loadable_module_create_module_interface(pool, modname); + channel_endpoint_interface = switch_loadable_module_create_interface(*module_interface, SWITCH_ENDPOINT_INTERFACE); + channel_endpoint_interface->interface_name = modname; + channel_endpoint_interface->io_routines = &channel_io_routines; + channel_endpoint_interface->state_handler = &channel_event_handlers; + + SWITCH_ADD_API(api_interface, "pa", "PortAudio", pa_cmd, " []"); /* indicate that the module should continue to be loaded */ return SWITCH_STATUS_SUCCESS; @@ -1639,7 +1576,7 @@ static switch_status_t place_call(char **argv, int argc, switch_stream_handle_t } dest = argv[0]; - if ((session = switch_core_session_request(&channel_endpoint_interface, NULL)) != 0) { + if ((session = switch_core_session_request(channel_endpoint_interface, NULL)) != 0) { private_t *tech_pvt; switch_channel_t *channel; char *dialplan = globals.dialplan; diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.c b/src/mod/endpoints/mod_sofia/mod_sofia.c index 04c661d98c..607c586e43 100644 --- a/src/mod/endpoints/mod_sofia/mod_sofia.c +++ b/src/mod/endpoints/mod_sofia/mod_sofia.c @@ -43,7 +43,7 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_sofia_shutdown); SWITCH_MODULE_DEFINITION(mod_sofia, mod_sofia_load, mod_sofia_shutdown, NULL); struct mod_sofia_globals mod_sofia_globals; -switch_endpoint_interface_t sofia_endpoint_interface; +switch_endpoint_interface_t *sofia_endpoint_interface; static switch_frame_t silence_frame = { 0 }; static char silence_data[13] = ""; @@ -1288,56 +1288,11 @@ static switch_state_handler_table_t sofia_event_handlers = { /*.on_transmit */ sofia_on_transmit }; -switch_endpoint_interface_t sofia_endpoint_interface = { - /*.interface_name */ "sofia", - /*.io_routines */ &sofia_io_routines, - /*.event_handlers */ &sofia_event_handlers, - /*.private */ NULL, - /*.next */ NULL -}; - -static switch_chat_interface_t sofia_chat_interface = { - /*.name */ SOFIA_CHAT_PROTO, - /*.sofia_presence_chat_send */ sofia_presence_chat_send, - -}; - static switch_status_t sofia_manage(char *relative_oid, switch_management_action_t action, char *data, switch_size_t datalen) { return SWITCH_STATUS_SUCCESS; } -static switch_management_interface_t sofia_management_interface = { - /*.relative_oid */ "1", - /*.management_function */ sofia_manage -}; - -static switch_api_interface_t sofia_api_interface = { - /*.interface_name */ "sofia", - /*.desc */ "Sofia Controls", - /*.function */ sofia_function, - /*.syntax */ " ", - /*.next */ NULL -}; - -static switch_loadable_module_interface_t sofia_module_interface = { - /*.module_name */ modname, - /*.endpoint_interface */ &sofia_endpoint_interface, - /*.timer_interface */ NULL, - /*.dialplan_interface */ NULL, - /*.codec_interface */ NULL, - /*.application_interface */ NULL, - /*.api_interface */ &sofia_api_interface, - /*.file_interface */ NULL, - /*.speech_interface */ NULL, - /*.directory_interface */ NULL, - /*.chat_interface */ &sofia_chat_interface, - /*.say_interface */ NULL, - /*.asr_interface */ NULL, - /*.management_interface */ &sofia_management_interface -}; - - static switch_call_cause_t sofia_outgoing_channel(switch_core_session_t *session, switch_caller_profile_t *outbound_profile, switch_core_session_t **new_session, @@ -1354,7 +1309,7 @@ static switch_call_cause_t sofia_outgoing_channel(switch_core_session_t *session *new_session = NULL; - if (!(nsession = switch_core_session_request(&sofia_endpoint_interface, pool))) { + if (!(nsession = switch_core_session_request(sofia_endpoint_interface, pool))) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Error Creating Session\n"); goto done; } @@ -1503,6 +1458,9 @@ static switch_call_cause_t sofia_outgoing_channel(switch_core_session_t *session SWITCH_MODULE_LOAD_FUNCTION(mod_sofia_load) { + switch_chat_interface_t *chat_interface; + switch_api_interface_t *api_interface; + switch_management_interface_t *management_interface; silence_frame.data = silence_data; silence_frame.datalen = sizeof(silence_data); @@ -1510,10 +1468,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_sofia_load) silence_frame.flags = SFF_CNG; - if (switch_core_new_memory_pool(&module_pool) != SWITCH_STATUS_SUCCESS) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "OH OH no pool\n"); - return SWITCH_STATUS_TERM; - } + module_pool = pool; memset(&mod_sofia_globals, 0, sizeof(mod_sofia_globals)); switch_mutex_init(&mod_sofia_globals.mutex, SWITCH_MUTEX_NESTED, module_pool); @@ -1536,43 +1491,54 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_sofia_load) switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Waiting for profiles to start\n"); switch_yield(1500000); - if (switch_event_bind((char *) modname, SWITCH_EVENT_CUSTOM, MULTICAST_EVENT, event_handler, NULL) != SWITCH_STATUS_SUCCESS) { + if (switch_event_bind(modname, SWITCH_EVENT_CUSTOM, MULTICAST_EVENT, event_handler, NULL) != SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't bind!\n"); return SWITCH_STATUS_TERM; } - if (switch_event_bind((char *) modname, SWITCH_EVENT_PRESENCE_IN, SWITCH_EVENT_SUBCLASS_ANY, sofia_presence_event_handler, NULL) + if (switch_event_bind(modname, SWITCH_EVENT_PRESENCE_IN, SWITCH_EVENT_SUBCLASS_ANY, sofia_presence_event_handler, NULL) != SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't bind!\n"); return SWITCH_STATUS_GENERR; } - if (switch_event_bind((char *) modname, SWITCH_EVENT_PRESENCE_OUT, SWITCH_EVENT_SUBCLASS_ANY, sofia_presence_event_handler, NULL) + if (switch_event_bind(modname, SWITCH_EVENT_PRESENCE_OUT, SWITCH_EVENT_SUBCLASS_ANY, sofia_presence_event_handler, NULL) != SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't bind!\n"); return SWITCH_STATUS_GENERR; } - if (switch_event_bind((char *) modname, SWITCH_EVENT_PRESENCE_PROBE, SWITCH_EVENT_SUBCLASS_ANY, sofia_presence_event_handler, NULL) + if (switch_event_bind(modname, SWITCH_EVENT_PRESENCE_PROBE, SWITCH_EVENT_SUBCLASS_ANY, sofia_presence_event_handler, NULL) != SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't bind!\n"); return SWITCH_STATUS_GENERR; } - if (switch_event_bind((char *) modname, SWITCH_EVENT_ROSTER, SWITCH_EVENT_SUBCLASS_ANY, sofia_presence_event_handler, NULL) + if (switch_event_bind(modname, SWITCH_EVENT_ROSTER, SWITCH_EVENT_SUBCLASS_ANY, sofia_presence_event_handler, NULL) != SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't bind!\n"); return SWITCH_STATUS_GENERR; } - if (switch_event_bind((char *) modname, SWITCH_EVENT_MESSAGE_WAITING, SWITCH_EVENT_SUBCLASS_ANY, sofia_presence_mwi_event_handler, NULL) + if (switch_event_bind(modname, SWITCH_EVENT_MESSAGE_WAITING, SWITCH_EVENT_SUBCLASS_ANY, sofia_presence_mwi_event_handler, NULL) != SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't bind!\n"); return SWITCH_STATUS_GENERR; } /* connect my internal structure to the blank pointer passed to me */ - *module_interface = &sofia_module_interface; + *module_interface = switch_loadable_module_create_module_interface(pool, modname); + sofia_endpoint_interface = switch_loadable_module_create_interface(*module_interface, SWITCH_ENDPOINT_INTERFACE); + sofia_endpoint_interface->interface_name = modname; + sofia_endpoint_interface->io_routines = &sofia_io_routines; + sofia_endpoint_interface->state_handler = &sofia_event_handlers; + + management_interface = switch_loadable_module_create_interface(*module_interface, SWITCH_MANAGEMENT_INTERFACE); + management_interface->relative_oid = "1"; + management_interface->management_function = sofia_manage; + + SWITCH_ADD_API(api_interface, "sofia", "Sofia Controls", sofia_function, " "); + SWITCH_ADD_CHAT(chat_interface, SOFIA_CHAT_PROTO, sofia_presence_chat_send); /* indicate that the module should continue to be loaded */ return SWITCH_STATUS_SUCCESS; diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.h b/src/mod/endpoints/mod_sofia/mod_sofia.h index 9d89e7f40b..8fd3a65180 100644 --- a/src/mod/endpoints/mod_sofia/mod_sofia.h +++ b/src/mod/endpoints/mod_sofia/mod_sofia.h @@ -465,7 +465,7 @@ switch_call_cause_t sofia_glue_sip_cause_to_freeswitch(int status); void sofia_glue_do_xfer_invite(switch_core_session_t *session); uint8_t sofia_reg_handle_register(nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sip_t const *sip, sofia_regtype_t regtype, char *key, uint32_t keylen, switch_event_t **v_event); -extern switch_endpoint_interface_t sofia_endpoint_interface; +extern switch_endpoint_interface_t *sofia_endpoint_interface; void sofia_presence_set_chat_hash(private_object_t *tech_pvt, sip_t const *sip); switch_status_t sofia_on_hangup(switch_core_session_t *session); char *sofia_glue_get_url_from_contact(char *buf, uint8_t to_dup); diff --git a/src/mod/endpoints/mod_sofia/sofia.c b/src/mod/endpoints/mod_sofia/sofia.c index 6df51c9701..df6d001c3a 100644 --- a/src/mod/endpoints/mod_sofia/sofia.c +++ b/src/mod/endpoints/mod_sofia/sofia.c @@ -1771,7 +1771,7 @@ void sofia_handle_sip_i_invite(nua_t *nua, sofia_profile_t *profile, nua_handle_ is_auth++; } - if (!(session = switch_core_session_request(&sofia_endpoint_interface, NULL))) { + if (!(session = switch_core_session_request(sofia_endpoint_interface, NULL))) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Session Alloc Failed!\n"); nua_respond(nh, SIP_503_SERVICE_UNAVAILABLE, TAG_END()); return; diff --git a/src/mod/endpoints/mod_woomera/mod_woomera.c b/src/mod/endpoints/mod_woomera/mod_woomera.c index c4bc80f1b9..a8ab683fc2 100644 --- a/src/mod/endpoints/mod_woomera/mod_woomera.c +++ b/src/mod/endpoints/mod_woomera/mod_woomera.c @@ -54,6 +54,7 @@ SWITCH_MODULE_RUNTIME_FUNCTION(mod_woomera_runtime); SWITCH_MODULE_DEFINITION(mod_woomera, mod_woomera_load, mod_woomera_shutdown, mod_woomera_runtime); static switch_memory_pool_t *module_pool = NULL; +static switch_endpoint_interface_t *woomera_endpoint_interface; #define STRLEN 15 #define FRAME_LEN 480 @@ -459,24 +460,6 @@ static switch_io_routines_t woomera_io_routines = { /*.waitfor_write */ woomera_waitfor_write }; -static switch_endpoint_interface_t woomera_endpoint_interface = { - /*.interface_name */ "woomera", - /*.io_routines */ &woomera_io_routines, - /*.event_handlers */ &woomera_event_handlers, - /*.private */ NULL, - /*.next */ NULL -}; - -static switch_loadable_module_interface_t woomera_module_interface = { - /*.module_name */ modname, - /*.endpoint_interface */ &woomera_endpoint_interface, - /*.timer_interface */ NULL, - /*.dialplan_interface */ NULL, - /*.codec_interface */ NULL, - /*.application_interface */ NULL -}; - - /* Make sure when you have 2 sessions in the same scope that you pass the appropriate one to the routines that allocate memory or you will have 1 channel with memory allocated from another channel's pool! */ @@ -484,7 +467,7 @@ static switch_call_cause_t woomera_outgoing_channel(switch_core_session_t *sessi switch_caller_profile_t *outbound_profile, switch_core_session_t **new_session, switch_memory_pool_t **pool) { - if ((*new_session = switch_core_session_request(&woomera_endpoint_interface, pool)) != 0) { + if ((*new_session = switch_core_session_request(woomera_endpoint_interface, pool)) != 0) { struct private_object *tech_pvt; switch_channel_t *channel; @@ -1226,7 +1209,7 @@ static void *woomera_thread_run(void *obj) } switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "New Inbound Channel %s!\n", name); - if ((session = switch_core_session_request(&woomera_endpoint_interface, NULL)) != 0) { + if ((session = switch_core_session_request(woomera_endpoint_interface, NULL)) != 0) { struct private_object *tech_pvt; switch_channel_t *channel; @@ -1294,9 +1277,9 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_woomera_shutdown) return SWITCH_STATUS_SUCCESS; } + SWITCH_MODULE_LOAD_FUNCTION(mod_woomera_load) { - struct woomera_profile *profile = &default_profile; char *cf = "woomera.conf"; switch_xml_t cfg, xml, settings, param, xmlp; @@ -1360,27 +1343,19 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_woomera_load) switch_xml_free(xml); - - if (switch_core_new_memory_pool(&module_pool) != SWITCH_STATUS_SUCCESS) { - //switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "OH OH no pool\n"); - - if (switch_core_new_memory_pool(&module_pool) != SWITCH_STATUS_SUCCESS) { - //switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "OH OH no pool\n"); - return SWITCH_STATUS_MEMERR; - } - return SWITCH_STATUS_MEMERR; - } - - + module_pool = pool; if (switch_mutex_init(&default_profile.iolock, SWITCH_MUTEX_NESTED, module_pool) != SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "OH OH no lock\n"); return SWITCH_STATUS_TERM; } - /* connect my internal structure to the blank pointer passed to me */ - *module_interface = &woomera_module_interface; + *module_interface = switch_loadable_module_create_module_interface(pool, modname); + woomera_endpoint_interface = switch_loadable_module_create_interface(*module_interface, SWITCH_ENDPOINT_INTERFACE); + woomera_endpoint_interface->interface_name = modname; + woomera_endpoint_interface->io_routines = &woomera_io_routines; + woomera_endpoint_interface->state_handler = &woomera_event_handlers; /* indicate that the module should continue to be loaded */ return SWITCH_STATUS_SUCCESS; diff --git a/src/switch_event.c b/src/switch_event.c index 3390b46989..6e70293f1d 100644 --- a/src/switch_event.c +++ b/src/switch_event.c @@ -870,7 +870,7 @@ SWITCH_DECLARE(switch_status_t) switch_event_fire_detailed(char *file, char *fun return SWITCH_STATUS_SUCCESS; } -SWITCH_DECLARE(switch_status_t) switch_event_bind(char *id, switch_event_types_t event, char *subclass_name, switch_event_callback_t callback, +SWITCH_DECLARE(switch_status_t) switch_event_bind(const char *id, switch_event_types_t event, char *subclass_name, switch_event_callback_t callback, void *user_data) { switch_event_node_t *event_node;