diff --git a/coreapi/TunnelManager.cc b/coreapi/TunnelManager.cc index 3e998cb74..44d12251c 100644 --- a/coreapi/TunnelManager.cc +++ b/coreapi/TunnelManager.cc @@ -276,7 +276,7 @@ void TunnelManager::waitUnRegistration(){ LinphoneProxyConfig* lProxy; linphone_core_get_default_proxy(mCore, &lProxy); if (lProxy && linphone_proxy_config_get_state(lProxy)==LinphoneRegistrationOk) { - int i; + int i=0; linphone_proxy_config_edit(lProxy); //make sure unregister is sent and authenticated do{ diff --git a/coreapi/linphone_tunnel.cc b/coreapi/linphone_tunnel.cc index d36778bb8..947286373 100644 --- a/coreapi/linphone_tunnel.cc +++ b/coreapi/linphone_tunnel.cc @@ -152,6 +152,17 @@ void linphone_tunnel_set_http_proxy_auth_info(LinphoneTunnel *tunnel, const char void linphone_tunnel_set_http_proxy(LinphoneTunnel*tunnel, const char *host, int port, const char* username,const char* passwd){ bcTunnel(tunnel)->setHttpProxy(host, port, username, passwd); + lp_config_set_string(config(tunnel),"tunnel","http_proxy_host",host); + lp_config_set_int(config(tunnel),"tunnel","http_proxy_port",port); + lp_config_set_string(config(tunnel),"tunnel","http_proxy_username",username); + lp_config_set_string(config(tunnel),"tunnel","http_proxy_password",passwd); +} + +void linphone_tunnel_get_http_proxy(LinphoneTunnel*tunnel,const char **host, int *port, const char **username, const char **passwd){ + if (host) *host=lp_config_get_string(config(tunnel),"tunnel","http_proxy_host",NULL); + if (port) *port=lp_config_get_int(config(tunnel),"tunnel","http_proxy_port",0); + if (username) *username=lp_config_get_string(config(tunnel),"tunnel","http_proxy_username",NULL); + if (passwd) *passwd=lp_config_get_string(config(tunnel),"tunnel","http_proxy_password",NULL); } void linphone_tunnel_reconnect(LinphoneTunnel *tunnel){ @@ -162,19 +173,17 @@ void linphone_tunnel_auto_detect(LinphoneTunnel *tunnel){ bcTunnel(tunnel)->autoDetect(); } -static void tunnel_add_servers_from_config(LinphoneTunnel *tunnel, const char* confaddress){ - char *addresses=(char*)ms_strdup(confaddress); +static void tunnel_add_servers_from_config(LinphoneTunnel *tunnel, char* confaddress){ char *str1; - for(str1=addresses;;str1=NULL){ + for(str1=confaddress;;str1=NULL){ char *port; char *address=strtok(str1," "); // Not thread safe if (!address) break; port=strchr(address, ':'); - if (!port) ms_fatal("Bad tunnel address %s", address); + if (!port) ms_fatal("Bad tunnel address %s",confaddress); *port++='\0'; linphone_tunnel_add_server(tunnel, address, atoi(port)); } - ms_free(addresses); } static void my_ortp_logv(OrtpLogLevel level, const char *fmt, va_list args){ @@ -188,10 +197,12 @@ static void my_ortp_logv(OrtpLogLevel level, const char *fmt, va_list args){ void linphone_tunnel_configure(LinphoneTunnel *tunnel){ bool_t enabled=(bool_t)lp_config_get_int(config(tunnel),"tunnel","enabled",FALSE); const char* addresses=lp_config_get_string(config(tunnel),"tunnel","server_addresses", NULL); + char *copy=addresses ? ms_strdup(addresses) : NULL; linphone_tunnel_enable_logs_with_handler(tunnel,TRUE,my_ortp_logv); linphone_tunnel_clean_servers(tunnel); - if (addresses){ - tunnel_add_servers_from_config(tunnel,addresses); + if (copy){ + tunnel_add_servers_from_config(tunnel,copy); + ms_free(copy); } linphone_tunnel_enable(tunnel, enabled); } diff --git a/coreapi/linphone_tunnel.h b/coreapi/linphone_tunnel.h index ea49ac8b2..5d78fe8f6 100644 --- a/coreapi/linphone_tunnel.h +++ b/coreapi/linphone_tunnel.h @@ -106,6 +106,7 @@ void linphone_tunnel_reconnect(LinphoneTunnel *tunnel); void linphone_tunnel_auto_detect(LinphoneTunnel *tunnel); void linphone_tunnel_set_http_proxy(LinphoneTunnel *tunnel, const char *host, int port, const char* username,const char* passwd); void linphone_tunnel_set_http_proxy_auth_info(LinphoneTunnel*tunnel, const char* username,const char* passwd); +void linphone_tunnel_get_http_proxy(LinphoneTunnel*tunnel,const char **host, int *port, const char **username, const char **passwd); void linphone_tunnel_enable_logs(LinphoneTunnel *tunnel, bool_t enabled); diff --git a/gtk/propertybox.c b/gtk/propertybox.c index 5af25a5c4..809207a2a 100644 --- a/gtk/propertybox.c +++ b/gtk/propertybox.c @@ -1077,6 +1077,19 @@ void linphone_gtk_edit_tunnel(GtkButton *button){ } else{ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(linphone_gtk_get_widget(w,"radio_disable")),1); } + { + const char *proxy=NULL,*username=NULL,*password=NULL; + port=0; + linphone_tunnel_get_http_proxy(tunnel,&proxy,&port,&username,&password); + if (proxy) + gtk_entry_set_text(GTK_ENTRY(linphone_gtk_get_widget(w,"http_host")),proxy); + if (port>0) + gtk_spin_button_set_value(GTK_SPIN_BUTTON(linphone_gtk_get_widget(w,"http_port")), port); + if (username) + gtk_entry_set_text(GTK_ENTRY(linphone_gtk_get_widget(w,"username")),username); + if (password) + gtk_entry_set_text(GTK_ENTRY(linphone_gtk_get_widget(w,"password")),password); + } g_object_weak_ref(G_OBJECT(w),(GWeakNotify)linphone_gtk_edit_tunnel_closed,w); gtk_widget_show(w); @@ -1090,12 +1103,19 @@ void linphone_gtk_tunnel_ok(GtkButton *button){ gint port = (gint)gtk_spin_button_get_value(GTK_SPIN_BUTTON(linphone_gtk_get_widget(w,"port"))); gboolean enabled=gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(linphone_gtk_get_widget(w,"radio_enable"))); const char *host=gtk_entry_get_text(GTK_ENTRY(linphone_gtk_get_widget(w,"host"))); + const char *http_host=gtk_entry_get_text(GTK_ENTRY(linphone_gtk_get_widget(w,"http_host"))); + gint http_port = (gint)gtk_spin_button_get_value(GTK_SPIN_BUTTON(linphone_gtk_get_widget(w,"http_port"))); + const char *username=gtk_entry_get_text(GTK_ENTRY(linphone_gtk_get_widget(w,"username"))); + const char *password=gtk_entry_get_text(GTK_ENTRY(linphone_gtk_get_widget(w,"password"))); if (tunnel==NULL) return; if (host && *host=='\0') host=NULL; + if (http_port==0) http_port=8080; linphone_tunnel_clean_servers(tunnel); linphone_tunnel_add_server(tunnel,host,port); linphone_tunnel_enable(tunnel,enabled); + linphone_tunnel_set_http_proxy(tunnel,http_host,http_port,username,password); + gtk_widget_destroy(w); } diff --git a/gtk/tunnel_config.ui b/gtk/tunnel_config.ui index c10ddf257..427346613 100644 --- a/gtk/tunnel_config.ui +++ b/gtk/tunnel_config.ui @@ -1,14 +1,23 @@ - + - + - 3600 - 100000 + 1 + 65535 + 443 + 1 + 10 + + + 1 + 65535 + 8080 1 10 + False GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK 5 Linphone - Configure a SIP account @@ -18,32 +27,39 @@ True + False GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK 2 True + False GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK 0 none True + False GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK 12 True + False GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK True + False GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK 4 2 + True True + False GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK Host right @@ -55,6 +71,10 @@ True True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + False + False + True + True 1 @@ -64,6 +84,7 @@ True + False GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK Port right @@ -73,14 +94,35 @@ 2 + + + True + True + + False + False + True + True + adjustment1 + + + 1 + 2 + 1 + 2 + + Enable True True False + False + 0 True True + radio_disable 1 @@ -95,9 +137,10 @@ True True False + False + 0 True True - radio_enable 1 @@ -106,20 +149,6 @@ 4 - - - True - True - - adjustment1 - - - 1 - 2 - 1 - 2 - - @@ -128,6 +157,8 @@ + True + True 0 @@ -138,19 +169,168 @@ True + False GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - Configure tunnel + <b>Configure tunnel</b> True + False + True + 0 + + + + + True + False + 0 + none + + + True + False + 12 + + + True + False + 4 + 2 + True + + + True + False + Host + + + + + True + False + Port + + + 1 + 2 + + + + + True + False + Username + + + 2 + 3 + + + + + True + False + Password + + + 3 + 4 + + + + + True + True + + False + False + True + True + adjustment2 + + + 1 + 2 + 1 + 2 + + + + + True + True + + False + False + True + True + + + 1 + 2 + + + + + True + True + + False + False + True + True + + + 1 + 2 + 2 + 3 + + + + + True + True + False + + False + False + True + True + + + 1 + 2 + 3 + 4 + + + + + + + + + True + False + <b>Configure http proxy (optional)</b> + True + + + + + True + True 1 True + False GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK end @@ -160,8 +340,9 @@ True True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + False True - + False @@ -176,8 +357,9 @@ True True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + False True - + False @@ -188,8 +370,9 @@ False + True end - 0 + 2