[Freeswitch-svn] [commit] r7878 - in freeswitch/trunk/src: . include
Freeswitch SVN
mikej at freeswitch.org
Wed Mar 12 03:48:38 EDT 2008
Author: mikej
Date: Wed Mar 12 03:48:38 2008
New Revision: 7878
Modified:
freeswitch/trunk/src/include/switch_types.h
freeswitch/trunk/src/switch_core_state_machine.c
Log:
add api_hangup_hook
Modified: freeswitch/trunk/src/include/switch_types.h
==============================================================================
--- freeswitch/trunk/src/include/switch_types.h (original)
+++ freeswitch/trunk/src/include/switch_types.h Wed Mar 12 03:48:38 2008
@@ -102,6 +102,7 @@
#define SWITCH_PATH_SEPARATOR "/"
#endif
#define SWITCH_URL_SEPARATOR "://"
+#define SWITCH_API_HANGUP_HOOK_VARIABLE "api_hangup_hook"
#define SWITCH_PROCESS_CDR_VARIABLE "process_cdr"
#define SWITCH_BRIDGE_CHANNEL_VARIABLE "bridge_channel"
#define SWITCH_CHANNEL_NAME_VARIABLE "channel_name"
Modified: freeswitch/trunk/src/switch_core_state_machine.c
==============================================================================
--- freeswitch/trunk/src/switch_core_state_machine.c (original)
+++ freeswitch/trunk/src/switch_core_state_machine.c Wed Mar 12 03:48:38 2008
@@ -412,6 +412,7 @@
case CS_HANGUP: /* Deactivate and end the thread */
{
const char *var = switch_channel_get_variable(session->channel, SWITCH_PROCESS_CDR_VARIABLE);
+ const char *hook_var = switch_channel_get_variable(session->channel, SWITCH_API_HANGUP_HOOK_VARIABLE);
if (!switch_strlen_zero(var)) {
if (!strcasecmp(var, "a_only")) {
@@ -429,6 +430,19 @@
switch_core_session_signal_lock(session);
STATE_MACRO(hangup, "HANGUP");
switch_core_session_signal_unlock(session);
+
+ if (!switch_strlen_zero(hook_var)) {
+ switch_stream_handle_t stream = { 0 };
+ char *cmd = switch_core_session_strdup(session, hook_var);
+ char *arg = NULL;
+ if ((arg = strchr(cmd, ' '))) {
+ *arg++ = '\0';
+ }
+ SWITCH_STANDARD_STREAM(stream);
+ switch_api_execute(cmd, arg, session, &stream);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Hangup Command %s(%s):\n%s\n", cmd, arg, switch_str_nil((char *) stream.data));
+ switch_safe_free(stream.data);
+ }
}
goto done;
case CS_INIT: /* Basic setup tasks */
More information about the Freeswitch-svn
mailing list