[NetworkManager-libreswan/fg/GUI_IKEv2_advanced_options: 6/6] properties: rework and extend the "advanced" dialog in GUI



commit fc7d015187c283a428653ca49fe8dab30413a6fc
Author: Francesco Giudici <fgiudici redhat com>
Date:   Thu Sep 13 18:28:23 2018 +0200

    properties: rework and extend the "advanced" dialog in GUI
    
    Make the advanced section a separate dialog, as we do with the other
    VPN plugins. Add also all the supported options that were still missing
    from the GUI.

 properties/nm-libreswan-dialog.ui | 587 +++++++++++++++++++++++++++++---------
 properties/nm-libreswan-editor.c  |  93 +++++-
 2 files changed, 538 insertions(+), 142 deletions(-)
---
diff --git a/properties/nm-libreswan-dialog.ui b/properties/nm-libreswan-dialog.ui
index c3f243f..0fb5b0f 100644
--- a/properties/nm-libreswan-dialog.ui
+++ b/properties/nm-libreswan-dialog.ui
@@ -353,199 +353,524 @@
       </packing>
     </child>
     <child>
-      <object class="GtkExpander" id="expander1">
-        <property name="width_request">350</property>
-        <property name="height_request">150</property>
+      <object class="GtkAlignment" id="advbutton_alignment">
         <property name="visible">True</property>
-        <property name="can_focus">True</property>
+        <property name="can_focus">False</property>
+        <property name="xalign">1</property>
+        <property name="xscale">0</property>
         <child>
-          <object class="GtkGrid" id="table_advanced">
+          <object class="GtkButton" id="advanced_button">
+            <property name="use_action_appearance">False</property>
             <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <property name="margin_left">12</property>
-            <property name="margin_right">12</property>
-            <property name="orientation">vertical</property>
-            <property name="row_spacing">6</property>
-            <property name="column_spacing">16</property>
+            <property name="can_focus">True</property>
+            <property name="receives_default">False</property>
             <child>
-              <object class="GtkLabel" id="phase1_label">
+              <object class="GtkBox" id="hbox2">
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
-                <property name="label" translatable="yes">Phase1 Algorithms:</property>
-                <property name="use_underline">True</property>
-                <property name="mnemonic_widget">phase1_entry</property>
-                <property name="xalign">0</property>
+                <property name="spacing">6</property>
+                <child>
+                  <object class="GtkImage" id="image1">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="stock">gtk-preferences</property>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">False</property>
+                    <property name="position">0</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkLabel" id="label1">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="label" translatable="yes">Ad_vanced…</property>
+                    <property name="use_underline">True</property>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">False</property>
+                    <property name="position">1</property>
+                  </packing>
+                </child>
               </object>
-              <packing>
-                <property name="left_attach">0</property>
-                <property name="top_attach">0</property>
-              </packing>
             </child>
+          </object>
+        </child>
+      </object>
+      <packing>
+        <property name="expand">False</property>
+        <property name="fill">False</property>
+        <property name="position">2</property>
+      </packing>
+    </child>
+  </object>
+  <object class="GtkSizeGroup" id="labels">
+    <widgets>
+      <widget name="gateway_label"/>
+      <widget name="user_label"/>
+      <widget name="user_password_label"/>
+      <widget name="group_label"/>
+      <widget name="group_password_label"/>
+      <widget name="cert_label"/>
+      <widget name="remoteid_label"/>
+    </widgets>
+  </object>
+  <object class="GtkListStore" id="liststore_yesno">
+    <columns>
+      <!-- column-name gchararray -->
+      <column type="gchararray"/>
+    </columns>
+    <data>
+      <row>
+        <col id="0" translatable="yes">no</col>
+      </row>
+      <row>
+        <col id="0" translatable="yes">yes</col>
+      </row>
+    </data>
+  </object>
+  <object class="GtkListStore" id="liststore_yesnoforce">
+    <columns>
+      <!-- column-name gchararray -->
+      <column type="gchararray"/>
+    </columns>
+    <data>
+      <row>
+        <col id="0" translatable="yes">no</col>
+      </row>
+      <row>
+        <col id="0" translatable="yes">yes</col>
+      </row>
+      <row>
+        <col id="0" translatable="yes">force</col>
+      </row>
+    </data>
+  </object>
+  <object class="GtkDialog" id="libreswan-advanced-dialog">
+    <property name="can_focus">False</property>
+    <property name="border_width">12</property>
+    <property name="type_hint">dialog</property>
+    <child>
+      <placeholder/>
+    </child>
+    <child internal-child="vbox">
+      <object class="GtkBox" id="dialog-vbox1">
+        <property name="can_focus">False</property>
+        <property name="orientation">vertical</property>
+        <property name="spacing">2</property>
+        <child internal-child="action_area">
+          <object class="GtkButtonBox" id="dialog-action_area1">
+            <property name="can_focus">False</property>
+            <property name="layout_style">end</property>
             <child>
