[asterisk-commits] jrose: trunk r393005 - in /trunk: funcs/ include/asterisk/ main/
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Wed Jun 26 15:59:19 CDT 2013
Author: jrose
Date: Wed Jun 26 15:59:14 2013
New Revision: 393005
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=393005
Log:
func_channel: Read/Write after_bridge_goto option
Allows reading and setting of a channel's after_bridge_goto datastore
(closes issue ASTERISK-21875)
Reported by: Matt Jordan
Review: https://reviewboard.asterisk.org/r/2628/
Modified:
trunk/funcs/func_channel.c
trunk/include/asterisk/bridging.h
trunk/main/bridging.c
Modified: trunk/funcs/func_channel.c
URL: http://svnview.digium.com/svn/asterisk/trunk/funcs/func_channel.c?view=diff&rev=393005&r1=393004&r2=393005
==============================================================================
--- trunk/funcs/func_channel.c (original)
+++ trunk/funcs/func_channel.c Wed Jun 26 15:59:14 2013
@@ -37,6 +37,7 @@
#include "asterisk/module.h"
#include "asterisk/channel.h"
+#include "asterisk/bridging.h"
#include "asterisk/pbx.h"
#include "asterisk/utils.h"
#include "asterisk/app.h"
@@ -118,6 +119,12 @@
<enum name="checkhangup">
<para>R/O Whether the channel is hanging up (1/0)</para>
</enum>
+ <enum name="after_bridge_goto">
+ <para>R/W the parseable goto string indicating where the channel is
+ expected to return to in the PBX after exiting the next bridge it joins
+ on the condition that it doesn't hang up. The parseable goto string uses
+ the same syntax as the <literal>Goto</literal> application.</para>
+ </enum>
<enum name="hangup_handler_pop">
<para>W/O Replace the most recently added hangup handler
with a new hangup handler on the channel if supplied. The
@@ -475,6 +482,8 @@
struct ast_str *tmp_str = ast_str_alloca(1024);
locked_copy_string(chan, buf, ast_print_namedgroups(&tmp_str, ast_channel_named_pickupgroups(chan)), len);
+ } else if (!strcasecmp(data, "after_bridge_goto")) {
+ ast_after_bridge_goto_read(chan, buf, len);
} else if (!strcasecmp(data, "amaflags")) {
ast_channel_lock(chan);
snprintf(buf, len, "%d", ast_channel_amaflags(chan));
@@ -516,7 +525,13 @@
locked_string_field_set(chan, accountcode, value);
else if (!strcasecmp(data, "userfield"))
locked_string_field_set(chan, userfield, value);
- else if (!strcasecmp(data, "amaflags")) {
+ else if (!strcasecmp(data, "after_bridge_goto")) {
+ if (ast_strlen_zero(value)) {
+ ast_after_bridge_goto_discard(chan);
+ } else {
+ ast_after_bridge_set_go_on(chan, ast_channel_context(chan), ast_channel_exten(chan), ast_channel_priority(chan), value);
+ }
+ } else if (!strcasecmp(data, "amaflags")) {
ast_channel_lock(chan);
if (isdigit(*value)) {
int amaflags;
Modified: trunk/include/asterisk/bridging.h
URL: http://svnview.digium.com/svn/asterisk/trunk/include/asterisk/bridging.h?view=diff&rev=393005&r1=393004&r2=393005
==============================================================================
--- trunk/include/asterisk/bridging.h (original)
+++ trunk/include/asterisk/bridging.h Wed Jun 26 15:59:14 2013
@@ -1634,6 +1634,16 @@
*/
void ast_after_bridge_goto_discard(struct ast_channel *chan);
+/*!
+ * \brief Read after bridge goto if it exists
+ * \since 12.0.0
+ *
+ * \param chan Channel to read the after bridge goto parseable goto string from
+ * \param buffer Buffer to write the after bridge goto data to
+ * \param buf_size size of the buffer being written to
+ */
+void ast_after_bridge_goto_read(struct ast_channel *chan, char *buffer, size_t buf_size);
+
/*! Reason the the after bridge callback will not be called. */
enum ast_after_bridge_cb_reason {
/*! The datastore is being destroyed. Likely due to hangup. */
Modified: trunk/main/bridging.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/bridging.c?view=diff&rev=393005&r1=393004&r2=393005
==============================================================================
--- trunk/main/bridging.c (original)
+++ trunk/main/bridging.c Wed Jun 26 15:59:14 2013
@@ -3414,6 +3414,47 @@
}
}
+void ast_after_bridge_goto_read(struct ast_channel *chan, char *buffer, size_t buf_size)
+{
+ struct ast_datastore *datastore;
+ struct after_bridge_goto_ds *after_bridge;
+ char *current_pos = buffer;
+ size_t remaining_size = buf_size;
+
+ SCOPED_CHANNELLOCK(lock, chan);
+
+ datastore = ast_channel_datastore_find(chan, &after_bridge_goto_info, NULL);
+ if (!datastore) {
+ buffer[0] = '\0';
+ return;
+ }
+
+ after_bridge = datastore->data;
+
+ if (after_bridge->parseable_goto) {
+ snprintf(buffer, buf_size, "%s", after_bridge->parseable_goto);
+ return;
+ }
+
+ if (!ast_strlen_zero(after_bridge->context)) {
+ snprintf(current_pos, remaining_size, "%s,", after_bridge->context);
+ remaining_size = remaining_size - strlen(current_pos);
+ current_pos += strlen(current_pos);
+ }
+
+ if (after_bridge->run_h_exten) {
+ snprintf(current_pos, remaining_size, "h,");
+ remaining_size = remaining_size - strlen(current_pos);
+ current_pos += strlen(current_pos);
+ } else if (!ast_strlen_zero(after_bridge->exten)) {
+ snprintf(current_pos, remaining_size, "%s,", after_bridge->exten);
+ remaining_size = remaining_size - strlen(current_pos);
+ current_pos += strlen(current_pos);
+ }
+
+ snprintf(current_pos, remaining_size, "%d", after_bridge->priority);
+}
+
int ast_after_bridge_goto_setup(struct ast_channel *chan)
{
struct ast_datastore *datastore;
@@ -3479,6 +3520,10 @@
after_bridge->exten, after_bridge->priority + 1);
}
if (!goto_failed) {
+ if (ast_test_flag(ast_channel_flags(chan), AST_FLAG_IN_AUTOLOOP)) {
+ ast_channel_priority_set(chan, ast_channel_priority(chan) + 1);
+ }
+
ast_debug(1, "Setup after bridge goto location to %s,%s,%d.\n",
ast_channel_context(chan),
ast_channel_exten(chan),
More information about the asterisk-commits
mailing list