From 3a736cfdb63e63f1ce07062924ae33cfaa737da1 Mon Sep 17 00:00:00 2001 From: Robert Love Date: Mon, 10 Apr 2006 20:05:31 +0000 Subject: [PATCH] 2006-04-10 Robert Love * properties/nm-vpnc.c: Report error if writing out of exported configuration fails. The silent treatment might work for me and my wife, but not for failed I/O. git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@1678 4912f4e0-d625-0410-9fb7-b9a5a253dbdc --- vpn-daemons/vpnc/ChangeLog | 6 ++++++ vpn-daemons/vpnc/auth-dialog/main.c | 2 +- vpn-daemons/vpnc/properties/nm-vpnc.c | 27 ++++++++++++++++++++++----- 3 files changed, 29 insertions(+), 6 deletions(-) diff --git a/vpn-daemons/vpnc/ChangeLog b/vpn-daemons/vpnc/ChangeLog index b122dbf73d..ebbdc90702 100644 --- a/vpn-daemons/vpnc/ChangeLog +++ b/vpn-daemons/vpnc/ChangeLog @@ -1,3 +1,9 @@ +2006-04-10 Robert Love + + * properties/nm-vpnc.c: Report error if writing out of exported + configuration fails. The silent treatment might work for me and my + wife, but not for failed I/O. + 2006-03-29 Robert Love * src/nm-vpnc-service.c: New eigth argument to DBUS VPN method, the diff --git a/vpn-daemons/vpnc/auth-dialog/main.c b/vpn-daemons/vpnc/auth-dialog/main.c index b87117b69c..935cf78e86 100644 --- a/vpn-daemons/vpnc/auth-dialog/main.c +++ b/vpn-daemons/vpnc/auth-dialog/main.c @@ -261,7 +261,7 @@ main (int argc, char *argv[]) gnome_program_init ("nm-vpnc-auth-dialog", VERSION, LIBGNOMEUI_MODULE, argc, argv, - GNOME_PARAM_NONE); + GNOME_PARAM_NONE, GNOME_PARAM_NONE); passwords = get_passwords (vpn_name, vpn_service, retry); if (passwords == NULL) diff --git a/vpn-daemons/vpnc/properties/nm-vpnc.c b/vpn-daemons/vpnc/properties/nm-vpnc.c index 44887d4589..c861fcc892 100644 --- a/vpn-daemons/vpnc/properties/nm-vpnc.c +++ b/vpn-daemons/vpnc/properties/nm-vpnc.c @@ -627,7 +627,7 @@ impl_import_file (NetworkManagerVpnUI *self, const char *path) return import_from_file (impl, path); } -static void +static gboolean export_to_file (NetworkManagerVpnUIImpl *impl, const char *path, GSList *properties, GSList *routes, const char *connection_name) { @@ -638,6 +638,7 @@ export_to_file (NetworkManagerVpnUIImpl *impl, const char *path, const char *username = NULL; const char *domain = NULL; char *routes_str = NULL; + gboolean ret = TRUE; /*printf ("in export_to_file; path='%s'\n", path);*/ @@ -681,7 +682,10 @@ export_to_file (NetworkManagerVpnUIImpl *impl, const char *path, f = fopen (path, "w"); if (f == NULL) + { + ret = FALSE; goto out; + } fprintf (f, "[main]\n" @@ -730,8 +734,9 @@ export_to_file (NetworkManagerVpnUIImpl *impl, const char *path, fclose (f); out: - g_free (routes_str); + + return ret; } @@ -763,7 +768,7 @@ impl_export (NetworkManagerVpnUI *self, GSList *properties, GSList *routes, cons /*printf ("User selected '%s'\n", path);*/ } - + gtk_widget_destroy (dialog); if (path != NULL) { @@ -785,8 +790,20 @@ impl_export (NetworkManagerVpnUI *self, GSList *properties, GSList *routes, cons goto out; } - export_to_file (impl, path, properties, routes, connection_name); - } + if (!export_to_file (impl, path, properties, routes, connection_name)) { + GtkWidget *dialog; + + dialog = gtk_message_dialog_new (NULL, + GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_MESSAGE_WARNING, + GTK_BUTTONS_CLOSE, + _("Failed to export configuration")); + gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog), + _("Failed to save file %s"), path); + gtk_dialog_run (GTK_DIALOG (dialog)); + gtk_widget_destroy (dialog); + } + } out: g_free (path);