-              <object class="GtkEntry" id="phase1_entry">
+              <object class="GtkButton" id="apply_button">
+                <property name="label">gtk-apply</property>
+                <property name="use_action_appearance">False</property>
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
-                <property name="hexpand">True</property>
-                <property name="invisible_char">●</property>
+                <property name="receives_default">True</property>
+                <property name="margin_top">10</property>
+                <property name="use_stock">True</property>
               </object>
               <packing>
-                <property name="left_attach">1</property>
-                <property name="top_attach">0</property>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="position">1</property>
               </packing>
             </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
+            <property name="pack_type">end</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkBox" id="vbox2">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="orientation">vertical</property>
+            <property name="spacing">6</property>
             <child>
-              <object class="GtkLabel" id="phase2_label">
+              <object class="GtkLabel" id="identification_label">
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
-                <property name="label" translatable="yes">Phase2 Algorithms:</property>
-                <property name="use_underline">True</property>
-                <property name="mnemonic_widget">phase2_entry</property>
+                <property name="label" translatable="yes">Identification</property>
                 <property name="xalign">0</property>
+                <attributes>
+                  <attribute name="weight" value="bold"/>
+                </attributes>
               </object>
               <packing>
-                <property name="left_attach">0</property>
-                <property name="top_attach">1</property>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="position">0</property>
               </packing>
             </child>
             <child>
-              <object class="GtkEntry" id="phase2_entry">
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="hexpand">True</property>
-                <property name="invisible_char">●</property>
-              </object>
-              <packing>
-                <property name="left_attach">1</property>
-                <property name="top_attach">1</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkLabel" id="domain_label">
+              <object class="GtkAlignment" id="alignment1_vbox2">
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
-                <property name="label" translatable="yes">Domain:</property>
-                <property name="use_underline">True</property>
-                <property name="mnemonic_widget">domain_entry</property>
-                <property name="xalign">0</property>
-              </object>
-              <packing>
-                <property name="left_attach">0</property>
-                <property name="top_attach">2</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkEntry" id="domain_entry">
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="hexpand">True</property>
-                <property name="invisible_char">●</property>
+                <property name="left_padding">12</property>
+                <child>
+                  <object class="GtkGrid">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="row_spacing">6</property>
+                    <property name="column_spacing">6</property>
+                    <child>
+                      <object class="GtkLabel" id="domain_label">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="label" translatable="yes">Domain:</property>
+                        <property name="use_underline">True</property>
+                        <property name="xalign">0</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">0</property>
+                        <property name="top_attach">0</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkEntry" id="domain_entry">
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="tooltip_text" translatable="yes">(NT-)Domain name for authentication
+config: Domain &lt;domain&gt;</property>
+                        <property name="invisible_char">●</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">1</property>
+                        <property name="top_attach">0</property>
+                      </packing>
+                    </child>
+                  </object>
+                </child>
               </object>
               <packing>
-                <property name="left_attach">1</property>
-                <property name="top_attach">2</property>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="position">1</property>
               </packing>
             </child>
             <child>
-              <object class="GtkLabel" id="phase1_lifetime_label">
+              <object class="GtkLabel" id="security_label">
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
-                <property name="label" translatable="yes">Phase1 Lifetime:</property>
-                <property name="use_underline">True</property>
-                <property name="mnemonic_widget">phase1_lifetime_entry</property>
+                <property name="label" translatable="yes">Security</property>
                 <property name="xalign">0</property>
+                <attributes>
+                  <attribute name="weight" value="bold"/>
+                </attributes>
               </object>
               <packing>
