private void PowerSettingChange(IntPtr lParam)
        {
            POWERBROADCAST_SETTING ps =
                                (POWERBROADCAST_SETTING)Marshal.PtrToStructure(
                                                lParam, typeof(POWERBROADCAST_SETTING));

            IntPtr pData = (IntPtr)((int)lParam + Marshal.SizeOf(ps));

            // Handle a change to the power plan.
            if (ps.PowerSetting == GUID_POWERSCHEME_PERSONALITY)
            {
                SetPowerPlan(ps, pData);
            }
            else
                if (ps.DataLength == Marshal.SizeOf(typeof(Int32)))
                {
                    Int32 iData = (Int32)Marshal.PtrToStructure(pData, typeof(Int32));
                    if (ps.PowerSetting == GUID_BATTERY_PERCENTAGE_REMAINING)
                    {
                        SetBatteryLevel(iData);
                    }
                    else if (ps.PowerSetting == GUID_MONITOR_POWER_ON)
                    {
                        SetMonitorState(iData);
                    }
                    else if (ps.PowerSetting == GUID_ACDC_POWER_SOURCE)
                    {
                        SetPowerSource(iData);
                    }
                }
        }
 private void SetPowerPlan(POWERBROADCAST_SETTING ps, IntPtr pData)
 {
     string eventText;
     if (ps.DataLength == Marshal.SizeOf(typeof(Guid)))
     {
         Guid newPersonality = (Guid)Marshal.PtrToStructure(pData, typeof(Guid));
         if (newPersonality == GUID_MAX_POWER_SAVINGS)
         {
             powerPlan = PowerPlan.PowerSaver;
             eventText = "Switched to Max Power savings";
         }
         else if (newPersonality == GUID_MIN_POWER_SAVINGS)
         {
             powerPlan = PowerPlan.HighPerformance;
             eventText = "Switched to Min Power savings";
         }
         else if (newPersonality == GUID_TYPICAL_POWER_SAVINGS)
         {
             powerPlan = PowerPlan.Automatic;
             eventText = "Switched to Automatic Power savings";
         }
         else
         {
             eventText = "switched to unknown Power savings";
         }
     }
 }
Exemple #3
0
        // MONITOR SLEEP DETECTION
        protected override void WndProc(ref Message m)
        {
            if (m.Msg == WM_POWERBROADCAST && m.WParam.ToInt32() == PBT_POWERSETTINGCHANGE)
            {
                POWERBROADCAST_SETTING ps = (POWERBROADCAST_SETTING)Marshal.PtrToStructure(m.LParam, typeof(POWERBROADCAST_SETTING));

                try
                {
                    switch (ps.Data)
                    {
                    // defined at http://msdn.microsoft.com/en-us/library/windows/desktop/hh448380(v=vs.85).aspx
                    case 0:
                        Monitor_Sleeping = true;
                        break;

                    case 1:
                        Monitor_Sleeping = false;
                        break;
                    }
                }
                catch
                {
                    // failed to communicate
                    // For now, just ignore. Might be nice to retry in the future.
                }
            }

            base.WndProc(ref m);
        }
Exemple #4
0
        private static IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
        {
            // We're only interested in WM_POWERBROADCAST (0x0218) messages with wParam of PBT_POWERSETTINGCHANGE (0x8013)
            if (msg == 0x0218 && (int)wParam == 0x8013)
            {
                POWERBROADCAST_SETTING settingMessage =
                    (POWERBROADCAST_SETTING)Marshal.PtrToStructure(
                        lParam,
                        typeof(POWERBROADCAST_SETTING));

                // We're only interested if the PowerSetting changed is GUID_POWERSCHEME_PERSONALITY
                if (settingMessage.PowerSetting == GUID_POWERSCHEME_PERSONALITY && settingMessage.DataLength == Marshal.SizeOf(typeof(Guid)))
                {
                    try
                    {
                        Win32Interop.PowerSchemeChanged?.Invoke(null, EventArgs.Empty);
                    }
                    catch
                    {
                        // TODO: log?  Or is that too expensive here?
                    }
                }
            }

            handled = false;
            return(IntPtr.Zero);
        }
        public void Message(int msg, IntPtr wParam, IntPtr lParam)
        {
            if (msg != WM_POWERBROADCAST)
            {
                return;
            }
            if (wParam.ToInt32() != PBT_POWERSETTINGCHANGE)
            {
                return;
            }

            POWERBROADCAST_SETTING ps = (POWERBROADCAST_SETTING)Marshal.PtrToStructure(lParam, typeof(POWERBROADCAST_SETTING));

            if (ps.PowerSetting != GUID_MONITOR_POWER_ON && ps.PowerSetting != GUID_CONSOLE_DISPLAY_STATE)
            {
                return;
            }

            if (ps.DataLength != Marshal.SizeOf(typeof(Int32)))
            {
                return;
            }

            IntPtr pData = IntPtr.Add(lParam, Marshal.SizeOf(ps));

            Int32 iData = (Int32)Marshal.PtrToStructure(pData, typeof(Int32));

            Notify(iData == 0);
        }
 protected override void WndProc(ref Message m)
 {
     if (m.Msg.Equals(WM_POWERBROADCAST))
     {
         POWERBROADCAST_SETTING setting = (POWERBROADCAST_SETTING)Marshal.PtrToStructure(m.LParam, typeof(POWERBROADCAST_SETTING));
         com.Write("led " + (setting.Data.Equals(0x0) ? "off" : "on"));
     }
     base.WndProc(ref m);
 }
