make sure dialog is in the right state before notifying

This commit is contained in:
Jehan Monnier 2013-07-09 16:07:06 +02:00
parent 2ecb66aa42
commit 2f3f665343

View file

@ -292,7 +292,13 @@ static belle_sip_request_t *create_presence_notify(SalOp *op){
}
int sal_notify_presence(SalOp *op, SalPresenceModel *presence){
belle_sip_request_t* notify=create_presence_notify(op);
belle_sip_dialog_state_t state=op->dialog?belle_sip_dialog_get_state(op->dialog): BELLE_SIP_DIALOG_NULL;
belle_sip_request_t* notify=NULL;
if (state != BELLE_SIP_DIALOG_CONFIRMED) {
ms_warning("Cannot notify presence because dialog in state [%s]",belle_sip_dialog_state_to_string(state));
return -1;
}
notify=create_presence_notify(op);
sal_add_presence_info(op,BELLE_SIP_MESSAGE(notify),presence); /*FIXME, what about expires ??*/
belle_sip_message_add_header(BELLE_SIP_MESSAGE(notify)
,BELLE_SIP_HEADER(belle_sip_header_subscription_state_create(BELLE_SIP_SUBSCRIPTION_STATE_ACTIVE,600)));