From cbbfdc573c6f071b12dc665273c0063a0c69ad69 Mon Sep 17 00:00:00 2001 From: eliel Date: Fri, 22 May 2009 17:52:35 +0000 Subject: 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: AMI action synopsis. <-- for ActionID Description ... AMI action description ... git-svn-id: http://svn.digium.com/svn/asterisk/trunk@196308 f38db490-d61c-443f-a65b-d21fe96a405b --- main/manager.c | 998 +++++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 718 insertions(+), 280 deletions(-) (limited to 'main/manager.c') 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 + + + Keepalive command. + + + + + + A 'Ping' action will ellicit a 'Pong' response. Used to keep the + manager connection open. + + + + + Control Event Flow. + + + + + + + If all events should be sent. + + + If no events should be sent. + + + To select which flags events should have to be sent. + + + + + + Enable/Disable sending of events to this manager client. + + + + + Logoff Manager. + + + + + + Logoff the current manager session. + + + + + Login Manager. + + + + ActionID for this transaction. Will be returned. + + + + Login Manager. + + + + + Generate Challenge for MD5 Auth. + + + + + + Generate a challenge for MD5 authentication. + + + + + Hangup channel. + + + + + The channel name to be hangup. + + + Numeric hangup cause. + + + + Hangup a channel. + + + + + List channel status. + + + + + The name of the channel to query for status. + + + Comma , separated list of variable to include. + + + + Will return the status information of each channel along with the + value for the specified channel variables. + + + + + Set a channel variable. + + + + + Channel to set variable for. + + + Variable name. + + + Variable value. + + + + Set a global or local channel variable. + + + + + Gets a channel variable. + + + + + Channel to read variable from. + + + Variable name. + + + + Get the value of a global or local channel variable. + + + + + Retrieve configuration. + + + + + Configuration filename (e.g. foo.conf). + + + Category in configuration file. + + + + This action will dump the contents of a configuration + file by category and contents or optionally by specified category only. + + + + + Retrieve configuration (JSON format). + + + + + Configuration filename (e.g. foo.conf). + + + + 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. + + + + + Update basic configuration. + + + + + Configuration filename to read (e.g. foo.conf). + + + Configuration filename to write (e.g. foo.conf) + + + Whether or not a reload should take place (or name of specific module). + + + Action to take. + X's represent 6 digit number beginning with 000000. + + + + + + + + + + + + + Category to operate on. + + + + Variable to work on. + + + + Value to work on. + + + + Extra match required to match line. + + + + Line in category to operate on (used with delete and insert actions). + + + + + This action will modify, create, or delete configuration elements + in Asterisk configuration files. + + + + + Creates an empty file in the configuration directory. + + + + + The configuration filename to create (e.g. foo.conf). + + + + This action will create an empty file in the configuration + directory. This action is intended to be used before an UpdateConfig + action. + + + + + List categories in configuration file. + + + + + Configuration filename (e.g. foo.conf). + + + + This action will dump the categories in a given file. + + + + + Redirect (transfer) a call. + + + + + Channel to redirect. + + + Second call leg to transfer (optional). + + + Extension to transfer to. + + + Context to transfer to. + + + Priority to transfer to. + + + + Redirect (transfer) a call. + + + + + Attended transfer. + + + + + Transferer's channel. + + + Extension to transfer to. + + + Context to transfer to. + + + Priority to transfer to. + + + + Attended transfer. + + + + + Originate a call. + + + + + Channel name to call. + + + Extension to use (requires Context and + Priority) + + + Context to use (requires Exten and + Priority) + + + Priority to use (requires Exten and + Context) + + + Application to execute. + + + Data to use (requires Application). + + + How long to wait for call to be answered (in ms). + + + Caller ID to be set on the outgoing channel. + + + Channel variable to set, multiple Variable: headers are allowed. + + + Account code. + + + Set to true for fast origination. + + + + Generates an outgoing call to a + Extension/Context/Priority + or Application/Data + + + + + Execute Asterisk CLI Command. + + + + + Asterisk CLI command to run. + + + + Run a CLI command. + + + + + Check Extension Status. + + + + + Extension to check state on. + + + Context for extension. + + + + 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. + Will return an Extension Status message. The response will include + the hint for the extension and the status. + + + + + Set absolute timeout. + + + + + Channel name to hangup. + + + Maximum duration of the call (sec). + + + + Hangup a channel after a certain time. Acknowledges set time with + Timeout Set message. + + + + + Check mailbox. + + + + + Full mailbox ID mailbox@vm-context. + + + + Checks a voicemail account for status. + Returns number of messages. + Message: Mailbox Status. + Mailbox: mailboxid. + Waiting: count. + + + + + Check Mailbox Message Count. + + + + + Full mailbox ID mailbox@vm-context. + + + + Checks a voicemail account for new messages. + Returns number of urgent, new and old messages. + Message: Mailbox Message Count + Mailbox: mailboxid + UrgentMessages: count + NewMessages: count + OldMessages: count + + + + + List available manager commands. + + + + + + Returns the action name and synopsis for every action that + is available to the user. + + + + + Send text message to channel. + + + + + Channel to send message to. + + + Message to send. + + + + Sends A Text Message to a channel while in a call. + + + + + Send an arbitrary event. + + + + + Event string to send. + + + Content1. + + + ContentN. + + + + Send an event to manager sessions. + + + + + Wait for an event to occur. + + + + + Maximum time (in seconds) to wait for events, -1 means forever. + + + + This action will ellicit a Success response. Whenever + a manager event is queued. Once WaitEvent has been called on an HTTP manager + session, events will be generated and queued. + + + + + Show PBX core settings (version etc). + + + + + + Query for Core PBX settings. + + + + + Show PBX core status variables. + + + + + + Query for Core PBX status. + + + + + Send a reload event. + + + + + Name of the module to reload. + + + + Send a reload event. + + + + + List currently active channels. + + + + + + List currently defined channels and some information about them. + + + + + Module management. + + + + + Asterisk module name (including .so extension) or subsystem identifier: + + + + + + + + + + + + The operation to be done on module. + + + + + + If no module is specified for a reload loadtype, + all modules are reloaded. + + + + Loads, unloads or reloads an Asterisk module in a running system. + + + + + Check if module is loaded. + + + + Asterisk module name (not including extension). + + + + Checks if Asterisk module is loaded. Will return Success/Failure. + For success returns, the module revision number is included. + + + ***/ + 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 @\n" -" ActionID: Optional ActionID for message matching.\n" -"Returns number of messages.\n" -" Message: Mailbox Status\n" -" Mailbox: \n" -" Waiting: \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 @\n" -" ActionID: Optional ActionID for message matching.\n" -"Returns number of urgent, new and old messages.\n" -" Message: Mailbox Message Count\n" -" Mailbox: \n" -" UrgentMessages: \n" -" NewMessages: \n" -" OldMessages: \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: Action ID for this transaction. Will be returned.\n" -" Module: 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: Action ID for this transaction. Will be returned.\n" -" Module: 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); -- cgit v1.2.3