From 180a835ed6535691f7d41b2dc6e15de2d0b83010 Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Tue, 16 Mar 2010 16:28:14 +0100 Subject: [PATCH] fix bug causing double subscribe. --- coreapi/friend.c | 3 ++- coreapi/sal_eXosip2.c | 2 +- coreapi/sal_eXosip2_presence.c | 15 +++++++++------ 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/coreapi/friend.c b/coreapi/friend.c index 047749e32..d5377952d 100644 --- a/coreapi/friend.c +++ b/coreapi/friend.c @@ -152,6 +152,7 @@ void __linphone_friend_do_subscribe(LinphoneFriend *fr){ fr->outsub=sal_op_new(fr->lc->sal); sal_op_set_route(fr->outsub,route); sal_subscribe_presence(fr->outsub,from,friend); + fr->subscribe_active=TRUE; ms_free(friend); } @@ -364,7 +365,7 @@ void linphone_friend_apply(LinphoneFriend *fr, LinphoneCore *lc){ fr->inc_subscribe_pending=FALSE; } if (fr->subscribe && fr->subscribe_active==FALSE){ - + ms_message("Sending a new SUBSCRIBE"); __linphone_friend_do_subscribe(fr); } ms_message("linphone_friend_apply() done."); diff --git a/coreapi/sal_eXosip2.c b/coreapi/sal_eXosip2.c index 17eb3c004..8fa1ec016 100644 --- a/coreapi/sal_eXosip2.c +++ b/coreapi/sal_eXosip2.c @@ -1305,7 +1305,7 @@ static bool_t process_event(Sal *sal, eXosip_event_t *ev){ } break; case EXOSIP_IN_SUBSCRIPTION_NEW: - ms_message("CALL_SUBSCRIPTION_NEW "); + ms_message("CALL_IN_SUBSCRIPTION_NEW "); sal_exosip_subscription_recv(sal,ev); break; case EXOSIP_IN_SUBSCRIPTION_RELEASED: diff --git a/coreapi/sal_eXosip2_presence.c b/coreapi/sal_eXosip2_presence.c index 03aef7821..8b17dfea6 100644 --- a/coreapi/sal_eXosip2_presence.c +++ b/coreapi/sal_eXosip2_presence.c @@ -416,7 +416,7 @@ int sal_notify_presence(SalOp *op, SalPresenceStatus status, const char *status_ } int sal_notify_close(SalOp *op){ - osip_message_t *msg; + osip_message_t *msg=NULL; eXosip_lock(); eXosip_insubscription_build_notify(op->did,EXOSIP_SUBCRSTATE_TERMINATED,DEACTIVATED,&msg); if (msg!=NULL){ @@ -424,7 +424,8 @@ int sal_notify_close(SalOp *op){ if (identity==NULL) identity=sal_op_get_to(op); osip_message_set_contact(msg,identity); eXosip_insubscription_send_request(op->did,msg); - }else ms_error("sal_notify_close(): could not create notify for incoming subscription."); + }else ms_error("sal_notify_close(): could not create notify for incoming subscription" + " did=%i, nid=%i",op->did,op->nid); eXosip_unlock(); return 0; } @@ -668,15 +669,16 @@ void sal_exosip_in_subscription_closed(Sal *sal, eXosip_event_t *ev){ ms_error("Incoming subscription closed but no associated op !"); return; } + + + sal_remove_in_subscribe(sal,op); + op->nid=-1; + op->did=-1; if (ev->request){ osip_from_to_str(ev->request->from,&tmp); sal->callbacks.subscribe_closed(op,tmp); osip_free(tmp); } - - sal_remove_in_subscribe(sal,op); - op->nid=-1; - op->did=-1; } void sal_exosip_subscription_closed(Sal *sal,eXosip_event_t *ev){ @@ -688,6 +690,7 @@ void sal_exosip_subscription_closed(Sal *sal,eXosip_event_t *ev){ sal_remove_out_subscribe(sal,op); op->sid=-1; op->did=-1; + sal->callbacks.notify(op,SalSubscribeTerminated, SalPresenceOffline,NULL); }