mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-28 08:39:20 +00:00
fix various crash due to // transaction
This commit is contained in:
parent
2f3f665343
commit
3fda5955fd
3 changed files with 29 additions and 6 deletions
|
|
@ -293,7 +293,8 @@ int sal_notify(SalOp *op, const SalBody *body){
|
|||
|
||||
if (!op->dialog) return -1;
|
||||
|
||||
notify=belle_sip_dialog_create_request(op->dialog,"NOTIFY");
|
||||
if (!(notify=belle_sip_dialog_create_request(op->dialog,"NOTIFY"))) return -1;
|
||||
|
||||
if (set_event_name(op,(belle_sip_message_t*)notify)==-1){
|
||||
belle_sip_object_unref(notify);
|
||||
return -1;
|
||||
|
|
@ -309,7 +310,7 @@ int sal_notify(SalOp *op, const SalBody *body){
|
|||
int sal_notify_close(SalOp *op){
|
||||
belle_sip_request_t* notify;
|
||||
if (!op->dialog) return -1;
|
||||
notify=belle_sip_dialog_create_request(op->dialog,"NOTIFY");
|
||||
if (!(notify=belle_sip_dialog_create_request(op->dialog,"NOTIFY"))) return -1;
|
||||
set_event_name(op,(belle_sip_message_t*)notify);
|
||||
belle_sip_message_add_header(BELLE_SIP_MESSAGE(notify)
|
||||
,BELLE_SIP_HEADER(belle_sip_header_subscription_state_create(BELLE_SIP_SUBSCRIPTION_STATE_TERMINATED,-1)));
|
||||
|
|
|
|||
|
|
@ -287,18 +287,29 @@ int sal_subscribe_presence(SalOp *op, const char *from, const char *to, int expi
|
|||
|
||||
static belle_sip_request_t *create_presence_notify(SalOp *op){
|
||||
belle_sip_request_t* notify=belle_sip_dialog_create_request(op->dialog,"NOTIFY");
|
||||
if (!notify) return NULL;
|
||||
|
||||
belle_sip_message_add_header((belle_sip_message_t*)notify,belle_sip_header_create("Event","presence"));
|
||||
return notify;
|
||||
}
|
||||
|
||||
int sal_notify_presence(SalOp *op, SalPresenceModel *presence){
|
||||
static int sal_op_check_dialog_state(SalOp *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));
|
||||
ms_warning("Cannot notify presence for op [%p] because dialog in state [%s]",op, belle_sip_dialog_state_to_string(state));
|
||||
return -1;
|
||||
} else
|
||||
return 0;
|
||||
|
||||
}
|
||||
int sal_notify_presence(SalOp *op, SalPresenceModel *presence){
|
||||
belle_sip_request_t* notify=NULL;
|
||||
if (sal_op_check_dialog_state(op)) {
|
||||
return -1;
|
||||
}
|
||||
notify=create_presence_notify(op);
|
||||
if (!notify) return-1;
|
||||
|
||||
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)));
|
||||
|
|
@ -306,7 +317,13 @@ int sal_notify_presence(SalOp *op, SalPresenceModel *presence){
|
|||
}
|
||||
|
||||
int sal_notify_presence_close(SalOp *op){
|
||||
belle_sip_request_t* notify=create_presence_notify(op);
|
||||
belle_sip_request_t* notify=NULL;
|
||||
if (sal_op_check_dialog_state(op)) {
|
||||
return -1;
|
||||
}
|
||||
notify=create_presence_notify(op);
|
||||
if (!notify) return-1;
|
||||
|
||||
sal_add_presence_info(op,BELLE_SIP_MESSAGE(notify),NULL); /*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_TERMINATED,-1)));
|
||||
|
|
|
|||
|
|
@ -30,6 +30,8 @@ static const char *notify_content="<somexml2>blabla</somexml2>";
|
|||
void linphone_notify_received(LinphoneCore *lc, LinphoneEvent *lev, const char *eventname, const LinphoneContent *content){
|
||||
CU_ASSERT_PTR_NOT_NULL_FATAL(content);
|
||||
CU_ASSERT_TRUE(strcmp(notify_content,(const char*)content->data)==0);
|
||||
LinphoneCoreManager *mgr=get_manager(lc);
|
||||
mgr->stat.number_of_NotifyReceived++;
|
||||
}
|
||||
|
||||
void linphone_subscription_state_change(LinphoneCore *lc, LinphoneEvent *lev, LinphoneSubscriptionState state) {
|
||||
|
|
@ -124,6 +126,9 @@ static void subscribe_test_with_args(bool_t terminated_by_subscriber) {
|
|||
CU_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneSubscriptionActive,1,1000));
|
||||
CU_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneSubscriptionActive,1,1000));
|
||||
|
||||
/*make sure marie receives first notification before terminating
|
||||
CU_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_NotifyReceived,1,1000));*/
|
||||
|
||||
if (terminated_by_subscriber){
|
||||
linphone_event_terminate(lev);
|
||||
}else{
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue