]> sjero.net Git - linphone/commitdiff
implement setting of http proxy host and port (for tunnel extension) in gtk ui
authorSimon Morlat <simon.morlat@linphone.org>
Tue, 29 May 2012 21:50:35 +0000 (23:50 +0200)
committerSimon Morlat <simon.morlat@linphone.org>
Tue, 29 May 2012 21:51:24 +0000 (23:51 +0200)
coreapi/TunnelManager.cc
coreapi/linphone_tunnel.cc
coreapi/linphone_tunnel.h
gtk/propertybox.c
gtk/tunnel_config.ui

index 3e998cb74bfb99ad2434f2ace5664b06784b412c..44d12251cc06d392ebcef0ebade6596d1aade5a2 100644 (file)
@@ -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{
index d36778bb8be811d71734b867de28d77b15fffe69..9472863732cc1568bcb6aa2eff9b5575cc4cede2 100644 (file)
@@ -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);
 }
index ea49ac8b25a565d6cd078a81ab86ea60e481fc57..5d78fe8f60a2a2728dd7db95cbf38557c2b5c76f 100644 (file)
@@ -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);
 
index 5af25a5c4b2e06ec253b0d4173588678262dc201..809207a2a21df3fd2daf28ca72323ce487c152b3 100644 (file)
@@ -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);
 }
 
index c10ddf257808e4cc6a5476159bd85925f00d0743..4273466130ab000cab81973370d1ccf5b73f3bd7 100644 (file)
@@ -1,14 +1,23 @@
-<?xml version="1.0"?>
+<?xml version="1.0" encoding="UTF-8"?>
 <interface>
-  <requires lib="gtk+" version="2.18"/>
+  <!-- interface-requires gtk+ 3.0 -->
   <!-- interface-naming-policy toplevel-contextual -->
   <object class="GtkAdjustment" id="adjustment1">
-    <property name="value">3600</property>
-    <property name="upper">100000</property>
+    <property name="lower">1</property>
+    <property name="upper">65535</property>
+    <property name="value">443</property>
+    <property name="step_increment">1</property>
+    <property name="page_increment">10</property>
+  </object>
+  <object class="GtkAdjustment" id="adjustment2">
+    <property name="lower">1</property>
+    <property name="upper">65535</property>
+    <property name="value">8080</property>
     <property name="step_increment">1</property>
     <property name="page_increment">10</property>
   </object>
   <object class="GtkDialog" id="tunnel_config">
+    <property name="can_focus">False</property>
     <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
     <property name="border_width">5</property>
     <property name="title" translatable="yes">Linphone - Configure a SIP account</property>
     <child internal-child="vbox">
       <object class="GtkVBox" id="dialog-vbox2">
         <property name="visible">True</property>
+        <property name="can_focus">False</property>
         <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
         <property name="spacing">2</property>
         <child>
           <object class="GtkFrame" id="frame15">
             <property name="visible">True</property>
+            <property name="can_focus">False</property>
             <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
             <property name="label_xalign">0</property>
             <property name="shadow_type">none</property>
             <child>
               <object class="GtkAlignment" id="alignment15">
                 <property name="visible">True</property>
+                <property name="can_focus">False</property>
                 <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
                 <property name="left_padding">12</property>
                 <child>
                   <object class="GtkVBox" id="vbox11">
                     <property name="visible">True</property>
+                    <property name="can_focus">False</property>
                     <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
                     <child>
                       <object class="GtkTable" id="table6">
                         <property name="visible">True</property>
+                        <property name="can_focus">False</property>
                         <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
                         <property name="n_rows">4</property>
                         <property name="n_columns">2</property>
+                        <property name="homogeneous">True</property>
                         <child>
                           <object class="GtkLabel" id="label38">
                             <property name="visible">True</property>
+                            <property name="can_focus">False</property>
                             <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
                             <property name="label" translatable="yes">Host</property>
                             <property name="justify">right</property>
                             <property name="visible">True</property>
                             <property name="can_focus">True</property>
                             <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                            <property name="primary_icon_activatable">False</property>
