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