diff --git a/src/include/switch_ivr.h b/src/include/switch_ivr.h index 34d6625541..09577152b4 100644 --- a/src/include/switch_ivr.h +++ b/src/include/switch_ivr.h @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2019, Anthony Minessale II + * Copyright (C) 2005-2021, Anthony Minessale II * * Version: MPL 1.1 * @@ -525,7 +525,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_enterprise_originate(switch_core_sess const char *cid_num_override, switch_caller_profile_t *caller_profile_override, switch_event_t *ovars, switch_originate_flag_t flags, - switch_call_cause_t *cancel_cause); + switch_call_cause_t *cancel_cause, + switch_dial_handle_list_t *hl); SWITCH_DECLARE(void) switch_ivr_bridge_display(switch_core_session_t *session, switch_core_session_t *peer_session); @@ -1057,6 +1058,16 @@ SWITCH_DECLARE(switch_event_t *) switch_dial_handle_get_global_vars(switch_dial_ SWITCH_DECLARE(switch_event_t *) switch_dial_leg_get_vars(switch_dial_leg_t *leg); SWITCH_DECLARE(const char *) switch_dial_leg_get_var(switch_dial_leg_t *leg, const char *key); SWITCH_DECLARE(int) switch_dial_handle_get_total(switch_dial_handle_t *handle); +SWITCH_DECLARE(switch_status_t) switch_dial_handle_list_serialize_json_obj(switch_dial_handle_list_t *hl, cJSON **json); +SWITCH_DECLARE(switch_status_t) switch_dial_handle_list_serialize_json(switch_dial_handle_list_t *hl, char **str); +SWITCH_DECLARE(switch_status_t) switch_dial_handle_list_create_json_obj(switch_dial_handle_list_t **handle, cJSON *json); +SWITCH_DECLARE(switch_status_t) switch_dial_handle_list_create_json(switch_dial_handle_list_t **handle, const char *handle_string); +SWITCH_DECLARE(switch_status_t) switch_dial_handle_list_create(switch_dial_handle_list_t **hl); +SWITCH_DECLARE(switch_status_t) switch_dial_handle_list_create_handle(switch_dial_handle_list_t *hl, switch_dial_handle_t **handle); +SWITCH_DECLARE(void) switch_dial_handle_list_destroy(switch_dial_handle_list_t **hl); +SWITCH_DECLARE(void) switch_dial_handle_list_add_global_var(switch_dial_handle_list_t *hl, const char *var, const char *val); +SWITCH_DECLARE(void) switch_dial_handle_list_add_global_var_printf(switch_dial_handle_list_t *hl, const char *var, const char *fmt, ...); +SWITCH_DECLARE(switch_status_t) switch_ivr_enterprise_orig_and_bridge(switch_core_session_t *session, const char *data, switch_dial_handle_list_t *hl, switch_call_cause_t *cause); SWITCH_DECLARE(switch_status_t) switch_ivr_orig_and_bridge(switch_core_session_t *session, const char *data, switch_dial_handle_t *dh, switch_call_cause_t *cause); SWITCH_DECLARE(switch_status_t) switch_ivr_play_and_collect_input(switch_core_session_t *session, diff --git a/src/include/switch_types.h b/src/include/switch_types.h index 79ef9caa26..58f708729d 100644 --- a/src/include/switch_types.h +++ b/src/include/switch_types.h @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2015, Anthony Minessale II + * Copyright (C) 2005-2021, Anthony Minessale II * * Version: MPL 1.1 * @@ -2868,6 +2868,8 @@ typedef struct switch_dial_leg_s switch_dial_leg_t; struct switch_dial_leg_list_s; typedef struct switch_dial_leg_list_s switch_dial_leg_list_t; +struct switch_dial_handle_list_s; +typedef struct switch_dial_handle_list_s switch_dial_handle_list_t; SWITCH_END_EXTERN_C #endif diff --git a/src/mod/languages/mod_java/src/org/freeswitch/swig/Event.java b/src/mod/languages/mod_java/src/org/freeswitch/swig/Event.java index fd2c933b20..5c3961dc8c 100644 --- a/src/mod/languages/mod_java/src/org/freeswitch/swig/Event.java +++ b/src/mod/languages/mod_java/src/org/freeswitch/swig/Event.java @@ -112,4 +112,8 @@ public class Event { return freeswitchJNI.Event_fire(swigCPtr, this); } + public boolean merge(Event to_merge) { + return freeswitchJNI.Event_merge(swigCPtr, this, Event.getCPtr(to_merge), to_merge); + } + } diff --git a/src/mod/languages/mod_java/src/org/freeswitch/swig/freeswitchJNI.java b/src/mod/languages/mod_java/src/org/freeswitch/swig/freeswitchJNI.java index cceea3402a..37786aff1a 100644 --- a/src/mod/languages/mod_java/src/org/freeswitch/swig/freeswitchJNI.java +++ b/src/mod/languages/mod_java/src/org/freeswitch/swig/freeswitchJNI.java @@ -71,6 +71,7 @@ public class freeswitchJNI { public final static native boolean Event_addHeader(long jarg1, Event jarg1_, String jarg2, String jarg3); public final static native boolean Event_delHeader(long jarg1, Event jarg1_, String jarg2); public final static native boolean Event_fire(long jarg1, Event jarg1_); + public final static native boolean Event_merge(long jarg1, Event jarg1_, long jarg2, Event jarg2_); public final static native void EventConsumer_events_set(long jarg1, EventConsumer jarg1_, long jarg2); public final static native long EventConsumer_events_get(long jarg1, EventConsumer jarg1_); public final static native void EventConsumer_e_event_id_set(long jarg1, EventConsumer jarg1_, long jarg2); diff --git a/src/mod/languages/mod_java/switch_swig_wrap.cpp b/src/mod/languages/mod_java/switch_swig_wrap.cpp index f1b004dece..efd0211940 100644 --- a/src/mod/languages/mod_java/switch_swig_wrap.cpp +++ b/src/mod/languages/mod_java/switch_swig_wrap.cpp @@ -1450,6 +1450,24 @@ SWIGEXPORT jboolean JNICALL Java_org_freeswitch_swig_freeswitchJNI_Event_1fire(J } +SWIGEXPORT jboolean JNICALL Java_org_freeswitch_swig_freeswitchJNI_Event_1merge(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jlong jarg2, jobject jarg2_) { + jboolean jresult = 0 ; + Event *arg1 = (Event *) 0 ; + Event *arg2 = (Event *) 0 ; + bool result; + + (void)jenv; + (void)jcls; + (void)jarg1_; + (void)jarg2_; + arg1 = *(Event **)&jarg1; + arg2 = *(Event **)&jarg2; + result = (bool)(arg1)->merge(arg2); + jresult = (jboolean)result; + return jresult; +} + + SWIGEXPORT void JNICALL Java_org_freeswitch_swig_freeswitchJNI_EventConsumer_1events_1set(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jlong jarg2) { EventConsumer *arg1 = (EventConsumer *) 0 ; switch_queue_t *arg2 = (switch_queue_t *) 0 ; diff --git a/src/mod/languages/mod_lua/mod_lua_wrap.cpp b/src/mod/languages/mod_lua/mod_lua_wrap.cpp index a54f1faf68..7d91ba33ba 100644 --- a/src/mod/languages/mod_lua/mod_lua_wrap.cpp +++ b/src/mod/languages/mod_lua/mod_lua_wrap.cpp @@ -4961,6 +4961,37 @@ fail: } +static int _wrap_Event_merge(lua_State* L) { + int SWIG_arg = 0; + Event *arg1 = (Event *) 0 ; + Event *arg2 = (Event *) 0 ; + bool result; + + SWIG_check_num_args("Event::merge",2,2) + if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("Event::merge",1,"Event *"); + if(!SWIG_isptrtype(L,2)) SWIG_fail_arg("Event::merge",2,"Event *"); + + if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_Event,0))){ + SWIG_fail_ptr("Event_merge",1,SWIGTYPE_p_Event); + } + + + if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&arg2,SWIGTYPE_p_Event,0))){ + SWIG_fail_ptr("Event_merge",2,SWIGTYPE_p_Event); + } + + result = (bool)(arg1)->merge(arg2); + lua_pushboolean(L,(int)(result!=0)); SWIG_arg++; + return SWIG_arg; + + if(0) SWIG_fail; + +fail: + lua_error(L); + return SWIG_arg; +} + + static void swig_delete_Event(void *obj) { Event *arg1 = (Event *) obj; delete arg1; @@ -4991,6 +5022,7 @@ static swig_lua_method swig_Event_methods[]= { { "addHeader", _wrap_Event_addHeader}, { "delHeader", _wrap_Event_delHeader}, { "fire", _wrap_Event_fire}, + { "merge", _wrap_Event_merge}, {0,0} }; static swig_lua_method swig_Event_meta[] = { diff --git a/src/mod/languages/mod_managed/freeswitch_wrap.cxx b/src/mod/languages/mod_managed/freeswitch_wrap.cxx index 7ecadca826..378be590e6 100644 --- a/src/mod/languages/mod_managed/freeswitch_wrap.cxx +++ b/src/mod/languages/mod_managed/freeswitch_wrap.cxx @@ -14551,6 +14551,22 @@ SWIGEXPORT void SWIGSTDCALL CSharp_FreeSWITCHfNative_switch_core_session_reset__ } +SWIGEXPORT int SWIGSTDCALL CSharp_FreeSWITCHfNative_switch_core_session_try_reset___(void * jarg1, int jarg2, int jarg3) { + int jresult ; + switch_core_session_t *arg1 = (switch_core_session_t *) 0 ; + switch_bool_t arg2 ; + switch_bool_t arg3 ; + switch_status_t result; + + arg1 = (switch_core_session_t *)jarg1; + arg2 = (switch_bool_t)jarg2; + arg3 = (switch_bool_t)jarg3; + result = (switch_status_t)switch_core_session_try_reset(arg1,arg2,arg3); + jresult = (int)result; + return jresult; +} + + SWIGEXPORT int SWIGSTDCALL CSharp_FreeSWITCHfNative_switch_core_session_write_frame___(void * jarg1, void * jarg2, unsigned long jarg3, int jarg4) { int jresult ; switch_core_session_t *arg1 = (switch_core_session_t *) 0 ; @@ -15736,6 +15752,22 @@ SWIGEXPORT int SWIGSTDCALL CSharp_FreeSWITCHfNative_switch_core_file_pre_close__ } +SWIGEXPORT int SWIGSTDCALL CSharp_FreeSWITCHfNative_switch_core_file_handle_dup___(void * jarg1, void * jarg2, void * jarg3) { + int jresult ; + switch_file_handle_t *arg1 = (switch_file_handle_t *) 0 ; + switch_file_handle_t **arg2 = (switch_file_handle_t **) 0 ; + switch_memory_pool_t *arg3 = (switch_memory_pool_t *) 0 ; + switch_status_t result; + + arg1 = (switch_file_handle_t *)jarg1; + arg2 = (switch_file_handle_t **)jarg2; + arg3 = (switch_memory_pool_t *)jarg3; + result = (switch_status_t)switch_core_file_handle_dup(arg1,arg2,arg3); + jresult = (int)result; + return jresult; +} + + SWIGEXPORT int SWIGSTDCALL CSharp_FreeSWITCHfNative_switch_core_file_close___(void * jarg1) { int jresult ; switch_file_handle_t *arg1 = (switch_file_handle_t *) 0 ; @@ -18554,6 +18586,18 @@ SWIGEXPORT int SWIGSTDCALL CSharp_FreeSWITCHfNative_switch_core_gen_certs___(cha } +SWIGEXPORT int SWIGSTDCALL CSharp_FreeSWITCHfNative_switch_core_check_dtls_pem___(char * jarg1) { + int jresult ; + char *arg1 = (char *) 0 ; + switch_bool_t result; + + arg1 = (char *)jarg1; + result = (switch_bool_t)switch_core_check_dtls_pem((char const *)arg1); + jresult = (int)result; + return jresult; +} + + SWIGEXPORT int SWIGSTDCALL CSharp_FreeSWITCHfNative_switch_core_cert_gen_fingerprint___(char * jarg1, void * jarg2) { int jresult ; char *arg1 = (char *) 0 ; @@ -41895,7 +41939,7 @@ SWIGEXPORT int SWIGSTDCALL CSharp_FreeSWITCHfNative_switch_ivr_originate___(void } -SWIGEXPORT int SWIGSTDCALL CSharp_FreeSWITCHfNative_switch_ivr_enterprise_originate___(void * jarg1, void * jarg2, void * jarg3, char * jarg4, unsigned long jarg5, void * jarg6, char * jarg7, char * jarg8, void * jarg9, void * jarg10, unsigned long jarg11, void * jarg12) { +SWIGEXPORT int SWIGSTDCALL CSharp_FreeSWITCHfNative_switch_ivr_enterprise_originate___(void * jarg1, void * jarg2, void * jarg3, char * jarg4, unsigned long jarg5, void * jarg6, char * jarg7, char * jarg8, void * jarg9, void * jarg10, unsigned long jarg11, void * jarg12, void * jarg13) { int jresult ; switch_core_session_t *arg1 = (switch_core_session_t *) 0 ; switch_core_session_t **arg2 = (switch_core_session_t **) 0 ; @@ -41909,6 +41953,7 @@ SWIGEXPORT int SWIGSTDCALL CSharp_FreeSWITCHfNative_switch_ivr_enterprise_origin switch_event_t *arg10 = (switch_event_t *) 0 ; switch_originate_flag_t arg11 ; switch_call_cause_t *arg12 = (switch_call_cause_t *) 0 ; + switch_dial_handle_list_t *arg13 = (switch_dial_handle_list_t *) 0 ; switch_status_t result; arg1 = (switch_core_session_t *)jarg1; @@ -41923,7 +41968,8 @@ SWIGEXPORT int SWIGSTDCALL CSharp_FreeSWITCHfNative_switch_ivr_enterprise_origin arg10 = (switch_event_t *)jarg10; arg11 = (switch_originate_flag_t)jarg11; arg12 = (switch_call_cause_t *)jarg12; - result = (switch_status_t)switch_ivr_enterprise_originate(arg1,arg2,arg3,(char const *)arg4,arg5,(switch_state_handler_table const *)arg6,(char const *)arg7,(char const *)arg8,arg9,arg10,arg11,arg12); + arg13 = (switch_dial_handle_list_t *)jarg13; + result = (switch_status_t)switch_ivr_enterprise_originate(arg1,arg2,arg3,(char const *)arg4,arg5,(switch_state_handler_table const *)arg6,(char const *)arg7,(char const *)arg8,arg9,arg10,arg11,arg12,arg13); jresult = (int)result; return jresult; } @@ -43694,6 +43740,139 @@ SWIGEXPORT int SWIGSTDCALL CSharp_FreeSWITCHfNative_switch_dial_handle_get_total } +SWIGEXPORT int SWIGSTDCALL CSharp_FreeSWITCHfNative_switch_dial_handle_list_serialize_json_obj___(void * jarg1, void * jarg2) { + int jresult ; + switch_dial_handle_list_t *arg1 = (switch_dial_handle_list_t *) 0 ; + cJSON **arg2 = (cJSON **) 0 ; + switch_status_t result; + + arg1 = (switch_dial_handle_list_t *)jarg1; + arg2 = (cJSON **)jarg2; + result = (switch_status_t)switch_dial_handle_list_serialize_json_obj(arg1,arg2); + jresult = (int)result; + return jresult; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_FreeSWITCHfNative_switch_dial_handle_list_serialize_json___(void * jarg1, void * jarg2) { + int jresult ; + switch_dial_handle_list_t *arg1 = (switch_dial_handle_list_t *) 0 ; + char **arg2 = (char **) 0 ; + switch_status_t result; + + arg1 = (switch_dial_handle_list_t *)jarg1; + arg2 = (char **)jarg2; + result = (switch_status_t)switch_dial_handle_list_serialize_json(arg1,arg2); + jresult = (int)result; + return jresult; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_FreeSWITCHfNative_switch_dial_handle_list_create_json_obj___(void * jarg1, void * jarg2) { + int jresult ; + switch_dial_handle_list_t **arg1 = (switch_dial_handle_list_t **) 0 ; + cJSON *arg2 = (cJSON *) 0 ; + switch_status_t result; + + arg1 = (switch_dial_handle_list_t **)jarg1; + arg2 = (cJSON *)jarg2; + result = (switch_status_t)switch_dial_handle_list_create_json_obj(arg1,arg2); + jresult = (int)result; + return jresult; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_FreeSWITCHfNative_switch_dial_handle_list_create_json___(void * jarg1, char * jarg2) { + int jresult ; + switch_dial_handle_list_t **arg1 = (switch_dial_handle_list_t **) 0 ; + char *arg2 = (char *) 0 ; + switch_status_t result; + + arg1 = (switch_dial_handle_list_t **)jarg1; + arg2 = (char *)jarg2; + result = (switch_status_t)switch_dial_handle_list_create_json(arg1,(char const *)arg2); + jresult = (int)result; + return jresult; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_FreeSWITCHfNative_switch_dial_handle_list_create___(void * jarg1) { + int jresult ; + switch_dial_handle_list_t **arg1 = (switch_dial_handle_list_t **) 0 ; + switch_status_t result; + + arg1 = (switch_dial_handle_list_t **)jarg1; + result = (switch_status_t)switch_dial_handle_list_create(arg1); + jresult = (int)result; + return jresult; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_FreeSWITCHfNative_switch_dial_handle_list_create_handle___(void * jarg1, void * jarg2) { + int jresult ; + switch_dial_handle_list_t *arg1 = (switch_dial_handle_list_t *) 0 ; + switch_dial_handle_t **arg2 = (switch_dial_handle_t **) 0 ; + switch_status_t result; + + arg1 = (switch_dial_handle_list_t *)jarg1; + arg2 = (switch_dial_handle_t **)jarg2; + result = (switch_status_t)switch_dial_handle_list_create_handle(arg1,arg2); + jresult = (int)result; + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_FreeSWITCHfNative_switch_dial_handle_list_destroy___(void * jarg1) { + switch_dial_handle_list_t **arg1 = (switch_dial_handle_list_t **) 0 ; + + arg1 = (switch_dial_handle_list_t **)jarg1; + switch_dial_handle_list_destroy(arg1); +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_FreeSWITCHfNative_switch_dial_handle_list_add_global_var___(void * jarg1, char * jarg2, char * jarg3) { + switch_dial_handle_list_t *arg1 = (switch_dial_handle_list_t *) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) 0 ; + + arg1 = (switch_dial_handle_list_t *)jarg1; + arg2 = (char *)jarg2; + arg3 = (char *)jarg3; + switch_dial_handle_list_add_global_var(arg1,(char const *)arg2,(char const *)arg3); +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_FreeSWITCHfNative_switch_dial_handle_list_add_global_var_printf___(void * jarg1, char * jarg2, char * jarg3) { + switch_dial_handle_list_t *arg1 = (switch_dial_handle_list_t *) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) 0 ; + void *arg4 = 0 ; + + arg1 = (switch_dial_handle_list_t *)jarg1; + arg2 = (char *)jarg2; + arg3 = (char *)jarg3; + switch_dial_handle_list_add_global_var_printf(arg1,(char const *)arg2,(char const *)arg3,arg4); +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_FreeSWITCHfNative_switch_ivr_enterprise_orig_and_bridge___(void * jarg1, char * jarg2, void * jarg3, void * jarg4) { + int jresult ; + switch_core_session_t *arg1 = (switch_core_session_t *) 0 ; + char *arg2 = (char *) 0 ; + switch_dial_handle_list_t *arg3 = (switch_dial_handle_list_t *) 0 ; + switch_call_cause_t *arg4 = (switch_call_cause_t *) 0 ; + switch_status_t result; + + arg1 = (switch_core_session_t *)jarg1; + arg2 = (char *)jarg2; + arg3 = (switch_dial_handle_list_t *)jarg3; + arg4 = (switch_call_cause_t *)jarg4; + result = (switch_status_t)switch_ivr_enterprise_orig_and_bridge(arg1,(char const *)arg2,arg3,arg4); + jresult = (int)result; + return jresult; +} + + SWIGEXPORT int SWIGSTDCALL CSharp_FreeSWITCHfNative_switch_ivr_orig_and_bridge___(void * jarg1, char * jarg2, void * jarg3, void * jarg4) { int jresult ; switch_core_session_t *arg1 = (switch_core_session_t *) 0 ; @@ -49740,6 +49919,38 @@ SWIGEXPORT unsigned long SWIGSTDCALL CSharp_FreeSWITCHfNative_switch_scheduler_a } +SWIGEXPORT unsigned long SWIGSTDCALL CSharp_FreeSWITCHfNative_switch_scheduler_add_task_ex___(void * jarg1, void * jarg2, char * jarg3, char * jarg4, unsigned long jarg5, void * jarg6, unsigned long jarg7, void * jarg8) { + unsigned long jresult ; + time_t arg1 ; + switch_scheduler_func_t arg2 = (switch_scheduler_func_t) 0 ; + char *arg3 = (char *) 0 ; + char *arg4 = (char *) 0 ; + uint32_t arg5 ; + void *arg6 = (void *) 0 ; + switch_scheduler_flag_t arg7 ; + uint32_t *arg8 = (uint32_t *) 0 ; + time_t *argp1 ; + uint32_t result; + + argp1 = (time_t *)jarg1; + if (!argp1) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null time_t", 0); + return 0; + } + arg1 = *argp1; + arg2 = (switch_scheduler_func_t)jarg2; + arg3 = (char *)jarg3; + arg4 = (char *)jarg4; + arg5 = (uint32_t)jarg5; + arg6 = (void *)jarg6; + arg7 = (switch_scheduler_flag_t)jarg7; + arg8 = (uint32_t *)jarg8; + result = (uint32_t)switch_scheduler_add_task_ex(arg1,arg2,(char const *)arg3,(char const *)arg4,arg5,arg6,arg7,arg8); + jresult = (unsigned long)result; + return jresult; +} + + SWIGEXPORT unsigned long SWIGSTDCALL CSharp_FreeSWITCHfNative_switch_scheduler_del_task_id___(unsigned long jarg1) { unsigned long jresult ; uint32_t arg1 ; @@ -50809,6 +51020,20 @@ SWIGEXPORT unsigned int SWIGSTDCALL CSharp_FreeSWITCHfNative_Event_Fire___(void } +SWIGEXPORT unsigned int SWIGSTDCALL CSharp_FreeSWITCHfNative_Event_merge___(void * jarg1, void * jarg2) { + unsigned int jresult ; + Event *arg1 = (Event *) 0 ; + Event *arg2 = (Event *) 0 ; + bool result; + + arg1 = (Event *)jarg1; + arg2 = (Event *)jarg2; + result = (bool)(arg1)->merge(arg2); + jresult = result; + return jresult; +} + + SWIGEXPORT void SWIGSTDCALL CSharp_FreeSWITCHfNative_EventConsumer_events_set___(void * jarg1, void * jarg2) { EventConsumer *arg1 = (EventConsumer *) 0 ; switch_queue_t *arg2 = (switch_queue_t *) 0 ; diff --git a/src/mod/languages/mod_managed/managed/swig.cs b/src/mod/languages/mod_managed/managed/swig.cs index 3002981514..25d419680c 100644 --- a/src/mod/languages/mod_managed/managed/swig.cs +++ b/src/mod/languages/mod_managed/managed/swig.cs @@ -650,6 +650,11 @@ public partial class Event : global::System.IDisposable { return ret; } + public bool merge(Event to_merge) { + bool ret = freeswitchPINVOKE.Event_merge(swigCPtr, Event.getCPtr(to_merge)); + return ret; + } + } } @@ -4795,6 +4800,35 @@ public class SWIGTYPE_p_p_switch_device_record_s { namespace FreeSWITCH.Native { +public class SWIGTYPE_p_p_switch_dial_handle_list_s { + private global::System.Runtime.InteropServices.HandleRef swigCPtr; + + internal SWIGTYPE_p_p_switch_dial_handle_list_s(global::System.IntPtr cPtr, bool futureUse) { + swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr); + } + + protected SWIGTYPE_p_p_switch_dial_handle_list_s() { + swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero); + } + + internal static global::System.Runtime.InteropServices.HandleRef getCPtr(SWIGTYPE_p_p_switch_dial_handle_list_s obj) { + return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr; + } +} + +} +//------------------------------------------------------------------------------ +// +// +// This file was automatically generated by SWIG (http://www.swig.org). +// Version 3.0.12 +// +// Do not make changes to this file unless you know what you are doing--modify +// the SWIG interface file instead. +//------------------------------------------------------------------------------ + +namespace FreeSWITCH.Native { + public class SWIGTYPE_p_p_switch_dial_handle_s { private global::System.Runtime.InteropServices.HandleRef swigCPtr; @@ -6071,6 +6105,35 @@ public class SWIGTYPE_p_switch_core_session { namespace FreeSWITCH.Native { +public class SWIGTYPE_p_switch_dial_handle_list_s { + private global::System.Runtime.InteropServices.HandleRef swigCPtr; + + internal SWIGTYPE_p_switch_dial_handle_list_s(global::System.IntPtr cPtr, bool futureUse) { + swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr); + } + + protected SWIGTYPE_p_switch_dial_handle_list_s() { + swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero); + } + + internal static global::System.Runtime.InteropServices.HandleRef getCPtr(SWIGTYPE_p_switch_dial_handle_list_s obj) { + return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr; + } +} + +} +//------------------------------------------------------------------------------ +// +// +// This file was automatically generated by SWIG (http://www.swig.org). +// Version 3.0.12 +// +// Do not make changes to this file unless you know what you are doing--modify +// the SWIG interface file instead. +//------------------------------------------------------------------------------ + +namespace FreeSWITCH.Native { + public class SWIGTYPE_p_switch_dial_handle_s { private global::System.Runtime.InteropServices.HandleRef swigCPtr; @@ -8907,6 +8970,11 @@ else freeswitchPINVOKE.switch_core_session_reset(SWIGTYPE_p_switch_core_session.getCPtr(session), (int)flush_dtmf, (int)reset_read_codec); } + public static switch_status_t switch_core_session_try_reset(SWIGTYPE_p_switch_core_session session, switch_bool_t flush_dtmf, switch_bool_t reset_read_codec) { + switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_core_session_try_reset(SWIGTYPE_p_switch_core_session.getCPtr(session), (int)flush_dtmf, (int)reset_read_codec); + return ret; + } + public static switch_status_t switch_core_session_write_frame(SWIGTYPE_p_switch_core_session session, switch_frame frame, uint flags, int stream_id) { switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_core_session_write_frame(SWIGTYPE_p_switch_core_session.getCPtr(session), switch_frame.getCPtr(frame), flags, stream_id); return ret; @@ -9328,6 +9396,11 @@ else return ret; } + public static switch_status_t switch_core_file_handle_dup(switch_file_handle oldfh, SWIGTYPE_p_p_switch_file_handle newfh, SWIGTYPE_p_apr_pool_t pool) { + switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_core_file_handle_dup(switch_file_handle.getCPtr(oldfh), SWIGTYPE_p_p_switch_file_handle.getCPtr(newfh), SWIGTYPE_p_apr_pool_t.getCPtr(pool)); + return ret; + } + public static switch_status_t switch_core_file_close(switch_file_handle fh) { switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_core_file_close(switch_file_handle.getCPtr(fh)); return ret; @@ -10207,6 +10280,11 @@ else return ret; } + public static switch_bool_t switch_core_check_dtls_pem(string file) { + switch_bool_t ret = (switch_bool_t)freeswitchPINVOKE.switch_core_check_dtls_pem(file); + return ret; + } + public static int switch_core_cert_gen_fingerprint(string prefix, dtls_fingerprint_t fp) { int ret = freeswitchPINVOKE.switch_core_cert_gen_fingerprint(prefix, dtls_fingerprint_t.getCPtr(fp)); return ret; @@ -13076,8 +13154,8 @@ else return ret; } - public static switch_status_t switch_ivr_enterprise_originate(SWIGTYPE_p_switch_core_session session, SWIGTYPE_p_p_switch_core_session bleg, SWIGTYPE_p_switch_call_cause_t cause, string bridgeto, uint timelimit_sec, switch_state_handler_table table, string cid_name_override, string cid_num_override, switch_caller_profile caller_profile_override, switch_event ovars, uint flags, SWIGTYPE_p_switch_call_cause_t cancel_cause) { - switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_ivr_enterprise_originate(SWIGTYPE_p_switch_core_session.getCPtr(session), SWIGTYPE_p_p_switch_core_session.getCPtr(bleg), SWIGTYPE_p_switch_call_cause_t.getCPtr(cause), bridgeto, timelimit_sec, switch_state_handler_table.getCPtr(table), cid_name_override, cid_num_override, switch_caller_profile.getCPtr(caller_profile_override), switch_event.getCPtr(ovars), flags, SWIGTYPE_p_switch_call_cause_t.getCPtr(cancel_cause)); + public static switch_status_t switch_ivr_enterprise_originate(SWIGTYPE_p_switch_core_session session, SWIGTYPE_p_p_switch_core_session bleg, SWIGTYPE_p_switch_call_cause_t cause, string bridgeto, uint timelimit_sec, switch_state_handler_table table, string cid_name_override, string cid_num_override, switch_caller_profile caller_profile_override, switch_event ovars, uint flags, SWIGTYPE_p_switch_call_cause_t cancel_cause, SWIGTYPE_p_switch_dial_handle_list_s hl) { + switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_ivr_enterprise_originate(SWIGTYPE_p_switch_core_session.getCPtr(session), SWIGTYPE_p_p_switch_core_session.getCPtr(bleg), SWIGTYPE_p_switch_call_cause_t.getCPtr(cause), bridgeto, timelimit_sec, switch_state_handler_table.getCPtr(table), cid_name_override, cid_num_override, switch_caller_profile.getCPtr(caller_profile_override), switch_event.getCPtr(ovars), flags, SWIGTYPE_p_switch_call_cause_t.getCPtr(cancel_cause), SWIGTYPE_p_switch_dial_handle_list_s.getCPtr(hl)); return ret; } @@ -13649,6 +13727,53 @@ else return ret; } + public static switch_status_t switch_dial_handle_list_serialize_json_obj(SWIGTYPE_p_switch_dial_handle_list_s hl, SWIGTYPE_p_p_cJSON json) { + switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_dial_handle_list_serialize_json_obj(SWIGTYPE_p_switch_dial_handle_list_s.getCPtr(hl), SWIGTYPE_p_p_cJSON.getCPtr(json)); + return ret; + } + + public static switch_status_t switch_dial_handle_list_serialize_json(SWIGTYPE_p_switch_dial_handle_list_s hl, ref string str) { + switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_dial_handle_list_serialize_json(SWIGTYPE_p_switch_dial_handle_list_s.getCPtr(hl), ref str); + return ret; + } + + public static switch_status_t switch_dial_handle_list_create_json_obj(SWIGTYPE_p_p_switch_dial_handle_list_s handle, SWIGTYPE_p_cJSON json) { + switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_dial_handle_list_create_json_obj(SWIGTYPE_p_p_switch_dial_handle_list_s.getCPtr(handle), SWIGTYPE_p_cJSON.getCPtr(json)); + return ret; + } + + public static switch_status_t switch_dial_handle_list_create_json(SWIGTYPE_p_p_switch_dial_handle_list_s handle, string handle_string) { + switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_dial_handle_list_create_json(SWIGTYPE_p_p_switch_dial_handle_list_s.getCPtr(handle), handle_string); + return ret; + } + + public static switch_status_t switch_dial_handle_list_create(SWIGTYPE_p_p_switch_dial_handle_list_s hl) { + switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_dial_handle_list_create(SWIGTYPE_p_p_switch_dial_handle_list_s.getCPtr(hl)); + return ret; + } + + public static switch_status_t switch_dial_handle_list_create_handle(SWIGTYPE_p_switch_dial_handle_list_s hl, SWIGTYPE_p_p_switch_dial_handle_s handle) { + switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_dial_handle_list_create_handle(SWIGTYPE_p_switch_dial_handle_list_s.getCPtr(hl), SWIGTYPE_p_p_switch_dial_handle_s.getCPtr(handle)); + return ret; + } + + public static void switch_dial_handle_list_destroy(SWIGTYPE_p_p_switch_dial_handle_list_s hl) { + freeswitchPINVOKE.switch_dial_handle_list_destroy(SWIGTYPE_p_p_switch_dial_handle_list_s.getCPtr(hl)); + } + + public static void switch_dial_handle_list_add_global_var(SWIGTYPE_p_switch_dial_handle_list_s hl, string var, string val) { + freeswitchPINVOKE.switch_dial_handle_list_add_global_var(SWIGTYPE_p_switch_dial_handle_list_s.getCPtr(hl), var, val); + } + + public static void switch_dial_handle_list_add_global_var_printf(SWIGTYPE_p_switch_dial_handle_list_s hl, string var, string fmt) { + freeswitchPINVOKE.switch_dial_handle_list_add_global_var_printf(SWIGTYPE_p_switch_dial_handle_list_s.getCPtr(hl), var, fmt); + } + + public static switch_status_t switch_ivr_enterprise_orig_and_bridge(SWIGTYPE_p_switch_core_session session, string data, SWIGTYPE_p_switch_dial_handle_list_s hl, SWIGTYPE_p_switch_call_cause_t cause) { + switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_ivr_enterprise_orig_and_bridge(SWIGTYPE_p_switch_core_session.getCPtr(session), data, SWIGTYPE_p_switch_dial_handle_list_s.getCPtr(hl), SWIGTYPE_p_switch_call_cause_t.getCPtr(cause)); + return ret; + } + public static switch_status_t switch_ivr_orig_and_bridge(SWIGTYPE_p_switch_core_session session, string data, SWIGTYPE_p_switch_dial_handle_s dh, SWIGTYPE_p_switch_call_cause_t cause) { switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_ivr_orig_and_bridge(SWIGTYPE_p_switch_core_session.getCPtr(session), data, SWIGTYPE_p_switch_dial_handle_s.getCPtr(dh), SWIGTYPE_p_switch_call_cause_t.getCPtr(cause)); return ret; @@ -14626,6 +14751,12 @@ else return ret; } + public static uint switch_scheduler_add_task_ex(SWIGTYPE_p_time_t task_runtime, SWIGTYPE_p_f_p_switch_scheduler_task__void func, string desc, string group, uint cmd_id, SWIGTYPE_p_void cmd_arg, uint flags, SWIGTYPE_p_unsigned_long task_id) { + uint ret = freeswitchPINVOKE.switch_scheduler_add_task_ex(SWIGTYPE_p_time_t.getCPtr(task_runtime), SWIGTYPE_p_f_p_switch_scheduler_task__void.getCPtr(func), desc, group, cmd_id, SWIGTYPE_p_void.getCPtr(cmd_arg), flags, SWIGTYPE_p_unsigned_long.getCPtr(task_id)); + if (freeswitchPINVOKE.SWIGPendingException.Pending) throw freeswitchPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + public static uint switch_scheduler_del_task_id(uint task_id) { uint ret = freeswitchPINVOKE.switch_scheduler_del_task_id(task_id); return ret; @@ -18830,6 +18961,9 @@ class freeswitchPINVOKE { [global::System.Runtime.InteropServices.DllImport("mod_managed", EntryPoint="CSharp_FreeSWITCHfNative_switch_core_session_reset___")] public static extern void switch_core_session_reset(global::System.Runtime.InteropServices.HandleRef jarg1, int jarg2, int jarg3); + [global::System.Runtime.InteropServices.DllImport("mod_managed", EntryPoint="CSharp_FreeSWITCHfNative_switch_core_session_try_reset___")] + public static extern int switch_core_session_try_reset(global::System.Runtime.InteropServices.HandleRef jarg1, int jarg2, int jarg3); + [global::System.Runtime.InteropServices.DllImport("mod_managed", EntryPoint="CSharp_FreeSWITCHfNative_switch_core_session_write_frame___")] public static extern int switch_core_session_write_frame(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2, uint jarg3, int jarg4); @@ -19073,6 +19207,9 @@ class freeswitchPINVOKE { [global::System.Runtime.InteropServices.DllImport("mod_managed", EntryPoint="CSharp_FreeSWITCHfNative_switch_core_file_pre_close___")] public static extern int switch_core_file_pre_close(global::System.Runtime.InteropServices.HandleRef jarg1); + [global::System.Runtime.InteropServices.DllImport("mod_managed", EntryPoint="CSharp_FreeSWITCHfNative_switch_core_file_handle_dup___")] + public static extern int switch_core_file_handle_dup(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2, global::System.Runtime.InteropServices.HandleRef jarg3); + [global::System.Runtime.InteropServices.DllImport("mod_managed", EntryPoint="CSharp_FreeSWITCHfNative_switch_core_file_close___")] public static extern int switch_core_file_close(global::System.Runtime.InteropServices.HandleRef jarg1); @@ -19742,6 +19879,9 @@ class freeswitchPINVOKE { [global::System.Runtime.InteropServices.DllImport("mod_managed", EntryPoint="CSharp_FreeSWITCHfNative_switch_core_gen_certs___")] public static extern int switch_core_gen_certs(string jarg1); + [global::System.Runtime.InteropServices.DllImport("mod_managed", EntryPoint="CSharp_FreeSWITCHfNative_switch_core_check_dtls_pem___")] + public static extern int switch_core_check_dtls_pem(string jarg1); + [global::System.Runtime.InteropServices.DllImport("mod_managed", EntryPoint="CSharp_FreeSWITCHfNative_switch_core_cert_gen_fingerprint___")] public static extern int switch_core_cert_gen_fingerprint(string jarg1, global::System.Runtime.InteropServices.HandleRef jarg2); @@ -25359,7 +25499,7 @@ class freeswitchPINVOKE { public static extern int switch_ivr_originate(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2, global::System.Runtime.InteropServices.HandleRef jarg3, string jarg4, uint jarg5, global::System.Runtime.InteropServices.HandleRef jarg6, string jarg7, string jarg8, global::System.Runtime.InteropServices.HandleRef jarg9, global::System.Runtime.InteropServices.HandleRef jarg10, uint jarg11, global::System.Runtime.InteropServices.HandleRef jarg12, global::System.Runtime.InteropServices.HandleRef jarg13); [global::System.Runtime.InteropServices.DllImport("mod_managed", EntryPoint="CSharp_FreeSWITCHfNative_switch_ivr_enterprise_originate___")] - public static extern int switch_ivr_enterprise_originate(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2, global::System.Runtime.InteropServices.HandleRef jarg3, string jarg4, uint jarg5, global::System.Runtime.InteropServices.HandleRef jarg6, string jarg7, string jarg8, global::System.Runtime.InteropServices.HandleRef jarg9, global::System.Runtime.InteropServices.HandleRef jarg10, uint jarg11, global::System.Runtime.InteropServices.HandleRef jarg12); + public static extern int switch_ivr_enterprise_originate(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2, global::System.Runtime.InteropServices.HandleRef jarg3, string jarg4, uint jarg5, global::System.Runtime.InteropServices.HandleRef jarg6, string jarg7, string jarg8, global::System.Runtime.InteropServices.HandleRef jarg9, global::System.Runtime.InteropServices.HandleRef jarg10, uint jarg11, global::System.Runtime.InteropServices.HandleRef jarg12, global::System.Runtime.InteropServices.HandleRef jarg13); [global::System.Runtime.InteropServices.DllImport("mod_managed", EntryPoint="CSharp_FreeSWITCHfNative_switch_ivr_bridge_display___")] public static extern void switch_ivr_bridge_display(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2); @@ -25706,6 +25846,36 @@ class freeswitchPINVOKE { [global::System.Runtime.InteropServices.DllImport("mod_managed", EntryPoint="CSharp_FreeSWITCHfNative_switch_dial_handle_get_total___")] public static extern int switch_dial_handle_get_total(global::System.Runtime.InteropServices.HandleRef jarg1); + [global::System.Runtime.InteropServices.DllImport("mod_managed", EntryPoint="CSharp_FreeSWITCHfNative_switch_dial_handle_list_serialize_json_obj___")] + public static extern int switch_dial_handle_list_serialize_json_obj(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2); + + [global::System.Runtime.InteropServices.DllImport("mod_managed", EntryPoint="CSharp_FreeSWITCHfNative_switch_dial_handle_list_serialize_json___")] + public static extern int switch_dial_handle_list_serialize_json(global::System.Runtime.InteropServices.HandleRef jarg1, ref string jarg2); + + [global::System.Runtime.InteropServices.DllImport("mod_managed", EntryPoint="CSharp_FreeSWITCHfNative_switch_dial_handle_list_create_json_obj___")] + public static extern int switch_dial_handle_list_create_json_obj(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2); + + [global::System.Runtime.InteropServices.DllImport("mod_managed", EntryPoint="CSharp_FreeSWITCHfNative_switch_dial_handle_list_create_json___")] + public static extern int switch_dial_handle_list_create_json(global::System.Runtime.InteropServices.HandleRef jarg1, string jarg2); + + [global::System.Runtime.InteropServices.DllImport("mod_managed", EntryPoint="CSharp_FreeSWITCHfNative_switch_dial_handle_list_create___")] + public static extern int switch_dial_handle_list_create(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport("mod_managed", EntryPoint="CSharp_FreeSWITCHfNative_switch_dial_handle_list_create_handle___")] + public static extern int switch_dial_handle_list_create_handle(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2); + + [global::System.Runtime.InteropServices.DllImport("mod_managed", EntryPoint="CSharp_FreeSWITCHfNative_switch_dial_handle_list_destroy___")] + public static extern void switch_dial_handle_list_destroy(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport("mod_managed", EntryPoint="CSharp_FreeSWITCHfNative_switch_dial_handle_list_add_global_var___")] + public static extern void switch_dial_handle_list_add_global_var(global::System.Runtime.InteropServices.HandleRef jarg1, string jarg2, string jarg3); + + [global::System.Runtime.InteropServices.DllImport("mod_managed", EntryPoint="CSharp_FreeSWITCHfNative_switch_dial_handle_list_add_global_var_printf___")] + public static extern void switch_dial_handle_list_add_global_var_printf(global::System.Runtime.InteropServices.HandleRef jarg1, string jarg2, string jarg3); + + [global::System.Runtime.InteropServices.DllImport("mod_managed", EntryPoint="CSharp_FreeSWITCHfNative_switch_ivr_enterprise_orig_and_bridge___")] + public static extern int switch_ivr_enterprise_orig_and_bridge(global::System.Runtime.InteropServices.HandleRef jarg1, string jarg2, global::System.Runtime.InteropServices.HandleRef jarg3, global::System.Runtime.InteropServices.HandleRef jarg4); + [global::System.Runtime.InteropServices.DllImport("mod_managed", EntryPoint="CSharp_FreeSWITCHfNative_switch_ivr_orig_and_bridge___")] public static extern int switch_ivr_orig_and_bridge(global::System.Runtime.InteropServices.HandleRef jarg1, string jarg2, global::System.Runtime.InteropServices.HandleRef jarg3, global::System.Runtime.InteropServices.HandleRef jarg4); @@ -27158,6 +27328,9 @@ class freeswitchPINVOKE { [global::System.Runtime.InteropServices.DllImport("mod_managed", EntryPoint="CSharp_FreeSWITCHfNative_switch_scheduler_add_task___")] public static extern uint switch_scheduler_add_task(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2, string jarg3, string jarg4, uint jarg5, global::System.Runtime.InteropServices.HandleRef jarg6, uint jarg7); + [global::System.Runtime.InteropServices.DllImport("mod_managed", EntryPoint="CSharp_FreeSWITCHfNative_switch_scheduler_add_task_ex___")] + public static extern uint switch_scheduler_add_task_ex(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2, string jarg3, string jarg4, uint jarg5, global::System.Runtime.InteropServices.HandleRef jarg6, uint jarg7, global::System.Runtime.InteropServices.HandleRef jarg8); + [global::System.Runtime.InteropServices.DllImport("mod_managed", EntryPoint="CSharp_FreeSWITCHfNative_switch_scheduler_del_task_id___")] public static extern uint switch_scheduler_del_task_id(uint jarg1); @@ -27416,6 +27589,9 @@ class freeswitchPINVOKE { [global::System.Runtime.InteropServices.DllImport("mod_managed", EntryPoint="CSharp_FreeSWITCHfNative_Event_Fire___")] public static extern bool Event_Fire(global::System.Runtime.InteropServices.HandleRef jarg1); + [global::System.Runtime.InteropServices.DllImport("mod_managed", EntryPoint="CSharp_FreeSWITCHfNative_Event_merge___")] + public static extern bool Event_merge(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2); + [global::System.Runtime.InteropServices.DllImport("mod_managed", EntryPoint="CSharp_FreeSWITCHfNative_EventConsumer_events_set___")] public static extern void EventConsumer_events_set(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2); @@ -31483,6 +31659,7 @@ public enum switch_channel_flag_t { CF_SERVICE, CF_TAGGED, CF_WINNER, + CF_REUSE_CALLER_PROFILE, CF_CONTROLLED, CF_PROXY_MODE, CF_PROXY_OFF, @@ -36106,7 +36283,8 @@ namespace FreeSWITCH.Native { ED_BRIDGE_READ = (1 << 4), ED_BRIDGE_WRITE = (1 << 5), ED_TAP_READ = (1 << 6), - ED_TAP_WRITE = (1 << 7) + ED_TAP_WRITE = (1 << 7), + ED_STEREO = (1 << 8) } } diff --git a/src/mod/languages/mod_perl/freeswitch.pm b/src/mod/languages/mod_perl/freeswitch.pm index 3d511c9225..9717fbb944 100644 --- a/src/mod/languages/mod_perl/freeswitch.pm +++ b/src/mod/languages/mod_perl/freeswitch.pm @@ -311,6 +311,7 @@ sub DESTROY { *addHeader = *freeswitchc::Event_addHeader; *delHeader = *freeswitchc::Event_delHeader; *fire = *freeswitchc::Event_fire; +*merge = *freeswitchc::Event_merge; sub DISOWN { my $self = shift; my $ptr = tied(%$self); diff --git a/src/mod/languages/mod_perl/mod_perl_wrap.cpp b/src/mod/languages/mod_perl/mod_perl_wrap.cpp index a6b48e7670..27e98ee3e6 100644 --- a/src/mod/languages/mod_perl/mod_perl_wrap.cpp +++ b/src/mod/languages/mod_perl/mod_perl_wrap.cpp @@ -4482,6 +4482,44 @@ XS(_wrap_Event_fire) { } +XS(_wrap_Event_merge) { + { + Event *arg1 = (Event *) 0 ; + Event *arg2 = (Event *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int argvi = 0; + bool result; + dXSARGS; + + if ((items < 2) || (items > 2)) { + SWIG_croak("Usage: Event_merge(self,to_merge);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_Event, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Event_merge" "', argument " "1"" of type '" "Event *""'"); + } + arg1 = reinterpret_cast< Event * >(argp1); + res2 = SWIG_ConvertPtr(ST(1), &argp2,SWIGTYPE_p_Event, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Event_merge" "', argument " "2"" of type '" "Event *""'"); + } + arg2 = reinterpret_cast< Event * >(argp2); + result = (bool)(arg1)->merge(arg2); + ST(argvi) = SWIG_From_bool SWIG_PERL_CALL_ARGS_1(static_cast< bool >(result)); argvi++ ; + + + XSRETURN(argvi); + fail: + + + SWIG_croak_null(); + } +} + + XS(_wrap_EventConsumer_events_set) { { EventConsumer *arg1 = (EventConsumer *) 0 ; @@ -10792,6 +10830,7 @@ static swig_command_info swig_commands[] = { {"freeswitchc::Event_addHeader", _wrap_Event_addHeader}, {"freeswitchc::Event_delHeader", _wrap_Event_delHeader}, {"freeswitchc::Event_fire", _wrap_Event_fire}, +{"freeswitchc::Event_merge", _wrap_Event_merge}, {"freeswitchc::EventConsumer_events_set", _wrap_EventConsumer_events_set}, {"freeswitchc::EventConsumer_events_get", _wrap_EventConsumer_events_get}, {"freeswitchc::EventConsumer_e_event_id_set", _wrap_EventConsumer_e_event_id_set}, diff --git a/src/mod/languages/mod_python/freeswitch.py b/src/mod/languages/mod_python/freeswitch.py index ac9f655ad9..48ccf472f1 100644 --- a/src/mod/languages/mod_python/freeswitch.py +++ b/src/mod/languages/mod_python/freeswitch.py @@ -327,6 +327,9 @@ class Event(_object): def fire(self): return _freeswitch.Event_fire(self) + + def merge(self, to_merge): + return _freeswitch.Event_merge(self, to_merge) Event_swigregister = _freeswitch.Event_swigregister Event_swigregister(Event) diff --git a/src/mod/languages/mod_python/mod_python_wrap.cpp b/src/mod/languages/mod_python/mod_python_wrap.cpp index 31ec090c6a..227b441b59 100644 --- a/src/mod/languages/mod_python/mod_python_wrap.cpp +++ b/src/mod/languages/mod_python/mod_python_wrap.cpp @@ -5765,6 +5765,37 @@ fail: } +SWIGINTERN PyObject *_wrap_Event_merge(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Event *arg1 = (Event *) 0 ; + Event *arg2 = (Event *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + bool result; + + if (!PyArg_ParseTuple(args,(char *)"OO:Event_merge",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Event, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Event_merge" "', argument " "1"" of type '" "Event *""'"); + } + arg1 = reinterpret_cast< Event * >(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_Event, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Event_merge" "', argument " "2"" of type '" "Event *""'"); + } + arg2 = reinterpret_cast< Event * >(argp2); + result = (bool)(arg1)->merge(arg2); + resultobj = SWIG_From_bool(static_cast< bool >(result)); + return resultobj; +fail: + return NULL; +} + + SWIGINTERN PyObject *Event_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *obj; if (!PyArg_ParseTuple(args,(char *)"O:swigregister", &obj)) return NULL; @@ -10541,6 +10572,7 @@ static PyMethodDef SwigMethods[] = { { "Event_addHeader", _wrap_Event_addHeader, METH_VARARGS, NULL}, { "Event_delHeader", _wrap_Event_delHeader, METH_VARARGS, NULL}, { "Event_fire", _wrap_Event_fire, METH_VARARGS, NULL}, + { "Event_merge", _wrap_Event_merge, METH_VARARGS, NULL}, { "Event_swigregister", Event_swigregister, METH_VARARGS, NULL}, { "EventConsumer_events_set", _wrap_EventConsumer_events_set, METH_VARARGS, NULL}, { "EventConsumer_events_get", _wrap_EventConsumer_events_get, METH_VARARGS, NULL}, diff --git a/src/switch_ivr_originate.c b/src/switch_ivr_originate.c index d2baeb2741..d81ffcc357 100644 --- a/src/switch_ivr_originate.c +++ b/src/switch_ivr_originate.c @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2014, Anthony Minessale II + * Copyright (C) 2005-2021, Anthony Minessale II * * Version: MPL 1.1 * @@ -106,6 +106,14 @@ struct switch_dial_handle_s { switch_memory_pool_t *pool; }; +struct switch_dial_handle_list_s { + int handle_idx; + switch_dial_handle_t *handles[MAX_PEERS]; + switch_event_t *global_vars; + switch_memory_pool_t *pool; +}; + +static switch_status_t switch_dial_handle_dup(switch_dial_handle_t **handle, switch_dial_handle_t *todup); typedef struct { switch_core_session_t *down_session; @@ -1451,6 +1459,7 @@ typedef struct { int done; switch_thread_t *thread; switch_mutex_t *mutex; + switch_dial_handle_t *dh; } enterprise_originate_handle_t; @@ -1475,7 +1484,7 @@ static void *SWITCH_THREAD_FUNC enterprise_originate_thread(switch_thread_t *thr handle->ovars, handle->flags, &handle->cancel_cause, - NULL); + handle->dh); handle->done = 1; @@ -1541,7 +1550,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_enterprise_originate(switch_core_sess const char *cid_num_override, switch_caller_profile_t *caller_profile_override, switch_event_t *ovars, switch_originate_flag_t flags, - switch_call_cause_t *cancel_cause) + switch_call_cause_t *cancel_cause, + switch_dial_handle_list_t *hl) { int x_argc = 0; char *x_argv[MAX_PEERS] = { 0 }; @@ -1549,7 +1559,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_enterprise_originate(switch_core_sess int i; switch_caller_profile_t *cp = NULL; switch_channel_t *channel = NULL; - char *data; + char *data = NULL; switch_status_t status = SWITCH_STATUS_FALSE; switch_threadattr_t *thd_attr = NULL; int running = 0, over = 0; @@ -1565,13 +1575,15 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_enterprise_originate(switch_core_sess switch_core_new_memory_pool(&pool); - if (zstr(bridgeto)) { + if (zstr(bridgeto) && (!hl || hl->handle_idx == 0)) { *cause = SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER; getcause = 0; switch_goto_status(SWITCH_STATUS_FALSE, end); } - data = switch_core_strdup(pool, bridgeto); + if (!hl) { + data = switch_core_strdup(pool, bridgeto); + } if (session) { switch_caller_profile_t *cpp = NULL; @@ -1632,6 +1644,9 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_enterprise_originate(switch_core_sess data = parsed; } + if (hl && hl->global_vars) { + switch_event_merge(var_event, hl->global_vars); + } /* strip leading spaces (again) */ while (data && *data && *data == ' ') { @@ -1646,10 +1661,14 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_enterprise_originate(switch_core_sess switch_event_add_header_string(var_event, SWITCH_STACK_BOTTOM, "ignore_early_media", "true"); - if (!(x_argc = switch_separate_string_string(data, SWITCH_ENT_ORIGINATE_DELIM, x_argv, MAX_PEERS))) { - *cause = SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER; - getcause = 0; - switch_goto_status(SWITCH_STATUS_FALSE, end); + if (data) { + if (!(x_argc = switch_separate_string_string(data, SWITCH_ENT_ORIGINATE_DELIM, x_argv, MAX_PEERS))) { + *cause = SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER; + getcause = 0; + switch_goto_status(SWITCH_STATUS_FALSE, end); + } + } else { + x_argc = hl->handle_idx; } switch_threadattr_create(&thd_attr, pool); @@ -1668,6 +1687,9 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_enterprise_originate(switch_core_sess handles[i].caller_profile_override = cp; switch_event_dup(&handles[i].ovars, var_event); handles[i].flags = flags; + if (hl) { + switch_dial_handle_dup(&handles[i].dh, hl->handles[i]); + } switch_mutex_init(&handles[i].mutex, SWITCH_MUTEX_NESTED, pool); switch_mutex_lock(handles[i].mutex); switch_thread_create(&handles[i].thread, thd_attr, enterprise_originate_thread, &handles[i], pool); @@ -1756,6 +1778,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_enterprise_originate(switch_core_sess switch_mutex_unlock(hp->mutex); switch_thread_join(&tstatus, hp->thread); switch_event_destroy(&hp->ovars); + switch_dial_handle_destroy(&hp->dh); } for (i = 0; i < x_argc; i++) { @@ -1789,6 +1812,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_enterprise_originate(switch_core_sess switch_thread_join(&tstatus, handles[i].thread); switch_event_destroy(&handles[i].ovars); + switch_dial_handle_destroy(&handles[i].dh); } if (channel && rb_data.thread) { @@ -2078,7 +2102,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess if (strstr(bridgeto, SWITCH_ENT_ORIGINATE_DELIM)) { return switch_ivr_enterprise_originate(session, bleg, cause, bridgeto, timelimit_sec, table, cid_name_override, cid_num_override, - caller_profile_override, ovars, flags, cancel_cause); + caller_profile_override, ovars, flags, cancel_cause, NULL); } oglobals.check_vars = SWITCH_TRUE; @@ -4234,6 +4258,133 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess return status; } +SWITCH_DECLARE(switch_status_t) switch_dial_handle_list_create(switch_dial_handle_list_t **hl) +{ + switch_dial_handle_list_t *hlP = NULL; + switch_memory_pool_t *pool = NULL; + + switch_core_new_memory_pool(&pool); + switch_assert(pool); + + hlP = switch_core_alloc(pool, sizeof(*hlP)); + switch_assert(hlP); + + hlP->pool = pool; + + *hl = hlP; + + return SWITCH_STATUS_SUCCESS; +} + +static switch_status_t switch_dial_handle_list_add_handle(switch_dial_handle_list_t *hl, switch_dial_handle_t *handle) +{ + if (hl->handle_idx < MAX_PEERS && handle) { + hl->handles[hl->handle_idx++] = handle; + return SWITCH_STATUS_SUCCESS; + } + return SWITCH_STATUS_FALSE; +} + +SWITCH_DECLARE(switch_status_t) switch_dial_handle_list_create_handle(switch_dial_handle_list_t *hl, switch_dial_handle_t **handle) +{ + switch_dial_handle_t *hp = NULL; + if (hl->handle_idx < MAX_PEERS && switch_dial_handle_create(&hp) == SWITCH_STATUS_SUCCESS && hp) { + hl->handles[hl->handle_idx++] = hp; + *handle = hp; + return SWITCH_STATUS_SUCCESS; + } + return SWITCH_STATUS_FALSE; +} + +SWITCH_DECLARE(void) switch_dial_handle_list_destroy(switch_dial_handle_list_t **hl) +{ + switch_dial_handle_list_t *hlP = *hl; + switch_memory_pool_t *pool = NULL; + + *hl = NULL; + + if (hlP) { + int i; + for (i = 0; i < hlP->handle_idx; i++) { + switch_dial_handle_destroy(&hlP->handles[i]); + } + + switch_event_destroy(&hlP->global_vars); + pool = hlP->pool; + hlP = NULL; + switch_core_destroy_memory_pool(&pool); + } +} + +SWITCH_DECLARE(void) switch_dial_handle_list_add_global_var(switch_dial_handle_list_t *hl, const char *var, const char *val) +{ + switch_assert(hl); + + if (!hl->global_vars) { + switch_event_create_plain(&hl->global_vars, SWITCH_EVENT_CHANNEL_DATA); + } + + switch_event_add_header_string(hl->global_vars, SWITCH_STACK_BOTTOM, var, val); +} + +SWITCH_DECLARE(void) switch_dial_handle_list_add_global_var_printf(switch_dial_handle_list_t *hl, const char *var, const char *fmt, ...) +{ + int ret = 0; + char *data = NULL; + va_list ap; + + va_start(ap, fmt); + ret = switch_vasprintf(&data, fmt, ap); + va_end(ap); + + if (ret == -1) { + abort(); + } + + switch_dial_handle_list_add_global_var(hl, var, data); + free(data); +} + +static switch_status_t switch_dial_handle_dup(switch_dial_handle_t **handle, switch_dial_handle_t *todup) +{ + int i; + switch_dial_handle_t *hp; + + if (!todup || !handle) { + return SWITCH_STATUS_FALSE; + } + + *handle = NULL; + + switch_dial_handle_create(&hp); + switch_assert(hp); + + for (i = 0; i < todup->leg_list_idx; i++) { + int j; + switch_dial_leg_list_t *ll_todup = todup->leg_lists[i]; + switch_dial_leg_list_t *ll = NULL; + switch_dial_handle_add_leg_list(hp, &ll); + for (j = 0; j < ll_todup->leg_idx; j++) { + switch_dial_leg_t *leg; + switch_dial_leg_t *leg_todup = ll_todup->legs[j]; + switch_dial_leg_list_add_leg(ll, &leg, leg_todup->dial_string); + if (leg_todup->leg_vars) { + switch_event_dup(&leg->leg_vars, leg_todup->leg_vars); + } + } + } + + if (todup->global_vars) { + switch_event_dup(&hp->global_vars, todup->global_vars); + } + + hp->is_sub = todup->is_sub; + + *handle = hp; + + return SWITCH_STATUS_SUCCESS; +} + SWITCH_DECLARE(switch_status_t) switch_dial_handle_create(switch_dial_handle_t **handle) { switch_dial_handle_t *hp; @@ -4605,6 +4756,115 @@ SWITCH_DECLARE(switch_status_t) switch_dial_handle_create_json(switch_dial_handl } +SWITCH_DECLARE(switch_status_t) switch_dial_handle_list_serialize_json_obj(switch_dial_handle_list_t *hl, cJSON **json) +{ + int i; + cJSON *global_vars_json = NULL; + cJSON *handles_json = NULL; + if (!hl) { + return SWITCH_STATUS_FALSE; + } + *json = cJSON_CreateObject(); + if (hl->global_vars && vars_serialize_json_obj(hl->global_vars, &global_vars_json) == SWITCH_STATUS_SUCCESS && global_vars_json) { + cJSON_AddItemToObject(*json, "vars", global_vars_json); + } + + handles_json = cJSON_CreateArray(); + cJSON_AddItemToObject(*json, "handles", handles_json); + for (i = 0; i < hl->handle_idx; i++) { + switch_dial_handle_t *handle = hl->handles[i]; + cJSON *handle_json = NULL; + if (switch_dial_handle_serialize_json_obj(handle, &handle_json) == SWITCH_STATUS_SUCCESS && handle_json) { + cJSON_AddItemToArray(handles_json, handle_json); + } + } + + return SWITCH_STATUS_SUCCESS; +} + + +SWITCH_DECLARE(switch_status_t) switch_dial_handle_list_serialize_json(switch_dial_handle_list_t *hl, char **str) +{ + cJSON *json = NULL; + if (switch_dial_handle_list_serialize_json_obj(hl, &json) == SWITCH_STATUS_SUCCESS && json) { + *str = cJSON_PrintUnformatted(json); + cJSON_Delete(json); + return SWITCH_STATUS_SUCCESS; + } + return SWITCH_STATUS_FALSE; +} + + +SWITCH_DECLARE(switch_status_t) switch_dial_handle_list_create_json_obj(switch_dial_handle_list_t **hl, cJSON *handle_list_json) +{ + cJSON *handle_json = NULL; + cJSON *handles_json = NULL; + cJSON *vars_json = NULL; + + *hl = NULL; + + handles_json = cJSON_GetObjectItem(handle_list_json, "handles"); + if (!handles_json || !cJSON_IsArray(handles_json)) { + return SWITCH_STATUS_FALSE; + } + switch_dial_handle_list_create(hl); + switch_assert(*hl); + for (handle_json = handles_json->child; handle_json; handle_json = handle_json->next) { + switch_dial_handle_t *handle = NULL; + if (switch_dial_handle_create_json_obj(&handle, handle_json) == SWITCH_STATUS_SUCCESS && handle) { + if (switch_dial_handle_list_add_handle(*hl, handle) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Not adding remaining dial handles: exceeded limit of %d handles\n", MAX_PEERS); + switch_dial_handle_destroy(&handle); + break; + } + } else { + char *handle_json_str = cJSON_PrintUnformatted(handle_json); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Failed to create dial handle: %s\n", handle_json_str); + switch_safe_free(handle_json_str); + } + } + + if ((*hl)->handle_idx == 0) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Failed to create dial handle list: no handles added!\n"); + switch_dial_handle_list_destroy(hl); + return SWITCH_STATUS_FALSE; + } + + vars_json = cJSON_GetObjectItem(handle_list_json, "vars"); + if (vars_json && vars_json->type == cJSON_Object) { + cJSON *var_json = NULL; + cJSON_ArrayForEach(var_json, vars_json) { + if (!var_json || var_json->type != cJSON_String || !var_json->valuestring || !var_json->string) { + continue; + } + switch_dial_handle_list_add_global_var(*hl, var_json->string, var_json->valuestring); + } + } + + return SWITCH_STATUS_SUCCESS; +} + + +SWITCH_DECLARE(switch_status_t) switch_dial_handle_list_create_json(switch_dial_handle_list_t **hl, const char *handle_list_string) +{ + switch_status_t status; + cJSON *handle_list_json = NULL; + + if (zstr(handle_list_string)) { + return SWITCH_STATUS_FALSE; + } + + handle_list_json = cJSON_Parse(handle_list_string); + if (!handle_list_json) { + return SWITCH_STATUS_FALSE; + } + + status = switch_dial_handle_list_create_json_obj(hl, handle_list_json); + cJSON_Delete(handle_list_json); + return status; +} + + static switch_status_t o_bridge_on_dtmf(switch_core_session_t *session, void *input, switch_input_type_t itype, void *buf, unsigned int buflen) { char *str = (char *) buf; @@ -4618,6 +4878,72 @@ static switch_status_t o_bridge_on_dtmf(switch_core_session_t *session, void *in return SWITCH_STATUS_SUCCESS; } + +SWITCH_DECLARE(switch_status_t) switch_ivr_enterprise_orig_and_bridge(switch_core_session_t *session, const char *data, switch_dial_handle_list_t *hl, switch_call_cause_t *cause) +{ + switch_channel_t *caller_channel = switch_core_session_get_channel(session); + switch_core_session_t *peer_session = NULL; + switch_status_t status = SWITCH_STATUS_FALSE; + int fail = 0; + + if ((status = switch_ivr_enterprise_originate(session, + &peer_session, + cause, data, 0, NULL, NULL, NULL, NULL, NULL, SOF_NONE, NULL, hl)) != SWITCH_STATUS_SUCCESS) { + fail = 1; + } + + + if (fail) { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "Originate Failed. Cause: %s\n", switch_channel_cause2str(*cause)); + + switch_channel_set_variable(caller_channel, "originate_failed_cause", switch_channel_cause2str(*cause)); + + switch_channel_handle_cause(caller_channel, *cause); + + return status; + } else { + switch_channel_t *peer_channel = switch_core_session_get_channel(peer_session); + + if (switch_true(switch_channel_get_variable(caller_channel, SWITCH_BYPASS_MEDIA_AFTER_BRIDGE_VARIABLE)) || + switch_true(switch_channel_get_variable(peer_channel, SWITCH_BYPASS_MEDIA_AFTER_BRIDGE_VARIABLE))) { + switch_channel_set_flag(caller_channel, CF_BYPASS_MEDIA_AFTER_BRIDGE); + } + + if (switch_channel_test_flag(caller_channel, CF_PROXY_MODE)) { + switch_ivr_signal_bridge(session, peer_session); + } else { + char *a_key = (char *) switch_channel_get_variable(caller_channel, "bridge_terminate_key"); + char *b_key = (char *) switch_channel_get_variable(peer_channel, "bridge_terminate_key"); + int ok = 0; + switch_input_callback_function_t func = NULL; + + if (a_key) { + a_key = switch_core_session_strdup(session, a_key); + ok++; + } + if (b_key) { + b_key = switch_core_session_strdup(session, b_key); + ok++; + } + if (ok) { + func = o_bridge_on_dtmf; + } else { + a_key = NULL; + b_key = NULL; + } + + switch_ivr_multi_threaded_bridge(session, peer_session, func, a_key, b_key); + } + + if (peer_session) { + switch_core_session_rwunlock(peer_session); + } + } + + return status; +} + + SWITCH_DECLARE(switch_status_t) switch_ivr_orig_and_bridge(switch_core_session_t *session, const char *data, switch_dial_handle_t *dh, switch_call_cause_t *cause) { switch_channel_t *caller_channel = switch_core_session_get_channel(session); diff --git a/tests/unit/switch_ivr_originate.c b/tests/unit/switch_ivr_originate.c index 9369506b13..6c34fcc1e8 100644 --- a/tests/unit/switch_ivr_originate.c +++ b/tests/unit/switch_ivr_originate.c @@ -209,6 +209,99 @@ FST_CORE_BEGIN("./conf") } FST_TEST_END(); + FST_TEST_BEGIN(dial_handle_list_create_json) + { + const char *dh_str_1 = "{\n" + " \"vars\": {\n" + " \"foo\": \"bar\",\n" + " \"absolute_codec_string\": \"pcmu,pcma\",\n" + " \"ignore_early_media\": \"true\"\n" + " },\n" + " \"leg_lists\": [\n" + " { \"legs\": [\n" + " { \n" + " \"dial_string\": \"loopback/dest2\", \n" + " \"vars\": {\n" + " \"bar\": \"bar\"\n" + " }\n" + " },\n" + " { \n" + " \"dial_string\": \"sofia/gateway/gw/123456\"\n" + " }\n" + " ] },\n" + " { \"legs\": [\n" + " {\n" + " \"dial_string\": \"sofia/external/foo@example.com^5551231234\",\n" + " \"vars\": {\n" + " \"sip_h_X-Custom\": \"my val 2\"\n" + " }\n" + " }\n" + " ] },\n" + " { \"legs\": [\n" + " {\n" + " \"dial_string\": \"group/my_group_2\"\n" + " }\n" + " ] }\n" + " ]\n" + "}"; + const char *dh_str_2 = "{\n" + " \"vars\": {\n" + " \"foo\": \"bar\",\n" + " \"absolute_codec_string\": \"opus,pcmu,pcma\",\n" + " \"ignore_early_media\": \"true\"\n" + " },\n" + " \"leg_lists\": [\n" + " { \"legs\": [\n" + " { \n" + " \"dial_string\": \"loopback/dest\", \n" + " \"vars\": {\n" + " \"bar\": \"bar\"\n" + " }\n" + " },\n" + " { \n" + " \"dial_string\": \"sofia/gateway/gw/12345\"\n" + " }\n" + " ] },\n" + " { \"legs\": [\n" + " {\n" + " \"dial_string\": \"sofia/external/foo@example.com^5551231234\",\n" + " \"vars\": {\n" + " \"sip_h_X-Custom\": \"my val\"\n" + " }\n" + " }\n" + " ] },\n" + " { \"legs\": [\n" + " {\n" + " \"dial_string\": \"group/my_group\"\n" + " }\n" + " ] }\n" + " ]\n" + "}"; + const char *dl_str = switch_core_sprintf(fst_pool, "{ \"handles\": [ %s, %s ], \"vars\": { \"global_1\":\"val_1\" } }", dh_str_1, dh_str_2); + // create dial handle from json string, convert back to json and compare + switch_dial_handle_list_t *dl = NULL; + char *dl_str_2 = NULL; + char *dl_str_3 = NULL; + cJSON *dl_json = NULL; + fst_requires(switch_dial_handle_list_create_json(&dl, dl_str) == SWITCH_STATUS_SUCCESS); + fst_requires(dl != NULL); + fst_requires(switch_dial_handle_list_serialize_json_obj(dl, &dl_json) == SWITCH_STATUS_SUCCESS); + fst_requires(dl_json != NULL); + fst_requires(switch_dial_handle_list_serialize_json(dl, &dl_str_2) == SWITCH_STATUS_SUCCESS); + fst_requires(dl_str_2 != NULL); + fst_check_string_equals(dl_str_2, "{\"vars\":{\"global_1\":\"val_1\"},\"handles\":[{\"vars\":{\"foo\":\"bar\",\"absolute_codec_string\":\"pcmu,pcma\",\"ignore_early_media\":\"true\"},\"leg_lists\":[{\"legs\":[{\"dial_string\":\"loopback/dest2\",\"vars\":{\"bar\":\"bar\"}},{\"dial_string\":\"sofia/gateway/gw/123456\"}]},{\"legs\":[{\"dial_string\":\"sofia/external/foo@example.com^5551231234\",\"vars\":{\"sip_h_X-Custom\":\"my val 2\"}}]},{\"legs\":[{\"dial_string\":\"group/my_group_2\"}]}]},{\"vars\":{\"foo\":\"bar\",\"absolute_codec_string\":\"opus,pcmu,pcma\",\"ignore_early_media\":\"true\"},\"leg_lists\":[{\"legs\":[{\"dial_string\":\"loopback/dest\",\"vars\":{\"bar\":\"bar\"}},{\"dial_string\":\"sofia/gateway/gw/12345\"}]},{\"legs\":[{\"dial_string\":\"sofia/external/foo@example.com^5551231234\",\"vars\":{\"sip_h_X-Custom\":\"my val\"}}]},{\"legs\":[{\"dial_string\":\"group/my_group\"}]}]}]}"); + + dl_str_3 = cJSON_PrintUnformatted(dl_json); + fst_requires(dl_str_3); + fst_check_string_equals(dl_str_2, dl_str_3); + + switch_safe_free(dl_str_2); + switch_safe_free(dl_str_3); + cJSON_Delete(dl_json); + switch_dial_handle_list_destroy(&dl); + } + FST_TEST_END(); + FST_TEST_BEGIN(originate_test_empty_dial_string) { switch_core_session_t *session = NULL; @@ -622,6 +715,103 @@ FST_CORE_BEGIN("./conf") fst_check_duration(4500, 600); // (>= 3.9 sec, <= 5.1 sec) } FST_TEST_END() + + FST_TEST_BEGIN(enterprise_originate_test_group_confirm_two_handles) + { + switch_core_session_t *session = NULL; + switch_status_t status; + switch_call_cause_t cause; + switch_dial_handle_list_t *dl; + switch_dial_handle_t *dh; + switch_dial_leg_list_t *ll; + switch_dial_leg_t *leg = NULL; + + switch_dial_handle_list_create(&dl); + + switch_dial_handle_list_create_handle(dl, &dh); + switch_dial_handle_add_leg_list(dh, &ll); + switch_dial_leg_list_add_leg(ll, &leg, "null/test"); + switch_dial_handle_add_leg_var(leg, "group_confirm_file", "playback silence_stream://1000"); + switch_dial_handle_add_leg_var(leg, "group_confirm_key", "exec"); + switch_dial_handle_add_leg_var(leg, "expected_winner", "true"); + + switch_dial_handle_list_create_handle(dl, &dh); + switch_dial_handle_add_leg_list(dh, &ll); + switch_dial_leg_list_add_leg(ll, &leg, "error/user_busy"); + + switch_dial_handle_list_add_global_var(dl, "continue_on_fail", "true"); + switch_dial_handle_list_add_global_var(dl, "is_from_dial_handle_list", "true"); + + status = switch_ivr_enterprise_originate(NULL, &session, &cause, NULL, 0, NULL, NULL, NULL, NULL, NULL, SOF_NONE, NULL, dl); + fst_requires(status == SWITCH_STATUS_SUCCESS); + fst_requires(session); + fst_xcheck(switch_true(switch_channel_get_variable(switch_core_session_get_channel(session), "is_from_dial_handle_list")), "Expect dial handle list global var to be set on channel"); + fst_xcheck(switch_true(switch_channel_get_variable(switch_core_session_get_channel(session), "expected_winner")), "Wrong winning leg"); + switch_channel_hangup(switch_core_session_get_channel(session), SWITCH_CAUSE_NORMAL_CLEARING); + switch_core_session_rwunlock(session); + switch_dial_handle_list_destroy(&dl); + } + FST_TEST_END() + + FST_SESSION_BEGIN(switch_ivr_enterprise_orig_and_bridge) + { + switch_status_t status; + switch_call_cause_t cause = SWITCH_CAUSE_NONE; + switch_dial_handle_list_t *dl; + switch_dial_handle_t *dh; + switch_dial_leg_list_t *ll; + switch_dial_leg_t *leg = NULL; + + switch_dial_handle_list_create(&dl); + + switch_dial_handle_list_create_handle(dl, &dh); + switch_dial_handle_add_leg_list(dh, &ll); + switch_dial_leg_list_add_leg(ll, &leg, "null/test"); + switch_dial_handle_add_leg_var(leg, "execute_on_answer", "sched_hangup +2 normal_clearing"); + + switch_dial_handle_list_create_handle(dl, &dh); + switch_dial_handle_add_leg_list(dh, &ll); + switch_dial_leg_list_add_leg(ll, &leg, "error/user_busy"); + + switch_dial_handle_list_add_global_var(dl, "continue_on_fail", "true"); + switch_dial_handle_list_add_global_var(dl, "is_from_dial_handle_list", "true"); + + switch_channel_set_variable(fst_channel, "park_after_bridge", "true"); + status = switch_ivr_enterprise_orig_and_bridge(fst_session, NULL, dl, &cause); + fst_xcheck(status == SWITCH_STATUS_SUCCESS, "Expect switch_ivr_enterprise_orig_and_bridge() to succeed"); + fst_xcheck(cause == SWITCH_CAUSE_SUCCESS, "Expect called party to answer"); + switch_dial_handle_list_destroy(&dl); + } + FST_SESSION_END() + + FST_SESSION_BEGIN(switch_ivr_enterprise_orig_and_bridge_fail) + { + switch_status_t status; + switch_call_cause_t cause = SWITCH_CAUSE_NONE; + switch_dial_handle_list_t *dl; + switch_dial_handle_t *dh; + switch_dial_leg_list_t *ll; + switch_dial_leg_t *leg = NULL; + + switch_dial_handle_list_create(&dl); + + switch_dial_handle_list_create_handle(dl, &dh); + switch_dial_handle_add_leg_list(dh, &ll); + switch_dial_leg_list_add_leg(ll, &leg, "error/no_answer"); + + switch_dial_handle_list_create_handle(dl, &dh); + switch_dial_handle_add_leg_list(dh, &ll); + switch_dial_leg_list_add_leg(ll, &leg, "error/user_busy"); + + switch_dial_handle_list_add_global_var(dl, "continue_on_fail", "true"); + + switch_channel_set_variable(fst_channel, "park_after_bridge", "true"); + status = switch_ivr_enterprise_orig_and_bridge(fst_session, NULL, dl, &cause); + fst_xcheck(status == SWITCH_STATUS_FALSE, "Expect switch_ivr_enterprise_orig_and_bridge() to fail"); + fst_xcheck(cause == SWITCH_CAUSE_USER_BUSY || cause == SWITCH_CAUSE_NO_ANSWER, "Expect called party not to answer"); + switch_dial_handle_list_destroy(&dl); + } + FST_SESSION_END() } FST_SUITE_END() }