Commit 5e0c3388 authored by Simon Morlat's avatar Simon Morlat

tunnel extension ported to windows (mingw) and working

parent 31d68ac1
......@@ -18,8 +18,6 @@ This is Linphone, a free (GPL) video softphone based on the SIP protocol.
with their corresponding -dev or -devel package if you don't use source packages.
Note that you need to build and install the tunnel library PRIOR to build linphone.
For windows compilation see README.mingw.
For macOS X, see README.macos
......
......@@ -55,7 +55,7 @@ It is recommended that you create a directory somewhere with a path without any
c:\sources\
Within msys-git bash, do
cd /c/sources
git clone git://git.savannah.nongnu.org/linphone.git --recursive
git clone git://git.linphone.org/linphone.git --recursive
Building
......
......@@ -135,3 +135,35 @@ LinphoneTunnelState linphone_tunnel_get_state(LinphoneTunnel *tunnel){
return LinphoneTunnelDisabled;
}
}
static void tunnel_add_servers_from_config(LinphoneTunnel *tunnel, const char* confaddress){
char *addresses=(char*)ms_strdup(confaddress);
char *str1;
for(str1=addresses;;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);
*port++='\0';
linphone_tunnel_add_server(tunnel, address, atoi(port));
}
ms_free(addresses);
}
/**
* Update tunnel using configuration.
*/
void linphone_tunnel_update(LinphoneTunnel *tunnel){
bool_t enabled;
const char* addresses=linphone_tunnel_get_server_addresses(tunnel);
linphone_tunnel_clean_servers(tunnel);
if (addresses){
tunnel_add_servers_from_config(tunnel,addresses);
}
enabled=linphone_tunnel_get_state(tunnel)==LinphoneTunnelEnabled && addresses!=NULL;
linphone_tunnel_enable(tunnel, enabled);
}
......@@ -51,8 +51,8 @@ void linphone_tunnel_set_http_proxy_auth_info(LinphoneTunnel*tunnel, const char*
* LinphoneTunnelState describes the tunnel activation states.
*/
typedef enum _LinphoneTunnelState{
LinphoneTunnelDisabled, /**<The tunnel is always on */
LinphoneTunnelEnabled, /**<The tunnel is always off */
LinphoneTunnelDisabled, /**<The tunnel is always off */
LinphoneTunnelEnabled, /**<The tunnel is always on */
LinphoneTunnelAuto /**<The tunnel is active if needed */
}LinphoneTunnelState;
......@@ -76,6 +76,10 @@ void linphone_tunnel_set_state(LinphoneTunnel *tunnel, LinphoneTunnelState state
**/
LinphoneTunnelState linphone_tunnel_get_state(LinphoneTunnel *tunnel);
/**
* Update tunnel connection after setting new server addresses.
**/
void linphone_tunnel_update(LinphoneTunnel *tunnel);
#ifdef __cplusplus
}
......
......@@ -997,35 +997,8 @@ static void misc_config_read (LinphoneCore *lc) {
lc->max_calls=lp_config_get_int(config,"misc","max_calls",NB_MAX_CALLS);
}
#ifdef TUNNEL_ENABLED
static void tunnel_add_servers_from_config(LinphoneTunnel *tunnel, const char* confaddress){
char *addresses=(char*)ms_strdup(confaddress);
char *str1;
for(str1=addresses;;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);
*port++='\0';
linphone_tunnel_add_server(tunnel, address, atoi(port));
}
ms_free(addresses);
}
#endif
void linphone_core_update_tunnel(LinphoneCore *lc){
#ifdef TUNNEL_ENABLED
bool_t enabled;
const char* addresses=linphone_tunnel_get_server_addresses(lc->tunnel);
if (addresses){
linphone_tunnel_clean_servers(lc->tunnel);
tunnel_add_servers_from_config(lc->tunnel,addresses);
}
enabled=linphone_tunnel_get_state(lc->tunnel)==LinphoneTunnelEnabled && addresses!=NULL;
linphone_tunnel_enable(lc->tunnel, enabled);
#endif
}
static void linphone_core_init (LinphoneCore * lc, const LinphoneCoreVTable *vtable, const char *config_path,
const char *factory_config_path, void * userdata)
......@@ -1125,7 +1098,7 @@ static void linphone_core_init (LinphoneCore * lc, const LinphoneCoreVTable *vta
ui_config_read(lc);
#ifdef TUNNEL_ENABLED
lc->tunnel=linphone_core_tunnel_new(lc);
linphone_core_update_tunnel(lc);
if (lc->tunnel) linphone_tunnel_update(lc->tunnel);
#endif
if (lc->vtable.display_status)
lc->vtable.display_status(lc,_("Ready"));
......
......@@ -1083,10 +1083,6 @@ void linphone_core_init_default_params(LinphoneCore*lc, LinphoneCallParams *para
*/
bool_t linphone_core_tunnel_available(void);
/**
* Update tunnel using configuration.
*/
void linphone_core_update_tunnel(LinphoneCore *lc);
typedef struct LinphoneTunnel LinphoneTunnel;
/**
* get tunnel instance if available
......
......@@ -1003,33 +1003,48 @@ void linphone_gtk_edit_tunnel_closed(GtkWidget *button){
gtk_widget_destroy(pb);
}
#ifdef TUNNEL_ENABLED
static void tunnel_get_server_host_and_port(LinphoneTunnel *tunnel, char *host, int size, int *port){
char *colon;
char *addresses=(char*)ms_strdup(linphone_tunnel_get_server_addresses(tunnel));
char *str1=addresses;
char *address=strtok(str1," "); // Not thread safe
if (!address) return;
colon=strchr(address, ':');
if (!colon) return;
*colon++='\0';
char *addresses;
char *str1;
char *address;
const char* configured_addresses;
#ifdef TUNNEL_ENABLED
configured_addresses=linphone_tunnel_get_server_addresses(tunnel);
#else
configured_addresses=NULL;
#endif
if (configured_addresses==NULL){
host[0]=0;
*port=0;
return;
}
addresses=ms_strdup(configured_addresses);
str1=addresses;
address=strtok(str1," "); // Not thread safe
if (!address) return;
colon=strchr(address, ':');
if (!colon) return;
*colon++='\0';
*port=atoi(colon);
memcpy(host,address,size);
ms_free(addresses);
strncpy(host,address,size);
ms_free(addresses);
}
#endif
void linphone_gtk_edit_tunnel(GtkButton *button){
#ifdef TUNNEL_ENABLED
LinphoneCore *lc=linphone_gtk_get_core();
GtkWidget *w=linphone_gtk_create_window("tunnel_config");
LinphoneTunnel *tunnel=linphone_core_get_tunnel(lc);
char host[50]={'\0'};
char host[128]={'\0'};
int port=0;
tunnel_get_server_host_and_port(tunnel, host, sizeof(host), &port);
LinphoneTunnelState state=linphone_tunnel_get_state(tunnel);
gtk_entry_set_text(GTK_ENTRY(linphone_gtk_get_widget(w,"host")),host);
if (port==0) port=443;
gtk_spin_button_set_value(GTK_SPIN_BUTTON(linphone_gtk_get_widget(w,"port")), port);
if (state == LinphoneTunnelEnabled){
......@@ -1040,16 +1055,14 @@ void linphone_gtk_edit_tunnel(GtkButton *button){
g_object_weak_ref(G_OBJECT(w),(GWeakNotify)linphone_gtk_edit_tunnel_closed,w);
gtk_widget_show(w);
#endif
gtk_widget_show(w);
}
void linphone_gtk_tunnel_ok(GtkButton *button){
#ifdef TUNNEL_ENABLED
// Save information to config file
LinphoneCore *lc=linphone_gtk_get_core();
GtkWidget *w=gtk_widget_get_toplevel(GTK_WIDGET(button));
char address[50]={'\0'};
char address[128]={'\0'};
LinphoneTunnel *tunnel=linphone_core_get_tunnel(lc);
gint port = (gint)gtk_spin_button_get_value(GTK_SPIN_BUTTON(linphone_gtk_get_widget(w,"port")));
......@@ -1057,15 +1070,16 @@ void linphone_gtk_tunnel_ok(GtkButton *button){
const char *host=gtk_entry_get_text(GTK_ENTRY(linphone_gtk_get_widget(w,"host")));
snprintf(address, sizeof address, "%s:%i", host, port);
#ifdef TUNNEL_ENABLED
linphone_tunnel_set_server_addresses(tunnel, address);
if (enabled){
linphone_tunnel_set_state(tunnel, LinphoneTunnelEnabled);
} else{
linphone_tunnel_set_state(tunnel,LinphoneTunnelDisabled);
}
linphone_core_update_tunnel(lc);
gtk_widget_destroy(w);
linphone_tunnel_update(tunnel);
#endif
gtk_widget_destroy(w);
}
......
tunnel @ 31379dba
Subproject commit 7ab47085cf698660e9fe17c2c4f3255cd5d5a8a5
Subproject commit 31379dba112c6d6bafe0522bc72e907458eba1a7
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