Fix documentation replication issues
[asterisk/asterisk.git] / main / manager_channels.c
index b6eeb60..23418e6 100644 (file)
@@ -42,44 +42,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
                <managerEventInstance class="EVENT_FLAG_CALL">
                        <synopsis>Raised when a new channel is created.</synopsis>
                        <syntax>
-                               <parameter name="Channel">
-                               </parameter>
-                               <parameter name="ChannelState">
-                                       <para>A numeric code for the channel's current state, related to ChannelStateDesc</para>
-                               </parameter>
-                               <parameter name="ChannelStateDesc">
-                                       <enumlist>
-                                               <enum name="Down"/>
-                                               <enum name="Rsrvd"/>
-                                               <enum name="OffHook"/>
-                                               <enum name="Dialing"/>
-                                               <enum name="Ring"/>
-                                               <enum name="Ringing"/>
-                                               <enum name="Up"/>
-                                               <enum name="Busy"/>
-                                               <enum name="Dialing Offhook"/>
-                                               <enum name="Pre-ring"/>
-                                               <enum name="Unknown"/>
-                                       </enumlist>
-                               </parameter>
-                               <parameter name="CallerIDNum">
-                               </parameter>
-                               <parameter name="CallerIDName">
-                               </parameter>
-                               <parameter name="ConnectedLineNum">
-                               </parameter>
-                               <parameter name="ConnectedLineName">
-                               </parameter>
-                               <parameter name="AccountCode">
-                               </parameter>
-                               <parameter name="Context">
-                               </parameter>
-                               <parameter name="Exten">
-                               </parameter>
-                               <parameter name="Priority">
-                               </parameter>
-                               <parameter name="Uniqueid">
-                               </parameter>
+                               <channel_snapshot/>
                        </syntax>
                </managerEventInstance>
        </managerEvent>
@@ -87,7 +50,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
                <managerEventInstance class="EVENT_FLAG_CALL">
                        <synopsis>Raised when a channel's state changes.</synopsis>
                        <syntax>
-                               <xi:include xpointer="xpointer(/docs/managerEvent[@name='Newchannel']/managerEventInstance/syntax/parameter)" />
+                               <channel_snapshot/>
                        </syntax>
                </managerEventInstance>
        </managerEvent>
@@ -95,7 +58,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
                <managerEventInstance class="EVENT_FLAG_CALL">
                        <synopsis>Raised when a channel is hung up.</synopsis>
                        <syntax>
-                               <xi:include xpointer="xpointer(/docs/managerEvent[@name='Newchannel']/managerEventInstance/syntax/parameter)" />
+                               <channel_snapshot/>
                                <parameter name="Cause">
                                        <para>A numeric cause code for why the channel was hung up.</para>
                                </parameter>
@@ -109,7 +72,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
                <managerEventInstance class="EVENT_FLAG_CALL">
                        <synopsis>Raised when a hangup is requested.</synopsis>
                        <syntax>
-                               <xi:include xpointer="xpointer(/docs/managerEvent[@name='Newchannel']/managerEventInstance/syntax/parameter)" />
+                               <channel_snapshot/>
                                <xi:include xpointer="xpointer(/docs/managerEvent[@name='Hangup']/managerEventInstance/syntax/parameter[@name='Cause'])" />
                        </syntax>
                </managerEventInstance>
@@ -118,7 +81,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
                <managerEventInstance class="EVENT_FLAG_CALL">
                        <synopsis>Raised when a soft hangup is requested with a specific cause code.</synopsis>
                        <syntax>
-                               <xi:include xpointer="xpointer(/docs/managerEvent[@name='Newchannel']/managerEventInstance/syntax/parameter)" />
+                               <channel_snapshot/>
                                <xi:include xpointer="xpointer(/docs/managerEvent[@name='Hangup']/managerEventInstance/syntax/parameter[@name='Cause'])" />
                        </syntax>
                </managerEventInstance>
@@ -127,7 +90,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
                <managerEventInstance class="EVENT_FLAG_DIALPLAN">
                        <synopsis>Raised when a channel enters a new context, extension, priority.</synopsis>
                        <syntax>
-                               <xi:include xpointer="xpointer(/docs/managerEvent[@name='Newchannel']/managerEventInstance/syntax/parameter)" />
+                               <channel_snapshot/>
                                <parameter name="Extension">
                                        <para>Deprecated in 12, but kept for
                                        backward compatability. Please use
@@ -146,56 +109,30 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
                <managerEventInstance class="EVENT_FLAG_CALL">
                        <synopsis>Raised when a channel receives new Caller ID information.</synopsis>
                        <syntax>
-                               <xi:include xpointer="xpointer(/docs/managerEvent[@name='Newchannel']/managerEventInstance/syntax/parameter)" />
+                               <channel_snapshot/>
                                <parameter name="CID-CallingPres">
                                        <para>A description of the Caller ID presentation.</para>
                                </parameter>
                        </syntax>
                </managerEventInstance>
        </managerEvent>
+       <managerEvent language="en_US" name="NewAccountCode">
+               <managerEventInstance class="EVENT_FLAG_CALL">
+                       <synopsis>Raised when a Channel's AccountCode is changed.</synopsis>
+                       <syntax>
+                               <channel_snapshot/>
+                               <parameter name="OldAccountCode">
+                                       <para>The channel's previous account code</para>
+                               </parameter>
+                       </syntax>
+               </managerEventInstance>
+       </managerEvent>
        <managerEvent language="en_US" name="DialBegin">
                <managerEventInstance class="EVENT_FLAG_CALL">
                        <synopsis>Raised when a dial action has started.</synopsis>
                        <syntax>
-                               <xi:include xpointer="xpointer(/docs/managerEvent[@name='Newchannel']/managerEventInstance/syntax/parameter)" />
-                               <parameter name="DestChannel">
-                               </parameter>
-                               <parameter name="DestChannelState">
-                                       <para>A numeric code for the channel's current state, related to DestChannelStateDesc</para>
-                               </parameter>
-                               <parameter name="DestChannelStateDesc">
-                                       <enumlist>
-                                               <enum name="Down"/>
-                                               <enum name="Rsrvd"/>
-                                               <enum name="OffHook"/>
-                                               <enum name="Dialing"/>
-                                               <enum name="Ring"/>
-                                               <enum name="Ringing"/>
-                                               <enum name="Up"/>
-                                               <enum name="Busy"/>
-                                               <enum name="Dialing Offhook"/>
-                                               <enum name="Pre-ring"/>
-                                               <enum name="Unknown"/>
-                                       </enumlist>
-                               </parameter>
-                               <parameter name="DestCallerIDNum">
-                               </parameter>
-                               <parameter name="DestCallerIDName">
-                               </parameter>
-                               <parameter name="DestConnectedLineNum">
-                               </parameter>
-                               <parameter name="DestConnectedLineName">
-                               </parameter>
-                               <parameter name="DestAccountCode">
-                               </parameter>
-                               <parameter name="DestContext">
-                               </parameter>
-                               <parameter name="DestExten">
-                               </parameter>
-                               <parameter name="DestPriority">
-                               </parameter>
-                               <parameter name="DestUniqueid">
-                               </parameter>
+                               <channel_snapshot/>
+                               <channel_snapshot prefix="Dest"/>
                                <parameter name="DialString">
                                        <para>The non-technology specific device being dialed.</para>
                                </parameter>
@@ -209,8 +146,8 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
                <managerEventInstance class="EVENT_FLAG_CALL">
                        <synopsis>Raised when a dial action has completed.</synopsis>
                        <syntax>
-                               <xi:include xpointer="xpointer(/docs/managerEvent[@name='Newchannel']/managerEventInstance/syntax/parameter)" />
-                               <xi:include xpointer="xpointer(/docs/managerEvent[@name='DialBegin']/managerEventInstance/syntax/parameter[contains(@name, 'Dest')])" />
+                               <channel_snapshot/>
+                               <channel_snapshot prefix="Dest"/>
                                <parameter name="DialStatus">
                                        <para>The result of the dial operation.</para>
                                        <enumlist>
@@ -232,7 +169,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
                <managerEventInstance class="EVENT_FLAG_CALL">
                        <synopsis>Raised when a channel goes on hold.</synopsis>
                        <syntax>
-                               <xi:include xpointer="xpointer(/docs/managerEvent[@name='Newchannel']/managerEventInstance/syntax/parameter)" />
+                               <channel_snapshot/>
                                <parameter name="MusicClass">
                                        <para>The suggested MusicClass, if provided.</para>
                                </parameter>
@@ -243,7 +180,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
                <managerEventInstance class="EVENT_FLAG_CALL">
                        <synopsis>Raised when a channel goes off hold.</synopsis>
                        <syntax>
-                               <xi:include xpointer="xpointer(/docs/managerEvent[@name='Newchannel']/managerEventInstance/syntax/parameter)" />
+                               <channel_snapshot/>
                        </syntax>
                </managerEventInstance>
        </managerEvent>
@@ -251,84 +188,8 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
                <managerEventInstance class="EVENT_FLAG_CALL">
                        <synopsis>Raised when one channel begins spying on another channel.</synopsis>
                        <syntax>
-                               <parameter name="SpyerChannel">
-                                       <para>The channel performing the spying.</para>
-                               </parameter>
-                               <parameter name="SpyerChannelState">
-                                       <para>A numeric code for the channel's current state, related to SpyerChannelStateDesc</para>
-                               </parameter>
-                               <parameter name="SpyerChannelStateDesc">
-                                       <enumlist>
-                                               <enum name="Down"/>
-                                               <enum name="Rsrvd"/>
-                                               <enum name="OffHook"/>
-                                               <enum name="Dialing"/>
-                                               <enum name="Ring"/>
-                                               <enum name="Ringing"/>
-                                               <enum name="Up"/>
-                                               <enum name="Busy"/>
-                                               <enum name="Dialing Offhook"/>
-                                               <enum name="Pre-ring"/>
-                                               <enum name="Unknown"/>
-                                       </enumlist>
-                               </parameter>
-                               <parameter name="SpyerCallerIDNum">
-                               </parameter>
-                               <parameter name="SpyerCallerIDName">
-                               </parameter>
-                               <parameter name="SpyerConnectedLineNum">
-                               </parameter>
-                               <parameter name="SpyerConnectedLineName">
-                               </parameter>
-                               <parameter name="SpyerAccountCode">
-                               </parameter>
-                               <parameter name="SpyerContext">
-                               </parameter>
-                               <parameter name="SpyerExten">
-                               </parameter>
-                               <parameter name="SpyerPriority">
-                               </parameter>
-                               <parameter name="SpyerUniqueid">
-                               </parameter>
-                               <parameter name="SpyeeChannel">
-                                       <para>The channel being spied upon.</para>
-                               </parameter>
-                               <parameter name="SpyeeChannelState">
-                                       <para>A numeric code for the channel's current state, related to SpyeeChannelStateDesc</para>
-                               </parameter>
-                               <parameter name="SpyeeChannelStateDesc">
-                                       <enumlist>
-                                               <enum name="Down"/>
-                                               <enum name="Rsrvd"/>
-                                               <enum name="OffHook"/>
-                                               <enum name="Dialing"/>
-                                               <enum name="Ring"/>
-                                               <enum name="Ringing"/>
-                                               <enum name="Up"/>
-                                               <enum name="Busy"/>
-                                               <enum name="Dialing Offhook"/>
-                                               <enum name="Pre-ring"/>
-                                               <enum name="Unknown"/>
-                                       </enumlist>
-                               </parameter>
-                               <parameter name="SpyeeCallerIDNum">
-                               </parameter>
-                               <parameter name="SpyeeCallerIDName">
-                               </parameter>
-                               <parameter name="SpyeeConnectedLineNum">
-                               </parameter>
-                               <parameter name="SpyeeConnectedLineName">
-                               </parameter>
-                               <parameter name="SpyeeAccountCode">
-                               </parameter>
-                               <parameter name="SpyeeContext">
-                               </parameter>
-                               <parameter name="SpyeeExten">
-                               </parameter>
-                               <parameter name="SpyeePriority">
-                               </parameter>
-                               <parameter name="SpyeeUniqueid">
-                               </parameter>
+                               <channel_snapshot prefix="Spyer"/>
+                               <channel_snapshot prefix="Spyee"/>
                        </syntax>
                        <see-also>
                                <ref type="application">ChanSpyStop</ref>
@@ -339,7 +200,8 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
                <managerEventInstance class="EVENT_FLAG_CALL">
                        <synopsis>Raised when a channel has stopped spying.</synopsis>
                        <syntax>
-                               <xi:include xpointer="xpointer(/docs/managerEvent[@name='ChanSpyStart']/managerEventInstance/syntax/parameter[contains(@name, 'Spyer')])" />
+                               <channel_snapshot prefix="Spyer"/>
+                               <channel_snapshot prefix="Spyee"/>
                        </syntax>
                        <see-also>
                                <ref type="application">ChanSpyStart</ref>
@@ -350,7 +212,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
                <managerEventInstance class="EVENT_FLAG_DIALPLAN">
                        <synopsis>Raised when a hangup handler is about to be called.</synopsis>
                        <syntax>
-                               <xi:include xpointer="xpointer(/docs/managerEvent[@name='Newchannel']/managerEventInstance/syntax/parameter)" />
+                               <channel_snapshot/>
                                <parameter name="Handler">
                                        <para>Hangup handler parameter string passed to the Gosub application.</para>
                                </parameter>
@@ -364,6 +226,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
                                by the CHANNEL() function.
                        </synopsis>
                        <syntax>
+                               <channel_snapshot/>
                                <xi:include xpointer="xpointer(/docs/managerEvent[@name='HangupHandlerRun']/managerEventInstance/syntax/parameter)" />
                        </syntax>
                        <see-also>
@@ -379,6 +242,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
                                the CHANNEL() function.
                        </synopsis>
                        <syntax>
+                               <channel_snapshot/>
                                <xi:include xpointer="xpointer(/docs/managerEvent[@name='HangupHandlerRun']/managerEventInstance/syntax/parameter)" />
                        </syntax>
                        <see-also>
@@ -393,7 +257,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
                                Raised periodically during a fax transmission.
                        </synopsis>
                        <syntax>
-                               <xi:include xpointer="xpointer(/docs/managerEvent[@name='Newchannel']/managerEventInstance/syntax/parameter)" />
+                               <channel_snapshot/>
                                <parameter name="Operation">
                                        <enumlist>
                                                <enum name="gateway"/>
@@ -415,7 +279,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
                                Raised when a receive fax operation has completed.
                        </synopsis>
                        <syntax>
-                               <xi:include xpointer="xpointer(/docs/managerEvent[@name='Newchannel']/managerEventInstance/syntax/parameter)" />
+                               <channel_snapshot/>
                                <parameter name="LocalStationID">
                                        <para>The value of the <variable>LOCALSTATIONID</variable> channel variable</para>
                                </parameter>
@@ -443,7 +307,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
                                Raised when a send fax operation has completed.
                        </synopsis>
                        <syntax>
-                               <xi:include xpointer="xpointer(/docs/managerEvent[@name='Newchannel']/managerEventInstance/syntax/parameter)" />
+                               <channel_snapshot/>
                                <xi:include xpointer="xpointer(/docs/managerEvent[@name='ReceiveFAX']/managerEventInstance/syntax/parameter)" />
                        </syntax>
                </managerEventInstance>
@@ -452,7 +316,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
                <managerEventInstance class="EVENT_FLAG_CALL">
                        <synopsis>Raised when music on hold has started on a channel.</synopsis>
                        <syntax>
-                               <xi:include xpointer="xpointer(/docs/managerEvent[@name='Newchannel']/managerEventInstance/syntax/parameter)" />
+                               <channel_snapshot/>
                                <parameter name="Class">
                                        <para>The class of music being played on the channel</para>
                                </parameter>
@@ -467,7 +331,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
                <managerEventInstance class="EVENT_FLAG_CALL">
                        <synopsis>Raised when music on hold has stopped on a channel.</synopsis>
                        <syntax>
-                               <xi:include xpointer="xpointer(/docs/managerEvent[@name='Newchannel']/managerEventInstance/syntax/parameter)" />
+                               <channel_snapshot/>
                        </syntax>
                        <see-also>
                                <ref type="managerEvent">MusicOnHoldStart</ref>
@@ -479,7 +343,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
                <managerEventInstance class="EVENT_FLAG_CALL">
                        <synopsis>Raised when monitoring has started on a channel.</synopsis>
                        <syntax>
-                               <xi:include xpointer="xpointer(/docs/managerEvent[@name='Newchannel']/managerEventInstance/syntax/parameter)" />
+                               <channel_snapshot/>
                        </syntax>
                        <see-also>
                                <ref type="managerEvent">MonitorStop</ref>
@@ -492,7 +356,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
                <managerEventInstance class="EVENT_FLAG_CALL">
                <synopsis>Raised when monitoring has stopped on a channel.</synopsis>
                <syntax>
-                       <xi:include xpointer="xpointer(/docs/managerEvent[@name='Newchannel']/managerEventInstance/syntax/parameter)" />
+                       <channel_snapshot/>
                </syntax>
                <see-also>
                        <ref type="managerEvent">MonitorStart</ref>
