diff --git a/src/include/switch_core.h b/src/include/switch_core.h index efb28017a5..2c6603568c 100644 --- a/src/include/switch_core.h +++ b/src/include/switch_core.h @@ -565,6 +565,8 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_flush_message(switch_core_se */ SWITCH_DECLARE(switch_status_t) switch_core_session_event_send(char *uuid_str, switch_event_t **event); +SWITCH_DECLARE(switch_status_t) switch_core_session_execute_exten(switch_core_session_t *session, char *exten, char *dialplan, char *context); + /*! \brief Send an event to a session translating it to it's native message format \param session the session to receive the event diff --git a/src/include/switch_types.h b/src/include/switch_types.h index 7a7f6c0285..19aa2867bd 100644 --- a/src/include/switch_types.h +++ b/src/include/switch_types.h @@ -999,7 +999,7 @@ typedef struct switch_media_bug switch_media_bug_t; typedef switch_bool_t (*switch_media_bug_callback_t) (switch_media_bug_t *, void *, switch_abc_type_t); typedef void (*switch_application_function_t) (switch_core_session_t *, char *); typedef void (*switch_event_callback_t) (switch_event_t *); -typedef switch_caller_extension_t *(*switch_dialplan_hunt_function_t) (switch_core_session_t *, void *); +typedef switch_caller_extension_t *(*switch_dialplan_hunt_function_t) (switch_core_session_t *, void *, switch_caller_profile_t *); typedef struct switch_scheduler_task switch_scheduler_task_t; typedef void (*switch_scheduler_func_t) (switch_scheduler_task_t *task); typedef switch_status_t (*switch_state_handler_t) (switch_core_session_t *); diff --git a/src/mod/applications/mod_dptools/mod_dptools.c b/src/mod/applications/mod_dptools/mod_dptools.c index 609590579d..6770a933aa 100644 --- a/src/mod/applications/mod_dptools/mod_dptools.c +++ b/src/mod/applications/mod_dptools/mod_dptools.c @@ -36,6 +36,7 @@ static const char modname[] = "mod_dptools"; static const switch_application_interface_t detect_speech_application_interface; +static const switch_application_interface_t exe_application_interface; static void detect_speech_function(switch_core_session_t *session, char *data) { @@ -64,6 +65,26 @@ static void detect_speech_function(switch_core_session_t *session, char *data) } +static void exe_function(switch_core_session_t *session, char *data) +{ + char *argv[4]; + int argc; + char *lbuf = NULL; + char *extension; + char *context; + char *dialplan; + + if (data && (lbuf = switch_core_session_strdup(session, data)) + && (argc = switch_separate_string(lbuf, ' ', argv, (sizeof(argv) / sizeof(argv[0]))))) { + extension = argv[0]; + dialplan = argv[1]; + context = argv[2]; + switch_core_session_execute_exten(session, extension, dialplan, context); + } else { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Usage: %s\n", exe_application_interface.syntax); + } +} + static void ring_ready_function(switch_core_session_t *session, char *data) { switch_channel_t *channel; @@ -606,7 +627,7 @@ static void ivr_application_function(switch_core_session_t *session, char *data) } -static switch_api_interface_t strepoch_api_interface = { +static const switch_api_interface_t strepoch_api_interface = { /*.interface_name */ "strepoch", /*.desc */ "Convert a date string into epoch time", /*.function */ strepoch_api_function, @@ -614,7 +635,7 @@ static switch_api_interface_t strepoch_api_interface = { /*.next */ NULL }; -static switch_api_interface_t chat_api_interface = { +static const switch_api_interface_t chat_api_interface = { /*.interface_name */ "chat", /*.desc */ "chat", /*.function */ chat_api_function, @@ -622,7 +643,7 @@ static switch_api_interface_t chat_api_interface = { /*.next */ &strepoch_api_interface }; -static switch_api_interface_t dptools_api_interface = { +static const switch_api_interface_t dptools_api_interface = { /*.interface_name */ "strftime", /*.desc */ "strftime", /*.function */ strftime_api_function, @@ -630,7 +651,7 @@ static switch_api_interface_t dptools_api_interface = { /*.next */ &chat_api_interface }; -static switch_api_interface_t presence_api_interface = { +static const switch_api_interface_t presence_api_interface = { /*.interface_name */ "presence", /*.desc */ "presence", /*.function */ presence_api_function, @@ -639,18 +660,27 @@ static switch_api_interface_t presence_api_interface = { }; +static const switch_application_interface_t exe_application_interface = { + /*.interface_name */ "execute_extension", + /*.application_function */ exe_function, + /*.long_desc */ "Execute an extension", + /*.short_desc */ "Execute an extension", + /*.syntax */ " ", + /* flags */ SAF_SUPPORT_NOMEDIA, + /*.next */ +}; -static switch_application_interface_t sched_transfer_application_interface = { +static const switch_application_interface_t sched_transfer_application_interface = { /*.interface_name */ "sched_transfer", /*.application_function */ sched_transfer_function, /*.long_desc */ "Schedule a transfer in the future", /*.short_desc */ "Schedule a transfer in the future", /*.syntax */ "[+]