Module: sip-router Branch: master Commit: d1097d6ac9295c529ad6e682534ee4b3f0a9daae URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=d1097d6a...
Author: Daniel-Constantin Mierla miconda@gmail.com Committer: Daniel-Constantin Mierla miconda@gmail.com Date: Fri Aug 12 22:51:20 2011 +0200
pua_xmpp: fixes to SIP-XMPP presence status translations
* patch by Laura Testi to fix: - the online/offline status is ok in both direction (SIP<-->XMPP) - other status (away/busy) is not ok from XMPP to SIP - busy status is not ok from SIP to XMPP - each time XMPP contact change the status, triger a new SUBSCRIBE in xmpp gateway which generate multiple same subscriptions with different callid in both active_watchers and pua tables. This also makes multiple NOTIFY generation from the main Presence Server to GW when the SIP contact change it's status
---
modules_k/pua_xmpp/simple2xmpp.c | 15 +++++++++---- modules_k/pua_xmpp/xmpp2simple.c | 42 +++++++++++-------------------------- 2 files changed, 23 insertions(+), 34 deletions(-)
diff --git a/modules_k/pua_xmpp/simple2xmpp.c b/modules_k/pua_xmpp/simple2xmpp.c index 040d36c..e041bcb 100644 --- a/modules_k/pua_xmpp/simple2xmpp.c +++ b/modules_k/pua_xmpp/simple2xmpp.c @@ -87,7 +87,7 @@ int Notify2Xmpp(struct sip_msg* msg, char* s1, char* s2) if(msg->to->parsed != NULL) { pto = (struct to_body*)msg->to->parsed; - LM_ERR("'To' header ALREADY PARSED:<%.*s>\n",pto->uri.len,pto->uri.s); + LM_DBG("'To' header ALREADY PARSED:<%.*s>\n",pto->uri.len,pto->uri.s); } else { @@ -415,7 +415,8 @@ int build_xmpp_content(str* to_uri, str* from_uri, str* body, str* id, goto error; }
- if(xmlStrcasecmp((unsigned char*)note, (unsigned char*)"away")== 0) + if((xmlStrcasecmp((unsigned char*)note, (unsigned char*)"away")== 0)|| + (xmlStrcasecmp((unsigned char*)note, (unsigned char*)"On the phone")== 0)) { new_node = xmlNewChild(xmpp_root, NULL, BAD_CAST "show", BAD_CAST "away"); @@ -456,12 +457,14 @@ int build_xmpp_content(str* to_uri, str* from_uri, str* body, str* id, LM_ERR("while adding node: idle\n"); goto error; } - } - else */ + }*/ + else if((xmlStrcasecmp((unsigned char*)note, (unsigned char*)"dnd")== 0)|| (xmlStrcasecmp((unsigned char*)note, - (unsigned char*)"do not disturb")== 0)) + (unsigned char*)"do not disturb")== 0)|| + (xmlStrcasecmp((unsigned char*)note, + (unsigned char*)"Busy (DND)")== 0)) { new_node = xmlNewChild(xmpp_root, NULL, BAD_CAST "show", BAD_CAST "dnd"); @@ -471,6 +474,8 @@ int build_xmpp_content(str* to_uri, str* from_uri, str* body, str* id, goto error; } } + else + LM_DBG("Not Found Status\n");
/* adding status node */ diff --git a/modules_k/pua_xmpp/xmpp2simple.c b/modules_k/pua_xmpp/xmpp2simple.c index 43fa9a0..d0bdc1e 100644 --- a/modules_k/pua_xmpp/xmpp2simple.c +++ b/modules_k/pua_xmpp/xmpp2simple.c @@ -76,13 +76,13 @@ void pres_Xmpp2Sip(char *msg, int type, void *param) { LM_DBG("type attribut not present\n"); build_publish(pres_node, -1); - if(presence_subscribe(pres_node, 3600, XMPP_SUBSCRIBE)< 0) + /* if(presence_subscribe(pres_node, 3600, XMPP_SUBSCRIBE)< 0) { LM_ERR("when sending subscribe for presence"); xmlFree(pres_type); goto error; } - + */
/* send subscribe after publish because in xmpp subscribe message * comes only when a new contact is inserted in buddy list */ @@ -91,13 +91,13 @@ void pres_Xmpp2Sip(char *msg, int type, void *param) if(strcmp(pres_type, "unavailable")== 0) { build_publish(pres_node, 0); - if(presence_subscribe(pres_node, 3600, XMPP_SUBSCRIBE)< 0) - /* else subscribe for one hour*/ + /* if(presence_subscribe(pres_node, 0, XMPP_SUBSCRIBE)< 0) { LM_ERR("when unsubscribing for presence"); xmlFree(pres_type); goto error; } + */
} else @@ -243,13 +243,13 @@ str* build_pidf(xmlNodePtr pres_node, char* uri, char* resource) if(show_cont) { if(strcmp(show_cont, "xa")== 0) - status= "not available"; + status= "Away"; else if(strcmp(show_cont, "chat")== 0) - status= "free for chat"; + status= "Online"; else if(strcmp(show_cont, "dnd")== 0) - status= "do not disturb"; + status= "Busy (DND)"; else status= show_cont; } @@ -264,24 +264,25 @@ str* build_pidf(xmlNodePtr pres_node, char* uri, char* resource) goto error; } */ - node = xmlNewChild(root_node, NULL, BAD_CAST "note", - BAD_CAST status_cont); + node = xmlNewChild(tuple_node, NULL, BAD_CAST "note", + BAD_CAST status); if(node== NULL) { LM_ERR("while adding node\n"); goto error; } - }else + } else { if(show_cont) { - node = xmlNewChild(root_node, NULL, BAD_CAST "note", + node = xmlNewChild(tuple_node, NULL, BAD_CAST "note", BAD_CAST status); if(node== NULL) { LM_ERR("while adding node\n"); goto error; } - } + } + }
if(show_cont) { @@ -295,23 +296,6 @@ str* build_pidf(xmlNodePtr pres_node, char* uri, char* resource) goto error; } } - node= xmlNewChild(person_node, NULL, BAD_CAST "activities", - BAD_CAST 0); - if(node== NULL) - { - LM_ERR("while adding node\n"); - goto error; - } - - - if( xmlNewChild(person_node, NULL, BAD_CAST "note", - BAD_CAST status )== NULL) - { - LM_ERR("while adding node\n"); - goto error; - } - - }