Commit fde22ebf authored by Simon Morlat's avatar Simon Morlat
Browse files

implement setting of http proxy host and port (for tunnel extension) in gtk ui

parent 12108965
......@@ -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{
......
......@@ -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);
}
......
......@@ -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);
......
......@@ -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);
}
......
This diff is collapsed.
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