From eadea6f55b5780f53d3bcf981358612be45b1651 Mon Sep 17 00:00:00 2001 From: Thomas Sevestre Date: Fri, 25 Aug 2017 13:19:00 +0000 Subject: features, manager : Add CancelAtxfer AMI action Add action to cancel feature attended transfer with AMI interface ASTERISK-27215 #close Change-Id: Iab8a81362b5a1757e2608f70b014ef863200cb42 --- main/manager.c | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) (limited to 'main/manager.c') diff --git a/main/manager.c b/main/manager.c index e67efe3f3..5c0b318b9 100644 --- a/main/manager.c +++ b/main/manager.c @@ -628,6 +628,25 @@ AttendedTransfer + + + Cancel an attended transfer. + + + + + The transferer channel. + + + + Cancel an attended transfer. Note, this uses the configured cancel attended transfer + feature option (atxferabort) to cancel the transfer. If not available this action will fail. + + + + AttendedTransfer + + Originate a call. @@ -4959,6 +4978,47 @@ static int action_atxfer(struct mansession *s, const struct message *m) return 0; } +static int action_cancel_atxfer(struct mansession *s, const struct message *m) +{ + const char *name = astman_get_header(m, "Channel"); + struct ast_channel *chan = NULL; + char *feature_code; + const char *digit; + + if (ast_strlen_zero(name)) { + astman_send_error(s, m, "No channel specified"); + return 0; + } + + if (!(chan = ast_channel_get_by_name(name))) { + astman_send_error(s, m, "Channel specified does not exist"); + return 0; + } + + ast_channel_lock(chan); + feature_code = ast_get_chan_features_atxferabort(chan); + ast_channel_unlock(chan); + + if (!feature_code) { + astman_send_error(s, m, "No disconnect feature code found"); + ast_channel_unref(chan); + return 0; + } + + for (digit = feature_code; *digit; ++digit) { + struct ast_frame f = { AST_FRAME_DTMF, .subclass.integer = *digit }; + ast_queue_frame(chan, &f); + } + ast_free(feature_code); + + chan = ast_channel_unref(chan); + + astman_send_ack(s, m, "CancelAtxfer successfully queued"); + + return 0; +} + + static int check_blacklist(const char *cmd) { char *cmd_copy, *cur_cmd; @@ -8679,6 +8739,7 @@ static void manager_shutdown(void) ast_manager_unregister("ListCategories"); ast_manager_unregister("Redirect"); ast_manager_unregister("Atxfer"); + ast_manager_unregister("CancelAtxfer"); ast_manager_unregister("Originate"); ast_manager_unregister("Command"); ast_manager_unregister("ExtensionState"); @@ -8894,6 +8955,7 @@ static int __init_manager(int reload, int by_external_config) ast_manager_register_xml_core("ListCategories", EVENT_FLAG_CONFIG, action_listcategories); ast_manager_register_xml_core("Redirect", EVENT_FLAG_CALL, action_redirect); ast_manager_register_xml_core("Atxfer", EVENT_FLAG_CALL, action_atxfer); + ast_manager_register_xml_core("CancelAtxfer", EVENT_FLAG_CALL, action_cancel_atxfer); ast_manager_register_xml_core("Originate", EVENT_FLAG_ORIGINATE, action_originate); ast_manager_register_xml_core("Command", EVENT_FLAG_COMMAND, action_command); ast_manager_register_xml_core("ExtensionState", EVENT_FLAG_CALL | EVENT_FLAG_REPORTING, action_extensionstate); -- cgit v1.2.3