diff options
author | Dan Williams <dcbw@redhat.com> | 2008-07-11 10:28:53 +0000 |
---|---|---|
committer | Tambet Ingo <tambet@gmail.com> | 2008-07-11 10:28:53 +0000 |
commit | 95bb76aa7f74075e1d0424b3c7441f366225b4c6 (patch) | |
tree | 49421fc21be919191d4f2a2e3a765f02289dde19 /libnm-glib | |
parent | 9228a199fd4d63c99048df061e15f7e4e628e24a (diff) | |
download | NetworkManager-95bb76aa7f74075e1d0424b3c7441f366225b4c6.tar.gz |
2008-07-11 Dan Williams <dcbw@redhat.com>
Modify the NMDevice::state-changed signal to include the previous state
and reason. Enables the applet to provide more information why device
activation failed.
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3819 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
Diffstat (limited to 'libnm-glib')
-rw-r--r-- | libnm-glib/nm-device.c | 53 | ||||
-rw-r--r-- | libnm-glib/nm-device.h | 6 |
2 files changed, 58 insertions, 1 deletions
diff --git a/libnm-glib/nm-device.c b/libnm-glib/nm-device.c index f0c990f8c2..7bda96f66b 100644 --- a/libnm-glib/nm-device.c +++ b/libnm-glib/nm-device.c @@ -9,6 +9,7 @@ #include "nm-device-private.h" #include "nm-object-private.h" #include "nm-object-cache.h" +#include "nm-marshal.h" #include "nm-device-bindings.h" @@ -47,6 +48,14 @@ enum { LAST_PROP }; +enum { + STATE_CHANGED, + + LAST_SIGNAL +}; + +static guint signals[LAST_SIGNAL] = { 0 }; + static void nm_device_init (NMDevice *device) @@ -108,7 +117,6 @@ register_for_property_changed (NMDevice *device) { NM_DEVICE_CAPABILITIES, nm_object_demarshal_generic, &priv->capabilities }, { NM_DEVICE_MANAGED, nm_object_demarshal_generic, &priv->managed }, { NM_DEVICE_IP4_CONFIG, demarshal_ip4_config, &priv->ip4_config }, - { NM_DEVICE_STATE, nm_object_demarshal_generic, &priv->state }, { NULL }, }; @@ -117,6 +125,23 @@ register_for_property_changed (NMDevice *device) property_changed_info); } +static void +device_state_changed (DBusGProxy *proxy, + NMDeviceState new_state, + NMDeviceState old_state, + NMDeviceStateReason reason, + gpointer user_data) +{ + NMDevice *self = NM_DEVICE (user_data); + NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self); + + if (priv->state != new_state) { + priv->state = new_state; + g_signal_emit (self, signals[STATE_CHANGED], 0, new_state, old_state, reason); + nm_object_queue_notify (NM_OBJECT (self), "state"); + } +} + static GObject* constructor (GType type, guint n_construct_params, @@ -140,6 +165,21 @@ constructor (GType type, register_for_property_changed (NM_DEVICE (object)); + dbus_g_object_register_marshaller (nm_marshal_VOID__UINT_UINT_UINT, + G_TYPE_NONE, + G_TYPE_UINT, G_TYPE_UINT, G_TYPE_UINT, + G_TYPE_INVALID); + + dbus_g_proxy_add_signal (priv->proxy, + "StateChanged", + G_TYPE_UINT, G_TYPE_UINT, G_TYPE_UINT, + G_TYPE_INVALID); + + dbus_g_proxy_connect_signal (priv->proxy, "StateChanged", + G_CALLBACK (device_state_changed), + NM_DEVICE (object), + NULL); + return G_OBJECT (object); } @@ -303,6 +343,17 @@ nm_device_class_init (NMDeviceClass *device_class) "Product string", NULL, G_PARAM_READABLE)); + + /* signals */ + signals[STATE_CHANGED] = + g_signal_new ("state-changed", + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_FIRST, + G_STRUCT_OFFSET (NMDeviceClass, state_changed), + NULL, NULL, + nm_marshal_VOID__UINT_UINT_UINT, + G_TYPE_NONE, 3, + G_TYPE_UINT, G_TYPE_UINT, G_TYPE_UINT); } GObject * diff --git a/libnm-glib/nm-device.h b/libnm-glib/nm-device.h index 4ee420fa33..1b1214c5c3 100644 --- a/libnm-glib/nm-device.h +++ b/libnm-glib/nm-device.h @@ -34,6 +34,12 @@ typedef struct { typedef struct { NMObjectClass parent; + + /* Signals */ + void (*state_changed) (NMDevice *device, + NMDeviceState new_state, + NMDeviceState old_state, + NMDeviceStateReason reason); } NMDeviceClass; GType nm_device_get_type (void); |