Commit 5c170840 authored by Dan Winship's avatar Dan Winship
Browse files

connection-editor: pass NMRemoteSettings to PageNewConnectionFunc

Rather than passing a PageGetConnectionsFunc that can be called to
indirectly call nm_remote_settings_list_connection(), just pass the
NMRemoteSettings object to the new-connection funcs directly, allowing
them to do other things with it as well.
parent b8ae895a
......@@ -495,7 +495,7 @@ NMConnection *
ce_page_new_connection (const char *format,
const char *ctype,
gboolean autoconnect,
PageGetConnectionsFunc get_connections_func,
NMRemoteSettings *settings,
gpointer user_data)
{
NMConnection *connection;
......@@ -510,7 +510,7 @@ ce_page_new_connection (const char *format,
uuid = nm_utils_uuid_generate ();
connections = (*get_connections_func) (user_data);
connections = nm_remote_settings_list_connections (settings);
id = ce_page_get_next_available_name (connections, format);
g_slist_free (connections);
......
......@@ -31,6 +31,7 @@
#include <dbus/dbus-glib.h>
#include <nm-connection.h>
#include <nm-client.h>
#include <nm-remote-settings.h>
#include "utils.h"
typedef void (*PageNewConnectionResultFunc) (NMConnection *connection,
......@@ -41,8 +42,8 @@ typedef void (*PageNewConnectionResultFunc) (NMConnection *connection,
typedef GSList * (*PageGetConnectionsFunc) (gpointer user_data);
typedef void (*PageNewConnectionFunc) (GtkWindow *parent,
NMRemoteSettings *settings,
PageNewConnectionResultFunc result_func,
PageGetConnectionsFunc get_connections_func,
gpointer user_data);
#define CE_TYPE_PAGE (ce_page_get_type ())
......@@ -131,7 +132,7 @@ GtkWidget *ce_page_nag_user (CEPage *self);
NMConnection *ce_page_new_connection (const char *format,
const char *ctype,
gboolean autoconnect,
PageGetConnectionsFunc get_connections_func,
NMRemoteSettings *settings,
gpointer user_data);
CEPage *ce_page_new (GType page_type,
......
......@@ -585,14 +585,6 @@ really_add_connection (NMConnection *connection,
nm_connection_editor_run (editor);
}
static GSList *
page_get_connections (gpointer user_data)
{
ActionInfo *info = (ActionInfo *) user_data;
return nm_remote_settings_list_connections (info->list->settings);
}
static void
add_clicked (GtkButton *button, gpointer user_data)
{
......@@ -608,8 +600,8 @@ add_clicked (GtkButton *button, gpointer user_data)
}
info->new_func (GTK_WINDOW (list->dialog),
list->settings,
really_add_connection,
page_get_connections,
info);
}
......@@ -1376,8 +1368,8 @@ nm_connection_list_create (NMConnectionList *self, GType ctype)
_("Don't know how to create '%s' connections"), g_type_name (ctype));
} else {
info->new_func (GTK_WINDOW (info->list->dialog),
info->list->settings,
really_add_connection,
page_get_connections,
info);
}
}
......
......@@ -222,8 +222,8 @@ ce_page_dsl_class_init (CEPageDslClass *dsl_class)
void
dsl_connection_new (GtkWindow *parent,
NMRemoteSettings *settings,
PageNewConnectionResultFunc result_func,
PageGetConnectionsFunc get_connections_func,
gpointer user_data)
{
NMConnection *connection;
......@@ -232,7 +232,7 @@ dsl_connection_new (GtkWindow *parent,
connection = ce_page_new_connection (_("DSL connection %d"),
NM_SETTING_PPPOE_SETTING_NAME,
FALSE,
get_connections_func,
settings,
user_data);
nm_connection_add_setting (connection, nm_setting_pppoe_new ());
nm_connection_add_setting (connection, nm_setting_wired_new ());
......
......@@ -54,8 +54,8 @@ CEPage *ce_page_dsl_new (NMConnection *connection,
GError **error);
void dsl_connection_new (GtkWindow *parent,
NMRemoteSettings *settings,
PageNewConnectionResultFunc callback,
PageGetConnectionsFunc get_connections_func,
gpointer user_data);
#endif /* __PAGE_DSL_H__ */
......@@ -539,8 +539,8 @@ add_default_serial_setting (NMConnection *connection)
}
typedef struct {
NMRemoteSettings *settings;
PageNewConnectionResultFunc result_func;
PageGetConnectionsFunc get_connections_func;
gpointer user_data;
} WizardInfo;
......@@ -589,7 +589,7 @@ 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 = ce_page_new_connection (detail, ctype, FALSE, info->get_connections_func, info->user_data);
connection = ce_page_new_connection (detail, ctype, FALSE, info->settings, info->user_data);
g_free (detail);
nm_connection_add_setting (connection, type_setting);
......@@ -601,6 +601,8 @@ new_connection_mobile_wizard_done (NMAMobileWizard *wizard,
if (wizard)
nma_mobile_wizard_destroy (wizard);
g_object_unref (info->settings);
g_free (info);
}
......@@ -612,8 +614,8 @@ cancel_dialog (GtkDialog *dialog)
void
mobile_connection_new (GtkWindow *parent,
NMRemoteSettings *settings,
PageNewConnectionResultFunc result_func,
PageGetConnectionsFunc get_connections_func,
gpointer user_data)
{
NMAMobileWizard *wizard;
......@@ -625,7 +627,7 @@ mobile_connection_new (GtkWindow *parent,
info = g_malloc0 (sizeof (WizardInfo));
info->result_func = result_func;
info->get_connections_func = get_connections_func;
info->settings = g_object_ref (settings);
info->user_data = user_data;
wizard = nma_mobile_wizard_new (parent, NULL, NM_DEVICE_MODEM_CAPABILITY_NONE, FALSE,
......
......@@ -54,8 +54,8 @@ CEPage *ce_page_mobile_new (NMConnection *connection,
GError **error);
void mobile_connection_new (GtkWindow *parent,
NMRemoteSettings *settings,
PageNewConnectionResultFunc result_func,
PageGetConnectionsFunc get_connections_func,
gpointer user_data);
#endif /* __PAGE_MOBILE_H__ */
......@@ -191,8 +191,8 @@ ce_page_vpn_class_init (CEPageVpnClass *vpn_class)
}
typedef struct {
NMRemoteSettings *settings;
PageNewConnectionResultFunc result_func;
PageGetConnectionsFunc get_connections_func;
gpointer user_data;
} NewVpnInfo;
......@@ -217,7 +217,7 @@ import_cb (NMConnection *connection, gpointer user_data)
if (!s) {
GSList *connections;
connections = info->get_connections_func (info->user_data);
connections = nm_remote_settings_list_connections (info->settings);
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);
......@@ -249,13 +249,14 @@ import_cb (NMConnection *connection, gpointer user_data)
info->result_func (connection, FALSE, error, info->user_data);
g_clear_error (&error);
g_object_unref (info->settings);
g_slice_free (NewVpnInfo, info);
}
void
vpn_connection_new (GtkWindow *parent,
NMRemoteSettings *settings,
PageNewConnectionResultFunc result_func,
PageGetConnectionsFunc get_connections_func,
gpointer user_data)
{
char *service = NULL;
......@@ -274,7 +275,7 @@ vpn_connection_new (GtkWindow *parent,
g_free (service);
info = g_slice_new (NewVpnInfo);
info->result_func = result_func;
info->get_connections_func = get_connections_func;
info->settings = g_object_ref (settings);
info->user_data = user_data;
vpn_import (import_cb, info);
return;
......@@ -283,7 +284,7 @@ vpn_connection_new (GtkWindow *parent,
connection = ce_page_new_connection (_("VPN connection %d"),
NM_SETTING_VPN_SETTING_NAME,
FALSE,
get_connections_func,
settings,
user_data);
s_vpn = nm_setting_vpn_new ();
g_object_set (s_vpn, NM_SETTING_VPN_SERVICE_TYPE, service, NULL);
......
......@@ -56,8 +56,8 @@ CEPage *ce_page_vpn_new (NMConnection *connection,
gboolean ce_page_vpn_can_export (CEPageVpn *page);
void vpn_connection_new (GtkWindow *parent,
NMRemoteSettings *settings,
PageNewConnectionResultFunc result_func,
PageGetConnectionsFunc get_connections_func,
gpointer user_data);
#endif /* __PAGE_VPN_H__ */
......@@ -440,8 +440,8 @@ ce_page_wired_class_init (CEPageWiredClass *wired_class)
void
wired_connection_new (GtkWindow *parent,
NMRemoteSettings *settings,
PageNewConnectionResultFunc result_func,
PageGetConnectionsFunc get_connections_func,
gpointer user_data)
{
NMConnection *connection;
......@@ -449,7 +449,7 @@ wired_connection_new (GtkWindow *parent,
connection = ce_page_new_connection (_("Wired connection %d"),
NM_SETTING_WIRED_SETTING_NAME,
TRUE,
get_connections_func,
settings,
user_data);
nm_connection_add_setting (connection, nm_setting_wired_new ());
......
......@@ -54,8 +54,8 @@ CEPage *ce_page_wired_new (NMConnection *connection,
GError **error);
void wired_connection_new (GtkWindow *parent,
NMRemoteSettings *settings,
PageNewConnectionResultFunc result_func,
PageGetConnectionsFunc get_connections_func,
gpointer user_data);
#endif /* __PAGE_WIRED_H__ */
......
......@@ -656,8 +656,8 @@ ce_page_wireless_class_init (CEPageWirelessClass *wireless_class)
void
wifi_connection_new (GtkWindow *parent,
NMRemoteSettings *settings,
PageNewConnectionResultFunc result_func,
PageGetConnectionsFunc get_connections_func,
gpointer user_data)
{
NMConnection *connection;
......@@ -666,7 +666,7 @@ wifi_connection_new (GtkWindow *parent,
connection = ce_page_new_connection (_("Wireless connection %d"),
NM_SETTING_WIRELESS_SETTING_NAME,
TRUE,
get_connections_func,
settings,
user_data);
s_wifi = nm_setting_wireless_new ();
g_object_set (s_wifi, NM_SETTING_WIRELESS_MODE, "infrastructure", NULL);
......
......@@ -58,8 +58,8 @@ GByteArray *ce_page_wireless_get_ssid (CEPageWireless *self);
void wifi_connection_new (GtkWindow *parent,
NMRemoteSettings *settings,
PageNewConnectionResultFunc result_func,
PageGetConnectionsFunc get_connections_func,
gpointer user_data);
#endif /* __PAGE_WIRELESS_H__ */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment