فهرست منبع

modules_k/presence_xml: Modified pres_check_activities() to return -2 when part of the XML tree is not present

- This is needed because some presence UAs (such as pua_usrloc) only
  fill in the basic part of the tree.  This change enables you to
  distinguish between not having a particular activity set (by a client
  that supports that) and not having any activities at all (by clients
  that only support basic presence).
pd 14 سال پیش
والد
کامیت
a078f2d1dd
3فایلهای تغییر یافته به همراه17 افزوده شده و 6 حذف شده
  1. 3 1
      modules_k/presence_xml/README
  2. 8 1
      modules_k/presence_xml/doc/presence_xml_admin.xml
  3. 6 4
      modules_k/presence_xml/pres_check.c

+ 3 - 1
modules_k/presence_xml/README

@@ -320,11 +320,13 @@ modparam("presence_xml", "passive_mode", 1)
    Return code:
      * 1 - if a match is found.
      * -1 - if a match is not found.
+     * -2 - if /presence/person or /presence/person/activity do not exist.
 
    Example 1.12. pres_check_activities usage
 ...
     if (pres_check_basic("$ru", "open")) {
-        if (pres_check_activities("$ru", "unknown") || !is_method("INVITE"))
+        pres_check_activities("$ru", "unknown");
+        if ($retcode || $retcode == -2 || !is_method("INVITE"))
             t_relay();
         else
             send_reply("486", "Busy Here");

+ 8 - 1
modules_k/presence_xml/doc/presence_xml_admin.xml

@@ -381,6 +381,12 @@ modparam("presence_xml", "passive_mode", 1)
 				<emphasis> -1 - if a match is not found</emphasis>.
 			</para>
 			</listitem>
+			<listitem>
+			<para>
+				<emphasis> -2 - if /presence/person or /presence/person/activity do not exist</emphasis>.
+			</para>
+			</listitem>
+	
 		</itemizedlist>
 		</para>
 		<example>
@@ -388,7 +394,8 @@ modparam("presence_xml", "passive_mode", 1)
 		<programlisting format="linespecific">
 ...
     if (pres_check_basic("$ru", "open")) {
-        if (pres_check_activities("$ru", "unknown") || !is_method("INVITE"))
+	pres_check_activities("$ru", "unknown");
+	if ($retcode || $retcode == -2 || !is_method("INVITE"))
             t_relay();
 	else
             send_reply("486", "Busy Here");

+ 6 - 4
modules_k/presence_xml/pres_check.c

@@ -98,7 +98,7 @@ int presxml_check_basic(struct sip_msg *msg, char *presentity_uri, char *status)
 		goto error;
 	}
 
-	while (tuple->next != NULL)
+	while (tuple != NULL)
 	{
 		if (xmlStrcasecmp(tuple->name, (unsigned char *) "tuple") == 0)
 		{
@@ -189,17 +189,19 @@ int presxml_check_activities(struct sip_msg *msg, char *presentity_uri, char *ac
 
 	if ((person = xmlDocGetNodeByName(xmlDoc, "person", NULL)) == NULL)
 	{
-		LM_ERR("unable to extract 'person'\n");
+		LM_DBG("unable to extract 'person'\n");
+		retval = -2;
 		goto error;
 	}
 
-	while (person->next != NULL)
+	while (person != NULL)
 	{
 		if (xmlStrcasecmp(person->name, (unsigned char *) "person") == 0)
 		{
 			if ((activitiesNode = xmlNodeGetNodeByName(person, "activities", NULL)) == NULL)
 			{
-				LM_ERR("while extracting 'actvities' node\n");
+				LM_DBG("unable to extract 'actvities' node\n");
+				retval = -2;
 				goto error;
 			}