[asterisk-commits] bkruse: branch group/appdocsxml r128246 - in /team/group/appdocsxml: apps/ in...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Sat Jul 5 16:08:52 CDT 2008


Author: bkruse
Date: Sat Jul  5 16:08:52 2008
New Revision: 128246

URL: http://svn.digium.com/view/asterisk?view=rev&rev=128246
Log:
I think this works :D

Modified:
    team/group/appdocsxml/apps/app_dial.c
    team/group/appdocsxml/include/asterisk/module.h
    team/group/appdocsxml/main/pbx.c

Modified: team/group/appdocsxml/apps/app_dial.c
URL: http://svn.digium.com/view/asterisk/team/group/appdocsxml/apps/app_dial.c?view=diff&rev=128246&r1=128245&r2=128246
==============================================================================
--- team/group/appdocsxml/apps/app_dial.c (original)
+++ team/group/appdocsxml/apps/app_dial.c Sat Jul  5 16:08:52 2008
@@ -2453,7 +2453,7 @@
 	else
 		ast_add_extension2(con, 1, "s", 1, NULL, NULL, "KeepAlive", ast_strdup(""), ast_free_ptr, "app_dial");
 
-	res = ast_register_application(app, dial_exec, synopsis, descrip);
+	res = ast_register_application_xml(app, dial_exec);
 	res |= ast_register_application(rapp, retrydial_exec, rsynopsis, rdescrip);
 
 	return res;

Modified: team/group/appdocsxml/include/asterisk/module.h
URL: http://svn.digium.com/view/asterisk/team/group/appdocsxml/include/asterisk/module.h?view=diff&rev=128246&r1=128245&r2=128246
==============================================================================
--- team/group/appdocsxml/include/asterisk/module.h (original)
+++ team/group/appdocsxml/include/asterisk/module.h Sat Jul  5 16:08:52 2008
@@ -401,6 +401,7 @@
 int ast_register_application2(const char *app, int (*execute)(struct ast_channel *, void *),
 				     const char *synopsis, const char *description, void *mod);
 
+#define ast_register_application_xml(app, execute, synopsis, description) ast_register_application_xml_real(app, execute, synopsis, description, ast_module_info->self)
 /*!
  * \brief Register an application.
  *
@@ -418,7 +419,7 @@
  * \retval 0 success
  * \retval -1 failure.
  */
-int ast_register_application_xml(const char *app, int (*execute)(struct ast_channel *, void *), void *mod);
+int ast_register_application_xml_real(const char *app, int (*execute)(struct ast_channel *, void *), void *mod);
 
 
 /*! 

Modified: team/group/appdocsxml/main/pbx.c
URL: http://svn.digium.com/view/asterisk/team/group/appdocsxml/main/pbx.c?view=diff&rev=128246&r1=128245&r2=128246
==============================================================================
--- team/group/appdocsxml/main/pbx.c (original)
+++ team/group/appdocsxml/main/pbx.c Sat Jul  5 16:08:52 2008
@@ -331,7 +331,7 @@
 static unsigned int hashtab_hash_labels(const void *obj);
 static void __ast_internal_context_destroy( struct ast_context *con);
 #ifdef XML_DOCUMENTATION
-mxml_node_t *documentation_tree;
+mxml_node_t *documentation_tree = NULL;
 #endif
 
 /* a func for qsort to use to sort a char array */
@@ -4318,8 +4318,6 @@
 	FILE *xmldoc;
 	mxml_node_t *node;
 
-	ast_log(LOG_DEBUG, "************** LOADING XML DOCUMENTATION ********************\n");
-
 	/* For now, I just throw away cdata */
 	xmldoc = fopen(FILE_XML_DOC, "r");
 
@@ -4328,13 +4326,11 @@
 		return 1;
 	}
 
-	documentation_tree = mxmlLoadFile(NULL, xmldoc, MXML_TEXT_CALLBACK);
+	documentation_tree = mxmlLoadFile(NULL, xmldoc, MXML_OPAQUE_CALLBACK);
 
 	fclose(xmldoc);
 
 	node = mxmlFindElement(documentation_tree, documentation_tree, "application", "name", "Dial", MXML_DESCEND);
-
-	ast_log(LOG_WARNING, "Testing: ********** '%s'", node->value.opaque);
 
 	/* Ok, let's now process it. */
 	/* Check for errors in loading the doc */
@@ -4343,11 +4339,21 @@
 }
 
 /*! \brief Dynamically register a new dial plan application */
-int ast_register_application_xml(const char *app, int (*execute)(struct ast_channel *, void *), void *mod)
+int ast_register_application_xml_real(const char *app, int (*execute)(struct ast_channel *, void *), void *mod)
 {
 	struct ast_app *tmp, *cur = NULL;
 	char tmps[80];
+	char *strapp;
 	int length, res;
+	mxml_node_t *node, *desc, *syn;
+
+	node = desc = syn = NULL;
+
+	/* XXX If we do not have documentation, should we still register the application? */
+	if(!documentation_tree) {
+	    ast_log(LOG_WARNING, "Cannot get description or synopsis for application, loading XML documentation failed.\n");
+	    return -1;
+	}
 
 	AST_RWLIST_WRLOCK(&apps);
 	AST_RWLIST_TRAVERSE(&apps, tmp, list) {
@@ -4365,11 +4371,29 @@
 		AST_RWLIST_UNLOCK(&apps);
 		return -1;
 	}
+	
+	strapp = ast_strdup(app);	
+	node = mxmlFindElement(documentation_tree, documentation_tree, "application", "name", strapp, MXML_DESCEND);
+
+	if(!node) {
+	    ast_log(LOG_WARNING, "Cannot find application documentation for app: '%s'\n", app);
+	    return -1;
+	}
+
+	syn = mxmlFindElement(node, documentation_tree, "synopsis", NULL, NULL, MXML_DESCEND);
+	desc = mxmlFindElement(node, documentation_tree, "description", NULL, NULL, MXML_DESCEND);
+    
+	if(!syn || !desc || !syn->child || !desc->child) {
+
+	    ast_log(LOG_WARNING, "Cannot find Application description or synopsis for app: '%s'\n", app);
+	    return -1;
+
+	}
 
 	strcpy(tmp->name, app);
 	tmp->execute = execute;
-	//tmp->synopsis = synopsis;
-	//tmp->description = description;
+	tmp->synopsis = syn->child->value.opaque;
+        tmp->description = desc->child->value.opaque;
 	tmp->module = mod;
 
 	/* Store in alphabetical order */




More information about the asterisk-commits mailing list