[asterisk-commits] rmudgett: branch rmudgett/hangup_handlers r369182 - in /team/rmudgett/hangup_...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Jun 21 18:30:49 CDT 2012


Author: rmudgett
Date: Thu Jun 21 18:30:47 2012
New Revision: 369182

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=369182
Log:
Commit current hangup handler work.

* Replace CHANNEL(hangup_handler) with CHANNEL(hangup_handler_pop), 
CHANNEL(hangup_handler_push), and CHANNEL(hangup_handler_replace).

* Replaced AMI event HangupHandlerAdd with HangupHandlerPush.

* Added AMI event HangupHandlerPop

Needs more testing and bridge peer calling hangup handlers where needed.

Modified:
    team/rmudgett/hangup_handlers/channels/chan_local.c
    team/rmudgett/hangup_handlers/funcs/func_channel.c
    team/rmudgett/hangup_handlers/include/asterisk/pbx.h
    team/rmudgett/hangup_handlers/main/pbx.c

Modified: team/rmudgett/hangup_handlers/channels/chan_local.c
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/hangup_handlers/channels/chan_local.c?view=diff&rev=369182&r1=369181&r2=369182
==============================================================================
--- team/rmudgett/hangup_handlers/channels/chan_local.c (original)
+++ team/rmudgett/hangup_handlers/channels/chan_local.c Thu Jun 21 18:30:47 2012
@@ -239,8 +239,8 @@
 	}
 
 	if (!strcmp(write_info->function, "CHANNEL")
-		&& !strcasecmp(write_info->data, "hangup_handler")) {
-		/* Block CHANNEL(hangup_handler) writes to the other local channel. */
+		&& !strncasecmp(write_info->data, "hangup_handler_", 15)) {
+		/* Block CHANNEL(hangup_handler_xxx) writes to the other local channel. */
 		return 0;
 	}
 

Modified: team/rmudgett/hangup_handlers/funcs/func_channel.c
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/hangup_handlers/funcs/func_channel.c?view=diff&rev=369182&r1=369181&r2=369182
==============================================================================
--- team/rmudgett/hangup_handlers/funcs/func_channel.c (original)
+++ team/rmudgett/hangup_handlers/funcs/func_channel.c Thu Jun 21 18:30:47 2012
@@ -98,12 +98,28 @@
 					<enum name="checkhangup">
 						<para>R/O Whether the channel is hanging up (1/0)</para>
 					</enum>
-					<enum name="hangup_handler">
-						<para>W/O Add a hangup handler to the channel.  The
+					<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
 						assigned string is passed to the Gosub application when
 						the channel is hung up.  Any optionally omitted context
-						and exten are supplied by the channel adding the handler
-						before it is saved.</para>
+						and exten are supplied by the channel pushing the handler
+						before it is pushed.</para>
+					</enum>
+					<enum name="hangup_handler_push">
+						<para>W/O Push a hangup handler onto the channel hangup
+						handler stack.  The assigned string is passed to the
+						Gosub application when the channel is hung up.  Any
+						optionally omitted context and exten are supplied by the
+						channel pushing the handler before it is pushed.</para>
+					</enum>
+					<enum name="hangup_handler_replace">
+						<para>W/O Replace the entire hangup handler stack
+						with a new hangup handler on the channel if supplied.  The
+						assigned string is passed to the Gosub application when
+						the channel is hung up.  Any optionally omitted context
+						and exten are supplied by the channel pushing the handler
+						before it is pushed.</para>
 					</enum>
 					<enum name="language">
 						<para>R/W language for sounds played.</para>
@@ -530,8 +546,17 @@
 				break;
 			}
 		}
