diff --git a/coreapi/bellesip_sal/sal_op_presence.c b/coreapi/bellesip_sal/sal_op_presence.c index 4c65ff3f7..89a6dbbb5 100644 --- a/coreapi/bellesip_sal/sal_op_presence.c +++ b/coreapi/bellesip_sal/sal_op_presence.c @@ -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)));