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
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
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);
+}
+
+
+
* 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;
**/
LinphoneTunnelState linphone_tunnel_get_state(LinphoneTunnel *tunnel);
+/**
+ * Update tunnel connection after setting new server addresses.
+**/
+void linphone_tunnel_update(LinphoneTunnel *tunnel);
#ifdef __cplusplus
}
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)
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"));
*/
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
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){
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")));
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);
}
-Subproject commit 7ab47085cf698660e9fe17c2c4f3255cd5d5a8a5
+Subproject commit 31379dba112c6d6bafe0522bc72e907458eba1a7