[network-manager-vpnc/NM_0_8] ui: add IKE DH Group combo to GUI (bgo #638217)



commit f952cdef615a09a8fa39b5f9393b5563238a8d08
Author: JiÅ?í KlimeÅ¡ <jklimes redhat com>
Date:   Fri Jan 14 13:27:07 2011 +0100

    ui: add IKE DH Group combo to GUI (bgo #638217)

 properties/nm-vpnc-dialog.glade |   53 ++++++++++++++++++++++++++++-----------
 properties/nm-vpnc.c            |   46 +++++++++++++++++++++++++++++++++
 src/nm-vpnc-service.h           |    6 +++-
 3 files changed, 89 insertions(+), 16 deletions(-)
---
diff --git a/properties/nm-vpnc-dialog.glade b/properties/nm-vpnc-dialog.glade
index 95f1186..adf9788 100644
--- a/properties/nm-vpnc-dialog.glade
+++ b/properties/nm-vpnc-dialog.glade
@@ -240,21 +240,6 @@
                       <placeholder/>
                     </child>
                     <child>
-                      <widget class="GtkCheckButton" id="disable_dpd_checkbutton">
-                        <property name="visible">True</property>
-                        <property name="can_focus">True</property>
-                        <property name="label" translatable="yes">Disable Dead Peer Detection</property>
-                        <property name="response_id">0</property>
-                        <property name="draw_indicator">True</property>
-                      </widget>
-                      <packing>
-                        <property name="left_attach">1</property>
-                        <property name="right_attach">2</property>
-                        <property name="top_attach">4</property>
-                        <property name="bottom_attach">5</property>
-                      </packing>
-                    </child>
-                    <child>
                       <widget class="GtkComboBox" id="encryption_combo">
                         <property name="visible">True</property>
                         <property name="items" translatable="yes"> </property>
@@ -348,6 +333,44 @@
                         <property name="bottom_attach">4</property>
                       </packing>
                     </child>
+                    <child>
+                      <widget class="GtkLabel" id="label5">
+                        <property name="visible">True</property>
+                        <property name="xalign">0</property>
+                        <property name="label" translatable="yes">IKE DH Group:</property>
+                      </widget>
+                      <packing>
+                        <property name="top_attach">4</property>
+                        <property name="bottom_attach">5</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <widget class="GtkComboBox" id="dhgroup_combo">
+                        <property name="visible">True</property>
+                        <property name="items" translatable="yes"> </property>
+                      </widget>
+                      <packing>
+                        <property name="left_attach">1</property>
+                        <property name="right_attach">2</property>
+                        <property name="top_attach">4</property>
+                        <property name="bottom_attach">5</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <widget class="GtkCheckButton" id="disable_dpd_checkbutton">
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="label" translatable="yes">Disable Dead Peer Detection</property>
+                        <property name="response_id">0</property>
+                        <property name="draw_indicator">True</property>
+                      </widget>
+                      <packing>
+                        <property name="left_attach">1</property>
+                        <property name="right_attach">2</property>
+                        <property name="top_attach">5</property>
+                        <property name="bottom_attach">6</property>
+                      </packing>
+                    </child>
                   </widget>
                 </child>
               </widget>
diff --git a/properties/nm-vpnc.c b/properties/nm-vpnc.c
index e647ef8..6d23d60 100644
--- a/properties/nm-vpnc.c
+++ b/properties/nm-vpnc.c
@@ -380,6 +380,7 @@ init_plugin_ui (VpncPluginUiWidget *self, NMConnection *connection, GError **err
 	const char *value = NULL;
 	int active = -1;
 	const char *natt_mode = NULL;
+	const char *ike_dh_group = NULL;
 
 	s_vpn = (NMSettingVPN *) nm_connection_get_setting (connection, NM_TYPE_SETTING_VPN);
 
@@ -506,6 +507,41 @@ init_plugin_ui (VpncPluginUiWidget *self, NMConnection *connection, GError **err
 	gtk_combo_box_set_active (GTK_COMBO_BOX (widget), active < 0 ? 0 : active);
 	g_signal_connect (G_OBJECT (widget), "changed", G_CALLBACK (stuff_changed_cb), self);
 
+	active = -1;
+	store = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_STRING);
+	if (s_vpn)
+		ike_dh_group = nm_setting_vpn_get_data_item (s_vpn, NM_VPNC_KEY_DHGROUP);
+
+	gtk_list_store_append (store, &iter);
+	gtk_list_store_set (store, &iter, 0, _("DH Group 1"), 1, NM_VPNC_DHGROUP_DH1, -1);
+	if ((active < 0) && ike_dh_group) {
+		if (!strcmp (ike_dh_group, NM_VPNC_DHGROUP_DH1))
+			active = 0;
+	}
+
+	gtk_list_store_append (store, &iter);
+	gtk_list_store_set (store, &iter, 0, _("DH Group 2 (default)"), 1, NM_VPNC_DHGROUP_DH2, -1);
+	if ((active < 0) && ike_dh_group) {
+		if (!strcmp (ike_dh_group, NM_VPNC_DHGROUP_DH2))
+			active = 1;
+	}
+
+	gtk_list_store_append (store, &iter);
+	gtk_list_store_set (store, &iter, 0, _("DH Group 5"), 1, NM_VPNC_DHGROUP_DH5, -1);
+	if ((active < 0) && ike_dh_group) {
+		if (!strcmp (ike_dh_group, NM_VPNC_DHGROUP_DH5))
+			active = 2;
+	}
+
+	widget = glade_xml_get_widget (priv->xml, "dhgroup_combo");
+	g_return_val_if_fail (widget != NULL, FALSE);
+	gtk_size_group_add_widget (priv->group, GTK_WIDGET (widget));
+	gtk_combo_box_set_model (GTK_COMBO_BOX (widget), GTK_TREE_MODEL (store));
+	g_object_unref (store);
+	gtk_combo_box_set_active (GTK_COMBO_BOX (widget), active < 0 ? 1 : active);
+	g_signal_connect (G_OBJECT (widget), "changed", G_CALLBACK (stuff_changed_cb), self);
+
+
 	widget = glade_xml_get_widget (priv->xml, "disable_dpd_checkbutton");
 	g_return_val_if_fail (widget != NULL, FALSE);
 	if (s_vpn) {
@@ -635,6 +671,16 @@ update_connection (NMVpnPluginUiWidgetInterface *iface,
 	} else
 		nm_setting_vpn_add_data_item (s_vpn, NM_VPNC_KEY_NAT_TRAVERSAL_MODE, NM_VPNC_NATT_MODE_NATT);
 
+	widget = glade_xml_get_widget (priv->xml, "dhgroup_combo");
+	model = gtk_combo_box_get_model (GTK_COMBO_BOX (widget));
+	if (gtk_combo_box_get_active_iter (GTK_COMBO_BOX (widget), &iter)) {
+		const char *dhgroup = NULL;
+
+		gtk_tree_model_get (model, &iter, 1, &dhgroup, -1);
+		nm_setting_vpn_add_data_item (s_vpn, NM_VPNC_KEY_DHGROUP, dhgroup);
+	} else
+		nm_setting_vpn_add_data_item (s_vpn, NM_VPNC_KEY_DHGROUP, NM_VPNC_DHGROUP_DH2);
+
 	widget = glade_xml_get_widget (priv->xml, "disable_dpd_checkbutton");
 	if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget))) {
 		nm_setting_vpn_add_data_item (s_vpn, NM_VPNC_KEY_DPD_IDLE_TIMEOUT, "0");
diff --git a/src/nm-vpnc-service.h b/src/nm-vpnc-service.h
index 293d9ca..e3bcbf4 100644
--- a/src/nm-vpnc-service.h
+++ b/src/nm-vpnc-service.h
@@ -15,7 +15,7 @@
  * with this program; if not, write to the Free Software Foundation, Inc.,
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  *
- * (C) Copyright 2005 - 2010 Red Hat, Inc.
+ * (C) Copyright 2005 - 2011 Red Hat, Inc.
  * (C) Copyright 2007 - 2008 Novell, Inc.
  */
 
@@ -65,6 +65,10 @@
 #define NM_VPNC_PW_TYPE_ASK    "ask"
 #define NM_VPNC_PW_TYPE_UNUSED "unused"
 
+#define NM_VPNC_DHGROUP_DH1 "dh1"
+#define NM_VPNC_DHGROUP_DH2 "dh2"
+#define NM_VPNC_DHGROUP_DH5 "dh5"
+
 typedef struct {
 	NMVPNPlugin parent;
 } NMVPNCPlugin;



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