diff --git a/introspection/nm-device.xml b/introspection/nm-device.xml index 2161bc4224..b0b56ca227 100644 --- a/introspection/nm-device.xml +++ b/introspection/nm-device.xml @@ -91,6 +91,14 @@ Whether or not this device is managed by NetworkManager. + + + If TRUE, indicates the device is allowed to autoconnect. If FALSE, + manual intervention is required before the device will automatically + connect to a known network, such as activating a connection using the + device, or setting this property to TRUE. + + If TRUE, indicates the device is likely missing firmware necessary for diff --git a/src/nm-device.c b/src/nm-device.c index 8fa8a4fb3d..00c7e20dc5 100644 --- a/src/nm-device.c +++ b/src/nm-device.c @@ -112,6 +112,7 @@ enum { PROP_ACTIVE_CONNECTION, PROP_DEVICE_TYPE, PROP_MANAGED, + PROP_AUTOCONNECT, PROP_FIRMWARE_MISSING, PROP_TYPE_DESC, PROP_RFKILL_TYPE, @@ -223,8 +224,8 @@ typedef struct { /* IP6 config from DHCP */ NMIP6Config * dhcp6_ip6_config; - /* inhibit autoconnect feature */ - gboolean autoconnect_inhibit; + /* allow autoconnect feature */ + gboolean autoconnect; /* master interface for bridge, bond, vlan, etc */ NMDevice * master; @@ -785,10 +786,10 @@ nm_device_autoconnect_allowed (NMDevice *self) g_value_take_object (&instance, self); g_value_init (&retval, G_TYPE_BOOLEAN); - if (priv->autoconnect_inhibit) - g_value_set_boolean (&retval, FALSE); - else + if (priv->autoconnect) g_value_set_boolean (&retval, TRUE); + else + g_value_set_boolean (&retval, FALSE); /* Use g_signal_emitv() rather than g_signal_emit() to avoid the return * value being changed if no handlers are connected */ @@ -3195,7 +3196,7 @@ nm_device_disconnect (NMDevice *device, GError **error) return FALSE; } - priv->autoconnect_inhibit = TRUE; + priv->autoconnect = FALSE; nm_device_state_changed (device, NM_DEVICE_STATE_DISCONNECTED, NM_DEVICE_STATE_REASON_USER_REQUESTED); @@ -3813,6 +3814,9 @@ set_property (GObject *object, guint prop_id, case PROP_MANAGED: priv->managed = g_value_get_boolean (value); break; + case PROP_AUTOCONNECT: + priv->autoconnect = g_value_get_boolean (value); + break; case PROP_FIRMWARE_MISSING: priv->firmware_missing = g_value_get_boolean (value); break; @@ -3921,6 +3925,9 @@ get_property (GObject *object, guint prop_id, case PROP_MANAGED: g_value_set_boolean (value, priv->managed); break; + case PROP_AUTOCONNECT: + g_value_set_boolean (value, priv->autoconnect); + break; case PROP_FIRMWARE_MISSING: g_value_set_boolean (value, priv->firmware_missing); break; @@ -4081,6 +4088,14 @@ nm_device_class_init (NMDeviceClass *klass) FALSE, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); + g_object_class_install_property + (object_class, PROP_AUTOCONNECT, + g_param_spec_boolean (NM_DEVICE_AUTOCONNECT, + "Autoconnect", + "Autoconnect", + TRUE, + G_PARAM_READWRITE)); + g_object_class_install_property (object_class, PROP_FIRMWARE_MISSING, g_param_spec_boolean (NM_DEVICE_FIRMWARE_MISSING, @@ -4391,7 +4406,7 @@ nm_device_state_changed (NMDevice *device, nm_device_deactivate (device, reason); break; default: - priv->autoconnect_inhibit = FALSE; + priv->autoconnect = TRUE; break; } @@ -4711,12 +4726,11 @@ nm_device_set_dhcp_anycast_address (NMDevice *device, guint8 *addr) } } - -void -nm_device_clear_autoconnect_inhibit (NMDevice *device) +gboolean +nm_device_get_autoconnect (NMDevice *device) { - NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (device); - g_return_if_fail (priv); - priv->autoconnect_inhibit = FALSE; + g_return_val_if_fail (NM_IS_DEVICE (device), FALSE); + + return NM_DEVICE_GET_PRIVATE (device)->autoconnect; } diff --git a/src/nm-device.h b/src/nm-device.h index ec4282d0e8..e665bbaabb 100644 --- a/src/nm-device.h +++ b/src/nm-device.h @@ -15,7 +15,7 @@ * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * - * Copyright (C) 2005 - 2011 Red Hat, Inc. + * Copyright (C) 2005 - 2012 Red Hat, Inc. * Copyright (C) 2006 - 2008 Novell, Inc. */ @@ -52,6 +52,7 @@ #define NM_DEVICE_ACTIVE_CONNECTION "active-connection" #define NM_DEVICE_DEVICE_TYPE "device-type" /* ugh */ #define NM_DEVICE_MANAGED "managed" +#define NM_DEVICE_AUTOCONNECT "autoconnect" #define NM_DEVICE_FIRMWARE_MISSING "firmware-missing" #define NM_DEVICE_TYPE_DESC "type-desc" /* Internal only */ #define NM_DEVICE_RFKILL_TYPE "rfkill-type" /* Internal only */ @@ -244,7 +245,7 @@ void nm_device_set_managed (NMDevice *device, gboolean managed, NMDeviceStateReason reason); -void nm_device_clear_autoconnect_inhibit (NMDevice *device); +gboolean nm_device_get_autoconnect (NMDevice *device); void nm_device_handle_autoip4_event (NMDevice *self, const char *event, diff --git a/src/nm-manager.c b/src/nm-manager.c index 7e03bc6048..6ee7ec5668 100644 --- a/src/nm-manager.c +++ b/src/nm-manager.c @@ -3133,7 +3133,8 @@ do_sleep_wake (NMManager *self) nm_device_set_enabled (device, enabled); } - nm_device_clear_autoconnect_inhibit (device); + g_object_set (G_OBJECT (device), NM_DEVICE_AUTOCONNECT, TRUE, NULL); + if (nm_device_spec_match_list (device, unmanaged_specs)) nm_device_set_managed (device, FALSE, NM_DEVICE_STATE_REASON_NOW_UNMANAGED); else diff --git a/src/nm-policy.c b/src/nm-policy.c index babf1649b5..16cd117a1e 100644 --- a/src/nm-policy.c +++ b/src/nm-policy.c @@ -15,7 +15,7 @@ * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * - * Copyright (C) 2004 - 2011 Red Hat, Inc. + * Copyright (C) 2004 - 2012 Red Hat, Inc. * Copyright (C) 2007 - 2008 Novell, Inc. */ @@ -1126,6 +1126,15 @@ device_ip_config_changed (NMDevice *device, update_routing_and_dns ((NMPolicy *) user_data, TRUE); } +static void +device_autoconnect_changed (NMDevice *device, + GParamSpec *pspec, + gpointer user_data) +{ + if (nm_device_get_autoconnect (device)) + schedule_activate_check ((NMPolicy *) user_data, device, 0); +} + static void wireless_networks_changed (NMDevice *device, GObject *ap, gpointer user_data) { @@ -1169,6 +1178,7 @@ device_added (NMManager *manager, NMDevice *device, gpointer user_data) _connect_device_signal (policy, device, "state-changed", device_state_changed); _connect_device_signal (policy, device, "notify::" NM_DEVICE_IP4_CONFIG, device_ip_config_changed); _connect_device_signal (policy, device, "notify::" NM_DEVICE_IP6_CONFIG, device_ip_config_changed); + _connect_device_signal (policy, device, "notify::" NM_DEVICE_AUTOCONNECT, device_autoconnect_changed); switch (nm_device_get_device_type (device)) { case NM_DEVICE_TYPE_WIFI: