[network-manager-applet/lr/import: 5/5] x



commit 895f66c3eb9d452304882e6352be816f8427abd9
Author: Lubomir Rintel <lkundrak v3 sk>
Date:   Thu Oct 20 18:59:38 2016 +0200

    x

 src/connection-editor/page-vpn.c |   55 +++++++++++++++++++++++--------------
 1 files changed, 34 insertions(+), 21 deletions(-)
---
diff --git a/src/connection-editor/page-vpn.c b/src/connection-editor/page-vpn.c
index 1c021c2..7ae8e8d 100644
--- a/src/connection-editor/page-vpn.c
+++ b/src/connection-editor/page-vpn.c
@@ -198,27 +198,16 @@ typedef struct {
        gpointer user_data;
 } ActionInfo;
 
-static void
-import_vpn_from_file_cb (GtkWidget *dialog, gint response, gpointer user_data)
+static NMConnection *
+vpn_import_from_file (const char *filename, NMClient *client)
 {
-       char *filename = NULL;
-       NewVpnInfo *info = (NewVpnInfo *) user_data;
+       NMConnection *connection = NULL;
+       const char *service_type;
        NMSettingConnection *s_con;
        NMSettingVpn *s_vpn;
-       const char *service_type;
-       char *s;
-       GSList *iter;
-       NMConnection *connection = NULL;
        GError *error = NULL;
-
-       if (response != GTK_RESPONSE_ACCEPT)
-               goto out;
-
-       filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
-       if (!filename) {
-               g_warning ("%s: didn't get a filename back from the chooser!", __func__);
-               goto out;
-       }
+       GSList *iter;
+       char *s;
 
        for (iter = vpn_get_plugin_infos (); !connection && iter; iter = iter->next) {
                NMVpnEditorPlugin *plugin;
@@ -240,7 +229,7 @@ import_vpn_from_file_cb (GtkWidget *dialog, gint response, gpointer user_data)
                if (!s) {
                        const GPtrArray *connections;
        
-                       connections = nm_client_get_connections (info->client);
+                       connections = nm_client_get_connections (client);
                        s = ce_page_get_next_available_name (connections, _("VPN connection %d"));
                        g_object_set (s_con, NM_SETTING_CONNECTION_ID, s, NULL);
                        g_free (s);
@@ -267,9 +256,9 @@ import_vpn_from_file_cb (GtkWidget *dialog, gint response, gpointer user_data)
                        error = g_error_new_literal (NMA_ERROR, NMA_ERROR_GENERIC,
                                                     _("The VPN plugin failed to import the VPN connection 
correctly\n\nError: no VPN service type."));
                }
-       
-               info->result_func (connection, FALSE, error, info->user_data);
-       } else {
+       }
+
+       if (!connection) {
                GtkWidget *err_dialog;
                char *bname = g_path_get_basename (filename);
 
@@ -289,6 +278,30 @@ import_vpn_from_file_cb (GtkWidget *dialog, gint response, gpointer user_data)
        }
 
        g_clear_error (&error);
+
+       return connection;
+}
+
+static void
+import_vpn_from_file_cb (GtkWidget *dialog, gint response, gpointer user_data)
+{
+       char *filename = NULL;
+       NewVpnInfo *info = (NewVpnInfo *) user_data;
+       NMConnection *connection = NULL;
+
+       if (response != GTK_RESPONSE_ACCEPT)
+               goto out;
+
+       filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
+       if (!filename) {
+               g_warning ("%s: didn't get a filename back from the chooser!", __func__);
+               goto out;
+       }
+
+       connection = vpn_import_from_file (filename, info->client);
+       if (connection)
+               info->result_func (connection, FALSE, NULL, info->user_data);
+
        g_free (filename);
 out:
        gtk_widget_hide (dialog);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]