Module: sip-router
Branch: master
Commit: a078f2d1dd19d83a9e740834403f48fdf6088d2b
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=a078f2d…
Author: pd <peter.dunkley(a)crocodile-rcs.com>
Committer: pd <peter.dunkley(a)crocodile-rcs.com>
Date: Thu Aug 18 15:12:33 2011 +0100
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).
---
modules_k/presence_xml/README | 4 +++-
modules_k/presence_xml/doc/presence_xml_admin.xml | 9 ++++++++-
modules_k/presence_xml/pres_check.c | 10 ++++++----
3 files changed, 17 insertions(+), 6 deletions(-)
diff --git a/modules_k/presence_xml/README b/modules_k/presence_xml/README
index 8756ea8..59099eb 100644
--- a/modules_k/presence_xml/README
+++ b/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");
diff --git a/modules_k/presence_xml/doc/presence_xml_admin.xml
b/modules_k/presence_xml/doc/presence_xml_admin.xml
index 059bb97..7bfe201 100644
--- a/modules_k/presence_xml/doc/presence_xml_admin.xml
+++ b/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");
diff --git a/modules_k/presence_xml/pres_check.c b/modules_k/presence_xml/pres_check.c
index 40ce7fb..fea420b 100644
--- a/modules_k/presence_xml/pres_check.c
+++ b/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;
}