2008-04-21 Dan Williams <dcbw@redhat.com>

* 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



git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3584 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
This commit is contained in:
Dan Williams 2008-04-22 02:40:47 +00:00
parent d74967e1b6
commit 095da180c8
4 changed files with 55 additions and 0 deletions

View file

@ -1,3 +1,18 @@
2008-04-21 Dan Williams <dcbw@redhat.com>
* 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 <dcbw@redhat.com>
* src/NetworkManagerPolicy.c

View file

@ -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);

View file

@ -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);
}

View file

@ -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 */