Commit 58c0d50b authored by Simon Morlat's avatar Simon Morlat
Browse files

take in account closed incoming subscriptions

parent 308b63c9
......@@ -296,6 +296,7 @@ static void linphone_friend_unsubscribe(LinphoneFriend *lf){
sal_unsubscribe(lf->outsub);
sal_op_release(lf->outsub);
lf->outsub=NULL;
lf->subscribe_active=FALSE;
}
}
......@@ -362,7 +363,7 @@ void linphone_friend_apply(LinphoneFriend *fr, LinphoneCore *lc){
}
fr->inc_subscribe_pending=FALSE;
}
if (fr->subscribe && fr->outsub==NULL){
if (fr->subscribe && fr->subscribe_active==FALSE){
__linphone_friend_do_subscribe(fr);
}
......
......@@ -128,6 +128,7 @@ void linphone_notify_recv(LinphoneCore *lc, SalOp *op, SalSubscribeState ss, Sal
friend=lf->uri;
tmp=linphone_address_as_string(friend);
lf->status=estatus;
lf->subscribe_active=TRUE;
lc->vtable.notify_recv(lc,(LinphoneFriend*)lf);
ms_free(tmp);
}else{
......@@ -135,8 +136,10 @@ void linphone_notify_recv(LinphoneCore *lc, SalOp *op, SalSubscribeState ss, Sal
}
if (ss==SalSubscribeTerminated){
sal_op_release(op);
if (lf)
if (lf){
lf->outsub=NULL;
lf->subscribe_active=FALSE;
}
}
}
......
......@@ -236,6 +236,7 @@ struct _LinphoneFriend{
BuddyInfo *info;
char *refkey;
bool_t subscribe;
bool_t subscribe_active;
bool_t inc_subscribe_pending;
};
......
......@@ -1308,6 +1308,10 @@ static bool_t process_event(Sal *sal, eXosip_event_t *ev){
ms_message("CALL_SUBSCRIPTION_NEW ");
sal_exosip_subscription_recv(sal,ev);
break;
case EXOSIP_IN_SUBSCRIPTION_RELEASED:
ms_message("CALL_SUBSCRIPTION_NEW ");
sal_exosip_in_subscription_closed(sal,ev);
break;
case EXOSIP_SUBSCRIPTION_UPDATE:
ms_message("CALL_SUBSCRIPTION_UPDATE");
break;
......@@ -1323,6 +1327,14 @@ static bool_t process_event(Sal *sal, eXosip_event_t *ev){
ms_message("EXOSIP_SUBSCRIPTION_CLOSED\n");
sal_exosip_subscription_closed(sal,ev);
break;
case EXOSIP_SUBSCRIPTION_REQUESTFAILURE: /**< announce a request failure */
if (ev->response && (ev->response->status_code == 407 || ev->response->status_code == 401)){
return process_authentication(sal,ev);
}
case EXOSIP_SUBSCRIPTION_SERVERFAILURE:
case EXOSIP_SUBSCRIPTION_GLOBALFAILURE:
sal_exosip_subscription_closed(sal,ev);
break;
case EXOSIP_CALL_RELEASED:
ms_message("CALL_RELEASED\n");
call_released(sal, ev);
......@@ -1351,7 +1363,7 @@ static bool_t process_event(Sal *sal, eXosip_event_t *ev){
}
break;
default:
ms_message("Unhandled exosip event ! %i");
ms_message("Unhandled exosip event ! %i",ev->type);
break;
}
return TRUE;
......
......@@ -67,6 +67,8 @@ void sal_exosip_subscription_answered(Sal *sal,eXosip_event_t *ev);
void sal_exosip_notify_recv(Sal *sal,eXosip_event_t *ev);
void sal_exosip_subscription_closed(Sal *sal,eXosip_event_t *ev);
void sal_exosip_in_subscription_closed(Sal *sal, eXosip_event_t *ev);
void sal_exosip_fix_route(SalOp *op);
......
......@@ -661,15 +661,33 @@ void sal_exosip_subscription_answered(Sal *sal,eXosip_event_t *ev){
op->did=ev->did;
}
void sal_exosip_subscription_closed(Sal *sal,eXosip_event_t *ev){
SalOp *op=sal_find_in_subscribe(sal,ev->sid);
void sal_exosip_in_subscription_closed(Sal *sal, eXosip_event_t *ev){
SalOp *op=sal_find_in_subscribe(sal,ev->nid);
char *tmp;
if (op==NULL){
ms_error("Subscription closed but no associated op !");
ms_error("Incoming subscription closed but no associated op !");
return;
}
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){
SalOp *op=sal_find_out_subscribe(sal,ev->sid);
if (op==NULL){
ms_error("Subscription closed but no associated op !");
return;
}
sal_remove_out_subscribe(sal,op);
op->sid=-1;
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