]> sjero.net Git - linphone/commitdiff
tunnel extension ported to windows (mingw) and working
authorSimon Morlat <simon.morlat@linphone.org>
Mon, 30 Jan 2012 22:47:29 +0000 (23:47 +0100)
committerSimon Morlat <simon.morlat@linphone.org>
Mon, 30 Jan 2012 22:47:29 +0000 (23:47 +0100)
README
README.mingw
coreapi/linphone_tunnel.cc
coreapi/linphone_tunnel.h
coreapi/linphonecore.c
coreapi/linphonecore.h
gtk/propertybox.c
tunnel

diff --git a/README b/README
index 630ca8b75dc89921d18fd90854d2916ba89e8628..7e68bb1996fd378fe4271ce3d58c85a1073902ac 100644 (file)
--- a/README
+++ b/README
@@ -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
 
index 93ba70d46d770779a4640be64a46170dca8d7a39..c35236dcc03daa3f7e98763357f8cc236fe16c1d 100644 (file)
@@ -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
index 120b1b12b9809b9974f31c3e42f743046d70e183..5a341ac7b483c3ddbfb555939688fcaafea2173d 100644 (file)
@@ -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);
+}
+
+
+
index 6a2d5218e00071540be3ead2630667fa9049be2f..fe9675eac0f929d90271cc15ab2abd730a3e6896 100644 (file)
@@ -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
 }
index f045c1a6c76fdbdee982144bd8be891e0df04a8b..735c4705a72648c1f5da98ac47eeaf42a5b50036 100644 (file)
@@ -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"));
index a3cd8d3e0c1470b003e997299800e19b17995f08..306569f1684d0abbdde60d28f9cb18a4d6953179 100644 (file)
@@ -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
index c45f34e31facf5906ee0947fa1531fe177ee623d..dc4086b49e6f5d4de60add3117829b7a437cb9a7 100644 (file)
@@ -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);
 }
 
 
diff --git a/tunnel b/tunnel
index 7ab47085cf698660e9fe17c2c4f3255cd5d5a8a5..31379dba112c6d6bafe0522bc72e907458eba1a7 160000 (submodule)
--- a/tunnel
+++ b/tunnel
@@ -1 +1 @@
-Subproject commit 7ab47085cf698660e9fe17c2c4f3255cd5d5a8a5
+Subproject commit 31379dba112c6d6bafe0522bc72e907458eba1a7