-	} else if (!strcasecmp(data, "hangup_handler")) {
-		ast_pbx_hangup_handler_add(chan, value);
+	} else if (!strcasecmp(data, "hangup_handler_pop")) {
+		/* Pop one hangup handler before pushing the new handler. */
+		ast_pbx_hangup_handler_pop(chan);
+		ast_pbx_hangup_handler_push(chan, value);
+	} else if (!strcasecmp(data, "hangup_handler_push")) {
+		ast_pbx_hangup_handler_push(chan, value);
+	} else if (!strcasecmp(data, "hangup_handler_replace")) {
+		/* Pop all hangup handlers before pushing the new handler. */
+		while (ast_pbx_hangup_handler_pop(chan)) {
+		}
+		ast_pbx_hangup_handler_push(chan, value);
 	} else if (!strncasecmp(data, "secure_bridge_", 14)) {
 		struct ast_datastore *ds;
 		struct ast_secure_call_store *store;

Modified: team/rmudgett/hangup_handlers/include/asterisk/pbx.h
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/hangup_handlers/include/asterisk/pbx.h?view=diff&rev=369182&r1=369181&r2=369182
==============================================================================
--- team/rmudgett/hangup_handlers/include/asterisk/pbx.h (original)
+++ team/rmudgett/hangup_handlers/include/asterisk/pbx.h Thu Jun 21 18:30:47 2012
@@ -412,15 +412,25 @@
 void ast_pbx_hangup_handler_destroy(struct ast_channel *chan);
 
 /*!
- * \brief Add the given hangup handler to the channel.
+ * \brief Pop the top of the channel hangup handler stack.
  * \since 11.0
  *
- * \param chan Channel to add the hangup handler to.
+ * \param chan Channel to push the hangup handler onto.
+ *
+ * \retval TRUE if a handler was popped off of the stack.
+ */
+int ast_pbx_hangup_handler_pop(struct ast_channel *chan);
+
+/*!
+ * \brief Push the given hangup handler onto the channel hangup handler stack.
+ * \since 11.0
+ *
+ * \param chan Channel to push the hangup handler onto.
  * \param handler Gosub application parameter string.
  *
  * \return Nothing
  */
-void ast_pbx_hangup_handler_add(struct ast_channel *chan, const char *handler);
+void ast_pbx_hangup_handler_push(struct ast_channel *chan, const char *handler);
 
 /*!
  * \brief Add and extension to an extension context.

Modified: team/rmudgett/hangup_handlers/main/pbx.c
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/hangup_handlers/main/pbx.c?view=diff&rev=369182&r1=369181&r2=369182
==============================================================================
--- team/rmudgett/hangup_handlers/main/pbx.c (original)
+++ team/rmudgett/hangup_handlers/main/pbx.c Thu Jun 21 18:30:47 2012
@@ -5474,7 +5474,32 @@
 	ast_channel_unlock(chan);
 }
 
-void ast_pbx_hangup_handler_add(struct ast_channel *chan, const char *handler)
+int ast_pbx_hangup_handler_pop(struct ast_channel *chan)
+{
+	struct ast_hangup_handler_list *handlers;
+	struct ast_hangup_handler *h_handler;
+
+	ast_channel_lock(chan);
+	handlers = ast_channel_hangup_handlers(chan);
+	h_handler = AST_LIST_REMOVE_HEAD(handlers, node);
+	if (h_handler) {
+		manager_event(EVENT_FLAG_CALL, "HangupHandlerPop",
+			"Channel: %s\r\n"
+			"Uniqueid: %s\r\n"
+			"Handler: %s\r\n",
+			ast_channel_name(chan),
+			ast_channel_uniqueid(chan),
+			h_handler->args);
+	}
+	ast_channel_unlock(chan);
+	if (h_handler) {
+		ast_free(h_handler);
+		return 1;
+	}
+	return 0;
+}
+
+void ast_pbx_hangup_handler_push(struct ast_channel *chan, const char *handler)
 {
 	struct ast_hangup_handler_list *handlers;
 	struct ast_hangup_handler *h_handler;
@@ -5501,7 +5526,7 @@
 	handlers = ast_channel_hangup_handlers(chan);
 	AST_LIST_INSERT_HEAD(handlers, h_handler, node);
 
-	manager_event(EVENT_FLAG_CALL, "HangupHandlerAdd",
+	manager_event(EVENT_FLAG_CALL, "HangupHandlerPush",
 		"Channel: %s\r\n"
 		"Uniqueid: %s\r\n"
 		"Handler: %s\r\n",




More information about the asterisk-commits mailing list