forked from mirrors/linphone-iphone
do not send body in PUBLISH with expires 0
do not send body in SUBSCRIBE for presence with expires 0
This commit is contained in:
parent
21f419d2ee
commit
732787687a
2 changed files with 23 additions and 14 deletions
|
|
@ -24,24 +24,28 @@ void sal_add_presence_info(SalOp *op, belle_sip_message_t *notify, SalPresenceMo
|
|||
char *content = NULL;
|
||||
size_t content_length;
|
||||
|
||||
belle_sip_header_from_t *from=belle_sip_message_get_header_by_type(notify,belle_sip_header_from_t);
|
||||
|
||||
contact_info=belle_sip_uri_to_string(belle_sip_header_address_get_uri(BELLE_SIP_HEADER_ADDRESS(from)));
|
||||
op->base.root->callbacks.convert_presence_to_xml_requested(op, presence, contact_info, &content);
|
||||
if (content == NULL) {
|
||||
if (presence){
|
||||
belle_sip_header_from_t *from=belle_sip_message_get_header_by_type(notify,belle_sip_header_from_t);
|
||||
contact_info=belle_sip_uri_to_string(belle_sip_header_address_get_uri(BELLE_SIP_HEADER_ADDRESS(from)));
|
||||
op->base.root->callbacks.convert_presence_to_xml_requested(op, presence, contact_info, &content);
|
||||
ms_free(contact_info);
|
||||
return;
|
||||
if (content == NULL) return;
|
||||
}
|
||||
|
||||
belle_sip_message_remove_header(BELLE_SIP_MESSAGE(notify),BELLE_SIP_CONTENT_TYPE);
|
||||
belle_sip_message_add_header(BELLE_SIP_MESSAGE(notify)
|
||||
,BELLE_SIP_HEADER(belle_sip_header_content_type_create("application","pidf+xml")));
|
||||
belle_sip_message_remove_header(BELLE_SIP_MESSAGE(notify),BELLE_SIP_CONTENT_LENGTH);
|
||||
belle_sip_message_add_header(BELLE_SIP_MESSAGE(notify)
|
||||
belle_sip_message_set_body(BELLE_SIP_MESSAGE(notify),NULL,0);
|
||||
|
||||
if (content){
|
||||
belle_sip_message_add_header(BELLE_SIP_MESSAGE(notify)
|
||||
,BELLE_SIP_HEADER(belle_sip_header_content_type_create("application","pidf+xml")));
|
||||
belle_sip_message_add_header(BELLE_SIP_MESSAGE(notify)
|
||||
,BELLE_SIP_HEADER(belle_sip_header_content_length_create(content_length=strlen(content))));
|
||||
belle_sip_message_set_body(BELLE_SIP_MESSAGE(notify),content,content_length);
|
||||
ms_free(contact_info);
|
||||
ms_free(content);
|
||||
belle_sip_message_set_body(BELLE_SIP_MESSAGE(notify),content,content_length);
|
||||
ms_free(content);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
static void presence_process_io_error(void *user_ctx, const belle_sip_io_error_event_t *event){
|
||||
|
|
|
|||
|
|
@ -56,6 +56,11 @@ void sal_op_publish_fill_cbs(SalOp*op) {
|
|||
op->type=SalOpPublish;
|
||||
}
|
||||
|
||||
/*
|
||||
* Sending a publish with 0 expires removes the event state and such request shall not contain a body.
|
||||
* See RFC3903, section 4.5
|
||||
*/
|
||||
|
||||
/*presence publish */
|
||||
int sal_publish_presence(SalOp *op, const char *from, const char *to, int expires, SalPresenceModel *presence){
|
||||
belle_sip_request_t *req=NULL;
|
||||
|
|
@ -77,7 +82,7 @@ int sal_publish_presence(SalOp *op, const char *from, const char *to, int expire
|
|||
/*update presence status*/
|
||||
const belle_sip_client_transaction_t* last_publish_trans=belle_sip_refresher_get_transaction(op->refresher);
|
||||
belle_sip_request_t* last_publish=belle_sip_transaction_get_request(BELLE_SIP_TRANSACTION(last_publish_trans));
|
||||
sal_add_presence_info(op,BELLE_SIP_MESSAGE(last_publish),presence);
|
||||
sal_add_presence_info(op,BELLE_SIP_MESSAGE(last_publish),expires!=0 ? presence : NULL);
|
||||
return belle_sip_refresher_refresh(op->refresher,expires);
|
||||
}
|
||||
}
|
||||
|
|
@ -103,7 +108,7 @@ int sal_publish(SalOp *op, const char *from, const char *to, const char *eventna
|
|||
const belle_sip_client_transaction_t* last_publish_trans=belle_sip_refresher_get_transaction(op->refresher);
|
||||
belle_sip_request_t* last_publish=belle_sip_transaction_get_request(BELLE_SIP_TRANSACTION(last_publish_trans));
|
||||
/*update body*/
|
||||
sal_op_add_body(op,BELLE_SIP_MESSAGE(last_publish),body);
|
||||
sal_op_add_body(op,BELLE_SIP_MESSAGE(last_publish),expires!=0 ? body : NULL);
|
||||
return belle_sip_refresher_refresh(op->refresher,expires==-1 ? BELLE_SIP_REFRESHER_REUSE_EXPIRES : expires);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue