add more modules to new mod loader macros/api.

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@5403 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Michael Jerris 2007-06-20 07:15:53 +00:00
parent ee67c1412b
commit 008777e95e
10 changed files with 98 additions and 292 deletions

View File

@ -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);
/*!

View File

@ -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;

View File

@ -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;

View File

@ -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 <profile_name>",
/*.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 <profile_name>",
/*.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 <profile_name>",
/*.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 <profile_name>"
#define LOGOUT_SYNTAX "dl_logout <profile_name>"
#define LOGIN_SYNTAX "dl_login <profile_name>"
#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);

View File

@ -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 */ "<command> [<args>]",
/*.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, "<command> [<args>]");
/* 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;

View File

@ -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 */ "<cmd> <args>",
/*.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, "<cmd> <args>");
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;

View File

@ -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);

View File

@ -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;

View File

@ -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;

View File

@ -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;