|
@@ -15,8 +15,8 @@
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
* GNU General Public License for more details.
|
|
*
|
|
*
|
|
- * You should have received a copy of the GNU General Public License
|
|
|
|
- * along with this program; if not, write to the Free Software
|
|
|
|
|
|
+ * You should have received a copy of the GNU General Public License
|
|
|
|
+ * along with this program; if not, write to the Free Software
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
*
|
|
*
|
|
*/
|
|
*/
|
|
@@ -58,7 +58,7 @@ int Notify2Xmpp(struct sip_msg* msg, char* s1, char* s2)
|
|
int event_flag= 0;
|
|
int event_flag= 0;
|
|
|
|
|
|
memset(&dialog, 0, sizeof(ua_pres_t));
|
|
memset(&dialog, 0, sizeof(ua_pres_t));
|
|
-
|
|
|
|
|
|
+
|
|
LM_DBG("start...\n\n");
|
|
LM_DBG("start...\n\n");
|
|
|
|
|
|
if( parse_headers(msg,HDR_EOH_F, 0)==-1 )
|
|
if( parse_headers(msg,HDR_EOH_F, 0)==-1 )
|
|
@@ -86,7 +86,7 @@ int Notify2Xmpp(struct sip_msg* msg, char* s1, char* s2)
|
|
else
|
|
else
|
|
{
|
|
{
|
|
parse_to(msg->to->body.s,msg->to->body.s + msg->to->body.len + 1, &TO);
|
|
parse_to(msg->to->body.s,msg->to->body.s + msg->to->body.len + 1, &TO);
|
|
- if(TO.uri.len <= 0)
|
|
|
|
|
|
+ if(TO.uri.len <= 0)
|
|
{
|
|
{
|
|
LM_ERR("'To' header NOT parsed\n");
|
|
LM_ERR("'To' header NOT parsed\n");
|
|
goto error;
|
|
goto error;
|
|
@@ -95,7 +95,7 @@ int Notify2Xmpp(struct sip_msg* msg, char* s1, char* s2)
|
|
}
|
|
}
|
|
|
|
|
|
dialog.watcher_uri= &pto->uri;
|
|
dialog.watcher_uri= &pto->uri;
|
|
-
|
|
|
|
|
|
+
|
|
uri=(char*)pkg_malloc(sizeof(char)*( pto->uri.len+1));
|
|
uri=(char*)pkg_malloc(sizeof(char)*( pto->uri.len+1));
|
|
if(uri== NULL)
|
|
if(uri== NULL)
|
|
{
|
|
{
|
|
@@ -110,12 +110,12 @@ int Notify2Xmpp(struct sip_msg* msg, char* s1, char* s2)
|
|
LM_ERR("while decoding sip uri in xmpp\n");
|
|
LM_ERR("while decoding sip uri in xmpp\n");
|
|
pkg_free(uri);
|
|
pkg_free(uri);
|
|
goto error;
|
|
goto error;
|
|
- }
|
|
|
|
|
|
+ }
|
|
to_uri.len= strlen(to_uri.s);
|
|
to_uri.len= strlen(to_uri.s);
|
|
pkg_free(uri);
|
|
pkg_free(uri);
|
|
|
|
|
|
if (pto->tag_value.s==NULL || pto->tag_value.len==0 )
|
|
if (pto->tag_value.s==NULL || pto->tag_value.len==0 )
|
|
- {
|
|
|
|
|
|
+ {
|
|
LM_ERR("to tag value not parsed\n");
|
|
LM_ERR("to tag value not parsed\n");
|
|
goto error;
|
|
goto error;
|
|
}
|
|
}
|
|
@@ -138,7 +138,7 @@ int Notify2Xmpp(struct sip_msg* msg, char* s1, char* s2)
|
|
{
|
|
{
|
|
LM_ERR("'From' header not parsed\n");
|
|
LM_ERR("'From' header not parsed\n");
|
|
/* parsing from header */
|
|
/* parsing from header */
|
|
- if ( parse_from_header( msg )<0 )
|
|
|
|
|
|
+ if ( parse_from_header( msg )<0 )
|
|
{
|
|
{
|
|
LM_ERR("ERROR cannot parse From header\n");
|
|
LM_ERR("ERROR cannot parse From header\n");
|
|
goto error;
|
|
goto error;
|
|
@@ -146,7 +146,7 @@ int Notify2Xmpp(struct sip_msg* msg, char* s1, char* s2)
|
|
}
|
|
}
|
|
pfrom = (struct to_body*)msg->from->parsed;
|
|
pfrom = (struct to_body*)msg->from->parsed;
|
|
dialog.pres_uri= &pfrom->uri;
|
|
dialog.pres_uri= &pfrom->uri;
|
|
-
|
|
|
|
|
|
+
|
|
uri=(char*)pkg_malloc(sizeof(char)*( pfrom->uri.len+1));
|
|
uri=(char*)pkg_malloc(sizeof(char)*( pfrom->uri.len+1));
|
|
if(uri== NULL)
|
|
if(uri== NULL)
|
|
{
|
|
{
|
|
@@ -155,17 +155,17 @@ int Notify2Xmpp(struct sip_msg* msg, char* s1, char* s2)
|
|
}
|
|
}
|
|
memcpy(uri, pfrom->uri.s, pfrom->uri.len);
|
|
memcpy(uri, pfrom->uri.s, pfrom->uri.len);
|
|
uri[pfrom->uri.len]= '\0';
|
|
uri[pfrom->uri.len]= '\0';
|
|
-
|
|
|
|
|
|
+
|
|
from_uri.s= euri_sip_xmpp(uri);
|
|
from_uri.s= euri_sip_xmpp(uri);
|
|
if(from_uri.s== NULL)
|
|
if(from_uri.s== NULL)
|
|
{
|
|
{
|
|
LM_ERR("while encoding sip uri in xmpp\n");
|
|
LM_ERR("while encoding sip uri in xmpp\n");
|
|
pkg_free(uri);
|
|
pkg_free(uri);
|
|
goto error;
|
|
goto error;
|
|
- }
|
|
|
|
|
|
+ }
|
|
from_uri.len= strlen(from_uri.s);
|
|
from_uri.len= strlen(from_uri.s);
|
|
pkg_free(uri);
|
|
pkg_free(uri);
|
|
-
|
|
|
|
|
|
+
|
|
if( pfrom->tag_value.s ==NULL || pfrom->tag_value.len == 0)
|
|
if( pfrom->tag_value.s ==NULL || pfrom->tag_value.len == 0)
|
|
{
|
|
{
|
|
LM_ERR("no from tag value present\n");
|
|
LM_ERR("no from tag value present\n");
|
|
@@ -174,20 +174,20 @@ int Notify2Xmpp(struct sip_msg* msg, char* s1, char* s2)
|
|
|
|
|
|
dialog.to_tag= pfrom->tag_value;
|
|
dialog.to_tag= pfrom->tag_value;
|
|
dialog.flag|= XMPP_SUBSCRIBE;
|
|
dialog.flag|= XMPP_SUBSCRIBE;
|
|
- if(msg->event->body.len== 8 &&
|
|
|
|
|
|
+ if(msg->event->body.len== 8 &&
|
|
(strncmp(msg->event->body.s,"presence",8 )==0))
|
|
(strncmp(msg->event->body.s,"presence",8 )==0))
|
|
event_flag|= PRESENCE_EVENT;
|
|
event_flag|= PRESENCE_EVENT;
|
|
else
|
|
else
|
|
- if(msg->event->body.len== 14 &&
|
|
|
|
- (strncmp(msg->event->body.s,"presence.winfo",14 )==0))
|
|
|
|
- event_flag|= PWINFO_EVENT;
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- LM_ERR("wrong event\n");
|
|
|
|
- goto error;
|
|
|
|
- }
|
|
|
|
|
|
+ if(msg->event->body.len== 14 &&
|
|
|
|
+ (strncmp(msg->event->body.s,"presence.winfo",14 )==0))
|
|
|
|
+ event_flag|= PWINFO_EVENT;
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ LM_ERR("wrong event\n");
|
|
|
|
+ goto error;
|
|
|
|
+ }
|
|
dialog.event= event_flag;
|
|
dialog.event= event_flag;
|
|
-
|
|
|
|
|
|
+
|
|
if(pua_is_dialog(&dialog)< 0) // verify if within a stored dialog
|
|
if(pua_is_dialog(&dialog)< 0) // verify if within a stored dialog
|
|
{
|
|
{
|
|
LM_ERR("Notify in a non existing dialog\n");
|
|
LM_ERR("Notify in a non existing dialog\n");
|
|
@@ -198,11 +198,11 @@ int Notify2Xmpp(struct sip_msg* msg, char* s1, char* s2)
|
|
{
|
|
{
|
|
body.s= NULL;
|
|
body.s= NULL;
|
|
body.len= 0;
|
|
body.len= 0;
|
|
- }
|
|
|
|
|
|
+ }
|
|
else
|
|
else
|
|
{
|
|
{
|
|
body.s=get_body(msg);
|
|
body.s=get_body(msg);
|
|
- if (body.s== NULL)
|
|
|
|
|
|
+ if (body.s== NULL)
|
|
{
|
|
{
|
|
LM_ERR("cannot extract body from msg\n");
|
|
LM_ERR("cannot extract body from msg\n");
|
|
goto error;
|
|
goto error;
|
|
@@ -210,9 +210,9 @@ int Notify2Xmpp(struct sip_msg* msg, char* s1, char* s2)
|
|
body.len = get_content_length( msg );
|
|
body.len = get_content_length( msg );
|
|
}
|
|
}
|
|
|
|
|
|
- /* treat the two cases: event= presence & event=presence.winfo */
|
|
|
|
|
|
+ /* treat the two cases: event= presence & event=presence.winfo */
|
|
if(event_flag & PRESENCE_EVENT)
|
|
if(event_flag & PRESENCE_EVENT)
|
|
- {
|
|
|
|
|
|
+ {
|
|
LM_DBG("PRESENCE\n");
|
|
LM_DBG("PRESENCE\n");
|
|
hdr = msg->headers;
|
|
hdr = msg->headers;
|
|
while (hdr!= NULL)
|
|
while (hdr!= NULL)
|
|
@@ -227,21 +227,21 @@ int Notify2Xmpp(struct sip_msg* msg, char* s1, char* s2)
|
|
if(strncmp(hdr->body.s+11,"reason=timeout", 14)== 0)
|
|
if(strncmp(hdr->body.s+11,"reason=timeout", 14)== 0)
|
|
{
|
|
{
|
|
LM_DBG("Received Notification with state"
|
|
LM_DBG("Received Notification with state"
|
|
- "terminated; reason= timeout=> don't send notification\n");
|
|
|
|
|
|
+ "terminated; reason= timeout=> don't send notification\n");
|
|
return 1;
|
|
return 1;
|
|
- }
|
|
|
|
|
|
+ }
|
|
is_terminated= 1;
|
|
is_terminated= 1;
|
|
|
|
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
if(build_xmpp_content(&to_uri, &from_uri, &body, &id, is_terminated)< 0)
|
|
if(build_xmpp_content(&to_uri, &from_uri, &body, &id, is_terminated)< 0)
|
|
{
|
|
{
|
|
- LM_ERR("in function build_xmpp_content\n");
|
|
|
|
|
|
+ LM_ERR("in function build_xmpp_content\n");
|
|
goto error;
|
|
goto error;
|
|
}
|
|
}
|
|
- }
|
|
|
|
|
|
+ }
|
|
else
|
|
else
|
|
- {
|
|
|
|
|
|
+ {
|
|
if(event_flag & PWINFO_EVENT)
|
|
if(event_flag & PWINFO_EVENT)
|
|
{
|
|
{
|
|
LM_DBG("PRESENCE.WINFO\n");
|
|
LM_DBG("PRESENCE.WINFO\n");
|
|
@@ -254,8 +254,8 @@ int Notify2Xmpp(struct sip_msg* msg, char* s1, char* s2)
|
|
}
|
|
}
|
|
if(hdr && strncmp(hdr->body.s,"terminated", 10)== 0)
|
|
if(hdr && strncmp(hdr->body.s,"terminated", 10)== 0)
|
|
{
|
|
{
|
|
- LM_DBG("Notify for presence.winfo with"
|
|
|
|
- " Subscription-State terminated- should not translate\n");
|
|
|
|
|
|
+ LM_DBG("Notify for presence.winfo with"
|
|
|
|
+ " Subscription-State terminated- should not translate\n");
|
|
goto error;
|
|
goto error;
|
|
}
|
|
}
|
|
if(winfo2xmpp(&to_uri, &body, &id)< 0)
|
|
if(winfo2xmpp(&to_uri, &body, &id)< 0)
|
|
@@ -324,7 +324,7 @@ int build_xmpp_content(str* to_uri, str* from_uri, str* body, str* id,
|
|
goto error;
|
|
goto error;
|
|
}
|
|
}
|
|
if(is_terminated)
|
|
if(is_terminated)
|
|
- {
|
|
|
|
|
|
+ {
|
|
attr= xmlNewProp(xmpp_root, BAD_CAST "type", BAD_CAST "unsubscribed");
|
|
attr= xmlNewProp(xmpp_root, BAD_CAST "type", BAD_CAST "unsubscribed");
|
|
if(attr== NULL)
|
|
if(attr== NULL)
|
|
{
|
|
{
|
|
@@ -357,7 +357,7 @@ int build_xmpp_content(str* to_uri, str* from_uri, str* body, str* id,
|
|
LM_ERR("while extracting 'presence' node\n");
|
|
LM_ERR("while extracting 'presence' node\n");
|
|
goto error;
|
|
goto error;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
node = XMLNodeGetNodeByName(sip_root, "basic", NULL);
|
|
node = XMLNodeGetNodeByName(sip_root, "basic", NULL);
|
|
if(node== NULL)
|
|
if(node== NULL)
|
|
{
|
|
{
|
|
@@ -397,11 +397,11 @@ int build_xmpp_content(str* to_uri, str* from_uri, str* body, str* id,
|
|
}
|
|
}
|
|
node= XMLNodeGetNodeByName(node, "note", NULL);
|
|
node= XMLNodeGetNodeByName(node, "note", NULL);
|
|
if(node== NULL)
|
|
if(node== NULL)
|
|
- {
|
|
|
|
|
|
+ {
|
|
LM_DBG("Person node has no note node\n");
|
|
LM_DBG("Person node has no note node\n");
|
|
goto done;
|
|
goto done;
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ }
|
|
|
|
+ }
|
|
note= (char*)xmlNodeGetContent(node);
|
|
note= (char*)xmlNodeGetContent(node);
|
|
if(note== NULL)
|
|
if(note== NULL)
|
|
{
|
|
{
|
|
@@ -418,7 +418,7 @@ int build_xmpp_content(str* to_uri, str* from_uri, str* body, str* id,
|
|
{
|
|
{
|
|
LM_ERR("while adding node show: away\n");
|
|
LM_ERR("while adding node show: away\n");
|
|
goto error;
|
|
goto error;
|
|
- }
|
|
|
|
|
|
+ }
|
|
}
|
|
}
|
|
else
|
|
else
|
|
if(xmlStrcasecmp((unsigned char*)note, (unsigned char*)"busy")== 0)
|
|
if(xmlStrcasecmp((unsigned char*)note, (unsigned char*)"busy")== 0)
|
|
@@ -429,57 +429,36 @@ int build_xmpp_content(str* to_uri, str* from_uri, str* body, str* id,
|
|
{
|
|
{
|
|
LM_ERR("while adding node show: away\n");
|
|
LM_ERR("while adding node show: away\n");
|
|
goto error;
|
|
goto error;
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /*
|
|
|
|
- if(xmlStrcasecmp((unsigned char*)note, (unsigned char*)"on the phone")== 0)
|
|
|
|
- {
|
|
|
|
- new_node = xmlNewChild(xmpp_root, NULL, BAD_CAST "show", BAD_CAST "chat");
|
|
|
|
- if(new_node== NULL)
|
|
|
|
- {
|
|
|
|
- LM_ERR("while adding node show: chat\n");
|
|
|
|
- goto error;
|
|
|
|
- }
|
|
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- else
|
|
|
|
- if(xmlStrcasecmp((unsigned char*)note, (unsigned char*)"idle")== 0)
|
|
|
|
|
|
+ else
|
|
|
|
+ if((xmlStrcasecmp((unsigned char*)note,
|
|
|
|
+ (unsigned char*)"dnd")== 0)||
|
|
|
|
+ (xmlStrcasecmp((unsigned char*)note,
|
|
|
|
+ (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 "idle");
|
|
|
|
|
|
+ new_node = xmlNewChild(xmpp_root, NULL, BAD_CAST "show",
|
|
|
|
+ BAD_CAST "dnd");
|
|
if(new_node== NULL)
|
|
if(new_node== NULL)
|
|
{
|
|
{
|
|
- LM_ERR("while adding node: idle\n");
|
|
|
|
|
|
+ LM_ERR("while adding node show: dnd\n");
|
|
goto error;
|
|
goto error;
|
|
- }
|
|
|
|
- }*/
|
|
|
|
- else
|
|
|
|
- if((xmlStrcasecmp((unsigned char*)note,
|
|
|
|
- (unsigned char*)"dnd")== 0)||
|
|
|
|
- (xmlStrcasecmp((unsigned char*)note,
|
|
|
|
- (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");
|
|
|
|
- if(new_node== NULL)
|
|
|
|
- {
|
|
|
|
- LM_ERR("while adding node show: dnd\n");
|
|
|
|
- goto error;
|
|
|
|
- }
|
|
|
|
}
|
|
}
|
|
- else
|
|
|
|
- LM_DBG("Not Found Status\n");
|
|
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ LM_DBG("Not Found Status\n");
|
|
|
|
+
|
|
|
|
|
|
-
|
|
|
|
/* adding status node */
|
|
/* adding status node */
|
|
new_node = xmlNewChild(xmpp_root, NULL, BAD_CAST "status", BAD_CAST note);
|
|
new_node = xmlNewChild(xmpp_root, NULL, BAD_CAST "status", BAD_CAST note);
|
|
if(new_node== NULL)
|
|
if(new_node== NULL)
|
|
{
|
|
{
|
|
LM_ERR("while adding node status\n");
|
|
LM_ERR("while adding node status\n");
|
|
goto error;
|
|
goto error;
|
|
- }
|
|
|
|
-
|
|
|
|
|
|
+ }
|
|
|
|
+
|
|
xmlFree(note);
|
|
xmlFree(note);
|
|
note= NULL;
|
|
note= NULL;
|
|
|
|
|
|
@@ -515,7 +494,7 @@ done:
|
|
LM_ERR("while adding creating new buffer\n");
|
|
LM_ERR("while adding creating new buffer\n");
|
|
goto error;
|
|
goto error;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
xmpp_msg.len= xmlNodeDump(buffer, doc, xmpp_root, 1,1);
|
|
xmpp_msg.len= xmlNodeDump(buffer, doc, xmpp_root, 1,1);
|
|
if(xmpp_msg.len== -1)
|
|
if(xmpp_msg.len== -1)
|
|
{
|
|
{
|
|
@@ -528,7 +507,7 @@ done:
|
|
LM_ERR("while extracting buffer content\n");
|
|
LM_ERR("while extracting buffer content\n");
|
|
goto error;
|
|
goto error;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
LM_DBG("xmpp_msg: %.*s\n",xmpp_msg.len, xmpp_msg.s);
|
|
LM_DBG("xmpp_msg: %.*s\n",xmpp_msg.len, xmpp_msg.s);
|
|
if( xmpp_notify(from_uri, to_uri, &xmpp_msg, id)< 0)
|
|
if( xmpp_notify(from_uri, to_uri, &xmpp_msg, id)< 0)
|
|
{
|
|
{
|
|
@@ -587,15 +566,15 @@ int winfo2xmpp(str* to_uri, str* body, str* id)
|
|
LM_ERR("while extracting 'presence' node\n");
|
|
LM_ERR("while extracting 'presence' node\n");
|
|
goto error;
|
|
goto error;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
node = XMLNodeGetNodeByName(pidf_root, "watcher", NULL);
|
|
node = XMLNodeGetNodeByName(pidf_root, "watcher", NULL);
|
|
|
|
|
|
for (; node!=NULL; node = node->next)
|
|
for (; node!=NULL; node = node->next)
|
|
- {
|
|
|
|
|
|
+ {
|
|
if( xmlStrcasecmp(node->name,(unsigned char*)"watcher"))
|
|
if( xmlStrcasecmp(node->name,(unsigned char*)"watcher"))
|
|
continue;
|
|
continue;
|
|
|
|
|
|
- watcher= (char*)xmlNodeGetContent(node->children);
|
|
|
|
|
|
+ watcher= (char*)xmlNodeGetContent(node->children);
|
|
if(watcher== NULL)
|
|
if(watcher== NULL)
|
|
{
|
|
{
|
|
LM_ERR("while extracting watcher node content\n");
|
|
LM_ERR("while extracting watcher node content\n");
|
|
@@ -606,7 +585,7 @@ int winfo2xmpp(str* to_uri, str* body, str* id)
|
|
{
|
|
{
|
|
LM_ERR("while encoding sip uri in xmpp\n");
|
|
LM_ERR("while encoding sip uri in xmpp\n");
|
|
goto error;
|
|
goto error;
|
|
- }
|
|
|
|
|
|
+ }
|
|
from_uri.len= strlen(from_uri.s);
|
|
from_uri.len= strlen(from_uri.s);
|
|
xmlFree(watcher);
|
|
xmlFree(watcher);
|
|
watcher= NULL;
|
|
watcher= NULL;
|
|
@@ -649,7 +628,7 @@ int winfo2xmpp(str* to_uri, str* body, str* id)
|
|
LM_ERR("while adding creating new buffer\n");
|
|
LM_ERR("while adding creating new buffer\n");
|
|
goto error;
|
|
goto error;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
xmpp_msg.len= xmlNodeDump(buffer, doc, root_node, 1,1);
|
|
xmpp_msg.len= xmlNodeDump(buffer, doc, root_node, 1,1);
|
|
if(xmpp_msg.len== -1)
|
|
if(xmpp_msg.len== -1)
|
|
{
|
|
{
|
|
@@ -662,9 +641,9 @@ int winfo2xmpp(str* to_uri, str* body, str* id)
|
|
LM_ERR("while extracting buffer content\n");
|
|
LM_ERR("while extracting buffer content\n");
|
|
goto error;
|
|
goto error;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
LM_DBG("xmpp_msg: %.*s\n",xmpp_msg.len, xmpp_msg.s);
|
|
LM_DBG("xmpp_msg: %.*s\n",xmpp_msg.len, xmpp_msg.s);
|
|
-
|
|
|
|
|
|
+
|
|
if( xmpp_subscribe(&from_uri, to_uri, &xmpp_msg, id)< 0)
|
|
if( xmpp_subscribe(&from_uri, to_uri, &xmpp_msg, id)< 0)
|
|
{
|
|
{
|
|
LM_ERR("while sending xmpp_subscribe\n");
|
|
LM_ERR("while sending xmpp_subscribe\n");
|
|
@@ -708,7 +687,7 @@ char* get_error_reason(int code, str* reason)
|
|
LM_ERR("no more memory\n");
|
|
LM_ERR("no more memory\n");
|
|
return NULL;
|
|
return NULL;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
switch( code )
|
|
switch( code )
|
|
{
|
|
{
|
|
case 300: { strcpy(err_cond, "redirect"); break;}
|
|
case 300: { strcpy(err_cond, "redirect"); break;}
|
|
@@ -756,10 +735,10 @@ char* get_error_reason(int code, str* reason)
|
|
}
|
|
}
|
|
|
|
|
|
return err_cond;
|
|
return err_cond;
|
|
-}
|
|
|
|
|
|
+}
|
|
|
|
|
|
|
|
|
|
-int Sipreply2Xmpp(ua_pres_t* hentity, struct sip_msg * msg)
|
|
|
|
|
|
+int Sipreply2Xmpp(ua_pres_t* hentity, struct sip_msg * msg)
|
|
{
|
|
{
|
|
char* uri;
|
|
char* uri;
|
|
/* named according to the direction of the message in xmpp*/
|
|
/* named according to the direction of the message in xmpp*/
|
|
@@ -773,7 +752,7 @@ int Sipreply2Xmpp(ua_pres_t* hentity, struct sip_msg * msg)
|
|
str reason;
|
|
str reason;
|
|
char* err_reason= NULL;
|
|
char* err_reason= NULL;
|
|
xmlBufferPtr buffer= NULL;
|
|
xmlBufferPtr buffer= NULL;
|
|
-
|
|
|
|
|
|
+
|
|
LM_DBG("start..\n");
|
|
LM_DBG("start..\n");
|
|
uri=(char*)pkg_malloc(sizeof(char)*( hentity->watcher_uri->len+1));
|
|
uri=(char*)pkg_malloc(sizeof(char)*( hentity->watcher_uri->len+1));
|
|
if(uri== NULL)
|
|
if(uri== NULL)
|
|
@@ -788,12 +767,12 @@ int Sipreply2Xmpp(ua_pres_t* hentity, struct sip_msg * msg)
|
|
{
|
|
{
|
|
LM_ERR("whil decoding sip uri in xmpp\n");
|
|
LM_ERR("whil decoding sip uri in xmpp\n");
|
|
pkg_free(uri);
|
|
pkg_free(uri);
|
|
- goto error;
|
|
|
|
- }
|
|
|
|
|
|
+ goto error;
|
|
|
|
+ }
|
|
|
|
|
|
to_uri.len= strlen(to_uri.s);
|
|
to_uri.len= strlen(to_uri.s);
|
|
pkg_free(uri);
|
|
pkg_free(uri);
|
|
-
|
|
|
|
|
|
+
|
|
uri=(char*)pkg_malloc(sizeof(char)*( hentity->pres_uri->len+1));
|
|
uri=(char*)pkg_malloc(sizeof(char)*( hentity->pres_uri->len+1));
|
|
if(uri== NULL)
|
|
if(uri== NULL)
|
|
{
|
|
{
|
|
@@ -817,7 +796,7 @@ int Sipreply2Xmpp(ua_pres_t* hentity, struct sip_msg * msg)
|
|
if(doc==0)
|
|
if(doc==0)
|
|
goto error;
|
|
goto error;
|
|
root_node = xmlNewNode(NULL, BAD_CAST "presence");
|
|
root_node = xmlNewNode(NULL, BAD_CAST "presence");
|
|
-
|
|
|
|
|
|
+
|
|
if(root_node==0)
|
|
if(root_node==0)
|
|
goto error;
|
|
goto error;
|
|
xmlDocSetRootElement(doc, root_node);
|
|
xmlDocSetRootElement(doc, root_node);
|
|
@@ -859,7 +838,7 @@ int Sipreply2Xmpp(ua_pres_t* hentity, struct sip_msg * msg)
|
|
LM_ERR("couldn't get response phrase\n");
|
|
LM_ERR("couldn't get response phrase\n");
|
|
goto error;
|
|
goto error;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
attr= xmlNewProp(root_node, BAD_CAST "type", BAD_CAST "error");
|
|
attr= xmlNewProp(root_node, BAD_CAST "type", BAD_CAST "error");
|
|
if(attr== NULL)
|
|
if(attr== NULL)
|
|
{
|
|
{
|
|
@@ -871,15 +850,15 @@ int Sipreply2Xmpp(ua_pres_t* hentity, struct sip_msg * msg)
|
|
{
|
|
{
|
|
LM_ERR("while adding new node\n");
|
|
LM_ERR("while adding new node\n");
|
|
goto error;
|
|
goto error;
|
|
- }
|
|
|
|
|
|
+ }
|
|
node= xmlNewChild(node, 0, BAD_CAST err_reason, 0 );
|
|
node= xmlNewChild(node, 0, BAD_CAST err_reason, 0 );
|
|
if(node== NULL)
|
|
if(node== NULL)
|
|
{
|
|
{
|
|
LM_ERR("while adding new node\n");
|
|
LM_ERR("while adding new node\n");
|
|
goto error;
|
|
goto error;
|
|
- }
|
|
|
|
|
|
+ }
|
|
|
|
|
|
- attr= xmlNewProp(node, BAD_CAST "xmlns",
|
|
|
|
|
|
+ attr= xmlNewProp(node, BAD_CAST "xmlns",
|
|
BAD_CAST "urn:ietf:params:xml:ns:xmpp-stanzas");
|
|
BAD_CAST "urn:ietf:params:xml:ns:xmpp-stanzas");
|
|
if(attr== NULL)
|
|
if(attr== NULL)
|
|
{
|
|
{
|
|
@@ -887,8 +866,7 @@ int Sipreply2Xmpp(ua_pres_t* hentity, struct sip_msg * msg)
|
|
goto error;
|
|
goto error;
|
|
}
|
|
}
|
|
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
|
|
+ } else {
|
|
if(code>=200 )
|
|
if(code>=200 )
|
|
{
|
|
{
|
|
LM_DBG(" 2xx code\n");
|
|
LM_DBG(" 2xx code\n");
|
|
@@ -899,30 +877,31 @@ int Sipreply2Xmpp(ua_pres_t* hentity, struct sip_msg * msg)
|
|
goto error;
|
|
goto error;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ buffer= xmlBufferCreate();
|
|
|
|
+ if(buffer== NULL)
|
|
|
|
+ {
|
|
|
|
+ LM_ERR("while adding creating new buffer\n");
|
|
|
|
+ goto error;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ xmpp_msg.len= xmlNodeDump(buffer, doc, root_node, 1,1);
|
|
|
|
+ if(xmpp_msg.len== -1)
|
|
|
|
+ {
|
|
|
|
+ LM_ERR("while dumping node\n");
|
|
|
|
+ goto error;
|
|
|
|
+ }
|
|
|
|
+ xmpp_msg.s= (char*)xmlBufferContent( buffer);
|
|
|
|
+ if(xmpp_msg.s== NULL)
|
|
|
|
+ {
|
|
|
|
+ LM_ERR("while extracting buffer content\n");
|
|
|
|
+ goto error;
|
|
|
|
+ }
|
|
|
|
|
|
- buffer= xmlBufferCreate();
|
|
|
|
- if(buffer== NULL)
|
|
|
|
- {
|
|
|
|
- LM_ERR("while adding creating new buffer\n");
|
|
|
|
- goto error;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- xmpp_msg.len= xmlNodeDump(buffer, doc, root_node, 1,1);
|
|
|
|
- if(xmpp_msg.len== -1)
|
|
|
|
- {
|
|
|
|
- LM_ERR("while dumping node\n");
|
|
|
|
- goto error;
|
|
|
|
- }
|
|
|
|
- xmpp_msg.s= (char*)xmlBufferContent( buffer);
|
|
|
|
- if(xmpp_msg.s== NULL)
|
|
|
|
- {
|
|
|
|
- LM_ERR("while extracting buffer content\n");
|
|
|
|
- goto error;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
|
|
|
|
LM_DBG("xmpp_msg: %.*s\n",xmpp_msg.len, xmpp_msg.s);
|
|
LM_DBG("xmpp_msg: %.*s\n",xmpp_msg.len, xmpp_msg.s);
|
|
-
|
|
|
|
|
|
+
|
|
if(xmpp_packet(&from_uri, &to_uri, &xmpp_msg, &hentity->to_tag)< 0)
|
|
if(xmpp_packet(&from_uri, &to_uri, &xmpp_msg, &hentity->to_tag)< 0)
|
|
{
|
|
{
|
|
LM_ERR("while sending xmpp_reply_to_subscribe\n");
|
|
LM_ERR("while sending xmpp_reply_to_subscribe\n");
|
|
@@ -931,7 +910,7 @@ int Sipreply2Xmpp(ua_pres_t* hentity, struct sip_msg * msg)
|
|
if(err_reason)
|
|
if(err_reason)
|
|
pkg_free(err_reason);
|
|
pkg_free(err_reason);
|
|
xmlFreeDoc(doc);
|
|
xmlFreeDoc(doc);
|
|
-
|
|
|
|
|
|
+
|
|
return 0;
|
|
return 0;
|
|
|
|
|
|
error:
|
|
error:
|