Update UI equal to nm-pptp 0.9.0

parent eacea0ba
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<requires lib="gtk+" version="2.16"/>
<!-- interface-naming-policy project-wide -->
<object class="GtkDialog" id="l2tp-advanced-dialog">
<property name="can_focus">False</property>
<property name="border_width">5</property>
......@@ -12,12 +11,12 @@
<property name="type_hint">dialog</property>
<property name="skip_pager_hint">True</property>
<child internal-child="vbox">
<object class="GtkVBox" id="dialog-vbox3">
<object class="GtkBox" id="dialog-vbox3">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">2</property>
<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="can_focus">False</property>
<property name="layout_style">end</property>
......@@ -112,13 +111,15 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hscrollbar_policy">never</property>
<property name="vscrollbar_policy">automatic</property>
<property name="shadow_type">in</property>
<child>
<object class="GtkTreeView" id="ppp_auth_methods">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="headers_visible">False</property>
<child internal-child="selection">
<object class="GtkTreeSelection" id="treeview-selection1"/>
</child>
</object>
</child>
</object>
......@@ -450,12 +451,12 @@
<property name="type_hint">dialog</property>
<property name="skip_pager_hint">True</property>
<child internal-child="vbox">
<object class="GtkVBox" id="dialog-vbox2">
<object class="GtkBox" id="dialog-vbox2">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">2</property>
<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="can_focus">False</property>
<property name="layout_style">end</property>
......@@ -563,8 +564,6 @@
<property name="invisible_char"></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>
......@@ -579,8 +578,6 @@
<property name="invisible_char"></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>
......@@ -598,8 +595,6 @@
<property name="invisible_char"></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>
......@@ -623,362 +618,348 @@
<action-widget response="-5">ipsec_ok_button</action-widget>
</action-widgets>
</object>
<object class="GtkWindow" id="l2tp-widget">
<object class="GtkVBox" id="l2tp-vbox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="title" translatable="yes">window1</property>
<property name="border_width">12</property>
<property name="spacing">16</property>
<child>
<object class="GtkVBox" id="l2tp-vbox">
<object class="GtkVBox" id="vbox8">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="border_width">12</property>
<property name="spacing">16</property>
<property name="spacing">6</property>
<child>
<object class="GtkVBox" id="vbox8">
<object class="GtkLabel" id="label22">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">6</property>
<child>
<object class="GtkLabel" id="label22">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">&lt;b&gt;General&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>
<property name="xalign">0</property>
<property name="label" translatable="yes">&lt;b&gt;General&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="alignment8">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="left_padding">12</property>
<child>
<object class="GtkAlignment" id="alignment8">
<object class="GtkTable" id="table2">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="left_padding">12</property>
<property name="n_columns">2</property>
<property name="column_spacing">12</property>
<property name="row_spacing">6</property>
<child>
<object class="GtkEntry" id="gateway_entry">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="primary_icon_activatable">False</property>
<property name="secondary_icon_activatable">False</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<object class="GtkTable" id="table2">
<object class="GtkLabel" id="label23">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="n_columns">2</property>
<property name="column_spacing">12</property>
<property name="row_spacing">6</property>
<child>
<object class="GtkEntry" id="gateway_entry">
<property name="visible">True</property>
<property name="can_focus">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"></property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label23">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">_Gateway:</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">gateway_entry</property>
</object>
<packing>
<property name="x_options">GTK_SHRINK | GTK_FILL</property>
<property name="y_options"></property>
</packing>
</child>
<property name="xalign">0</property>
<property name="label" translatable="yes">_Gateway:</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">gateway_entry</property>
</object>
<packing>
<property name="x_options">GTK_SHRINK | GTK_FILL</property>
<property name="y_options"></property>
</packing>
</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="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">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkVBox" id="vbox11">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">6</property>
<child>
<object class="GtkLabel" id="label25">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">&lt;b&gt;Optional&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="GtkVBox" id="vbox11">
<object class="GtkAlignment" id="alignment9">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">6</property>
<property name="left_padding">12</property>
<child>
<object class="GtkLabel" id="label25">
<object class="GtkTable" id="table3">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">&lt;b&gt;Optional&lt;/b&gt;</property>
<property name="use_markup">True</property>
<property name="n_rows">4</property>
<property name="n_columns">2</property>
<property name="column_spacing">12</property>
<property name="row_spacing">6</property>
<child>
<object class="GtkEntry" id="domain_entry">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="primary_icon_activatable">False</property>
<property name="secondary_icon_activatable">False</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label27">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">NT Domain:</property>
</object>
<packing>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="x_options">GTK_SHRINK | GTK_FILL</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="show_passwords_checkbutton">
<property name="label" translatable="yes">Show password</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="use_action_appearance">False</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<object class="GtkEntry" id="user_password_entry">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="visibility">False</property>
<property name="primary_icon_activatable">False</property>
<property name="secondary_icon_activatable">False</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"></property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label3">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Password:</property>
</object>
<packing>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">GTK_SHRINK | GTK_FILL</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<object class="GtkEntry" id="user_entry">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="primary_icon_activatable">False</property>
<property name="secondary_icon_activatable">False</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label26">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">User name:</property>
</object>
<packing>
<property name="x_options">GTK_SHRINK | GTK_FILL</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</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">1</property>
</packing>
</child>
<child>
<object class="GtkAlignment" id="alignment1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">1</property>
<property name="xscale">0</property>
<child>
<object class="GtkHBox" id="hbox1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkAlignment" id="alignment9">
<object class="GtkButton" id="ipsec_button">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="left_padding">12</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_action_appearance">False</property>
<child>
<object class="GtkTable" id="table3">
<object class="GtkHBox" id="hbox3">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="n_rows">4</property>
<property name="n_columns">2</property>
<property name="column_spacing">12</property>
<property name="row_spacing">6</property>
<child>
<object class="GtkEntry" id="domain_entry">
<property name="visible">True</property>
<property name="can_focus">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">3</property>
<property name="bottom_attach">4</property>
<property name="y_options"></property>
</packing>
</child>
<property name="spacing">6</property>
<child>
<object class="GtkLabel" id="label27">
<object class="GtkImage" id="image2">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">NT Domain:</property>
</object>
<packing>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="x_options">GTK_SHRINK | GTK_FILL</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="show_passwords_checkbutton">
<property name="label" translatable="yes">Show password</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="use_action_appearance">False</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<object class="GtkEntry" id="user_password_entry">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="visibility">False</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>
<property name="stock">gtk-preferences</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"></property>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label3">
<object class="GtkLabel" id="label5">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Password:</property>
</object>
<packing>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">GTK_SHRINK | GTK_FILL</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<object class="GtkEntry" id="user_entry">
<property name="visible">True</property>
<property name="can_focus">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"></property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label26">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">User name:</property>
<property name="label" translatable="yes">_IPsec Settings...</property>
<property name="use_markup">True</property>
<property name="use_underline">True</property>
</object>
<packing>
<property name="x_options">GTK_SHRINK | GTK_FILL</property>
<property name="y_options"></property>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
<child>
<placeholder/>
</child>
</object>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
<property name="position">0</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkAlignment" id="alignment1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">1</property>
<property name="xscale">0</property>
<child>
<object class="GtkHBox" id="hbox1">
<object class="GtkButton" id="advanced_button">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_action_appearance">False</property>
<child>
<object class="GtkButton" id="ipsec_button">
<object class="GtkHBox" id="hbox4">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_action_appearance">False</property>
<property name="can_focus">False</property>
<property name="spacing">6</property>
<child>
<object class="GtkHBox" id="hbox3">
<object class="GtkImage" id="image1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">6</property>
<child>
<object class="GtkImage" id="image2">
<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="label5">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">_IPsec Settings...</property>
<property name="use_markup">True</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>
<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>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkButton" id="advanced_button">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_action_appearance">False</property>
<child>
<object class="GtkHBox" id="hbox4">
<object class="GtkLabel" id="label6">
<property name="visible">True</property>
<property name="can_focus">False</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="label6">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">PPP Se_ttings...</property>
<property name="use_markup">True</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>
<property name="label" translatable="yes">PPP Se_ttings...</property>
<property name="use_markup">True</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="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</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="pack_type">end</property>
<property name="position">2</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="pack_type">end</property>
<property name="position">2</property>
</packing>
</child>
</object>
<object class="GtkListStore" id="model1">
......
......@@ -40,8 +40,7 @@
#include <nm-setting-connection.h>
#include <nm-setting-ip4-config.h>
#include "../src/nm-l2tp-service.h"
#include "../common-gnome/keyring-helpers.h"
#include "src/nm-l2tp-service.h"
#include "nm-l2tp.h"
#include "import-export.h"
#include "advanced-dialog.h"
......@@ -80,6 +79,7 @@ typedef struct {
gboolean window_added;
GHashTable *advanced;
GHashTable *ipsec;
gboolean new_connection;
} L2tpPluginUiWidgetPrivate;
......@@ -218,10 +218,11 @@ advanced_button_clicked_cb (GtkWidget *button, gpointer user_data)
{
L2tpPluginUiWidget *self = L2TP_PLUGIN_UI_WIDGET (user_data);
L2tpPluginUiWidgetPrivate *priv = L2TP_PLUGIN_UI_WIDGET_GET_PRIVATE (self);
GtkWidget *dialog, *toplevel;
GtkWidget *dialog;
GtkWindow *toplevel;
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);
if (!dialog) {
......@@ -247,10 +248,11 @@ ipsec_button_clicked_cb (GtkWidget *button, gpointer user_data)
{
L2tpPluginUiWidget *self = L2TP_PLUGIN_UI_WIDGET (user_data);
L2tpPluginUiWidgetPrivate *priv = L2TP_PLUGIN_UI_WIDGET_GET_PRIVATE (self);
GtkWidget *dialog, *toplevel;
GtkWidget *dialog;
GtkWindow *toplevel;
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);
if (!dialog) {
......@@ -286,65 +288,65 @@ show_toggled_cb (GtkCheckButton *button, L2tpPluginUiWidget *self)
gtk_entry_set_visibility (GTK_ENTRY (widget), visible);
}
static GtkWidget *
fill_password (GtkBuilder *builder,
const char *widget_name,
NMConnection *connection,
const char *password_type)
{
GtkWidget *widget = NULL;
gchar *password = NULL;
NMSettingVPN *s_vpn;
gboolean unused;
widget = GTK_WIDGET (gtk_builder_get_object (builder, widget_name));
g_assert (widget);
if (!connection)
return widget;
/* Try the connection first */
s_vpn = (NMSettingVPN *) nm_connection_get_setting (connection, NM_TYPE_SETTING_VPN);
if (s_vpn) {
const gchar *tmp = NULL;
tmp = nm_setting_vpn_get_secret (s_vpn, password_type);
if (tmp)
password = gnome_keyring_memory_strdup (tmp);
}
if (!password) {
password = keyring_helpers_lookup_secret (nm_connection_get_uuid (connection),
password_type,
&unused);
}
if (password) {
gtk_entry_set_text (GTK_ENTRY (widget), password);
gnome_keyring_memory_free (password);
}
return widget;
}
static void
fill_vpn_passwords (GtkBuilder *builder,
GtkSizeGroup *group,
NMConnection *connection,
ChangedCallback changed_cb,
gpointer user_data)
{
GtkWidget *w = NULL;
w = fill_password (builder, "user_password_entry", connection, NM_L2TP_KEY_PASSWORD);
if (w) {
gtk_size_group_add_widget (group, w);
g_signal_connect (w, "changed", G_CALLBACK (changed_cb), user_data);
} else {
g_error ("No userbuilder in GtkBuilder file!");
}
}
/* static GtkWidget * */
/* fill_password (GtkBuilder *builder, */
/* const char *widget_name, */
/* NMConnection *connection, */
/* const char *password_type) */
/* { */
/* GtkWidget *widget = NULL; */
/* gchar *password = NULL; */
/* NMSettingVPN *s_vpn; */
/* gboolean unused; */
/* widget = GTK_WIDGET (gtk_builder_get_object (builder, widget_name)); */
/* g_assert (widget); */
/* if (!connection) */
/* return widget; */
/* /\* Try the connection first *\/ */
/* s_vpn = (NMSettingVPN *) nm_connection_get_setting (connection, NM_TYPE_SETTING_VPN); */
/* if (s_vpn) { */
/* const gchar *tmp = NULL; */
/* tmp = nm_setting_vpn_get_secret (s_vpn, password_type); */
/* if (tmp) */
/* password = gnome_keyring_memory_strdup (tmp); */
/* } */
/* if (!password) { */
/* password = keyring_helpers_lookup_secret (nm_connection_get_uuid (connection), */
/* password_type, */
/* &unused); */
/* } */
/* if (password) { */
/* gtk_entry_set_text (GTK_ENTRY (widget), password); */
/* gnome_keyring_memory_free (password); */
/* } */
/* return widget; */
/* } */
/* static void */
/* fill_vpn_passwords (GtkBuilder *builder, */
/* GtkSizeGroup *group, */
/* NMConnection *connection, */
/* ChangedCallback changed_cb, */
/* gpointer user_data) */
/* { */
/* GtkWidget *w = NULL; */
/* w = fill_password (builder, "user_password_entry", connection, NM_L2TP_KEY_PASSWORD); */
/* if (w) { */
/* gtk_size_group_add_widget (group, w); */
/* g_signal_connect (w, "changed", G_CALLBACK (changed_cb), user_data); */
/* } else { */
/* g_error ("No userbuilder in GtkBuilder file!"); */
/* } */
/* } */
static gboolean
init_plugin_ui (L2tpPluginUiWidget *self, NMConnection *connection, GError **error)
......@@ -353,6 +355,7 @@ init_plugin_ui (L2tpPluginUiWidget *self, NMConnection *connection, GError **err
NMSettingVPN *s_vpn;
GtkWidget *widget;
const char *value;
NMSettingSecretFlags pw_flags = NM_SETTING_SECRET_FLAG_NONE;
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
(GCallback) show_toggled_cb,
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;
}
......@@ -436,6 +455,7 @@ update_connection (NMVpnPluginUiWidgetInterface *iface,
GtkWidget *widget;
const char *str;
gboolean valid = FALSE;
NMSettingSecretFlags pw_flags;
if (!check_validity (self, error))
return FALSE;
......@@ -455,6 +475,16 @@ update_connection (NMVpnPluginUiWidgetInterface *iface,
if (str && strlen (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 */
widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "domain_entry"));
str = gtk_entry_get_text (GTK_ENTRY (widget));
......@@ -472,41 +502,50 @@ update_connection (NMVpnPluginUiWidgetInterface *iface,
return valid;
}
static gboolean
save_secrets (NMVpnPluginUiWidgetInterface *iface,
NMConnection *connection,
GError **error)
{
L2tpPluginUiWidget *self = L2TP_PLUGIN_UI_WIDGET (iface);
L2tpPluginUiWidgetPrivate *priv = L2TP_PLUGIN_UI_WIDGET_GET_PRIVATE (self);
GnomeKeyringResult ret;
NMSettingConnection *s_con;
GtkWidget *widget;
const char *str, *uuid, *id;
s_con = (NMSettingConnection *) nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION);
if (!s_con) {
g_set_error (error,
L2TP_PLUGIN_UI_ERROR,
L2TP_PLUGIN_UI_ERROR_INVALID_CONNECTION,
"missing 'connection' setting");
return FALSE;
}
/* static gboolean */
/* save_secrets (NMVpnPluginUiWidgetInterface *iface, */
/* NMConnection *connection, */
/* GError **error) */
/* { */
/* L2tpPluginUiWidget *self = L2TP_PLUGIN_UI_WIDGET (iface); */
/* L2tpPluginUiWidgetPrivate *priv = L2TP_PLUGIN_UI_WIDGET_GET_PRIVATE (self); */
/* GnomeKeyringResult ret; */
/* NMSettingConnection *s_con; */
/* GtkWidget *widget; */
/* const char *str, *uuid, *id; */
/* s_con = (NMSettingConnection *) nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION); */
/* if (!s_con) { */
/* g_set_error (error, */
/* L2TP_PLUGIN_UI_ERROR, */
/* L2TP_PLUGIN_UI_ERROR_INVALID_CONNECTION, */
/* "missing 'connection' setting"); */
/* return FALSE; */
/* } */
/* id = nm_setting_connection_get_id (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; */
/* } */
id = nm_setting_connection_get_id (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);
static void
is_new_func (const char *key, const char *value, gpointer user_data)
{
gboolean *is_new = user_data;
return TRUE;
/* If there are any VPN data items the connection isn't new */
*is_new = FALSE;
}
static NMVpnPluginUiWidgetInterface *
......@@ -514,7 +553,9 @@ nm_vpn_plugin_ui_widget_interface_new (NMConnection *connection, GError **error)
{
NMVpnPluginUiWidgetInterface *object;
L2tpPluginUiWidgetPrivate *priv;
char *ui_file;;
char *ui_file;
gboolean new = TRUE;
NMSettingVPN *s_vpn;
if (error)
g_return_val_if_fail (*error == NULL, NULL);
......@@ -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");
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)) {
g_warning ("Couldn't load builder file: %s",
error && *error ? (*error)->message : "(unknown)");
......@@ -537,15 +580,11 @@ nm_vpn_plugin_ui_widget_interface_new (NMConnection *connection, GError **error)
g_set_error(error, L2TP_PLUGIN_UI_ERROR, 0,
"could not load required resources at %s", ui_file);
g_free(ui_file);
g_object_unref(object);
return NULL;
}
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"));
if (!priv->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)
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)) {
g_object_unref (object);
return NULL;
......@@ -591,7 +635,7 @@ dispose (GObject *object)
g_object_unref (priv->widget);
if (priv->builder)
g_object_unref(priv->builder);
g_object_unref (priv->builder);
if (priv->advanced)
g_hash_table_destroy (priv->advanced);
......@@ -623,33 +667,33 @@ l2tp_plugin_ui_widget_interface_init (NMVpnPluginUiWidgetInterface *iface_class)
/* interface implementation */
iface_class->get_widget = get_widget;
iface_class->update_connection = update_connection;
iface_class->save_secrets = save_secrets;
}
static gboolean
delete_connection (NMVpnPluginUiInterface *iface,
NMConnection *connection,
GError **error)
{
NMSettingConnection *s_con = NULL;
const char *uuid;
/* Remove any secrets in the keyring associated with this connection's UUID */
s_con = (NMSettingConnection *) nm_connection_get_setting (connection,
NM_TYPE_SETTING_CONNECTION);
if (!s_con) {
g_set_error (error,
L2TP_PLUGIN_UI_ERROR,
L2TP_PLUGIN_UI_ERROR_INVALID_CONNECTION,
"missing 'connection' setting");
return FALSE;
}
uuid = nm_setting_connection_get_uuid (s_con);
keyring_helpers_delete_secret (uuid, NM_L2TP_KEY_PASSWORD);
return TRUE;
}
// iface_class->save_secrets = save_secrets;
}
/* static gboolean */
/* delete_connection (NMVpnPluginUiInterface *iface, */
/* NMConnection *connection, */
/* GError **error) */
/* { */
/* NMSettingConnection *s_con = NULL; */
/* const char *uuid; */
/* /\* Remove any secrets in the keyring associated with this connection's UUID *\/ */
/* s_con = (NMSettingConnection *) nm_connection_get_setting (connection, */
/* NM_TYPE_SETTING_CONNECTION); */
/* if (!s_con) { */
/* g_set_error (error, */
/* L2TP_PLUGIN_UI_ERROR, */
/* L2TP_PLUGIN_UI_ERROR_INVALID_CONNECTION, */
/* "missing 'connection' setting"); */
/* return FALSE; */
/* } */
/* uuid = nm_setting_connection_get_uuid (s_con); */
/* keyring_helpers_delete_secret (uuid, NM_L2TP_KEY_PASSWORD); */
/* return TRUE; */
/* } */
static NMConnection *
import (NMVpnPluginUiInterface *iface, const char *path, GError **error)
......@@ -789,7 +833,7 @@ l2tp_plugin_ui_interface_init (NMVpnPluginUiInterface *iface_class)
iface_class->import_from_file = import;
iface_class->export_to_file = export;
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