diff options
author | Lubomir Rintel <lkundrak@v3.sk> | 2018-06-07 16:14:39 +0200 |
---|---|---|
committer | Lubomir Rintel <lkundrak@v3.sk> | 2018-06-19 19:58:03 +0200 |
commit | 1232b26de687763e531f0da7129e6d333a6a595e (patch) | |
tree | 5810dc0914e5d9d2f95c6d9cd327c62063c5255e | |
parent | a24589d9d54b23d9d4601df3641f5cf7551ab851 (diff) | |
download | network-manager-applet-1232b26de687763e531f0da7129e6d333a6a595e.tar.gz |
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.
25 files changed, 46 insertions, 126 deletions
diff --git a/src/connection-editor/ce-page.c b/src/connection-editor/ce-page.c index e26f1773..84e3de75 100644 --- a/src/connection-editor/ce-page.c +++ b/src/connection-editor/ce-page.c @@ -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 diff --git a/src/connection-editor/page-8021x-security.c b/src/connection-editor/page-8021x-security.c index 0348f9c9..9794fe36 100644 --- a/src/connection-editor/page-8021x-security.c +++ b/src/connection-editor/page-8021x-security.c @@ -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."); diff --git a/src/connection-editor/page-bluetooth.c b/src/connection-editor/page-bluetooth.c index 5d2fa158..4355eb65 100644 --- a/src/connection-editor/page-bluetooth.c +++ b/src/connection-editor/page-bluetooth.c @@ -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); diff --git a/src/connection-editor/page-bond.c b/src/connection-editor/page-bond.c index 76356cbb..60e93f39 100644 --- a/src/connection-editor/page-bond.c +++ b/src/connection-editor/page-bond.c @@ -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); diff --git a/src/connection-editor/page-bridge-port.c b/src/connection-editor/page-bridge-port.c index a7ed6491..e4afa61a 100644 --- a/src/connection-editor/page-bridge-port.c +++ b/src/connection-editor/page-bridge-port.c @@ -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); diff --git a/src/connection-editor/page-bridge.c b/src/connection-editor/page-bridge.c index 1f452633..6876c67f 100644 --- a/src/connection-editor/page-bridge.c +++ b/src/connection-editor/page-bridge.c @@ -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); } diff --git a/src/connection-editor/page-dcb.c b/src/connection-editor/page-dcb.c index e0e26bde..99f14d5a 100644 --- a/src/connection-editor/page-dcb.c +++ b/src/connection-editor/page-dcb.c @@ -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); diff --git a/src/connection-editor/page-dsl.c b/src/connection-editor/page-dsl.c index b07a1b5e..5e6abaae 100644 --- a/src/connection-editor/page-dsl.c +++ b/src/connection-editor/page-dsl.c @@ -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); diff --git a/src/connection-editor/page-ethernet.c b/src/connection-editor/page-ethernet.c index aea7d128..59603f64 100644 --- a/src/connection-editor/page-ethernet.c +++ b/src/connection-editor/page-ethernet.c @@ -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); diff --git a/src/connection-editor/page-general.c b/src/connection-editor/page-general.c index 9ed317c0..55d9671e 100644 --- a/src/connection-editor/page-general.c +++ b/src/connection-editor/page-general.c @@ -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); diff --git a/src/connection-editor/page-infiniband.c b/src/connection-editor/page-infiniband.c index fb9a0694..5e9e8f9b 100644 --- a/src/connection-editor/page-infiniband.c +++ b/src/connection-editor/page-infiniband.c @@ -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); diff --git a/src/connection-editor/page-ip-tunnel.c b/src/connection-editor/page-ip-tunnel.c index 0a1ec02d..89969c35 100644 --- a/src/connection-editor/page-ip-tunnel.c +++ b/src/connection-editor/page-ip-tunnel.c @@ -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); diff --git a/src/connection-editor/page-ip4.c b/src/connection-editor/page-ip4.c index fa807dfa..80364370 100644 --- a/src/connection-editor/page-ip4.c +++ b/src/connection-editor/page-ip4.c @@ -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 */ diff --git a/src/connection-editor/page-ip6.c b/src/connection-editor/page-ip6.c index 4fce0d9c..9aa7574d 100644 --- a/src/connection-editor/page-ip6.c +++ b/src/connection-editor/page-ip6.c @@ -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 */ diff --git a/src/connection-editor/page-macsec.c b/src/connection-editor/page-macsec.c index a25cbe9d..c273dd1f 100644 --- a/src/connection-editor/page-macsec.c +++ b/src/connection-editor/page-macsec.c @@ -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); diff --git a/src/connection-editor/page-master.c b/src/connection-editor/page-master.c index 424c5a87..13e93f8f 100644 --- a/src/connection-editor/page-master.c +++ b/src/connection-editor/page-master.c @@ -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")); diff --git a/src/connection-editor/page-mobile.c b/src/connection-editor/page-mobile.c index 62cdfa58..df9e95f2 100644 --- a/src/connection-editor/page-mobile.c +++ b/src/connection-editor/page-mobile.c @@ -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)) diff --git a/src/connection-editor/page-ppp.c b/src/connection-editor/page-ppp.c index 3bd84a47..7ffca4cc 100644 --- a/src/connection-editor/page-ppp.c +++ b/src/connection-editor/page-ppp.c @@ -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 * diff --git a/src/connection-editor/page-proxy.c b/src/connection-editor/page-proxy.c index 36ff5908..a2769533 100644 --- a/src/connection-editor/page-proxy.c +++ b/src/connection-editor/page-proxy.c @@ -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); diff --git a/src/connection-editor/page-team-port.c b/src/connection-editor/page-team-port.c index c896551e..64c65731 100644 --- a/src/connection-editor/page-team-port.c +++ b/src/connection-editor/page-team-port.c @@ -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); } diff --git a/src/connection-editor/page-team.c b/src/connection-editor/page-team.c index f4d07824..f3173c3a 100644 --- a/src/connection-editor/page-team.c +++ b/src/connection-editor/page-team.c @@ -998,13 +998,10 @@ add_slave (CEPageMaster *master, NewConnectionResultFunc result_func) } static void -finish_setup (CEPageTeam *self, gpointer unused, GError *error, gpointer user_data) +finish_setup (CEPageTeam *self, gpointer user_data) { CEPageTeamPrivate *priv = CE_PAGE_TEAM_GET_PRIVATE (self); - if (error) - return; - populate_ui (self); g_signal_connect (priv->mtu, "value-changed", G_CALLBACK (stuff_changed), self); diff --git a/src/connection-editor/page-vlan.c b/src/connection-editor/page-vlan.c index 4d94f13b..bfae1464 100644 --- a/src/connection-editor/page-vlan.c +++ b/src/connection-editor/page-vlan.c @@ -565,11 +565,8 @@ populate_ui (CEPageVlan *self) } static void -finish_setup (CEPageVlan *self, gpointer unused, GError *error, gpointer user_data) +finish_setup (CEPageVlan *self, gpointer user_data) { - if (error) - return; - populate_ui (self); } diff --git a/src/connection-editor/page-vpn.c b/src/connection-editor/page-vpn.c index ab407003..bc06a1cb 100644 --- a/src/connection-editor/page-vpn.c +++ b/src/connection-editor/page-vpn.c @@ -51,15 +51,12 @@ vpn_plugin_changed_cb (NMVpnEditorPlugin *plugin, CEPageVpn *self) } static void -finish_setup (CEPageVpn *self, gpointer unused, GError *error, gpointer user_data) +finish_setup (CEPageVpn *self, gpointer user_data) { CEPage *parent = CE_PAGE (self); CEPageVpnPrivate *priv = CE_PAGE_VPN_GET_PRIVATE (self); GError *local = NULL; - if (error) - return; - g_return_if_fail (NM_IS_VPN_EDITOR_PLUGIN (priv->plugin)); priv->editor = nm_vpn_editor_plugin_get_editor (priv->plugin, CE_PAGE (self)->connection, &local); diff --git a/src/connection-editor/page-wifi-security.c b/src/connection-editor/page-wifi-security.c index 20a14646..79d3bba8 100644 --- a/src/connection-editor/page-wifi-security.c +++ b/src/connection-editor/page-wifi-security.c @@ -292,7 +292,7 @@ security_valid (NMUtilsSecurityType sectype, NM80211Mode mode) } static void -finish_setup (CEPageWifiSecurity *self, gpointer unused, GError *error, gpointer user_data) +finish_setup (CEPageWifiSecurity *self, gpointer user_data) { CEPage *parent = CE_PAGE (self); CEPageWifiSecurityPrivate *priv = CE_PAGE_WIFI_SECURITY_GET_PRIVATE (self); @@ -308,9 +308,6 @@ finish_setup (CEPageWifiSecurity *self, gpointer unused, GError *error, gpointer GtkComboBox *combo; GtkCellRenderer *renderer; - if (error) - return; - s_wireless = nm_connection_get_setting_wireless (connection); g_assert (s_wireless); diff --git a/src/connection-editor/page-wifi.c b/src/connection-editor/page-wifi.c index d11ff5bc..f4713e53 100644 --- a/src/connection-editor/page-wifi.c +++ b/src/connection-editor/page-wifi.c @@ -396,14 +396,11 @@ populate_ui (CEPageWifi *self) } static void -finish_setup (CEPageWifi *self, gpointer unused, GError *error, gpointer user_data) +finish_setup (CEPageWifi *self, gpointer user_data) { CEPage *parent = CE_PAGE (self); GtkWidget *widget; - if (error) - return; - populate_ui (self); widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "wifi_tx_power_label")); |