Commit 53a6987b authored by jehan monnier's avatar jehan monnier Committed by jehan
Browse files

add network state management api

parent 1fbfa824
......@@ -655,7 +655,7 @@ static void sip_config_read(LinphoneCore *lc)
lc->sip_conf.sdp_200_ack=lp_config_get_int(lc->config,"sip","sdp_200_ack",0);
lc->sip_conf.only_one_codec=lp_config_get_int(lc->config,"sip","only_one_codec",0);
lc->sip_conf.register_only_when_network_is_up=
lp_config_get_int(lc->config,"sip","register_only_when_network_is_up",0);
lp_config_get_int(lc->config,"sip","register_only_when_network_is_up",1);
}
static void rtp_config_read(LinphoneCore *lc)
......@@ -1403,7 +1403,7 @@ static void linphone_core_disconnected(LinphoneCore *lc){
}
static void proxy_update(LinphoneCore *lc, time_t curtime){
bool_t doit=FALSE;
static time_t last_check=0;
static bool_t last_status=FALSE;
if (lc->sip_conf.register_only_when_network_is_up){
......@@ -1418,9 +1418,10 @@ static void proxy_update(LinphoneCore *lc, time_t curtime){
}
last_check=curtime;
}
doit=last_status;
}else doit=TRUE;
if (doit) ms_list_for_each(lc->sip_conf.proxies,(void (*)(void*))&linphone_proxy_config_update);
linphone_core_set_network_reachable(lc,last_status);
}else {
ms_list_for_each(lc->sip_conf.proxies,(void (*)(void*))&linphone_proxy_config_update);
}
}
static void assign_buddy_info(LinphoneCore *lc, BuddyInfo *info){
......@@ -3488,6 +3489,23 @@ static void linphone_core_uninit(LinphoneCore *lc)
gstate_new_state(lc, GSTATE_POWER_OFF, NULL);
}
void linphone_core_set_network_reachable(LinphoneCore* lc,bool_t isReachable) {
// first get the list of available proxies
const MSList *elem=linphone_core_get_proxy_config_list(lc);
for(;elem!=NULL;elem=elem->next){
LinphoneProxyConfig *cfg=(LinphoneProxyConfig*)elem->data;
if (linphone_proxy_config_register_enabled(cfg) ) {
if (!isReachable) {
cfg->registered=0;
cfg->commit=TRUE;
} else {
linphone_proxy_config_update(cfg);
}
}
}
}
/**
* Destroys a LinphoneCore
*
......
......@@ -657,6 +657,10 @@ typedef struct _LinphoneCore
int rsvp_enable;
int rpc_enable;
#endif
/*set this field to false if application manage the network connection state
* In case of false, network state must be communicate to linphone core with method linphone_core_
*/
bool_t auto_net_state_mon;
} LinphoneCore;
......@@ -897,6 +901,18 @@ const LinphoneAddress *linphone_core_get_remote_uri(LinphoneCore *lc);
int linphone_core_get_mtu(const LinphoneCore *lc);
void linphone_core_set_mtu(LinphoneCore *lc, int mtu);
/**
* Calling this method with false disable automatiic
*/
void linphone_core_enable_auto_net_stat_mon(LinphoneCore* lc,bool_t value);
/**
* This method is called by the application to notify the linphone core library when network is reachable.
* Calling this method with true trigger linphone to initiate a registration process for all proxy
* configuration with parameter register set to enable
*
*/
void linphone_core_set_network_reachable(LinphoneCore* lc,bool_t value);
bool_t linphone_core_is_in_main_thread(LinphoneCore *lc);
......
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