[asterisk-commits] mjordan: branch mjordan/manager-events r368557 - in /team/mjordan/manager-eve...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Tue Jun 5 15:55:37 CDT 2012
Author: mjordan
Date: Tue Jun 5 15:55:32 2012
New Revision: 368557
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=368557
Log:
Update with more documentation examples; working CLI commands
Hey, it works!
* manager show event / manager show events
* Some more documentation examples
* Fixed makefile to not double install the documentation (whoops)
* Fixed script to not add whitespace (but really, why do we honor whitespace
in nodes without CDATA tags???)
Modified:
team/mjordan/manager-events/Makefile
team/mjordan/manager-events/apps/app_chanspy.c
team/mjordan/manager-events/apps/app_confbridge.c
team/mjordan/manager-events/apps/app_dial.c
team/mjordan/manager-events/apps/app_voicemail.c
team/mjordan/manager-events/build_tools/get_documentation.py
team/mjordan/manager-events/include/asterisk/xmldoc.h
team/mjordan/manager-events/main/manager.c
team/mjordan/manager-events/main/xmldoc.c
Modified: team/mjordan/manager-events/Makefile
URL: http://svnview.digium.com/svn/asterisk/team/mjordan/manager-events/Makefile?view=diff&rev=368557&r1=368556&r2=368557
==============================================================================
--- team/mjordan/manager-events/Makefile (original)
+++ team/mjordan/manager-events/Makefile Tue Jun 5 15:55:32 2012
@@ -336,7 +336,7 @@
_all: makeopts $(SUBDIRS) doc/core-en_US.xml $(ADDL_TARGETS)
-_all_full: makeopts $(SUBDIRS) doc/core-full-en_US.xml $(ADDL_TARGETS)
+_all_full: makeopts $(SUBDIRS) doc/full-en_US.xml $(ADDL_TARGETS)
makeopts: configure
@echo "****"
@@ -430,7 +430,7 @@
rm -f include/asterisk/build.h
rm -f main/version.c
rm -f doc/core-en_US.xml
- rm -f doc/core-full-en_US.xml
+ rm -f doc/full-en_US.xml
@$(MAKE) -C menuselect clean
cp -f .cleancount .lastclean
@@ -484,7 +484,7 @@
@echo
@echo "</docs>" >> $@
-doc/core-full-en_US.xml: $(foreach dir,$(MOD_SUBDIRS),$(shell $(GREP) -l "language=\"en_US\"" $(dir)/*.c $(dir)/*.cc 2>/dev/null))
+doc/full-en_US.xml: $(foreach dir,$(MOD_SUBDIRS),$(shell $(GREP) -l "language=\"en_US\"" $(dir)/*.c $(dir)/*.cc 2>/dev/null))
ifeq ($(PYTHON),:)
@echo "--------------------------------------------------------------------------"
@echo "--- Please install python to build full documentation ---"
Modified: team/mjordan/manager-events/apps/app_chanspy.c
URL: http://svnview.digium.com/svn/asterisk/team/mjordan/manager-events/apps/app_chanspy.c?view=diff&rev=368557&r1=368556&r2=368557
==============================================================================
--- team/mjordan/manager-events/apps/app_chanspy.c (original)
+++ team/mjordan/manager-events/apps/app_chanspy.c Tue Jun 5 15:55:32 2012
@@ -539,6 +539,15 @@
ast_channel_unlock(spyee_autochan->chan);
ast_verb(2, "Spying on channel %s\n", name);
+ /*** DOCUMENTATION
+ <managerEventInstance>
+ <synopsis>Raised when a channel has started spying on another channel.</synopsis>
+ <see-also>
+ <ref type="application">ChanSpy</ref>
+ <ref type="application">ExtenSpy</ref>
+ </see-also>
+ </managerEventInstance>
+ ***/
ast_manager_event_multichan(EVENT_FLAG_CALL, "ChanSpyStart", 2, chans,
"SpyerChannel: %s\r\n"
"SpyeeChannel: %s\r\n",
@@ -727,6 +736,11 @@
}
ast_verb(2, "Done Spying on channel %s\n", name);
+ /*** DOCUMENTATION
+ <managerEventInstance>
+ <synopsis>Raised when a channel has stopped spying on another channel.</synopsis>
+ </managerEventInstance>
+ ***/
ast_manager_event(chan, EVENT_FLAG_CALL, "ChanSpyStop", "SpyeeChannel: %s\r\n", name);
return running;
Modified: team/mjordan/manager-events/apps/app_confbridge.c
URL: http://svnview.digium.com/svn/asterisk/team/mjordan/manager-events/apps/app_confbridge.c?view=diff&rev=368557&r1=368556&r2=368557
==============================================================================
--- team/mjordan/manager-events/apps/app_confbridge.c (original)
+++ team/mjordan/manager-events/apps/app_confbridge.c Tue Jun 5 15:55:32 2012
@@ -539,6 +539,16 @@
static void send_join_event(struct ast_channel *chan, const char *conf_name)
{
+ /*** DOCUMENTATION
+ <managerEventInstance>
+ <synopsis>Raised when a channel joins a Confbridge conference.</synopsis>
+ <syntax>
+ <parameter name="Conference">
+ <para>The name of the Confbridge conference.</para>
+ </parameter>
+ </syntax>
+ </managerEventInstance>
+ ***/
ast_manager_event(chan, EVENT_FLAG_CALL, "ConfbridgeJoin",
"Channel: %s\r\n"
"Uniqueid: %s\r\n"
@@ -555,6 +565,16 @@
static void send_leave_event(struct ast_channel *chan, const char *conf_name)
{
+ /*** DOCUMENTATION
+ <managerEventInstance>
+ <synopsis>Raised when a channel leaves a Confbridge conference.</synopsis>
+ <syntax>
+ <parameter name="Conference">
+ <para>The name of the Confbridge conference.</para>
+ </parameter>
+ </syntax>
+ </managerEventInstance>
+ ***/
ast_manager_event(chan, EVENT_FLAG_CALL, "ConfbridgeLeave",
"Channel: %s\r\n"
"Uniqueid: %s\r\n"
@@ -1242,6 +1262,22 @@
}
/* notify AMI someone is has either started or stopped talking */
+ /*** DOCUMENTATION
+ <managerEventInstance>
+ <synopsis>Raised when a conference participant has started or stopped talking.</synopsis>
+ <syntax>
+ <parameter name="Conference">
+ <para>The name of the Confbridge conference.</para>
+ </parameter>
+ <parameter name="TalkingStatus">
+ <enumlist>
+ <enum name="on"/>
+ <enum name="off"/>
+ </enumlist>
+ </parameter>
+ </syntax>
+ </managerEventInstance>
+ ***/
ast_manager_event(bridge_channel->chan, EVENT_FLAG_CALL, "ConfbridgeTalking",
"Channel: %s\r\n"
"Uniqueid: %s\r\n"
Modified: team/mjordan/manager-events/apps/app_dial.c
URL: http://svnview.digium.com/svn/asterisk/team/mjordan/manager-events/apps/app_dial.c?view=diff&rev=368557&r1=368556&r2=368557
==============================================================================
--- team/mjordan/manager-events/apps/app_dial.c (original)
+++ team/mjordan/manager-events/apps/app_dial.c Tue Jun 5 15:55:32 2012
@@ -828,7 +828,11 @@
<synopsis>Raised when a dial action has started.</synopsis>
<syntax>
<parameter name="SubEvent">
- <para>The sub event</para>
+ <enumlist>
+ <enum name="Begin"/>
+ <enum name="End"/>
+ </enumlist>
+ <para>A sub event type, specifying whether or not the dial action has begun or ended.</para>
</parameter>
</syntax>
</managerEventInstance>
@@ -858,6 +862,11 @@
/*** DOCUMENTATION
<managerEventInstance>
<synopsis>Raised when a dial action has ended.</synopsis>
+ <syntax>
+ <parameter name="DialStatus">
+ <para>The value of the <variable>DIALSTATUS</variable> channel variable.</para>
+ </parameter>
+ </syntax>
</managerEventInstance>
***/
ast_manager_event(src, EVENT_FLAG_CALL, "Dial",
Modified: team/mjordan/manager-events/apps/app_voicemail.c
URL: http://svnview.digium.com/svn/asterisk/team/mjordan/manager-events/apps/app_voicemail.c?view=diff&rev=368557&r1=368556&r2=368557
==============================================================================
--- team/mjordan/manager-events/apps/app_voicemail.c (original)
+++ team/mjordan/manager-events/apps/app_voicemail.c Tue Jun 5 15:55:32 2012
@@ -7197,7 +7197,30 @@
queue_mwi_event(ext_context, urgentmsgs, newmsgs, oldmsgs);
- ast_manager_event(chan, EVENT_FLAG_CALL, "MessageWaiting", "Mailbox: %s@%s\r\nWaiting: %d\r\nNew: %d\r\nOld: %d\r\n", vmu->mailbox, vmu->context, ast_app_has_voicemail(ext_context, NULL), newmsgs, oldmsgs);
+ /*** DOCUMENTATION
+ <managerEventInstance>
+ <synopsis>Raised when a new message has been left in a voicemail mailbox.</synopsis>
+ <syntax>
+ <parameter name="Mailbox">
+ <para>The mailbox with the new message, specified as <emphasis>mailbox</emphasis>@<emphasis>context</emphasis></para>
+ </parameter>
+ <parameter name="Waiting">
+ <para>Whether or not the mailbox has access to a voicemail application.</para>
+ </parameter>
+ <parameter name="New">
+ <para>The number of new messages.</para>
+ </parameter>
+ <parameter name="Old">
+ <para>The number of old messages.</para>
+ </parameter>
+ </syntax>
+ </managerEventInstance>
+ ***/
+ ast_manager_event(chan, EVENT_FLAG_CALL, "MessageWaiting",
+ "Mailbox: %s@%s\r\n"
+ "Waiting: %d\r\n"
+ "New: %d\r\n"
+ "Old: %d\r\n", vmu->mailbox, vmu->context, ast_app_has_voicemail(ext_context, NULL), newmsgs, oldmsgs);
run_externnotify(vmu->context, vmu->mailbox, flag);
#ifdef IMAP_STORAGE
@@ -10690,6 +10713,11 @@
if (valid) {
int new = 0, old = 0, urgent = 0;
snprintf(ext_context, sizeof(ext_context), "%s@%s", vms.username, vmu->context);
+ /*** DOCUMENTATION
+ <managerEventInstance>
+ <synopsis>Raised when a user has finished listening to their messages.</synopsis>
+ </managerEventInstance>
+ ***/
ast_manager_event(chan, EVENT_FLAG_CALL, "MessageWaiting", "Mailbox: %s\r\nWaiting: %d\r\n", ext_context, has_voicemail(ext_context, NULL));
/* Urgent flag not passwd to externnotify here */
run_externnotify(vmu->context, vmu->mailbox, NULL);
Modified: team/mjordan/manager-events/build_tools/get_documentation.py
URL: http://svnview.digium.com/svn/asterisk/team/mjordan/manager-events/build_tools/get_documentation.py?view=diff&rev=368557&r1=368556&r2=368557
==============================================================================
--- team/mjordan/manager-events/build_tools/get_documentation.py (original)
+++ team/mjordan/manager-events/build_tools/get_documentation.py Tue Jun 5 15:55:32 2012
@@ -97,7 +97,7 @@
e.setAttribute('name', parameter)
syntax.appendChild(e)
- return dom.toprettyxml().replace("<?xml version=\"1.0\" ?>", "")
+ return dom.toxml().replace("<?xml version=\"1.0\" ?>", "")
def main(argv=None):
Modified: team/mjordan/manager-events/include/asterisk/xmldoc.h
URL: http://svnview.digium.com/svn/asterisk/team/mjordan/manager-events/include/asterisk/xmldoc.h?view=diff&rev=368557&r1=368556&r2=368557
==============================================================================
--- team/mjordan/manager-events/include/asterisk/xmldoc.h (original)
+++ team/mjordan/manager-events/include/asterisk/xmldoc.h Tue Jun 5 15:55:32 2012
@@ -46,6 +46,8 @@
* \note
* Each of the ast_str objects are built from the corresponding ast_xmldoc_build_*
* calls
+ *
+ * \since 11
*/
struct ast_xml_doc_item {
/*!< The syntax of the item */
@@ -129,11 +131,14 @@
char *ast_xmldoc_build_description(const char *type, const char *name, const char *module);
/*!
- * \brief Build the documentation for a particular type
+ * \brief Build the documentation for a particular source type
* \param type The source of the documentation items (application, function, etc.)
+ *
* \retval NULL on error
* \retval An ao2_container populated with ast_xml_doc instances for each item
- * that exists within that type
+ * that exists for the specified source type
+ *
+ * \since 11
*/
struct ao2_container *ast_xmldoc_build_documentation(const char *type);
Modified: team/mjordan/manager-events/main/manager.c
URL: http://svnview.digium.com/svn/asterisk/team/mjordan/manager-events/main/manager.c?view=diff&rev=368557&r1=368556&r2=368557
==============================================================================
--- team/mjordan/manager-events/main/manager.c (original)
+++ team/mjordan/manager-events/main/manager.c Tue Jun 5 15:55:32 2012
@@ -6766,13 +6766,23 @@
return CLI_SUCCESS;
}
+#ifdef AST_XML_DOCS
+
+static int ast_xml_doc_item_cmp_fn(const void *a, const void *b)
+{
+ struct ast_xml_doc_item **item_a = (struct ast_xml_doc_item **)a;
+ struct ast_xml_doc_item **item_b = (struct ast_xml_doc_item **)b;
+ return strcmp((*item_a)->name, (*item_b)->name);
+}
+
static char *handle_manager_show_events(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
struct ao2_container *events;
- struct ao2_iterator it_events;
+ struct ao2_iterator *it_events;
struct ast_xml_doc_item *item;
+ struct ast_xml_doc_item **items;
struct ast_str *buffer;
- int i = 0;
+ int i = 0, totalitems = 0;
switch (cmd) {
case CLI_INIT:
@@ -6800,23 +6810,45 @@
return CLI_SUCCESS;
}
+ ao2_lock(events);
+ if (!(it_events = ao2_callback(events, OBJ_MULTIPLE | OBJ_NOLOCK, NULL, NULL))) {
+ ao2_unlock(events);
+ ast_log(AST_LOG_ERROR, "Unable to create iterator for events container\n");
+ ast_free(buffer);
+ ao2_ref(events, -1);
+ return CLI_SUCCESS;
+ }
+ if (!(items = ast_calloc(sizeof(struct ast_xml_doc_item *), ao2_container_count(events)))) {
+ ao2_unlock(events);
+ ast_log(AST_LOG_ERROR, "Unable to create temporary sorting array for events\n");
+ ao2_iterator_destroy(it_events);
+ ast_free(buffer);
+ ao2_ref(events, -1);
+ return CLI_SUCCESS;
+ }
+ ao2_unlock(events);
+
+ while ((item = ao2_iterator_next(it_events))) {
+ items[totalitems++] = item;
+ }
+
+ qsort(items, totalitems, sizeof(struct ast_xml_doc_item *), ast_xml_doc_item_cmp_fn);
+
ast_cli(a->fd, "Events:\n");
- ast_cli(a->fd, "---------------------------");
-
- it_events = ao2_iterator_init(events, 0);
- while ((item = ao2_iterator_next(&it_events))) {
- ast_str_append(&buffer, 0, " %-15.15s", item->name);
- ++i;
- if (i % 3 == 0) {
+ ast_cli(a->fd, " -------------------- -------------------- -------------------- \n");
+ for (i = 0; i < totalitems; i++) {
+ ast_str_append(&buffer, 0, " %-20.20s", items[i]->name);
+ if ((i + 1) % 3 == 0) {
ast_cli(a->fd, "%s\n", ast_str_buffer(buffer));
ast_str_set(&buffer, 0, "%s", "");
}
}
- if (i % 3 != 0) {
+ if ((i + 1) % 3 != 0) {
ast_cli(a->fd, "%s\n", ast_str_buffer(buffer));
}
- ao2_iterator_destroy(&it_events);
-
+
+ ao2_iterator_destroy(it_events);
+ ast_free(items);
ao2_ref(events, -1);
ast_free(buffer);
@@ -6826,7 +6858,7 @@
static char *handle_manager_show_event(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
struct ao2_container *events;
- struct ast_xml_doc_item *item;
+ struct ast_xml_doc_item *item, *temp;
char syntax_title[64], description_title[64], synopsis_title[64], seealso_title[64], arguments_title[64];
switch (cmd) {
@@ -6863,18 +6895,32 @@
term_color(arguments_title, "[Arguments]\n", COLOR_MAGENTA, 0, 40);
ast_cli(a->fd, "Event: %s\n", a->argv[3]);
- for (; item; item = item->next) {
- ast_cli(a->fd, "%s%s\n\n"
- "%s%s\n\n"
- "%s%s\n\n"
- "%s%s\n\n"
- "%s%s\n\n",
- synopsis_title, ast_xmldoc_printable(S_OR(ast_str_buffer(item->synopsis), "Not available"), 1),
- syntax_title, ast_xmldoc_printable(S_OR(ast_str_buffer(item->syntax), "Not available"), 1),
- description_title, ast_xmldoc_printable(S_OR(ast_str_buffer(item->description), "Not available"),1),
- arguments_title, ast_xmldoc_printable(S_OR(ast_str_buffer(item->arguments), "Not available"), 1),
- seealso_title, ast_xmldoc_printable(S_OR(ast_str_buffer(item->seealso), "Not available"), 1)
- );
+ for (temp = item; temp; temp = temp->next) {
+ if (ast_str_strlen(temp->synopsis) && strcmp("(null)", ast_str_buffer(temp->synopsis))) {
+ ast_cli(a->fd, "%s%s\n\n",
+ synopsis_title,
+ ast_xmldoc_printable(ast_str_buffer(temp->synopsis), 1));
+ }
+ if (ast_str_strlen(temp->syntax) && strcmp("(null)", ast_str_buffer(temp->syntax))) {
+ ast_cli(a->fd, "%s%s\n\n",
+ syntax_title,
+ ast_xmldoc_printable(ast_str_buffer(temp->syntax), 1));
+ }
+ if (ast_str_strlen(temp->description) && strcmp("(null)", ast_str_buffer(temp->description))) {
+ ast_cli(a->fd, "%s%s\n\n",
+ description_title,
+ ast_xmldoc_printable(ast_str_buffer(temp->description), 1));
+ }
+ if (ast_str_strlen(temp->arguments) && strcmp("(null)", ast_str_buffer(temp->arguments))) {
+ ast_cli(a->fd, "%s%s\n\n",
+ arguments_title,
+ ast_xmldoc_printable(ast_str_buffer(temp->arguments), 1));
+ }
+ if (ast_str_strlen(temp->seealso) && strcmp("(null)", ast_str_buffer(temp->seealso))) {
+ ast_cli(a->fd, "%s%s\n\n",
+ seealso_title,
+ ast_xmldoc_printable(ast_str_buffer(temp->seealso), 1));
+ }
}
ao2_ref(item, -1);
@@ -6882,6 +6928,7 @@
return CLI_SUCCESS;
}
+#endif
static struct ast_cli_entry cli_manager[] = {
AST_CLI_DEFINE(handle_showmancmd, "Show a manager interface command"),
@@ -6893,8 +6940,10 @@
AST_CLI_DEFINE(handle_mandebug, "Show, enable, disable debugging of the manager code"),
AST_CLI_DEFINE(handle_manager_reload, "Reload manager configurations"),
AST_CLI_DEFINE(handle_manager_show_settings, "Show manager global settings"),
+#ifdef AST_XML_DOCS
AST_CLI_DEFINE(handle_manager_show_events, "List manager interface events"),
AST_CLI_DEFINE(handle_manager_show_event, "Show a manager interface event"),
+#endif
};
/*!
@@ -6996,6 +7045,7 @@
append_event("Event: Placeholder\r\n\r\n", 0);
}
+#ifdef AST_XML_DOCS
temp_event_docs = ast_xmldoc_build_documentation("managerEvent");
if (temp_event_docs) {
temp_event_docs = ao2_global_obj_replace(event_docs, temp_event_docs);
@@ -7003,6 +7053,7 @@
ao2_ref(temp_event_docs, -1);
}
}
+#endif
if ((cfg = ast_config_load2("manager.conf", "manager", config_flags)) == CONFIG_STATUS_FILEUNCHANGED) {
return 0;
Modified: team/mjordan/manager-events/main/xmldoc.c
URL: http://svnview.digium.com/svn/asterisk/team/mjordan/manager-events/main/xmldoc.c?view=diff&rev=368557&r1=368556&r2=368557
==============================================================================
--- team/mjordan/manager-events/main/xmldoc.c (original)
+++ team/mjordan/manager-events/main/xmldoc.c Tue Jun 5 15:55:32 2012
@@ -1084,11 +1084,15 @@
continue;
}
- ast_str_append(&syntax, 0, "\n%s%s:%s <value>",
- (required ? "" : "["),
- attrname,
- (required ? "" : "]"));
-
+ if (!strcasecmp(manager_type, "event")) {
+ ast_str_append(&syntax, 0, "\n%s: <value>",
+ attrname);
+ } else {
+ ast_str_append(&syntax, 0, "\n%s%s:%s <value>",
+ (required ? "" : "["),
+ attrname,
+ (required ? "" : "]"));
+ }
ast_xml_free_attr(attrname);
}
@@ -1115,7 +1119,7 @@
{ "function", FUNCTION_SYNTAX },
{ "application", FUNCTION_SYNTAX },
{ "manager", MANAGER_SYNTAX },
- { "managerEventInstance", MANAGER_EVENT_SYNTAX },
+ { "managerEvent", MANAGER_EVENT_SYNTAX },
{ "agi", COMMAND_SYNTAX }
};
@@ -1138,7 +1142,17 @@
static char *_ast_xmldoc_build_syntax(struct ast_xml_node *node, const char *type, const char *name)
{
- char *syntax;
+ char *syntax = NULL;
+
+ for (node = ast_xml_node_get_children(node); node; node = ast_xml_node_get_next(node)) {
+ if (!strcasecmp(ast_xml_node_get_name(node), "syntax")) {
+ break;
+ }
+ }
+
+ if (!node) {
+ return syntax;
+ }
switch (xmldoc_get_syntax_type(type)) {
case FUNCTION_SYNTAX:
@@ -1163,23 +1177,13 @@
char *ast_xmldoc_build_syntax(const char *type, const char *name, const char *module)
{
struct ast_xml_node *node;
- char *syntax = NULL;
node = xmldoc_get_node(type, name, module, documentation_language);
if (!node) {
return NULL;
}
- for (node = ast_xml_node_get_children(node); node; node = ast_xml_node_get_next(node)) {
- if (!strcasecmp(ast_xml_node_get_name(node), "syntax")) {
- break;
- }
- }
-
- if (node) {
- syntax = _ast_xmldoc_build_syntax(node, type, name);
- }
- return syntax;
+ return _ast_xmldoc_build_syntax(node, type, name);
}
/*! \internal
@@ -1511,6 +1515,7 @@
}
output = ast_strdup(ast_str_buffer(outputstr));
+ ast_log(AST_LOG_NOTICE, "%s\n", output);
ast_free(outputstr);
return output;
@@ -2047,8 +2052,6 @@
struct documentation_tree *doctree;
const char *name;
-
-
if (!(docs = ao2_container_alloc(127, ast_xml_doc_item_hash, ast_xml_doc_item_cmp))) {
ast_log(AST_LOG_ERROR, "Failed to create container for xml document item instances\n");
return NULL;
@@ -2067,7 +2070,6 @@
if (!ast_xml_node_get_children(node) || strcasecmp(ast_xml_node_get_name(node), type)) {
continue;
}
- ast_log(AST_LOG_NOTICE, "GOT %s!\n", ast_xml_node_get_name(node));
name = ast_xml_get_attribute(node, "name");
switch (xmldoc_get_syntax_type(type)) {
@@ -2097,6 +2099,7 @@
if (item) {
ao2_link(docs, item);
+ item = NULL;
}
}
}
More information about the asterisk-commits
mailing list