fix some language issues and move media bug removal to hangup state
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@12225 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
54ff389b09
commit
e66b78047a
|
@ -214,7 +214,7 @@ switch_status_t Session::run_dtmf_callback(void *input, switch_input_type_t ityp
|
|||
HV *hash;
|
||||
SV *this_sv;
|
||||
char *code;
|
||||
|
||||
|
||||
if (!(hash = get_hv("__dtmf", TRUE))) {
|
||||
abort();
|
||||
}
|
||||
|
@ -228,8 +228,8 @@ switch_status_t Session::run_dtmf_callback(void *input, switch_input_type_t ityp
|
|||
this_sv = newSV(strlen(str) + 1);
|
||||
sv_setpv(this_sv, str);
|
||||
hv_store(hash, "duration", 8, this_sv, 0);
|
||||
|
||||
code = switch_mprintf("$__RV = %s($%s, 'dtmf', \\%%__dtmf, %s);", cb_function, suuid, switch_str_nil(cb_arg));
|
||||
|
||||
code = switch_mprintf("eval { $__RV = &%s($%s, 'dtmf', \\%%__dtmf, %s);};", cb_function, suuid, switch_str_nil(cb_arg));
|
||||
Perl_eval_pv(my_perl, code, FALSE);
|
||||
free(code);
|
||||
|
||||
|
@ -241,11 +241,25 @@ switch_status_t Session::run_dtmf_callback(void *input, switch_input_type_t ityp
|
|||
switch_event_t *event = (switch_event_t *) input;
|
||||
int arg_count = 2;
|
||||
char *code;
|
||||
switch_uuid_t uuid;
|
||||
char uuid_str[SWITCH_UUID_FORMATTED_LENGTH + 1];
|
||||
char var_name[SWITCH_UUID_FORMATTED_LENGTH + 25];
|
||||
char *p;
|
||||
|
||||
mod_perl_conjure_event(my_perl, event, "__Input_Event__");
|
||||
switch_uuid_get(&uuid);
|
||||
switch_uuid_format(uuid_str, &uuid);
|
||||
|
||||
code = switch_mprintf("$__RV = %s($%s, 'event', $__Input_Event__, %s);", cb_function, suuid, switch_str_nil(cb_arg));
|
||||
Perl_eval_pv(my_perl, code, TRUE);
|
||||
switch_snprintf(var_name, sizeof(var_name), "main::__event_%s", uuid_str);
|
||||
for(p = var_name; p && *p; p++) {
|
||||
if (*p == '-') {
|
||||
*p = '_';
|
||||
}
|
||||
}
|
||||
|
||||
mod_perl_conjure_event(my_perl, event, var_name);
|
||||
code = switch_mprintf("eval {$__RV = &%s($%s, 'event', $%s, '%s');};$%s = undef;",
|
||||
cb_function, suuid, var_name, switch_str_nil(cb_arg), var_name);
|
||||
Perl_eval_pv(my_perl, code, FALSE);
|
||||
free(code);
|
||||
|
||||
return process_callback_result(SvPV(get_sv("__RV", TRUE), n_a));
|
||||
|
|
|
@ -140,7 +140,7 @@ static int perl_parse_and_execute(PerlInterpreter * my_perl, char *input_code, c
|
|||
return error;
|
||||
}
|
||||
|
||||
#define HACK_CLEAN_CODE "foreach my $kl(keys %main::) {undef($$kl) if (defined($$kl) && ($kl =~ /^\\w+[\\w\\d_]+$/))}"
|
||||
#define HACK_CLEAN_CODE "eval{foreach my $kl(keys %main::) {eval{undef($$kl);} if (defined($$kl) && ($kl =~ /^\\w+[\\w\\d_]+$/))}}"
|
||||
|
||||
static void destroy_perl(PerlInterpreter ** to_destroy)
|
||||
{
|
||||
|
@ -434,18 +434,16 @@ static void message_query_handler(switch_event_t *event)
|
|||
char *account = switch_event_get_header(event, "message-account");
|
||||
|
||||
if (account) {
|
||||
char *path, *cmd;
|
||||
|
||||
path = switch_mprintf("%s%smwi.pl", SWITCH_GLOBAL_dirs.script_dir, SWITCH_PATH_SEPARATOR);
|
||||
switch_assert(path != NULL);
|
||||
char path[512], *cmd;
|
||||
|
||||
switch_snprintf(path, sizeof(path), "%s%smwi.pl", SWITCH_GLOBAL_dirs.script_dir, SWITCH_PATH_SEPARATOR);
|
||||
|
||||
if (switch_file_exists(path, NULL) == SWITCH_STATUS_SUCCESS) {
|
||||
cmd = switch_mprintf("%s %s", path, account);
|
||||
switch_assert(cmd != NULL);
|
||||
perl_thread(cmd);
|
||||
switch_safe_free(cmd);
|
||||
}
|
||||
switch_safe_free(path);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1100,11 +1100,26 @@ static switch_status_t js_common_callback(switch_core_session_t *session, void *
|
|||
jsval ret, nval, *rval = &nval;
|
||||
JSContext *cx = cb_state->cx;
|
||||
JSObject *obj = cb_state->obj;
|
||||
switch_uuid_t uuid;
|
||||
char uuid_str[SWITCH_UUID_FORMATTED_LENGTH + 1];
|
||||
char var_name[SWITCH_UUID_FORMATTED_LENGTH + 25];
|
||||
char *p;
|
||||
|
||||
METHOD_SANITY_CHECK();
|
||||
|
||||
jss->stack_depth++;
|
||||
|
||||
|
||||
switch_uuid_get(&uuid);
|
||||
switch_uuid_format(uuid_str, &uuid);
|
||||
|
||||
switch_snprintf(var_name, sizeof(var_name), "__event_%s", uuid_str);
|
||||
for(p = var_name; p && *p; p++) {
|
||||
if (*p == '-') {
|
||||
*p = '_';
|
||||
}
|
||||
}
|
||||
|
||||
if (cb_state->jss_a && cb_state->jss_a->session && cb_state->jss_a->session == session) {
|
||||
argv[argc++] = OBJECT_TO_JSVAL(cb_state->session_obj_a);
|
||||
} else if (cb_state->jss_b && cb_state->jss_b->session && cb_state->jss_b->session == session) {
|
||||
|
@ -1116,7 +1131,7 @@ static switch_status_t js_common_callback(switch_core_session_t *session, void *
|
|||
switch (itype) {
|
||||
case SWITCH_INPUT_TYPE_EVENT:
|
||||
if ((event = (switch_event_t *) input)) {
|
||||
if ((Event = new_js_event(event, "_XX_EVENT_XX_", cb_state->cx, cb_state->obj))) {
|
||||
if ((Event = new_js_event(event, var_name, cb_state->cx, cb_state->obj))) {
|
||||
argv[argc++] = STRING_TO_JSVAL(JS_NewStringCopyZ(cb_state->cx, "event"));
|
||||
argv[argc++] = OBJECT_TO_JSVAL(Event);
|
||||
}
|
||||
|
@ -1131,7 +1146,7 @@ static switch_status_t js_common_callback(switch_core_session_t *session, void *
|
|||
switch_dtmf_t *dtmf = (switch_dtmf_t *) input;
|
||||
|
||||
if (dtmf) {
|
||||
if ((Event = new_js_dtmf(dtmf, "_XX_DTMF_XX_", cb_state->cx, cb_state->obj))) {
|
||||
if ((Event = new_js_dtmf(dtmf, var_name, cb_state->cx, cb_state->obj))) {
|
||||
argv[argc++] = STRING_TO_JSVAL(JS_NewStringCopyZ(cb_state->cx, "dtmf"));
|
||||
argv[argc++] = OBJECT_TO_JSVAL(Event);
|
||||
} else {
|
||||
|
@ -1175,11 +1190,12 @@ static switch_status_t js_stream_input_callback(switch_core_session_t *session,
|
|||
switch_file_handle_t *fh = cb_state->extra;
|
||||
struct js_session *jss = cb_state->session_state;
|
||||
|
||||
switch_dtmf_t *wtfdtmf = (switch_dtmf_t *) input;
|
||||
|
||||
if ((status = js_common_callback(session, input, itype, buf, buflen)) != SWITCH_STATUS_SUCCESS) {
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
if ((ret = JS_GetStringBytes(JS_ValueToString(cb_state->cx, cb_state->ret)))) {
|
||||
if (!strncasecmp(ret, "speed", 5)) {
|
||||
char *p;
|
||||
|
|
|
@ -397,6 +397,7 @@ SWITCH_DECLARE(switch_size_t) switch_channel_dequeue_dtmf_string(switch_channel_
|
|||
SWITCH_DECLARE(void) switch_channel_flush_dtmf(switch_channel_t *channel)
|
||||
{
|
||||
void *pop;
|
||||
|
||||
switch_mutex_lock(channel->dtmf_mutex);
|
||||
while (switch_queue_trypop(channel->dtmf_queue, &pop) == SWITCH_STATUS_SUCCESS) {
|
||||
switch_safe_free(pop);
|
||||
|
@ -1562,6 +1563,7 @@ SWITCH_DECLARE(switch_channel_state_t) switch_channel_perform_hangup(switch_chan
|
|||
switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_NOTICE, "Hangup %s [%s] [%s]\n",
|
||||
channel->name, state_names[last_state], switch_channel_cause2str(channel->hangup_cause));
|
||||
|
||||
switch_core_media_bug_remove_all(channel->session);
|
||||
switch_channel_set_variable(channel, "hangup_cause", switch_channel_cause2str(channel->hangup_cause));
|
||||
switch_channel_presence(channel, "unavailable", switch_channel_cause2str(channel->hangup_cause), NULL);
|
||||
|
||||
|
|
|
@ -1059,6 +1059,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_play_file(switch_core_session_t *sess
|
|||
switch_channel_dequeue_dtmf(channel, &dtmf);
|
||||
if (args->input_callback) {
|
||||
status = args->input_callback(session, (void *) &dtmf, SWITCH_INPUT_TYPE_DTMF, args->buf, args->buflen);
|
||||
printf("CORE %c %d\n", dtmf.digit, status);
|
||||
|
||||
} else {
|
||||
*((char *) args->buf) = dtmf.digit;
|
||||
status = SWITCH_STATUS_BREAK;
|
||||
|
|
Loading…
Reference in New Issue