]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
[core] add new prompt functionality to ask for pin over dialogbox
authorAnthony Minessale <anthm@signalwire.com>
Fri, 10 Apr 2020 16:48:24 +0000 (16:48 +0000)
committerAndrey Volk <andywolk@gmail.com>
Sat, 23 Oct 2021 19:00:00 +0000 (22:00 +0300)
src/include/switch_ivr.h
src/include/switch_types.h
src/mod/endpoints/mod_verto/mod_verto.c
src/switch_core_session.c
src/switch_ivr.c

index 09577152b45212f03c55df9187e4e5f229069d1b..318ce262141efe00caa0796c5be99686baea6883 100644 (file)
@@ -1069,7 +1069,8 @@ SWITCH_DECLARE(void) switch_dial_handle_list_add_global_var(switch_dial_handle_l
 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_send_prompt(switch_core_session_t *session, const char *type, const char *text, const char *regex);
+                                                               
 SWITCH_DECLARE(switch_status_t) switch_ivr_play_and_collect_input(switch_core_session_t *session,
                                                                                                                        const char *prompt,
                                                                                                                        const char *recognizer_mod_name,
index 7217a207a4997476a7d413702ef62d1c644667e7..69e87f4aff0db2dfe4f685b401d2e091d78e03af 100644 (file)
@@ -1173,6 +1173,7 @@ typedef enum {
        SWITCH_MESSAGE_RESAMPLE_EVENT,
        SWITCH_MESSAGE_HEARTBEAT_EVENT,
        SWITCH_MESSAGE_INDICATE_SESSION_ID,
+       SWITCH_MESSAGE_INDICATE_PROMPT,
        SWITCH_MESSAGE_INVALID
 } switch_core_session_message_types_t;
 
index e12cc99677ee1ccb5c70173ccfc9a007e1460d15..230d0ff6155d6c5d3b7def142f7a019fceccf7e3 100644 (file)
@@ -2623,6 +2623,40 @@ static switch_status_t messagehook (switch_core_session_t *session, switch_core_
 
                }
                break;
+       case SWITCH_MESSAGE_INDICATE_PROMPT:
+               {
+                       const char *type = NULL, *text = NULL, *regex = NULL;
+                       cJSON *jmsg = NULL, *params = NULL;
+                       jsock_t *jsock = NULL;
+                       
+                       if ((jsock = get_jsock(tech_pvt->jsock_uuid))) {
+                               
+                               type = msg->string_array_arg[0];
+                               text = msg->string_array_arg[1];
+                               regex = msg->string_array_arg[2];
+
+                               if (type && (!strcasecmp(type, "dtmf") || !strcasecmp(type, "message")) && text) {
+                                       jmsg = jrpc_new_req("verto.prompt", tech_pvt->call_id, &params);
+
+                                       cJSON_AddItemToObject(params, "type", cJSON_CreateString(type));
+                                       cJSON_AddItemToObject(params, "text", cJSON_CreateString(text));
+
+                                       if (regex) {
+                                               cJSON_AddItemToObject(params, "regex", cJSON_CreateString(regex));
+                                       }
+
+                                       jsock_queue_event(jsock, &jmsg, SWITCH_TRUE);
+                                               
+                               } else {
+                                       switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Error Parsing Media Params\n");
+                                       r = SWITCH_STATUS_FALSE;
+                               }
+                               
+
+                               switch_thread_rwlock_unlock(jsock->rwlock);
+                       }
+               }
+               break;
        case SWITCH_MESSAGE_INDICATE_MEDIA_RENEG:
                {
                        jsock_t *jsock = NULL;
index 2258824159a2c18a187f9438c46f550131a89a0c..4440da639d5b5ca42236fde93d8721ae61437d17 100644 (file)
@@ -827,6 +827,8 @@ static const char *message_names[] = {
        "RING_EVENT",
        "RESAMPLE_EVENT",
        "HEARTBEAT_EVENT",
+       "SESSION_ID",
+       "PROMPT",
        "INVALID"
 };
 
index 97bece7c36a91c2dd77b7c8866b7a837f78b1c22..ba292376f018b1209a32985e76ca9040b5b62f96 100644 (file)
@@ -1506,6 +1506,22 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_collect_digits_count(switch_core_sess
        return status;
 }
 
+
+SWITCH_DECLARE(switch_status_t) switch_ivr_send_prompt(switch_core_session_t *session, const char *type, const char *text, const char *regex)
+{
+       switch_core_session_message_t msg = { 0 };
+       
+       msg.message_id = SWITCH_MESSAGE_INDICATE_PROMPT;
+       msg.string_array_arg[0] = type;
+       msg.string_array_arg[1] = text;
+       msg.string_array_arg[2] = regex;
+       msg.from = __FILE__;
+
+       switch_core_session_receive_message(session, &msg);
+
+       return SWITCH_STATUS_SUCCESS;
+}
+
 SWITCH_DECLARE(switch_status_t) switch_ivr_hold(switch_core_session_t *session, const char *message, switch_bool_t moh)
 {
        switch_core_session_message_t msg = { 0 };