core: add the NM_ACTIVE_CONNECTION_STATE_DEACTIVATED state

We'll use this to know when to clean up and dispose of the
active connection in the manager.
This commit is contained in:
Dan Williams 2012-08-22 16:59:11 -05:00
parent abad22f87e
commit 7258dd270f
4 changed files with 27 additions and 9 deletions

View file

@ -523,6 +523,8 @@ typedef enum {
* @NM_ACTIVE_CONNECTION_STATE_ACTIVATED: there is a connection to the network
* @NM_ACTIVE_CONNECTION_STATE_DEACTIVATING: the network connection is being
* torn down and cleaned up
* @NM_ACTIVE_CONNECTION_STATE_DEACTIVATED: the network connection is disconnected
* and will be removed
*
* #NMActiveConnectionState values indicate the state of a connection to a
* specific network while it is starting, connected, or disconnecting from that
@ -532,7 +534,8 @@ typedef enum {
NM_ACTIVE_CONNECTION_STATE_UNKNOWN = 0,
NM_ACTIVE_CONNECTION_STATE_ACTIVATING,
NM_ACTIVE_CONNECTION_STATE_ACTIVATED,
NM_ACTIVE_CONNECTION_STATE_DEACTIVATING
NM_ACTIVE_CONNECTION_STATE_DEACTIVATING,
NM_ACTIVE_CONNECTION_STATE_DEACTIVATED
} NMActiveConnectionState;
#endif /* NETWORK_MANAGER_H */

View file

@ -70,6 +70,11 @@
The connection is being torn down and cleaned up.
</tp:docstring>
</tp:enumvalue>
<tp:enumvalue suffix="DEACTIVATED" value="4">
<tp:docstring>
The connection is no longer active.
</tp:docstring>
</tp:enumvalue>
</tp:enum>
</interface>
</node>

View file

@ -297,7 +297,7 @@ nm_act_request_add_share_rule (NMActRequest *req,
static void
device_state_changed (NMDevice *device, GParamSpec *pspec, NMActRequest *self)
{
NMActiveConnectionState new_ac_state;
NMActiveConnectionState ac_state = NM_ACTIVE_CONNECTION_STATE_UNKNOWN;
/* Set NMActiveConnection state based on the device's state */
switch (nm_device_get_state (device)) {
@ -307,22 +307,29 @@ device_state_changed (NMDevice *device, GParamSpec *pspec, NMActRequest *self)
case NM_DEVICE_STATE_IP_CONFIG:
case NM_DEVICE_STATE_IP_CHECK:
case NM_DEVICE_STATE_SECONDARIES:
new_ac_state = NM_ACTIVE_CONNECTION_STATE_ACTIVATING;
ac_state = NM_ACTIVE_CONNECTION_STATE_ACTIVATING;
break;
case NM_DEVICE_STATE_ACTIVATED:
new_ac_state = NM_ACTIVE_CONNECTION_STATE_ACTIVATED;
ac_state = NM_ACTIVE_CONNECTION_STATE_ACTIVATED;
break;
case NM_DEVICE_STATE_DEACTIVATING:
new_ac_state = NM_ACTIVE_CONNECTION_STATE_DEACTIVATING;
ac_state = NM_ACTIVE_CONNECTION_STATE_DEACTIVATING;
break;
case NM_DEVICE_STATE_FAILED:
case NM_DEVICE_STATE_DISCONNECTED:
ac_state = NM_ACTIVE_CONNECTION_STATE_DEACTIVATED;
break;
default:
new_ac_state = NM_ACTIVE_CONNECTION_STATE_UNKNOWN;
nm_active_connection_set_default (NM_ACTIVE_CONNECTION (self), FALSE);
nm_active_connection_set_default6 (NM_ACTIVE_CONNECTION (self), FALSE);
break;
}
nm_active_connection_set_state (NM_ACTIVE_CONNECTION (self), new_ac_state);
if ( ac_state == NM_ACTIVE_CONNECTION_STATE_DEACTIVATED
|| ac_state == NM_ACTIVE_CONNECTION_STATE_UNKNOWN) {
nm_active_connection_set_default (NM_ACTIVE_CONNECTION (self), FALSE);
nm_active_connection_set_default6 (NM_ACTIVE_CONNECTION (self), FALSE);
}
nm_active_connection_set_state (NM_ACTIVE_CONNECTION (self), ac_state);
}
/********************************************************************/

View file

@ -133,6 +133,9 @@ ac_state_from_vpn_state (NMVPNConnectionState vpn_state)
return NM_ACTIVE_CONNECTION_STATE_ACTIVATING;
case NM_VPN_CONNECTION_STATE_ACTIVATED:
return NM_ACTIVE_CONNECTION_STATE_ACTIVATED;
case NM_VPN_CONNECTION_STATE_FAILED:
case NM_VPN_CONNECTION_STATE_DISCONNECTED:
return NM_ACTIVE_CONNECTION_STATE_DEACTIVATED;
default:
break;
}