Exemple #7
0
 protected override void WndProc(ref Message m)
 {
     if (m.Msg == UMsg.WM_POWERBROADCAST && m.WParam.ToInt32() == WParam.PBT_POWERSETTINGCHANGE)
     {
         POWERBROADCAST_SETTING powerBroadcastSetting = (POWERBROADCAST_SETTING)m.GetLParam(typeof(POWERBROADCAST_SETTING));
         if (powerBroadcastSetting.PowerSetting == GUID_POWERSCHEME_PERSONALITY)
         {
             OnPowerSettingChanged();
         }
     }
     base.WndProc(ref m);
 }
        // Generic power setting change message
        private void _ProcessPowerSettingChange(ref IntPtr lResult, IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam)
        {
            lResult = IntPtr.Zero;

            // Get the structure from the message
            var power = new POWERBROADCAST_SETTING();

            power.guidPowerSetting = (Guid)Marshal.PtrToStructure(lParam, typeof(Guid));
            power.dwDataLength     = (uint)Marshal.PtrToStructure(new IntPtr(lParam.ToInt64() + Marshal.SizeOf(typeof(Guid))), typeof(uint));
            power.bData            = new byte[power.dwDataLength];
            Marshal.Copy(new IntPtr(lParam.ToInt64() + Marshal.SizeOf(typeof(Guid))) + Marshal.SizeOf(typeof(uint)), power.bData, 0, power.bData.Length);

            // Search internal list, raise event
            var pg = _guids.Where((i) => i.Value.Guid == power.guidPowerSetting).First().Value;

            pg.RaiseNotified(pg.ParseFunc != null ? pg.ParseFunc(power.bData) : power.bData);
        }
        private void OnPowerBroadcast(IntPtr wParam, IntPtr lParam)
        {
            if ((int)wParam == PBT_POWERSETTINGCHANGE)
            {
                POWERBROADCAST_SETTING ps = (POWERBROADCAST_SETTING)Marshal.PtrToStructure(lParam, typeof(POWERBROADCAST_SETTING));

                if (ps.PowerSetting == GUID_LIDSWITCH_STATE_CHANGE)
                {
                    bool isLidOpen = ps.Data != 0;

                    if (!isLidOpen == _previousLidState)
                    {
                        LidStatusChanged(isLidOpen);
                    }

                    _previousLidState = isLidOpen;
                }
            }
        }
Exemple #10
0
        private void OnPowerBroadcast(IntPtr wParam, IntPtr lParam)
        {
            Console.WriteLine($"OnPowerBroadcast wParam={wParam}, lParam={lParam}");
            if ((int)wParam == PBT_POWERSETTINGCHANGE)
            {
                POWERBROADCAST_SETTING ps = (POWERBROADCAST_SETTING)Marshal.PtrToStructure(lParam, typeof(POWERBROADCAST_SETTING));
                IntPtr pData = (IntPtr)((int)lParam + Marshal.SizeOf(ps));
                Int32  iData = (Int32)Marshal.PtrToStructure(pData, typeof(Int32));
                if (ps.PowerSetting == GUID_LIDSWITCH_STATE_CHANGE)
                {
                    Console.WriteLine($"ps.PowerSetting: {ps.PowerSetting}");
                    bool isLidOpen = ps.Data != 0;

                    if (!isLidOpen == _previousLidState)
                    {
                        LidStatusChanged(isLidOpen);
                    }

                    _previousLidState = isLidOpen;
                }
            }
        }
Exemple #11
0
        internal void HandlePowerBroadcast(IntPtr wParam, IntPtr lParam)
        {
            var pbt = wParam.ToInt32();

            // https://docs.microsoft.com/en-us/windows/win32/power/power-setting-guids
            switch (pbt)
            {
            case PBT_POWERSETTINGCHANGE:
                POWERBROADCAST_SETTING pbSetting = (POWERBROADCAST_SETTING)Marshal.PtrToStructure(lParam, typeof(POWERBROADCAST_SETTING));
                if (pbSetting.PowerSetting == GUID_SESSION_USER_PRESENCE)
                {
                    // BUGBUG: Data is just a byte and we're lucky the MSB has our value in it
                    switch (pbSetting.Data)
                    {
                    case 0:         // PowerUserPresent (0) - The user is providing input to the session.
                        Logger.Instance.Log4.Info($"ActivityMonitor: PowerBroadcast: The user is providing input to the session.");
                        //this.Activity("PowerBroadcast: The user is providing input to the session");
                        break;


                    case 2:         // PowerUserInactive(2) - The user activity timeout has elapsed with no interaction from the user.
                        _PresencePresumedTimer.Enabled = false;
                        Logger.Instance.Log4.Info($"ActivityMonitor: PowerBroadcast: The user activity timeout has elapsed with no interaction from the user.");
                        break;

                    default:
                        Logger.Instance.Log4.Error($"ActivityMonitor: PowerBroadcast: Unknown GUID_SESSION_USER_PRESENCE data {pbSetting.Data}.");
                        break;
                    }
                }
                else if (pbSetting.PowerSetting == GUID_SYSTEM_AWAYMODE)
                {
                    // BUGBUG: Data is just a byte and we're lucky the MSB has our value in it
                    switch (pbSetting.Data)
                    {
                    case 0:         // 0x0 - The computer is exiting away mode.
                        Logger.Instance.Log4.Info($"ActivityMonitor: PowerBroadcast: The computer is exiting away mode.");
                        //this.Activity("PowerBroadcast: The computer is exiting away mode");
                        break;


                    case 1:         // 0x1 - The computer is entering away mode.
                        _PresencePresumedTimer.Enabled = false;
                        Logger.Instance.Log4.Info($"ActivityMonitor: PowerBroadcast: The computer is entering away mode.");
                        break;

                    default:
                        Logger.Instance.Log4.Error($"ActivityMonitor: PowerBroadcast: Unknown GUID_SYSTEM_AWAYMODE data {pbSetting.Data}.");
                        break;
                    }
                }
                else if (pbSetting.PowerSetting == GUID_MONITOR_POWER_ON)
                {
                    // BUGBUG: Data is just a byte and we're lucky the MSB has our value in it
                    switch (pbSetting.Data)
                    {
                    case 0:         // 0x0 - The monitor is off.
                        _PresencePresumedTimer.Enabled = false;
                        Logger.Instance.Log4.Info($"ActivityMonitor: PowerBroadcast: The monitor is off");
                        break;


                    case 1:         // 0x1 - The monitor is on.
                        Logger.Instance.Log4.Info($"ActivityMonitor: PowerBroadcast: The monitor is on");
                        //this.Activity("PowerBroadcast: The monitor is on.");
                        break;

                    default:
                        Logger.Instance.Log4.Error($"ActivityMonitor: PowerBroadcast: Unknown GUID_MONITOR_POWER_ON data {pbSetting.Data}.");
                        break;
                    }
                }
                break;

            default:
                Logger.Instance.Log4.Error($"ActivityMonitor: PowerBroadcast: Unknown PBT {pbt}.");
                break;
            }
        }