+                            <property name="secondary_icon_activatable">False</property>
+                            <property name="primary_icon_sensitive">True</property>
+                            <property name="secondary_icon_sensitive">True</property>
                           </object>
                           <packing>
                             <property name="left_attach">1</property>
@@ -64,6 +84,7 @@
                         <child>
                           <object class="GtkLabel" id="label39">
                             <property name="visible">True</property>
+                            <property name="can_focus">False</property>
                             <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
                             <property name="label" translatable="yes">Port</property>
                             <property name="justify">right</property>
                             <property name="bottom_attach">2</property>
                           </packing>
                         </child>
+                        <child>
+                          <object class="GtkSpinButton" id="port">
+                            <property name="visible">True</property>
+                            <property name="can_focus">True</property>
+                            <property name="invisible_char">●</property>
+                            <property name="primary_icon_activatable">False</property>
+                            <property name="secondary_icon_activatable">False</property>
+                            <property name="primary_icon_sensitive">True</property>
+                            <property name="secondary_icon_sensitive">True</property>
+                            <property name="adjustment">adjustment1</property>
+                          </object>
+                          <packing>
+                            <property name="left_attach">1</property>
+                            <property name="right_attach">2</property>
+                            <property name="top_attach">1</property>
+                            <property name="bottom_attach">2</property>
+                          </packing>
+                        </child>
                         <child>
                           <object class="GtkRadioButton" id="radio_enable">
                             <property name="label" translatable="yes">Enable</property>
                             <property name="visible">True</property>
                             <property name="can_focus">True</property>
                             <property name="receives_default">False</property>
+                            <property name="use_action_appearance">False</property>
+                            <property name="xalign">0</property>
                             <property name="active">True</property>
                             <property name="draw_indicator">True</property>
+                            <property name="group">radio_disable</property>
                           </object>
                           <packing>
                             <property name="left_attach">1</property>
                             <property name="visible">True</property>
                             <property name="can_focus">True</property>
                             <property name="receives_default">False</property>
+                            <property name="use_action_appearance">False</property>
+                            <property name="xalign">0</property>
                             <property name="active">True</property>
                             <property name="draw_indicator">True</property>
-                            <property name="group">radio_enable</property>
                           </object>
                           <packing>
                             <property name="left_attach">1</property>
                             <property name="bottom_attach">4</property>
                           </packing>
                         </child>
-                        <child>
-                          <object class="GtkSpinButton" id="port">
-                            <property name="visible">True</property>
-                            <property name="can_focus">True</property>
-                            <property name="invisible_char">&#x25CF;</property>
-                            <property name="adjustment">adjustment1</property>
-                          </object>
-                          <packing>
-                            <property name="left_attach">1</property>
-                            <property name="right_attach">2</property>
-                            <property name="top_attach">1</property>
-                            <property name="bottom_attach">2</property>
-                          </packing>
-                        </child>
                         <child>
                           <placeholder/>
                         </child>
                         </child>
                       </object>
                       <packing>
+                        <property name="expand">True</property>
+                        <property name="fill">True</property>
                         <property name="position">0</property>
                       </packing>
                     </child>
             <child type="label">
               <object class="GtkLabel" id="label42">
                 <property name="visible">True</property>
+                <property name="can_focus">False</property>
                 <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                <property name="label" translatable="yes">Configure tunnel</property>
+                <property name="label" translatable="yes">&lt;b&gt;Configure tunnel&lt;/b&gt;</property>
+                <property name="use_markup">True</property>
+              </object>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkFrame" id="frame1">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="label_xalign">0</property>
+            <property name="shadow_type">none</property>
+            <child>
+              <object class="GtkAlignment" id="alignment1">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="left_padding">12</property>
+                <child>
+                  <object class="GtkTable" id="table1">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="n_rows">4</property>
+                    <property name="n_columns">2</property>
+                    <property name="homogeneous">True</property>
+                    <child>
+                      <object class="GtkLabel" id="label1">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="label" translatable="yes">Host</property>
+                      </object>
+                    </child>
+                    <child>
+                      <object class="GtkLabel" id="label3">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="label" translatable="yes">Port</property>
+                      </object>
+                      <packing>
+                        <property name="top_attach">1</property>
+                        <property name="bottom_attach">2</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkLabel" id="label4">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="label" translatable="yes">Username</property>
+                      </object>
+                      <packing>
+                        <property name="top_attach">2</property>
+                        <property name="bottom_attach">3</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkLabel" id="label5">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="label" translatable="yes">Password</property>
+                      </object>
+                      <packing>
+                        <property name="top_attach">3</property>
+                        <property name="bottom_attach">4</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkSpinButton" id="http_port">
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="invisible_char">●</property>
+                        <property name="primary_icon_activatable">False</property>
+                        <property name="secondary_icon_activatable">False</property>
+                        <property name="primary_icon_sensitive">True</property>
+                        <property name="secondary_icon_sensitive">True</property>
+                        <property name="adjustment">adjustment2</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">1</property>
+                        <property name="right_attach">2</property>
+                        <property name="top_attach">1</property>
+                        <property name="bottom_attach">2</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkEntry" id="http_host">
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="invisible_char">●</property>
+                        <property name="primary_icon_activatable">False</property>
+                        <property name="secondary_icon_activatable">False</property>
+                        <property name="primary_icon_sensitive">True</property>
+                        <property name="secondary_icon_sensitive">True</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">1</property>
+                        <property name="right_attach">2</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkEntry" id="username">
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="invisible_char">●</property>
+                        <property name="primary_icon_activatable">False</property>
+                        <property name="secondary_icon_activatable">False</property>
+                        <property name="primary_icon_sensitive">True</property>
+                        <property name="secondary_icon_sensitive">True</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">1</property>
+                        <property name="right_attach">2</property>
+                        <property name="top_attach">2</property>
+                        <property name="bottom_attach">3</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkEntry" id="password">
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="visibility">False</property>
+                        <property name="invisible_char">●</property>
+                        <property name="primary_icon_activatable">False</property>
+                        <property name="secondary_icon_activatable">False</property>
+                        <property name="primary_icon_sensitive">True</property>
+                        <property name="secondary_icon_sensitive">True</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">1</property>
+                        <property name="right_attach">2</property>
+                        <property name="top_attach">3</property>
+                        <property name="bottom_attach">4</property>
+                      </packing>
+                    </child>
+                  </object>
+                </child>
+              </object>
+            </child>
+            <child type="label">
+              <object class="GtkLabel" id="label2">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="label" translatable="yes">&lt;b&gt;Configure http proxy (optional)&lt;/b&gt;</property>
                 <property name="use_markup">True</property>
               </object>
             </child>
           </object>
           <packing>
+            <property name="expand">True</property>
+            <property name="fill">True</property>
             <property name="position">1</property>
           </packing>
         </child>
         <child internal-child="action_area">
           <object class="GtkHButtonBox" id="dialog-action_area2">
             <property name="visible">True</property>
+            <property name="can_focus">False</property>
             <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
             <property name="layout_style">end</property>
             <child>
                 <property name="can_focus">True</property>
                 <property name="receives_default">True</property>
                 <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                <property name="use_action_appearance">False</property>
                 <property name="use_stock">True</property>
-                <signal name="clicked" handler="linphone_gtk_tunnel_ok"/>
+                <signal name="clicked" handler="linphone_gtk_tunnel_ok" swapped="no"/>
               </object>
               <packing>
                 <property name="expand">False</property>
                 <property name="can_focus">True</property>
                 <property name="receives_default">True</property>
                 <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                <property name="use_action_appearance">False</property>
                 <property name="use_stock">True</property>
-                <signal name="clicked" handler="linphone_gtk_proxy_cancel"/>
+                <signal name="clicked" handler="linphone_gtk_proxy_cancel" swapped="no"/>
               </object>
               <packing>
                 <property name="expand">False</property>
           </object>
           <packing>
             <property name="expand">False</property>
+            <property name="fill">True</property>
             <property name="pack_type">end</property>
-            <property name="position">0</property>
+            <property name="position">2</property>
           </packing>
         </child>
       </object>