[network-manager-openvpn] ui: add UI element for reneg-sec



commit bb54f963cf95d6a723a988f0a2bbb8174a5bd401
Author: Huzaifa S. Sidhpurwala <huzaifas redhat com>
Date:   Wed Sep 23 02:07:41 2009 -0700

    ui: add UI element for reneg-sec

 properties/auth-helpers.c          |   44 ++++++++++
 properties/import-export.c         |   22 +++++
 properties/nm-openvpn-dialog.glade |  156 ++++++++++++++++++++++++------------
 3 files changed, 170 insertions(+), 52 deletions(-)
---
diff --git a/properties/auth-helpers.c b/properties/auth-helpers.c
index 875554b..0fd2e10 100644
--- a/properties/auth-helpers.c
+++ b/properties/auth-helpers.c
@@ -761,6 +761,7 @@ static const char *advanced_keys[] = {
 	NM_OPENVPN_KEY_AUTH,
 	NM_OPENVPN_KEY_TA_DIR,
 	NM_OPENVPN_KEY_TA,
+	NM_OPENVPN_KEY_RENEG_SECONDS,
 	NULL
 };
 
@@ -802,6 +803,16 @@ port_toggled_cb (GtkWidget *check, gpointer user_data)
 	gtk_widget_set_sensitive (widget, gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (check)));
 }
 
+static void
+reneg_toggled_cb (GtkWidget *check, gpointer user_data)
+{
+	GladeXML *xml = (GladeXML *) user_data;
+	GtkWidget *widget;
+
+	widget = glade_xml_get_widget (xml, "reneg_spinbutton");
+	gtk_widget_set_sensitive (widget, gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (check)));
+}
+
 static const char *
 nm_find_openvpn (void)
 {
@@ -1011,6 +1022,30 @@ advanced_dialog_new (GHashTable *hash, const char *contype)
 	                        xml, (GDestroyNotify) g_object_unref);
 	g_object_set_data (G_OBJECT (dialog), "connection-type", GINT_TO_POINTER (contype));
 
+	widget = glade_xml_get_widget (xml, "reneg_checkbutton");
+	g_signal_connect ( G_OBJECT (widget), "toggled", G_CALLBACK (reneg_toggled_cb), xml);
+
+	value = g_hash_table_lookup (hash, NM_OPENVPN_KEY_RENEG_SECONDS);
+	if (value && strlen (value)) {
+		long int tmp;
+
+		errno = 0;
+		tmp = strtol (value, NULL, 10);
+		if (errno == 0 && tmp >= 0 && tmp < 604800) {  /* up to a week? */
+			gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), TRUE);
+
+			widget = glade_xml_get_widget (xml, "reneg_spinbutton");
+			gtk_spin_button_set_value (GTK_SPIN_BUTTON (widget), (gdouble) tmp);
+		}
+		gtk_widget_set_sensitive (widget, TRUE);
+	} else {
+		gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), FALSE);
+
+		widget = glade_xml_get_widget (xml, "reneg_spinbutton");
+		gtk_spin_button_set_value (GTK_SPIN_BUTTON (widget), 0.0);
+		gtk_widget_set_sensitive (widget, FALSE);
+	}
+
 	widget = glade_xml_get_widget (xml, "port_checkbutton");
 	g_signal_connect (G_OBJECT (widget), "toggled", G_CALLBACK (port_toggled_cb), xml);
 
@@ -1136,6 +1171,15 @@ advanced_dialog_new_hash_from_dialog (GtkWidget *dialog, GError **error)
 
 	hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
 