Exemple #12
0
        /// <summary>
        /// Check for power state changes, and pass up when it's something we don't care about
        /// </summary>
        /// <param name="msg">The incoming window message</param>
        protected override void WndProc(ref Message msg)
        {
            if (msg.Msg == WM_SYSCOMMAND && (msg.WParam.ToInt32() & 0xfff0) == SC_SCREENSAVE)
            {
                // there's no event for screensaver exit
                if (!_sstimer.Enabled)
                {
                    // guard against screensaver failing, and resulting in power up and down spam to the tv
                    TimeSpan diff = DateTime.Now - _lastScreensaverActivated;
                    if (diff.TotalSeconds > 60)
                    {
                        _sstimer.Enabled          = true;
                        _lastScreensaverActivated = DateTime.Now;
                        Controller.CECActions.SendStandby(CecLogicalAddress.Broadcast);
                    }
                }
            }
            else if (msg.Msg == WM_POWERBROADCAST)
            {
                switch (msg.WParam.ToInt32())
                {
                case PBT_APMSUSPEND:
                    OnSleep();
                    return;

                case PBT_APMRESUMESUSPEND:
                case PBT_APMRESUMECRITICAL:
                case PBT_APMRESUMEAUTOMATIC:
                    OnWake();
                    return;

                case PBT_POWERSETTINGCHANGE:
                {
                    POWERBROADCAST_SETTING pwr = (POWERBROADCAST_SETTING)Marshal.PtrToStructure(msg.LParam, typeof(POWERBROADCAST_SETTING));
                    if (pwr.PowerSetting == GUID_SYSTEM_AWAYMODE && pwr.DataLength == Marshal.SizeOf(typeof(Int32)))
                    {
                        switch (pwr.Data)
                        {
                        case 0:
                        // do _not_ wake the pc when away mode is deactivated
                        //OnWake();
                        //return;
                        case 1:
                            Controller.CECActions.SendStandby(CecLogicalAddress.Broadcast);
                            return;

                        default:
                            break;
                        }
                    }
                }
                break;

                default:
                    break;
                }
            }

            // pass up when not handled
            base.WndProc(ref msg);
        }
