Commit 7593b007 authored by Simon Morlat's avatar Simon Morlat

fix several bug in presence support again.

parent 52fe995a
......@@ -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);
......
......@@ -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);
}
......
......@@ -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);
......
......@@ -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);
}
......
......@@ -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);
......
......@@ -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;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment