diff --git a/ChangeLog b/ChangeLog index 61b9709b40..52ab57b8df 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +2008-04-21 Dan Williams + + * src/nm-activation-request.c + src/nm-activation-request.h + - (dispose): ensure to disconnect from the device's state-changed signal + when appropriate so the signal doesn't get handled by an already + disposed NMActRequest + - (device_state_changed): update is_default here too just to make sure + default is only True when the child device is activated + - (nm_act_request_set_default): new function + + * src/NetworkManagerPolicy.c + - (update_routing_and_dns): set 'default' on the active connection which + has the default route and DNS + 2008-04-21 Dan Williams * src/NetworkManagerPolicy.c diff --git a/src/NetworkManagerPolicy.c b/src/NetworkManagerPolicy.c index 4494bd8f0a..ee25359e3e 100644 --- a/src/NetworkManagerPolicy.c +++ b/src/NetworkManagerPolicy.c @@ -116,6 +116,7 @@ update_routing_and_dns (NMPolicy *policy, gboolean force_update) { NMDevice *best = NULL; guint32 best_prio = 0; + NMActRequest *best_req = NULL; GSList *devices, *iter; NMNamedManager *named_mgr; NMIP4Config *config; @@ -146,6 +147,7 @@ update_routing_and_dns (NMPolicy *policy, gboolean force_update) if (prio > best_prio) { best = dev; best_prio = prio; + best_req = req; } } @@ -155,6 +157,16 @@ update_routing_and_dns (NMPolicy *policy, gboolean force_update) goto out; update_default_route (policy, best); + + /* Update the default active connection */ + for (iter = devices; iter; iter = g_slist_next (iter)) { + NMDevice *dev = NM_DEVICE (iter->data); + NMActRequest *req; + + req = nm_device_get_act_request (dev); + if (req) + nm_act_request_set_default (req, (req == best_req) ? TRUE : FALSE); + } named_mgr = nm_named_manager_get (); config = nm_device_get_ip4_config (best); diff --git a/src/nm-activation-request.c b/src/nm-activation-request.c index c57e9336a3..56dc30eb7d 100644 --- a/src/nm-activation-request.c +++ b/src/nm-activation-request.c @@ -141,6 +141,10 @@ dispose (GObject *object) if (!priv->connection) goto out; + g_signal_handlers_disconnect_by_func (G_OBJECT (priv->device), + G_CALLBACK (device_state_changed), + NM_ACT_REQUEST (object)); + proxy = g_object_get_data (G_OBJECT (priv->connection), NM_MANAGER_CONNECTION_SECRETS_PROXY_TAG); call = g_object_get_data (G_OBJECT (priv->connection), @@ -333,6 +337,7 @@ device_state_changed (NMDevice *device, NMDeviceState state, gpointer user_data) NMActRequest *self = NM_ACT_REQUEST (user_data); NMActRequestPrivate *priv = NM_ACT_REQUEST_GET_PRIVATE (self); NMActiveConnectionState new_state; + gboolean new_default = FALSE; /* Set NMActiveConnection state based on the device's state */ switch (state) { @@ -344,6 +349,7 @@ device_state_changed (NMDevice *device, NMDeviceState state, gpointer user_data) break; case NM_DEVICE_STATE_ACTIVATED: new_state = NM_ACTIVE_CONNECTION_STATE_ACTIVATED; + new_default = priv->is_default; break; default: new_state = NM_ACTIVE_CONNECTION_STATE_UNKNOWN; @@ -354,6 +360,11 @@ device_state_changed (NMDevice *device, NMDeviceState state, gpointer user_data) priv->state = new_state; g_object_notify (G_OBJECT (self), NM_ACTIVE_CONNECTION_STATE); } + + if (new_default != priv->is_default) { + priv->is_default = new_default; + g_object_notify (G_OBJECT (self), NM_ACTIVE_CONNECTION_DEFAULT); + } } typedef struct GetSecretsInfo { @@ -618,3 +629,18 @@ nm_act_request_get_active_connection_path (NMActRequest *req) return NM_ACT_REQUEST_GET_PRIVATE (req)->ac_path; } +void +nm_act_request_set_default (NMActRequest *req, gboolean is_default) +{ + NMActRequestPrivate *priv; + + g_return_if_fail (NM_IS_ACT_REQUEST (req)); + + priv = NM_ACT_REQUEST_GET_PRIVATE (req); + if (priv->is_default == is_default) + return; + + priv->is_default = is_default; + g_object_notify (G_OBJECT (req), NM_ACTIVE_CONNECTION_DEFAULT); +} + diff --git a/src/nm-activation-request.h b/src/nm-activation-request.h index b7f43e7073..f5c9115102 100644 --- a/src/nm-activation-request.h +++ b/src/nm-activation-request.h @@ -72,4 +72,6 @@ gboolean nm_act_request_get_user_requested (NMActRequest *req); const char * nm_act_request_get_active_connection_path (NMActRequest *req); +void nm_act_request_set_default (NMActRequest *req, gboolean is_default); + #endif /* NM_ACTIVATION_REQUEST_H */