Commit 5017c6eb authored by Yann Diorcet's avatar Yann Diorcet
Browse files

Improve uPnP behaviour (Firewall policy change, local ip change, ...)

Hide uPnP firewall setting if uPnP is not available
parent e3c60a69
......@@ -782,6 +782,7 @@ printf "* %-30s %s\n" "Account assistant" $build_wizard
printf "* %-30s %s\n" "Console interface" $console_ui
printf "* %-30s %s\n" "Tools" $build_tools
printf "* %-30s %s\n" "zRTP encryption (GPLv3)" $zrtp
printf "* %-30s %s\n" "uPnP support" $build_upnp
if test "$enable_tunnel" = "true" ; then
printf "* Tunnel support\t\ttrue\n"
......
......@@ -1304,9 +1304,6 @@ static void linphone_core_init (LinphoneCore * lc, const LinphoneCoreVTable *vta
lc->tunnel=linphone_core_tunnel_new(lc);
if (lc->tunnel) linphone_tunnel_configure(lc->tunnel);
#endif
#ifdef BUILD_UPNP
lc->upnp = linphone_upnp_context_new(lc);
#endif //BUILD_UPNP
if (lc->vtable.display_status)
lc->vtable.display_status(lc,_("Ready"));
lc->auto_net_state_mon=lc->sip_conf.auto_net_state_mon;
......@@ -4211,6 +4208,17 @@ void linphone_core_set_firewall_policy(LinphoneCore *lc, LinphoneFirewallPolicy
ms_warning("UPNP is not available, reset firewall policy to no firewall");
pol = LinphonePolicyNoFirewall;
}
#else //BUILD_UPNP
if(pol == LinphonePolicyUseUpnp) {
if(lc->upnp == NULL) {
lc->upnp = linphone_upnp_context_new(lc);
}
} else {
if(lc->upnp != NULL) {
linphone_upnp_context_destroy(lc->upnp);
lc->upnp = NULL;
}
}
#endif //BUILD_UPNP
lc->net_conf.firewall_policy=pol;
if (lc->sip_conf.contact) update_primary_contact(lc);
......@@ -5170,8 +5178,10 @@ static void linphone_core_uninit(LinphoneCore *lc)
}
#ifdef BUILD_UPNP
linphone_upnp_context_destroy(lc->upnp);
lc->upnp = NULL;
if(lc->upnp != NULL) {
linphone_upnp_context_destroy(lc->upnp);
lc->upnp = NULL;
}
#endif //BUILD_UPNP
if (lc->friends)
......@@ -5506,7 +5516,7 @@ void linphone_core_remove_iterate_hook(LinphoneCore *lc, LinphoneCoreIterateHook
for(elem=lc->hooks;elem!=NULL;elem=elem->next){
Hook *h=(Hook*)elem->data;
if (h->fun==hook && h->data==hook_data){
ms_list_remove_link(lc->hooks,elem);
lc->hooks = ms_list_remove_link(lc->hooks,elem);
ms_free(h);
return;
}
......
......@@ -1097,9 +1097,18 @@ void linphone_proxy_config_update(LinphoneProxyConfig *cfg){
if (cfg->type && cfg->ssctx==NULL){
linphone_proxy_config_activate_sip_setup(cfg);
}
if ((!lc->sip_conf.register_only_when_network_is_up || lc->network_reachable) &&
(!lc->sip_conf.register_only_when_upnp_is_ok || linphone_core_get_upnp_state(lc) == LinphoneUpnpStateOk))
linphone_proxy_config_register(cfg);
switch(linphone_core_get_firewall_policy(lc)) {
case LinphonePolicyUseUpnp:
#ifdef BUILD_UPNP
if(lc->upnp != NULL && !linphone_upnp_context_is_ready_for_register(lc->upnp)) {
break;
}
#endif
default:
if ((!lc->sip_conf.register_only_when_network_is_up || lc->network_reachable)) {
linphone_proxy_config_register(cfg);
}
}
if (cfg->publish && cfg->publish_op==NULL){
linphone_proxy_config_send_publish(cfg,lc->presence_mode);
}
......
This diff is collapsed.
......@@ -41,6 +41,7 @@ void linphone_upnp_context_destroy(UpnpContext *ctx);
LinphoneUpnpState linphone_upnp_context_get_state(UpnpContext *ctx);
const char *linphone_upnp_context_get_external_ipaddress(UpnpContext *ctx);
int linphone_upnp_context_get_external_port(UpnpContext *ctx);
bool_t linphone_upnp_context_is_ready_for_register(UpnpContext *ctx);
void linphone_core_update_upnp_state_in_call_stats(LinphoneCall *call);
#endif //LINPHONE_UPNP_H
......@@ -1083,6 +1083,10 @@ void linphone_gtk_show_parameters(void){
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(linphone_gtk_get_widget(pb,"use_upnp")),TRUE);
break;
}
if(!linphone_core_upnp_available(lc)) {
gtk_widget_hide(linphone_gtk_get_widget(pb,"use_upnp"));
}
mtu=linphone_core_get_mtu(lc);
if (mtu<=0){
gtk_widget_set_sensitive(linphone_gtk_get_widget(pb,"mtu"),FALSE);
......
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