Commit 9b846f0e authored by jehan's avatar jehan
Browse files

better support of publish

parent 06a9ea3c
......@@ -392,9 +392,10 @@ void sal_add_presence_info(belle_sip_message_t *notify, SalPresenceStatus online
mk_presence_body (online_status, contact_info, buf, sizeof (buf), presence_style);
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",presence_style?"xpidf+xml":"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_HEADER(belle_sip_header_content_length_create(content_length=strlen(buf))));
belle_sip_message_set_body(BELLE_SIP_MESSAGE(notify),buf,content_length);
......
......@@ -32,15 +32,24 @@ static void publish_refresher_listener ( const belle_sip_refresher_t* refresher
/*presence publish */
int sal_publish(SalOp *op, const char *from, const char *to, SalPresenceStatus status){
belle_sip_request_t *req=NULL;
if (from)
sal_op_set_from(op,from);
if (to)
sal_op_set_to(op,to);
op->type=SalOpPublish;
req=sal_op_build_request(op,"PUBLISH");
sal_add_presence_info(BELLE_SIP_MESSAGE(req),status);
return sal_op_send_and_create_refresher(op,req,600,publish_refresher_listener);
if(!op->refresher || !belle_sip_refresher_get_transaction(op->refresher)) {
if (from)
sal_op_set_from(op,from);
if (to)
sal_op_set_to(op,to);
op->type=SalOpPublish;
req=sal_op_build_request(op,"PUBLISH");
belle_sip_message_add_header(BELLE_SIP_MESSAGE(req),belle_sip_header_create("Event","presence"));
sal_add_presence_info(BELLE_SIP_MESSAGE(req),status);
return sal_op_send_and_create_refresher(op,req,600,publish_refresher_listener);
} else {
/*update 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));
/*update status*/
sal_add_presence_info(BELLE_SIP_MESSAGE(last_publish),status);
return belle_sip_refresher_refresh(op->refresher,BELLE_SIP_REFRESHER_REUSE_EXPIRES);
}
}
......@@ -78,6 +78,11 @@ static void simple_publish(void) {
linphone_core_iterate(marie->lc);
ms_usleep(100000);
}
linphone_core_set_presence_info(marie->lc,0,NULL,LinphoneStatusOffline);
for (i=0;i<10;i++) {
linphone_core_iterate(marie->lc);
ms_usleep(100000);
}
linphone_core_manager_destroy(marie);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment