summarylogtreecommitdiffstats
path: root/0007-nm-replace-libgnomeui-with-libnma-for-password-dialo.patch
blob: 0531e5a2a3ade307b3a4716ef5b4547b0e72f877 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
From 76deb2d6678545fab6712edf25aeb89cbaf1f062 Mon Sep 17 00:00:00 2001
From: Lubomir Rintel <lkundrak@v3.sk>
Date: Wed, 21 Oct 2015 11:29:25 +0200
Subject: [PATCH 07/10] nm: replace libgnomeui with libnma for password dialog

libgnomeui is long deprecated.

There's one functional difference: the choice to save the passwords is gone.
The password flags and saved password should be set in the preferences dialog,
but this commit does not fix that.
---
 auth-dialog/Makefile.am |  6 ++---
 auth-dialog/main.c      | 61 ++++++++++++++++++-------------------------------
 configure.ac            |  2 +-
 3 files changed, 26 insertions(+), 43 deletions(-)

diff --git a/auth-dialog/Makefile.am b/auth-dialog/Makefile.am
index 1ebef22..4dcf1d2 100644
--- a/auth-dialog/Makefile.am
+++ b/auth-dialog/Makefile.am
@@ -2,9 +2,9 @@ libexec_PROGRAMS = nm-strongswan-auth-dialog
 
 nm_strongswan_auth_dialog_CPPFLAGS = \
 	$(GTK_CFLAGS) \
-	$(LIBGNOMEUI_CFLAGS) \
 	$(GNOMEKEYRING_CFLAGS) \
 	$(LIBNM_CFLAGS) \
+	$(LIBNMA_CFLAGS) \
 	-DG_DISABLE_DEPRECATED \
 	-DGNOME_DISABLE_DEPRECATED \
 	-DGNOMELOCALEDIR=\"$(datadir)/locale\" \
@@ -15,7 +15,7 @@ nm_strongswan_auth_dialog_SOURCES =	\
 
 nm_strongswan_auth_dialog_LDADD = \
 	$(GTK_LIBS) \
-	$(LIBGNOMEUI_LIBS) \
 	$(GNOMEKEYRING_LIBS) \
-	$(LIBNM_LIBS)
+	$(LIBNM_LIBS) \
+	$(LIBNMA_LIBS)
 
diff --git a/auth-dialog/main.c b/auth-dialog/main.c
index f579fc5..d1f3096 100644
--- a/auth-dialog/main.c
+++ b/auth-dialog/main.c
@@ -1,4 +1,5 @@
 /*
+ * Copyright (C) 2015 Lubomir Rintel
  * Copyright (C) 2008-2011 Martin Willi
  * Hochschule fuer Technik Rapperswil
  * Copyright (C) 2004 Dan Williams
@@ -19,14 +20,16 @@
 #include <config.h>
 #endif
 
+#include <errno.h>
+#include <stdlib.h>
 #include <string.h>
 #include <glib/gi18n.h>
 #include <gtk/gtk.h>
 #include <gnome-keyring.h>
-#include <libgnomeui/libgnomeui.h>
 
 #include <NetworkManager.h>
 #include <nm-vpn-service-plugin.h>
+#include <nma-vpn-password-dialog.h>
 
 #define NM_DBUS_SERVICE_STRONGSWAN	"org.freedesktop.NetworkManager.strongswan"
 
@@ -114,10 +117,10 @@ static char* get_connection_type(char *uuid)
 int main (int argc, char *argv[])
 {
 	gboolean retry = FALSE, allow_interaction = FALSE;
-	gchar *name = NULL, *uuid = NULL, *service = NULL, *keyring = NULL, *pass;
+	gchar *name = NULL, *uuid = NULL, *service = NULL, *pass;
 	GOptionContext *context;
 	char *agent, *type;
-	guint32 itemid, minlen = 0;
+	guint32 minlen = 0;
 	GtkWidget *dialog;
 	GOptionEntry entries[] = {
 		{ "reprompt", 'r', 0, G_OPTION_ARG_NONE, &retry, "Reprompt for passwords", NULL},
@@ -166,66 +169,46 @@ int main (int argc, char *argv[])
 		{
 			if (!strcmp(type, "eap"))
 			{
-				dialog = gnome_password_dialog_new(_("VPN password required"),
-							_("EAP password required to establish VPN connection:"),
-							NULL, NULL, TRUE);
-				gnome_password_dialog_set_show_remember(GNOME_PASSWORD_DIALOG(dialog), TRUE);
+				dialog = nma_vpn_password_dialog_new(_("VPN password required"),
+								     _("EAP password required to establish VPN connection:"),
+								     NULL);
 			}
 			else if (!strcmp(type, "key"))
 			{
-				dialog = gnome_password_dialog_new(_("VPN password required"),
-							_("Private key decryption password required to establish VPN connection:"),
-							NULL, NULL, TRUE);
-				gnome_password_dialog_set_show_remember(GNOME_PASSWORD_DIALOG(dialog), TRUE);
+				dialog = nma_vpn_password_dialog_new(_("VPN password required"),
+								     _("Private key decryption password required to establish VPN connection:"),
+								     NULL);
 			}
 			else if (!strcmp(type, "psk"))
 			{
-				dialog = gnome_password_dialog_new(_("VPN password required"),
-							_("Pre-shared key required to establish VPN connection (min. 20 characters):"),
-							NULL, NULL, TRUE);
-				gnome_password_dialog_set_show_remember(GNOME_PASSWORD_DIALOG(dialog), TRUE);
+				dialog = nma_vpn_password_dialog_new(_("VPN password required"),
+								     _("Pre-shared key required to establish VPN connection (min. 20 characters):"),
+								     NULL);
 				minlen = 20;
 			}
 			else /* smartcard */
 			{
-				dialog = gnome_password_dialog_new(_("VPN password required"),
-							_("Smartcard PIN required to establish VPN connection:"),
-							NULL, NULL, TRUE);
-				gnome_password_dialog_set_show_remember(GNOME_PASSWORD_DIALOG(dialog), FALSE);
+				dialog = nma_vpn_password_dialog_new(_("VPN password required"),
+								     _("Smartcard PIN required to establish VPN connection:"),
+								     NULL);
 			}
-			gnome_password_dialog_set_show_username(GNOME_PASSWORD_DIALOG(dialog), FALSE);
 			if (pass)
 			{
-				gnome_password_dialog_set_password(GNOME_PASSWORD_DIALOG(dialog), pass);
+				nma_vpn_password_dialog_set_password(NMA_VPN_PASSWORD_DIALOG(dialog), pass);
 			}
 
+			gtk_widget_show(dialog);
 too_short_retry:
-			if (!gnome_password_dialog_run_and_block(GNOME_PASSWORD_DIALOG(dialog)))
+			if (!nma_vpn_password_dialog_run_and_block(NMA_VPN_PASSWORD_DIALOG(dialog)))
 			{
 				return 1;
 			}
 
-			pass = gnome_password_dialog_get_password(GNOME_PASSWORD_DIALOG(dialog));
+			pass = g_strdup(nma_vpn_password_dialog_get_password(NMA_VPN_PASSWORD_DIALOG(dialog)));
 			if (minlen && strlen(pass) < minlen)
 			{
 				goto too_short_retry;
 			}
-			switch (gnome_password_dialog_get_remember(GNOME_PASSWORD_DIALOG(dialog)))
-			{
-				case GNOME_PASSWORD_DIALOG_REMEMBER_NOTHING:
-					break;
-				case GNOME_PASSWORD_DIALOG_REMEMBER_SESSION:
-					keyring = "session";
-					/* FALL */
-				case GNOME_PASSWORD_DIALOG_REMEMBER_FOREVER:
-					if (gnome_keyring_set_network_password_sync(keyring,
-							g_get_user_name(), NULL, name, "password", service, NULL, 0,
-							pass, &itemid) != GNOME_KEYRING_RESULT_OK)
-					{
-						g_warning ("storing password in keyring failed");
-					}
-					break;
-			}
 		}
 		if (pass)
 		{
diff --git a/configure.ac b/configure.ac
index 4a16c5b..823ae79 100644
--- a/configure.ac
+++ b/configure.ac
@@ -43,9 +43,9 @@ IT_PROG_INTLTOOL([0.35])
 AM_GLIB_GNU_GETTEXT
 
 PKG_CHECK_MODULES(GTK, gtk+-2.0 >= 2.6)
-PKG_CHECK_MODULES(LIBGNOMEUI, libgnomeui-2.0)
 PKG_CHECK_MODULES(GNOMEKEYRING, gnome-keyring-1)
 PKG_CHECK_MODULES(LIBNM_GLIB, NetworkManager >= 1.1.0 libnm-util libnm-glib libnm-glib-vpn)
+PKG_CHECK_MODULES(LIBNMA, libnma >= 1.1.0)
 
 PKG_CHECK_MODULES(LIBNM, libnm >= 1.1.0)
 LIBNM_CFLAGS="$LIBNM_CFLAGS -DNM_VERSION_MIN_REQUIRED=NM_VERSION_1_2"
-- 
2.4.3