[network-manager-vpnc] properties: default new connections to agent-owned secrets
- From: Dan Williams <dcbw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [network-manager-vpnc] properties: default new connections to agent-owned secrets
- Date: Fri, 8 Apr 2011 21:49:52 +0000 (UTC)
commit 05e264a576fd61e217acfbde456bf5a3669caaf0
Author: Dan Williams <dcbw redhat com>
Date: Fri Apr 8 16:50:46 2011 -0500
properties: default new connections to agent-owned secrets
properties/nm-vpnc.c | 31 ++++++++++++++++++++++++++++---
1 files changed, 28 insertions(+), 3 deletions(-)
---
diff --git a/properties/nm-vpnc.c b/properties/nm-vpnc.c
index c1ae60e..54c31b3 100644
--- a/properties/nm-vpnc.c
+++ b/properties/nm-vpnc.c
@@ -87,6 +87,7 @@ typedef struct {
GtkWidget *widget;
GtkSizeGroup *group;
gint orig_dpd_timeout;
+ gboolean new_connection;
} VpncPluginUiWidgetPrivate;
@@ -602,7 +603,8 @@ handle_one_pw_type (NMSettingVPN *s_vpn,
GtkBuilder *builder,
const char *combo_name,
const char *secret_key,
- const char *type_key)
+ const char *type_key,
+ gboolean new_connection)
{
NMSettingSecretFlags flags = NM_SETTING_SECRET_FLAG_NONE;
GtkWidget *widget;
@@ -630,6 +632,11 @@ handle_one_pw_type (NMSettingVPN *s_vpn,
break;
}
+ if (new_connection) {
+ /* new connections default to agent-owned secrets */
+ flags |= NM_SETTING_SECRET_FLAG_AGENT_OWNED;
+ }
+
nm_setting_vpn_add_data_item (s_vpn, type_key, data_val);
nm_setting_set_secret_flags (NM_SETTING (s_vpn), secret_key, flags, NULL);
return pw_type;
@@ -729,12 +736,14 @@ update_connection (NMVpnPluginUiWidgetInterface *iface,
priv->builder,
"user_pass_type_combo",
NM_VPNC_KEY_XAUTH_PASSWORD,
- NM_VPNC_KEY_XAUTH_PASSWORD_TYPE);
+ NM_VPNC_KEY_XAUTH_PASSWORD_TYPE,
+ priv->new_connection);
gpw_type = handle_one_pw_type (s_vpn,
priv->builder,
"group_pass_type_combo",
NM_VPNC_KEY_SECRET,
- NM_VPNC_KEY_SECRET_TYPE);
+ NM_VPNC_KEY_SECRET_TYPE,
+ priv->new_connection);
/* User password */
widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "user_password_entry"));
@@ -839,12 +848,23 @@ save_secrets (NMVpnPluginUiWidgetInterface *iface,
return TRUE;
}
+static void
+is_new_func (const char *key, const char *value, gpointer user_data)
+{
+ gboolean *is_new = user_data;
+
+ /* If there are any VPN data items the connection isn't new */
+ *is_new = FALSE;
+}
+
static NMVpnPluginUiWidgetInterface *
nm_vpn_plugin_ui_widget_interface_new (NMConnection *connection, GError **error)
{
NMVpnPluginUiWidgetInterface *object;
VpncPluginUiWidgetPrivate *priv;
char *ui_file;
+ NMSettingVPN *s_vpn;
+ gboolean new = TRUE;
if (error)
g_return_val_if_fail (*error == NULL, NULL);
@@ -882,6 +902,11 @@ nm_vpn_plugin_ui_widget_interface_new (NMConnection *connection, GError **error)
}
g_object_ref_sink (priv->widget);
+ s_vpn = nm_connection_get_setting_vpn (connection);
+ if (s_vpn)
+ nm_setting_vpn_foreach_data_item (s_vpn, is_new_func, &new);
+ priv->new_connection = new;
+
if (!init_plugin_ui (VPNC_PLUGIN_UI_WIDGET (object), connection, error)) {
g_object_unref (object);
return NULL;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]