[network-manager-applet/lr/import] fixup! editor: add connection argument to the new page function



commit c54522e5e1584832b2a0ea3c7f30c24d2096a71d
Author: Lubomir Rintel <lkundrak v3 sk>
Date:   Mon Nov 7 20:24:15 2016 +0100

    fixup! editor: add connection argument to the new page function

 src/connection-editor/page-bluetooth.c |   20 ++++++++++----------
 src/connection-editor/page-mobile.c    |   22 +++++++++++-----------
 2 files changed, 21 insertions(+), 21 deletions(-)
---
diff --git a/src/connection-editor/page-bluetooth.c b/src/connection-editor/page-bluetooth.c
index 587536e..45eabdb 100644
--- a/src/connection-editor/page-bluetooth.c
+++ b/src/connection-editor/page-bluetooth.c
@@ -206,6 +206,7 @@ typedef struct {
        PageNewConnectionResultFunc result_func;
        gpointer user_data;
        const gchar *type;
+       NMConnection *connection;
 } WizardInfo;
 
 static void
@@ -215,7 +216,6 @@ new_connection_mobile_wizard_done (NMAMobileWizard *wizard,
                                    gpointer user_data)
 {
        WizardInfo *info = user_data;
-       NMConnection *connection = NULL;
        char *detail = NULL;
        NMSetting *type_setting = NULL;
 
@@ -256,24 +256,25 @@ new_connection_mobile_wizard_done (NMAMobileWizard *wizard,
 
        if (!detail)
                detail = g_strdup (_("Bluetooth connection %d"));
-       connection = nm_simple_connection_new ();
-       ce_page_complete_connection (connection,
+       if (!info->connection)
+               info->connection = nm_simple_connection_new ();
+       ce_page_complete_connection (info->connection,
                                     detail,
                                     NM_SETTING_BLUETOOTH_SETTING_NAME,
                                     FALSE,
                                     info->client);
        g_free (detail);
-       nm_connection_add_setting (connection, nm_setting_bluetooth_new ());
-       g_object_set (nm_connection_get_setting_bluetooth (connection),
+       nm_connection_add_setting (info->connection, nm_setting_bluetooth_new ());
+       g_object_set (nm_connection_get_setting_bluetooth (info->connection),
                      NM_SETTING_BLUETOOTH_TYPE, info->type, NULL);
 
        if (type_setting) {
-               nm_connection_add_setting (connection, type_setting);
-               nm_connection_add_setting (connection, nm_setting_ppp_new ());
+               nm_connection_add_setting (info->connection, type_setting);
+               nm_connection_add_setting (info->connection, nm_setting_ppp_new ());
        }
 
 out:
-       (*info->result_func) (connection, canceled, NULL, info->user_data);
+       (*info->result_func) (info->connection, canceled, NULL, info->user_data);
 
        if (wizard)
                nma_mobile_wizard_destroy (wizard);
@@ -296,13 +297,12 @@ bluetooth_connection_new (GtkWindow *parent,
        WizardInfo *info;
        GtkWidget *dialog, *content, *alignment, *vbox, *label, *dun_radio, *panu_radio;
 
-       g_return_if_fail (!connection);
-
        info = g_malloc0 (sizeof (WizardInfo));
        info->result_func = result_func;
        info->client = g_object_ref (client);
        info->user_data = user_data;
        info->type = NM_SETTING_BLUETOOTH_TYPE_PANU;
+       info->connection = connection;
 
        dialog = gtk_dialog_new_with_buttons (_("Bluetooth Type"),
                                              parent,
diff --git a/src/connection-editor/page-mobile.c b/src/connection-editor/page-mobile.c
index efb6ffe..bd5a477 100644
--- a/src/connection-editor/page-mobile.c
+++ b/src/connection-editor/page-mobile.c
@@ -427,9 +427,10 @@ ce_page_mobile_class_init (CEPageMobileClass *mobile_class)
 }
 
 typedef struct {
-    NMClient *client;
-    PageNewConnectionResultFunc result_func;
-    gpointer user_data;
+       NMClient *client;
+       PageNewConnectionResultFunc result_func;
+       gpointer user_data;
+       NMConnection *connection;
 } WizardInfo;
 
 static void
@@ -439,7 +440,6 @@ new_connection_mobile_wizard_done (NMAMobileWizard *wizard,
                                    gpointer user_data)
 {
        WizardInfo *info = user_data;
-       NMConnection *connection = NULL;
 
        if (!canceled && method) {
                NMSetting *type_setting;
@@ -477,19 +477,20 @@ new_connection_mobile_wizard_done (NMAMobileWizard *wizard,
                        detail = g_strdup_printf ("%s %s %%d", method->provider_name, method->plan_name);
                else
                        detail = g_strdup_printf ("%s connection %%d", method->provider_name);
-               connection = nm_simple_connection_new ();
-               ce_page_complete_connection (connection,
+               if (!info->connection)
+                       info->connection = nm_simple_connection_new ();
+               ce_page_complete_connection (info->connection,
                                             detail,
                                              ctype,
                                              FALSE,
                                              info->client);
                g_free (detail);
 
-               nm_connection_add_setting (connection, type_setting);
-               nm_connection_add_setting (connection, nm_setting_ppp_new ());
+               nm_connection_add_setting (info->connection, type_setting);
+               nm_connection_add_setting (info->connection, nm_setting_ppp_new ());
        }
 
-       (*info->result_func) (connection, canceled, NULL, info->user_data);
+       (*info->result_func) (info->connection, canceled, NULL, info->user_data);
 
        if (wizard)
                nma_mobile_wizard_destroy (wizard);
@@ -520,12 +521,11 @@ mobile_connection_new (GtkWindow *parent,
        gint response;
        NMAMobileWizardAccessMethod method;
 
-       g_return_if_fail (!connection);
-
        info = g_malloc0 (sizeof (WizardInfo));
        info->result_func = result_func;
        info->client = g_object_ref (client);
        info->user_data = user_data;
+       info->connection = connection;
 
        wizard = nma_mobile_wizard_new (parent, NULL, NM_DEVICE_MODEM_CAPABILITY_NONE, FALSE,
                                        new_connection_mobile_wizard_done, info);


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