Commit f30cf17b authored by Dan Williams's avatar Dan Williams

2008-03-12 Dan Williams <dcbw@redhat.com>

	Move the 'carrier' property from NMDevice to NMDevice8023Ethernet;
	convert the libnm-glib NMDevice8023Ethernet to cached properties

	* introspection/nm-device-802-3-ethernet.xml
		- New 'Carrier' property
		- New 'PropertiesChanged' signal

	* introspection/nm-device.xml
		- Remove 'Carrier' property
		- Remove 'CarrierChanged' signal

	* src/nm-device-interface.c
	  src/nm-device-interface.h
		- (nm_device_interface_init): remove 'carrier' property and
			'carrier-changed' signal

	* src/nm-device.c
	  src/nm-device.h
		- (nm_device_get_carrier, nm_device_set_carrier): remove
		- (nm_device_activate_stage5_ip_config_commit): don't bother updating
			the link here; wired device will handle that
		- (handle_dhcp_lease_change): don't bother updating link here
		- (get_property, nm_device_class_init): remove carrier property

	* src/nm-device-802-11-wireless.c
		- (real_update_link, nm_device_802_11_wireless_class_init): remove
			real_update_link(); wireless devices don't use carrier at all
		- (link_timeout_cb, supplicant_iface_state_cb_handler,
		   supplicant_iface_connection_state_cb_handler,
		   supplicant_mgr_state_cb_handler): remove anything to do with carrier

	* src/nm-device-802-3-ethernet.c
	  src/nm-device-802-3-ethernet.h
		- (nm_device_802_3_ethernet_carrier_on,
		   nm_device_802_3_ethernet_carrier_off, constructor): use set_carrier()
			instead of nm_device_set_carrier()
		- (device_state_changed): update link from sysfs on activation;
			replaces real_update_link()
		- (real_update_link): remove, replaced by device_state_changed()
		- (nm_device_802_3_ethernet_get_carrier, set_carrier): new functions
		- (nm_device_802_3_ethernet_get_speed): move up with other getters/setters
		- (real_get_generic_capabilities, real_can_interrupt_activation): use
			new get_carrier function
		- (get_property): add 'carrier' property
		- (nm_device_802_3_ethernet_class_init): add 'carrier' property and
			hook into property-changed signal helper

	* src/NetworkManagerPolicy.c
		- (device_carrier_changed): will only ever be called with a wired device
		- (device_added): only hook up to carrier-changed for wired devices

	* libnm-glib/nm-device.c
	  libnm-glib/nm-device.h
		- (constructor, nm_device_class_init): remove carrier-changed signal
		- (device_carrier_changed_proxy): remove; unused
		- (nm_device_get_carrier): remove; carrier a property of wired devices

	* libnm-glib/nm-device-802-3-ethernet.c
	  libnm-glib/nm-device-802-3-ethernet.h
		- Convert to cached properties like AP and Wireless objects
		- (nm_device_802_3_ethernet_get_hw_address): now returns a 'const char *'
			instead of a 'char *', return value should not be freed
		- (nm_device_802_3_ethernet_get_carrier): return current carrier status
		- (constructor): hook into properties-changed helper
		- (set_property, get_property): new functions
		- (nm_device_802_3_ethernet_class_init): export GObject properties

	* test/nm-tool.c
		- (detail_device): strdup the wired hardware address too since it's
			cached now

	* libnm-glib/libnm-glib-test.c
		- (dump_wired): strdup the wired hardware address too since it's
			cached now



git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3428 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
parent 763913b2
2008-03-12 Dan Williams <dcbw@redhat.com>
Move the 'carrier' property from NMDevice to NMDevice8023Ethernet;
convert the libnm-glib NMDevice8023Ethernet to cached properties
* introspection/nm-device-802-3-ethernet.xml
- New 'Carrier' property
- New 'PropertiesChanged' signal
* introspection/nm-device.xml
- Remove 'Carrier' property
- Remove 'CarrierChanged' signal
* src/nm-device-interface.c
src/nm-device-interface.h
- (nm_device_interface_init): remove 'carrier' property and
'carrier-changed' signal
* src/nm-device.c
src/nm-device.h
- (nm_device_get_carrier, nm_device_set_carrier): remove
- (nm_device_activate_stage5_ip_config_commit): don't bother updating
the link here; wired device will handle that
- (handle_dhcp_lease_change): don't bother updating link here
- (get_property, nm_device_class_init): remove carrier property
* src/nm-device-802-11-wireless.c
- (real_update_link, nm_device_802_11_wireless_class_init): remove
real_update_link(); wireless devices don't use carrier at all
- (link_timeout_cb, supplicant_iface_state_cb_handler,
supplicant_iface_connection_state_cb_handler,
supplicant_mgr_state_cb_handler): remove anything to do with carrier
* src/nm-device-802-3-ethernet.c
src/nm-device-802-3-ethernet.h
- (nm_device_802_3_ethernet_carrier_on,
nm_device_802_3_ethernet_carrier_off, constructor): use set_carrier()
instead of nm_device_set_carrier()
- (device_state_changed): update link from sysfs on activation;
replaces real_update_link()
- (real_update_link): remove, replaced by device_state_changed()
- (nm_device_802_3_ethernet_get_carrier, set_carrier): new functions
- (nm_device_802_3_ethernet_get_speed): move up with other getters/setters
- (real_get_generic_capabilities, real_can_interrupt_activation): use
new get_carrier function
- (get_property): add 'carrier' property
- (nm_device_802_3_ethernet_class_init): add 'carrier' property and
hook into property-changed signal helper
* src/NetworkManagerPolicy.c
- (device_carrier_changed): will only ever be called with a wired device
- (device_added): only hook up to carrier-changed for wired devices
* libnm-glib/nm-device.c
libnm-glib/nm-device.h
- (constructor, nm_device_class_init): remove carrier-changed signal
- (device_carrier_changed_proxy): remove; unused
- (nm_device_get_carrier): remove; carrier a property of wired devices
* libnm-glib/nm-device-802-3-ethernet.c
libnm-glib/nm-device-802-3-ethernet.h
- Convert to cached properties like AP and Wireless objects
- (nm_device_802_3_ethernet_get_hw_address): now returns a 'const char *'
instead of a 'char *', return value should not be freed
- (nm_device_802_3_ethernet_get_carrier): return current carrier status
- (constructor): hook into properties-changed helper
- (set_property, get_property): new functions
- (nm_device_802_3_ethernet_class_init): export GObject properties
* test/nm-tool.c
- (detail_device): strdup the wired hardware address too since it's
cached now
* libnm-glib/libnm-glib-test.c
- (dump_wired): strdup the wired hardware address too since it's
cached now
2008-03-12 Dan Williams <dcbw@redhat.com>
* libnm-util/nm-setting-ip4-config.c
......
......@@ -2,15 +2,32 @@
<node name="/" xmlns:tp="http://telepathy.freedesktop.org/wiki/DbusSpec#extensions-v0">
<interface name="org.freedesktop.NetworkManager.Device.Wired">
<property name="HwAddress" type="s" access="read">
<tp:docstring>
Hardware address of the device.
</tp:docstring>
</property>
<property name="Speed" type="u" access="read">
<tp:docstring>
Design speed of the device.
</tp:docstring>
</property>
<property name="Carrier" type="b" access="read">
<tp:docstring>
Indicates whether the physical carrier is found (e.g. whether a cable is plugged in or not).
</tp:docstring>
</property>
<signal name="PropertiesChanged">
<arg name="properties" type="a{sv}" tp:type="String_Variant_Map">
<tp:docstring>
A dictionary mapping property names to variant boxed values
</tp:docstring>
</arg>
</signal>
</interface>
</node>
......@@ -44,11 +44,6 @@
Object path of the Ip4Config object describing the configuration of the device. Only valid when the device is in the NM_DEVICE_STATE_ACTIVATED state.
</tp:docstring>
</property>
<property name="Carrier" type="b" access="read">
<tp:docstring>
Indicates whether the physical carrier is found (e.g. the device is plugged in or associated to a network).
</tp:docstring>
</property>
<!-- Ugh, but I see no other way of getting the type on the caller
based on dbus object path only -->
......@@ -66,13 +61,6 @@
</arg>
</signal>
<signal name="CarrierChanged">
<arg name="carrier_on" type="b">
<tp:docstring>
Boolean indicating whether the carrier is now on or off.
</tp:docstring>
</arg>
</signal>
<tp:enum name="NM_DEVICE_STATE" type="u">
<tp:enumvalue suffix="UNKNOWN" value="0">
<tp:docstring>
......
......@@ -172,13 +172,12 @@ dump_wireless (NMDevice80211Wireless *device)
static void
dump_wired (NMDevice8023Ethernet *device)
{
char *str;
const char *str;
g_print ("Speed: %d\n", nm_device_802_3_ethernet_get_speed (device));
str = nm_device_802_3_ethernet_get_hw_address (device);
g_print ("MAC: %s\n", str);
g_free (str);
}
static void
......
......@@ -8,11 +8,124 @@ G_DEFINE_TYPE (NMDevice8023Ethernet, nm_device_802_3_ethernet, NM_TYPE_DEVICE)
#define NM_DEVICE_802_3_ETHERNET_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DEVICE_802_3_ETHERNET, NMDevice8023EthernetPrivate))
typedef struct {
DBusGProxy *ethernet_proxy;
DBusGProxy *wired_proxy;
char * hw_address;
guint32 speed;
gboolean carrier;
gboolean carrier_valid;
gboolean disposed;
} NMDevice8023EthernetPrivate;
enum {
PROP_0,
PROP_HW_ADDRESS,
PROP_SPEED,
PROP_CARRIER,
LAST_PROP
};
#define DBUS_PROP_HW_ADDRESS "HwAddress"
#define DBUS_PROP_SPEED "Speed"
#define DBUS_PROP_CARRIER "Carrier"
NMDevice8023Ethernet *
nm_device_802_3_ethernet_new (DBusGConnection *connection, const char *path)
{
g_return_val_if_fail (connection != NULL, NULL);
g_return_val_if_fail (path != NULL, NULL);
return (NMDevice8023Ethernet *) g_object_new (NM_TYPE_DEVICE_802_3_ETHERNET,
NM_OBJECT_CONNECTION, connection,
NM_OBJECT_PATH, path,
NULL);
}
static void
nm_device_802_3_ethernet_set_hw_address (NMDevice8023Ethernet *self,
const char *address)
{
NMDevice8023EthernetPrivate *priv = NM_DEVICE_802_3_ETHERNET_GET_PRIVATE (self);
g_free (priv->hw_address);
priv->hw_address = g_strdup (address);
g_object_notify (G_OBJECT (self), NM_DEVICE_802_3_ETHERNET_HW_ADDRESS);
}
const char *
nm_device_802_3_ethernet_get_hw_address (NMDevice8023Ethernet *device)
{
NMDevice8023EthernetPrivate *priv;
g_return_val_if_fail (NM_IS_DEVICE_802_3_ETHERNET (device), NULL);
priv = NM_DEVICE_802_3_ETHERNET_GET_PRIVATE (device);
if (!priv->hw_address) {
priv->hw_address = nm_object_get_string_property (NM_OBJECT (device),
NM_DBUS_INTERFACE_DEVICE_WIRED,
DBUS_PROP_HW_ADDRESS);
}
return priv->hw_address;
}
static void
nm_device_802_3_ethernet_set_speed (NMDevice8023Ethernet *self, guint32 speed)
{
NMDevice8023EthernetPrivate *priv = NM_DEVICE_802_3_ETHERNET_GET_PRIVATE (self);
priv->speed = speed;
g_object_notify (G_OBJECT (self), NM_DEVICE_802_3_ETHERNET_SPEED);
}
guint32
nm_device_802_3_ethernet_get_speed (NMDevice8023Ethernet *device)
{
NMDevice8023EthernetPrivate *priv;
g_return_val_if_fail (NM_IS_DEVICE_802_3_ETHERNET (device), 0);
priv = NM_DEVICE_802_3_ETHERNET_GET_PRIVATE (device);
if (!priv->speed) {
priv->speed = nm_object_get_uint_property (NM_OBJECT (device),
NM_DBUS_INTERFACE_DEVICE_WIRED,
DBUS_PROP_SPEED);
}
return priv->speed;
}
static void
nm_device_802_3_ethernet_set_carrier (NMDevice8023Ethernet *self, gboolean carrier)
{
NMDevice8023EthernetPrivate *priv = NM_DEVICE_802_3_ETHERNET_GET_PRIVATE (self);
if (priv->carrier != carrier) {
priv->carrier_valid = TRUE;
priv->carrier = carrier;
g_object_notify (G_OBJECT (self), NM_DEVICE_802_3_ETHERNET_CARRIER);
}
}
gboolean
nm_device_802_3_ethernet_get_carrier (NMDevice8023Ethernet *device)
{
NMDevice8023EthernetPrivate *priv;
g_return_val_if_fail (NM_IS_DEVICE_802_3_ETHERNET (device), FALSE);
priv = NM_DEVICE_802_3_ETHERNET_GET_PRIVATE (device);
if (!priv->carrier_valid) {
priv->carrier = nm_object_get_boolean_property (NM_OBJECT (device),
NM_DBUS_INTERFACE_DEVICE_WIRED,
DBUS_PROP_CARRIER);
priv->carrier_valid = TRUE;
}
return priv->carrier;
}
static void
nm_device_802_3_ethernet_init (NMDevice8023Ethernet *device)
......@@ -20,6 +133,8 @@ nm_device_802_3_ethernet_init (NMDevice8023Ethernet *device)
NMDevice8023EthernetPrivate *priv = NM_DEVICE_802_3_ETHERNET_GET_PRIVATE (device);
priv->disposed = FALSE;
priv->carrier = FALSE;
priv->carrier_valid = FALSE;
}
static GObject*
......@@ -38,10 +153,13 @@ constructor (GType type,
priv = NM_DEVICE_802_3_ETHERNET_GET_PRIVATE (object);
priv->ethernet_proxy = dbus_g_proxy_new_for_name (nm_object_get_connection (NM_OBJECT (object)),
priv->wired_proxy = dbus_g_proxy_new_for_name (nm_object_get_connection (NM_OBJECT (object)),
NM_DBUS_SERVICE,
nm_object_get_path (NM_OBJECT (object)),
NM_DBUS_INTERFACE_DEVICE_WIRED);
nm_object_handle_properties_changed (NM_OBJECT (object), priv->wired_proxy);
return object;
}
......@@ -57,47 +175,105 @@ dispose (GObject *object)
priv->disposed = TRUE;
g_object_unref (priv->ethernet_proxy);
g_object_unref (priv->wired_proxy);
G_OBJECT_CLASS (nm_device_802_3_ethernet_parent_class)->dispose (object);
}
static void
nm_device_802_3_ethernet_class_init (NMDevice8023EthernetClass *device_class)
finalize (GObject *object)
{
GObjectClass *object_class = G_OBJECT_CLASS (device_class);
NMDevice8023EthernetPrivate *priv = NM_DEVICE_802_3_ETHERNET_GET_PRIVATE (object);
g_type_class_add_private (device_class, sizeof (NMDevice8023EthernetPrivate));
if (priv->hw_address)
g_free (priv->hw_address);
/* virtual methods */
object_class->constructor = constructor;
object_class->dispose = dispose;
G_OBJECT_CLASS (nm_device_802_3_ethernet_parent_class)->finalize (object);
}
NMDevice8023Ethernet *
nm_device_802_3_ethernet_new (DBusGConnection *connection, const char *path)
static void
set_property (GObject *object, guint prop_id,
const GValue *value, GParamSpec *pspec)
{
g_return_val_if_fail (connection != NULL, NULL);
g_return_val_if_fail (path != NULL, NULL);
NMDevice8023Ethernet *device = NM_DEVICE_802_3_ETHERNET (object);
return (NMDevice8023Ethernet *) g_object_new (NM_TYPE_DEVICE_802_3_ETHERNET,
NM_OBJECT_CONNECTION, connection,
NM_OBJECT_PATH, path,
NULL);
switch (prop_id) {
case PROP_HW_ADDRESS:
nm_device_802_3_ethernet_set_hw_address (device, g_value_get_string (value));
break;
case PROP_SPEED:
nm_device_802_3_ethernet_set_speed (device, g_value_get_uint (value));
break;
case PROP_CARRIER:
nm_device_802_3_ethernet_set_carrier (device, g_value_get_boolean (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
guint32
nm_device_802_3_ethernet_get_speed (NMDevice8023Ethernet *device)
static void
get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
g_return_val_if_fail (NM_IS_DEVICE_802_3_ETHERNET (device), 0);
NMDevice8023EthernetPrivate *priv = NM_DEVICE_802_3_ETHERNET_GET_PRIVATE (object);
return nm_object_get_uint_property (NM_OBJECT (device), NM_DBUS_INTERFACE_DEVICE_WIRED, "Speed");
switch (prop_id) {
case PROP_HW_ADDRESS:
g_value_set_string (value, priv->hw_address);
break;
case PROP_SPEED:
g_value_set_uint (value, priv->speed);
break;
case PROP_CARRIER:
g_value_set_boolean (value, priv->carrier);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
char *
nm_device_802_3_ethernet_get_hw_address (NMDevice8023Ethernet *device)
static void
nm_device_802_3_ethernet_class_init (NMDevice8023EthernetClass *device_class)
{
g_return_val_if_fail (NM_IS_DEVICE_802_3_ETHERNET (device), NULL);
GObjectClass *object_class = G_OBJECT_CLASS (device_class);
g_type_class_add_private (device_class, sizeof (NMDevice8023EthernetPrivate));
/* virtual methods */
object_class->constructor = constructor;
object_class->dispose = dispose;
object_class->finalize = finalize;
object_class->set_property = set_property;
object_class->get_property = get_property;
/* properties */
g_object_class_install_property
(object_class, PROP_HW_ADDRESS,
g_param_spec_string (NM_DEVICE_802_3_ETHERNET_HW_ADDRESS,
"MAC Address",
"Hardware MAC address",
NULL,
G_PARAM_READWRITE));
g_object_class_install_property
(object_class, PROP_SPEED,
g_param_spec_uint (NM_DEVICE_802_3_ETHERNET_SPEED,
"Speed",
"Speed",
0, G_MAXUINT32, 0,
G_PARAM_READWRITE));
g_object_class_install_property
(object_class, PROP_CARRIER,
g_param_spec_boolean (NM_DEVICE_802_3_ETHERNET_CARRIER,
"Carrier",
"Carrier",
FALSE, G_PARAM_READWRITE));
return nm_object_get_string_property (NM_OBJECT (device), NM_DBUS_INTERFACE_DEVICE_WIRED, "HwAddress");
}
......@@ -12,6 +12,10 @@ G_BEGIN_DECLS
#define NM_IS_DEVICE_802_3_ETHERNET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), NM_TYPE_DEVICE_802_3_ETHERNET))
#define NM_DEVICE_802_3_ETHERNET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DEVICE_802_3_ETHERNET, NMDevice8023EthernetClass))
#define NM_DEVICE_802_3_ETHERNET_HW_ADDRESS "hw-address"
#define NM_DEVICE_802_3_ETHERNET_SPEED "speed"
#define NM_DEVICE_802_3_ETHERNET_CARRIER "carrier"
typedef struct {
NMDevice parent;
} NMDevice8023Ethernet;
......@@ -24,8 +28,10 @@ GType nm_device_802_3_ethernet_get_type (void);
NMDevice8023Ethernet *nm_device_802_3_ethernet_new (DBusGConnection *connection,
const char *path);
guint32 nm_device_802_3_ethernet_get_speed (NMDevice8023Ethernet *device);
char *nm_device_802_3_ethernet_get_hw_address (NMDevice8023Ethernet *device);
const char * nm_device_802_3_ethernet_get_hw_address (NMDevice8023Ethernet *device);
guint32 nm_device_802_3_ethernet_get_speed (NMDevice8023Ethernet *device);
gboolean nm_device_802_3_ethernet_get_carrier (NMDevice8023Ethernet *device);
G_END_DECLS
......
......@@ -14,15 +14,11 @@ typedef struct {
char *product;
char *vendor;
gboolean carrier;
gboolean carrier_valid;
gboolean disposed;
} NMDevicePrivate;
enum {
STATE_CHANGED,
CARRIER_CHANGED,
LAST_SIGNAL
};
......@@ -40,7 +36,6 @@ enum {
static void device_state_change_proxy (DBusGProxy *proxy, guint state, gpointer user_data);
static void device_carrier_changed_proxy (DBusGProxy *proxy, gboolean carrier, gpointer user_data);
static void
nm_device_init (NMDevice *device)
......@@ -48,8 +43,6 @@ nm_device_init (NMDevice *device)
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (device);
priv->state = NM_DEVICE_STATE_UNKNOWN;
priv->carrier = FALSE;
priv->carrier_valid = FALSE;
priv->disposed = FALSE;
priv->product = NULL;
priv->vendor = NULL;
......@@ -81,10 +74,6 @@ constructor (GType type,
G_CALLBACK (device_state_change_proxy),
object, NULL);
dbus_g_proxy_add_signal (priv->device_proxy, "CarrierChanged", G_TYPE_BOOLEAN, G_TYPE_INVALID);
dbus_g_proxy_connect_signal (priv->device_proxy, "CarrierChanged",
G_CALLBACK (device_carrier_changed_proxy),
object, NULL);
return G_OBJECT (object);
}
......@@ -138,16 +127,6 @@ nm_device_class_init (NMDeviceClass *device_class)
g_cclosure_marshal_VOID__UINT,
G_TYPE_NONE, 1,
G_TYPE_UINT);
signals[CARRIER_CHANGED] =
g_signal_new ("carrier-changed",
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (NMDeviceClass, carrier_changed),
NULL, NULL,
g_cclosure_marshal_VOID__BOOLEAN,
G_TYPE_NONE, 1,
G_TYPE_BOOLEAN);
}
static void
......@@ -162,19 +141,6 @@ device_state_change_proxy (DBusGProxy *proxy, guint state, gpointer user_data)
}
}
static void
device_carrier_changed_proxy (DBusGProxy *proxy, gboolean carrier, gpointer user_data)
{
NMDevice *device = NM_DEVICE (user_data);
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (device);
if ((priv->carrier != carrier) || !priv->carrier_valid) {
priv->carrier_valid = TRUE;
priv->carrier = carrier;
g_signal_emit (device, signals[CARRIER_CHANGED], 0, carrier);
}
}
NMDevice *
nm_device_new (DBusGConnection *connection, const char *path)
{
......@@ -438,24 +404,6 @@ nm_device_get_vendor (NMDevice *device)
return priv->vendor;
}
gboolean
nm_device_get_carrier (NMDevice *device)
{
NMDevicePrivate *priv;
g_return_val_if_fail (NM_IS_DEVICE (device), FALSE);
priv = NM_DEVICE_GET_PRIVATE (device);
if (!priv->carrier_valid) {
priv->carrier = nm_object_get_boolean_property (NM_OBJECT (device),
NM_DBUS_INTERFACE_DEVICE, "Carrier");
priv->carrier_valid = TRUE;
}
return priv->carrier;
}
NMDeviceType
nm_device_type_for_path (DBusGConnection *connection,
const char *path)
......
......@@ -27,7 +27,6 @@ typedef struct {
/* Signals */
void (*state_changed) (NMDevice *device, NMDeviceState state);
void (*carrier_changed) (NMDevice *device, gboolean carrier);
} NMDeviceClass;
GType nm_device_get_type (void);
......@@ -46,7 +45,6 @@ NMIP4Config *nm_device_get_ip4_config (NMDevice *device);
NMDeviceState nm_device_get_state (NMDevice *device);
const char *nm_device_get_product (NMDevice *device);
const char *nm_device_get_vendor (NMDevice *device);
gboolean nm_device_get_carrier (NMDevice *device);
NMDeviceType nm_device_type_for_path (DBusGConnection *connection,
const char *path);
......
......@@ -308,18 +308,24 @@ device_state_changed (NMDevice *device, NMDeviceState state, gpointer user_data)
}
static void
device_carrier_changed (NMDevice *device, gboolean carrier, gpointer user_data)
device_carrier_changed (NMDevice8023Ethernet *device,
GParamSpec *pspec,
gpointer user_data)
{
if (!carrier) {
if (NM_IS_DEVICE_802_3_ETHERNET (device))
nm_device_interface_deactivate (NM_DEVICE_INTERFACE (device));
} else {
schedule_activate_check ((NMPolicy *) user_data, device);
}
const char *prop = g_param_spec_get_name (pspec);
g_return_if_fail (strcmp (prop, NM_DEVICE_802_3_ETHERNET_CARRIER) == 0);
if (!nm_device_802_3_ethernet_get_carrier (device))
nm_device_interface_deactivate (NM_DEVICE_INTERFACE (device));
else
schedule_activate_check ((NMPolicy *) user_data, NM_DEVICE (device));
}
static void
device_ip4_config_changed (NMDevice *device, NMIP4Config *config, gpointer user_data)
device_ip4_config_changed (NMDevice *device,
GParamSpec *pspec,
gpointer user_data)
{
update_routing_and_dns ((NMPolicy *) user_data, TRUE);
}
......@@ -360,11 +366,6 @@ device_added (NMManager *manager, NMDevice *device, gpointer user_data)
policy);
policy->dev_signal_ids = add_device_signal_id (policy->dev_signal_ids, id, device);
id = g_signal_connect (device, "carrier-changed",
G_CALLBACK (device_carrier_changed),
policy);
policy->dev_signal_ids = add_device_signal_id (policy->dev_signal_ids, id, device);
id = g_signal_connect (device, "notify::" NM_DEVICE_INTERFACE_IP4_CONFIG,
G_CALLBACK (device_ip4_config_changed),
policy);
......@@ -382,6 +383,13 @@ device_added (NMManager *manager, NMDevice *device, gpointer user_data)
policy->dev_signal_ids = add_device_signal_id (policy->dev_signal_ids, id, device);
}
if (NM_IS_DEVICE_802_3_ETHERNET (device)) {
id = g_signal_connect (device, "notify::" NM_DEVICE_802_3_ETHERNET_CARRIER,
G_CALLBACK (device_carrier_changed),
policy);
policy->dev_signal_ids = add_device_signal_id (policy->dev_signal_ids, id, device);
}
schedule_activate_check (policy, device);
}
......
......@@ -519,35 +519,6 @@ init_supplicant_interface (NMDevice80211Wireless * self)
}
}
static void
real_update_link (NMDevice *dev)
{
NMDevice80211Wireless * self = NM_DEVICE_802_11_WIRELESS (dev);
gboolean new_link = FALSE;
guint32 state;
/* Ignore link changes when scanning */
if (self->priv->scanning)
return;
if (!self->priv->supplicant.iface)
goto out;
state = nm_supplicant_interface_get_state (self->priv->supplicant.iface);
if (state != NM_SUPPLICANT_INTERFACE_STATE_READY)
goto out;
state = nm_supplicant_interface_get_connection_state (self->priv->supplicant.iface);
if ( state == NM_SUPPLICANT_INTERFACE_CON_STATE_COMPLETED
|| state == NM_SUPPLICANT_INTERFACE_CON_STATE_ASSOCIATED
|| state == NM_SUPPLICANT_INTERFACE_CON_STATE_4WAY_HANDSHAKE
|| state == NM_SUPPLICANT_INTERFACE_CON_STATE_GROUP_HANDSHAKE)
new_link = TRUE;
out:
nm_device_set_carrier (NM_DEVICE (self), new_link);
}
static NMAccessPoint *
get_active_ap (NMDevice80211Wireless *self,
NMAccessPoint *ignore_ap,
......@@ -1886,7 +1857,6 @@ link_timeout_cb (gpointer user_data)
ap = nm_device_802_11_wireless_get_activation_ap (self);
if (req == NULL || ap == NULL) {
nm_warning ("couldn't get activation request or activation AP.");
nm_device_set_carrier (dev, FALSE);
if (nm_device_is_activating (dev)) {
cleanup_association_attempt (self, TRUE);
nm_device_state_changed (dev, NM_DEVICE_STATE_FAILED);
......@@ -1937,7 +1907,6 @@ link_timeout_cb (gpointer user_data)
time_out:
nm_info ("%s: link timed out.", nm_device_get_iface (dev));
nm_device_set_carrier (dev, FALSE);
return FALSE;
}
......@@ -2005,7 +1974,6 @@ supplicant_iface_state_cb_handler (gpointer user_data)
cancel_pending_scan (self);
cleanup_association_attempt (self, FALSE);
cleanup_supplicant_interface (self);
nm_device_set_carrier (NM_DEVICE (self), FALSE);
}
g_slice_free (struct state_cb_data, cb_data);
......@@ -2054,7 +2022,6 @@ supplicant_iface_connection_state_cb_handler (gpointer user_data)
if (new_state == NM_SUPPLICANT_INTERFACE_CON_STATE_COMPLETED) {
remove_supplicant_interface_connection_error_handler (self);
remove_supplicant_timeouts (self);
nm_device_set_carrier (dev, TRUE);
/* If this is the initial association during device activation,
* schedule the next activation stage.
......@@ -2074,8 +2041,6 @@ supplicant_iface_connection_state_cb_handler (gpointer user_data)
/* Start the link timeout so we allow some time for reauthentication */
if (!self->priv->link_timeout_id)
self->priv->link_timeout_id = g_timeout_add (15000, link_timeout_cb, self);
} else {
nm_device_set_carrier (dev, FALSE);
}
}
......@@ -2173,8 +2138,6 @@ supplicant_mgr_state_cb_handler (gpointer user_data)
cleanup_association_attempt (self, FALSE);
cleanup_supplicant_interface (self);
nm_device_set_carrier (NM_DEVICE (self), FALSE);
if (nm_device_is_activating (dev)) {
nm_device_state_changed (dev, NM_DEVICE_STATE_FAILED);
}
......@@ -3081,7 +3044,6 @@ nm_device_802_11_wireless_class_init (NMDevice80211WirelessClass *klass)
parent_class->is_up = real_is_up;
parent_class->bring_up = real_bring_up;
parent_class->bring_down = real_bring_down;
parent_class->update_link = real_update_link;
parent_class->set_hw_address = real_set_hw_address;
parent_class->get_best_auto_connection = real_get_best_auto_connection;
parent_class->can_activate = real_can_activate;
......
......@@ -27,6 +27,8 @@
#include <string.h>
#include <net/ethernet.h>
#include <stdlib.h>
#include <linux/sockios.h>
#include <linux/ethtool.h>