NetworkManager r3428 - in trunk: . introspection libnm-glib src test
- From: dcbw svn gnome org
- To: svn-commits-list gnome org
- Subject: NetworkManager r3428 - in trunk: . introspection libnm-glib src test
- Date: Wed, 12 Mar 2008 16:12:40 +0000 (GMT)
Author: dcbw
Date: Wed Mar 12 16:12:39 2008
New Revision: 3428
URL: http://svn.gnome.org/viewvc/NetworkManager?rev=3428&view=rev
Log:
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
Modified:
trunk/ChangeLog
trunk/introspection/nm-device-802-3-ethernet.xml
trunk/introspection/nm-device.xml
trunk/libnm-glib/libnm-glib-test.c
trunk/libnm-glib/nm-device-802-3-ethernet.c
trunk/libnm-glib/nm-device-802-3-ethernet.h
trunk/libnm-glib/nm-device.c
trunk/libnm-glib/nm-device.h
trunk/src/NetworkManagerPolicy.c
trunk/src/nm-device-802-11-wireless.c
trunk/src/nm-device-802-3-ethernet.c
trunk/src/nm-device-802-3-ethernet.h
trunk/src/nm-device-interface.c
trunk/src/nm-device-interface.h
trunk/src/nm-device.c
trunk/src/nm-device.h
trunk/src/nm-properties-changed-signal.c
trunk/test/nm-tool.c
Modified: trunk/introspection/nm-device-802-3-ethernet.xml
==============================================================================
--- trunk/introspection/nm-device-802-3-ethernet.xml (original)
+++ trunk/introspection/nm-device-802-3-ethernet.xml Wed Mar 12 16:12:39 2008
@@ -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>
Modified: trunk/introspection/nm-device.xml
==============================================================================
--- trunk/introspection/nm-device.xml (original)
+++ trunk/introspection/nm-device.xml Wed Mar 12 16:12:39 2008
@@ -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>
Modified: trunk/libnm-glib/libnm-glib-test.c
==============================================================================
--- trunk/libnm-glib/libnm-glib-test.c (original)
+++ trunk/libnm-glib/libnm-glib-test.c Wed Mar 12 16:12:39 2008
@@ -172,13 +172,12 @@
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
Modified: trunk/libnm-glib/nm-device-802-3-ethernet.c
==============================================================================
--- trunk/libnm-glib/nm-device-802-3-ethernet.c (original)
+++ trunk/libnm-glib/nm-device-802-3-ethernet.c Wed Mar 12 16:12:39 2008
@@ -8,11 +8,124 @@
#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 @@
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 @@
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 @@
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");
}
+
Modified: trunk/libnm-glib/nm-device-802-3-ethernet.h
==============================================================================
--- trunk/libnm-glib/nm-device-802-3-ethernet.h (original)
+++ trunk/libnm-glib/nm-device-802-3-ethernet.h Wed Mar 12 16:12:39 2008
@@ -12,6 +12,10 @@
#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 @@
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
Modified: trunk/libnm-glib/nm-device.c
==============================================================================
--- trunk/libnm-glib/nm-device.c (original)
+++ trunk/libnm-glib/nm-device.c Wed Mar 12 16:12:39 2008
@@ -14,15 +14,11 @@
char *product;
char *vendor;
- gboolean carrier;
- gboolean carrier_valid;
-
gboolean disposed;
} NMDevicePrivate;
enum {
STATE_CHANGED,
- CARRIER_CHANGED,
LAST_SIGNAL
};
@@ -40,7 +36,6 @@
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 @@
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 @@
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 @@
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 @@
}
}
-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 @@
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)
Modified: trunk/libnm-glib/nm-device.h
==============================================================================
--- trunk/libnm-glib/nm-device.h (original)
+++ trunk/libnm-glib/nm-device.h Wed Mar 12 16:12:39 2008
@@ -27,7 +27,6 @@
/* 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 @@
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);
Modified: trunk/src/NetworkManagerPolicy.c
==============================================================================
--- trunk/src/NetworkManagerPolicy.c (original)
+++ trunk/src/NetworkManagerPolicy.c Wed Mar 12 16:12:39 2008
@@ -308,18 +308,24 @@
}
static void
-device_carrier_changed (NMDevice *device, gboolean carrier, 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);
- }
+device_carrier_changed (NMDevice8023Ethernet *device,
+ GParamSpec *pspec,
+ gpointer user_data)
+{
+ 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 @@
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 @@
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);
}
Modified: trunk/src/nm-device-802-11-wireless.c
==============================================================================
--- trunk/src/nm-device-802-11-wireless.c (original)
+++ trunk/src/nm-device-802-11-wireless.c Wed Mar 12 16:12:39 2008
@@ -519,35 +519,6 @@
}
}
-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 @@
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 @@
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 @@
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 @@
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 @@
/* 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 @@
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 @@
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;
Modified: trunk/src/nm-device-802-3-ethernet.c
==============================================================================
--- trunk/src/nm-device-802-3-ethernet.c (original)
+++ trunk/src/nm-device-802-3-ethernet.c Wed Mar 12 16:12:39 2008
@@ -27,6 +27,8 @@
#include <string.h>
#include <net/ethernet.h>
#include <stdlib.h>
+#include <linux/sockios.h>
+#include <linux/ethtool.h>
#include "nm-device-802-3-ethernet.h"
#include "nm-device-interface.h"
@@ -42,6 +44,7 @@
#include "nm-setting-pppoe.h"
#include "ppp-manager/nm-ppp-manager.h"
#include "nm-utils.h"
+#include "nm-properties-changed-signal.h"
#include "nm-device-802-3-ethernet-glue.h"
@@ -54,6 +57,8 @@
gboolean dispose_has_run;
struct ether_addr hw_addr;
+ gboolean carrier;
+
char * carrier_file_path;
gulong link_connected_id;
gulong link_disconnected_id;
@@ -67,14 +72,24 @@
} NMDevice8023EthernetPrivate;
enum {
+ PROPERTIES_CHANGED,
+
+ LAST_SIGNAL
+};
+
+static guint signals[LAST_SIGNAL] = { 0 };
+
+enum {
PROP_0,
PROP_HW_ADDRESS,
PROP_SPEED,
+ PROP_CARRIER,
LAST_PROP
};
-static guint32 nm_device_802_3_ethernet_get_speed (NMDevice8023Ethernet *self);
+
+static void set_carrier (NMDevice8023Ethernet *self, const gboolean carrier);
static gboolean supports_mii_carrier_detect (NMDevice8023Ethernet *dev);
static gboolean supports_ethtool_carrier_detect (NMDevice8023Ethernet *dev);
@@ -100,7 +115,7 @@
if (!(caps & NM_DEVICE_CAP_CARRIER_DETECT))
return;
- nm_device_set_carrier (dev, TRUE);
+ set_carrier (NM_DEVICE_802_3_ETHERNET (dev), TRUE);
}
}
@@ -119,8 +134,33 @@
if (!(caps & NM_DEVICE_CAP_CARRIER_DETECT))
return;
- nm_device_set_carrier (dev, FALSE);
+ set_carrier (NM_DEVICE_802_3_ETHERNET (dev), FALSE);
+ }
+}
+
+static void
+device_state_changed (NMDeviceInterface *device, NMDeviceState state, gpointer user_data)
+{
+ NMDevice8023Ethernet *self = NM_DEVICE_802_3_ETHERNET (user_data);
+ NMDevice8023EthernetPrivate *priv = NM_DEVICE_802_3_ETHERNET_GET_PRIVATE (self);
+ gboolean carrier = FALSE;
+ guint32 caps;
+ gchar *contents;
+
+ if (state != NM_DEVICE_STATE_ACTIVATED)
+ return;
+
+ /* Devices that don't support carrier detect are always "on" */
+ caps = nm_device_get_capabilities (NM_DEVICE (self));
+ if (!(caps & NM_DEVICE_CAP_CARRIER_DETECT))
+ return;
+
+ if (g_file_get_contents (priv->carrier_file_path, &contents, NULL, NULL)) {
+ carrier = atoi (contents) > 0 ? TRUE : FALSE;
+ g_free (contents);
}
+
+ set_carrier (self, carrier);
}
static GObject*
@@ -161,9 +201,11 @@
} else {
priv->link_connected_id = 0;
priv->link_disconnected_id = 0;
- nm_device_set_carrier (dev, TRUE);
+ set_carrier (NM_DEVICE_802_3_ETHERNET (dev), TRUE);
}
+ g_signal_connect (dev, "state-changed", G_CALLBACK (device_state_changed), dev);
+
return object;
}
@@ -175,38 +217,11 @@
priv->dispose_has_run = FALSE;
memset (&(priv->hw_addr), 0, sizeof (struct ether_addr));
+ priv->carrier = FALSE;
nm_device_set_device_type (NM_DEVICE (self), DEVICE_TYPE_802_3_ETHERNET);
}
-static void
-real_update_link (NMDevice *dev)
-{
- NMDevice8023EthernetPrivate *priv = NM_DEVICE_802_3_ETHERNET_GET_PRIVATE (dev);
- gboolean carrier = FALSE;
- guint32 caps;
- gchar * contents;
- gsize length;
-
- /* Devices that don't support carrier detect are always "on" and
- * must be manually chosen by the user.
- */
- caps = nm_device_get_capabilities (dev);
- if (!(caps & NM_DEVICE_CAP_CARRIER_DETECT)) {
- carrier = TRUE;
- goto out;
- }
-
- if (g_file_get_contents (priv->carrier_file_path, &contents, &length, NULL)) {
- carrier = atoi (contents) > 0 ? TRUE : FALSE;
- g_free (contents);
- }
-
-out:
- nm_device_set_carrier (dev, carrier);
-}
-
-
static gboolean
real_is_up (NMDevice *device)
{
@@ -298,6 +313,63 @@
memcpy (addr, &(NM_DEVICE_802_3_ETHERNET_GET_PRIVATE (self)->hw_addr), sizeof (struct ether_addr));
}
+/*
+ * Get/set functions for carrier
+ */
+gboolean
+nm_device_802_3_ethernet_get_carrier (NMDevice8023Ethernet *self)
+{
+ g_return_val_if_fail (self != NULL, FALSE);
+
+ return NM_DEVICE_802_3_ETHERNET_GET_PRIVATE (self)->carrier;
+}
+
+static void
+set_carrier (NMDevice8023Ethernet *self, const gboolean carrier)
+{
+ NMDevice8023EthernetPrivate *priv;
+
+ g_return_if_fail (NM_IS_DEVICE (self));
+
+ priv = NM_DEVICE_802_3_ETHERNET_GET_PRIVATE (self);
+ if (priv->carrier != carrier) {
+ priv->carrier = carrier;
+ g_object_notify (G_OBJECT (self), NM_DEVICE_802_3_ETHERNET_CARRIER);
+ }
+}
+
+/* Returns speed in Mb/s */
+static guint32
+nm_device_802_3_ethernet_get_speed (NMDevice8023Ethernet *self)
+{
+ NMSock * sk;
+ struct ifreq ifr;
+ struct ethtool_cmd edata;
+ const char * iface;
+ guint32 speed = 0;
+
+ g_return_val_if_fail (self != NULL, FALSE);
+
+ iface = nm_device_get_iface (NM_DEVICE (self));
+ if ((sk = nm_dev_sock_open (iface, DEV_GENERAL, __func__, NULL)) == NULL)
+ {
+ nm_warning ("cannot open socket on interface %s for ethtool: %s",
+ iface, strerror (errno));
+ return FALSE;
+ }
+
+ strncpy (ifr.ifr_name, iface, sizeof (ifr.ifr_name) - 1);
+ edata.cmd = ETHTOOL_GSET;
+ ifr.ifr_data = (char *) &edata;
+ if (ioctl (nm_dev_sock_get_fd (sk), SIOCETHTOOL, &ifr) == -1)
+ goto out;
+
+ speed = edata.speed != G_MAXUINT16 ? edata.speed : 0;
+
+out:
+ nm_dev_sock_close (sk);
+ return speed;
+}
static void
real_set_hw_address (NMDevice *dev)
@@ -342,15 +414,15 @@
static gboolean
real_can_interrupt_activation (NMDevice *dev)
{
+ NMDevice8023Ethernet *self = NM_DEVICE_802_3_ETHERNET (dev);
gboolean interrupt = FALSE;
/* Devices that support carrier detect can interrupt activation
* if the link becomes inactive.
*/
if (nm_device_get_capabilities (dev) & NM_DEVICE_CAP_CARRIER_DETECT) {
- if (nm_device_get_carrier (dev) == FALSE) {
+ if (nm_device_802_3_ethernet_get_carrier (self) == FALSE)
interrupt = TRUE;
- }
}
return interrupt;
}
@@ -358,8 +430,10 @@
static gboolean
real_can_activate (NMDevice *dev, gboolean wireless_enabled)
{
+ NMDevice8023Ethernet *self = NM_DEVICE_802_3_ETHERNET (dev);
+
/* Can't do anything if there isn't a carrier */
- if (!nm_device_get_carrier (dev))
+ if (!nm_device_802_3_ethernet_get_carrier (self))
return FALSE;
return TRUE;
@@ -641,6 +715,9 @@
case PROP_SPEED:
g_value_set_uint (value, nm_device_802_3_ethernet_get_speed (device));
break;
+ case PROP_CARRIER:
+ g_value_set_boolean (value, nm_device_802_3_ethernet_get_carrier (device));
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -666,7 +743,6 @@
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->can_interrupt_activation = real_can_interrupt_activation;
parent_class->set_hw_address = real_set_hw_address;
parent_class->get_best_auto_connection = real_get_best_auto_connection;
@@ -694,6 +770,19 @@
0, G_MAXUINT32, 0,
G_PARAM_READABLE));
+ g_object_class_install_property
+ (object_class, PROP_CARRIER,
+ g_param_spec_boolean (NM_DEVICE_802_3_ETHERNET_CARRIER,
+ "Carrier",
+ "Carrier",
+ FALSE,
+ G_PARAM_READABLE));
+
+ /* Signals */
+ signals[PROPERTIES_CHANGED] =
+ nm_properties_changed_signal_new (object_class,
+ G_STRUCT_OFFSET (NMDevice8023EthernetClass, properties_changed));
+
dbus_g_object_type_install_info (G_TYPE_FROM_CLASS (klass),
&dbus_glib_nm_device_802_3_ethernet_object_info);
}
@@ -721,8 +810,6 @@
/**************************************/
/* Ethtool capability detection */
/**************************************/
-#include <linux/sockios.h>
-#include <linux/ethtool.h>
static gboolean
supports_ethtool_carrier_detect (NMDevice8023Ethernet *self)
@@ -760,40 +847,6 @@
}
-/* Returns speed in Mb/s */
-static guint32
-nm_device_802_3_ethernet_get_speed (NMDevice8023Ethernet *self)
-{
- NMSock * sk;
- struct ifreq ifr;
- struct ethtool_cmd edata;
- const char * iface;
- guint32 speed = 0;
-
- g_return_val_if_fail (self != NULL, FALSE);
-
- iface = nm_device_get_iface (NM_DEVICE (self));
- if ((sk = nm_dev_sock_open (iface, DEV_GENERAL, __func__, NULL)) == NULL)
- {
- nm_warning ("cannot open socket on interface %s for ethtool: %s",
- iface, strerror (errno));
- return FALSE;
- }
-
- strncpy (ifr.ifr_name, iface, sizeof (ifr.ifr_name) - 1);
- edata.cmd = ETHTOOL_GSET;
- ifr.ifr_data = (char *) &edata;
- if (ioctl (nm_dev_sock_get_fd (sk), SIOCETHTOOL, &ifr) == -1)
- goto out;
-
- speed = edata.speed != G_MAXUINT16 ? edata.speed : 0;
-
-out:
- nm_dev_sock_close (sk);
- return speed;
-}
-
-
/**************************************/
/* MII capability detection */
/**************************************/
Modified: trunk/src/nm-device-802-3-ethernet.h
==============================================================================
--- trunk/src/nm-device-802-3-ethernet.h (original)
+++ trunk/src/nm-device-802-3-ethernet.h Wed Mar 12 16:12:39 2008
@@ -40,6 +40,7 @@
#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;
@@ -47,6 +48,9 @@
typedef struct {
NMDeviceClass parent;
+
+ /* Signals */
+ void (*properties_changed) (NMDevice8023Ethernet *device, GHashTable *properties);
} NMDevice8023EthernetClass;
@@ -60,6 +64,8 @@
void nm_device_802_3_ethernet_get_address (NMDevice8023Ethernet *dev,
struct ether_addr *addr);
+gboolean nm_device_802_3_ethernet_get_carrier (NMDevice8023Ethernet *dev);
+
G_END_DECLS
#endif /* NM_DEVICE_802_3_ETHERNET_H */
Modified: trunk/src/nm-device-interface.c
==============================================================================
--- trunk/src/nm-device-interface.c (original)
+++ trunk/src/nm-device-interface.c Wed Mar 12 16:12:39 2008
@@ -113,14 +113,6 @@
0, G_MAXUINT32, DEVICE_TYPE_UNKNOWN,
G_PARAM_READABLE));
- g_object_interface_install_property
- (g_iface,
- g_param_spec_boolean (NM_DEVICE_INTERFACE_CARRIER,
- "Carrier",
- "Carrier",
- FALSE,
- G_PARAM_READABLE));
-
/* Signals */
g_signal_new ("state-changed",
iface_type,
@@ -131,15 +123,6 @@
G_TYPE_NONE, 1,
G_TYPE_UINT);
- g_signal_new ("carrier-changed",
- iface_type,
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (NMDeviceInterface, carrier_changed),
- NULL, NULL,
- g_cclosure_marshal_VOID__BOOLEAN,
- G_TYPE_NONE, 1,
- G_TYPE_BOOLEAN);
-
dbus_g_object_type_install_info (iface_type,
&dbus_glib_nm_device_interface_object_info);
Modified: trunk/src/nm-device-interface.h
==============================================================================
--- trunk/src/nm-device-interface.h (original)
+++ trunk/src/nm-device-interface.h Wed Mar 12 16:12:39 2008
@@ -29,7 +29,6 @@
#define NM_DEVICE_INTERFACE_IP4_CONFIG "ip4-config"
#define NM_DEVICE_INTERFACE_STATE "state"
#define NM_DEVICE_INTERFACE_DEVICE_TYPE "device-type" /* ugh */
-#define NM_DEVICE_INTERFACE_CARRIER "carrier"
typedef enum {
NM_DEVICE_INTERFACE_PROP_FIRST = 0x1000,
@@ -42,7 +41,6 @@
NM_DEVICE_INTERFACE_PROP_IP4_CONFIG,
NM_DEVICE_INTERFACE_PROP_STATE,
NM_DEVICE_INTERFACE_PROP_DEVICE_TYPE,
- NM_DEVICE_INTERFACE_PROP_CARRIER
} NMDeviceInterfaceProp;
@@ -64,7 +62,6 @@
/* Signals */
void (*state_changed) (NMDeviceInterface *device, NMDeviceState state);
- void (*carrier_changed) (NMDeviceInterface *device, gboolean carrier_on);
};
GQuark nm_device_interface_error_quark (void);
Modified: trunk/src/nm-device.c
==============================================================================
--- trunk/src/nm-device.c (original)
+++ trunk/src/nm-device.c Wed Mar 12 16:12:39 2008
@@ -66,7 +66,6 @@
guint32 capabilities;
char * driver;
- gboolean carrier;
guint32 ip4_address;
struct in6_addr ip6_address;
@@ -123,7 +122,6 @@
self->priv->capabilities = NM_DEVICE_CAP_NONE;
self->priv->driver = NULL;
- self->priv->carrier = FALSE;
self->priv->ip4_address = 0;
memset (&self->priv->ip6_address, 0, sizeof (struct in6_addr));
@@ -346,33 +344,6 @@
}
-/*
- * Get/set functions for carrier
- */
-gboolean
-nm_device_get_carrier (NMDevice *self)
-{
- g_return_val_if_fail (self != NULL, FALSE);
-
- return self->priv->carrier;
-}
-
-void
-nm_device_set_carrier (NMDevice *self,
- const gboolean carrier)
-{
- NMDevicePrivate *priv;
-
- g_return_if_fail (NM_IS_DEVICE (self));
-
- priv = NM_DEVICE_GET_PRIVATE (self);
- if (priv->carrier != carrier) {
- priv->carrier = carrier;
- g_signal_emit_by_name (self, "carrier-changed", carrier);
- }
-}
-
-
gboolean
nm_device_can_activate (NMDevice *self, gboolean wireless_enabled)
{
@@ -918,14 +889,10 @@
nm_info ("Activation (%s) Stage 5 of 5 (IP Configure Commit) started...",
iface);
- if (nm_device_set_ip4_config (self, ip4_config)) {
- if (NM_DEVICE_GET_CLASS (self)->update_link)
- NM_DEVICE_GET_CLASS (self)->update_link (self);
-
+ if (nm_device_set_ip4_config (self, ip4_config))
nm_device_state_changed (self, NM_DEVICE_STATE_ACTIVATED);
- } else {
+ else
nm_device_state_changed (self, NM_DEVICE_STATE_FAILED);
- }
nm_info ("Activation (%s) Stage 5 of 5 (IP Configure Commit) complete.",
iface);
@@ -1276,10 +1243,7 @@
g_object_set_data (G_OBJECT (req), NM_ACT_REQUEST_IP4_CONFIG, config);
- if (nm_device_set_ip4_config (device, config)) {
- if (NM_DEVICE_GET_CLASS (device)->update_link)
- NM_DEVICE_GET_CLASS (device)->update_link (device);
- } else {
+ if (!nm_device_set_ip4_config (device, config)) {
nm_warning ("Failed to update IP4 config in response to DHCP event.");
nm_device_state_changed (device, NM_DEVICE_STATE_FAILED);
}
@@ -1724,9 +1688,6 @@
case NM_DEVICE_INTERFACE_PROP_DEVICE_TYPE:
g_value_set_uint (value, priv->type);
break;
- case NM_DEVICE_INTERFACE_PROP_CARRIER:
- g_value_set_boolean (value, priv->carrier);
- break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -1791,10 +1752,6 @@
g_object_class_override_property (object_class,
NM_DEVICE_INTERFACE_PROP_DEVICE_TYPE,
NM_DEVICE_INTERFACE_DEVICE_TYPE);
-
- g_object_class_override_property (object_class,
- NM_DEVICE_INTERFACE_PROP_CARRIER,
- NM_DEVICE_INTERFACE_CARRIER);
}
void
Modified: trunk/src/nm-device.h
==============================================================================
--- trunk/src/nm-device.h (original)
+++ trunk/src/nm-device.h Wed Mar 12 16:12:39 2008
@@ -79,8 +79,6 @@
{
GObjectClass parent;
- void (* update_link) (NMDevice *self);
-
gboolean (* is_up) (NMDevice *self);
gboolean (* bring_up) (NMDevice *self);
void (* bring_down) (NMDevice *self);
@@ -131,9 +129,6 @@
guint32 nm_device_get_capabilities (NMDevice *dev);
guint32 nm_device_get_type_capabilities (NMDevice *dev);
-gboolean nm_device_get_carrier (NMDevice *dev);
-void nm_device_set_carrier (NMDevice *dev, const gboolean carrier);
-
guint32 nm_device_get_ip4_address (NMDevice *dev);
void nm_device_update_ip4_address (NMDevice *dev);
struct in6_addr * nm_device_get_ip6_address (NMDevice *dev);
Modified: trunk/src/nm-properties-changed-signal.c
==============================================================================
--- trunk/src/nm-properties-changed-signal.c (original)
+++ trunk/src/nm-properties-changed-signal.c Wed Mar 12 16:12:39 2008
@@ -1,5 +1,8 @@
/* -*- Mode: C; tab-width: 5; indent-tabs-mode: t; c-basic-offset: 5 -*- */
+#include <string.h>
+#include <stdio.h>
+
#include <dbus/dbus-glib.h>
#include "nm-properties-changed-signal.h"
@@ -44,6 +47,22 @@
g_slice_free (PropertiesChangedInfo, info);
}
+#define DEBUG
+#ifdef DEBUG
+static void
+add_to_string (gpointer key, gpointer value, gpointer user_data)
+{
+ char *buf = (char *) user_data;
+ GValue str_val = { 0, };
+
+ g_value_init (&str_val, G_TYPE_STRING);
+ g_value_transform ((GValue *) value, &str_val);
+
+ sprintf (buf + strlen (buf), "{%s: %s}, ", (const char *) key, g_value_get_string (&str_val));
+ g_value_unset (&str_val);
+}
+#endif
+
static gboolean
properties_changed (gpointer data)
{
@@ -52,6 +71,14 @@
g_assert (info);
+#ifdef DEBUG
+ {
+ char buf[2048] = { 0, };
+ g_hash_table_foreach (info->hash, add_to_string, &buf);
+ g_message ("%s: %s -> %s", __func__, G_OBJECT_TYPE_NAME (object), buf);
+ }
+#endif
+
g_signal_emit (object, info->signal_id, 0, info->hash);
g_hash_table_remove_all (info->hash);
Modified: trunk/test/nm-tool.c
==============================================================================
--- trunk/test/nm-tool.c (original)
+++ trunk/test/nm-tool.c Wed Mar 12 16:12:39 2008
@@ -205,7 +205,7 @@
tmp = NULL;
if (NM_IS_DEVICE_802_3_ETHERNET (device))
- tmp = nm_device_802_3_ethernet_get_hw_address (NM_DEVICE_802_3_ETHERNET (device));
+ tmp = g_strdup (nm_device_802_3_ethernet_get_hw_address (NM_DEVICE_802_3_ETHERNET (device)));
else if (NM_IS_DEVICE_802_11_WIRELESS (device))
tmp = g_strdup (nm_device_802_11_wireless_get_hw_address (NM_DEVICE_802_11_WIRELESS (device)));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]