@@ -514,9 +378,16 @@ struct ast_str *ast_manager_build_channel_state_string_prefix(
 {
        struct ast_str *out = ast_str_create(1024);
        int res = 0;
+
        if (!out) {
                return NULL;
        }
+
+       if (snapshot->tech_properties & (AST_CHAN_TP_ANNOUNCER | AST_CHAN_TP_RECORDER)) {
+               ast_free(out);
+               return NULL;
+       }
+
        res = ast_str_set(&out, 0,
                "%sChannel: %s\r\n"
                "%sChannelState: %d\r\n"
@@ -544,6 +415,7 @@ struct ast_str *ast_manager_build_channel_state_string_prefix(
                prefix, snapshot->uniqueid);
 
        if (!res) {
+               ast_free(out);
                return NULL;
        }
 
@@ -592,8 +464,8 @@ static struct ast_manager_event_blob *channel_state_change(
                        EVENT_FLAG_CALL, "Newchannel", NO_EXTRA_FIELDS);
        }
 
-       was_hungup = ast_test_flag(&old_snapshot->flags, AST_FLAG_ZOMBIE) ? 1 : 0;
-       is_hungup = ast_test_flag(&new_snapshot->flags, AST_FLAG_ZOMBIE) ? 1 : 0;
+       was_hungup = ast_test_flag(&old_snapshot->flags, AST_FLAG_DEAD) ? 1 : 0;
+       is_hungup = ast_test_flag(&new_snapshot->flags, AST_FLAG_DEAD) ? 1 : 0;
 
        if (!was_hungup && is_hungup) {
                return ast_manager_event_blob_create(
@@ -627,7 +499,13 @@ static struct ast_manager_event_blob *channel_newexten(
                return NULL;
        }
 
-       if (old_snapshot && ast_channel_snapshot_cep_equal(old_snapshot, new_snapshot)) {
+       /* Ignore any updates if we're hungup */
+       if (ast_test_flag(&new_snapshot->flags, AST_FLAG_DEAD)) {
+               return NULL;
+       }
+
+       if (old_snapshot && ast_channel_snapshot_cep_equal(old_snapshot, new_snapshot)
+               && !strcmp(old_snapshot->appl, new_snapshot->appl)) {
                return NULL;
        }
 
@@ -662,10 +540,28 @@ static struct ast_manager_event_blob *channel_new_callerid(
                ast_describe_caller_presentation(new_snapshot->caller_pres));
 }
 
+static struct ast_manager_event_blob *channel_new_accountcode(
+       struct ast_channel_snapshot *old_snapshot,
+       struct ast_channel_snapshot *new_snapshot)
+{
+       if (!old_snapshot || !new_snapshot) {
+               return NULL;
+       }
+
+       if (!strcmp(old_snapshot->accountcode, new_snapshot->accountcode)) {
+               return NULL;
+       }
+
+       return ast_manager_event_blob_create(
+               EVENT_FLAG_CALL, "NewAccountCode",
+               "OldAccountCode: %s\r\n", old_snapshot->accountcode);
+}
+
 channel_snapshot_monitor channel_monitors[] = {
        channel_state_change,
        channel_newexten,
-       channel_new_callerid
+       channel_new_callerid,
+       channel_new_accountcode
 };
 
 static void channel_snapshot_update(void *data, struct stasis_subscription *sub,
@@ -680,9 +576,7 @@ static void channel_snapshot_update(void *data, struct stasis_subscription *sub,
 
        update = stasis_message_data(message);
 
-       if (ast_channel_snapshot_type() != update->type) {
-               return;
-       }
+       ast_assert(ast_channel_snapshot_type() == update->type);
 
        old_snapshot = stasis_message_data(update->old_snapshot);
        new_snapshot = stasis_message_data(update->new_snapshot);
@@ -710,49 +604,6 @@ static void channel_snapshot_update(void *data, struct stasis_subscription *sub,
        }
 }
 
-static void channel_varset_cb(void *data, struct stasis_subscription *sub,
-       struct stasis_topic *topic, struct stasis_message *message)
-{
-       struct ast_channel_blob *obj = stasis_message_data(message);
-       RAII_VAR(struct ast_str *, channel_event_string, NULL, ast_free);
-       const char *variable = ast_json_string_get(ast_json_object_get(obj->blob, "variable"));
-       const char *value = ast_json_string_get(ast_json_object_get(obj->blob, "value"));
-
-       if (obj->snapshot) {
-               channel_event_string = ast_manager_build_channel_state_string(obj->snapshot);
-       } else {
-               channel_event_string = ast_str_create(35);
-               ast_str_set(&channel_event_string, 0,
-                           "Channel: none\r\n"
-                           "Uniqueid: none\r\n");
-       }
-
-       if (!channel_event_string) {
-               return;
-       }
-
-       /*** DOCUMENTATION
-               <managerEventInstance>
-                       <synopsis>Raised when a variable is set to a particular value.</synopsis>
-                       <syntax>
-                               <xi:include xpointer="xpointer(/docs/managerEvent[@name='Newchannel']/managerEventInstance/syntax/parameter)" />
-                               <parameter name="Variable">
-                                       <para>The variable being set.</para>
-                               </parameter>
-                               <parameter name="Value">
-                                       <para>The new value of the variable.</para>
-                               </parameter>
-                       </syntax>
-               </managerEventInstance>
-       ***/
-       manager_event(EVENT_FLAG_DIALPLAN, "VarSet",
-                     "%s"
-                     "Variable: %s\r\n"
-                     "Value: %s\r\n",
-                     ast_str_buffer(channel_event_string),
-                     variable, value);
-}
-
 static int userevent_exclusion_cb(const char *key)
 {
        if (!strcmp("type", key)) {
@@ -784,7 +635,7 @@ static void channel_user_event_cb(void *data, struct stasis_subscription *sub,
                <managerEventInstance>
                        <synopsis>A user defined event raised from the dialplan.</synopsis>
                        <syntax>
-                               <xi:include xpointer="xpointer(/docs/managerEvent[@name='Newchannel']/managerEventInstance/syntax/parameter)" />
+                               <channel_snapshot/>
                                <parameter name="UserEvent">
                                        <para>The event name, as specified in the dialplan.</para>
                                </parameter>
@@ -933,7 +784,7 @@ static void channel_dtmf_begin_cb(void *data, struct stasis_subscription *sub,
                <managerEventInstance>
                        <synopsis>Raised when a DTMF digit has started on a channel.</synopsis>
                                <syntax>
-                                       <xi:include xpointer="xpointer(/docs/managerEvent[@name='Newchannel']/managerEventInstance/syntax/parameter)" />
+                                       <channel_snapshot/>
                                        <parameter name="Digit">
                                                <para>DTMF digit received or transmitted (0-9, A-E, # or *</para>
                                        </parameter>
@@ -976,7 +827,7 @@ static void channel_dtmf_end_cb(void *data, struct stasis_subscription *sub,
                <managerEventInstance>
                        <synopsis>Raised when a DTMF digit has ended on a channel.</synopsis>
                                <syntax>
-                                       <xi:include xpointer="xpointer(/docs/managerEvent[@name='Newchannel']/managerEventInstance/syntax/parameter)" />
+                                       <channel_snapshot/>
                                        <parameter name="Digit">
                                                <para>DTMF digit received or transmitted (0-9, A-E, # or *</para>
                                        </parameter>
@@ -1212,6 +1063,9 @@ static void channel_hold_cb(void *data, struct stasis_subscription *sub,
        }
 
        channel_event_string = ast_manager_build_channel_state_string(obj->snapshot);
+       if (!channel_event_string) {
+               return;
+       }
 
        if (obj->blob) {
                musicclass = ast_json_string_get(ast_json_object_get(obj->blob, "musicclass"));
@@ -1235,6 +1089,9 @@ static void channel_unhold_cb(void *data, struct stasis_subscription *sub,
        RAII_VAR(struct ast_str *, channel_event_string, NULL, ast_free);
 
        channel_event_string = ast_manager_build_channel_state_string(obj->snapshot);
+       if (!channel_event_string) {
+               return;
+       }
 
        manager_event(EVENT_FLAG_CALL, "Unhold",
                "%s",
@@ -1262,7 +1119,7 @@ int manager_channels_init(void)
        if (!message_router) {
                return -1;
        }
-       channel_topic = stasis_caching_get_topic(ast_channel_topic_all_cached());
+       channel_topic = ast_channel_topic_all_cached();
        if (!channel_topic) {
                return -1;
        }
@@ -1274,90 +1131,57 @@ int manager_channels_init(void)
 
        ast_register_atexit(manager_channels_shutdown);
 
-       ret |= stasis_message_router_add(message_router,
-                                        stasis_cache_update_type(),
-                                        channel_snapshot_update,
-                                        NULL);
-
-       ret |= stasis_message_router_add(message_router,
-                                        ast_channel_varset_type(),
-                                        channel_varset_cb,
-                                        NULL);
+       ret |= stasis_message_router_add_cache_update(message_router,
+               ast_channel_snapshot_type(), channel_snapshot_update, NULL);
 
        ret |= stasis_message_router_add(message_router,
-                                        ast_channel_user_event_type(),
-                                        channel_user_event_cb,
-                                        NULL);
+               ast_channel_user_event_type(), channel_user_event_cb, NULL);
 
        ret |= stasis_message_router_add(message_router,
-                                        ast_channel_dtmf_begin_type(),
-                                        channel_dtmf_begin_cb,
-                                        NULL);
+               ast_channel_dtmf_begin_type(), channel_dtmf_begin_cb, NULL);
 
        ret |= stasis_message_router_add(message_router,
-                                        ast_channel_dtmf_end_type(),
-                                        channel_dtmf_end_cb,
-                                        NULL);
+               ast_channel_dtmf_end_type(), channel_dtmf_end_cb, NULL);
 
        ret |= stasis_message_router_add(message_router,
-                                        ast_channel_hangup_request_type(),
-                                        channel_hangup_request_cb,
-                                        NULL);
+               ast_channel_hangup_request_type(), channel_hangup_request_cb,
+               NULL);
 
        ret |= stasis_message_router_add(message_router,
-                                        ast_channel_dial_type(),
-                                        channel_dial_cb,
-                                        NULL);
+               ast_channel_dial_type(), channel_dial_cb, NULL);
 
        ret |= stasis_message_router_add(message_router,
-                                        ast_channel_hold_type(),
-                                        channel_hold_cb,
-                                        NULL);
+               ast_channel_hold_type(), channel_hold_cb, NULL);
 
        ret |= stasis_message_router_add(message_router,
-                                        ast_channel_unhold_type(),
-                                        channel_unhold_cb,
-                                        NULL);
+               ast_channel_unhold_type(), channel_unhold_cb, NULL);
 
        ret |= stasis_message_router_add(message_router,
-                                        ast_channel_fax_type(),
-                                        channel_fax_cb,
-                                        NULL);
+               ast_channel_fax_type(), channel_fax_cb, NULL);
 
        ret |= stasis_message_router_add(message_router,
-                                        ast_channel_chanspy_start_type(),
-                                        channel_chanspy_start_cb,
-                                        NULL);
+               ast_channel_chanspy_start_type(), channel_chanspy_start_cb,
+               NULL);
 
        ret |= stasis_message_router_add(message_router,
-                                        ast_channel_chanspy_stop_type(),
-                                        channel_chanspy_stop_cb,
-                                        NULL);
+               ast_channel_chanspy_stop_type(), channel_chanspy_stop_cb, NULL);
 
        ret |= stasis_message_router_add(message_router,
-                                        ast_channel_hangup_handler_type(),
-                                        channel_hangup_handler_cb,
-                                        NULL);
+               ast_channel_hangup_handler_type(), channel_hangup_handler_cb,
+               NULL);
 
        ret |= stasis_message_router_add(message_router,
-                                        ast_channel_moh_start_type(),
-                                        channel_moh_start_cb,
-                                        NULL);
+               ast_channel_moh_start_type(), channel_moh_start_cb, NULL);
 
        ret |= stasis_message_router_add(message_router,
-                                        ast_channel_moh_stop_type(),
-                                        channel_moh_stop_cb,
-                                        NULL);
+               ast_channel_moh_stop_type(), channel_moh_stop_cb, NULL);
 
        ret |= stasis_message_router_add(message_router,
-                                        ast_channel_monitor_start_type(),
-                                        channel_monitor_start_cb,
-                                        NULL);
+               ast_channel_monitor_start_type(), channel_monitor_start_cb,
+               NULL);
 
        ret |= stasis_message_router_add(message_router,
-                                        ast_channel_monitor_stop_type(),
-                                        channel_monitor_stop_cb,
-                                        NULL);
+               ast_channel_monitor_stop_type(), channel_monitor_stop_cb, NULL);
 
        /* If somehow we failed to add any routes, just shut down the whole
         * thing and fail it.