[sr-dev] git:master: modules_k/presence: Added additional return value to pres_auth_status() for polite-block

Peter Dunkley peter.dunkley at crocodile-rcs.com
Sun Dec 18 22:16:29 CET 2011


Module: sip-router
Branch: master
Commit: 27ab10b4c61593ae544b7c24633840d0deafff92
URL:    http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=27ab10b4c61593ae544b7c24633840d0deafff92

Author: pd <peter.dunkley at crocodile-rcs.com>
Committer: pd <peter.dunkley at crocodile-rcs.com>
Date:   Sun Dec 18 21:08:45 2011 +0000

modules_k/presence: Added additional return value to pres_auth_status() for polite-block

- pres_auth_status() currently returns just the status of presence relationship.
- However, polite-block consists of a combination of status and reason,
  a polite-blocked watcher has ACTIVE status but a reason of polite-block.
  This means that even though blocked, when just checking based on status,
  polite-blocked watchers appear to be authorised.
- After this change pres_auth_status() returns a magic value of 5 when
  a watcher is polite-blocked.
- Feature added by Hugh Waite @ Crocodile RCS.

---

 modules_k/presence/presence.c  |    2 ++
 modules_k/presence/subscribe.h |    3 +++
 2 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/modules_k/presence/presence.c b/modules_k/presence/presence.c
index d573fb6..65b7a75 100644
--- a/modules_k/presence/presence.c
+++ b/modules_k/presence/presence.c
@@ -1465,6 +1465,8 @@ int pres_auth_status(struct sip_msg* msg, str watcher_uri, str presentity_uri)
 	   subs.status);
     pkg_free(rules_doc->s);
     pkg_free(rules_doc);
+    if ((subs.reason.len == 12) && (strncmp(subs.reason.s, "polite-block", 12) == 0))
+		return POLITE_BLOCK_STATUS;
     return subs.status;
 
  err:
diff --git a/modules_k/presence/subscribe.h b/modules_k/presence/subscribe.h
index b216fff..97e5309 100644
--- a/modules_k/presence/subscribe.h
+++ b/modules_k/presence/subscribe.h
@@ -46,6 +46,9 @@ struct pres_ev;
 #define PENDING_STATUS       2
 #define TERMINATED_STATUS    3
 #define WAITING_STATUS       4
+/* Additional value returned from pres_auth_status when the status is ACTIVE
+   and reason is polite-block */
+#define POLITE_BLOCK_STATUS  5
 
 #define INTERNAL_UPDATE_FALSE	0
 #define INTERNAL_UPDATE_TRUE	1




More information about the sr-dev mailing list