[PATCH 2/2] Add nm_device_prepare_wake_up function to MNDevice, called when going to sleep and device is marked as 'CanWakeUp'
- From: Jean Parpaillon <jparpaillon mandriva com>
- To: networkmanager-list gnome org
- Cc: Jean Parpaillon <jean parpaillon free fr>
- Subject: [PATCH 2/2] Add nm_device_prepare_wake_up function to MNDevice, called when going to sleep and device is marked as 'CanWakeUp'
- Date: Wed, 12 Oct 2011 13:22:34 +0200
From: Jean Parpaillon <jean parpaillon free fr>
---
src/nm-device.c | 20 ++++++++++++++++++--
src/nm-device.h | 1 +
2 files changed, 19 insertions(+), 2 deletions(-)
diff --git a/src/nm-device.c b/src/nm-device.c
index 31a73c1..fdd5627 100644
--- a/src/nm-device.c
+++ b/src/nm-device.c
@@ -167,6 +167,8 @@ static gboolean can_assume_connections (NMDeviceInterface *device);
static void nm_device_activate_schedule_stage5_ip_config_commit (NMDevice *self, int family);
+static void nm_device_prepare_wake_up (NMDevice *dev);
+
static void nm_device_take_down (NMDevice *dev, gboolean wait, NMDeviceStateReason reason);
static gboolean nm_device_bring_up (NMDevice *self, gboolean block, gboolean *no_firmware);
@@ -3296,6 +3298,17 @@ nm_device_bring_up (NMDevice *self, gboolean block, gboolean *no_firmware)
}
static void
+nm_device_prepare_wake_up (NMDevice *self)
+{
+ g_return_if_fail (NM_IS_DEVICE (self));
+
+ nm_log_info (LOGD_DEVICE, "(%s): preparing for waking up...");
+
+ if (NM_DEVICE_GET_CLASS (self)->prepare_wake_up)
+ NM_DEVICE_GET_CLASS (self)->prepare_wake_up (self);
+}
+
+static void
nm_device_take_down (NMDevice *self, gboolean block, NMDeviceStateReason reason)
{
g_return_if_fail (NM_IS_DEVICE (self));
@@ -3899,8 +3912,11 @@ nm_device_state_changed (NMDevice *device,
switch (state) {
case NM_DEVICE_STATE_UNMANAGED:
nm_device_set_firmware_missing (device, FALSE);
- if (old_state > NM_DEVICE_STATE_UNMANAGED)
- nm_device_take_down (device, TRUE, reason);
+ if (old_state > NM_DEVICE_STATE_UNMANAGED) {
+ if (priv->can_wake_up)
+ nm_device_prepare_wake_up (device);
+ else
+ nm_device_take_down (device, TRUE, reason);
break;
case NM_DEVICE_STATE_UNAVAILABLE:
if (old_state == NM_DEVICE_STATE_UNMANAGED || priv->firmware_missing) {
diff --git a/src/nm-device.h b/src/nm-device.h
index b7273de..fb450bf 100644
--- a/src/nm-device.h
+++ b/src/nm-device.h
@@ -70,6 +70,7 @@ typedef struct {
gboolean (*is_up) (NMDevice *self);
gboolean (*bring_up) (NMDevice *self);
void (*take_down) (NMDevice *self);
+ void (*prepare_wake_up) (NMDevice *self);
void (* update_hw_address) (NMDevice *self);
void (* update_permanent_hw_address) (NMDevice *self);
--
1.7.6.3
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]