summaryrefslogtreecommitdiff
path: root/main/pbx.c
diff options
context:
space:
mode:
authorMatthew Jordan <mjordan@digium.com>2013-05-24 20:44:07 +0000
committerMatthew Jordan <mjordan@digium.com>2013-05-24 20:44:07 +0000
commit06be8463b683333c79845402d55168ef1b582fa9 (patch)
tree2fe0871cfec4d5edf3aae763541ff7efa32a444a /main/pbx.c
parentc1b51fd2654736fd7c614d1571f904e236006651 (diff)
Migrate a large number of AMI events over to Stasis-Core
This patch moves a number of AMI events over to the Stasis-Core message bus. This includes: * ChanSpyStart/Stop * MonitorStart/Stop * MusicOnHoldStart/Stop * FullyBooted/Reload * All Voicemail/MWI related events In addition, it adds some Stasis-Core and AMI support for generic AMI messages, refactors the message router in AMI to use a single router with topic forwarding for the topics that AMI cares about, and refactors MWI message types and topics to be more name compliant. Review: https://reviewboard.asterisk.org/r/2532 (closes issue ASTERISK-21462) git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@389733 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main/pbx.c')
-rw-r--r--main/pbx.c94
1 files changed, 27 insertions, 67 deletions
diff --git a/main/pbx.c b/main/pbx.c
index 8408048f2..1c26a9c10 100644
--- a/main/pbx.c
+++ b/main/pbx.c
@@ -5769,6 +5769,30 @@ void ast_pbx_h_exten_run(struct ast_channel *chan, const char *context)
ast_channel_unlock(chan);
}
+/*!
+ * \internal
+ * \brief Publish a hangup handler related message to \ref stasis
+ */
+static void publish_hangup_handler_message(const char *action, struct ast_channel *chan, const char *handler)
+{
+ RAII_VAR(struct ast_json *, blob, NULL, ast_json_unref);
+ RAII_VAR(struct stasis_message *, message, NULL, ao2_cleanup);
+
+ blob = ast_json_pack("{s: s, s: s}",
+ "type", action,
+ "handler", S_OR(handler, ""));
+ if (!blob) {
+ return;
+ }
+
+ message = ast_channel_blob_create(chan, ast_channel_hangup_handler_type(), blob);
+ if (!message) {
+ return;
+ }
+
+ stasis_publish(ast_channel_topic(chan), message);
+}
+
int ast_pbx_hangup_handler_run(struct ast_channel *chan)
{
struct ast_hangup_handler_list *handlers;
@@ -5798,23 +5822,7 @@ int ast_pbx_hangup_handler_run(struct ast_channel *chan)
break;
}
- /*** DOCUMENTATION
- <managerEventInstance>
- <synopsis>Raised when a hangup handler is about to be called.</synopsis>
- <syntax>
- <parameter name="Handler">
- <para>Hangup handler parameter string passed to the Gosub application.</para>
- </parameter>
- </syntax>
- </managerEventInstance>
- ***/
- manager_event(EVENT_FLAG_DIALPLAN, "HangupHandlerRun",
- "Channel: %s\r\n"
- "Uniqueid: %s\r\n"
- "Handler: %s\r\n",
- ast_channel_name(chan),
- ast_channel_uniqueid(chan),
- h_handler->args);
+ publish_hangup_handler_message("run", chan, h_handler->args);
ast_channel_unlock(chan);
ast_app_exec_sub(NULL, chan, h_handler->args, 1);
@@ -5859,30 +5867,7 @@ int ast_pbx_hangup_handler_pop(struct ast_channel *chan)
handlers = ast_channel_hangup_handlers(chan);
h_handler = AST_LIST_REMOVE_HEAD(handlers, node);
if (h_handler) {
- /*** DOCUMENTATION
- <managerEventInstance>
- <synopsis>
- Raised when a hangup handler is removed from the handler
- stack by the CHANNEL() function.
- </synopsis>
- <syntax>
- <parameter name="Handler">
- <para>Hangup handler parameter string passed to the Gosub application.</para>
- </parameter>
- </syntax>
- <see-also>
- <ref type="managerEvent">HangupHandlerPush</ref>
- <ref type="function">CHANNEL</ref>
- </see-also>
- </managerEventInstance>
- ***/
- manager_event(EVENT_FLAG_DIALPLAN, "HangupHandlerPop",
- "Channel: %s\r\n"
- "Uniqueid: %s\r\n"
- "Handler: %s\r\n",
- ast_channel_name(chan),
- ast_channel_uniqueid(chan),
- h_handler->args);
+ publish_hangup_handler_message("pop", chan, h_handler->args);
}
ast_channel_unlock(chan);
if (h_handler) {
@@ -5918,32 +5903,7 @@ void ast_pbx_hangup_handler_push(struct ast_channel *chan, const char *handler)
handlers = ast_channel_hangup_handlers(chan);
AST_LIST_INSERT_HEAD(handlers, h_handler, node);
-
- /*** DOCUMENTATION
- <managerEventInstance>
- <synopsis>
- Raised when a hangup handler is added to the handler
- stack by the CHANNEL() function.
- </synopsis>
- <syntax>
- <parameter name="Handler">
- <para>Hangup handler parameter string passed to the Gosub application.</para>
- </parameter>
- </syntax>
- <see-also>
- <ref type="managerEvent">HangupHandlerPop</ref>
- <ref type="function">CHANNEL</ref>
- </see-also>
- </managerEventInstance>
- ***/
- manager_event(EVENT_FLAG_DIALPLAN, "HangupHandlerPush",
- "Channel: %s\r\n"
- "Uniqueid: %s\r\n"
- "Handler: %s\r\n",
- ast_channel_name(chan),
- ast_channel_uniqueid(chan),
- h_handler->args);
-
+ publish_hangup_handler_message("push", chan, h_handler->args);
ast_channel_unlock(chan);
}