Commit 1232b26d authored by Lubomir Rintel's avatar Lubomir Rintel
Browse files

editor/page: streamline initialized signalling

The error argument is never used, don't pretend we handle it and avoid
leaking it. Just dumping the error on the console is still not optimal,
but unconfusing things is a good start.
parent a24589d9
......@@ -659,12 +659,6 @@ ce_page_get_next_available_name (const GPtrArray *connections, const char *forma
return cname;
}
static void
emit_initialized (CEPage *self, GError *error)
{
g_signal_emit (self, signals[INITIALIZED], 0, error);
}
void
ce_page_complete_init (CEPage *self,
const char *setting_name,
......@@ -674,27 +668,29 @@ ce_page_complete_init (CEPage *self,
GError *update_error = NULL;
GVariant *setting_dict;
char *dbus_err;
gboolean ignore_error = FALSE;
g_return_if_fail (self != NULL);
g_return_if_fail (CE_IS_PAGE (self));
if (error) {
/* Ignore missing settings errors */
dbus_err = g_dbus_error_get_remote_error (error);
ignore_error = !g_strcmp0 (dbus_err, "org.freedesktop.NetworkManager.Settings.InvalidSetting")
|| !g_strcmp0 (dbus_err, "org.freedesktop.NetworkManager.Settings.Connection.SettingNotFound")
|| !g_strcmp0 (dbus_err, "org.freedesktop.NetworkManager.AgentManager.NoSecrets");
if ( g_strcmp0 (dbus_err, "org.freedesktop.NetworkManager.Settings.InvalidSetting") == 0
|| g_strcmp0 (dbus_err, "org.freedesktop.NetworkManager.Settings.Connection.SettingNotFound") == 0
|| g_strcmp0 (dbus_err, "org.freedesktop.NetworkManager.AgentManager.NoSecrets") == 0)
g_clear_error (&error);
g_free (dbus_err);
}
/* Ignore missing settings errors */
if (error && !ignore_error) {
emit_initialized (self, error);
return;
} else if (!setting_name || !secrets || g_variant_n_children (secrets) == 0) {
if (error) {
g_warning ("Couldn't fetch secrets: %s", error->message);
g_error_free (error);
goto out;
}
if (!setting_name || !secrets || g_variant_n_children (secrets) == 0) {
/* Success, no secrets */
emit_initialized (self, NULL);
return;
goto out;
}
g_assert (setting_name);
......@@ -703,28 +699,22 @@ ce_page_complete_init (CEPage *self,
setting_dict = g_variant_lookup_value (secrets, setting_name, NM_VARIANT_TYPE_SETTING);
if (!setting_dict) {
/* Success, no secrets */
emit_initialized (self, NULL);
return;
goto out;
}
g_variant_unref (setting_dict);
/* Update the connection with the new secrets */
if (nm_connection_update_secrets (self->connection,
if (!nm_connection_update_secrets (self->connection,
setting_name,
secrets,
&update_error)) {
/* Success */
emit_initialized (self, NULL);
return;
}
if (!update_error) {
g_set_error_literal (&update_error, NMA_ERROR, NMA_ERROR_GENERIC,
_("Failed to update connection secrets due to an unknown error."));
g_warning ("Couldn't update the secrets: %s", update_error->message);
g_error_free (update_error);
goto out;
}
emit_initialized (self, update_error);
g_clear_error (&update_error);
out:
g_signal_emit (self, signals[INITIALIZED], 0, NULL);
}
static void
......
......@@ -62,15 +62,12 @@ enable_toggled (GtkToggleButton *button, gpointer user_data)
}
static void
finish_setup (CEPage8021xSecurity *self, gpointer unused, GError *error, gpointer user_data)
finish_setup (CEPage8021xSecurity *self, gpointer user_data)
{
CEPage *parent = CE_PAGE (self);
CEPage8021xSecurityPrivate *priv = CE_PAGE_8021X_SECURITY_GET_PRIVATE (self);
GtkWidget *parent_container;
if (error)
return;
priv->security = (WirelessSecurity *) ws_wpa_eap_new (parent->connection, TRUE, FALSE);
if (!priv->security) {
g_warning ("Could not load 802.1X user interface.");
......
......@@ -89,14 +89,11 @@ stuff_changed (GtkEditable *editable, gpointer user_data)
}
static void
finish_setup (CEPageBluetooth *self, gpointer unused, GError *error, gpointer user_data)
finish_setup (CEPageBluetooth *self, gpointer user_data)
{
CEPage *parent = CE_PAGE (self);
CEPageBluetoothPrivate *priv = CE_PAGE_BLUETOOTH_GET_PRIVATE (self);
if (error)
return;
populate_ui (self, parent->connection);
g_signal_connect (priv->bdaddr, "changed", G_CALLBACK (stuff_changed), self);
......
......@@ -406,13 +406,10 @@ add_slave (CEPageMaster *master, NewConnectionResultFunc result_func)
}
static void
finish_setup (CEPageBond *self, gpointer unused, GError *error, gpointer user_data)
finish_setup (CEPageBond *self, gpointer user_data)
{
CEPageBondPrivate *priv = CE_PAGE_BOND_GET_PRIVATE (self);
if (error)
return;
populate_ui (self);
g_signal_connect (priv->mode, "changed", G_CALLBACK (stuff_changed), self);
......
......@@ -70,13 +70,10 @@ populate_ui (CEPageBridgePort *self)
}
static void
finish_setup (CEPageBridgePort *self, gpointer unused, GError *error, gpointer user_data)
finish_setup (CEPageBridgePort *self, gpointer user_data)
{
CEPageBridgePortPrivate *priv = CE_PAGE_BRIDGE_PORT_GET_PRIVATE (self);
if (error)
return;
populate_ui (self);
g_signal_connect (priv->priority, "value-changed", G_CALLBACK (stuff_changed), self);
......
......@@ -204,11 +204,8 @@ add_slave (CEPageMaster *master, NewConnectionResultFunc result_func)
}
static void
finish_setup (CEPageBridge *self, gpointer unused, GError *error, gpointer user_data)
finish_setup (CEPageBridge *self, gpointer user_data)
{
if (error)
return;
populate_ui (self);
}
......
......@@ -586,16 +586,13 @@ enable_toggled (GtkToggleButton *button, gpointer user_data)
}
static void
finish_setup (CEPageDcb *self, gpointer unused, GError *error, gpointer user_data)
finish_setup (CEPageDcb *self, gpointer user_data)
{
CEPage *parent = CE_PAGE (self);
CEPageDcbPrivate *priv = CE_PAGE_DCB_GET_PRIVATE (self);
NMSettingDcb *s_dcb = nm_connection_get_setting_dcb (parent->connection);
guint i;
if (error)
return;
gtk_toggle_button_set_active (priv->enabled, priv->initial_have_dcb);
g_signal_connect (priv->enabled, "toggled", G_CALLBACK (enable_toggled), self);
gtk_widget_set_sensitive (GTK_WIDGET (priv->box), priv->initial_have_dcb);
......
......@@ -178,14 +178,11 @@ show_password (GtkToggleButton *button, gpointer user_data)
}
static void
finish_setup (CEPageDsl *self, gpointer unused, GError *error, gpointer user_data)
finish_setup (CEPageDsl *self, gpointer user_data)
{
CEPage *parent = CE_PAGE (self);
CEPageDslPrivate *priv = CE_PAGE_DSL_GET_PRIVATE (self);
if (error)
return;
populate_ui (self, parent->connection);
g_signal_connect (priv->parent, "changed", G_CALLBACK (stuff_changed), self);
......
......@@ -291,15 +291,12 @@ populate_ui (CEPageEthernet *self)
}
static void
finish_setup (CEPageEthernet *self, gpointer unused, GError *error, gpointer user_data)
finish_setup (CEPageEthernet *self, gpointer user_data)
{
CEPage *parent = CE_PAGE (self);
CEPageEthernetPrivate *priv = CE_PAGE_ETHERNET_GET_PRIVATE (self);
GtkWidget *widget;
if (error)
return;
populate_ui (self);
g_signal_connect (priv->linkneg, "changed", G_CALLBACK (link_special_changed_cb), self);
......
......@@ -323,14 +323,11 @@ populate_ui (CEPageGeneral *self)
}
static void
finish_setup (CEPageGeneral *self, gpointer unused, GError *error, gpointer user_data)
finish_setup (CEPageGeneral *self, gpointer user_data)
{
CEPageGeneralPrivate *priv = CE_PAGE_GENERAL_GET_PRIVATE (self);
gboolean any_dependent_vpn;
if (error)
return;
priv->setup_finished = TRUE;
populate_ui (self);
......
......@@ -114,13 +114,10 @@ populate_ui (CEPageInfiniband *self)
}
static void
finish_setup (CEPageInfiniband *self, gpointer unused, GError *error, gpointer user_data)
finish_setup (CEPageInfiniband *self, gpointer user_data)
{
CEPageInfinibandPrivate *priv = CE_PAGE_INFINIBAND_GET_PRIVATE (self);
if (error)
return;
populate_ui (self);
g_signal_connect (priv->transport_mode, "changed", G_CALLBACK (stuff_changed), self);
......
......@@ -133,14 +133,11 @@ stuff_changed (GtkEditable *editable, gpointer user_data)
}
static void
finish_setup (CEPageIPTunnel *self, gpointer unused, GError *error, gpointer user_data)
finish_setup (CEPageIPTunnel *self, gpointer user_data)
{
CEPage *parent = CE_PAGE (self);
CEPageIPTunnelPrivate *priv = CE_PAGE_IP_TUNNEL_GET_PRIVATE (self);
if (error)
return;
populate_ui (self, parent->connection);
g_signal_connect (priv->name, "changed", G_CALLBACK (stuff_changed), self);
......
......@@ -1109,7 +1109,7 @@ cell_error_data_func (GtkTreeViewColumn *tree_column,
}
static void
finish_setup (CEPageIP4 *self, gpointer unused, GError *error, gpointer user_data)
finish_setup (CEPageIP4 *self, gpointer user_data)
{
CEPageIP4Private *priv = CE_PAGE_IP4_GET_PRIVATE (self);
GtkTreeSelection *selection;
......@@ -1117,9 +1117,6 @@ finish_setup (CEPageIP4 *self, gpointer unused, GError *error, gpointer user_dat
GtkTreeViewColumn *column;
GtkCellRenderer *renderer;
if (error)
return;
populate_ui (self);
/* IP Address column */
......
......@@ -1091,7 +1091,7 @@ cell_error_data_func (GtkTreeViewColumn *tree_column,
}
static void
finish_setup (CEPageIP6 *self, gpointer unused, GError *error, gpointer user_data)
finish_setup (CEPageIP6 *self, gpointer user_data)
{
CEPageIP6Private *priv = CE_PAGE_IP6_GET_PRIVATE (self);
GtkTreeSelection *selection;
......@@ -1099,9 +1099,6 @@ finish_setup (CEPageIP6 *self, gpointer unused, GError *error, gpointer user_dat
GtkTreeViewColumn *column;
GtkCellRenderer *renderer;
if (error)
return;
populate_ui (self);
/* IP Address column */
......
......@@ -147,14 +147,11 @@ stuff_changed (GtkEditable *editable, gpointer user_data)
}
static void
finish_setup (CEPageMacsec *self, gpointer unused, GError *error, gpointer user_data)
finish_setup (CEPageMacsec *self, gpointer user_data)
{
CEPage *parent = CE_PAGE (self);
CEPageMacsecPrivate *priv = CE_PAGE_MACSEC_GET_PRIVATE (self);
if (error)
return;
populate_ui (self, parent->connection);
g_signal_connect (priv->name, "changed", G_CALLBACK (stuff_changed), self);
......
......@@ -46,7 +46,7 @@ typedef struct {
} CEPageMasterPrivate;
static void finish_setup (CEPageMaster *self, gpointer unused, GError *error, gpointer user_data);
static void finish_setup (CEPageMaster *self, gpointer user_data);
enum {
COL_CONNECTION,
......@@ -515,16 +515,13 @@ populate_ui (CEPageMaster *self)
}
static void
finish_setup (CEPageMaster *self, gpointer unused, GError *error, gpointer user_data)
finish_setup (CEPageMaster *self, gpointer user_data)
{
CEPageMasterPrivate *priv = CE_PAGE_MASTER_GET_PRIVATE (self);
GtkTreeSelection *selection;
GtkBuilder *builder;
NMSettingConnection *s_con;
if (error)
return;
builder = CE_PAGE (self)->builder;
priv->interface_name = GTK_ENTRY (gtk_builder_get_object (builder, "master_interface"));
......
......@@ -250,14 +250,11 @@ apn_filter_cb (GtkEditable *editable,
}
static void
finish_setup (CEPageMobile *self, gpointer unused, GError *error, gpointer user_data)
finish_setup (CEPageMobile *self, gpointer user_data)
{
CEPage *parent = CE_PAGE (self);
CEPageMobilePrivate *priv = CE_PAGE_MOBILE_GET_PRIVATE (self);
if (error)
return;
if (NM_IS_SETTING_GSM (priv->setting))
populate_gsm_ui (self, parent->connection);
else if (NM_IS_SETTING_CDMA (priv->setting))
......
......@@ -251,10 +251,9 @@ populate_ui (CEPagePpp *self, NMConnection *connection)
}
static void
finish_setup (CEPagePpp *self, gpointer unused, GError *error, gpointer user_data)
finish_setup (CEPagePpp *self, gpointer user_data)
{
if (!error)
populate_ui (self, CE_PAGE (self)->connection);
populate_ui (self, CE_PAGE (self)->connection);
}
CEPage *
......
......@@ -179,13 +179,10 @@ populate_ui (CEPageProxy *self)
}
static void
finish_setup (CEPageProxy *self, gpointer unused, GError *error, gpointer user_data)
finish_setup (CEPageProxy *self, gpointer user_data)
{
CEPageProxyPrivate *priv = CE_PAGE_PROXY_GET_PRIVATE (self);
if (error)
return;
populate_ui (self);
method_changed (priv->method, self);
......
......@@ -623,11 +623,8 @@ populate_ui (CEPageTeamPort *self)
}
static void
finish_setup (CEPageTeamPort *self, gpointer unused, GError *error, gpointer user_data)
finish_setup (CEPageTeamPort *self, gpointer user_data)
{
if (error)
return;
populate_ui (self);
}
......
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