[Asterisk-code-review] features, manager : Add CancelAtxfer AMI action (asterisk[13])
Thomas Sevestre
asteriskteam at digium.com
Fri Aug 25 08:20:22 CDT 2017
Thomas Sevestre has uploaded this change for review. ( https://gerrit.asterisk.org/6307
Change subject: features, manager : Add CancelAtxfer AMI action
......................................................................
features, manager : Add CancelAtxfer AMI action
Add action to cancel feature attended transfer with AMI interface
Change-Id: Iab8a81362b5a1757e2608f70b014ef863200cb42
---
M include/asterisk/features_config.h
M main/features_config.c
M main/manager.c
3 files changed, 73 insertions(+), 0 deletions(-)
git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/07/6307/1
diff --git a/include/asterisk/features_config.h b/include/asterisk/features_config.h
index baaff18..1bce50b 100644
--- a/include/asterisk/features_config.h
+++ b/include/asterisk/features_config.h
@@ -117,6 +117,21 @@
char *ast_get_chan_features_xferfailsound(struct ast_channel *chan);
/*!
+ * \brief Get the transfer configuration option atxferabort
+ *
+ * \note The channel should be locked before calling this function.
+ * \note The returned value has to be freed.
+ *
+ * If no channel is provided, then option is pulled from the global
+ * transfer configuration.
+ *
+ * \param chan The channel to get configuration options for
+ * \retval NULL Failed to get configuration
+ * \retval non-NULL The atxferabort
+ */
+char *ast_get_chan_features_atxferabort(struct ast_channel *chan);
+
+/*!
* \brief Configuration relating to call pickup
*/
struct ast_features_pickup_config {
diff --git a/main/features_config.c b/main/features_config.c
index 4a86f4b..2689687 100644
--- a/main/features_config.c
+++ b/main/features_config.c
@@ -1173,6 +1173,21 @@
return res;
}
+char *ast_get_chan_features_atxferabort(struct ast_channel *chan)
+{
+ char *res;
+ struct ast_features_xfer_config *cfg = ast_get_chan_features_xfer_config(chan);
+
+ if (!cfg) {
+ return NULL;
+ }
+
+ res = ast_strdup(cfg->atxferabort);
+ ao2_ref(cfg, -1);
+
+ return res;
+}
+
struct ast_features_pickup_config *ast_get_chan_features_pickup_config(struct ast_channel *chan)
{
RAII_VAR(struct features_config *, cfg, NULL, ao2_cleanup);
diff --git a/main/manager.c b/main/manager.c
index 17057b3..2a7f7fb 100644
--- a/main/manager.c
+++ b/main/manager.c
@@ -4930,6 +4930,47 @@
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;
@@ -8665,6 +8706,7 @@
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");
@@ -8880,6 +8922,7 @@
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);
--
To view, visit https://gerrit.asterisk.org/6307
To unsubscribe, visit https://gerrit.asterisk.org/settings
Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-MessageType: newchange
Gerrit-Change-Id: Iab8a81362b5a1757e2608f70b014ef863200cb42
Gerrit-Change-Number: 6307
Gerrit-PatchSet: 1
Gerrit-Owner: Thomas Sevestre <thomassevestre at free.fr>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20170825/72fe8fef/attachment.html>
More information about the asterisk-code-review
mailing list