]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
[mod_valet_parking] Add valet_parking_orbit_exit_key option
authorphonecomwire <62449660+phonecomwire@users.noreply.github.com>
Fri, 24 Apr 2020 22:13:12 +0000 (15:13 -0700)
committerAndrey Volk <andywolk@gmail.com>
Sat, 23 Oct 2021 18:59:54 +0000 (21:59 +0300)
src/mod/applications/mod_valet_parking/mod_valet_parking.c

index 0c95c16265236d8616587d3fb4ef6a375415fc3d..9d8f9e6938fb12fc29ab151ca1365e36060a4a90 100644 (file)
@@ -86,6 +86,34 @@ static switch_status_t valet_on_dtmf(switch_core_session_t *session, void *input
        case SWITCH_INPUT_TYPE_DTMF:
                {
                        switch_dtmf_t *dtmf = (switch_dtmf_t *) input;
+                       switch_channel_t *channel = switch_core_session_get_channel(session);
+                       switch_dtmf_t *exit_key_pvt = (switch_dtmf_t *) switch_channel_get_private(channel, "_orbit_exit_key_");
+
+                       if (dtmf->digit == exit_key_pvt->digit) {
+                               const char *dp;
+                               const char *exten;
+                               const char *context;
+
+                               switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "valet_on_dtmf() - digit pressed '%d' matched valet_parking_orbit_exit_key '%d'\n", dtmf->digit, exit_key_pvt->digit);
+
+                               dp = switch_channel_get_variable(channel, "valet_parking_orbin_dialplan");
+                               if (zstr(dp)) {
+                                       dp = switch_channel_get_variable(channel, "XML");
+                               }
+
+                               context = switch_channel_get_variable(channel, "valet_parking_orbit_context");
+                               if (zstr(context)) {
+                                       context = switch_channel_get_variable(channel, "context");
+                               }
+
+                               exten = switch_channel_get_variable(channel, "valet_parking_orbit_exten");
+                               if (!zstr(exten)) {
+                                       switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "valet_on_dtmf() - transferring session to '%s %s %s'\n", exten, dp, context);
+                                       switch_ivr_session_transfer(session, exten, dp, context);
+                               }
+
+                               return SWITCH_STATUS_BREAK;
+                       }
 
                        if (dtmf->digit == '#') {
                                return SWITCH_STATUS_BREAK;
@@ -433,8 +461,8 @@ SWITCH_STANDARD_APP(valet_parking_function)
                char *dest;
                int in = -1;
 
-               const char *timeout, *orbit_exten, *orbit_dialplan, *orbit_context;
-               char *timeout_str = "", *orbit_exten_str = "", *orbit_dialplan_str = "", *orbit_context_str = "";
+               const char *timeout, *orbit_exten, *orbit_dialplan, *orbit_context, *orbit_exit_key;
+               char *timeout_str = "", *orbit_exten_str = "", *orbit_dialplan_str = "", *orbit_context_str = "", *orbit_exit_key_str = "";
 
                lot = valet_find_lot(lot_name, SWITCH_TRUE);
                switch_assert(lot);
@@ -606,16 +634,23 @@ SWITCH_STANDARD_APP(valet_parking_function)
                        orbit_context_str = switch_core_session_sprintf(session, "set:valet_parking_orbit_context=%s,", orbit_context);
                }
 
+               if ((orbit_exit_key = switch_channel_get_variable(channel, "valet_parking_orbit_exit_key"))) {
+                       orbit_exit_key_str = switch_core_session_sprintf(session, "set:valet_parking_orbit_exit_key=%s,", orbit_exit_key);
+
+                       switch_channel_set_private(channel, "_orbit_exit_key_", orbit_exit_key);
+               }
+
                if ((timeout = switch_channel_get_variable(channel, "valet_parking_timeout"))) {
                        timeout_str = switch_core_session_sprintf(session, "set:valet_parking_timeout=%s,", timeout);
                }
 
-               dest = switch_core_session_sprintf(session, "%s%s%s%s"
+               dest = switch_core_session_sprintf(session, "%s%s%s%s%s"
                                                                                   "set:valet_ticket=%s,set:valet_hold_music='%s',sleep:1000,valet_park:%s %s",
                                                                                   timeout_str,
                                                                                   orbit_exten_str,
                                                                                   orbit_dialplan_str,
                                                                                   orbit_context_str,
+                                                                                  orbit_exit_key_str,
                                                                                   token->uuid, music, lot_name, ext);
                switch_channel_set_variable(channel, "inline_destination", dest);