diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index d063bdf60..e70594d17 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -3444,6 +3444,12 @@ nm_device_set_autoconnect_both (NMDevice *self, gboolean autoconnect) nm_device_set_autoconnect_full (self, autoconnect, autoconnect); } +static gboolean +get_autoconnect_allowed (NMDevice *self) +{ + return TRUE; +} + static gboolean autoconnect_allowed_accumulator (GSignalInvocationHint *ihint, GValue *return_accu, @@ -3466,10 +3472,12 @@ gboolean nm_device_autoconnect_allowed (NMDevice *self) { NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self); + NMDeviceClass *klass = NM_DEVICE_GET_CLASS (self); GValue instance = G_VALUE_INIT; GValue retval = G_VALUE_INIT; - if (!nm_device_get_autoconnect (self)) + if ( !nm_device_get_autoconnect (self) + || !klass->get_autoconnect_allowed (self)) return FALSE; /* Unrealized devices can always autoconnect. */ @@ -13499,6 +13507,7 @@ nm_device_class_init (NMDeviceClass *klass) klass->have_any_ready_slaves = have_any_ready_slaves; klass->get_type_description = get_type_description; + klass->get_autoconnect_allowed = get_autoconnect_allowed; klass->can_auto_connect = can_auto_connect; klass->check_connection_compatible = check_connection_compatible; klass->check_connection_available = check_connection_available; diff --git a/src/devices/nm-device.h b/src/devices/nm-device.h index 1b239c2e0..eb527cc37 100644 --- a/src/devices/nm-device.h +++ b/src/devices/nm-device.h @@ -243,6 +243,11 @@ typedef struct { void (* set_enabled) (NMDevice *self, gboolean enabled); + /* allow derived classes to override the result of nm_device_autoconnect_allowed(). + * If the value changes, the class should call nm_device_emit_recheck_auto_activate(), + * which emits NM_DEVICE_RECHECK_AUTO_ACTIVATE signal. */ + gboolean (* get_autoconnect_allowed) (NMDevice *self); + gboolean (* can_auto_connect) (NMDevice *self, NMConnection *connection, char **specific_object);