properly build REGISTER refreshes

This commit is contained in:
Simon Morlat 2011-05-17 14:30:18 +02:00
parent 7a82ee71fe
commit 0e517a8906
6 changed files with 34 additions and 4 deletions

View file

@ -3946,12 +3946,11 @@ void linphone_core_refresh_registers(LinphoneCore* lc) {
for(;elem!=NULL;elem=elem->next){
LinphoneProxyConfig *cfg=(LinphoneProxyConfig*)elem->data;
if (linphone_proxy_config_register_enabled(cfg) ) {
cfg->registered=0;
cfg->commit=TRUE;
linphone_proxy_config_refresh_register(cfg);
}
}
}
void linphone_core_set_network_reachable(LinphoneCore* lc,bool_t isReachable) {
//first disable automatic mode
if (lc->auto_net_state_mon) {

View file

@ -364,6 +364,7 @@ bool_t linphone_proxy_config_publish_enabled(const LinphoneProxyConfig *obj);
const char *linphone_proxy_config_get_addr(const LinphoneProxyConfig *obj);
int linphone_proxy_config_get_expires(const LinphoneProxyConfig *obj);
bool_t linphone_proxy_config_register_enabled(const LinphoneProxyConfig *obj);
void linphone_proxy_config_refresh_register(LinphoneProxyConfig *obj);
struct _LinphoneCore * linphone_proxy_config_get_core(const LinphoneProxyConfig *obj);
bool_t linphone_proxy_config_get_dial_escape_plus(const LinphoneProxyConfig *cfg);

View file

@ -290,6 +290,16 @@ static void linphone_proxy_config_register(LinphoneProxyConfig *obj){
}
}
/**
* Refresh a proxy registration.
* This is useful if for example you resuming from suspend, thus IP address may have changed.
**/
void linphone_proxy_config_refresh_register(LinphoneProxyConfig *obj){
if (obj->reg_sendregister && obj->op){
sal_register_refresh(obj->op,obj->expires);
}
}
/**
* Sets a dialing prefix to be automatically prepended when inviting a number with

View file

@ -315,6 +315,7 @@ void sal_call_send_vfu_request(SalOp *h);
/*Registration*/
int sal_register(SalOp *op, const char *proxy, const char *from, int expires);
int sal_register_refresh(SalOp *op, int expires);
int sal_unregister(SalOp *h);
/*Messaging */

View file

@ -1908,6 +1908,25 @@ int sal_register(SalOp *h, const char *proxy, const char *from, int expires){
return 0;
}
int sal_register_refresh(SalOp *op, int expires){
osip_message_t *msg=NULL;
const char *contact=sal_op_get_contact(op);
if (op->rid==-1){
ms_error("Unexistant registration context, not possible to refresh.");
return -1;
}
eXosip_lock();
eXosip_register_build_register(op->rid,expires,&msg);
if (msg!=NULL){
if (contact) register_set_contact(msg,contact);
eXosip_register_send_register(op->rid,msg);
}else ms_error("Could not build REGISTER refresh message.");
eXosip_unlock();
return 0;
}
int sal_unregister(SalOp *h){
osip_message_t *msg=NULL;
eXosip_lock();

@ -1 +1 @@
Subproject commit 88d2500c0a1a01c136f0e7ebb8d9872262b57a41
Subproject commit e7e43f83d827eebc1b6989f0ec22a89c00f15627