Module: sip-router Branch: master Commit: 59f30b6cbcf25d0ef0f517dad21fa8e711732293 URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=59f30b6c...
Author: Juha Heinanen jh@tutpro.com Committer: Juha Heinanen jh@tutpro.com Date: Wed Apr 22 14:08:51 2009 +0300
* Modules: presence
* Changed name of auth_status function to pres_auth_status. * Fixed and improved example (don't know how to generate new README).
---
modules_k/presence/doc/presence_admin.xml | 15 ++++++++++----- modules_k/presence/presence.c | 6 +++--- 2 files changed, 13 insertions(+), 8 deletions(-)
diff --git a/modules_k/presence/doc/presence_admin.xml b/modules_k/presence/doc/presence_admin.xml index 057bc95..f39d676 100644 --- a/modules_k/presence/doc/presence_admin.xml +++ b/modules_k/presence/doc/presence_admin.xml @@ -455,11 +455,11 @@ if(method=="SUBSCRIBE")
<section> <title> - <function moreinfo="none">auth_status(watcher_uri, presentity_uri)</function> + <function moreinfo="none">pres_auth_status(watcher_uri, presentity_uri)</function> </title> <para> The function checks if watcher is authorized to subscribe - presence of presentity. Both watcher_uri and + event 'presence' of presentity. Both watcher_uri and presentity_uri are pseudo variables. Function returns ACTIVE_STATUS, if subscription is allowed and PENDING_STATUS, TERMINATED_STATUS, or WAITING_STATUS @@ -472,11 +472,16 @@ if(method=="SUBSCRIBE") </para>
<example> - <title><function>auth_status</function> usage</title> + <title><function>pres_auth_status</function> usage</title> <programlisting format="linespecific"> ... -if((method=="MESSAGE") && (auth_status("$fu", $ru"))) { - t_relay(); +if (method=="MESSAGE") { + pres_auth_status("$fu", $ru"); + if ($retcode == 1) { + t_relay(); + } else { + send_reply("403", "Forbidden"); + } } ... </programlisting> diff --git a/modules_k/presence/presence.c b/modules_k/presence/presence.c index 9aac54c..703050c 100644 --- a/modules_k/presence/presence.c +++ b/modules_k/presence/presence.c @@ -118,7 +118,7 @@ static struct mi_root* mi_cleanup(struct mi_root* cmd, void* param); static int update_pw_dialogs(subs_t* subs, unsigned int hash_code, subs_t** subs_array); int update_watchers_status(str pres_uri, pres_ev_t* ev, str* rules_doc); static int mi_child_init(void); -static int auth_status(struct sip_msg* _msg, char* _sp1, char* _sp2); +static int pres_auth_status(struct sip_msg* _msg, char* _sp1, char* _sp2);
int counter =0; int pid = 0; @@ -140,7 +140,7 @@ static cmd_export_t cmds[]= {"handle_publish", (cmd_function)handle_publish, 0,fixup_presence,0, REQUEST_ROUTE}, {"handle_publish", (cmd_function)handle_publish, 1,fixup_presence, 0, REQUEST_ROUTE}, {"handle_subscribe",(cmd_function)handle_subscribe,0,fixup_subscribe,0, REQUEST_ROUTE}, - {"auth_status", (cmd_function)auth_status, 2, fixup_pvar_pvar, fixup_free_pvar_pvar, REQUEST_ROUTE}, + {"pres_auth_status", (cmd_function)pres_auth_status, 2, fixup_pvar_pvar, fixup_free_pvar_pvar, REQUEST_ROUTE}, {"bind_presence", (cmd_function)bind_presence, 1, 0, 0, 0}, { 0, 0, 0, 0, 0, 0} }; @@ -1078,7 +1078,7 @@ static int update_pw_dialogs(subs_t* subs, unsigned int hash_code, subs_t** subs return 0; }
-static int auth_status(struct sip_msg* _msg, char* _sp1, char* _sp2) +static int pres_auth_status(struct sip_msg* _msg, char* _sp1, char* _sp2) { pv_spec_t *sp; pv_value_t pv_val;