From bf492b4278d1c68b2da55c65da173a33aec32ea1 Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Wed, 17 Apr 2013 15:49:34 +0200 Subject: [PATCH] fix publish request, whose request uri must identify the resources for which the event is to be published. --- coreapi/sal_eXosip2.c | 8 ++++---- coreapi/sal_eXosip2.h | 2 ++ coreapi/sal_eXosip2_presence.c | 11 +++++++---- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/coreapi/sal_eXosip2.c b/coreapi/sal_eXosip2.c index 75ee4629..e577b642 100644 --- a/coreapi/sal_eXosip2.c +++ b/coreapi/sal_eXosip2.c @@ -2317,7 +2317,7 @@ static void register_set_contact(osip_message_t *msg, const char *contact){ osip_uri_uparam_add(ct->url,osip_strdup("line"),line); } -static void sal_register_add_route(osip_message_t *msg, const char *proxy){ +void sal_message_add_route(osip_message_t *msg, const char *proxy){ osip_route_t *route; osip_list_special_free(&msg->routes,(void (*)(void*))osip_route_free); @@ -2364,7 +2364,7 @@ int sal_register(SalOp *h, const char *proxy, const char *from, int expires){ h->rid=eXosip_register_build_initial_register(from,domain,NULL,expires,&msg); if (msg){ if (contact) register_set_contact(msg,contact); - sal_register_add_route(msg,proxy); + sal_message_add_route(msg,proxy); sal_add_register(h->base.root,h); }else{ ms_error("Could not build initial register."); @@ -2374,7 +2374,7 @@ int sal_register(SalOp *h, const char *proxy, const char *from, int expires){ }else{ eXosip_lock(); eXosip_register_build_register(h->rid,expires,&msg); - sal_register_add_route(msg,proxy); + sal_message_add_route(msg,proxy); } if (msg){ eXosip_register_send_register(h->rid,msg); @@ -2412,7 +2412,7 @@ int sal_register_refresh(SalOp *op, int expires){ eXosip_register_build_register(op->rid,expires,&msg); if (msg!=NULL){ if (contact) register_set_contact(msg,contact); - sal_register_add_route(msg,sal_op_get_route(op)); + sal_message_add_route(msg,sal_op_get_route(op)); eXosip_register_send_register(op->rid,msg); }else ms_error("Could not build REGISTER refresh message."); eXosip_unlock(); diff --git a/coreapi/sal_eXosip2.h b/coreapi/sal_eXosip2.h index 68a2d05e..e00dd64d 100644 --- a/coreapi/sal_eXosip2.h +++ b/coreapi/sal_eXosip2.h @@ -99,4 +99,6 @@ SalCustomHeader * sal_exosip_get_custom_headers(osip_message_t *msg); void _osip_list_set_empty(osip_list_t *l, void (*freefunc)(void*)); +void sal_message_add_route(osip_message_t *msg, const char *proxy); + #endif diff --git a/coreapi/sal_eXosip2_presence.c b/coreapi/sal_eXosip2_presence.c index 1b64fe42..c8191098 100644 --- a/coreapi/sal_eXosip2_presence.c +++ b/coreapi/sal_eXosip2_presence.c @@ -637,23 +637,26 @@ int sal_publish(SalOp *op, const char *from, const char *to, SalPresenceStatus p osip_message_t *pub; int i; char buf[1024]; + const char *route=sal_op_get_route(op); mk_presence_body (presence_mode, from, buf, sizeof (buf), presence_style); - i = eXosip_build_publish(&pub,from, to, sal_op_get_route(op), "presence", "300", + i = eXosip_build_publish(&pub,to, from, NULL, "presence", "600", presence_style ? "application/xpidf+xml" : "application/pidf+xml", buf); if (i<0){ ms_warning("Failed to build publish request."); return -1; } - + if (route) + sal_message_add_route(pub,route); + eXosip_lock(); i = eXosip_publish(pub, to); /* should update the sip-if-match parameter from sip-etag from last 200ok of PUBLISH */ eXosip_unlock(); if (i<0){ - ms_message("Failed to send publish request."); - return -1; + ms_message("Failed to send publish request."); + return -1; } sal_add_other(sal_op_get_sal(op),op,pub); return 0; -- 2.39.2