Update UI equal to nm-pptp 0.9.0

parent eacea0ba
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<interface> <interface>
<requires lib="gtk+" version="2.16"/> <requires lib="gtk+" version="2.16"/>
<!-- interface-naming-policy project-wide -->
<object class="GtkDialog" id="l2tp-advanced-dialog"> <object class="GtkDialog" id="l2tp-advanced-dialog">
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="border_width">5</property> <property name="border_width">5</property>
...@@ -12,12 +11,12 @@ ...@@ -12,12 +11,12 @@
<property name="type_hint">dialog</property> <property name="type_hint">dialog</property>
<property name="skip_pager_hint">True</property> <property name="skip_pager_hint">True</property>
<child internal-child="vbox"> <child internal-child="vbox">
<object class="GtkVBox" id="dialog-vbox3"> <object class="GtkBox" id="dialog-vbox3">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="spacing">2</property> <property name="spacing">2</property>
<child internal-child="action_area"> <child internal-child="action_area">
<object class="GtkHButtonBox" id="dialog-action_area3"> <object class="GtkButtonBox" id="dialog-action_area3">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="layout_style">end</property> <property name="layout_style">end</property>
...@@ -112,13 +111,15 @@ ...@@ -112,13 +111,15 @@
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="hscrollbar_policy">never</property> <property name="hscrollbar_policy">never</property>
<property name="vscrollbar_policy">automatic</property>
<property name="shadow_type">in</property> <property name="shadow_type">in</property>
<child> <child>
<object class="GtkTreeView" id="ppp_auth_methods"> <object class="GtkTreeView" id="ppp_auth_methods">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="headers_visible">False</property> <property name="headers_visible">False</property>
<child internal-child="selection">
<object class="GtkTreeSelection" id="treeview-selection1"/>
</child>
</object> </object>
</child> </child>
</object> </object>
...@@ -450,12 +451,12 @@ ...@@ -450,12 +451,12 @@
<property name="type_hint">dialog</property> <property name="type_hint">dialog</property>
<property name="skip_pager_hint">True</property> <property name="skip_pager_hint">True</property>
<child internal-child="vbox"> <child internal-child="vbox">
<object class="GtkVBox" id="dialog-vbox2"> <object class="GtkBox" id="dialog-vbox2">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="spacing">2</property> <property name="spacing">2</property>
<child internal-child="action_area"> <child internal-child="action_area">
<object class="GtkHButtonBox" id="dialog-action_area2"> <object class="GtkButtonBox" id="dialog-action_area2">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="layout_style">end</property> <property name="layout_style">end</property>
...@@ -563,8 +564,6 @@ ...@@ -563,8 +564,6 @@
<property name="invisible_char"></property> <property name="invisible_char"></property>
<property name="primary_icon_activatable">False</property> <property name="primary_icon_activatable">False</property>
<property name="secondary_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> </object>
<packing> <packing>
<property name="left_attach">1</property> <property name="left_attach">1</property>
...@@ -579,8 +578,6 @@ ...@@ -579,8 +578,6 @@
<property name="invisible_char"></property> <property name="invisible_char"></property>
<property name="primary_icon_activatable">False</property> <property name="primary_icon_activatable">False</property>
<property name="secondary_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> </object>
<packing> <packing>
<property name="left_attach">1</property> <property name="left_attach">1</property>
...@@ -598,8 +595,6 @@ ...@@ -598,8 +595,6 @@
<property name="invisible_char"></property> <property name="invisible_char"></property>
<property name="primary_icon_activatable">False</property> <property name="primary_icon_activatable">False</property>
<property name="secondary_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> </object>
<packing> <packing>
<property name="left_attach">1</property> <property name="left_attach">1</property>
...@@ -623,10 +618,6 @@ ...@@ -623,10 +618,6 @@
<action-widget response="-5">ipsec_ok_button</action-widget> <action-widget response="-5">ipsec_ok_button</action-widget>
</action-widgets> </action-widgets>
</object> </object>
<object class="GtkWindow" id="l2tp-widget">
<property name="can_focus">False</property>
<property name="title" translatable="yes">window1</property>
<child>
<object class="GtkVBox" id="l2tp-vbox"> <object class="GtkVBox" id="l2tp-vbox">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
...@@ -669,8 +660,6 @@ ...@@ -669,8 +660,6 @@
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="primary_icon_activatable">False</property> <property name="primary_icon_activatable">False</property>
<property name="secondary_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> </object>
<packing> <packing>
<property name="left_attach">1</property> <property name="left_attach">1</property>
...@@ -746,8 +735,6 @@ ...@@ -746,8 +735,6 @@
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="primary_icon_activatable">False</property> <property name="primary_icon_activatable">False</property>
<property name="secondary_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> </object>
<packing> <packing>
<property name="left_attach">1</property> <property name="left_attach">1</property>
...@@ -795,8 +782,6 @@ ...@@ -795,8 +782,6 @@
<property name="visibility">False</property> <property name="visibility">False</property>
<property name="primary_icon_activatable">False</property> <property name="primary_icon_activatable">False</property>
<property name="secondary_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> </object>
<packing> <packing>
<property name="left_attach">1</property> <property name="left_attach">1</property>
...@@ -826,8 +811,6 @@ ...@@ -826,8 +811,6 @@
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="primary_icon_activatable">False</property> <property name="primary_icon_activatable">False</property>
<property name="secondary_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> </object>
<packing> <packing>
<property name="left_attach">1</property> <property name="left_attach">1</property>
...@@ -979,8 +962,6 @@ ...@@ -979,8 +962,6 @@
</packing> </packing>
</child> </child>
</object> </object>
</child>
</object>
<object class="GtkListStore" id="model1"> <object class="GtkListStore" id="model1">
<columns> <columns>
<!-- column-name gchararray --> <!-- column-name gchararray -->
......
...@@ -40,8 +40,7 @@ ...@@ -40,8 +40,7 @@
#include <nm-setting-connection.h> #include <nm-setting-connection.h>
#include <nm-setting-ip4-config.h> #include <nm-setting-ip4-config.h>
#include "../src/nm-l2tp-service.h" #include "src/nm-l2tp-service.h"
#include "../common-gnome/keyring-helpers.h"
#include "nm-l2tp.h" #include "nm-l2tp.h"
#include "import-export.h" #include "import-export.h"
#include "advanced-dialog.h" #include "advanced-dialog.h"
...@@ -80,6 +79,7 @@ typedef struct { ...@@ -80,6 +79,7 @@ typedef struct {
gboolean window_added; gboolean window_added;
GHashTable *advanced; GHashTable *advanced;
GHashTable *ipsec; GHashTable *ipsec;
gboolean new_connection;
} L2tpPluginUiWidgetPrivate; } L2tpPluginUiWidgetPrivate;
...@@ -218,10 +218,11 @@ advanced_button_clicked_cb (GtkWidget *button, gpointer user_data) ...@@ -218,10 +218,11 @@ advanced_button_clicked_cb (GtkWidget *button, gpointer user_data)
{ {
L2tpPluginUiWidget *self = L2TP_PLUGIN_UI_WIDGET (user_data); L2tpPluginUiWidget *self = L2TP_PLUGIN_UI_WIDGET (user_data);
L2tpPluginUiWidgetPrivate *priv = L2TP_PLUGIN_UI_WIDGET_GET_PRIVATE (self); L2tpPluginUiWidgetPrivate *priv = L2TP_PLUGIN_UI_WIDGET_GET_PRIVATE (self);
GtkWidget *dialog, *toplevel; GtkWidget *dialog;
GtkWindow *toplevel;
toplevel = gtk_widget_get_toplevel (priv->widget); toplevel = gtk_widget_get_toplevel (priv->widget);
g_return_if_fail (GTK_WIDGET_TOPLEVEL (toplevel)); g_return_if_fail (gtk_widget_is_toplevel (toplevel));
dialog = advanced_dialog_new (priv->advanced); dialog = advanced_dialog_new (priv->advanced);
if (!dialog) { if (!dialog) {
...@@ -247,10 +248,11 @@ ipsec_button_clicked_cb (GtkWidget *button, gpointer user_data) ...@@ -247,10 +248,11 @@ ipsec_button_clicked_cb (GtkWidget *button, gpointer user_data)
{ {
L2tpPluginUiWidget *self = L2TP_PLUGIN_UI_WIDGET (user_data); L2tpPluginUiWidget *self = L2TP_PLUGIN_UI_WIDGET (user_data);
L2tpPluginUiWidgetPrivate *priv = L2TP_PLUGIN_UI_WIDGET_GET_PRIVATE (self); L2tpPluginUiWidgetPrivate *priv = L2TP_PLUGIN_UI_WIDGET_GET_PRIVATE (self);
GtkWidget *dialog, *toplevel; GtkWidget *dialog;
GtkWindow *toplevel;
toplevel = gtk_widget_get_toplevel (priv->widget); toplevel = gtk_widget_get_toplevel (priv->widget);
g_return_if_fail (GTK_WIDGET_TOPLEVEL (toplevel)); g_return_if_fail (gtk_widget_is_toplevel (toplevel));
dialog = ipsec_dialog_new (priv->ipsec); dialog = ipsec_dialog_new (priv->ipsec);
if (!dialog) { if (!dialog) {
...@@ -286,65 +288,65 @@ show_toggled_cb (GtkCheckButton *button, L2tpPluginUiWidget *self) ...@@ -286,65 +288,65 @@ show_toggled_cb (GtkCheckButton *button, L2tpPluginUiWidget *self)
gtk_entry_set_visibility (GTK_ENTRY (widget), visible); gtk_entry_set_visibility (GTK_ENTRY (widget), visible);
} }
static GtkWidget * /* static GtkWidget * */
fill_password (GtkBuilder *builder, /* fill_password (GtkBuilder *builder, */
const char *widget_name, /* const char *widget_name, */
NMConnection *connection, /* NMConnection *connection, */
const char *password_type) /* const char *password_type) */
{ /* { */
GtkWidget *widget = NULL; /* GtkWidget *widget = NULL; */
gchar *password = NULL; /* gchar *password = NULL; */
NMSettingVPN *s_vpn; /* NMSettingVPN *s_vpn; */
gboolean unused; /* gboolean unused; */
widget = GTK_WIDGET (gtk_builder_get_object (builder, widget_name)); /* widget = GTK_WIDGET (gtk_builder_get_object (builder, widget_name)); */
g_assert (widget); /* g_assert (widget); */
if (!connection) /* if (!connection) */
return widget; /* return widget; */
/* Try the connection first */ /* /\* Try the connection first *\/ */
s_vpn = (NMSettingVPN *) nm_connection_get_setting (connection, NM_TYPE_SETTING_VPN); /* s_vpn = (NMSettingVPN *) nm_connection_get_setting (connection, NM_TYPE_SETTING_VPN); */
if (s_vpn) { /* if (s_vpn) { */
const gchar *tmp = NULL; /* const gchar *tmp = NULL; */
tmp = nm_setting_vpn_get_secret (s_vpn, password_type); /* tmp = nm_setting_vpn_get_secret (s_vpn, password_type); */
if (tmp) /* if (tmp) */
password = gnome_keyring_memory_strdup (tmp); /* password = gnome_keyring_memory_strdup (tmp); */
} /* } */
if (!password) { /* if (!password) { */
password = keyring_helpers_lookup_secret (nm_connection_get_uuid (connection), /* password = keyring_helpers_lookup_secret (nm_connection_get_uuid (connection), */
password_type, /* password_type, */
&unused); /* &unused); */
} /* } */
if (password) { /* if (password) { */
gtk_entry_set_text (GTK_ENTRY (widget), password); /* gtk_entry_set_text (GTK_ENTRY (widget), password); */
gnome_keyring_memory_free (password); /* gnome_keyring_memory_free (password); */
} /* } */
return widget; /* return widget; */
} /* } */
static void /* static void */
fill_vpn_passwords (GtkBuilder *builder, /* fill_vpn_passwords (GtkBuilder *builder, */
GtkSizeGroup *group, /* GtkSizeGroup *group, */
NMConnection *connection, /* NMConnection *connection, */
ChangedCallback changed_cb, /* ChangedCallback changed_cb, */
gpointer user_data) /* gpointer user_data) */
{ /* { */
GtkWidget *w = NULL; /* GtkWidget *w = NULL; */
w = fill_password (builder, "user_password_entry", connection, NM_L2TP_KEY_PASSWORD); /* w = fill_password (builder, "user_password_entry", connection, NM_L2TP_KEY_PASSWORD); */
if (w) { /* if (w) { */
gtk_size_group_add_widget (group, w); /* gtk_size_group_add_widget (group, w); */
g_signal_connect (w, "changed", G_CALLBACK (changed_cb), user_data); /* g_signal_connect (w, "changed", G_CALLBACK (changed_cb), user_data); */
} else { /* } else { */
g_error ("No userbuilder in GtkBuilder file!"); /* g_error ("No userbuilder in GtkBuilder file!"); */
} /* } */
} /* } */
static gboolean static gboolean
init_plugin_ui (L2tpPluginUiWidget *self, NMConnection *connection, GError **error) init_plugin_ui (L2tpPluginUiWidget *self, NMConnection *connection, GError **error)
...@@ -353,6 +355,7 @@ init_plugin_ui (L2tpPluginUiWidget *self, NMConnection *connection, GError **err ...@@ -353,6 +355,7 @@ init_plugin_ui (L2tpPluginUiWidget *self, NMConnection *connection, GError **err
NMSettingVPN *s_vpn; NMSettingVPN *s_vpn;
GtkWidget *widget; GtkWidget *widget;
const char *value; const char *value;
NMSettingSecretFlags pw_flags = NM_SETTING_SECRET_FLAG_NONE;
s_vpn = (NMSettingVPN *) nm_connection_get_setting (connection, NM_TYPE_SETTING_VPN); s_vpn = (NMSettingVPN *) nm_connection_get_setting (connection, NM_TYPE_SETTING_VPN);
...@@ -403,7 +406,23 @@ init_plugin_ui (L2tpPluginUiWidget *self, NMConnection *connection, GError **err ...@@ -403,7 +406,23 @@ init_plugin_ui (L2tpPluginUiWidget *self, NMConnection *connection, GError **err
(GCallback) show_toggled_cb, (GCallback) show_toggled_cb,
self); self);
fill_vpn_passwords (priv->builder, priv->group, connection, stuff_changed_cb, self); widget = (GtkWidget *) gtk_builder_get_object (priv->builder, "user_password_entry");
g_assert (widget);
gtk_size_group_add_widget (priv->group, widget);
if (s_vpn) {
value = nm_setting_vpn_get_secret (s_vpn, NM_L2TP_KEY_PASSWORD);
if (value)
gtk_entry_set_text (GTK_ENTRY (widget), value);
/* Default to agent-owned for new connections */
if (priv->new_connection)
pw_flags = NM_SETTING_SECRET_FLAG_AGENT_OWNED;
else
nm_setting_get_secret_flags (NM_SETTING (s_vpn), NM_L2TP_KEY_PASSWORD, &pw_flags, NULL);
g_object_set_data (G_OBJECT (widget), "flags", GUINT_TO_POINTER (pw_flags));
}
g_signal_connect (widget, "changed", G_CALLBACK (stuff_changed_cb), self);
return TRUE; return TRUE;
} }
...@@ -436,6 +455,7 @@ update_connection (NMVpnPluginUiWidgetInterface *iface, ...@@ -436,6 +455,7 @@ update_connection (NMVpnPluginUiWidgetInterface *iface,
GtkWidget *widget; GtkWidget *widget;
const char *str; const char *str;
gboolean valid = FALSE; gboolean valid = FALSE;
NMSettingSecretFlags pw_flags;
if (!check_validity (self, error)) if (!check_validity (self, error))
return FALSE; return FALSE;
...@@ -455,6 +475,16 @@ update_connection (NMVpnPluginUiWidgetInterface *iface, ...@@ -455,6 +475,16 @@ update_connection (NMVpnPluginUiWidgetInterface *iface,
if (str && strlen (str)) if (str && strlen (str))
nm_setting_vpn_add_data_item (s_vpn, NM_L2TP_KEY_USER, str); nm_setting_vpn_add_data_item (s_vpn, NM_L2TP_KEY_USER, str);
/* User password */
widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "user_password_entry"));
str = gtk_entry_get_text (GTK_ENTRY (widget));
if (str && strlen (str))
nm_setting_vpn_add_secret (s_vpn, NM_L2TP_KEY_PASSWORD, str);
/* And password flags */
pw_flags = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (widget), "flags"));
nm_setting_set_secret_flags (NM_SETTING (s_vpn), NM_L2TP_KEY_PASSWORD, pw_flags, NULL);
/* Domain */ /* Domain */
widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "domain_entry")); widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "domain_entry"));
str = gtk_entry_get_text (GTK_ENTRY (widget)); str = gtk_entry_get_text (GTK_ENTRY (widget));
...@@ -472,41 +502,50 @@ update_connection (NMVpnPluginUiWidgetInterface *iface, ...@@ -472,41 +502,50 @@ update_connection (NMVpnPluginUiWidgetInterface *iface,
return valid; return valid;
} }
static gboolean /* static gboolean */
save_secrets (NMVpnPluginUiWidgetInterface *iface, /* save_secrets (NMVpnPluginUiWidgetInterface *iface, */
NMConnection *connection, /* NMConnection *connection, */
GError **error) /* GError **error) */
{ /* { */
L2tpPluginUiWidget *self = L2TP_PLUGIN_UI_WIDGET (iface); /* L2tpPluginUiWidget *self = L2TP_PLUGIN_UI_WIDGET (iface); */
L2tpPluginUiWidgetPrivate *priv = L2TP_PLUGIN_UI_WIDGET_GET_PRIVATE (self); /* L2tpPluginUiWidgetPrivate *priv = L2TP_PLUGIN_UI_WIDGET_GET_PRIVATE (self); */
GnomeKeyringResult ret; /* GnomeKeyringResult ret; */
NMSettingConnection *s_con; /* NMSettingConnection *s_con; */
GtkWidget *widget; /* GtkWidget *widget; */
const char *str, *uuid, *id; /* const char *str, *uuid, *id; */
s_con = (NMSettingConnection *) nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION); /* s_con = (NMSettingConnection *) nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION); */
if (!s_con) { /* if (!s_con) { */
g_set_error (error, /* g_set_error (error, */
L2TP_PLUGIN_UI_ERROR, /* L2TP_PLUGIN_UI_ERROR, */
L2TP_PLUGIN_UI_ERROR_INVALID_CONNECTION, /* L2TP_PLUGIN_UI_ERROR_INVALID_CONNECTION, */
"missing 'connection' setting"); /* "missing 'connection' setting"); */
return FALSE; /* return FALSE; */
} /* } */
id = nm_setting_connection_get_id (s_con); /* id = nm_setting_connection_get_id (s_con); */
uuid = nm_setting_connection_get_uuid (s_con); /* uuid = nm_setting_connection_get_uuid (s_con); */
/* widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "user_password_entry")); */
/* g_assert (widget); */
/* str = gtk_entry_get_text (GTK_ENTRY (widget)); */
/* if (str && strlen (str)) { */
/* ret = keyring_helpers_save_secret (uuid, id, NULL, NM_L2TP_KEY_PASSWORD, str); */
/* if (ret != GNOME_KEYRING_RESULT_OK) */
/* g_warning ("%s: failed to save user password to keyring.", __func__); */
/* } else */
/* keyring_helpers_delete_secret (uuid, NM_L2TP_KEY_PASSWORD); */
/* return TRUE; */
/* } */
widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "user_password_entry")); static void
g_assert (widget); is_new_func (const char *key, const char *value, gpointer user_data)
str = gtk_entry_get_text (GTK_ENTRY (widget)); {
if (str && strlen (str)) { gboolean *is_new = user_data;
ret = keyring_helpers_save_secret (uuid, id, NULL, NM_L2TP_KEY_PASSWORD, str);
if (ret != GNOME_KEYRING_RESULT_OK)
g_warning ("%s: failed to save user password to keyring.", __func__);
} else
keyring_helpers_delete_secret (uuid, NM_L2TP_KEY_PASSWORD);
return TRUE; /* If there are any VPN data items the connection isn't new */
*is_new = FALSE;
} }
static NMVpnPluginUiWidgetInterface * static NMVpnPluginUiWidgetInterface *
...@@ -514,7 +553,9 @@ nm_vpn_plugin_ui_widget_interface_new (NMConnection *connection, GError **error) ...@@ -514,7 +553,9 @@ nm_vpn_plugin_ui_widget_interface_new (NMConnection *connection, GError **error)
{ {
NMVpnPluginUiWidgetInterface *object; NMVpnPluginUiWidgetInterface *object;
L2tpPluginUiWidgetPrivate *priv; L2tpPluginUiWidgetPrivate *priv;
char *ui_file;; char *ui_file;
gboolean new = TRUE;
NMSettingVPN *s_vpn;
if (error) if (error)
g_return_val_if_fail (*error == NULL, NULL); g_return_val_if_fail (*error == NULL, NULL);
...@@ -530,6 +571,8 @@ nm_vpn_plugin_ui_widget_interface_new (NMConnection *connection, GError **error) ...@@ -530,6 +571,8 @@ nm_vpn_plugin_ui_widget_interface_new (NMConnection *connection, GError **error)
ui_file = g_strdup_printf ("%s/%s", UIDIR, "nm-l2tp-dialog.ui"); ui_file = g_strdup_printf ("%s/%s", UIDIR, "nm-l2tp-dialog.ui");
priv->builder = gtk_builder_new (); priv->builder = gtk_builder_new ();
gtk_builder_set_translation_domain (priv->builder, GETTEXT_PACKAGE);
if (!gtk_builder_add_from_file(priv->builder, ui_file, error)) { if (!gtk_builder_add_from_file(priv->builder, ui_file, error)) {
g_warning ("Couldn't load builder file: %s", g_warning ("Couldn't load builder file: %s",
error && *error ? (*error)->message : "(unknown)"); error && *error ? (*error)->message : "(unknown)");
...@@ -537,15 +580,11 @@ nm_vpn_plugin_ui_widget_interface_new (NMConnection *connection, GError **error) ...@@ -537,15 +580,11 @@ nm_vpn_plugin_ui_widget_interface_new (NMConnection *connection, GError **error)
g_set_error(error, L2TP_PLUGIN_UI_ERROR, 0, g_set_error(error, L2TP_PLUGIN_UI_ERROR, 0,
"could not load required resources at %s", ui_file); "could not load required resources at %s", ui_file);
g_free(ui_file); g_free(ui_file);
g_object_unref(object); g_object_unref(object);
return NULL; return NULL;
} }
g_free(ui_file); g_free(ui_file);
gtk_builder_set_translation_domain (priv->builder, GETTEXT_PACKAGE);
priv->widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "l2tp-vbox")); priv->widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "l2tp-vbox"));
if (!priv->widget) { if (!priv->widget) {
g_set_error (error, L2TP_PLUGIN_UI_ERROR, 0, "could not load UI widget"); g_set_error (error, L2TP_PLUGIN_UI_ERROR, 0, "could not load UI widget");
...@@ -556,6 +595,11 @@ nm_vpn_plugin_ui_widget_interface_new (NMConnection *connection, GError **error) ...@@ -556,6 +595,11 @@ nm_vpn_plugin_ui_widget_interface_new (NMConnection *connection, GError **error)
priv->window_group = gtk_window_group_new (); priv->window_group = gtk_window_group_new ();
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 (L2TP_PLUGIN_UI_WIDGET (object), connection, error)) { if (!init_plugin_ui (L2TP_PLUGIN_UI_WIDGET (object), connection, error)) {
g_object_unref (object); g_object_unref (object);
return NULL; return NULL;
...@@ -591,7 +635,7 @@ dispose (GObject *object) ...@@ -591,7 +635,7 @@ dispose (GObject *object)
g_object_unref (priv->widget); g_object_unref (priv->widget);
if (priv->builder) if (priv->builder)
g_object_unref(priv->builder); g_object_unref (priv->builder);
if (priv->advanced) if (priv->advanced)
g_hash_table_destroy (priv->advanced); g_hash_table_destroy (priv->advanced);
...@@ -623,33 +667,33 @@ l2tp_plugin_ui_widget_interface_init (NMVpnPluginUiWidgetInterface *iface_class) ...@@ -623,33 +667,33 @@ l2tp_plugin_ui_widget_interface_init (NMVpnPluginUiWidgetInterface *iface_class)
/* interface implementation */ /* interface implementation */
iface_class->get_widget = get_widget; iface_class->get_widget = get_widget;
iface_class->update_connection = update_connection; iface_class->update_connection = update_connection;
iface_class->save_secrets = save_secrets; // iface_class->save_secrets = save_secrets;
} }
static gboolean /* static gboolean */
delete_connection (NMVpnPluginUiInterface *iface, /* delete_connection (NMVpnPluginUiInterface *iface, */
NMConnection *connection, /* NMConnection *connection, */
GError **error) /* GError **error) */
{ /* { */
NMSettingConnection *s_con = NULL; /* NMSettingConnection *s_con = NULL; */
const char *uuid; /* const char *uuid; */
/* Remove any secrets in the keyring associated with this connection's UUID */ /* /\* Remove any secrets in the keyring associated with this connection's UUID *\/ */
s_con = (NMSettingConnection *) nm_connection_get_setting (connection, /* s_con = (NMSettingConnection *) nm_connection_get_setting (connection, */
NM_TYPE_SETTING_CONNECTION); /* NM_TYPE_SETTING_CONNECTION); */
if (!s_con) { /* if (!s_con) { */
g_set_error (error, /* g_set_error (error, */
L2TP_PLUGIN_UI_ERROR, /* L2TP_PLUGIN_UI_ERROR, */
L2TP_PLUGIN_UI_ERROR_INVALID_CONNECTION, /* L2TP_PLUGIN_UI_ERROR_INVALID_CONNECTION, */
"missing 'connection' setting"); /* "missing 'connection' setting"); */
return FALSE; /* return FALSE; */
} /* } */
uuid = nm_setting_connection_get_uuid (s_con); /* uuid = nm_setting_connection_get_uuid (s_con); */
keyring_helpers_delete_secret (uuid, NM_L2TP_KEY_PASSWORD); /* keyring_helpers_delete_secret (uuid, NM_L2TP_KEY_PASSWORD); */
return TRUE; /* return TRUE; */
} /* } */
static NMConnection * static NMConnection *
import (NMVpnPluginUiInterface *iface, const char *path, GError **error) import (NMVpnPluginUiInterface *iface, const char *path, GError **error)
...@@ -789,7 +833,7 @@ l2tp_plugin_ui_interface_init (NMVpnPluginUiInterface *iface_class) ...@@ -789,7 +833,7 @@ l2tp_plugin_ui_interface_init (NMVpnPluginUiInterface *iface_class)
iface_class->import_from_file = import; iface_class->import_from_file = import;
iface_class->export_to_file = export; iface_class->export_to_file = export;
iface_class->get_suggested_name = get_suggested_name; iface_class->get_suggested_name = get_suggested_name;
iface_class->delete_connection = delete_connection; /* iface_class->delete_connection = delete_connection; */
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment