diff --git a/apps/app_meetme.c b/apps/app_meetme.c index ba278ba76..db5c39103 100644 --- a/apps/app_meetme.c +++ b/apps/app_meetme.c @@ -420,6 +420,46 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") + + + Mute a Meetme user. + + + + + + + + + + + + Unmute a Meetme user. + + + + + + + + + + + + List participants in a conference. + + + + + Conference number. + + + + Lists all users in a particular MeetMe conference. + MeetmeList will follow as separate events, followed by a final event called + MeetmeListComplete. + + ***/ #define CONFIG_FILE_NAME "meetme.conf" @@ -4236,14 +4276,6 @@ static int action_meetmeunmute(struct mansession *s, const struct message *m) return meetmemute(s, m, 0); } -static const char mandescr_meetmelist[] = -"Description: Lists all users in a particular MeetMe conference.\n" -"MeetmeList will follow as separate events, followed by a final event called\n" -"MeetmeListComplete.\n" -"Variables:\n" -" *ActionId: \n" -" *Conference: \n"; - static int action_meetmelist(struct mansession *s, const struct message *m) { const char *actionid = astman_get_header(m, "ActionID"); @@ -6418,12 +6450,9 @@ static int load_module(void) res |= load_config(0); ast_cli_register_multiple(cli_meetme, ARRAY_LEN(cli_meetme)); - res |= ast_manager_register("MeetmeMute", EVENT_FLAG_CALL, - action_meetmemute, "Mute a Meetme user"); - res |= ast_manager_register("MeetmeUnmute", EVENT_FLAG_CALL, - action_meetmeunmute, "Unmute a Meetme user"); - res |= ast_manager_register2("MeetmeList", EVENT_FLAG_REPORTING, - action_meetmelist, "List participants in a conference", mandescr_meetmelist); + res |= ast_manager_register_xml("MeetmeMute", EVENT_FLAG_CALL, action_meetmemute); + res |= ast_manager_register_xml("MeetmeUnmute", EVENT_FLAG_CALL, action_meetmeunmute); + res |= ast_manager_register_xml("MeetmeList", EVENT_FLAG_REPORTING, action_meetmelist); res |= ast_register_application_xml(app4, channel_admin_exec); res |= ast_register_application_xml(app3, admin_exec); res |= ast_register_application_xml(app2, count_exec); diff --git a/apps/app_queue.c b/apps/app_queue.c index d792cdfd5..9e0519f8d 100644 --- a/apps/app_queue.c +++ b/apps/app_queue.c @@ -494,7 +494,160 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") Gets or sets queue members penalty. - + + + Queues. + + + + + + + + + + Show queue status. + + + + + + + + + + + + Show queue summary. + + + + + + + + + + + Add interface to queue. + + + + + + + + + + + + + + + + Remove interface from queue. + + + + + + + + + + + + Makes a queue member temporarily unavailable. + + + + + + + + + + + + + + Adds custom entry in queue_log. + + + + + + + + + + + + + + + Set the penalty for a queue member. + + + + + + + + + + + + + Queue Rules. + + + + + + + + + + + Reload a queue, queues, or any sub-section of a queue or queues. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Reset queue statistics. + + + + + + + + ***/ enum { @@ -7299,17 +7452,17 @@ static int load_module(void) res |= ast_register_application_xml(app_pqm, pqm_exec); res |= ast_register_application_xml(app_upqm, upqm_exec); res |= ast_register_application_xml(app_ql, ql_exec); - res |= ast_manager_register("Queues", 0, manager_queues_show, "Queues"); - res |= ast_manager_register("QueueStatus", 0, manager_queues_status, "Queue Status"); - res |= ast_manager_register("QueueSummary", 0, manager_queues_summary, "Queue Summary"); - res |= ast_manager_register("QueueAdd", EVENT_FLAG_AGENT, manager_add_queue_member, "Add interface to queue."); - res |= ast_manager_register("QueueRemove", EVENT_FLAG_AGENT, manager_remove_queue_member, "Remove interface from queue."); - res |= ast_manager_register("QueuePause", EVENT_FLAG_AGENT, manager_pause_queue_member, "Makes a queue member temporarily unavailable"); - res |= ast_manager_register("QueueLog", EVENT_FLAG_AGENT, manager_queue_log_custom, "Adds custom entry in queue_log"); - res |= ast_manager_register("QueuePenalty", EVENT_FLAG_AGENT, manager_queue_member_penalty, "Set the penalty for a queue member"); - res |= ast_manager_register("QueueRule", 0, manager_queue_rule_show, "Queue Rules"); - res |= ast_manager_register("QueueReload", 0, manager_queue_reload, "Reload a queue, queues, or any sub-section of a queue or queues"); - res |= ast_manager_register("QueueReset", 0, manager_queue_reset, "Reset queue statistics"); + res |= ast_manager_register_xml("Queues", 0, manager_queues_show); + res |= ast_manager_register_xml("QueueStatus", 0, manager_queues_status); + res |= ast_manager_register_xml("QueueSummary", 0, manager_queues_summary); + res |= ast_manager_register_xml("QueueAdd", EVENT_FLAG_AGENT, manager_add_queue_member); + res |= ast_manager_register_xml("QueueRemove", EVENT_FLAG_AGENT, manager_remove_queue_member); + res |= ast_manager_register_xml("QueuePause", EVENT_FLAG_AGENT, manager_pause_queue_member); + res |= ast_manager_register_xml("QueueLog", EVENT_FLAG_AGENT, manager_queue_log_custom); + res |= ast_manager_register_xml("QueuePenalty", EVENT_FLAG_AGENT, manager_queue_member_penalty); + res |= ast_manager_register_xml("QueueRule", 0, manager_queue_rule_show); + res |= ast_manager_register_xml("QueueReload", 0, manager_queue_reload); + res |= ast_manager_register_xml("QueueReset", 0, manager_queue_reset); res |= ast_custom_function_register(&queuevar_function); res |= ast_custom_function_register(&queuemembercount_function); res |= ast_custom_function_register(&queuemembercount_dep); diff --git a/apps/app_senddtmf.c b/apps/app_senddtmf.c index 68f2d784f..395ae28c9 100644 --- a/apps/app_senddtmf.c +++ b/apps/app_senddtmf.c @@ -59,6 +59,23 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") Read + + + Play DTMF signal on a specific channel. + + + + + Channel name to send digit to. + + + The DTMF digit to play. + + + + Plays a dtmf digit on the specified channel. + + ***/ static char *app = "SendDTMF"; @@ -90,12 +107,6 @@ static int senddtmf_exec(struct ast_channel *chan, const char *vdata) return res; } -static const char mandescr_playdtmf[] = -"Description: Plays a dtmf digit on the specified channel.\n" -"Variables: (all are required)\n" -" Channel: Channel name to send digit to\n" -" Digit: The dtmf digit to play\n"; - static int manager_play_dtmf(struct mansession *s, const struct message *m) { const char *channel = astman_get_header(m, "Channel"); @@ -136,7 +147,7 @@ static int load_module(void) { int res; - res = ast_manager_register2( "PlayDTMF", EVENT_FLAG_CALL, manager_play_dtmf, "Play DTMF signal on a specific channel.", mandescr_playdtmf ); + res = ast_manager_register_xml("PlayDTMF", EVENT_FLAG_CALL, manager_play_dtmf); res |= ast_register_application_xml(app, senddtmf_exec); return res; diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c index 4362dbcd8..824c42532 100644 --- a/apps/app_voicemail.c +++ b/apps/app_voicemail.c @@ -298,6 +298,16 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") context. + + + List All Voicemail User Information. + + + + + + + ***/ #ifdef IMAP_STORAGE @@ -11150,7 +11160,7 @@ static int load_module(void) res |= ast_register_application_xml(app3, vm_box_exists); res |= ast_register_application_xml(app4, vmauthenticate); res |= ast_custom_function_register(&mailbox_exists_acf); - res |= ast_manager_register("VoicemailUsersList", EVENT_FLAG_CALL | EVENT_FLAG_REPORTING, manager_list_voicemail_users, "List All Voicemail User Information"); + res |= ast_manager_register_xml("VoicemailUsersList", EVENT_FLAG_CALL | EVENT_FLAG_REPORTING, manager_list_voicemail_users); if (res) return res; diff --git a/channels/chan_agent.c b/channels/chan_agent.c index d922d4927..17b20cd8b 100644 --- a/channels/chan_agent.c +++ b/channels/chan_agent.c @@ -167,6 +167,34 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") + + + Lists agents and their status. + + + + + + Will list info about all possible agents. + + + + + Sets an agent as no longer logged in. + + + + + Agent ID of the agent to log off. + + + Set to true to not hangup existing calls. + + + + Sets an agent as no longer logged in. + + ***/ static const char tdesc[] = "Call Agent Proxy Channel"; @@ -175,16 +203,6 @@ static const char config[] = "agents.conf"; static const char app[] = "AgentLogin"; static const char app3[] = "AgentMonitorOutgoing"; -static const char mandescr_agents[] = -"Description: Will list info about all possible agents.\n" -"Variables: NONE\n"; - -static const char mandescr_agent_logoff[] = -"Description: Sets an agent as no longer logged in.\n" -"Variables: (Names marked with * are required)\n" -" *Agent: Agent ID of the agent to log off\n" -" Soft: Set to 'true' to not hangup existing calls\n"; - static char moh[80] = "default"; #define AST_MAX_AGENT 80 /*!< Agent ID or Password max length */ @@ -2559,8 +2577,8 @@ static int load_module(void) ast_register_application_xml(app3, agentmonitoroutgoing_exec); /* Manager commands */ - ast_manager_register2("Agents", EVENT_FLAG_AGENT, action_agents, "Lists agents and their status", mandescr_agents); - ast_manager_register2("AgentLogoff", EVENT_FLAG_AGENT, action_agent_logoff, "Sets an agent as no longer logged in", mandescr_agent_logoff); + ast_manager_register_xml("Agents", EVENT_FLAG_AGENT, action_agents); + ast_manager_register_xml("AgentLogoff", EVENT_FLAG_AGENT, action_agent_logoff); /* CLI Commands */ ast_cli_register_multiple(cli_agents, ARRAY_LEN(cli_agents)); diff --git a/channels/chan_dahdi.c b/channels/chan_dahdi.c index 5971539b0..f4b6d3aca 100644 --- a/channels/chan_dahdi.c +++ b/channels/chan_dahdi.c @@ -154,6 +154,89 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") This application will Accept the R2 call either with charge or no charge. + + + Transfer DAHDI Channel. + + + + + DAHDI channel name to transfer. + + + + Transfer a DAHDI channel. + + + + + Hangup DAHDI Channel. + + + + + DAHDI channel name to hangup. + + + + Hangup a DAHDI channel. + + + + + Dial over DAHDI channel while offhook. + + + + + + + + + + + + Toggle DAHDI channel Do Not Disturb status ON. + + + + + + + + + + + Toggle DAHDI channel Do Not Disturb status OFF. + + + + + + + + + + + Show status DAHDI channels. + + + + + + + + + + + Fully Restart DAHDI channels (terminates calls). + + + + + + + ***/ #define SMDI_MD_WAIT_TIMEOUT 1500 /* 1.5 seconds */ @@ -16193,11 +16276,11 @@ static int __unload_module(void) #endif ast_cli_unregister_multiple(dahdi_cli, ARRAY_LEN(dahdi_cli)); - ast_manager_unregister( "DAHDIDialOffhook" ); - ast_manager_unregister( "DAHDIHangup" ); - ast_manager_unregister( "DAHDITransfer" ); - ast_manager_unregister( "DAHDIDNDoff" ); - ast_manager_unregister( "DAHDIDNDon" ); + ast_manager_unregister("DAHDIDialOffhook"); + ast_manager_unregister("DAHDIHangup"); + ast_manager_unregister("DAHDITransfer"); + ast_manager_unregister("DAHDIDNDoff"); + ast_manager_unregister("DAHDIDNDon"); ast_manager_unregister("DAHDIShowChannels"); ast_manager_unregister("DAHDIRestart"); ast_channel_unregister(&dahdi_tech); @@ -17640,13 +17723,13 @@ static int load_module(void) ast_cli_register_multiple(dahdi_cli, ARRAY_LEN(dahdi_cli)); memset(round_robin, 0, sizeof(round_robin)); - ast_manager_register( "DAHDITransfer", 0, action_transfer, "Transfer DAHDI Channel" ); - ast_manager_register( "DAHDIHangup", 0, action_transferhangup, "Hangup DAHDI Channel" ); - ast_manager_register( "DAHDIDialOffhook", 0, action_dahdidialoffhook, "Dial over DAHDI channel while offhook" ); - ast_manager_register( "DAHDIDNDon", 0, action_dahdidndon, "Toggle DAHDI channel Do Not Disturb status ON" ); - ast_manager_register( "DAHDIDNDoff", 0, action_dahdidndoff, "Toggle DAHDI channel Do Not Disturb status OFF" ); - ast_manager_register("DAHDIShowChannels", 0, action_dahdishowchannels, "Show status DAHDI channels"); - ast_manager_register("DAHDIRestart", 0, action_dahdirestart, "Fully Restart DAHDI channels (terminates calls)"); + ast_manager_register_xml("DAHDITransfer", 0, action_transfer); + ast_manager_register_xml("DAHDIHangup", 0, action_transferhangup); + ast_manager_register_xml("DAHDIDialOffhook", 0, action_dahdidialoffhook); + ast_manager_register_xml("DAHDIDNDon", 0, action_dahdidndon); + ast_manager_register_xml("DAHDIDNDoff", 0, action_dahdidndoff); + ast_manager_register_xml("DAHDIShowChannels", 0, action_dahdishowchannels); + ast_manager_register_xml("DAHDIRestart", 0, action_dahdirestart); ast_cond_init(&ss_thread_complete, NULL); diff --git a/channels/chan_iax2.c b/channels/chan_iax2.c index 383f97ed9..e6e1280cc 100644 --- a/channels/chan_iax2.c +++ b/channels/chan_iax2.c @@ -175,6 +175,47 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") + + + List IAX peers. + + + + + + + + + + List IAX Peers. + + + + + + List all the IAX peers. + + + + + Show IAX Netstats. + + + + Show IAX channels network statistics. + + + + + Show IAX registrations. + + + + + + Show IAX registrations. + + ***/ /* Define SCHED_MULTITHREADED to run the scheduler in a special @@ -12720,10 +12761,10 @@ static int load_module(void) ast_register_application_xml(papp, iax2_prov_app); - ast_manager_register( "IAXpeers", EVENT_FLAG_SYSTEM | EVENT_FLAG_REPORTING, manager_iax2_show_peers, "List IAX Peers" ); - ast_manager_register( "IAXpeerlist", EVENT_FLAG_SYSTEM | EVENT_FLAG_REPORTING, manager_iax2_show_peer_list, "List IAX Peers" ); - ast_manager_register( "IAXnetstats", EVENT_FLAG_SYSTEM | EVENT_FLAG_REPORTING, manager_iax2_show_netstats, "Show IAX Netstats" ); - ast_manager_register( "IAXregistry", EVENT_FLAG_SYSTEM | EVENT_FLAG_REPORTING, manager_iax2_show_registry, "Show IAX registrations"); + ast_manager_register_xml("IAXpeers", EVENT_FLAG_SYSTEM | EVENT_FLAG_REPORTING, manager_iax2_show_peers); + ast_manager_register_xml("IAXpeerlist", EVENT_FLAG_SYSTEM | EVENT_FLAG_REPORTING, manager_iax2_show_peer_list); + ast_manager_register_xml("IAXnetstats", EVENT_FLAG_SYSTEM | EVENT_FLAG_REPORTING, manager_iax2_show_netstats); + ast_manager_register_xml("IAXregistry", EVENT_FLAG_SYSTEM | EVENT_FLAG_REPORTING, manager_iax2_show_registry); if ((timer = ast_timer_open())) { ast_timer_set_rate(timer, trunkfreq); diff --git a/channels/chan_sip.c b/channels/chan_sip.c index 02762691e..35fedb9ad 100644 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -473,6 +473,79 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") Check the domain= configuration in sip.conf. + + + List SIP peers (text format). + + + + + + Lists SIP peers in text format with details on current status. + Peerlist will follow as separate events, followed by a final event called + PeerlistComplete. + + + + + show SIP peer (text format). + + + + + The peer name you want to check. + + + + Show one SIP peer with details on current status. + + + + + Qualify SIP peers. + + + + + The peer name you want to qualify. + + + + Qualify a SIP peer. + + + + + Show SIP registrations (text format). + + + + + + Lists all registration requests and status. Registrations will follow as separate + events. followed by a final event called RegistrationsComplete. + + + + + Send a SIP notify. + + + + + Peer to receive the notify. + + + At least one variable pair must be specified. + name=value + + + + Sends a SIP Notify event. + All parameters for this event must be specified in the body of this request + via multiple Variable: name=value sequences. + + ***/ #ifndef FALSE @@ -10859,15 +10932,6 @@ static int manager_sipnotify(struct mansession *s, const struct message *m) return 0; } -static const char mandescr_sipnotify[] = -"Description: Sends a SIP Notify event\n" -"All parameters for this event must be specified in the body of this request\n" -"via multiple Variable: name=value sequences.\n" -"Variables: \n" -" *Channel: Peer to receive the notify. Required.\n" -" *Variable: = At least one variable pair must be specified.\n" -" ActionID: Action ID for this transaction. Will be returned.\n"; - /*! \brief Send a provisional response indicating that a call was redirected */ static void update_redirecting(struct sip_pvt *p, const void *data, size_t datalen) @@ -14166,14 +14230,6 @@ static char *sip_show_users(struct ast_cli_entry *e, int cmd, struct ast_cli_arg #undef FORMAT } -/*! \brief Manager Action SIPShowRegistry description */ -static const char mandescr_show_registry[] = -"Description: Lists all registration requests and status\n" -"Registrations will follow as separate events. followed by a final event called\n" -"RegistrationsComplete.\n" -"Variables: \n" -" ActionID: Action ID for this transaction. Will be returned.\n"; - /*! \brief Show SIP registrations in the manager API */ static int manager_show_registry(struct mansession *s, const struct message *m) { @@ -14212,13 +14268,6 @@ static int manager_show_registry(struct mansession *s, const struct message *m) return 0; } -static const char mandescr_show_peers[] = -"Description: Lists SIP peers in text format with details on current status.\n" -"Peerlist will follow as separate events, followed by a final event called\n" -"PeerlistComplete.\n" -"Variables: \n" -" ActionID: Action ID for this transaction. Will be returned.\n"; - /*! \brief Show SIP peers in the manager API */ /* Inspired from chan_iax2 */ static int manager_sip_show_peers(struct mansession *s, const struct message *m) @@ -14837,12 +14886,6 @@ static char *sip_show_domains(struct ast_cli_entry *e, int cmd, struct ast_cli_a } #undef FORMAT -static const char mandescr_show_peer[] = -"Description: Show one SIP peer with details on current status.\n" -"Variables: \n" -" Peer: The peer name you want to check.\n" -" ActionID: Optional action ID for this AMI transaction.\n"; - /*! \brief Show SIP peers in the manager API */ static int manager_sip_show_peer(struct mansession *s, const struct message *m) { @@ -25478,16 +25521,11 @@ static int load_module(void) ast_custom_function_register(&checksipdomain_function); /* Register manager commands */ - ast_manager_register2("SIPpeers", EVENT_FLAG_SYSTEM | EVENT_FLAG_REPORTING, manager_sip_show_peers, - "List SIP peers (text format)", mandescr_show_peers); - ast_manager_register2("SIPshowpeer", EVENT_FLAG_SYSTEM | EVENT_FLAG_REPORTING, manager_sip_show_peer, - "Show SIP peer (text format)", mandescr_show_peer); - ast_manager_register2("SIPqualifypeer", EVENT_FLAG_SYSTEM | EVENT_FLAG_REPORTING, manager_sip_qualify_peer, - "Show SIP peer (text format)", mandescr_show_peer); /*! \todo Fix this XXX This must be all wrong XXXX */ - ast_manager_register2("SIPshowregistry", EVENT_FLAG_SYSTEM | EVENT_FLAG_REPORTING, manager_show_registry, - "Show SIP registrations (text format)", mandescr_show_registry); - ast_manager_register2("SIPnotify", EVENT_FLAG_SYSTEM, manager_sipnotify, - "Send a SIP notify", mandescr_sipnotify); + ast_manager_register_xml("SIPpeers", EVENT_FLAG_SYSTEM | EVENT_FLAG_REPORTING, manager_sip_show_peers); + ast_manager_register_xml("SIPshowpeer", EVENT_FLAG_SYSTEM | EVENT_FLAG_REPORTING, manager_sip_show_peer); + ast_manager_register_xml("SIPqualifypeer", EVENT_FLAG_SYSTEM | EVENT_FLAG_REPORTING, manager_sip_qualify_peer); + ast_manager_register_xml("SIPshowregistry", EVENT_FLAG_SYSTEM | EVENT_FLAG_REPORTING, manager_show_registry); + ast_manager_register_xml("SIPnotify", EVENT_FLAG_SYSTEM, manager_sipnotify); sip_poke_all_peers(); sip_send_all_registers(); sip_send_all_mwi_subscriptions(); diff --git a/channels/chan_skinny.c b/channels/chan_skinny.c index dbb90a5d5..0aea73b07 100644 --- a/channels/chan_skinny.c +++ b/channels/chan_skinny.c @@ -71,6 +71,63 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") #include "asterisk/indications.h" #include "asterisk/linkedlists.h" +/*** DOCUMENTATION + + + List SKINNY devices (text format). + + + + + + Lists Skinny devices in text format with details on current status. + Devicelist will follow as separate events, followed by a final event called + DevicelistComplete. + + + + + Show SKINNY device (text format). + + + + + The device name you want to check. + + + + Show one SKINNY device with details on current status. + + + + + List SKINNY lines (text format). + + + + + + Lists Skinny lines in text format with details on current status. + Linelist will follow as separate events, followed by a final event called + LinelistComplete. + + + + + Show SKINNY line (text format). + + + + + The line name you want to check. + + + + Show one SKINNY line with details on current status. + + + ***/ + #ifdef SKINNY_DEVMODE #define SKINNY_DEVONLY(code) \ code @@ -3049,13 +3106,6 @@ static char *_skinny_show_devices(int fd, int *total, struct mansession *s, cons return CLI_SUCCESS; } -static const char mandescr_show_devices[] = -"Description: Lists Skinny devices in text format with details on current status.\n" -"Devicelist will follow as separate events, followed by a final event called\n" -"DevicelistComplete.\n" -"Variables: \n" -" ActionID: Action ID for this transaction. Will be returned.\n"; - /*! \brief Show SKINNY devices in the manager API */ /* Inspired from chan_sip */ static int manager_skinny_show_devices(struct mansession *s, const struct message *m) @@ -3194,12 +3244,6 @@ static char *_skinny_show_device(int type, int fd, struct mansession *s, const s return CLI_SUCCESS; } -static const char mandescr_show_device[] = -"Description: Show one SKINNY device with details on current status.\n" -"Variables: \n" -" Device: The device name you want to check.\n" -" ActionID: Optional action ID for this AMI transaction.\n"; - static int manager_skinny_show_device(struct mansession *s, const struct message *m) { const char *a[4]; @@ -3310,13 +3354,6 @@ static char *_skinny_show_lines(int fd, int *total, struct mansession *s, const return CLI_SUCCESS; } -static const char mandescr_show_lines[] = -"Description: Lists Skinny lines in text format with details on current status.\n" -"Linelist will follow as separate events, followed by a final event called\n" -"LinelistComplete.\n" -"Variables: \n" -" ActionID: Action ID for this transaction. Will be returned.\n"; - /*! \brief Show Skinny lines in the manager API */ /* Inspired from chan_sip */ static int manager_skinny_show_lines(struct mansession *s, const struct message *m) @@ -3502,12 +3539,6 @@ static char *_skinny_show_line(int type, int fd, struct mansession *s, const str return CLI_SUCCESS; } -static const char mandescr_show_line[] = -"Description: Show one SKINNY line with details on current status.\n" -"Variables: \n" -" Line: The line name you want to check.\n" -" ActionID: Optional action ID for this AMI transaction.\n"; - static int manager_skinny_show_line(struct mansession *s, const struct message *m) { const char *a[4]; @@ -7347,14 +7378,10 @@ static int load_module(void) ast_rtp_glue_register(&skinny_rtp_glue); ast_cli_register_multiple(cli_skinny, ARRAY_LEN(cli_skinny)); - ast_manager_register2("SKINNYdevices", EVENT_FLAG_SYSTEM | EVENT_FLAG_REPORTING, manager_skinny_show_devices, - "List SKINNY devices (text format)", mandescr_show_devices); - ast_manager_register2("SKINNYshowdevice", EVENT_FLAG_SYSTEM | EVENT_FLAG_REPORTING, manager_skinny_show_device, - "Show SKINNY device (text format)", mandescr_show_device); - ast_manager_register2("SKINNYlines", EVENT_FLAG_SYSTEM | EVENT_FLAG_REPORTING, manager_skinny_show_lines, - "List SKINNY lines (text format)", mandescr_show_lines); - ast_manager_register2("SKINNYshowline", EVENT_FLAG_SYSTEM | EVENT_FLAG_REPORTING, manager_skinny_show_line, - "Show SKINNY line (text format)", mandescr_show_line); + ast_manager_register_xml("SKINNYdevices", EVENT_FLAG_SYSTEM | EVENT_FLAG_REPORTING, manager_skinny_show_devices); + ast_manager_register_xml("SKINNYshowdevice", EVENT_FLAG_SYSTEM | EVENT_FLAG_REPORTING, manager_skinny_show_device); + ast_manager_register_xml("SKINNYlines", EVENT_FLAG_SYSTEM | EVENT_FLAG_REPORTING, manager_skinny_show_lines); + ast_manager_register_xml("SKINNYshowline", EVENT_FLAG_SYSTEM | EVENT_FLAG_REPORTING, manager_skinny_show_line); sched = sched_context_create(); if (!sched) { diff --git a/doc/appdocsxml.dtd b/doc/appdocsxml.dtd index c06f720e1..1de0ea452 100644 --- a/doc/appdocsxml.dtd +++ b/doc/appdocsxml.dtd @@ -1,4 +1,4 @@ - + @@ -23,6 +23,10 @@ + + + + diff --git a/include/asterisk/manager.h b/include/asterisk/manager.h index d9e33e538..33eb52c04 100644 --- a/include/asterisk/manager.h +++ b/include/asterisk/manager.h @@ -22,6 +22,7 @@ #include "asterisk/network.h" #include "asterisk/lock.h" #include "asterisk/datastore.h" +#include "asterisk/xmldoc.h" /*! \file @@ -116,14 +117,19 @@ struct message { struct manager_action { /*! Name of the action */ const char *action; - /*! Short description of the action */ - const char *synopsis; - /*! Detailed description of the action */ - const char *description; + AST_DECLARE_STRING_FIELDS( + AST_STRING_FIELD(synopsis); /*!< Synopsis text (short description). */ + AST_STRING_FIELD(description); /*!< Description (help text) */ + AST_STRING_FIELD(syntax); /*!< Syntax text */ + AST_STRING_FIELD(arguments); /*!< Description of each argument. */ + AST_STRING_FIELD(seealso); /*!< See also */ + ); /*! Permission required for action. EVENT_FLAG_* */ int authority; /*! Function to be called */ int (*func)(struct mansession *s, const struct message *m); + /*! Where the documentation come from. */ + enum ast_doc_src docsrc; /*! For easy linking */ AST_RWLIST_ENTRY(manager_action) list; }; @@ -132,6 +138,8 @@ struct manager_action { * \note Use ast_manager_register2() to register with help text for new manager commands */ #define ast_manager_register(a, b, c, d) ast_manager_register2(a, b, c, d, NULL) +/*! \brief Register a manager callback using XML documentation to describe the manager. */ +#define ast_manager_register_xml(a, b, c) ast_manager_register2(a, b, c, NULL, NULL) /*! \brief Register a manager command with the manager interface \param action Name of the requested Action: diff --git a/include/asterisk/pbx.h b/include/asterisk/pbx.h index c2f999eb6..d086416d8 100644 --- a/include/asterisk/pbx.h +++ b/include/asterisk/pbx.h @@ -27,6 +27,7 @@ #include "asterisk/chanvars.h" #include "asterisk/hashtab.h" #include "asterisk/stringfields.h" +#include "asterisk/xmldoc.h" #if defined(__cplusplus) || defined(c_plusplus) extern "C" { @@ -73,12 +74,6 @@ struct ast_sw; /*! \brief Typedef for devicestate and hint callbacks */ typedef int (*ast_state_cb_type)(char *context, char* id, enum ast_extension_states state, void *data); -/*! \brief From where the documentation come from */ -enum ast_doc_src { - AST_XML_DOC, /*!< From XML documentation */ - AST_STATIC_DOC /*!< From application/function registration */ -}; - /*! \brief Data structure associated with a custom dialplan function */ struct ast_custom_function { const char *name; /*!< Name */ diff --git a/include/asterisk/xmldoc.h b/include/asterisk/xmldoc.h index d781e8043..c876b46da 100644 --- a/include/asterisk/xmldoc.h +++ b/include/asterisk/xmldoc.h @@ -23,6 +23,13 @@ #include "asterisk/xml.h" +/*! \brief From where the documentation come from, this structure is useful for + * use it inside application/functions/manager actions structure. */ +enum ast_doc_src { + AST_XML_DOC, /*!< From XML documentation */ + AST_STATIC_DOC /*!< From application/function registration */ +}; + #ifdef AST_XML_DOCS /*! diff --git a/main/db.c b/main/db.c index 6528aa246..244288a19 100644 --- a/main/db.c +++ b/main/db.c @@ -48,6 +48,58 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") #include "asterisk/manager.h" #include "db1-ast/include/db.h" +/*** DOCUMENTATION + + + Get DB Entry. + + + + + + + + + + + + Put DB entry. + + + + + + + + + + + + + Delete DB entry. + + + + + + + + + + + + Delete DB Tree. + + + + + + + + + + ***/ + 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$") ParkedCall + + + List parked calls. + + + + + + List parked calls. + + + + + Park a channel. + + + + + Channel name to park. + + + Channel to announce park info to (and return to if timeout). + + + Number of milliseconds to wait before callback. + + + + Park a channel. + + + + + Bridge two channels already in the PBX. + + + + + Channel to Bridge to Channel2. + + + Channel to Bridge to Channel1. + + + Play courtesy tone to Channel 2. + + + + + + + + Bridge together two channels already in the PBX. + + ***/ #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 + + + 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); 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$") RaiseException + + + La merde se produit. + + + + + Show a specific extension. + + + Show a specific context. + + + + Show dialplan contexts and extensions. Be aware that showing the full dialplan + may take a lot of capacity. + + ***/ #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: Action ID for this AMI transaction (optional)\n" -" Extension: Extension (Optional)\n" -" 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 ", + (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; diff --git a/res/res_agi.c b/res/res_agi.c index 9d312b823..fea57800d 100644 --- a/res/res_agi.c +++ b/res/res_agi.c @@ -2609,8 +2609,8 @@ int ast_agi_register(struct ast_module *mod, agi_command *cmd) ast_join(fullcmd, sizeof(fullcmd), cmd->cmda); if (!find_command(cmd->cmda, 1)) { - *((enum ast_doc_src *) &cmd->docsrc) = AST_STATIC_DOC; #ifdef AST_XML_DOCS + *((enum ast_doc_src *) &cmd->docsrc) = AST_STATIC_DOC; if (ast_strlen_zero(cmd->summary) && ast_strlen_zero(cmd->usage)) { *((char **) &cmd->summary) = ast_xmldoc_build_synopsis("agi", fullcmd); *((char **) &cmd->usage) = ast_xmldoc_build_description("agi", fullcmd);