-                <property name="left_attach">0</property>
-                <property name="top_attach">3</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkEntry" id="phase1_lifetime_entry">
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-              </object>
-              <packing>
-                <property name="left_attach">1</property>
-                <property name="top_attach">3</property>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="position">2</property>
               </packing>
             </child>
             <child>
-              <object class="GtkLabel" id="phase2_lifetime_label">
+              <object class="GtkAlignment" id="alignment_vbox2">
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
-                <property name="label" translatable="yes">Phase2 Lifetime:</property>
-                <property name="use_underline">True</property>
-                <property name="mnemonic_widget">phase2_lifetime_entry</property>
-                <property name="single_line_mode">True</property>
-                <property name="xalign">0</property>
-              </object>
-              <packing>
-                <property name="left_attach">0</property>
-                <property name="top_attach">4</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkEntry" id="phase2_lifetime_entry">
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
+                <property name="left_padding">12</property>
+                <child>
+                  <object class="GtkGrid" id="table_advanced1">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="row_spacing">6</property>
+                    <property name="column_spacing">6</property>
+                    <child>
+                      <object class="GtkLabel" id="phase1_label">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="label" translatable="yes">Phase1 Algorithms:</property>
+                        <property name="use_underline">True</property>
+                        <property name="xalign">0</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">0</property>
+                        <property name="top_attach">1</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkEntry" id="phase1_entry">
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="tooltip_text" translatable="yes">IKE encryption/authentication 
algorithm to be used for the connection (phase 1 aka ISAKMP SA). The format is "cipher-hash;modpgroup, 
cipher-hash;modpgroup, ..."
+config: ike &lt;proposals&gt;</property>
+                        <property name="hexpand">True</property>
+                        <property name="invisible_char">●</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">1</property>
+                        <property name="top_attach">1</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkLabel" id="phase2_label">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="label" translatable="yes">Phase2 Algorithms:</property>
+                        <property name="use_underline">True</property>
+                        <property name="xalign">0</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">0</property>
+                        <property name="top_attach">2</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkEntry" id="phase2_entry">
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="tooltip_text" translatable="yes">Specifies the algorithms that will 
be offered/accepted for a phase2 negotiation. The format is "cipher-hash;modpgroup, cipher-hash;modpgroup, 
..."
+config: esp &lt;proposals&gt;</property>
+                        <property name="hexpand">True</property>
+                        <property name="invisible_char">●</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">1</property>
+                        <property name="top_attach">2</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkLabel" id="phase1_lifetime_label">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="label" translatable="yes">Phase1 Lifetime:</property>
+                        <property name="use_underline">True</property>
+                        <property name="xalign">0</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">0</property>
+                        <property name="top_attach">3</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkEntry" id="phase1_lifetime_entry">
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="tooltip_text" translatable="yes">how long the keying channel of a 
connection should last before being renegotiated. The value is expressed by a number followed by an optional 
's'(econds), 'm'(inutes), 'h'(ours) or 'd'(ays)
+config: ikelifetime &lt;lifetime&gt;</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">1</property>
+                        <property name="top_attach">3</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkLabel" id="phase2_lifetime_label">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="label" translatable="yes">Phase2 Lifetime:</property>
+                        <property name="use_underline">True</property>
+                        <property name="single_line_mode">True</property>
+                        <property name="xalign">0</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">0</property>
+                        <property name="top_attach">4</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkEntry" id="phase2_lifetime_entry">
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="tooltip_text" translatable="yes">how long a particular instance of a 
connection (a set of encryption/authentication keys for user packets) should last, from successful 
negotiation to expiry. The value is expressed by a number followed by an optional 's'(econds), 'm'(inutes), 
'h'(ours) or 'd'(ays)
+config: salifetime &lt;lifetime&gt;</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">1</property>
+                        <property name="top_attach">4</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkCheckButton" id="rekey_checkbutton">
+                        <property name="label" translatable="yes">Disable rekeying</property>
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="receives_default">False</property>
+                        <property name="tooltip_text" translatable="yes">whether a connection should not be 
renegotiated when it is about to expire
+config: rekey &lt;no/yes&gt;</property>
+                        <property name="xalign">0</property>
+                        <property name="draw_indicator">True</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">1</property>
+                        <property name="top_attach">5</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <placeholder/>
+                    </child>
+                    <child>
+                      <placeholder/>
+                    </child>
+                    <child>
+                      <placeholder/>
+                    </child>
+                  </object>
+                </child>
               </object>
               <packing>
