From 2f3f66534375c40d2170286e059c5cd47b931107 Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Tue, 9 Jul 2013 16:07:06 +0200 Subject: [PATCH] make sure dialog is in the right state before notifying --- coreapi/bellesip_sal/sal_op_presence.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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)));