nm: IKE/ESP proposal customization support
authorDefunct <defunct@defunct.io>
Sat, 29 Apr 2017 19:02:36 +0000 (19:02 +0000)
committerTobias Brunner <tobias@strongswan.org>
Mon, 8 May 2017 12:35:27 +0000 (14:35 +0200)
Closes strongswan/strongswan#70.

src/frontends/gnome/properties/nm-strongswan-dialog.ui
src/frontends/gnome/properties/nm-strongswan.c

index 278fd00..e1af547 100644 (file)
         <property name="position">2</property>
       </packing>
     </child>
+    <child>
+      <object class="GtkVBox" id="proposals-vbox">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="spacing">6</property>
+        <child>
+          <object class="GtkLabel" id="proposals-label">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="xalign">0</property>
+            <property name="label" translatable="yes">&lt;b&gt;Cipher proposals&lt;/b&gt;</property>
+            <property name="use_markup">True</property>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">False</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkAlignment" id="proposal-alignment">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="left_padding">12</property>
+            <child>
+              <object class="GtkVBox" id="vbox1">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <child>
+                  <object class="GtkCheckButton" id="proposal-check">
+                    <property name="label" translatable="yes">_Enable custom proposals</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>
+                  </object>
+                  <packing>
+                    <property name="expand">True</property>
+                    <property name="fill">True</property>
+                    <property name="position">0</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkTable" id="proposal-table">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="n_rows">2</property>
+                    <property name="n_columns">2</property>
+                    <property name="column_spacing">6</property>
+                    <property name="row_spacing">6</property>
+                    <child>
+                      <object class="GtkLabel" id="ike-label">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="xalign">0</property>
+                        <property name="ypad">1</property>
+                        <property name="label" translatable="yes">_IKE:</property>
+                        <property name="use_underline">True</property>
+                        <property name="mnemonic_widget">ike-entry</property>
+                      </object>
+                      <packing>
+                        <property name="x_options">GTK_FILL</property>
+                        <property name="y_options"/>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkEntry" id="ike-entry">
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="has_tooltip">True</property>
+                        <property name="tooltip_text" translatable="yes">A list of proposals for IKE seperated by ";". (A suffix of ! enforces strict mode)</property>
+                        <property name="invisible_char">•</property>
+                        <property name="invisible_char_set">True</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="y_options"/>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkLabel" id="esp-label">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="xalign">0</property>
+                        <property name="label" translatable="yes">_ESP:</property>
+                        <property name="use_underline">True</property>
+                        <property name="mnemonic_widget">address-entry</property>
+                      </object>
+                      <packing>
+                        <property name="top_attach">1</property>
+                        <property name="bottom_attach">2</property>
+                        <property name="x_options">GTK_FILL</property>
+                        <property name="y_options"/>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkEntry" id="esp-entry">
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="has_tooltip">True</property>
+                        <property name="tooltip_text" translatable="yes">A list of proposals for ESP seperated by ";". (A suffix of ! enforces strict mode)</property>
+                        <property name="invisible_char">•</property>
+                        <property name="invisible_char_set">True</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">1</property>
+                        <property name="bottom_attach">2</property>
+                        <property name="y_options"/>
+                      </packing>
+                    </child>
+                  </object>
+                  <packing>
+                    <property name="expand">True</property>
+                    <property name="fill">True</property>
+                    <property name="position">1</property>
+                  </packing>
+                </child>
+              </object>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">True</property>
+            <property name="fill">True</property>
+            <property name="position">1</property>
+          </packing>
+        </child>
+      </object>
+      <packing>
+        <property name="expand">False</property>
+        <property name="fill">False</property>
+        <property name="position">3</property>
+      </packing>
+    </child>
   </object>
 </interface>
index b791068..8deaa84 100644 (file)
@@ -229,6 +229,15 @@ show_toggled_cb (GtkCheckButton *button, StrongswanPluginUiWidget *self)
 }
 
 static void
+toggle_proposal_cb(GtkCheckButton *button, StrongswanPluginUiWidget *self)
+{
+       StrongswanPluginUiWidgetPrivate *priv = STRONGSWAN_PLUGIN_UI_WIDGET_GET_PRIVATE (self);
+       gboolean visible = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button));
+       gtk_widget_set_sensitive(GTK_WIDGET(gtk_builder_get_object(priv->builder, "ike-entry")), visible);
+       gtk_widget_set_sensitive(GTK_WIDGET(gtk_builder_get_object(priv->builder, "esp-entry")), visible);
+}
+
+static void
 password_storage_changed_cb (GObject *entry, GParamSpec *pspec, gpointer user_data)
 {
        settings_changed_cb (NULL, STRONGSWAN_PLUGIN_UI_WIDGET (user_data));
@@ -372,6 +381,34 @@ init_plugin_ui (StrongswanPluginUiWidget *self, NMConnection *connection, GError
        }
        g_signal_connect (G_OBJECT (widget), "toggled", G_CALLBACK (settings_changed_cb), self);
 
+       widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "proposal-check"));
+       value = nm_setting_vpn_get_data_item(settings, "proposal");
+       if (value && strcmp(value, "yes") == 0)
+               gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), TRUE);
+       else
+               toggle_proposal_cb(GTK_CHECK_BUTTON(widget), self);
+       g_signal_connect (G_OBJECT (widget), "toggled", G_CALLBACK (toggle_proposal_cb), self);
+
+       widget = GTK_WIDGET(gtk_builder_get_object(priv->builder, "ike-entry"));
+       value = nm_setting_vpn_get_data_item(settings, "ike");
+       if (value)
+       {
+               value = g_strdelimit (g_strdup (value), ";", ',');
+               gtk_entry_set_text (GTK_ENTRY (widget), value);
+               g_free ((char*)value);
+       }
+       g_signal_connect (G_OBJECT (widget), "changed", G_CALLBACK (settings_changed_cb), self);
+
+       widget = GTK_WIDGET(gtk_builder_get_object(priv->builder, "esp-entry"));
+       value = nm_setting_vpn_get_data_item(settings, "esp");
+       if (value)
+       {
+               value = g_strdelimit (g_strdup (value), ";", ',');
+               gtk_entry_set_text (GTK_ENTRY (widget), value);
+               g_free ((char*)value);
+       }
+       g_signal_connect (G_OBJECT (widget), "changed", G_CALLBACK (settings_changed_cb), self);
+
        return TRUE;
 }
 
@@ -507,6 +544,26 @@ update_connection (NMVpnEditor *iface,
        active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
        nm_setting_vpn_add_data_item (settings, "ipcomp", active ? "yes" : "no");
 
+       widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "proposal-check"));
+       active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
+       nm_setting_vpn_add_data_item (settings, "proposal", active ? "yes" : "no");
+
+       widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "ike-entry"));
+       str = (char *) gtk_entry_get_text (GTK_ENTRY (widget));
+       if (str && strlen (str)) {
+               str = g_strdelimit (g_strdup (str), ",", ';');
+               nm_setting_vpn_add_data_item (settings, "ike", str);
+               g_free (str);
+       }
+
+       widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "esp-entry"));
+       str = (char *) gtk_entry_get_text (GTK_ENTRY (widget));
+       if (str && strlen (str)) {
+               str = g_strdelimit (g_strdup (str), ",", ';');
+               nm_setting_vpn_add_data_item (settings, "esp", str);
+               g_free (str);
+       }
+
        nm_connection_add_setting (connection, NM_SETTING (settings));
        return TRUE;
 }