[asterisk-commits] mmichelson: branch group/CCSS r233278 - /team/group/CCSS/channels/chan_sip.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Dec 4 15:48:59 CST 2009


Author: mmichelson
Date: Fri Dec  4 15:48:55 2009
New Revision: 233278

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=233278
Log:
Add some XML parsing code to the CC ESC initial handler.

I need to look up what the appropriate response code to
send is when the body of the PUBLISH does not have the
requisite information.


Modified:
    team/group/CCSS/channels/chan_sip.c

Modified: team/group/CCSS/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/team/group/CCSS/channels/chan_sip.c?view=diff&rev=233278&r1=233277&r2=233278
==============================================================================
--- team/group/CCSS/channels/chan_sip.c (original)
+++ team/group/CCSS/channels/chan_sip.c Fri Dec  4 15:48:55 2009
@@ -23480,6 +23480,11 @@
 	struct ast_cc_agent *agent = find_sip_cc_agent_by_notify_uri(uri);
 	struct sip_cc_agent_pvt *agent_pvt;
 	struct ast_xml_doc *pidf_doc;
+	const char *basic_status;
+	struct ast_xml_node *presence_node;
+	struct ast_xml_node *tuple_node;
+	struct ast_xml_node *status_node;
+	struct ast_xml_node *basic_node;
 	
 	if (!agent) {
 		ast_log(LOG_WARNING, "Could not find agent using uri '%s'\n", uri);
@@ -23499,8 +23504,34 @@
 	 * element contained within. While not violating the PIDF spec, these are
 	 * insufficient for our needs in this situation
 	 */
-
-	agent_pvt->is_available = FALSE;
+	presence_node = ast_xml_get_root(pidf_doc);
+	tuple_node = ast_xml_find_element(presence_node, "tuple", NULL, NULL);
+
+	if (!tuple_node) {
+		/*XXX send an error response, yo! */
+	}
+
+	status_node = ast_xml_find_element(tuple_node, "status", NULL, NULL);
+	/* We already made sure that the tuple has a status node when we validated the PIDF
+	 * document earlier.
+	 */
+	basic_node = ast_xml_find_element(status_node, "basic", NULL, NULL);
+	if (!basic_node) {
+		/* XXX send an error response */
+	}
+
+	basic_status = ast_xml_get_text(basic_node);
+
+	if (!strcmp(basic_status, "open")) {
+		agent_pvt->is_available = TRUE;
+	} else if (!strcmp(basic_status, "closed")) {
+		agent_pvt->is_available = FALSE;
+	} else {
+		/* XXX send an error response */
+	}
+
+	ast_xml_free_text(basic_status);
+
 	/* It's possible to get a PUBLISH before we have sent a NOTIFY that a callee is
 	 * available. If that is the case, this call to ast_cc_agent_caller_busy will not
 	 * have any effect. We handle that case properly, though, in the SIP agent's recall




More information about the asterisk-commits mailing list