[asterisk-commits] kmoore: branch kmoore/channel_event_refactor r391595 - /team/kmoore/channel_e...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Wed Jun 12 23:27:48 CDT 2013
Author: kmoore
Date: Wed Jun 12 23:27:46 2013
New Revision: 391595
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=391595
Log:
Refactor and document DAHDIChannel and correct some doxygen copypasta
Modified:
team/kmoore/channel_event_refactor/channels/chan_agent.c
team/kmoore/channel_event_refactor/channels/chan_dahdi.c
team/kmoore/channel_event_refactor/channels/chan_gtalk.c
team/kmoore/channel_event_refactor/channels/sig_pri.c
Modified: team/kmoore/channel_event_refactor/channels/chan_agent.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/channel_event_refactor/channels/chan_agent.c?view=diff&rev=391595&r1=391594&r2=391595
==============================================================================
--- team/kmoore/channel_event_refactor/channels/chan_agent.c (original)
+++ team/kmoore/channel_event_refactor/channels/chan_agent.c Wed Jun 12 23:27:46 2013
@@ -1922,7 +1922,6 @@
.to_ami = login_to_ami,
);
-/*! \brief Sends a session timeout channel blob used to produce SessionTimeout AMI messages */
static void send_agent_login(struct ast_channel *chan, const char *agent)
{
RAII_VAR(struct ast_json *, blob, NULL, ast_json_unref);
@@ -1962,7 +1961,6 @@
.to_ami = logoff_to_ami,
);
-/*! \brief Sends a session timeout channel blob used to produce SessionTimeout AMI messages */
static void send_agent_logoff(struct ast_channel *chan, const char *agent, long logintime)
{
RAII_VAR(struct ast_json *, blob, NULL, ast_json_unref);
Modified: team/kmoore/channel_event_refactor/channels/chan_dahdi.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/channel_event_refactor/channels/chan_dahdi.c?view=diff&rev=391595&r1=391594&r2=391595
==============================================================================
--- team/kmoore/channel_event_refactor/channels/chan_dahdi.c (original)
+++ team/kmoore/channel_event_refactor/channels/chan_dahdi.c Wed Jun 12 23:27:46 2013
@@ -133,6 +133,7 @@
#include "asterisk/data.h"
#include "asterisk/features_config.h"
#include "asterisk/bridging.h"
+#include "asterisk/stasis_channels.h"
/*** DOCUMENTATION
<application name="DAHDISendKeypadFacility" language="en_US">
@@ -356,6 +357,20 @@
</parameter>
<parameter name="Alarm">
<para>A textual description of the alarm that occurred.</para>
+ </parameter>
+ </syntax>
+ </managerEventInstance>
+ </managerEvent>
+ <managerEvent language="en_US" name="DAHDIChannel">
+ <managerEventInstance class="EVENT_FLAG_CALL">
+ <synopsis>Raised when a DAHDI channel is created or an underlying technology is associated with a DAHDI channel.</synopsis>
+ <syntax>
+ <xi:include xpointer="xpointer(/docs/managerEvent[@name='Newchannel']/managerEventInstance/syntax/parameter)" />
+ <parameter name="DAHDISpan">
+ <para>The DAHDI span associated with this channel.</para>
+ </parameter>
+ <parameter name="DAHDIChannel">
+ <para>The DAHDI channel associated with this channel.</para>
</parameter>
</syntax>
</managerEventInstance>
@@ -2334,6 +2349,50 @@
DEADLOCK_AVOIDANCE(&p->lock);
}
+static struct ast_manager_event_blob *dahdichannel_to_ami(struct stasis_message *msg)
+{
+ RAII_VAR(struct ast_str *, channel_string, NULL, ast_free);
+ struct ast_channel_blob *obj = stasis_message_data(msg);
+ struct ast_json *span, *channel;
+
+ channel_string = ast_manager_build_channel_state_string(obj->snapshot);
+ if (!channel_string) {
+ return NULL;
+ }
+
+ span = ast_json_object_get(obj->blob, "span");
+ channel = ast_json_object_get(obj->blob, "channel");
+
+ return ast_manager_event_blob_create(EVENT_FLAG_CALL, "DAHDIChannel",
+ "%s"
+ "DAHDISpan: %d\r\n"
+ "DAHDIChannel: %s\r\n",
+ ast_str_buffer(channel_string),
+ (unsigned int)ast_json_integer_get(span),
+ ast_json_string_get(channel));
+}
+
+STASIS_MESSAGE_TYPE_DEFN_LOCAL(dahdichannel_type,
+ .to_ami = dahdichannel_to_ami,
+ );
+
+/*! \brief Sends a DAHDIChannel channel blob used to produce DAHDIChannel AMI messages */
+static void publish_dahdichannel(struct ast_channel *chan, int span, const char *dahdi_channel)
+{
+ RAII_VAR(struct ast_json *, blob, NULL, ast_json_unref);
+
+ ast_assert(dahdi_channel != NULL);
+
+ blob = ast_json_pack("{s: i, s: s}",
+ "span", span,
+ "channel", dahdi_channel);
+ if (!blob) {
+ return;
+ }
+
+ ast_channel_publish_blob(chan, dahdichannel_type(), blob);
+}
+
/*!
* \internal
* \brief Post an AMI DAHDI channel association event.
@@ -2358,20 +2417,7 @@
/* Real channel */
snprintf(ch_name, sizeof(ch_name), "%d", p->channel);
}
- /*** DOCUMENTATION
- <managerEventInstance>
- <synopsis>Raised when a DAHDI channel is created or an underlying technology is associated with a DAHDI channel.</synopsis>
- </managerEventInstance>
- ***/
- ast_manager_event(chan, EVENT_FLAG_CALL, "DAHDIChannel",
- "Channel: %s\r\n"
- "Uniqueid: %s\r\n"
- "DAHDISpan: %d\r\n"
- "DAHDIChannel: %s\r\n",
- ast_channel_name(chan),
- ast_channel_uniqueid(chan),
- p->span,
- ch_name);
+ publish_dahdichannel(chan, p->span, ch_name);
}
#ifdef HAVE_PRI
@@ -17332,6 +17378,7 @@
ast_cond_destroy(&ss_thread_complete);
dahdi_tech.capabilities = ast_format_cap_destroy(dahdi_tech.capabilities);
+ STASIS_MESSAGE_TYPE_CLEANUP(dahdichannel_type);
return 0;
}
@@ -19332,6 +19379,10 @@
int y;
#endif /* defined(HAVE_PRI) || defined(HAVE_SS7) */
+ if (STASIS_MESSAGE_TYPE_INIT(dahdichannel_type)) {
+ return AST_MODULE_LOAD_FAILURE;
+ }
+
if (!(dahdi_tech.capabilities = ast_format_cap_alloc())) {
return AST_MODULE_LOAD_FAILURE;
}
Modified: team/kmoore/channel_event_refactor/channels/chan_gtalk.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/channel_event_refactor/channels/chan_gtalk.c?view=diff&rev=391595&r1=391594&r2=391595
==============================================================================
--- team/kmoore/channel_event_refactor/channels/chan_gtalk.c (original)
+++ team/kmoore/channel_event_refactor/channels/chan_gtalk.c Wed Jun 12 23:27:46 2013
@@ -55,7 +55,7 @@
<syntax>
<xi:include xpointer="xpointer(/docs/managerEvent[@name='Newchannel']/managerEventInstance/syntax/parameter)" />
<parameter name="Gtalk-SID">
- <para>The source of the session timeout.</para>
+ <para>The Gtalk session identifier.</para>
</parameter>
<parameter name="Channeltype">
<para>The type of the channel (always <literal>Gtalk</literal>).</para>
@@ -581,7 +581,6 @@
S_COR(obj->snapshot, ast_str_buffer(channel_string), ""), sid);
}
-/*! \brief Sends a session timeout channel blob used to produce SessionTimeout AMI messages */
static void send_channel_update(struct ast_channel *chan, const char *sid)
{
RAII_VAR(struct ast_json *, blob, NULL, ast_json_unref);
Modified: team/kmoore/channel_event_refactor/channels/sig_pri.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/channel_event_refactor/channels/sig_pri.c?view=diff&rev=391595&r1=391594&r2=391595
==============================================================================
--- team/kmoore/channel_event_refactor/channels/sig_pri.c (original)
+++ team/kmoore/channel_event_refactor/channels/sig_pri.c Wed Jun 12 23:27:46 2013
@@ -2458,7 +2458,6 @@
.to_ami = mcid_to_ami,
);
-/*! \brief Sends a session timeout channel blob used to produce SessionTimeout AMI messages */
static void send_mcid(struct ast_channel *chan, struct ast_party_id *caller, struct ast_party_id *connected)
{
RAII_VAR(struct ast_json *, blob, NULL, ast_json_unref);
More information about the asterisk-commits
mailing list