Exemple #13
0
        /// <summary>
        /// Transforms a Window/Service Message to PowerEventInfo
        /// </summary>
        public static PowerEventInfo TransformMessage(ref Message m)
        {
            if (m.Msg == WM_POWERBROADCAST)
            {
                switch ((int)m.WParam)
                {
                case (int)ServicesAPI.SERVICE_CONTROL_POWEREVENT_Control.PBT_APMBATTERYLOW:
                    return(new PowerEventInfo {
                        PowerEvent = (ServicesAPI.SERVICE_CONTROL_POWEREVENT_Control)(int)(m.WParam)
                    });

                case (int)ServicesAPI.SERVICE_CONTROL_POWEREVENT_Control.PBT_APMOEMEVENT:
                    return(new PowerEventInfo {
                        PowerEvent = (ServicesAPI.SERVICE_CONTROL_POWEREVENT_Control)(int)(m.WParam), OEMEventCode = (int)m.LParam
                    });

                case (int)ServicesAPI.SERVICE_CONTROL_POWEREVENT_Control.PBT_APMPOWERSTATUSCHANGE:
                {
                    var pei = new PowerEventInfo {
                        PowerEvent = (ServicesAPI.SERVICE_CONTROL_POWEREVENT_Control)(int)(m.WParam)
                    };
                    SYSTEM_POWER_STATUS sps = new SYSTEM_POWER_STATUS();
                    if (GetSystemPowerStatus(out sps))
                    {
                        pei.SYSTEM_POWER_STATUS = sps;
                    }
                    return(pei);
                }

                case (int)ServicesAPI.SERVICE_CONTROL_POWEREVENT_Control.PBT_APMQUERYSTANDBY:
                    return(new PowerEventInfo {
                        PowerEvent = (ServicesAPI.SERVICE_CONTROL_POWEREVENT_Control)(int)(m.WParam)
                    });

                case (int)ServicesAPI.SERVICE_CONTROL_POWEREVENT_Control.PBT_APMQUERYSTANDBYFAILED:
                    return(new PowerEventInfo {
                        PowerEvent = (ServicesAPI.SERVICE_CONTROL_POWEREVENT_Control)(int)(m.WParam)
                    });

                case (int)ServicesAPI.SERVICE_CONTROL_POWEREVENT_Control.PBT_APMQUERYSUSPEND:
                    return(new PowerEventInfo {
                        PowerEvent = (ServicesAPI.SERVICE_CONTROL_POWEREVENT_Control)(int)(m.WParam)
                    });

                case (int)ServicesAPI.SERVICE_CONTROL_POWEREVENT_Control.PBT_APMQUERYSUSPENDFAILED:
                    return(new PowerEventInfo {
                        PowerEvent = (ServicesAPI.SERVICE_CONTROL_POWEREVENT_Control)(int)(m.WParam)
                    });

                case (int)ServicesAPI.SERVICE_CONTROL_POWEREVENT_Control.PBT_APMRESUMEAUTOMATIC:
                    return(new PowerEventInfo {
                        PowerEvent = (ServicesAPI.SERVICE_CONTROL_POWEREVENT_Control)(int)(m.WParam)
                    });

                case (int)ServicesAPI.SERVICE_CONTROL_POWEREVENT_Control.PBT_APMRESUMECRITICAL:
                    return(new PowerEventInfo {
                        PowerEvent = (ServicesAPI.SERVICE_CONTROL_POWEREVENT_Control)(int)(m.WParam)
                    });

                case (int)ServicesAPI.SERVICE_CONTROL_POWEREVENT_Control.PBT_APMRESUMESTANDBY:
                    return(new PowerEventInfo {
                        PowerEvent = (ServicesAPI.SERVICE_CONTROL_POWEREVENT_Control)(int)(m.WParam)
                    });

                case (int)ServicesAPI.SERVICE_CONTROL_POWEREVENT_Control.PBT_APMRESUMESUSPEND:
                    return(new PowerEventInfo {
                        PowerEvent = (ServicesAPI.SERVICE_CONTROL_POWEREVENT_Control)(int)(m.WParam)
                    });

                case (int)ServicesAPI.SERVICE_CONTROL_POWEREVENT_Control.PBT_APMSTANDBY:
                    return(new PowerEventInfo {
                        PowerEvent = (ServicesAPI.SERVICE_CONTROL_POWEREVENT_Control)(int)(m.WParam)
                    });

                case (int)ServicesAPI.SERVICE_CONTROL_POWEREVENT_Control.PBT_APMSUSPEND:
                    return(new PowerEventInfo {
                        PowerEvent = (ServicesAPI.SERVICE_CONTROL_POWEREVENT_Control)(int)(m.WParam)
                    });

                case (int)ServicesAPI.SERVICE_CONTROL_POWEREVENT_Control.PBT_POWERSETTINGCHANGE:
                {
                    var pei = new PowerEventInfo {
                        PowerEvent = (ServicesAPI.SERVICE_CONTROL_POWEREVENT_Control)(int)(m.WParam)
                    };


                    POWERBROADCAST_SETTING ps = (POWERBROADCAST_SETTING)Marshal.PtrToStructure(m.LParam, typeof(POWERBROADCAST_SETTING));
                    IntPtr pData = (IntPtr)(m.LParam.ToInt32() + Marshal.SizeOf(ps));          // (*1)

                    if (ps.PowerSetting == PowerSettings.GUID_POWERSCHEME_PERSONALITY && ps.DataLength == Marshal.SizeOf(typeof(Guid)))
                    {
                        Guid newPersonality = (Guid)Marshal.PtrToStructure(pData, typeof(Guid));

                        if (newPersonality == PowerSettings.GUID_MAX_POWER_SAVINGS)
                        {
                            pei.PowerSavingsMode = PowerSavings.Max;
                        }
                        else if (newPersonality == PowerSettings.GUID_MIN_POWER_SAVINGS)
                        {
                            pei.PowerSavingsMode = PowerSavings.Min;
                        }
                        else if (newPersonality == PowerSettings.GUID_TYPICAL_POWER_SAVINGS)
                        {
                            pei.PowerSavingsMode = PowerSavings.Typical;
                        }
                        else
                        {
                            DebugLogger.WriteLine("switched to unknown Power savings");
                        }
                    }
                    else if (ps.PowerSetting == PowerSettings.GUID_ACDC_POWER_SOURCE && ps.DataLength == Marshal.SizeOf(typeof(Int32)))
                    {
                        Int32 iData = (Int32)Marshal.PtrToStructure(pData, typeof(Int32));
                        DebugLogger.WriteLine("ACDC: " + (PoweredBy)iData);

                        pei.PoweredBy = (PoweredBy)iData;
                        //onBattery = iData != 0;
                    }
                    else if (ps.PowerSetting == PowerSettings.GUID_ACTIVE_POWERSCHEME && ps.DataLength == Marshal.SizeOf(typeof(Guid)))
                    {
                        Guid schemeId = (Guid)Marshal.PtrToStructure(pData, typeof(Guid));
                        pei.CurrentPowerSchemeId = schemeId;
                        pei.CurrentPowerScheme   = ReadPowerSchemeFriendlyName(schemeId);
                    }
                    else if ((ps.PowerSetting == PowerSettings.GUID_CONSOLE_DISPLAY_STATE || ps.PowerSetting == PowerSettings.GUID_MONITOR_POWER_ON) && ps.DataLength == Marshal.SizeOf(typeof(Int32)))
                    {
                        Int32 iData = (Int32)Marshal.PtrToStructure(pData, typeof(Int32));
                        DebugLogger.WriteLine("monitor's display state: " + (MonitorDisplayState)iData);
                        pei.CurrentMonitorDisplayState = (MonitorDisplayState)iData;
                    }
                    else if (ps.PowerSetting == PowerSettings.GUID_IDLE_BACKGROUND_TASK)
                    {
                        pei.Idle = DateTime.UtcNow;
                    }
                    else if (ps.PowerSetting == PowerSettings.GUID_BATTERY_PERCENTAGE_REMAINING)
                    {
                        Int32 iData = (Int32)Marshal.PtrToStructure(pData, typeof(Int32));
                        DebugLogger.WriteLine("Battery Power Remaining: " + iData);

                        pei.BatteryPowerRemaining = iData;
                    }
                    else if (ps.PowerSetting == PowerSettings.GUID_LIDSWITCH_STATE_CHANGE)
                    {
                        Int32 iData = (Int32)Marshal.PtrToStructure(pData, typeof(Int32));
                        DebugLogger.WriteLine("Lid Open: " + iData);

                        pei.LidOpen = (iData == 1);
                    }
                    else
                    {
                        DebugLogger.WriteLine("Unknown power setting {0}", ps.PowerSetting);
                    }
                    return(pei);
                }
                }
            }

            DebugLogger.WriteLine("Unhandled Power notification " + m.ToString());
            return(null);
        }
