Commit 3164c026 authored by Thomas Haller's avatar Thomas Haller

settings: merge "connection-updated" and "connection-updated-by-user" signals

This is mostly interesting of NMPolicy, which no longer needs to
subscribe to two almost identical signals (where the by-user signal
was always invoked together with the plain "updated" signal).
parent 65c55e2a
......@@ -80,8 +80,7 @@ static gboolean find_master (NMManager *self,
static void nm_manager_update_state (NMManager *manager);
static void connection_changed (NMSettings *settings, NMConnection *connection,
NMManager *manager);
static void connection_changed (NMManager *self, NMConnection *connection);
#define TAG_ACTIVE_CONNETION_ADD_AND_ACTIVATE "act-con-add-and-activate"
......@@ -1148,7 +1147,7 @@ retry_connections_for_parent_device (NMManager *self, NMDevice *device)
ifname = nm_manager_get_connection_iface (self, candidate, &parent, &error);
if (ifname) {
if (!nm_platform_link_get_by_ifname (NM_PLATFORM_GET, ifname))
connection_changed (priv->settings, candidate, self);
connection_changed (self, candidate);
}
}
}
......@@ -1157,34 +1156,40 @@ retry_connections_for_parent_device (NMManager *self, NMDevice *device)
}
static void
connection_changed (NMSettings *settings,
NMConnection *connection,
NMManager *manager)
connection_changed (NMManager *self,
NMConnection *connection)
{
NMDevice *device;
if (!nm_connection_is_virtual (connection))
return;
device = system_create_virtual_device (manager, connection);
device = system_create_virtual_device (self, connection);
if (!device)
return;
/* Maybe the device that was created was needed by some other
* connection's device (parent of a VLAN). Let the connections
* can use the newly created device as a parent know. */
retry_connections_for_parent_device (manager, device);
retry_connections_for_parent_device (self, device);
}
static void
connection_removed (NMSettings *settings,
NMSettingsConnection *connection,
NMManager *manager)
connection_added_cb (NMSettings *settings,
NMConnection *connection,
NMManager *self)
{
/*
* Do not delete existing virtual devices to keep connectivity up.
* Virtual devices are reused when NetworkManager is restarted.
*/
connection_changed (self, connection);
}
static void
connection_updated_cb (NMSettings *settings,
NMConnection *connection,
gboolean by_user,
NMManager *self)
{
if (by_user)
connection_changed (self, connection);
}
static void
......@@ -4403,7 +4408,7 @@ nm_manager_start (NMManager *self, GError **error)
_LOGD (LOGD_CORE, "creating virtual devices...");
connections = nm_settings_get_connections (priv->settings);
for (iter = connections; iter; iter = iter->next)
connection_changed (priv->settings, NM_CONNECTION (iter->data), self);
connection_changed (self, NM_CONNECTION (iter->data));
g_slist_free (connections);
priv->devices_inited = TRUE;
......@@ -5080,11 +5085,14 @@ constructed (GObject *object)
g_signal_connect (priv->settings, "notify::" NM_SETTINGS_HOSTNAME,
G_CALLBACK (system_hostname_changed_cb), self);
g_signal_connect (priv->settings, NM_SETTINGS_SIGNAL_CONNECTION_ADDED,
G_CALLBACK (connection_changed), self);
g_signal_connect (priv->settings, NM_SETTINGS_SIGNAL_CONNECTION_UPDATED_BY_USER,
G_CALLBACK (connection_changed), self);
g_signal_connect (priv->settings, NM_SETTINGS_SIGNAL_CONNECTION_REMOVED,
G_CALLBACK (connection_removed), self);
G_CALLBACK (connection_added_cb), self);
g_signal_connect (priv->settings, NM_SETTINGS_SIGNAL_CONNECTION_UPDATED,
G_CALLBACK (connection_updated_cb), self);
/*
* Do not delete existing virtual devices to keep connectivity up.
* Virtual devices are reused when NetworkManager is restarted.
* Hence, don't react on NM_SETTINGS_SIGNAL_CONNECTION_REMOVED.
*/
priv->policy = nm_policy_new (self, priv->settings);
g_signal_connect (priv->policy, "notify::" NM_POLICY_DEFAULT_IP4_DEVICE,
......@@ -5394,8 +5402,8 @@ dispose (GObject *object)
g_signal_handlers_disconnect_by_func (priv->settings, settings_startup_complete_changed, manager);
g_signal_handlers_disconnect_by_func (priv->settings, system_unmanaged_devices_changed_cb, manager);
g_signal_handlers_disconnect_by_func (priv->settings, system_hostname_changed_cb, manager);
g_signal_handlers_disconnect_by_func (priv->settings, connection_changed, manager);
g_signal_handlers_disconnect_by_func (priv->settings, connection_removed, manager);
g_signal_handlers_disconnect_by_func (priv->settings, connection_added_cb, manager);
g_signal_handlers_disconnect_by_func (priv->settings, connection_updated_cb, manager);
g_clear_object (&priv->settings);
}
......
......@@ -1664,39 +1664,34 @@ dns_config_changed (NMDnsManager *dns_manager, gpointer user_data)
static void
connection_updated (NMSettings *settings,
NMConnection *connection,
NMSettingsConnection *connection,
gboolean by_user,
gpointer user_data)
{
NMPolicyPrivate *priv = user_data;
NMPolicy *self = priv->self;
schedule_activate_all (self);
}
static void
connection_updated_by_user (NMSettings *settings,
NMSettingsConnection *connection,
gpointer user_data)
{
NMPolicyPrivate *priv = user_data;
const GSList *iter;
NMDevice *device = NULL;
/* find device with given connection */
for (iter = nm_manager_get_devices (priv->manager); iter; iter = g_slist_next (iter)) {
NMDevice *dev = NM_DEVICE (iter->data);
if (by_user) {
/* find device with given connection */
for (iter = nm_manager_get_devices (priv->manager); iter; iter = g_slist_next (iter)) {
NMDevice *dev = NM_DEVICE (iter->data);
if (nm_device_get_settings_connection (dev) == connection) {
device = dev;
break;
if (nm_device_get_settings_connection (dev) == connection) {
device = dev;
break;
}
}
}
if (device)
nm_device_reapply_settings_immediately (device);
if (device)
nm_device_reapply_settings_immediately (device);
/* Reset auto retries back to default since connection was updated */
nm_settings_connection_reset_autoconnect_retries (connection);
}
/* Reset auto retries back to default since connection was updated */
nm_settings_connection_reset_autoconnect_retries (connection);
schedule_activate_all (self);
}
static void
......@@ -1892,7 +1887,6 @@ constructed (GObject *object)
g_signal_connect (priv->settings, NM_SETTINGS_SIGNAL_CONNECTION_ADDED, (GCallback) connection_added, priv);
g_signal_connect (priv->settings, NM_SETTINGS_SIGNAL_CONNECTION_UPDATED, (GCallback) connection_updated, priv);
g_signal_connect (priv->settings, NM_SETTINGS_SIGNAL_CONNECTION_UPDATED_BY_USER, (GCallback) connection_updated_by_user, priv);
g_signal_connect (priv->settings, NM_SETTINGS_SIGNAL_CONNECTION_REMOVED, (GCallback) connection_removed, priv);
g_signal_connect (priv->settings, NM_SETTINGS_SIGNAL_CONNECTION_VISIBILITY_CHANGED, (GCallback) connection_visibility_changed, priv);
g_signal_connect (priv->settings, NM_SETTINGS_SIGNAL_AGENT_REGISTERED, (GCallback) secret_agent_registered, priv);
......
......@@ -167,7 +167,6 @@ typedef struct {
enum {
CONNECTION_ADDED,
CONNECTION_UPDATED,
CONNECTION_UPDATED_BY_USER,
CONNECTION_REMOVED,
CONNECTION_VISIBILITY_CHANGED,
AGENT_REGISTERED,
......@@ -844,17 +843,11 @@ next:
static void
connection_updated (NMSettingsConnection *connection, gboolean by_user, gpointer user_data)
{
if (by_user) {
g_signal_emit (NM_SETTINGS (user_data),
signals[CONNECTION_UPDATED_BY_USER],
0,
connection);
}
g_signal_emit (NM_SETTINGS (user_data),
signals[CONNECTION_UPDATED],
0,
connection);
connection,
by_user);
g_signal_emit_by_name (NM_SETTINGS (user_data), NM_CP_SIGNAL_CONNECTION_UPDATED, connection);
}
......@@ -2447,17 +2440,8 @@ nm_settings_class_init (NMSettingsClass *class)
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_FIRST,
0, NULL, NULL,
g_cclosure_marshal_VOID__OBJECT,
G_TYPE_NONE, 1, NM_TYPE_SETTINGS_CONNECTION);
signals[CONNECTION_UPDATED_BY_USER] =
g_signal_new (NM_SETTINGS_SIGNAL_CONNECTION_UPDATED_BY_USER,
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_FIRST,
0,
NULL, NULL,
g_cclosure_marshal_VOID__OBJECT,
G_TYPE_NONE, 1, NM_TYPE_SETTINGS_CONNECTION);
NULL,
G_TYPE_NONE, 2, NM_TYPE_SETTINGS_CONNECTION, G_TYPE_BOOLEAN);
signals[CONNECTION_REMOVED] =
g_signal_new (NM_SETTINGS_SIGNAL_CONNECTION_REMOVED,
......
......@@ -45,7 +45,6 @@
#define NM_SETTINGS_SIGNAL_CONNECTION_ADDED "connection-added"
#define NM_SETTINGS_SIGNAL_CONNECTION_UPDATED "connection-updated"
#define NM_SETTINGS_SIGNAL_CONNECTION_UPDATED_BY_USER "connection-updated-by-user"
#define NM_SETTINGS_SIGNAL_CONNECTION_REMOVED "connection-removed"
#define NM_SETTINGS_SIGNAL_CONNECTION_VISIBILITY_CHANGED "connection-visibility-changed"
#define NM_SETTINGS_SIGNAL_AGENT_REGISTERED "agent-registered"
......
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