-                <property name="left_attach">1</property>
-                <property name="top_attach">4</property>
+                <property name="expand">True</property>
+                <property name="fill">True</property>
+                <property name="position">3</property>
               </packing>
             </child>
             <child>
-              <object class="GtkLabel" id="remote_network_label">
+              <object class="GtkLabel" id="connectivity_label">
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
-                <property name="label" translatable="yes">Remote Network:</property>
-                <property name="use_underline">True</property>
-                <property name="mnemonic_widget">remote_network_entry</property>
+                <property name="label" translatable="yes">Connectivity</property>
                 <property name="xalign">0</property>
+                <attributes>
+                  <attribute name="weight" value="bold"/>
+                </attributes>
               </object>
               <packing>
-                <property name="left_attach">0</property>
-                <property name="top_attach">5</property>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="position">4</property>
               </packing>
             </child>
             <child>
-              <object class="GtkEntry" id="remote_network_entry">
+              <object class="GtkAlignment" id="alignment3_vbox2">
                 <property name="visible">True</property>
-                <property name="can_focus">True</property>
+                <property name="can_focus">False</property>
+                <property name="left_padding">12</property>
+                <child>
+                  <object class="GtkGrid">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="row_spacing">6</property>
+                    <property name="column_spacing">6</property>
+                    <child>
+                      <object class="GtkLabel" id="remote_network_label">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="label" translatable="yes">Remote Network:</property>
+                        <property name="use_underline">True</property>
+                        <property name="xalign">0</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">0</property>
+                        <property name="top_attach">0</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkEntry" id="remote_network_entry">
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="tooltip_text" translatable="yes">private subnet behind the remote 
participant, expressed as network/netmask
+config: rightsubnet &lt;net&gt;</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">1</property>
+                        <property name="top_attach">0</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkLabel" id="label_fragmentation">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="label" translatable="yes">Enable fragmentation</property>
+                        <property name="xalign">0</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">0</property>
+                        <property name="top_attach">2</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkComboBox" id="fragmentation_combo">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="hexpand">True</property>
+                        <property name="model">liststore_yesnoforce</property>
+                        <property name="active">1</property>
+                        <child>
+                          <object class="GtkCellRendererText" id="fragmentation_renderer"/>
+                          <attributes>
+                            <attribute name="text">0</attribute>
+                          </attributes>
+                        </child>
+                      </object>
+                      <packing>
+                        <property name="left_attach">1</property>
+                        <property name="top_attach">2</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkCheckButton" id="narrowing_checkbutton">
+                        <property name="label" translatable="yes">narrowing</property>
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="receives_default">False</property>
+                        <property name="tooltip_text" translatable="yes">IKEv2 negotiation may allow 
establishing an IPsec connection with narrowed down traffic selectors. This option is ignored for IKEv1
+config: narrowing &lt;yes/no&gt;</property>
+                        <property name="xalign">0</property>
+                        <property name="draw_indicator">True</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">1</property>
+                        <property name="top_attach">1</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkLabel" id="label_mobike">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="label" translatable="yes">Enable MOBIKE</property>
+                        <property name="xalign">0</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">0</property>
+                        <property name="top_attach">3</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkComboBox" id="mobike_combo">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="model">liststore_yesno</property>
+                        <property name="active">0</property>
+                        <child>
+                          <object class="GtkCellRendererText" id="type_renderer1"/>
+                          <attributes>
+                            <attribute name="text">0</attribute>
+                          </attributes>
+                        </child>
+                      </object>
+                      <packing>
+                        <property name="left_attach">1</property>
+                        <property name="top_attach">3</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <placeholder/>
+                    </child>
+                  </object>
+                </child>
               </object>
               <packing>
-                <property name="left_attach">1</property>
-                <property name="top_attach">5</property>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="position">5</property>
               </packing>
             </child>
           </object>
-        </child>
-        <child type="label">
-          <object class="GtkLabel" id="label_advanced">
-            <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <property name="label" translatable="yes">Ad_vanced</property>
-            <property name="use_underline">True</property>
-            <property name="ellipsize">end</property>
-          </object>
+          <packing>
+            <property name="expand">False</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">2</property>
-      </packing>
     </child>
   </object>