+	widget = glade_xml_get_widget (xml, "reneg_checkbutton");
+	if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget))) {
+		int reneg_seconds;
+
+		widget = glade_xml_get_widget (xml, "reneg_spinbutton");
+		reneg_seconds = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (widget));
+		g_hash_table_insert (hash, g_strdup (NM_OPENVPN_KEY_RENEG_SECONDS), g_strdup_printf ("%d", reneg_seconds));
+	}
+
 	widget = glade_xml_get_widget (xml, "port_checkbutton");
 	if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget))) {
 		int port;
diff --git a/properties/import-export.c b/properties/import-export.c
index c4396f1..5e17dea 100644
--- a/properties/import-export.c
+++ b/properties/import-export.c
@@ -57,6 +57,7 @@
 #define AUTH_USER_PASS_TAG "auth-user-pass"
 #define TLS_AUTH_TAG "tls-auth"
 #define AUTH_TAG "auth"
+#define RENEG_SEC_TAG "reneg-sec"
 
 static gboolean
 handle_path_item (const char *line,
@@ -236,6 +237,27 @@ do_import (const char *path, char **lines, GError **error)
 			continue;
 		}
 
+		if (!strncmp (*line, RENEG_SEC_TAG, strlen (RENEG_SEC_TAG))) {
+			items = get_args (*line + strlen (RENEG_SEC_TAG));
+			if (!items)
+				continue;
+
+			if (g_strv_length (items) >= 1) {
+				glong secs;
+
+				errno = 0;
+				secs = strtol (items[0], NULL, 10);
+				if ((errno == 0) && (secs >= 0) && (secs < 604800)) {
+					char *tmp = g_strdup_printf ("%d", (guint32) secs);
+					nm_setting_vpn_add_data_item (s_vpn, NM_OPENVPN_KEY_RENEG_SECONDS, tmp);
+					g_free (tmp);
+				} else
+					g_warning ("%s: invalid time length in option '%s'", __func__, *line);
+			}
+			g_strfreev (items);
+			continue;
+		}
+
 		if (!strncmp (*line, REMOTE_TAG, strlen (REMOTE_TAG))) {
 			items = get_args (*line + strlen (REMOTE_TAG));
 			if (!items)
diff --git a/properties/nm-openvpn-dialog.glade b/properties/nm-openvpn-dialog.glade
index a42b7c3..f8d011d 100644
--- a/properties/nm-openvpn-dialog.glade
+++ b/properties/nm-openvpn-dialog.glade
@@ -1,7 +1,7 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
-<!--*- mode: xml -*-->
+<?xml version="1.0"?>
 <glade-interface>
+  <!-- interface-requires gtk+ 2.16 -->
+  <!-- interface-naming-policy toplevel-contextual -->
   <widget class="GtkWindow" id="openvpn-widget">
     <property name="title" translatable="yes">window1</property>
     <child>
@@ -23,6 +23,7 @@
               <packing>
                 <property name="expand">False</property>
                 <property name="fill">False</property>
+                <property name="position">0</property>
               </packing>
             </child>
             <child>
@@ -32,7 +33,6 @@
                 <child>
                   <widget class="GtkTable" id="table2">
                     <property name="visible">True</property>
-                    <property name="n_rows">1</property>
                     <property name="n_columns">2</property>
                     <property name="column_spacing">6</property>
                     <property name="row_spacing">6</property>
@@ -77,6 +77,7 @@
           </widget>
           <packing>
             <property name="expand">False</property>
+            <property name="position">0</property>
           </packing>
         </child>
         <child>
@@ -93,6 +94,7 @@
               <packing>
                 <property name="expand">False</property>
                 <property name="fill">False</property>
+                <property name="position">0</property>
               </packing>
             </child>
             <child>
@@ -108,18 +110,18 @@
                     <property name="row_spacing">6</property>
                     <child>
                       <widget class="GtkCheckButton" id="show_passwords">
+                        <property name="label" translatable="yes">Show passwords</property>
                         <property name="visible">True</property>
                         <property name="can_focus">True</property>
-                        <property name="label" translatable="yes">Show passwords</property>
+                        <property name="receives_default">False</property>
                         <property name="use_underline">True</property>
-                        <property name="response_id">0</property>
                         <property name="draw_indicator">True</property>
                       </widget>
                       <packing>
                         <property name="right_attach">2</property>
                         <property name="top_attach">2</property>
                         <property name="bottom_attach">3</property>
-                        <property name="x_options">GTK_FILL</property>
+                        <property name="x_options"></property>
                         <property name="y_options"></property>
                       </packing>
                     </child>
@@ -265,8 +267,8 @@
                             <property name="label">page 1</property>
                           </widget>
                           <packing>
-                            <property name="type">tab</property>
                             <property name="tab_fill">False</property>
+                            <property name="type">tab</property>
                           </packing>
                         </child>
                         <child>
@@ -325,7 +327,6 @@
                               <packing>
                                 <property name="top_attach">1</property>
                                 <property name="bottom_attach">2</property>
-                                <property name="x_options">GTK_FILL</property>
                                 <property name="y_options"></property>
                               </packing>
                             </child>
@@ -338,7 +339,6 @@
                               <packing>
                                 <property name="top_attach">2</property>
                                 <property name="bottom_attach">3</property>
-                                <property name="x_options">GTK_FILL</property>
                                 <property name="y_options"></property>
                               </packing>
                             </child>
@@ -381,9 +381,9 @@
                             <property name="label">page 2</property>
                           </widget>
                           <packing>
-                            <property name="type">tab</property>
                             <property name="position">1</property>
                             <property name="tab_fill">False</property>
+                            <property name="type">tab</property>
                           </packing>
                         </child>
                         <child>
@@ -591,9 +591,9 @@
                             <property name="label">page 3</property>
                           </widget>
                           <packing>
-                            <property name="type">tab</property>
                             <property name="position">2</property>
                             <property name="tab_fill">False</property>
+                            <property name="type">tab</property>
                           </packing>
                         </child>
                         <child>
@@ -628,7 +628,7 @@
                                 <property name="visible">True</property>
                                 <property name="xalign">0</property>
                                 <property name="label" translatable="yes">Remote IP Address:</property>
-                                <property name="justify">GTK_JUSTIFY_RIGHT</property>
+                                <property name="justify">right</property>
                               </widget>
                               <packing>
                                 <property name="top_attach">3</property>
@@ -640,7 +640,7 @@
                                 <property name="visible">True</property>
                                 <property name="xalign">0</property>
                                 <property name="label" translatable="yes">Local IP Address:</property>
-                                <property name="justify">GTK_JUSTIFY_RIGHT</property>
+                                <property name="justify">right</property>
                               </widget>
                               <packing>
                                 <property name="top_attach">4</property>
@@ -648,9 +648,6 @@
                               </packing>
                             </child>
                             <child>
-                              <placeholder/>
-                            </child>
-                            <child>
                               <widget class="GtkAlignment" id="alignment18">
                                 <property name="visible">True</property>
                                 <property name="xalign">1</property>
@@ -752,6 +749,9 @@
                                 <property name="y_options"></property>
                               </packing>
                             </child>
+                            <child>
+                              <placeholder/>
+                            </child>
                           </widget>
                           <packing>
                             <property name="position">3</property>
@@ -763,9 +763,9 @@
                             <property name="label">page 4</property>
                           </widget>
                           <packing>
-                            <property name="type">tab</property>
                             <property name="position">3</property>
                             <property name="tab_fill">False</property>
+                            <property name="type">tab</property>
                           </packing>
                         </child>
                       </widget>
@@ -826,7 +826,7 @@
               <widget class="GtkButton" id="advanced_button">
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
-                <property name="response_id">0</property>
+                <property name="receives_default">False</property>
                 <child>
                   <widget class="GtkHBox" id="hbox2">
                     <property name="visible">True</property>
@@ -835,10 +835,12 @@
                       <widget class="GtkImage" id="image1">
                         <property name="visible">True</property>
                         <property name="stock">gtk-preferences</property>
+                        <property name="icon-size">4</property>
                       </widget>
                       <packing>
                         <property name="expand">False</property>
                         <property name="fill">False</property>
+                        <property name="position">0</property>
                       </packing>
                     </child>
                     <child>
@@ -862,7 +864,7 @@
           <packing>
             <property name="expand">False</property>
             <property name="fill">False</property>
-            <property name="pack_type">GTK_PACK_END</property>
+            <property name="pack_type">end</property>
             <property name="position">2</property>
           </packing>
         </child>
@@ -872,10 +874,10 @@
   <widget class="GtkDialog" id="openvpn-advanced-dialog">
     <property name="border_width">5</property>
     <property name="title" translatable="yes">OpenVPN Advanced Options</property>
-    <property name="window_position">GTK_WIN_POS_CENTER_ON_PARENT</property>
+    <property name="window_position">center-on-parent</property>
     <property name="destroy_with_parent">True</property>
     <property name="icon_name">stock-preferences</property>
-    <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
+    <property name="type_hint">dialog</property>
     <property name="skip_pager_hint">True</property>
     <property name="has_separator">False</property>
     <child internal-child="vbox">
@@ -897,15 +899,16 @@
                     <property name="spacing">6</property>
                     <child>
                       <widget class="GtkCheckButton" id="port_checkbutton">
+                        <property name="label" translatable="yes">Use custom gateway p_ort:</property>
                         <property name="visible">True</property>
                         <property name="can_focus">True</property>
-                        <property name="label" translatable="yes">Use custom gateway p_ort:</property>
+                        <property name="receives_default">False</property>
                         <property name="use_underline">True</property>
-                        <property name="response_id">0</property>
                         <property name="draw_indicator">True</property>
                       </widget>
                       <packing>
                         <property name="expand">False</property>
+                        <property name="position">0</property>
                       </packing>
                     </child>
                     <child>
@@ -925,48 +928,87 @@
                   </widget>
                   <packing>
                     <property name="expand">False</property>
+                    <property name="position">0</property>
+                  </packing>
+                </child>
+                <child>
+                  <widget class="GtkHBox" id="hbox3">
+                    <property name="visible">True</property>
+                    <property name="spacing">6</property>
+                    <child>
+                      <widget class="GtkCheckButton" id="reneg_checkbutton">
+                        <property name="label" translatable="yes">Use custom _renegotiation interval:</property>
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="receives_default">False</property>
+                        <property name="use_underline">True</property>
+                        <property name="draw_indicator">True</property>
+                      </widget>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="position">0</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <widget class="GtkSpinButton" id="reneg_spinbutton">
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="adjustment">0 0 10000 1 10 10</property>
+                        <property name="climb_rate">1</property>
+                        <property name="numeric">True</property>
+                      </widget>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="fill">False</property>
+                        <property name="position">1</property>
+                      </packing>
+                    </child>
+                  </widget>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="position">1</property>
                   </packing>
                 </child>
                 <child>
                   <widget class="GtkCheckButton" id="lzo_checkbutton">
+                    <property name="label" translatable="yes">Use L_ZO data compression</property>
                     <property name="visible">True</property>
                     <property name="can_focus">True</property>
-                    <property name="label" translatable="yes">Use L_ZO data compression</property>
+                    <property name="receives_default">False</property>
                     <property name="use_underline">True</property>
-                    <property name="response_id">0</property>
                     <property name="draw_indicator">True</property>
                   </widget>
                   <packing>
                     <property name="expand">False</property>
-                    <property name="position">1</property>
+                    <property name="position">2</property>
                   </packing>
                 </child>
                 <child>
                   <widget class="GtkCheckButton" id="tcp_checkbutton">
+                    <property name="label" translatable="yes">Use a _TCP connection</property>
                     <property name="visible">True</property>
                     <property name="can_focus">True</property>
-                    <property name="label" translatable="yes">Use a _TCP connection</property>
+                    <property name="receives_default">False</property>
                     <property name="use_underline">True</property>
-                    <property name="response_id">0</property>
                     <property name="draw_indicator">True</property>
                   </widget>
                   <packing>
                     <property name="expand">False</property>
-                    <property name="position">2</property>
+                    <property name="position">3</property>
                   </packing>
                 </child>
                 <child>
                   <widget class="GtkCheckButton" id="tap_checkbutton">
+                    <property name="label" translatable="yes">Use a TA_P device</property>
                     <property name="visible">True</property>
                     <property name="can_focus">True</property>
-                    <property name="label" translatable="yes">Use a TA_P device</property>
+                    <property name="receives_default">False</property>
                     <property name="use_underline">True</property>
-                    <property name="response_id">0</property>
                     <property name="draw_indicator">True</property>
                   </widget>
                   <packing>
                     <property name="expand">False</property>
-                    <property name="position">3</property>
+                    <property name="position">4</property>
                   </packing>
                 </child>
               </widget>
@@ -977,8 +1019,8 @@
                 <property name="label" translatable="yes">General</property>
               </widget>
               <packing>
-                <property name="type">tab</property>
                 <property name="tab_fill">False</property>
+                <property name="type">tab</property>
               </packing>
             </child>
             <child>
@@ -1015,7 +1057,7 @@
                         <property name="label" translatable="yes">Cipher:</property>
                       </widget>
                       <packing>
-                        <property name="x_options">GTK_FILL</property>
+                        <property name="x_options"></property>
                         <property name="y_options"></property>
                       </packing>
                     </child>
@@ -1028,7 +1070,7 @@
                       <packing>
                         <property name="top_attach">1</property>
                         <property name="bottom_attach">2</property>
-                        <property name="x_options">GTK_FILL</property>
+                        <property name="x_options"></property>
                         <property name="y_options"></property>
                       </packing>
                     </child>
@@ -1058,9 +1100,9 @@
                 <property name="label" translatable="yes">Security</property>
               </widget>
               <packing>
-                <property name="type">tab</property>
                 <property name="position">1</property>
                 <property name="tab_fill">False</property>
+                <property name="type">tab</property>
               </packing>
             </child>
             <child>
@@ -1072,15 +1114,12 @@
                 <property name="column_spacing">12</property>
                 <property name="row_spacing">6</property>
                 <child>
-                  <placeholder/>
-                </child>
-                <child>
                   <widget class="GtkCheckButton" id="tls_auth_checkbutton">
+                    <property name="label" translatable="yes">Use additional TLS authentication</property>
                     <property name="visible">True</property>
                     <property name="can_focus">True</property>
-                    <property name="label" translatable="yes">Use additional TLS authentication</property>
+                    <property name="receives_default">False</property>
                     <property name="use_underline">True</property>
-                    <property name="response_id">0</property>
                     <property name="draw_indicator">True</property>
                   </widget>
                   <packing>
@@ -1095,9 +1134,6 @@
                     <property name="column_spacing">12</property>
                     <property name="row_spacing">6</property>
                     <child>
-                      <placeholder/>
-                    </child>
-                    <child>
                       <widget class="GtkLabel" id="direction_label">
                         <property name="visible">True</property>
                         <property name="xalign">0</property>
@@ -1159,6 +1195,9 @@
                         <property name="label" translatable="yes">Key File:</property>
                       </widget>
                     </child>
+                    <child>
+                      <placeholder/>
+                    </child>
                   </widget>
                   <packing>
                     <property name="left_attach">1</property>
@@ -1167,6 +1206,9 @@
                     <property name="bottom_attach">2</property>
                   </packing>
                 </child>
+                <child>
+                  <placeholder/>
+                </child>
               </widget>
               <packing>
                 <property name="position">2</property>
@@ -1178,9 +1220,9 @@
                 <property name="label" translatable="yes">TLS Authentication</property>
               </widget>
               <packing>
-                <property name="type">tab</property>
                 <property name="position">2</property>
                 <property name="tab_fill">False</property>
+                <property name="type">tab</property>
               </packing>
             </child>
           </widget>
@@ -1193,32 +1235,42 @@
         <child internal-child="action_area">
           <widget class="GtkHButtonBox" id="dialog-action_area1">
             <property name="visible">True</property>
-            <property name="layout_style">GTK_BUTTONBOX_END</property>
+            <property name="layout_style">end</property>
             <child>
               <widget class="GtkButton" id="cancel_button">
+                <property name="label">gtk-cancel</property>
+                <property name="response_id">-6</property>
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
-                <property name="label">gtk-cancel</property>
+                <property name="receives_default">False</property>
                 <property name="use_stock">True</property>
-                <property name="response_id">-6</property>
               </widget>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="position">0</property>
+              </packing>
             </child>
             <child>
               <widget class="GtkButton" id="ok_button">
+                <property name="label">gtk-ok</property>
+                <property name="response_id">-5</property>
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
-                <property name="label">gtk-ok</property>
+                <property name="receives_default">False</property>
                 <property name="use_stock">True</property>
-                <property name="response_id">-5</property>
               </widget>
               <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
                 <property name="position">1</property>
               </packing>
             </child>
           </widget>
           <packing>
             <property name="expand">False</property>
-            <property name="pack_type">GTK_PACK_END</property>
+            <property name="pack_type">end</property>
+            <property name="position">0</property>
           </packing>
         </child>
       </widget>



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]