Exemple #14
0
        public bool WndProc(ref Message msg)
        {
            if (msg.Msg == WM_POWERBROADCAST)
            {
                switch (msg.WParam.ToInt32())
                {
                case PBT_APMSUSPEND:

                    if (!_sleep)
                    {
                        _sleep = true;

                        Log.Info("CecRemote: PowerControl: System going to sleep, stopping CEC-client...");

                        if (_client != null)
                        {
                            _client.OnSleep();
                        }
                    }
                    else
                    {
                        Log.Warn("CecRemote: PowerControl: Received PBT_APMSUSPEND when remote state already suspended");
                    }

                    break;

                case PBT_APMRESUMESUSPEND:

                    Log.Info("CecRemote: PowerControl: User input detected after sleep (APMRESUMESUSPEND)");
                    HandleResume(false);

                    break;

                case PBT_APMRESUMEAUTOMATIC:

                    Log.Info("CecRemote: PowerControl: System resuming from sleep (APMRESUMEAUTOMATIC)");
                    HandleResume(true);

                    break;

                // Handle awaymode
                case PBT_POWERSETTINGCHANGE:

                    POWERBROADCAST_SETTING ps = (POWERBROADCAST_SETTING)Marshal.PtrToStructure(msg.LParam, typeof(POWERBROADCAST_SETTING));

                    if (ps.PowerSetting == GUID_SYSTEM_AWAYMODE)
                    {
                        if (ps.Data == 0)
                        {
                            if (_away && !_sleep)
                            {
                                _away = false;
                                Log.Info("CecRemote: PowerControl: System exiting away mode");
                                HandleResume(false);
                            }
                            else
                            {
                                Log.Warn("CecRemote: PowerControl: Received GUID_SYSTEM_AWAYMODE 0 and sleepmode is {0} and awaymode is {1}", _sleep.ToString(), _away.ToString());
                            }
                        }
                        else
                        {
                            if (!_away)
                            {
                                _away = true;
                                Log.Info("CecRemote: PowerControl: System entering away mode");

                                if (_client != null)
                                {
                                    _client.OnAwayMode();
                                }
                            }
                            else
                            {
                                Log.Warn("CecRemote: PowerControl: Received GUID_SYSTEM_AWAYMODE 1 and awaymode is {0}", _away.ToString());
                            }
                        }
                    }

                    break;


                default:
                    break;
                }
            }

            return(false); // false = allow other plugins to handle the message
        }