-  <object class="GtkSizeGroup" id="labels">
-    <widgets>
-      <widget name="gateway_label"/>
-      <widget name="user_label"/>
-      <widget name="user_password_label"/>
-      <widget name="group_label"/>
-      <widget name="group_password_label"/>
-      <widget name="cert_label"/>
-      <widget name="remoteid_label"/>
-    </widgets>
-  </object>
 </interface>
diff --git a/properties/nm-libreswan-editor.c b/properties/nm-libreswan-editor.c
index 5164b2b..5bb8e3e 100644
--- a/properties/nm-libreswan-editor.c
+++ b/properties/nm-libreswan-editor.c
@@ -54,6 +54,7 @@ typedef struct {
        GtkBuilder *builder;
        GtkWidget *widget;
        GtkSizeGroup *group;
+       GtkWidget *advanced_dialog;
 } LibreswanEditorPrivate;
 
 #define TYPE_IKEV1_XAUTH 0
@@ -249,6 +250,31 @@ init_password_icon (LibreswanEditor *self,
                          G_CALLBACK (password_storage_changed_cb), self);
 }
 
+static void
+advanced_button_clicked_cb (GtkWidget *button, gpointer user_data)
+{
+       LibreswanEditorPrivate *priv = LIBRESWAN_EDITOR_GET_PRIVATE (user_data);
+       GtkWidget *toplevel;
+
+       if (gtk_widget_get_visible (priv->advanced_dialog))
+               gtk_widget_hide (priv->advanced_dialog);
+       else {
+               toplevel = gtk_widget_get_toplevel (priv->widget);
+               if (gtk_widget_is_toplevel (toplevel))
+                       gtk_window_set_transient_for (GTK_WINDOW (priv->advanced_dialog), GTK_WINDOW 
(toplevel));
+               gtk_widget_show_all (priv->advanced_dialog);
+       }
+}
+
+static GObject *
+get_widget (NMVpnEditor *iface)
+{
+       LibreswanEditor *self = LIBRESWAN_EDITOR (iface);
+       LibreswanEditorPrivate *priv = LIBRESWAN_EDITOR_GET_PRIVATE (self);
+
+       return G_OBJECT (priv->widget);
+}
+
 
 /* Init the widget on the basis of its actual type.
  *  widget_name: the name of the widget
@@ -371,10 +397,10 @@ init_editor_plugin (LibreswanEditor *self,
        widget_updated = init_widget (self, s_vpn, "gateway_entry", NM_LIBRESWAN_KEY_RIGHT, NULL);
        g_return_val_if_fail (widget_updated, FALSE);
 
-       widget_updated = init_widget (self, s_vpn, "group_entry", NM_LIBRESWAN_KEY_LEFTID, NULL);
+       widget_updated = init_widget (self, s_vpn, "user_entry", NM_LIBRESWAN_KEY_LEFTXAUTHUSER, NULL);
        g_return_val_if_fail (widget_updated, FALSE);
 
-       widget_updated = init_widget (self, s_vpn, "user_entry", NM_LIBRESWAN_KEY_LEFTXAUTHUSER, NULL);
+       widget_updated = init_widget (self, s_vpn, "group_entry", NM_LIBRESWAN_KEY_LEFTID, NULL);
        g_return_val_if_fail (widget_updated, FALSE);
 
        widget_updated = init_widget (self, s_vpn, "cert_entry", NM_LIBRESWAN_KEY_LEFTCERT, NULL);
@@ -383,6 +409,11 @@ init_editor_plugin (LibreswanEditor *self,
        widget_updated = init_widget (self, s_vpn, "remoteid_entry", NM_LIBRESWAN_KEY_RIGHTID, NULL);
        g_return_val_if_fail (widget_updated, FALSE);
 
+
+       /* Advanced Dialog */
+       widget_updated = init_widget (self, s_vpn, "domain_entry", NM_LIBRESWAN_KEY_DOMAIN, NULL);
+       g_return_val_if_fail (widget_updated, FALSE);
+
        widget_updated = init_widget (self, s_vpn, "phase1_entry", NM_LIBRESWAN_KEY_IKE, NULL);
        g_return_val_if_fail (widget_updated, FALSE);
 
