Update from upstream Kamailio 3.3 branch: 3abf967f61a1bd95c28d4e8a929a8bd5df00671d

modules_k/presence_xml Xcap auth reason when user deleted from list
    
    The reason in Subscription-Status header in Notify when a user is
    deleted from the contact list can be decided by the admin by setting
    presence_xml module parameter xcapauth_usedel_reason. Default value is
    "probation".
remotes/origin/3.3+ngcp2.6
Min Wang 14 years ago
parent 16d210cf28
commit e6ced81bb3

@ -828,17 +828,9 @@ int pres_update_status(subs_t subs, str reason, db_key_t* query_cols,
query_vals[q_wuser_col].val.str_val= subs.watcher_user;
query_vals[q_wdomain_col].val.str_val= subs.watcher_domain;
/* if status is no longer ACTIVE, switch to terminated */
if(subs.status!=status && status==ACTIVE_STATUS)
{
subs.status = TERMINATED_STATUS;
subs.reason.s = get_status_str(TERMINATED_STATUS);
subs.reason.len = strlen(subs.reason.s);
}
update_vals[u_status_col].val.int_val= subs.status;
update_vals[u_reason_col].val.str_val= subs.reason;
if (pa_dbf.use_table(pa_db, &watchers_table) < 0)
{
LM_ERR( "in use_table\n");

@ -32,6 +32,7 @@ Anca-Maria Vamanu
3.7. integrated_xcap_server (int)
3.8. xcap_server (str)
3.9. passive_mode(int)
3.10. xcapauth_userdel_reason(str)
4. Functions
@ -54,8 +55,9 @@ Anca-Maria Vamanu
1.7. Set integrated_xcap_server parameter
1.8. Set xcap_server parameter
1.9. Set passive_mode parameter
1.10. pres_check_basic usage
1.11. pres_check_activities usage
1.10. Set xcapauth_userdel_reason parameter
1.11. pres_check_basic usage
1.12. pres_check_activities usage
Chapter 1. Admin Guide
@ -78,6 +80,7 @@ Chapter 1. Admin Guide
3.7. integrated_xcap_server (int)
3.8. xcap_server (str)
3.9. passive_mode(int)
3.10. xcapauth_userdel_reason(str)
4. Functions
@ -135,6 +138,7 @@ Chapter 1. Admin Guide
3.7. integrated_xcap_server (int)
3.8. xcap_server (str)
3.9. passive_mode(int)
3.10. xcapauth_userdel_reason(str)
3.1. db_url(str)
@ -260,6 +264,26 @@ modparam("presence_xml", "xcap_server", "xcap_server.ag.org")
modparam("presence_xml", "passive_mode", 1)
...
3.10. xcapauth_userdel_reason(str)
This parameter represents the reason that will be included in the
Subscription-State header of the Notify when a rule is no longer found
in the XCAP pres-auth document for a user that was previously allowed.
The Subscription state in this case switches to "terminated". Because
it is not clear which reason is most appropriate in this case from the
ones defined by the RFC 3265, this parameter offers the possibility for
the admin to decide which one he wishes to use.
Default value: “probation” . Since probation also accepts a retry-after
parameter to specify after at least how may seconds the client should
reattempt to resubscribe, you can include this in the parameter also.
Example 1.10. Set xcapauth_userdel_reason parameter
...
modparam("presence_xml", "xcapauth_userdel_reason", "probation;retry-after=30")
modparam("presence_xml", "xcapauth_userdel_reason", "rejected")
...
4. Functions
4.1. pres_check_basic(presentity_uri, status)
@ -276,7 +300,7 @@ modparam("presence_xml", "passive_mode", 1)
* 1 - if a match is found.
* -1 - if a match is not found.
Example 1.10. pres_check_basic usage
Example 1.11. pres_check_basic usage
...
if (pres_check_basic("$ru", "open")) {
...
@ -300,7 +324,7 @@ modparam("presence_xml", "passive_mode", 1)
* -1 - if a match is not found.
* -2 - if /presence/person or /presence/person/activity do not exist.
Example 1.11. pres_check_activities usage
Example 1.12. pres_check_activities usage
...
if (pres_check_basic("$ru", "open")) {
pres_check_activities("$ru", "unknown");

@ -285,11 +285,40 @@ modparam("presence_xml", "xcap_server", "xcap_server.ag.org")
...
modparam("presence_xml", "passive_mode", 1)
...
</programlisting>
</example>
</section>
<section>
<title><varname>xcapauth_userdel_reason</varname>(str)</title>
<para>
This parameter represents the reason that will be included in the
Subscription-State header of the Notify when a rule is no longer found
in the XCAP pres-auth document for a user that was previously allowed.
The Subscription state in this case switches to "terminated". Because
it is not clear which reason is most appropriate in this case from
the ones defined by the RFC 3265, this parameter offers the possibility
for the admin to decide which one he wishes to use.
</para>
<para>
<emphasis>Default value: <quote>probation</quote> </emphasis> . Since
probation also accepts a retry-after parameter to specify after at
least how may seconds the client should reattempt to resubscribe,
you can include this in the parameter also.
</para>
<example>
<title>Set <varname>xcapauth_userdel_reason</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("presence_xml", "xcapauth_userdel_reason", "probation;retry-after=30")
modparam("presence_xml", "xcapauth_userdel_reason", "rejected")
...
</programlisting>
</example>
</section>
</section>
<section>
<title>Functions</title>
<section>

@ -94,6 +94,7 @@ int disable_presence = 0;
int disable_winfo = 0;
int disable_bla = 1;
int passive_mode = 0;
str xcapauth_userdel_reason = str_init("probation");
/** SL API structure */
sl_api_t slb;
@ -126,6 +127,7 @@ static param_export_t params[]={
{ "disable_winfo", INT_PARAM, &disable_winfo },
{ "disable_bla", INT_PARAM, &disable_bla },
{ "passive_mode", INT_PARAM, &passive_mode },
{ "xcapauth_userdel_reason", STR_PARAM, &xcapauth_userdel_reason.s},
{ 0, 0, 0}
};
@ -168,6 +170,8 @@ static int mod_init(void)
return -1;
}
xcapauth_userdel_reason.len = strlen(xcapauth_userdel_reason.s);
db_url.len = db_url.s ? strlen(db_url.s) : 0;
LM_DBG("db_url=%s/%d/%p\n",ZSW(db_url.s),db_url.len, db_url.s);
xcap_table.len = xcap_table.s ? strlen(xcap_table.s) : 0;

@ -47,6 +47,8 @@
#include "xcap_auth.h"
#include "pidf.h"
extern str xcapauth_userdel_reason;
int http_get_rules_doc(str user, str domain, str* rules_doc);
int pres_watcher_allowed(subs_t* subs)
@ -55,7 +57,8 @@ int pres_watcher_allowed(subs_t* subs)
xmlNodePtr node= NULL, actions_node = NULL;
xmlNodePtr sub_handling_node = NULL;
char* sub_handling = NULL;
int ret = 0;
/* if force_active set status to active*/
if(force_active)
{
@ -64,12 +67,12 @@ int pres_watcher_allowed(subs_t* subs)
subs->reason.len= 0;
return 0;
}
subs->status= PENDING_STATUS;
subs->reason.s= NULL;
subs->reason.len= 0;
if(subs->auth_rules_doc== NULL)
{
subs->status= PENDING_STATUS;
subs->reason.s= NULL;
subs->reason.len= 0;
return 0;
}
@ -84,27 +87,35 @@ int pres_watcher_allowed(subs_t* subs)
node= get_rule_node(subs, xcap_tree);
if(node== NULL)
{
xmlFreeDoc(xcap_tree);
return 0;
/* if no rule node was found and the previous state was active -> set the
* state to terminated with reason xcapauth_userdel_reason (default "probation") */
if(subs->status != PENDING_STATUS)
{
subs->status= TERMINATED_STATUS;
subs->reason= xcapauth_userdel_reason;
}
goto done;
}
/* process actions */
subs->status= PENDING_STATUS;
subs->reason.s= NULL;
subs->reason.len= 0;
/* process actions */
actions_node = xmlNodeGetChildByName(node, "actions");
if(actions_node == NULL)
{
{
LM_DBG("actions_node NULL\n");
xmlFreeDoc(xcap_tree);
return 0;
goto done;
}
LM_DBG("actions_node->name= %s\n",
actions_node->name);
sub_handling_node = xmlNodeGetChildByName(actions_node, "sub-handling");
if(sub_handling_node== NULL)
{
{
LM_DBG("sub_handling_node NULL\n");
xmlFreeDoc(xcap_tree);
return 0;
goto done;
}
sub_handling = (char*)xmlNodeGetContent(sub_handling_node);
LM_DBG("sub_handling_node->name= %s\n",
@ -115,8 +126,8 @@ int pres_watcher_allowed(subs_t* subs)
if(sub_handling== NULL)
{
LM_ERR("Couldn't get sub-handling content\n");
xmlFreeDoc(xcap_tree);
return -1;
ret = -1;
goto done;
}
if( strncmp((char*)sub_handling, "block",5 )==0)
{
@ -140,21 +151,19 @@ int pres_watcher_allowed(subs_t* subs)
if( strncmp((char*)sub_handling , "allow",5 )==0)
{
subs->status = ACTIVE_STATUS;
subs->reason.s = NULL;
}
else
{
LM_ERR("unknown subscription handling action\n");
xmlFree(sub_handling);
xmlFreeDoc(xcap_tree);
return -1;
ret = -1;
}
xmlFree(sub_handling);
done:
if(sub_handling)
xmlFree(sub_handling);
xmlFreeDoc(xcap_tree);
return 0;
}
return ret;
}
xmlNodePtr get_rule_node(subs_t* subs, xmlDocPtr xcap_tree )
{

Loading…
Cancel
Save