From 98063854c6181837b5af34f939356e03ab52f27f Mon Sep 17 00:00:00 2001 From: Brian West Date: Wed, 19 Sep 2012 15:54:38 -0500 Subject: [PATCH 01/11] This already has a new line in it --- .../src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_rcv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_rcv.c b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_rcv.c index 34b4150ac0..da9a3024eb 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_rcv.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_rcv.c @@ -1091,7 +1091,7 @@ void sngisdn_rcv_sng_log(uint8_t level, char *fmt,...) switch (level) { case SNG_LOGLEVEL_DEBUG: - ftdm_log(FTDM_LOG_DEBUG, "sng_isdn->%s\n", data); + ftdm_log(FTDM_LOG_DEBUG, "sng_isdn->%s", data); break; case SNG_LOGLEVEL_WARN: if ( strncmp(data, "Invalid Q.921/Q.931 frame", 25) ) { From 72f0cf476d55f08f49c85af192792f6b67624fdb Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Wed, 19 Sep 2012 16:34:22 -0500 Subject: [PATCH 02/11] add conference-create and conference-destroy action events --- .../applications/mod_conference/mod_conference.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/mod/applications/mod_conference/mod_conference.c b/src/mod/applications/mod_conference/mod_conference.c index 0b1adcab57..0bdf28822b 100644 --- a/src/mod/applications/mod_conference/mod_conference.c +++ b/src/mod/applications/mod_conference/mod_conference.c @@ -1910,7 +1910,7 @@ static void *SWITCH_THREAD_FUNC conference_thread_run(switch_thread_t *thread, v int32_t z = 0; int member_score_sum = 0; int divisor = 0; - + if (!(divisor = conference->rate / 8000)) { divisor = 1; } @@ -1932,6 +1932,13 @@ static void *SWITCH_THREAD_FUNC conference_thread_run(switch_thread_t *thread, v conference->is_recording = 0; conference->record_count = 0; + + + switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT); + conference_add_event_data(conference, event); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Action", "conference-create"); + switch_event_fire(&event); + while (globals.running && !switch_test_flag(conference, CFLAG_DESTRUCT)) { switch_size_t file_sample_len = samples; switch_size_t file_data_len = samples * 2; @@ -2448,6 +2455,11 @@ static void *SWITCH_THREAD_FUNC conference_thread_run(switch_thread_t *thread, v } } + + switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT); + conference_add_event_data(conference, event); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Action", "conference-destroy"); + switch_event_fire(&event); switch_core_timer_destroy(&timer); switch_mutex_lock(globals.hash_mutex); From fff6e50a9bd76676ea23a49e0102cda77bdabeca Mon Sep 17 00:00:00 2001 From: Moises Silva Date: Wed, 19 Sep 2012 20:02:30 -0400 Subject: [PATCH 03/11] freetdm: Fix E&M answer procedure for DAHDI --- libs/freetdm/mod_freetdm/mod_freetdm.c | 1 + libs/freetdm/src/ftmod/ftmod_zt/ftmod_zt.c | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/libs/freetdm/mod_freetdm/mod_freetdm.c b/libs/freetdm/mod_freetdm/mod_freetdm.c index 271f532a70..06dc587a4b 100755 --- a/libs/freetdm/mod_freetdm/mod_freetdm.c +++ b/libs/freetdm/mod_freetdm/mod_freetdm.c @@ -2285,6 +2285,7 @@ static FIO_SIGNAL_CB_FUNCTION(on_fxo_signal) } break; case FTDM_SIGEVENT_SIGSTATUS_CHANGED: + case FTDM_SIGEVENT_COLLECTED_DIGIT: /* Analog E&M */ break; default: { diff --git a/libs/freetdm/src/ftmod/ftmod_zt/ftmod_zt.c b/libs/freetdm/src/ftmod/ftmod_zt/ftmod_zt.c index 2569ea49fd..363dcee7c5 100644 --- a/libs/freetdm/src/ftmod/ftmod_zt/ftmod_zt.c +++ b/libs/freetdm/src/ftmod/ftmod_zt/ftmod_zt.c @@ -737,6 +737,7 @@ static FIO_COMMAND_FUNCTION(zt_command) ftdm_log_chan_msg(ftdmchan, FTDM_LOG_ERROR, "OFFHOOK Failed"); return FTDM_FAIL; } + ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "Channel is now offhook\n"); ftdm_set_flag_locked(ftdmchan, FTDM_CHANNEL_OFFHOOK); } break; @@ -747,6 +748,7 @@ static FIO_COMMAND_FUNCTION(zt_command) ftdm_log_chan_msg(ftdmchan, FTDM_LOG_ERROR, "ONHOOK Failed"); return FTDM_FAIL; } + ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "Channel is now onhook\n"); ftdm_clear_flag_locked(ftdmchan, FTDM_CHANNEL_OFFHOOK); } break; @@ -1084,7 +1086,10 @@ static __inline__ ftdm_status_t zt_channel_process_event(ftdm_channel_t *fchan, case ZT_EVENT_RINGOFFHOOK: { if (fchan->type == FTDM_CHAN_TYPE_FXS || (fchan->type == FTDM_CHAN_TYPE_EM && fchan->state != FTDM_CHANNEL_STATE_UP)) { - ftdm_set_flag_locked(fchan, FTDM_CHANNEL_OFFHOOK); + if (fchan->type != FTDM_CHAN_TYPE_EM) { + /* In E&M we're supposed to set this flag when the tx side goes offhook, not the rx */ + ftdm_set_flag_locked(fchan, FTDM_CHANNEL_OFFHOOK); + } *event_id = FTDM_OOB_OFFHOOK; } else if (fchan->type == FTDM_CHAN_TYPE_FXO) { *event_id = FTDM_OOB_RING_START; From 45bda533616d6b2ea866b1cbb3707851fe876627 Mon Sep 17 00:00:00 2001 From: Travis Cross Date: Thu, 20 Sep 2012 06:43:54 +0000 Subject: [PATCH 04/11] Add new modules to debian packaging --- debian/control-modules | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/debian/control-modules b/debian/control-modules index 5b76bd5d26..a41e858513 100644 --- a/debian/control-modules +++ b/debian/control-modules @@ -147,6 +147,11 @@ Description: Nibblebill This module allows for real-time accounting of a cash balance and using that information for call routing. +Module: applications/mod_oreka +Description: Media recording with Oreka + This module provides media recording with the Oreka cross-platfor + audio stream recording and retrieval system. + Module: applications/mod_osp Description: Open Settlement Protocol This module adds support for the Open Settlement Protocol (OSP). @@ -192,6 +197,11 @@ Module: applications/mod_snom Description: SNOM specific features This module implements features specific to SNOM phones. +Module: applications/mod_sonar +Description: Sonar ping timer + This module measures the latency on an audio link by sending audible + audio sonar pings. + Module: applications/mod_soundtouch Description: Soundtouch This module implements example media bugs. @@ -335,6 +345,10 @@ Module: codecs/mod_voipcodecs Description: mod_voipcodecs Adds mod_voipcodecs. +Module: codecs/mod_vp8 +Description: VP8 video codec + This module adds the VP8 video codec, also known as WebM. + ## mod/dialplans Module: dialplans/mod_dialplan_asterisk @@ -376,6 +390,10 @@ Description: mod_h323 Adds mod_h323. Build-Depends: libopenh323-dev, libpt-dev +Module: endpoints/mod_html5 +Description: HTML5 endpoint module + This module adds support for HTML5 technologies such as WebRTC. + Module: endpoints/mod_khomp Description: mod_khomp Adds mod_khomp. @@ -651,6 +669,10 @@ Description: mod_xml_ldap Adds mod_xml_ldap. Build-Depends: libsasl2-dev +Module: xml_int/mod_xml_radius +Description: mod_xml_radius + Adds mod_xml_radius + Module: xml_int/mod_xml_rpc Description: mod_xml_rpc Adds mod_xml_rpc. From 1dd2e0f6b0294019f0a62ce3b0e7c658c9e2de66 Mon Sep 17 00:00:00 2001 From: Travis Cross Date: Thu, 20 Sep 2012 06:48:07 +0000 Subject: [PATCH 05/11] Avoid new modules in debian except mod_vp8 --- debian/bootstrap.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/debian/bootstrap.sh b/debian/bootstrap.sh index a724948577..5ba909b851 100755 --- a/debian/bootstrap.sh +++ b/debian/bootstrap.sh @@ -12,9 +12,11 @@ avoid_mods=( applications/mod_limit applications/mod_mongo applications/mod_mp4 + applications/mod_oreka applications/mod_osp applications/mod_rad_auth applications/mod_skel + applications/mod_sonar applications/mod_soundtouch asr_tts/mod_cepstral asr_tts/mod_flite @@ -26,6 +28,7 @@ avoid_mods=( codecs/mod_voipcodecs endpoints/mod_gsmopen endpoints/mod_h323 + endpoints/mod_html5 endpoints/mod_khomp endpoints/mod_opal endpoints/mod_reference @@ -35,6 +38,7 @@ avoid_mods=( languages/mod_spidermonkey sdk/autotools xml_int/mod_xml_ldap + xml_int/mod_xml_radius ) avoid_mods_sid=( endpoints/mod_portaudio From eca14d46011a416db288a8e87d00dee47be70002 Mon Sep 17 00:00:00 2001 From: Travis Cross Date: Thu, 20 Sep 2012 07:03:30 +0000 Subject: [PATCH 06/11] Fix format string for actual type of apr_time_t This was causing the build to fail if mod_sonar was configured to build. --- src/mod/applications/mod_sonar/mod_sonar.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mod/applications/mod_sonar/mod_sonar.c b/src/mod/applications/mod_sonar/mod_sonar.c index 5cdcd35188..8f6e424eb3 100644 --- a/src/mod/applications/mod_sonar/mod_sonar.c +++ b/src/mod/applications/mod_sonar/mod_sonar.c @@ -61,7 +61,7 @@ switch_bool_t sonar_ping_callback(switch_core_session_t *session, const char *ap end = switch_time_now(); diff = end - start; start = 0; - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Sonar ping took %lu milliseconds\n", diff / 1000); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Sonar ping took %ld milliseconds\n", (long)diff / 1000); return SWITCH_TRUE; } From c6e75490552a500fb8dddc6889e14b6229489c0f Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Thu, 20 Sep 2012 09:48:47 -0500 Subject: [PATCH 07/11] FS-4634 --resolve --- src/switch_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/switch_core.c b/src/switch_core.c index 30f1ef3bae..2a9bec7dee 100644 --- a/src/switch_core.c +++ b/src/switch_core.c @@ -1692,7 +1692,7 @@ static void switch_load_core_config(const char *file) switch_core_session_ctl(SCSC_LOGLEVEL, &level); } #ifdef HAVE_SETRLIMIT - } else if (!strcasecmp(var, "dump-cores")) { + } else if (!strcasecmp(var, "dump-cores") && switch_true(val)) { struct rlimit rlp; memset(&rlp, 0, sizeof(rlp)); rlp.rlim_cur = RLIM_INFINITY; From 0dac49008655ea222318ab056ea5a82548bb6d73 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Thu, 20 Sep 2012 09:53:53 -0500 Subject: [PATCH 08/11] FS-4315 --resolve --- src/mod/applications/mod_spy/mod_spy.c | 113 ++++++++++++++++--------- 1 file changed, 71 insertions(+), 42 deletions(-) diff --git a/src/mod/applications/mod_spy/mod_spy.c b/src/mod/applications/mod_spy/mod_spy.c index 12c42ba15c..a5cb3c92c0 100644 --- a/src/mod/applications/mod_spy/mod_spy.c +++ b/src/mod/applications/mod_spy/mod_spy.c @@ -46,22 +46,39 @@ struct mod_spy_globals { uint32_t spy_count; } globals; +typedef struct spy { + const char *uuid; + struct spy *next; +} spy_t; + + static switch_status_t spy_on_hangup(switch_core_session_t *session) { switch_channel_t *channel = switch_core_session_get_channel(session); + const char *data = switch_channel_get_private(channel, "_userspy_"); + const char *uuid = switch_core_session_get_uuid(session); + spy_t *spy = NULL, *p = NULL, *prev = NULL; - char *data = switch_channel_get_private(channel, "_userspy_"); switch_thread_rwlock_wrlock(globals.spy_hash_lock); - if ((switch_core_hash_delete(globals.spy_hash, data) != SWITCH_STATUS_SUCCESS)) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "No such key in userspy: %s \n", data); - - } else { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Userspy deactivated on %s\n", data); - globals.spy_count--; + spy = switch_core_hash_find(globals.spy_hash, data); + for (p = spy; p; p = p->next) { + if (p->uuid == uuid) { + if (prev) { + prev->next = p->next; + } else { + spy = p->next; + } + globals.spy_count--; + break; + } + prev = p; } + switch_core_hash_insert(globals.spy_hash, data, spy); + switch_thread_rwlock_unlock(globals.spy_hash_lock); + return SWITCH_STATUS_SUCCESS; } @@ -115,12 +132,20 @@ SWITCH_STANDARD_API(dump_hash) switch_hash_index_t *hi; const void *key; void *val; + spy_t *spy; switch_thread_rwlock_rdlock(globals.spy_hash_lock); for (hi = switch_hash_first(NULL, globals.spy_hash); hi; hi = switch_hash_next(hi)) { switch_hash_this(hi, &key, NULL, &val); - stream->write_function(stream, "%s : %s\n", (char *) key, (const char *) val); + spy = (spy_t *) val; + + stream->write_function(stream, "%s :"); + while (spy) { + stream->write_function(stream, " %s", spy->uuid); + spy = spy->next; + } + stream->write_function(stream, "\n"); } stream->write_function(stream, "\n%d total spy\n", globals.spy_count); @@ -130,9 +155,10 @@ SWITCH_STANDARD_API(dump_hash) static switch_status_t process_event(switch_event_t *event) { + switch_status_t status = SWITCH_STATUS_SUCCESS; switch_core_session_t *session = NULL; - char *username[3] = { 0 }; - char *domain[3] = { 0 }; + char *username[3] = { NULL }; + char *domain[3] = { NULL }; char key[512]; char *uuid = NULL, *my_uuid = NULL; int i; @@ -147,8 +173,8 @@ static switch_status_t process_event(switch_event_t *event) username[0] = switch_event_get_header(event, "Caller-Username"); domain[0] = switch_event_get_header(event, "variable_domain_name"); - domain[1] = switch_event_get_header(event, "variable_dialed_domain"); username[1] = switch_event_get_header(event, "variable_dialed_user"); + domain[1] = switch_event_get_header(event, "variable_dialed_domain"); username[2] = switch_event_get_header(event, "variable_user_name"); domain[2] = switch_event_get_header(event, "variable_domain_name"); @@ -156,35 +182,39 @@ static switch_status_t process_event(switch_event_t *event) for (i = 0; i < 3; i++) { if (username[i] && domain[i]) { + spy_t *spy = NULL; switch_snprintf(key, sizeof(key), "%s@%s", username[i], domain[i]); - if ((uuid = switch_core_hash_find(globals.spy_hash, key))) { + if ((spy = switch_core_hash_find(globals.spy_hash, key))) { + while (spy) { + if ((session = switch_core_session_locate(spy->uuid))) { + switch_channel_t *channel = switch_core_session_get_channel(session); + + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "UserSpy retrieved uuid %s for key %s, activating eavesdrop\n", uuid, key); + my_uuid = switch_event_get_header(event, "Unique-ID"); + + switch_channel_set_variable(channel, "spy_uuid", my_uuid); + + switch_channel_set_state(channel, CS_EXCHANGE_MEDIA); + switch_channel_set_flag(channel, CF_BREAK); + + switch_core_session_rwunlock(session); + } + spy = spy->next; + } break; + } else { + /* not found */ + status = SWITCH_STATUS_FALSE; } } } - + + done: switch_thread_rwlock_unlock(globals.spy_hash_lock); + return status; - if (!uuid) { - return SWITCH_STATUS_FALSE; - } - - if ((session = switch_core_session_locate(uuid))) { - switch_channel_t *channel = switch_core_session_get_channel(session); - - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "UserSpy retrieved uuid %s for key %s, activating eavesdrop \n", uuid, key); - my_uuid = switch_event_get_header(event, "Unique-ID"); - - switch_channel_set_variable(channel, "spy_uuid", my_uuid); - - switch_channel_set_state(channel, CS_EXCHANGE_MEDIA); - switch_channel_set_flag(channel, CF_BREAK); - - switch_core_session_rwunlock(session); - } - return SWITCH_STATUS_SUCCESS; } @@ -233,20 +263,20 @@ SWITCH_STANDARD_APP(userspy_function) if (!zstr(data) && (params = switch_core_session_strdup(session, data))) { if ((argc = switch_separate_string(params, ' ', argv, (sizeof(argv) / sizeof(argv[0])))) >= 1) { - switch_channel_t *channel = switch_core_session_get_channel(session); char *uuid = switch_core_session_get_uuid(session); switch_status_t status; + spy_t *spy = NULL; + + spy = switch_core_session_alloc(session, sizeof(spy_t)); + switch_assert(spy != NULL); + spy->uuid = uuid; switch_thread_rwlock_wrlock(globals.spy_hash_lock); - if (switch_core_hash_find(globals.spy_hash, argv[0])) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Spy already exists for %s\n", argv[0]); - switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING); - switch_thread_rwlock_unlock(globals.spy_hash_lock); - return; - } - status = switch_core_hash_insert(globals.spy_hash, argv[0], (void *) uuid); + spy->next = (spy_t *) switch_core_hash_find(globals.spy_hash, argv[0]); + + status = switch_core_hash_insert(globals.spy_hash, argv[0], (void *) spy); if ((status != SWITCH_STATUS_SUCCESS)) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Can't insert to spy hash\n"); @@ -270,11 +300,10 @@ SWITCH_STANDARD_APP(userspy_function) } switch_channel_set_state(channel, CS_PARK); - return; } - return; + } else { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Usage: %s\n", USERSPY_SYNTAX); } - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Usage: %s\n", USERSPY_SYNTAX); } SWITCH_MODULE_LOAD_FUNCTION(mod_spy_load) From a39ba84f5e5cf1c318bd57a41bfc649c0a79776b Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Thu, 20 Sep 2012 09:55:47 -0500 Subject: [PATCH 09/11] FS-4458 --resolve --- .../mod_erlang_event/mod_erlang_event.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/mod/event_handlers/mod_erlang_event/mod_erlang_event.c b/src/mod/event_handlers/mod_erlang_event/mod_erlang_event.c index 0aeaece8dd..9b34bfa8fc 100644 --- a/src/mod/event_handlers/mod_erlang_event/mod_erlang_event.c +++ b/src/mod/event_handlers/mod_erlang_event/mod_erlang_event.c @@ -812,7 +812,6 @@ static void handle_exit(listener_t *listener, erlang_pid * pid) } - if (listener->log_process.type == ERLANG_PID && !ei_compare_pids(&listener->log_process.pid, pid)) { void *pop; @@ -1477,15 +1476,14 @@ SWITCH_STANDARD_APP(erlang_outbound_function) int argc = 0, argc2 = 0; char *argv[80] = { 0 }, *argv2[80] = { 0 }; char *mydata, *myarg; - char uuid[SWITCH_UUID_FORMATTED_LENGTH + 1]; session_elem_t *session_element = NULL; + switch_channel_t *channel = switch_core_session_get_channel(session); /* process app arguments */ if (data && (mydata = switch_core_session_strdup(session, data))) { argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0]))); } /* XXX else? */ - memcpy(uuid, switch_core_session_get_uuid(session), SWITCH_UUID_FORMATTED_LENGTH); if (argc < 2) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Parse Error - need registered name and node!\n"); @@ -1518,6 +1516,13 @@ SWITCH_STANDARD_APP(erlang_outbound_function) switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "enter erlang_outbound_function %s %s\n", argv[0], node); + + if (switch_channel_test_flag(channel, CF_CONTROLLED)) { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Channel is already under control\n"); + return; + } + + /* first work out if there is a listener already talking to the node we want to talk to */ listener = find_listener(node); /* if there is no listener, then create one */ @@ -1551,7 +1556,7 @@ SWITCH_STANDARD_APP(erlang_outbound_function) switch_thread_rwlock_unlock(globals.listener_rwlock); } - switch_log_printf(SWITCH_CHANNEL_UUID_LOG(uuid), SWITCH_LOG_DEBUG, "exit erlang_outbound_function\n"); + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "exit erlang_outbound_function\n"); } From 07ed03c45845901c997c3d999d5603c85e44cc9d Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Thu, 20 Sep 2012 09:57:58 -0500 Subject: [PATCH 10/11] FS-4625 --resolve --- src/mod/applications/mod_dptools/mod_dptools.c | 17 +++++++++++++++++ src/switch_channel.c | 2 +- src/switch_ivr_async.c | 11 +---------- 3 files changed, 19 insertions(+), 11 deletions(-) diff --git a/src/mod/applications/mod_dptools/mod_dptools.c b/src/mod/applications/mod_dptools/mod_dptools.c index b481ca9f05..4fec5c3269 100755 --- a/src/mod/applications/mod_dptools/mod_dptools.c +++ b/src/mod/applications/mod_dptools/mod_dptools.c @@ -567,6 +567,22 @@ SWITCH_STANDARD_APP(mkdir_function) switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s MKDIR: %s\n", switch_channel_get_name(switch_core_session_get_channel(session)), data); } +#define RENAME_SYNTAX " " +SWITCH_STANDARD_APP(rename_function) +{ + char *argv[2] = { 0 }; + char *lbuf = NULL; + + if (!zstr(data) && (lbuf = switch_core_session_strdup(session, data)) + && switch_split(lbuf, ' ', argv) == 2) { + switch_file_rename(argv[0], argv[1], switch_core_session_get_pool(session)); + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s RENAME: %s %s\n", + switch_channel_get_name(switch_core_session_get_channel(session)), argv[0], argv[1]); + + } else { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Usage: %s\n", RENAME_SYNTAX); + } +} #define SOFT_HOLD_SYNTAX " [] []" SWITCH_STANDARD_APP(soft_hold_function) @@ -5103,6 +5119,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_dptools_load) SWITCH_ADD_APP(app_interface, "enable_heartbeat", "Enable Media Heartbeat", "Enable Media Heartbeat", heartbeat_function, HEARTBEAT_SYNTAX, SAF_SUPPORT_NOMEDIA); SWITCH_ADD_APP(app_interface, "mkdir", "Create a directory", "Create a directory", mkdir_function, MKDIR_SYNTAX, SAF_SUPPORT_NOMEDIA); + SWITCH_ADD_APP(app_interface, "rename", "Rename file", "Rename file", rename_function, RENAME_SYNTAX, SAF_SUPPORT_NOMEDIA | SAF_ZOMBIE_EXEC); SWITCH_ADD_APP(app_interface, "soft_hold", "Put a bridged channel on hold", "Put a bridged channel on hold", soft_hold_function, SOFT_HOLD_SYNTAX, SAF_NONE); SWITCH_ADD_APP(app_interface, "bind_meta_app", "Bind a key to an application", "Bind a key to an application", dtmf_bind_function, BIND_SYNTAX, diff --git a/src/switch_channel.c b/src/switch_channel.c index f823b22e49..5606d81fe0 100644 --- a/src/switch_channel.c +++ b/src/switch_channel.c @@ -3274,7 +3274,7 @@ static void do_execute_on(switch_channel_t *channel, const char *variable) app = switch_core_session_strdup(channel->session, variable); for(p = app; p && *p; p++) { - if (*p == ' ') { + if (*p == ' ' || (*p == ':' && (*(p+1) != ':'))) { *p++ = '\0'; arg = p; break; diff --git a/src/switch_ivr_async.c b/src/switch_ivr_async.c index 03f9839f78..314b41a5ed 100644 --- a/src/switch_ivr_async.c +++ b/src/switch_ivr_async.c @@ -1083,16 +1083,7 @@ static switch_bool_t record_callback(switch_media_bug_t *bug, void *user_data, s switch_event_fire(&event); } - if ((var = switch_channel_get_variable(channel, "record_post_process_exec_app"))) { - char *app = switch_core_session_strdup(session, var); - char *data; - - if ((data = strchr(app, ':'))) { - *data++ = '\0'; - } - - switch_core_session_execute_application(session, app, data); - } + switch_channel_execute_on(channel, "record_post_process_exec_app"); if ((var = switch_channel_get_variable(channel, "record_post_process_exec_api"))) { char *cmd = switch_core_session_strdup(session, var); From dfa83799d0921b0b2486267c9634d17130ad337e Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Thu, 20 Sep 2012 09:59:50 -0500 Subject: [PATCH 11/11] FS-4624 --resolve --- .../applications/mod_dptools/mod_dptools.c | 58 ++++++++++++++----- src/switch_ivr_async.c | 2 +- 2 files changed, 45 insertions(+), 15 deletions(-) diff --git a/src/mod/applications/mod_dptools/mod_dptools.c b/src/mod/applications/mod_dptools/mod_dptools.c index 4fec5c3269..fae029bc61 100755 --- a/src/mod/applications/mod_dptools/mod_dptools.c +++ b/src/mod/applications/mod_dptools/mod_dptools.c @@ -4419,7 +4419,7 @@ struct file_string_context { typedef struct file_string_context file_string_context_t; -static int next_file(switch_file_handle_t *handle) +static switch_status_t next_file(switch_file_handle_t *handle) { file_string_context_t *context = handle->private_info; char *file; @@ -4434,7 +4434,7 @@ static int next_file(switch_file_handle_t *handle) } if (context->index >= context->argc) { - return 0; + return SWITCH_STATUS_FALSE; } @@ -4450,8 +4450,23 @@ static int next_file(switch_file_handle_t *handle) file = switch_core_sprintf(handle->memory_pool, "%s%s%s", prefix, SWITCH_PATH_SEPARATOR, context->argv[context->index]); } - if (switch_core_file_open(&context->fh, - file, handle->channels, handle->samplerate, SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT, NULL) != SWITCH_STATUS_SUCCESS) { + if (switch_test_flag(handle, SWITCH_FILE_FLAG_WRITE)) { + char *path = switch_core_strdup(handle->memory_pool, file); + char *p; + + if ((p = strrchr(path, *SWITCH_PATH_SEPARATOR))) { + *p = '\0'; + if (switch_dir_make_recursive(path, SWITCH_DEFAULT_DIR_PERMS, handle->memory_pool) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error creating %s\n", path); + return SWITCH_STATUS_FALSE; + } + + } else { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error finding the folder path section in '%s'\n", path); + } + + } + if (switch_core_file_open(&context->fh, file, handle->channels, handle->samplerate, handle->flags, NULL) != SWITCH_STATUS_SUCCESS) { goto top; } @@ -4477,7 +4492,7 @@ static int next_file(switch_file_handle_t *handle) } } - return 1; + return SWITCH_STATUS_SUCCESS; } @@ -4503,11 +4518,6 @@ static switch_status_t file_string_file_open(switch_file_handle_t *handle, const file_string_context_t *context; char *file_dup; - if (switch_test_flag(handle, SWITCH_FILE_FLAG_WRITE)) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "This format does not support writing!\n"); - return SWITCH_STATUS_FALSE; - } - context = switch_core_alloc(handle->memory_pool, sizeof(*context)); file_dup = switch_core_strdup(handle->memory_pool, path); @@ -4516,7 +4526,7 @@ static switch_status_t file_string_file_open(switch_file_handle_t *handle, const handle->private_info = context; - return next_file(handle) ? SWITCH_STATUS_SUCCESS : SWITCH_STATUS_FALSE; + return next_file(handle); } static switch_status_t file_string_file_close(switch_file_handle_t *handle) @@ -4549,16 +4559,35 @@ static switch_status_t file_string_file_read(switch_file_handle_t *handle, void } if (status != SWITCH_STATUS_SUCCESS) { - if (!next_file(handle)) { - return SWITCH_STATUS_FALSE; + if ((status = next_file(handle)) != SWITCH_STATUS_SUCCESS) { + return status; } *len = llen; status = switch_core_file_read(&context->fh, data, len); } - return SWITCH_STATUS_SUCCESS; + return status; } +static switch_status_t file_string_file_write(switch_file_handle_t *handle, void *data, size_t *len) +{ + file_string_context_t *context = handle->private_info; + switch_status_t status; + size_t llen = *len; + + status = switch_core_file_write(&context->fh, data, len); + + if (status != SWITCH_STATUS_SUCCESS) { + if ((status = next_file(handle)) != SWITCH_STATUS_SUCCESS) { + return status; + } + *len = llen; + status = switch_core_file_write(&context->fh, data, len); + } + return status; +} + + /* Registration */ static char *file_string_supported_formats[SWITCH_MAX_CODECS] = { 0 }; @@ -4979,6 +5008,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_dptools_load) file_interface->file_open = file_string_file_open; file_interface->file_close = file_string_file_close; file_interface->file_read = file_string_file_read; + file_interface->file_write = file_string_file_write; file_interface->file_seek = file_string_file_seek; diff --git a/src/switch_ivr_async.c b/src/switch_ivr_async.c index 314b41a5ed..a9ebc4b352 100644 --- a/src/switch_ivr_async.c +++ b/src/switch_ivr_async.c @@ -1825,7 +1825,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_record_session(switch_core_session_t file_path = switch_core_session_strdup(session, file); } - if (file_path) { + if (file_path && !strstr(file_path, SWITCH_URL_SEPARATOR)) { char *p; char *path = switch_core_session_strdup(session, file_path);