@@ -395,22 +426,36 @@ init_editor_plugin (LibreswanEditor *self,
        widget_updated = init_widget (self, s_vpn, "phase2_lifetime_entry", NM_LIBRESWAN_KEY_SALIFETIME, 
NULL);
        g_return_val_if_fail (widget_updated, FALSE);
 
-       widget_updated = init_widget (self, s_vpn, "domain_entry", NM_LIBRESWAN_KEY_DOMAIN, NULL);
+       widget_updated = init_widget (self, s_vpn, "rekey_checkbutton", NM_LIBRESWAN_KEY_REKEY, "no");
        g_return_val_if_fail (widget_updated, FALSE);
 
        widget_updated = init_widget (self, s_vpn, "remote_network_entry", NM_LIBRESWAN_KEY_REMOTENETWORK, 
NULL);
        g_return_val_if_fail (widget_updated, FALSE);
 
-       return TRUE;
-}
+       widget_updated = init_widget (self, s_vpn, "narrowing_checkbutton", NM_LIBRESWAN_KEY_NARROWING, 
"yes");
+       g_return_val_if_fail (widget_updated, FALSE);
 
-static GObject *
-get_widget (NMVpnEditor *iface)
-{
-       LibreswanEditor *self = LIBRESWAN_EDITOR (iface);
-       LibreswanEditorPrivate *priv = LIBRESWAN_EDITOR_GET_PRIVATE (self);
+       widget_updated = init_widget (self, s_vpn, "fragmentation_combo", NM_LIBRESWAN_KEY_FRAGMENTATION, 
"force");
+       g_return_val_if_fail (widget_updated, FALSE);
 
-       return G_OBJECT (priv->widget);
+       widget_updated = init_widget (self, s_vpn, "mobike_combo", NM_LIBRESWAN_KEY_MOBIKE, NULL);
+       g_return_val_if_fail (widget_updated, FALSE);
+
+       priv->advanced_dialog = GTK_WIDGET (gtk_builder_get_object (priv->builder, 
"libreswan-advanced-dialog"));
+       g_return_val_if_fail (priv->advanced_dialog != NULL, FALSE);
+
+       g_signal_connect (G_OBJECT (priv->advanced_dialog), "delete-event",
+                         G_CALLBACK (gtk_widget_hide_on_delete), self);
+
+       widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "advanced_button"));
+       g_return_val_if_fail (widget != NULL, FALSE);
+       g_signal_connect (G_OBJECT (widget), "clicked", G_CALLBACK (advanced_button_clicked_cb), self);
+
+       widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "apply_button"));
+       g_return_val_if_fail (widget != NULL, FALSE);
+       g_signal_connect (G_OBJECT (widget), "clicked", G_CALLBACK (advanced_button_clicked_cb), self);
+
+       return TRUE;
 }
 
 static void
@@ -569,6 +614,32 @@ update_connection (NMVpnEditor *iface,
        if (str && *str)
                nm_setting_vpn_add_data_item (s_vpn, NM_LIBRESWAN_KEY_REMOTENETWORK, str);
 
+       /* Disable rekeying */
+       widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "rekey_checkbutton"));
+       if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)))
+               nm_setting_vpn_add_data_item (s_vpn, NM_LIBRESWAN_KEY_REKEY, "no");
+
+       /* Narrowing */
+       widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "narrowing_checkbutton"));
+       if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)))
+               nm_setting_vpn_add_data_item (s_vpn, NM_LIBRESWAN_KEY_NARROWING, "yes");
+
+       /* MOBIKE */
+       widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "mobike_combo"));
+       if (gtk_combo_box_get_active (GTK_COMBO_BOX (widget)) == TYPE_3VL_YES)
+               nm_setting_vpn_add_data_item (s_vpn, NM_LIBRESWAN_KEY_MOBIKE, "yes");
+
+       /* Fragmentation */
+       widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "fragmentation_combo"));
+       switch (gtk_combo_box_get_active (GTK_COMBO_BOX (widget))) {
+       case TYPE_3VL_NO:
+               nm_setting_vpn_add_data_item (s_vpn, NM_LIBRESWAN_KEY_FRAGMENTATION, "no");
+               break;
+       case TYPE_3VL_OTHER:
+               nm_setting_vpn_add_data_item (s_vpn, NM_LIBRESWAN_KEY_FRAGMENTATION, "force");
+               break;
+       }
+
        nm_connection_add_setting (connection, NM_SETTING (s_vpn));
        return TRUE;
 }



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