diff options
author | eliel <eliel@f38db490-d61c-443f-a65b-d21fe96a405b> | 2009-05-22 17:52:35 +0000 |
---|---|---|
committer | eliel <eliel@f38db490-d61c-443f-a65b-d21fe96a405b> | 2009-05-22 17:52:35 +0000 |
commit | cbbfdc573c6f071b12dc665273c0063a0c69ad69 (patch) | |
tree | e1c6ca80d913c0e0aa3166a40d7b8e4461cd62d1 /main | |
parent | c208610d90db5a241e187413c831309cd5f13f32 (diff) |
Implement a new element in AstXML for AMI actions documentation.
A new xml element was created to manage the AMI actions documentation,
using AstXML.
To register a manager action using XML documentation it is now possible
using ast_manager_register_xml().
The CLI command 'manager show command' can be used to show the parsed
documentation.
Example manager xml documentation:
<manager name="ami action name" language="en_US">
<synopsis>
AMI action synopsis.
</synopsis>
<syntax>
<xi:include xpointer="xpointer(...)" /> <-- for ActionID
<parameter name="header1" required="true">
<para>Description</para>
</parameter>
...
</syntax>
<description>
<para>AMI action description</para>
</description>
<see-also>
...
</see-also>
</manager>
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@196308 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'main')
-rw-r--r-- | main/db.c | 60 | ||||
-rw-r--r-- | main/features.c | 76 | ||||
-rw-r--r-- | main/manager.c | 998 | ||||
-rw-r--r-- | main/pbx.c | 39 | ||||
-rw-r--r-- | main/xmldoc.c | 70 |
5 files changed, 927 insertions, 316 deletions
@@ -48,6 +48,58 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") #include "asterisk/manager.h" #include "db1-ast/include/db.h" +/*** DOCUMENTATION + <manager name="DBGet" language="en_US"> + <synopsis> + Get DB Entry. + </synopsis> + <syntax> + <xi:include xpointer="xpointer(/docs/manager[@name='Login']/syntax/parameter[@name='ActionID'])" /> + <parameter name="Family" required="true" /> + <parameter name="Key" required="true" /> + </syntax> + <description> + </description> + </manager> + <manager name="DBPut" language="en_US"> + <synopsis> + Put DB entry. + </synopsis> + <syntax> + <xi:include xpointer="xpointer(/docs/manager[@name='Login']/syntax/parameter[@name='ActionID'])" /> + <parameter name="Family" required="true" /> + <parameter name="Key" required="true" /> + <parameter name="Val" /> + </syntax> + <description> + </description> + </manager> + <manager name="DBDel" language="en_US"> + <synopsis> + Delete DB entry. + </synopsis> + <syntax> + <xi:include xpointer="xpointer(/docs/manager[@name='Login']/syntax/parameter[@name='ActionID'])" /> + <parameter name="Family" required="true" /> + <parameter name="Key" required="true" /> + </syntax> + <description> + </description> + </manager> + <manager name="DBDelTree" language="en_US"> + <synopsis> + Delete DB Tree. + </synopsis> + <syntax> + <xi:include xpointer="xpointer(/docs/manager[@name='Login']/syntax/parameter[@name='ActionID'])" /> + <parameter name="Family" required="true" /> + <parameter name="Key" /> + </syntax> + <description> + </description> + </manager> + ***/ + static DB *astdb; AST_MUTEX_DEFINE_STATIC(dblock); @@ -666,9 +718,9 @@ int astdb_init(void) { dbinit(); ast_cli_register_multiple(cli_database, ARRAY_LEN(cli_database)); - ast_manager_register("DBGet", EVENT_FLAG_SYSTEM | EVENT_FLAG_REPORTING, manager_dbget, "Get DB Entry"); - ast_manager_register("DBPut", EVENT_FLAG_SYSTEM, manager_dbput, "Put DB Entry"); - ast_manager_register("DBDel", EVENT_FLAG_SYSTEM, manager_dbdel, "Delete DB Entry"); - ast_manager_register("DBDelTree", EVENT_FLAG_SYSTEM, manager_dbdeltree, "Delete DB Tree"); + ast_manager_register_xml("DBGet", EVENT_FLAG_SYSTEM | EVENT_FLAG_REPORTING, manager_dbget); + ast_manager_register_xml("DBPut", EVENT_FLAG_SYSTEM, manager_dbput); + ast_manager_register_xml("DBDel", EVENT_FLAG_SYSTEM, manager_dbdel); + ast_manager_register_xml("DBDelTree", EVENT_FLAG_SYSTEM, manager_dbdeltree); return 0; } diff --git a/main/features.c b/main/features.c index 8da3c7baa..6e3570e63 100644 --- a/main/features.c +++ b/main/features.c @@ -154,6 +154,61 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") <ref type="application">ParkedCall</ref> </see-also> </application> + <manager name="ParkedCalls" language="en_US"> + <synopsis> + List parked calls. + </synopsis> + <syntax> + <xi:include xpointer="xpointer(/docs/manager[@name='Login']/syntax/parameter[@name='ActionID'])" /> + </syntax> + <description> + <para>List parked calls.</para> + </description> + </manager> + <manager name="Park" language="en_US"> + <synopsis> + Park a channel. + </synopsis> + <syntax> + <xi:include xpointer="xpointer(/docs/manager[@name='Login']/syntax/parameter[@name='ActionID'])" /> + <parameter name="Channel" required="true"> + <para>Channel name to park.</para> + </parameter> + <parameter name="Channel2" required="true"> + <para>Channel to announce park info to (and return to if timeout).</para> + </parameter> + <parameter name="Timeout"> + <para>Number of milliseconds to wait before callback.</para> + </parameter> + </syntax> + <description> + <para>Park a channel.</para> + </description> + </manager> + <manager name="Bridge" language="en_US"> + <synopsis> + Bridge two channels already in the PBX. + </synopsis> + <syntax> + <xi:include xpointer="xpointer(/docs/manager[@name='Login']/syntax/parameter[@name='ActionID'])" /> + <parameter name="Channel1" required="true"> + <para>Channel to Bridge to Channel2.</para> + </parameter> + <parameter name="Channel2" required="true"> + <para>Channel to Bridge to Channel1.</para> + </parameter> + <parameter name="Tone"> + <para>Play courtesy tone to Channel 2.</para> + <enumlist> + <enum name="yes" /> + <enum name="no" /> + </enumlist> + </parameter> + </syntax> + <description> + <para>Bridge together two channels already in the PBX.</para> + </description> + </manager> ***/ #define DEFAULT_PARK_TIME 45000 @@ -4109,14 +4164,6 @@ static char *handle_features_reload(struct ast_cli_entry *e, int cmd, struct ast return CLI_SUCCESS; } -static const char mandescr_bridge[] = -"Description: Bridge together two channels already in the PBX\n" -"Variables: ( Headers marked with * are required )\n" -" *Channel1: Channel to Bridge to Channel2\n" -" *Channel2: Channel to Bridge to Channel1\n" -" Tone: (Yes|No) Play courtesy tone to Channel 2\n" -"\n"; - /*! * \brief Actual bridge * \param chan @@ -4382,13 +4429,6 @@ static int manager_parking_status(struct mansession *s, const struct message *m) return RESULT_SUCCESS; } -static const char mandescr_park[] = -"Description: Park a channel.\n" -"Variables: (Names marked with * are required)\n" -" *Channel: Channel name to park\n" -" *Channel2: Channel to announce park info to (and return to if timeout)\n" -" Timeout: Number of milliseconds to wait before callback.\n"; - /*! * \brief Create manager event for parked calls * \param s @@ -4695,9 +4735,9 @@ int ast_features_init(void) if (!res) res = ast_register_application2(parkcall, park_call_exec, NULL, NULL, NULL); if (!res) { - ast_manager_register("ParkedCalls", 0, manager_parking_status, "List parked calls"); - ast_manager_register2("Park", EVENT_FLAG_CALL, manager_park, "Park a channel", mandescr_park); - ast_manager_register2("Bridge", EVENT_FLAG_CALL, action_bridge, "Bridge two channels already in the PBX", mandescr_bridge); + ast_manager_register_xml("ParkedCalls", 0, manager_parking_status); + ast_manager_register_xml("Park", EVENT_FLAG_CALL, manager_park); + ast_manager_register_xml("Bridge", EVENT_FLAG_CALL, action_bridge); } res |= ast_devstate_prov_add("Park", metermaidstate); diff --git a/main/manager.c b/main/manager.c index 7d5ee7a59..ba1d2f56b 100644 --- a/main/manager.c +++ b/main/manager.c @@ -75,6 +75,618 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") #include "asterisk/astobj2.h" #include "asterisk/features.h" +/*** DOCUMENTATION + <manager name="Ping" language="en_US"> + <synopsis> + Keepalive command. + </synopsis> + <syntax> + <xi:include xpointer="xpointer(/docs/manager[@name='Login']/syntax/parameter[@name='ActionID'])" /> + </syntax> + <description> + <para>A 'Ping' action will ellicit a 'Pong' response. Used to keep the + manager connection open.</para> + </description> + </manager> + <manager name="Events" language="en_US"> + <synopsis> + Control Event Flow. + </synopsis> + <syntax> + <xi:include xpointer="xpointer(/docs/manager[@name='Login']/syntax/parameter[@name='ActionID'])" /> + <parameter name="EventMask" required="true"> + <enumlist> + <enum name="on"> + <para>If all events should be sent.</para> + </enum> + <enum name="off"> + <para>If no events should be sent.</para> + </enum> + <enum name="system,call,log,..."> + <para>To select which flags events should have to be sent.</para> + </enum> + </enumlist> + </parameter> + </syntax> + <description> + <para>Enable/Disable sending of events to this manager client.</para> + </description> + </manager> + <manager name="Logoff" language="en_US"> + <synopsis> + Logoff Manager. + </synopsis> + <syntax> + <xi:include xpointer="xpointer(/docs/manager[@name='Login']/syntax/parameter[@name='ActionID'])" /> + </syntax> + <description> + <para>Logoff the current manager session.</para> + </description> + </manager> + <manager name="Login" language="en_US"> + <synopsis> + Login Manager. + </synopsis> + <syntax> + <parameter name="ActionID"> + <para>ActionID for this transaction. Will be returned.</para> + </parameter> + </syntax> + <description> + <para>Login Manager.</para> + </description> + </manager> + <manager name="Challenge" language="en_US"> + <synopsis> + Generate Challenge for MD5 Auth. + </synopsis> + <syntax> + <xi:include xpointer="xpointer(/docs/manager[@name='Login']/syntax/parameter[@name='ActionID'])" /> + </syntax> + <description> + <para>Generate a challenge for MD5 authentication.</para> + </description> + </manager> + <manager name="Hangup" language="en_US"> + <synopsis> + Hangup channel. + </synopsis> + <syntax> + <xi:include xpointer="xpointer(/docs/manager[@name='Login']/syntax/parameter[@name='ActionID'])" /> + <parameter name="Channel" required="true"> + <para>The channel name to be hangup.</para> + </parameter> + <parameter name="Cause"> + <para>Numeric hangup cause.</para> + </parameter> + </syntax> + <description> + <para>Hangup a channel.</para> + </description> + </manager> + <manager name="Status" language="en_US"> + <synopsis> + List channel status. + </synopsis> + <syntax> + <xi:include xpointer="xpointer(/docs/manager[@name='Login']/syntax/parameter[@name='ActionID'])" /> + <parameter name="Channel" required="true"> + <para>The name of the channel to query for status.</para> + </parameter> + <parameter name="Variables"> + <para>Comma <literal>,</literal> separated list of variable to include.</para> + </parameter> + </syntax> + <description> + <para>Will return the status information of each channel along with the + value for the specified channel variables.</para> + </description> + </manager> + <manager name="Setvar" language="en_US"> + <synopsis> + Set a channel variable. + </synopsis> + <syntax> + <xi:include xpointer="xpointer(/docs/manager[@name='Login']/syntax/parameter[@name='ActionID'])" /> + <parameter name="Channel"> + <para>Channel to set variable for.</para> + </parameter> + <parameter name="Variable" required="true"> + <para>Variable name.</para> + </parameter> + <parameter name="Value" required="true"> + <para>Variable value.</para> + </parameter> + </syntax> + <description> + <para>Set a global or local channel variable.</para> + </description> + </manager> + <manager name="Getvar" language="en_US"> + <synopsis> + Gets a channel variable. + </synopsis> + <syntax> + <xi:include xpointer="xpointer(/docs/manager[@name='Login']/syntax/parameter[@name='ActionID'])" /> + <parameter name="Channel"> + <para>Channel to read variable from.</para> + </parameter> + <parameter name="Variable" required="true"> + <para>Variable name.</para> + </parameter> + </syntax> + <description> + <para>Get the value of a global or local channel variable.</para> + </description> + </manager> + <manager name="GetConfig" language="en_US"> + <synopsis> + Retrieve configuration. + </synopsis> + <syntax> + <xi:include xpointer="xpointer(/docs/manager[@name='Login']/syntax/parameter[@name='ActionID'])" /> + <parameter name="Filename" required="true"> + <para>Configuration filename (e.g. <filename>foo.conf</filename>).</para> + </parameter> + <parameter name="Category"> + <para>Category in configuration file.</para> + </parameter> + </syntax> + <description> + <para>This action will dump the contents of a configuration + file by category and contents or optionally by specified category only.</para> + </description> + </manager> + <manager name="GetConfigJSON" language="en_US"> + <synopsis> + Retrieve configuration (JSON format). + </synopsis> + <syntax> + <xi:include xpointer="xpointer(/docs/manager[@name='Login']/syntax/parameter[@name='ActionID'])" /> + <parameter name="Filename" required="true"> + <para>Configuration filename (e.g. <filename>foo.conf</filename>).</para> + </parameter> + </syntax> + <description> + <para>This action will dump the contents of a configuration file by category + and contents in JSON format. This only makes sense to be used using rawman over + the HTTP interface.</para> + </description> + </manager> + <manager name="UpdateConfig" language="en_US"> + <synopsis> + Update basic configuration. + </synopsis> + <syntax> + <xi:include xpointer="xpointer(/docs/manager[@name='Login']/syntax/parameter[@name='ActionID'])" /> + <parameter name="SrcFilename" required="true"> + <para>Configuration filename to read (e.g. <filename>foo.conf</filename>).</para> + </parameter> + <parameter name="DstFilename" required="true"> + <para>Configuration filename to write (e.g. <filename>foo.conf</filename>)</para> + </parameter> + <parameter name="Reload"> + <para>Whether or not a reload should take place (or name of specific module).</para> + </parameter> + <parameter name="Action-XXXXXX"> + <para>Action to take.</para> + <para>X's represent 6 digit number beginning with 000000.</para> + <enumlist> + <enum name="NewCat" /> + <enum name="RenameCat" /> + <enum name="DelCat" /> + <enum name="EmptyCat" /> + <enum name="Update" /> + <enum name="Delete" /> + <enum name="Append" /> + <enum name="Insert" /> + </enumlist> + </parameter> + <parameter name="Cat-XXXXXX"> + <para>Category to operate on.</para> + <xi:include xpointer="xpointer(/docs/manager[@name='UpdateConfig']/syntax/parameter[@name='Action-XXXXXX']/para[2])" /> + </parameter> + <parameter name="Var-XXXXXX"> + <para>Variable to work on.</para> + <xi:include xpointer="xpointer(/docs/manager[@name='UpdateConfig']/syntax/parameter[@name='Action-XXXXXX']/para[2])" /> + </parameter> + <parameter name="Value-XXXXXX"> + <para>Value to work on.</para> + <xi:include xpointer="xpointer(/docs/manager[@name='UpdateConfig']/syntax/parameter[@name='Action-XXXXXX']/para[2])" /> + </parameter> + <parameter name="Match-XXXXXX"> + <para>Extra match required to match line.</para> + <xi:include xpointer="xpointer(/docs/manager[@name='UpdateConfig']/syntax/parameter[@name='Action-XXXXXX']/para[2])" /> + </parameter> + <parameter name="Line-XXXXXX"> + <para>Line in category to operate on (used with delete and insert actions).</para> + <xi:include xpointer="xpointer(/docs/manager[@name='UpdateConfig']/syntax/parameter[@name='Action-XXXXXX']/para[2])" /> + </parameter> + </syntax> + <description> + <para>This action will modify, create, or delete configuration elements + in Asterisk configuration files.</para> + </description> + </manager> + <manager name="CreateConfig" language="en_US"> + <synopsis> + Creates an empty file in the configuration directory. + </synopsis> + <syntax> + <xi:include xpointer="xpointer(/docs/manager[@name='Login']/syntax/parameter[@name='ActionID'])" /> + <parameter name="Filename" required="true"> + <para>The configuration filename to create (e.g. <filename>foo.conf</filename>).</para> + </parameter> + </syntax> + <description> + <para>This action will create an empty file in the configuration + directory. This action is intended to be used before an UpdateConfig + action.</para> + </description> + </manager> + <manager name="ListCategories" language="en_US"> + <synopsis> + List categories in configuration file. + </synopsis> + <syntax> + <xi:include xpointer="xpointer(/docs/manager[@name='Login']/syntax/parameter[@name='ActionID'])" /> + <parameter name="Filename" required="true"> + <para>Configuration filename (e.g. <filename>foo.conf</filename>).</para> + </parameter> + </syntax> + <description> + <para>This action will dump the categories in a given file.</para> + </description> + </manager> + <manager name="Redirect" language="en_US"> + <synopsis> + Redirect (transfer) a call. + </synopsis> + <syntax> + <xi:include xpointer="xpointer(/docs/manager[@name='Login']/syntax/parameter[@name='ActionID'])" /> + <parameter name="Channel" required="true"> + <para>Channel to redirect.</para> + </parameter> + <parameter name="ExtraChannel"> + <para>Second call leg to transfer (optional).</para> + </parameter> + <parameter name="Exten" required="true"> + <para>Extension to transfer to.</para> + </parameter> + <parameter name="Context" required="true"> + <para>Context to transfer to.</para> + </parameter> + <parameter name="Priority" required="true"> + <para>Priority to transfer to.</para> + </parameter> + </syntax> + <description> + <para>Redirect (transfer) a call.</para> + </description> + </manager> + <manager name="Atxfer" language="en_US"> + <synopsis> + Attended transfer. + </synopsis> + <syntax> + <xi:include xpointer="xpointer(/docs/manager[@name='Login']/syntax/parameter[@name='ActionID'])" /> + <parameter name="Channel" required="true"> + <para>Transferer's channel.</para> + </parameter> + <parameter name="Exten" required="true"> + <para>Extension to transfer to.</para> + </parameter> + <parameter name="Context" required="true"> + <para>Context to transfer to.</para> + </parameter> + <parameter name="Priority" required="true"> + <para>Priority to transfer to.</para> + </parameter> + </syntax> + <description> + <para>Attended transfer.</para> + </description> + </manager> + <manager name="Originate" language="en_US"> + <synopsis> + Originate a call. + </synopsis> + <syntax> + <xi:include xpointer="xpointer(/docs/manager[@name='Login']/syntax/parameter[@name='ActionID'])" /> + <parameter name="Channel" required="true"> + <para>Channel name to call.</para> + </parameter> + <parameter name="Exten"> + <para>Extension to use (requires <literal>Context</literal> and + <literal>Priority</literal>)</para> + </parameter> + <parameter name="Context"> + <para>Context to use (requires <literal>Exten</literal> and + <literal>Priority</literal>)</para> + </parameter> + <parameter name="Priority"> + <para>Priority to use (requires <literal>Exten</literal> and + <literal>Context</literal>)</para> + </parameter> + <parameter name="Application"> + <para>Application to execute.</para> + </parameter> + <parameter name="Data"> + <para>Data to use (requires <literal>Application</literal>).</para> + </parameter> + <parameter name="Timeout"> + <para>How long to wait for call to be answered (in ms).</para> + </parameter> + <parameter name="CallerID"> + <para>Caller ID to be set on the outgoing channel.</para> + </parameter> + <parameter name="Variable"> + <para>Channel variable to set, multiple Variable: headers are allowed.</para> + </parameter> + <parameter name="Account"> + <para>Account code.</para> + </parameter> + <parameter name="Async"> + <para>Set to <literal>true</literal> for fast origination.</para> + </parameter> + </syntax> + <description> + <para>Generates an outgoing call to a + <replaceable>Extension</replaceable>/<replaceable>Context</replaceable>/<replaceable>Priority</replaceable> + or <replaceable>Application</replaceable>/<replaceable>Data</replaceable></para> + </description> + </manager> + <manager name="Command" language="en_US"> + <synopsis> + Execute Asterisk CLI Command. + </synopsis> + <syntax> + <xi:include xpointer="xpointer(/docs/manager[@name='Login']/syntax/parameter[@name='ActionID'])" /> + <parameter name="Command" required="true"> + <para>Asterisk CLI command to run.</para> + </parameter> + </syntax> + <description> + <para>Run a CLI command.</para> + </description> + </manager> + <manager name="ExtensionState" language="en_US"> + <synopsis> + Check Extension Status. + </synopsis> + <syntax> + <xi:include xpointer="xpointer(/docs/manager[@name='Login']/syntax/parameter[@name='ActionID'])" /> + <parameter name="Exten" required="true"> + <para>Extension to check state on.</para> + </parameter> + <parameter name="Context" required="true"> + <para>Context for extension.</para> + </parameter> + </syntax> + <description> + <para>Report the extension state for given extension. If the extension has a hint, + will use devicestate to check the status of the device connected to the extension.</para> + <para>Will return an <literal>Extension Status</literal> message. The response will include + the hint for the extension and the status.</para> + </description> + </manager> + <manager name="AbsoluteTimeout" language="en_US"> + <synopsis> + Set absolute timeout. + </synopsis> + <syntax> + <xi:include xpointer="xpointer(/docs/manager[@name='Login']/syntax/parameter[@name='ActionID'])" /> + <parameter name="Channel" required="true"> + <para>Channel name to hangup.</para> + </parameter> + <parameter name="Timeout" required="true"> + <para>Maximum duration of the call (sec).</para> + </parameter> + </syntax> + <description> + <para>Hangup a channel after a certain time. Acknowledges set time with + <literal>Timeout Set</literal> message.</para> + </description> + </manager> + <manager name="MailboxStatus" language="en_US"> + <synopsis> + Check mailbox. + </synopsis> + <syntax> + <xi:include xpointer="xpointer(/docs/manager[@name='Login']/syntax/parameter[@name='ActionID'])" /> + <parameter name="Mailbox" required="true"> + <para>Full mailbox ID <replaceable>mailbox</replaceable>@<replaceable>vm-context</replaceable>.</para> + </parameter> + </syntax> + <description> + <para>Checks a voicemail account for status.</para> + <para>Returns number of messages.</para> + <para>Message: Mailbox Status.</para> + <para>Mailbox: <replaceable>mailboxid</replaceable>.</para> + <para>Waiting: <replaceable>count</replaceable>.</para> + </description> + </manager> + <manager name="MailboxCount" language="en_US"> + <synopsis> + Check Mailbox Message Count. + </synopsis> + <syntax> + <xi:include xpointer="xpointer(/docs/manager[@name='Login']/syntax/parameter[@name='ActionID'])" /> + <parameter name="Mailbox" required="true"> + <para>Full mailbox ID <replaceable>mailbox</replaceable>@<replaceable>vm-context</replaceable>.</para> + </parameter> + </syntax> + <description> + <para>Checks a voicemail account for new messages.</para> + <para>Returns number of urgent, new and old messages.</para> + <para>Message: Mailbox Message Count</para> + <para>Mailbox: <replaceable>mailboxid</replaceable></para> + <para>UrgentMessages: <replaceable>count</replaceable></para> + <para>NewMessages: <replaceable>count</replaceable></para> + <para>OldMessages: <replaceable>count</replaceable></para> + </description> + </manager> + <manager name="ListCommands" language="en_US"> + <synopsis> + List available manager commands. + </synopsis> + <syntax> + <xi:include xpointer="xpointer(/docs/manager[@name='Login']/syntax/parameter[@name='ActionID'])" /> + </syntax> + <description> + <para>Returns the action name and synopsis for every action that + is available to the user.</para> + </description> + </manager> + <manager name="SendText" language="en_US"> + <synopsis> + Send text message to channel. + </synopsis> + <syntax> + <xi:include xpointer="xpointer(/docs/manager[@name='Login']/syntax/parameter[@name='ActionID'])" /> + <parameter name="Channel" required="true"> + <para>Channel to send message to.</para> + </parameter> + <parameter name="Message" required="true"> + <para>Message to send.</para> + </parameter> + </syntax> + <description> + <para>Sends A Text Message to a channel while in a call.</para> + </description> + </manager> + <manager name="UserEvent" language="en_US"> + <synopsis> + Send an arbitrary event. + </synopsis> + <syntax> + <xi:include xpointer="xpointer(/docs/manager[@name='Login']/syntax/parameter[@name='ActionID'])" /> + <parameter name="UserEvent" required="true"> + <para>Event string to send.</para> + </parameter> + <parameter name="Header1"> + <para>Content1.</para> + </parameter> + <parameter name="HeaderN"> + <para>ContentN.</para> + </parameter> + </syntax> + <description> + <para>Send an event to manager sessions.</para> + </description> + </manager> + <manager name="WaitEvent" language="en_US"> + <synopsis> + Wait for an event to occur. + </synopsis> + <syntax> + <xi:include xpointer="xpointer(/docs/manager[@name='Login']/syntax/parameter[@name='ActionID'])" /> + <parameter name="Timeout" required="true"> + <para>Maximum time (in seconds) to wait for events, <literal>-1</literal> means forever.</para> + </parameter> + </syntax> + <description> + <para>This action will ellicit a <literal>Success</literal> response. Whenever + a manager event is queued. Once WaitEvent has been called on an HTTP manager + session, events will be generated and queued.</para> + </description> + </manager> + <manager name="CoreSettings" language="en_US"> + <synopsis> + Show PBX core settings (version etc). + </synopsis> + <syntax> + <xi:include xpointer="xpointer(/docs/manager[@name='Login']/syntax/parameter[@name='ActionID'])" /> + </syntax> + <description> + <para>Query for Core PBX settings.</para> + </description> + </manager> + <manager name="CoreStatus" language="en_US"> + <synopsis> + Show PBX core status variables. + </synopsis> + <syntax> + <xi:include xpointer="xpointer(/docs/manager[@name='Login']/syntax/parameter[@name='ActionID'])" /> + </syntax> + <description> + <para>Query for Core PBX status.</para> + </description> + </manager> + <manager name="Reload" language="en_US"> + <synopsis> + Send a reload event. + </synopsis> + <syntax> + <xi:include xpointer="xpointer(/docs/manager[@name='Login']/syntax/parameter[@name='ActionID'])" /> + <parameter name="Module"> + <para>Name of the module to reload.</para> + </parameter> + </syntax> + <description> + <para>Send a reload event.</para> + </description> + </manager> + <manager name="CoreShowChannels" language="en_US"> + <synopsis> + List currently active channels. + </synopsis> + <syntax> + <xi:include xpointer="xpointer(/docs/manager[@name='Login']/syntax/parameter[@name='ActionID'])" /> + </syntax> + <description> + <para>List currently defined channels and some information about them.</para> + </description> + </manager> + <manager name="ModuleLoad" language="en_US"> + <synopsis> + Module management. + </synopsis> + <syntax> + <xi:include xpointer="xpointer(/docs/manager[@name='Login']/syntax/parameter[@name='ActionID'])" /> + <parameter name="Module"> + <para>Asterisk module name (including .so extension) or subsystem identifier:</para> + <enumlist> + <enum name="cdr" /> + <enum name="enum" /> + <enum name="dnsmgr" /> + <enum name="extconfig" /> + <enum name="manager" /> + <enum name="rtp" /> + <enum name="http" /> + </enumlist> + </parameter> + <parameter name="LoadType" required="true"> + <para>The operation to be done on module.</para> + <enumlist> + <enum name="load" /> + <enum name="unload" /> + <enum name="reload" /> + </enumlist> + <para>If no module is specified for a <literal>reload</literal> loadtype, + all modules are reloaded.</para> + </parameter> + </syntax> + <description> + <para>Loads, unloads or reloads an Asterisk module in a running system.</para> + </description> + </manager> + <manager name="ModuleCheck" language="en_US"> + <synopsis> + Check if module is loaded. + </synopsis> + <syntax> + <parameter name="Module" required="true"> + <para>Asterisk module name (not including extension).</para> + </parameter> + </syntax> + <description> + <para>Checks if Asterisk module is loaded. Will return Success/Failure. + For success returns, the module revision number is included.</para> + </description> + </manager> + ***/ + enum error_type { UNKNOWN_ACTION = 1, UNKNOWN_CATEGORY, @@ -604,6 +1216,10 @@ static char *handle_showmancmd(struct ast_cli_entry *e, int cmd, struct ast_cli_ struct ast_str *authority; int num, l, which; char *ret = NULL; +#ifdef AST_XML_DOCS + char syntax_title[64], description_title[64], synopsis_title[64], seealso_title[64], arguments_title[64]; +#endif + switch (cmd) { case CLI_INIT: e->command = "manager show command"; @@ -629,14 +1245,41 @@ static char *handle_showmancmd(struct ast_cli_entry *e, int cmd, struct ast_cli_ return CLI_SHOWUSAGE; } +#ifdef AST_XML_DOCS + /* setup the titles */ + term_color(synopsis_title, "[Synopsis]\n", COLOR_MAGENTA, 0, 40); + term_color(description_title, "[Description]\n", COLOR_MAGENTA, 0, 40); + term_color(syntax_title, "[Syntax]\n", COLOR_MAGENTA, 0, 40); + term_color(seealso_title, "[See Also]\n", COLOR_MAGENTA, 0, 40); + term_color(arguments_title, "[Arguments]\n", COLOR_MAGENTA, 0, 40); +#endif + AST_RWLIST_RDLOCK(&actions); AST_RWLIST_TRAVERSE(&actions, cur, list) { for (num = 3; num < a->argc; num++) { if (!strcasecmp(cur->action, a->argv[num])) { - ast_cli(a->fd, "Action: %s\nSynopsis: %s\nPrivilege: %s\n%s\n", - cur->action, cur->synopsis, - authority_to_str(cur->authority, &authority), - S_OR(cur->description, "")); +#ifdef AST_XML_DOCS + if (cur->docsrc == AST_XML_DOC) { + ast_cli(a->fd, "%s%s\n\n%s%s\n\n%s%s\n\n%s%s\n\n%s%s\n\n", + syntax_title, + ast_xmldoc_printable(S_OR(cur->syntax, "Not available"), 1), + synopsis_title, + ast_xmldoc_printable(S_OR(cur->synopsis, "Not available"), 1), + description_title, + ast_xmldoc_printable(S_OR(cur->description, "Not available"), 1), + arguments_title, + ast_xmldoc_printable(S_OR(cur->arguments, "Not available"), 1), + seealso_title, + ast_xmldoc_printable(S_OR(cur->seealso, "Not available"), 1)); + } else { +#endif + ast_cli(a->fd, "Action: %s\nSynopsis: %s\nPrivilege: %s\n%s\n", + cur->action, cur->synopsis, + authority_to_str(cur->authority, &authority), + S_OR(cur->description, "")); +#ifdef AST_XML_DOCS + } +#endif } } } @@ -1207,12 +1850,6 @@ static int authenticate(struct mansession *s, const struct message *m) return 0; } -/*! \brief Manager PING */ -static const char mandescr_ping[] = -"Description: A 'Ping' action will ellicit a 'Pong' response. Used to keep the\n" -" manager connection open.\n" -"Variables: NONE\n"; - static int action_ping(struct mansession *s, const struct message *m) { const char *actionid = astman_get_header(m, "ActionID"); @@ -1225,13 +1862,6 @@ static int action_ping(struct mansession *s, const struct message *m) return 0; } -static const char mandescr_getconfig[] = -"Description: A 'GetConfig' action will dump the contents of a configuration\n" -"file by category and contents or optionally by specified category only.\n" -"Variables: (Names marked with * are required)\n" -" *Filename: Configuration filename (e.g. foo.conf)\n" -" Category: Category in configuration file\n"; - static int action_getconfig(struct mansession *s, const struct message *m) { struct ast_config *cfg; @@ -1273,12 +1903,6 @@ static int action_getconfig(struct mansession *s, const struct message *m) return 0; } -static const char mandescr_listcategories[] = -"Description: A 'ListCategories' action will dump the categories in\n" -"a given file.\n" -"Variables:\n" -" Filename: Configuration filename (e.g. foo.conf)\n"; - static int action_listcategories(struct mansession *s, const struct message *m) { struct ast_config *cfg; @@ -1324,13 +1948,6 @@ static void json_escape(char *out, const char *in) *out = '\0'; } -static const char mandescr_getconfigjson[] = -"Description: A 'GetConfigJSON' action will dump the contents of a configuration\n" -"file by category and contents in JSON format. This only makes sense to be used\n" -"using rawman over the HTTP interface.\n" -"Variables:\n" -" Filename: Configuration filename (e.g. foo.conf)\n"; - static int action_getconfigjson(struct mansession *s, const struct message *m) { struct ast_config *cfg; @@ -1543,20 +2160,6 @@ static enum error_type handle_updates(struct mansession *s, const struct message return result; } -static const char mandescr_updateconfig[] = -"Description: A 'UpdateConfig' action will modify, create, or delete\n" -"configuration elements in Asterisk configuration files.\n" -"Variables (X's represent 6 digit number beginning with 000000):\n" -" SrcFilename: Configuration filename to read(e.g. foo.conf)\n" -" DstFilename: Configuration filename to write(e.g. foo.conf)\n" -" Reload: Whether or not a reload should take place (or name of specific module)\n" -" Action-XXXXXX: Action to Take (NewCat,RenameCat,DelCat,EmptyCat,Update,Delete,Append,Insert)\n" -" Cat-XXXXXX: Category to operate on\n" -" Var-XXXXXX: Variable to work on\n" -" Value-XXXXXX: Value to work on\n" -" Match-XXXXXX: Extra match required to match line\n" -" Line-XXXXXX: Line in category to operate on (used with delete and insert actions)\n"; - static int action_updateconfig(struct mansession *s, const struct message *m) { struct ast_config *cfg; @@ -1632,13 +2235,6 @@ static int action_updateconfig(struct mansession *s, const struct message *m) return 0; } -static const char mandescr_createconfig[] = -"Description: A 'CreateConfig' action will create an empty file in the\n" -"configuration directory. This action is intended to be used before an\n" -"UpdateConfig action.\n" -"Variables\n" -" Filename: The configuration filename to create (e.g. foo.conf)\n"; - static int action_createconfig(struct mansession *s, const struct message *m) { int fd; @@ -1657,14 +2253,6 @@ static int action_createconfig(struct mansession *s, const struct message *m) return 0; } -/*! \brief Manager WAITEVENT */ -static const char mandescr_waitevent[] = -"Description: A 'WaitEvent' action will ellicit a 'Success' response. Whenever\n" -"a manager event is queued. Once WaitEvent has been called on an HTTP manager\n" -"session, events will be generated and queued.\n" -"Variables: \n" -" Timeout: Maximum time (in seconds) to wait for events, -1 means forever.\n"; - static int action_waitevent(struct mansession *s, const struct message *m) { const char *timeouts = astman_get_header(m, "Timeout"); @@ -1771,11 +2359,6 @@ static int action_waitevent(struct mansession *s, const struct message *m) return 0; } -static const char mandescr_listcommands[] = -"Description: Returns the action name and synopsis for every\n" -" action that is available to the user\n" -"Variables: NONE\n"; - /*! \note The actionlock is read-locked by the caller of this function */ static int action_listcommands(struct mansession *s, const struct message *m) { @@ -1794,14 +2377,6 @@ static int action_listcommands(struct mansession *s, const struct message *m) return 0; } -static const char mandescr_events[] = -"Description: Enable/Disable sending of events to this manager\n" -" client.\n" -"Variables:\n" -" EventMask: 'on' if all events should be sent,\n" -" 'off' if no events should be sent,\n" -" 'system,call,log' to select which flags events should have to be sent.\n"; - static int action_events(struct mansession *s, const struct message *m) { const char *mask = astman_get_header(m, "EventMask"); @@ -1817,10 +2392,6 @@ static int action_events(struct mansession *s, const struct message *m) return 0; } -static const char mandescr_logoff[] = -"Description: Logoff this manager session\n" -"Variables: NONE\n"; - static int action_logoff(struct mansession *s, const struct message *m) { astman_send_response(s, m, "Goodbye", "Thanks for all the fish."); @@ -1867,12 +2438,6 @@ static int action_challenge(struct mansession *s, const struct message *m) return 0; } -static const char mandescr_hangup[] = -"Description: Hangup a channel\n" -"Variables: \n" -" Channel: The channel name to be hungup\n" -" Cause: numeric hangup cause\n"; - static int action_hangup(struct mansession *s, const struct message *m) { struct ast_channel *c = NULL; @@ -1916,13 +2481,6 @@ static int action_hangup(struct mansession *s, const struct message *m) return 0; } -static const char mandescr_setvar[] = -"Description: Set a global or local channel variable.\n" -"Variables: (Names marked with * are required)\n" -" Channel: Channel to set variable for\n" -" *Variable: Variable name\n" -" *Value: Value\n"; - static int action_setvar(struct mansession *s, const struct message *m) { struct ast_channel *c = NULL; @@ -1953,13 +2511,6 @@ static int action_setvar(struct mansession *s, const struct message *m) return 0; } -static const char mandescr_getvar[] = -"Description: Get the value of a global or local channel variable.\n" -"Variables: (Names marked with * are required)\n" -" Channel: Channel to read variable from\n" -" *Variable: Variable name\n" -" ActionID: Optional Action id for message matching.\n"; - static int action_getvar(struct mansession *s, const struct message *m) { struct ast_channel *c = NULL; @@ -2006,16 +2557,6 @@ static int action_getvar(struct mansession *s, const struct message *m) return 0; } -static const char mandescr_status[] = -"Description: Lists channel status along with requested channel vars.\n" -"Variables: (Names marked with * are required)\n" -" *Channel: Name of the channel to query for status\n" -" Variables: Comma ',' separated list of variables to include\n" -" ActionID: Optional ID for this transaction\n" -"Will return the status information of each channel along with the\n" -"value for the specified channel variables.\n"; - - /*! \brief Manager "status" command to show channels */ /* Needs documentation... */ static int action_status(struct mansession *s, const struct message *m) @@ -2163,13 +2704,6 @@ static int action_status(struct mansession *s, const struct message *m) return 0; } -static const char mandescr_sendtext[] = -"Description: Sends A Text Message while in a call.\n" -"Variables: (Names marked with * are required)\n" -" *Channel: Channel to send message to\n" -" *Message: Message to send\n" -" ActionID: Optional Action id for message matching.\n"; - static int action_sendtext(struct mansession *s, const struct message *m) { struct ast_channel *c = NULL; @@ -2206,16 +2740,6 @@ static int action_sendtext(struct mansession *s, const struct message *m) return res; } -static const char mandescr_redirect[] = -"Description: Redirect (transfer) a call.\n" -"Variables: (Names marked with * are required)\n" -" *Channel: Channel to redirect\n" -" ExtraChannel: Second call leg to transfer (optional)\n" -" *Exten: Extension to transfer to\n" -" *Context: Context to transfer to\n" -" *Priority: Priority to transfer to\n" -" ActionID: Optional Action id for message matching.\n"; - /*! \brief action_redirect: The redirect manager command */ static int action_redirect(struct mansession *s, const struct message *m) { @@ -2306,15 +2830,6 @@ static int action_redirect(struct mansession *s, const struct message *m) return 0; } -static const char mandescr_atxfer[] = -"Description: Attended transfer.\n" -"Variables: (Names marked with * are required)\n" -" *Channel: Transferer's channel\n" -" *Exten: Extension to transfer to\n" -" *Context: Context to transfer to\n" -" *Priority: Priority to transfer to\n" -" ActionID: Optional Action id for message matching.\n"; - static int action_atxfer(struct mansession *s, const struct message *m) { const char *name = astman_get_header(m, "Channel"); @@ -2399,12 +2914,6 @@ static int check_blacklist(const char *cmd) return 0; } -static const char mandescr_command[] = -"Description: Run a CLI command.\n" -"Variables: (Names marked with * are required)\n" -" *Command: Asterisk CLI command to run\n" -" ActionID: Optional Action id for message matching.\n"; - /*! \brief Manager command "command" - execute CLI command */ static int action_command(struct mansession *s, const struct message *m) { @@ -2526,22 +3035,6 @@ static void *fast_originate(void *data) return NULL; } -static const char mandescr_originate[] = -"Description: Generates an outgoing call to a Extension/Context/Priority or\n" -" Application/Data\n" -"Variables: (Names marked with * are required)\n" -" *Channel: Channel name to call\n" -" Exten: Extension to use (requires 'Context' and 'Priority')\n" -" Context: Context to use (requires 'Exten' and 'Priority')\n" -" Priority: Priority to use (requires 'Exten' and 'Context')\n" -" Application: Application to use\n" -" Data: Data to use (requires 'Application')\n" -" Timeout: How long to wait for call to be answered (in ms)\n" -" CallerID: Caller ID to be set on the outgoing channel\n" -" Variable: Channel variable to set, multiple Variable: headers are allowed\n" -" Account: Account code\n" -" Async: Set to 'true' for fast origination\n"; - static int action_originate(struct mansession *s, const struct message *m) { const char *name = astman_get_header(m, "Channel"); @@ -2671,19 +3164,6 @@ static int action_originate(struct mansession *s, const struct message *m) return 0; } -/*! \brief Help text for manager command mailboxstatus - */ -static const char mandescr_mailboxstatus[] = -"Description: Checks a voicemail account for status.\n" -"Variables: (Names marked with * are required)\n" -" *Mailbox: Full mailbox ID <mailbox>@<vm-context>\n" -" ActionID: Optional ActionID for message matching.\n" -"Returns number of messages.\n" -" Message: Mailbox Status\n" -" Mailbox: <mailboxid>\n" -" Waiting: <count>\n" -"\n"; - static int action_mailboxstatus(struct mansession *s, const struct message *m) { const char *mailbox = astman_get_header(m, "Mailbox"); @@ -2701,18 +3181,6 @@ static int action_mailboxstatus(struct mansession *s, const struct message *m) return 0; } -static const char mandescr_mailboxcount[] = -"Description: Checks a voicemail account for new messages.\n" -"Variables: (Names marked with * are required)\n" -" *Mailbox: Full mailbox ID <mailbox>@<vm-context>\n" -" ActionID: Optional ActionID for message matching.\n" -"Returns number of urgent, new and old messages.\n" -" Message: Mailbox Message Count\n" -" Mailbox: <mailboxid>\n" -" UrgentMessages: <count>\n" -" NewMessages: <count>\n" -" OldMessages: <count>\n" -"\n"; static int action_mailboxcount(struct mansession *s, const struct message *m) { const char *mailbox = astman_get_header(m, "Mailbox"); @@ -2734,17 +3202,6 @@ static int action_mailboxcount(struct mansession *s, const struct message *m) return 0; } -static const char mandescr_extensionstate[] = -"Description: Report the extension state for given extension.\n" -" If the extension has a hint, will use devicestate to check\n" -" the status of the device connected to the extension.\n" -"Variables: (Names marked with * are required)\n" -" *Exten: Extension to check state on\n" -" *Context: Context for extension\n" -" ActionId: Optional ID for this transaction\n" -"Will return an \"Extension Status\" message.\n" -"The response will include the hint for the extension and the status.\n"; - static int action_extensionstate(struct mansession *s, const struct message *m) { const char *exten = astman_get_header(m, "Exten"); @@ -2770,13 +3227,6 @@ static int action_extensionstate(struct mansession *s, const struct message *m) return 0; } -static const char mandescr_timeout[] = -"Description: Hangup a channel after a certain time.\n" -"Variables: (Names marked with * are required)\n" -" *Channel: Channel name to hangup\n" -" *Timeout: Maximum duration of the call (sec)\n" -"Acknowledges set time with 'Timeout Set' message\n"; - static int action_timeout(struct mansession *s, const struct message *m) { struct ast_channel *c; @@ -2839,13 +3289,6 @@ static int process_events(struct mansession *s) return ret; } -static const char mandescr_userevent[] = -"Description: Send an event to manager sessions.\n" -"Variables: (Names marked with * are required)\n" -" *UserEvent: EventStringToSend\n" -" Header1: Content1\n" -" HeaderN: ContentN\n"; - static int action_userevent(struct mansession *s, const struct message *m) { const char *event = astman_get_header(m, "UserEvent"); @@ -2864,11 +3307,6 @@ static int action_userevent(struct mansession *s, const struct message *m) return 0; } -static const char mandescr_coresettings[] = -"Description: Query for Core PBX settings.\n" -"Variables: (Names marked with * are optional)\n" -" *ActionID: ActionID of this transaction\n"; - /*! \brief Show PBX core settings information */ static int action_coresettings(struct mansession *s, const struct message *m) { @@ -2911,11 +3349,6 @@ static int action_coresettings(struct mansession *s, const struct message *m) return 0; } -static const char mandescr_corestatus[] = -"Description: Query for Core PBX status.\n" -"Variables: (Names marked with * are optional)\n" -" *ActionID: ActionID of this transaction\n"; - /*! \brief Show PBX core status information */ static int action_corestatus(struct mansession *s, const struct message *m) { @@ -2950,12 +3383,6 @@ static int action_corestatus(struct mansession *s, const struct message *m) return 0; } -static const char mandescr_reload[] = -"Description: Send a reload event.\n" -"Variables: (Names marked with * are optional)\n" -" *ActionID: ActionID of this transaction\n" -" *Module: Name of the module to reload\n"; - /*! \brief Send a reload event */ static int action_reload(struct mansession *s, const struct message *m) { @@ -2970,12 +3397,6 @@ static int action_reload(struct mansession *s, const struct message *m) return 0; } -static const char mandescr_coreshowchannels[] = -"Description: List currently defined channels and some information\n" -" about them.\n" -"Variables:\n" -" ActionID: Optional Action id for message matching.\n"; - /*! \brief Manager command "CoreShowChannels" - List currently defined channels * and some information about them. */ static int action_coreshowchannels(struct mansession *s, const struct message *m) @@ -3052,15 +3473,6 @@ static int action_coreshowchannels(struct mansession *s, const struct message *m return 0; } -static const char mandescr_modulecheck[] = -"Description: Checks if Asterisk module is loaded\n" -"Variables: \n" -" ActionID: <id> Action ID for this transaction. Will be returned.\n" -" Module: <name> Asterisk module name (not including extension)\n" -"\n" -"Will return Success/Failure\n" -"For success returns, the module revision number is included.\n"; - /* Manager function to check if module is loaded */ static int manager_modulecheck(struct mansession *s, const struct message *m) { @@ -3105,17 +3517,6 @@ static int manager_modulecheck(struct mansession *s, const struct message *m) return 0; } -static const char mandescr_moduleload[] = -"Description: Loads, unloads or reloads an Asterisk module in a running system.\n" -"Variables: \n" -" ActionID: <id> Action ID for this transaction. Will be returned.\n" -" Module: <name> Asterisk module name (including .so extension)\n" -" or subsystem identifier:\n" -" cdr, enum, dnsmgr, extconfig, manager, rtp, http\n" -" LoadType: load | unload | reload\n" -" The operation to be done on module\n" -" If no module is specified for a reload loadtype, all modules are reloaded"; - static int manager_moduleload(struct mansession *s, const struct message *m) { int res; @@ -3584,6 +3985,7 @@ int ast_manager_unregister(char *action) AST_RWLIST_TRAVERSE_SAFE_BEGIN(&actions, cur, list) { if (!strcasecmp(action, cur->action)) { AST_RWLIST_REMOVE_CURRENT(list); + ast_string_field_free_memory(cur); ast_free(cur); ast_verb(2, "Manager unregistered action %s\n", action); break; @@ -3645,17 +4047,53 @@ static int ast_manager_register_struct(struct manager_action *act) int ast_manager_register2(const char *action, int auth, int (*func)(struct mansession *s, const struct message *m), const char *synopsis, const char *description) { struct manager_action *cur = NULL; +#ifdef AST_XML_DOCS + char *tmpxml; +#endif if (!(cur = ast_calloc(1, sizeof(*cur)))) { return -1; } + if (ast_string_field_init(cur, 128)) { + ast_free(cur); + return -1; + } + cur->action = action; cur->authority = auth; cur->func = func; - cur->synopsis = synopsis; - cur->description = description; +#ifdef AST_XML_DOCS + if (ast_strlen_zero(synopsis) && ast_strlen_zero(description)) { + tmpxml = ast_xmldoc_build_synopsis("manager", action); + ast_string_field_set(cur, synopsis, tmpxml); + ast_free(tmpxml); + + tmpxml = ast_xmldoc_build_syntax("manager", action); + ast_string_field_set(cur, syntax, tmpxml); + ast_free(tmpxml); + + tmpxml = ast_xmldoc_build_description("manager", action); + ast_string_field_set(cur, description, tmpxml); + ast_free(tmpxml); + tmpxml = ast_xmldoc_build_seealso("manager", action); + ast_string_field_set(cur, seealso, tmpxml); + ast_free(tmpxml); + + tmpxml = ast_xmldoc_build_arguments("manager", action); + ast_string_field_set(cur, arguments, tmpxml); + ast_free(tmpxml); + + cur->docsrc = AST_XML_DOC; + } else { +#endif + ast_string_field_set(cur, synopsis, synopsis); + ast_string_field_set(cur, description, description); +#ifdef AST_XML_DOCS + cur->docsrc = AST_STATIC_DOC; + } +#endif if (ast_manager_register_struct(cur)) { ast_free(cur); return -1; @@ -4724,38 +5162,38 @@ static int __init_manager(int reload) if (!registered) { /* Register default actions */ - ast_manager_register2("Ping", 0, action_ping, "Keepalive command", mandescr_ping); - ast_manager_register2("Events", 0, action_events, "Control Event Flow", mandescr_events); - ast_manager_register2("Logoff", 0, action_logoff, "Logoff Manager", mandescr_logoff); - ast_manager_register2("Login", 0, action_login, "Login Manager", NULL); - ast_manager_register2("Challenge", 0, action_challenge, "Generate Challenge for MD5 Auth", NULL); - ast_manager_register2("Hangup", EVENT_FLAG_SYSTEM | EVENT_FLAG_CALL, action_hangup, "Hangup Channel", mandescr_hangup); - ast_manager_register2("Status", EVENT_FLAG_SYSTEM | EVENT_FLAG_CALL | EVENT_FLAG_REPORTING, action_status, "Lists channel status", mandescr_status); - ast_manager_register2("Setvar", EVENT_FLAG_CALL, action_setvar, "Set Channel Variable", mandescr_setvar); - ast_manager_register2("Getvar", EVENT_FLAG_CALL | EVENT_FLAG_REPORTING, action_getvar, "Gets a Channel Variable", mandescr_getvar); - ast_manager_register2("GetConfig", EVENT_FLAG_SYSTEM | EVENT_FLAG_CONFIG, action_getconfig, "Retrieve configuration", mandescr_getconfig); - ast_manager_register2("GetConfigJSON", EVENT_FLAG_SYSTEM | EVENT_FLAG_CONFIG, action_getconfigjson, "Retrieve configuration (JSON format)", mandescr_getconfigjson); - ast_manager_register2("UpdateConfig", EVENT_FLAG_CONFIG, action_updateconfig, "Update basic configuration", mandescr_updateconfig); - ast_manager_register2("CreateConfig", EVENT_FLAG_CONFIG, action_createconfig, "Creates an empty file in the configuration directory", mandescr_createconfig); - ast_manager_register2("ListCategories", EVENT_FLAG_CONFIG, action_listcategories, "List categories in configuration file", mandescr_listcategories); - ast_manager_register2("Redirect", EVENT_FLAG_CALL, action_redirect, "Redirect (transfer) a call", mandescr_redirect ); - ast_manager_register2("Atxfer", EVENT_FLAG_CALL, action_atxfer, "Attended transfer", mandescr_atxfer); - ast_manager_register2("Originate", EVENT_FLAG_ORIGINATE, action_originate, "Originate Call", mandescr_originate); - ast_manager_register2("Command", EVENT_FLAG_COMMAND, action_command, "Execute Asterisk CLI Command", mandescr_command ); - ast_manager_register2("ExtensionState", EVENT_FLAG_CALL | EVENT_FLAG_REPORTING, action_extensionstate, "Check Extension Status", mandescr_extensionstate ); - ast_manager_register2("AbsoluteTimeout", EVENT_FLAG_SYSTEM | EVENT_FLAG_CALL, action_timeout, "Set Absolute Timeout", mandescr_timeout ); - ast_manager_register2("MailboxStatus", EVENT_FLAG_CALL | EVENT_FLAG_REPORTING, action_mailboxstatus, "Check Mailbox", mandescr_mailboxstatus ); - ast_manager_register2("MailboxCount", EVENT_FLAG_CALL | EVENT_FLAG_REPORTING, action_mailboxcount, "Check Mailbox Message Count", mandescr_mailboxcount ); - ast_manager_register2("ListCommands", 0, action_listcommands, "List available manager commands", mandescr_listcommands); - ast_manager_register2("SendText", EVENT_FLAG_CALL, action_sendtext, "Send text message to channel", mandescr_sendtext); - ast_manager_register2("UserEvent", EVENT_FLAG_USER, action_userevent, "Send an arbitrary event", mandescr_userevent); - ast_manager_register2("WaitEvent", 0, action_waitevent, "Wait for an event to occur", mandescr_waitevent); - ast_manager_register2("CoreSettings", EVENT_FLAG_SYSTEM | EVENT_FLAG_REPORTING, action_coresettings, "Show PBX core settings (version etc)", mandescr_coresettings); - ast_manager_register2("CoreStatus", EVENT_FLAG_SYSTEM | EVENT_FLAG_REPORTING, action_corestatus, "Show PBX core status variables", mandescr_corestatus); - ast_manager_register2("Reload", EVENT_FLAG_CONFIG | EVENT_FLAG_SYSTEM, action_reload, "Send a reload event", mandescr_reload); - ast_manager_register2("CoreShowChannels", EVENT_FLAG_SYSTEM | EVENT_FLAG_REPORTING, action_coreshowchannels, "List currently active channels", mandescr_coreshowchannels); - ast_manager_register2("ModuleLoad", EVENT_FLAG_SYSTEM, manager_moduleload, "Module management", mandescr_moduleload); - ast_manager_register2("ModuleCheck", EVENT_FLAG_SYSTEM, manager_modulecheck, "Check if module is loaded", mandescr_modulecheck); + ast_manager_register_xml("Ping", 0, action_ping); + ast_manager_register_xml("Events", 0, action_events); + ast_manager_register_xml("Logoff", 0, action_logoff); + ast_manager_register_xml("Login", 0, action_login); + ast_manager_register_xml("Challenge", 0, action_challenge); + ast_manager_register_xml("Hangup", EVENT_FLAG_SYSTEM | EVENT_FLAG_CALL, action_hangup); + ast_manager_register_xml("Status", EVENT_FLAG_SYSTEM | EVENT_FLAG_CALL | EVENT_FLAG_REPORTING, action_status); + ast_manager_register_xml("Setvar", EVENT_FLAG_CALL, action_setvar); + ast_manager_register_xml("Getvar", EVENT_FLAG_CALL | EVENT_FLAG_REPORTING, action_getvar); + ast_manager_register_xml("GetConfig", EVENT_FLAG_SYSTEM | EVENT_FLAG_CONFIG, action_getconfig); + ast_manager_register_xml("GetConfigJSON", EVENT_FLAG_SYSTEM | EVENT_FLAG_CONFIG, action_getconfigjson); + ast_manager_register_xml("UpdateConfig", EVENT_FLAG_CONFIG, action_updateconfig); + ast_manager_register_xml("CreateConfig", EVENT_FLAG_CONFIG, action_createconfig); + ast_manager_register_xml("ListCategories", EVENT_FLAG_CONFIG, action_listcategories); + ast_manager_register_xml("Redirect", EVENT_FLAG_CALL, action_redirect); + ast_manager_register_xml("Atxfer", EVENT_FLAG_CALL, action_atxfer); + ast_manager_register_xml("Originate", EVENT_FLAG_ORIGINATE, action_originate); + ast_manager_register_xml("Command", EVENT_FLAG_COMMAND, action_command); + ast_manager_register_xml("ExtensionState", EVENT_FLAG_CALL | EVENT_FLAG_REPORTING, action_extensionstate); + ast_manager_register_xml("AbsoluteTimeout", EVENT_FLAG_SYSTEM | EVENT_FLAG_CALL, action_timeout); + ast_manager_register_xml("MailboxStatus", EVENT_FLAG_CALL | EVENT_FLAG_REPORTING, action_mailboxstatus); + ast_manager_register_xml("MailboxCount", EVENT_FLAG_CALL | EVENT_FLAG_REPORTING, action_mailboxcount); + ast_manager_register_xml("ListCommands", 0, action_listcommands); + ast_manager_register_xml("SendText", EVENT_FLAG_CALL, action_sendtext); + ast_manager_register_xml("UserEvent", EVENT_FLAG_USER, action_userevent); + ast_manager_register_xml("WaitEvent", 0, action_waitevent); + ast_manager_register_xml("CoreSettings", EVENT_FLAG_SYSTEM | EVENT_FLAG_REPORTING, action_coresettings); + ast_manager_register_xml("CoreStatus", EVENT_FLAG_SYSTEM | EVENT_FLAG_REPORTING, action_corestatus); + ast_manager_register_xml("Reload", EVENT_FLAG_CONFIG | EVENT_FLAG_SYSTEM, action_reload); + ast_manager_register_xml("CoreShowChannels", EVENT_FLAG_SYSTEM | EVENT_FLAG_REPORTING, action_coreshowchannels); + ast_manager_register_xml("ModuleLoad", EVENT_FLAG_SYSTEM, manager_moduleload); + ast_manager_register_xml("ModuleCheck", EVENT_FLAG_SYSTEM, manager_modulecheck); ast_cli_register_multiple(cli_manager, ARRAY_LEN(cli_manager)); ast_extension_state_add(NULL, NULL, manager_state_cb, NULL); diff --git a/main/pbx.c b/main/pbx.c index f64810e16..4e4b1c683 100644 --- a/main/pbx.c +++ b/main/pbx.c @@ -717,6 +717,24 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") <ref type="application">RaiseException</ref> </see-also> </function> + <manager name="ShowDialPlan" language="en_US"> + <synopsis> + La merde se produit. + </synopsis> + <syntax> + <xi:include xpointer="xpointer(/docs/manager[@name='Login']/syntax/parameter[@name='ActionID'])" /> + <parameter name="Extension"> + <para>Show a specific extension.</para> + </parameter> + <parameter name="Context"> + <para>Show a specific context.</para> + </parameter> + </syntax> + <description> + <para>Show dialplan contexts and extensions. Be aware that showing the full dialplan + may take a lot of capacity.</para> + </description> + </manager> ***/ #ifdef LOW_MEMORY @@ -863,7 +881,9 @@ struct ast_app { AST_STRING_FIELD(arguments); /*!< Arguments description */ AST_STRING_FIELD(seealso); /*!< See also */ ); - enum ast_doc_src docsrc;/*!< Where the documentation come from. */ +#ifdef AST_XML_DOCS + enum ast_doc_src docsrc; /*!< Where the documentation come from. */ +#endif AST_RWLIST_ENTRY(ast_app) list; /*!< Next app in list */ struct ast_module *module; /*!< Module this app belongs to */ char name[0]; /*!< Name of the application */ @@ -3267,9 +3287,11 @@ int ast_custom_function_unregister(struct ast_custom_function *acf) AST_RWLIST_WRLOCK(&acf_root); if ((cur = AST_RWLIST_REMOVE(&acf_root, acf, acflist))) { +#ifdef AST_XML_DOCS if (cur->docsrc == AST_XML_DOC) { ast_string_field_free_memory(acf); } +#endif ast_verb(2, "Unregistered custom function %s\n", cur->name); } AST_RWLIST_UNLOCK(&acf_root); @@ -3340,7 +3362,9 @@ int __ast_custom_function_register(struct ast_custom_function *acf, struct ast_m } acf->mod = mod; +#ifdef AST_XML_DOCS acf->docsrc = AST_STATIC_DOC; +#endif if (acf_retrieve_docs(acf)) { return -1; @@ -5395,8 +5419,8 @@ int ast_register_application2(const char *app, int (*execute)(struct ast_channel #endif ast_string_field_set(tmp, synopsis, synopsis); ast_string_field_set(tmp, description, description); - tmp->docsrc = AST_STATIC_DOC; #ifdef AST_XML_DOCS + tmp->docsrc = AST_STATIC_DOC; } #endif @@ -6416,15 +6440,6 @@ static int manager_show_dialplan(struct mansession *s, const struct message *m) return 0; } -static const char mandescr_show_dialplan[] = -"Description: Show dialplan contexts and extensions.\n" -"Be aware that showing the full dialplan may take a lot of capacity\n" -"Variables: \n" -" ActionID: <id> Action ID for this AMI transaction (optional)\n" -" Extension: <extension> Extension (Optional)\n" -" Context: <context> Context (Optional)\n" -"\n"; - /*! \brief CLI support for listing global variables in a parseable way */ static char *handle_show_globals(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) { @@ -9546,7 +9561,7 @@ int load_pbx(void) } /* Register manager application */ - ast_manager_register2("ShowDialPlan", EVENT_FLAG_CONFIG | EVENT_FLAG_REPORTING, manager_show_dialplan, "List dialplan", mandescr_show_dialplan); + ast_manager_register_xml("ShowDialPlan", EVENT_FLAG_CONFIG | EVENT_FLAG_REPORTING, manager_show_dialplan); if (!(device_state_sub = ast_event_subscribe(AST_EVENT_DEVICE_STATE, device_state_cb, NULL, AST_EVENT_IE_END))) { diff --git a/main/xmldoc.c b/main/xmldoc.c index 29d951ac5..3f9b607d2 100644 --- a/main/xmldoc.c +++ b/main/xmldoc.c @@ -986,9 +986,66 @@ static char *xmldoc_get_syntax_cmd(struct ast_xml_node *fixnode, const char *nam return ret; } +/*! \internal + * \brief Generate an AMI action syntax. + * \param fixnode The manager action node pointer. + * \param name The name of the manager action. + * \retval The generated syntax. + * \retval NULL on error. + */ +static char *xmldoc_get_syntax_manager(struct ast_xml_node *fixnode, const char *name) +{ + struct ast_str *syntax; + struct ast_xml_node *node = fixnode; + const char *paramtype, *attrname; + int required; + char *ret; + + syntax = ast_str_create(128); + if (!syntax) { + return ast_strdup(name); + } + + ast_str_append(&syntax, 0, "Action: %s", name); + + for (node = ast_xml_node_get_children(node); node; node = ast_xml_node_get_next(node)) { + if (strcasecmp(ast_xml_node_get_name(node), "parameter")) { + continue; + } + + /* Is this parameter required? */ + required = 0; + paramtype = ast_xml_get_attribute(node, "required"); + if (paramtype) { + required = ast_true(paramtype); + ast_xml_free_attr(paramtype); + } + + attrname = ast_xml_get_attribute(node, "name"); + if (!attrname) { + /* ignore this bogus parameter and continue. */ + continue; + } + + ast_str_append(&syntax, 0, "\n%s%s:%s <value>", + (required ? "" : "["), + attrname, + (required ? "" : "]")); + + ast_xml_free_attr(attrname); + } + + /* return a common string. */ + ret = ast_strdup(ast_str_buffer(syntax)); + ast_free(syntax); + + return ret; +} + /*! \brief Types of syntax that we are able to generate. */ enum syntaxtype { FUNCTION_SYNTAX, + MANAGER_SYNTAX, COMMAND_SYNTAX }; @@ -999,6 +1056,7 @@ struct strsyntaxtype { } stxtype[] = { { "function", FUNCTION_SYNTAX }, { "application", FUNCTION_SYNTAX }, + { "manager", MANAGER_SYNTAX }, { "agi", COMMAND_SYNTAX } }; @@ -1036,10 +1094,18 @@ char *ast_xmldoc_build_syntax(const char *type, const char *name) } if (node) { - if (xmldoc_get_syntax_type(type) == FUNCTION_SYNTAX) { + switch (xmldoc_get_syntax_type(type)) { + case FUNCTION_SYNTAX: syntax = xmldoc_get_syntax_fun(node, name, "parameter", 1, 1); - } else { + break; + case COMMAND_SYNTAX: syntax = xmldoc_get_syntax_cmd(node, name, 1); + break; + case MANAGER_SYNTAX: + syntax = xmldoc_get_syntax_manager(node, name); + break; + default: + syntax = xmldoc_get_syntax_fun(node, name, "parameter", 1, 1); } } return syntax; |