core: add NMActivationStateFlags "master-has-slaves"

This commit is contained in:
Thomas Haller 2017-09-27 10:16:15 +02:00
parent 50c62edccb
commit 2f1ab058f1
3 changed files with 13 additions and 0 deletions

View file

@ -885,6 +885,8 @@ typedef enum {
* @NM_ACTIVATION_STATE_FLAG_LAYER2_READY: layer2 is activated and ready.
* @NM_ACTIVATION_STATE_FLAG_IP4_READY: IPv4 setting is completed.
* @NM_ACTIVATION_STATE_FLAG_IP6_READY: IPv6 setting is completed.
* @NM_ACTIVATION_STATE_FLAG_MASTER_HAS_SLAVES: The master has any slave devices attached.
* This only makes sense if the device is a master.
*
* Flags describing the current activation state.
*
@ -898,6 +900,7 @@ typedef enum { /*< flags >*/
NM_ACTIVATION_STATE_FLAG_LAYER2_READY = (1LL << 2),
NM_ACTIVATION_STATE_FLAG_IP4_READY = (1LL << 3),
NM_ACTIVATION_STATE_FLAG_IP6_READY = (1LL << 4),
NM_ACTIVATION_STATE_FLAG_MASTER_HAS_SLAVES = (1LL << 5),
} NMActivationStateFlags;
#endif /* __NM_DBUS_INTERFACE_H__ */

View file

@ -2215,6 +2215,12 @@ nm_device_master_release_one_slave (NMDevice *self, NMDevice *slave, gboolean co
g_object_unref (slave);
g_slice_free (SlaveInfo, info);
if (c_list_is_empty (&priv->slaves)) {
_active_connection_set_state_flags_full (self,
0,
NM_ACTIVATION_STATE_FLAG_MASTER_HAS_SLAVES);
}
/* Ensure the device's hardware address is up-to-date; it often changes
* when slaves change.
*/
@ -3724,6 +3730,9 @@ nm_device_master_add_slave (NMDevice *self, NMDevice *slave, gboolean configure)
c_list_link_tail (&priv->slaves, &info->lst_slave);
slave_priv->master = g_object_ref (self);
_active_connection_set_state_flags (self,
NM_ACTIVATION_STATE_FLAG_MASTER_HAS_SLAVES);
/* no need to emit
*
* _notify (slave, PROP_MASTER);

View file

@ -153,6 +153,7 @@ NM_UTILS_FLAGS2STR_DEFINE_STATIC (_state_flags_to_string, NMActivationStateFlags
NM_UTILS_FLAGS2STR (NM_ACTIVATION_STATE_FLAG_LAYER2_READY, "layer2-ready"),
NM_UTILS_FLAGS2STR (NM_ACTIVATION_STATE_FLAG_IP4_READY, "ip4-ready"),
NM_UTILS_FLAGS2STR (NM_ACTIVATION_STATE_FLAG_IP6_READY, "ip6-ready"),
NM_UTILS_FLAGS2STR (NM_ACTIVATION_STATE_FLAG_MASTER_HAS_SLAVES, "master-has-slaves"),
);
/*****************************************************************************/