From 7593b0073c01a188fb94b149c4d9afe746ac26bc Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Tue, 16 Mar 2010 11:55:30 +0100 Subject: [PATCH] fix several bug in presence support again. --- coreapi/friend.c | 7 ++++++- coreapi/linphonecore.c | 4 ++-- coreapi/private.h | 2 +- coreapi/sal_eXosip2.c | 6 ++++++ coreapi/sal_eXosip2.h | 3 +++ coreapi/sal_eXosip2_presence.c | 30 +++++++----------------------- 6 files changed, 25 insertions(+), 27 deletions(-) diff --git a/coreapi/friend.c b/coreapi/friend.c index a4ca5484..68f43e65 100644 --- a/coreapi/friend.c +++ b/coreapi/friend.c @@ -299,13 +299,18 @@ static void linphone_friend_unsubscribe(LinphoneFriend *lf){ } } -void linphone_friend_destroy(LinphoneFriend *lf){ +void linphone_friend_close_subscriptions(LinphoneFriend *lf){ linphone_friend_notify(lf,LINPHONE_STATUS_OFFLINE); linphone_friend_unsubscribe(lf); if (lf->insub){ sal_notify_close(lf->insub); sal_op_release(lf->insub); + lf->insub=NULL; } +} + +void linphone_friend_destroy(LinphoneFriend *lf){ + if (lf->uri!=NULL) linphone_address_destroy(lf->uri); if (lf->info!=NULL) buddy_info_free(lf->info); ms_free(lf); diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index ddb09892..f699a2a3 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -1392,7 +1392,6 @@ int linphone_core_get_sip_port(LinphoneCore *lc) return lc->sip_conf.sip_port; } -static bool_t exosip_running=FALSE; static char _ua_name[64]="Linphone"; static char _ua_version[64]=LINPHONE_VERSION; @@ -3389,6 +3388,8 @@ static void linphone_core_uninit(LinphoneCore *lc) linphone_core_iterate(lc); } } + if (lc->friends) + ms_list_for_each(lc->friends,(void (*)(void *))linphone_friend_close_subscriptions); gstate_new_state(lc, GSTATE_POWER_SHUTDOWN, NULL); #ifdef VIDEO_ENABLED if (lc->previewstream!=NULL){ @@ -3412,7 +3413,6 @@ static void linphone_core_uninit(LinphoneCore *lc) linphone_core_free_payload_types(); ortp_exit(); - exosip_running=FALSE; gstate_new_state(lc, GSTATE_POWER_OFF, NULL); } diff --git a/coreapi/private.h b/coreapi/private.h index 84b4d077..cbb76720 100644 --- a/coreapi/private.h +++ b/coreapi/private.h @@ -101,7 +101,7 @@ void linphone_core_refresh_subscribes(LinphoneCore *lc); int linphone_proxy_config_send_publish(LinphoneProxyConfig *cfg, LinphoneOnlineStatus os); int linphone_online_status_to_eXosip(LinphoneOnlineStatus os); - +void linphone_friend_close_subscriptions(LinphoneFriend *lf); void linphone_friend_notify(LinphoneFriend *lf, LinphoneOnlineStatus os); LinphoneFriend *linphone_find_friend_by_inc_subscribe(MSList *l, SalOp *op); LinphoneFriend *linphone_find_friend_by_out_subscribe(MSList *l, SalOp *op); diff --git a/coreapi/sal_eXosip2.c b/coreapi/sal_eXosip2.c index f8a45edb..5f337b3f 100644 --- a/coreapi/sal_eXosip2.c +++ b/coreapi/sal_eXosip2.c @@ -153,6 +153,12 @@ void sal_op_release(SalOp *op){ ms_message("Cleaning cid %i",op->cid); eXosip_call_set_reference(op->cid,NULL); } + if (op->sid!=-1){ + sal_remove_out_subscribe(op->base.root,op); + } + if (op->nid!=-1){ + sal_remove_in_subscribe(op->base.root,op); + } if (op->pending_auth){ sal_remove_pending_auth(op->base.root,op); } diff --git a/coreapi/sal_eXosip2.h b/coreapi/sal_eXosip2.h index 22694813..6539dcae 100644 --- a/coreapi/sal_eXosip2.h +++ b/coreapi/sal_eXosip2.h @@ -59,6 +59,9 @@ struct SalOp{ bool_t reinvite; }; +void sal_remove_out_subscribe(Sal *sal, SalOp *op); +void sal_remove_in_subscribe(Sal *sal, SalOp *op); + void sal_exosip_subscription_recv(Sal *sal, eXosip_event_t *ev); void sal_exosip_subscription_answered(Sal *sal,eXosip_event_t *ev); void sal_exosip_notify_recv(Sal *sal,eXosip_event_t *ev); diff --git a/coreapi/sal_eXosip2_presence.c b/coreapi/sal_eXosip2_presence.c index f6c85b5f..11104b8d 100644 --- a/coreapi/sal_eXosip2_presence.c +++ b/coreapi/sal_eXosip2_presence.c @@ -35,16 +35,8 @@ static void sal_add_out_subscribe(Sal *sal, SalOp *op){ sal->out_subscribes=ms_list_append(sal->out_subscribes,op); } -static void sal_remove_out_subscribe(Sal *sal, int sid){ - MSList *elem; - SalOp *op; - for(elem=sal->out_subscribes;elem!=NULL;elem=elem->next){ - op=(SalOp*)elem->data; - if (op->sid==sid) { - sal->out_subscribes=ms_list_remove_link(sal->out_subscribes,elem); - return; - } - } +void sal_remove_out_subscribe(Sal *sal, SalOp *op){ + sal->out_subscribes=ms_list_remove(sal->out_subscribes,op); } static SalOp * sal_find_in_subscribe(Sal *sal, int nid){ @@ -61,16 +53,8 @@ static void sal_add_in_subscribe(Sal *sal, SalOp *op){ sal->in_subscribes=ms_list_append(sal->in_subscribes,op); } -static void sal_remove_in_subscribe(Sal *sal, int nid){ - MSList *elem; - SalOp *op; - for(elem=sal->in_subscribes;elem!=NULL;elem=elem->next){ - op=(SalOp*)elem->data; - if (op->nid==nid) { - sal->in_subscribes=ms_list_remove_link(sal->in_subscribes,elem); - return; - } - } +void sal_remove_in_subscribe(Sal *sal, SalOp *op){ + sal->in_subscribes=ms_list_remove(sal->in_subscribes,op); } int sal_text_send(SalOp *op, const char *from, const char *to, const char *msg){ @@ -659,7 +643,7 @@ void sal_exosip_notify_recv(Sal *sal, eXosip_event_t *ev){ } ms_message("We are notified that %s has online status %i",tmp,estatus); if (ev->ss_status==EXOSIP_SUBCRSTATE_TERMINATED) { - sal_remove_out_subscribe(sal,op->sid); + sal_remove_out_subscribe(sal,op); op->sid=-1; op->did=-1; ms_message("And outgoing subscription terminated by remote."); @@ -683,9 +667,9 @@ void sal_exosip_subscription_closed(Sal *sal,eXosip_event_t *ev){ ms_error("Subscription closed but no associated op !"); return; } - sal_remove_in_subscribe(sal,op->nid); + sal_remove_in_subscribe(sal,op); op->nid=-1; - op->did=0; + op->did=-1; } -- 2.39.2