Disable Hibernate and Suspend related power options for Raspberry & Co. without ...
authorStephan Raue <stephan@openelec.tv>
Thu, 1 Aug 2013 23:32:03 +0000 (01:32 +0200)
committerStephan Raue <stephan@openelec.tv>
Fri, 2 Aug 2013 11:49:27 +0000 (13:49 +0200)
xbmc/powermanagement/PowerManager.cpp
xbmc/powermanagement/linux/FallbackPowerSyscall.h [new file with mode: 0644]

index d658a97..993477e 100644 (file)
 #include "osx/CocoaPowerSyscall.h"
 #elif defined(TARGET_ANDROID)
 #include "android/AndroidPowerSyscall.h"
-#elif defined(TARGET_POSIX) && defined(HAS_DBUS)
+#elif defined(TARGET_POSIX)
+#include "linux/FallbackPowerSyscall.h"
+#if defined(HAS_DBUS)
 #include "linux/ConsoleUPowerSyscall.h"
 #include "linux/ConsoleDeviceKitPowerSyscall.h"
 #include "linux/LogindUPowerSyscall.h"
 #include "linux/UPowerSyscall.h"
-#ifdef HAS_HAL
+#if defined(HAS_HAL)
 #include "linux/HALPowerSyscall.h"
-#endif
+#endif // HAS_HAL
+#endif // HAS_DBUS
 #elif defined(TARGET_WINDOWS)
 #include "powermanagement/windows/Win32PowerSyscall.h"
 extern HWND g_hWnd;
@@ -73,7 +76,8 @@ void CPowerManager::Initialize()
   m_instance = new CCocoaPowerSyscall();
 #elif defined(TARGET_ANDROID)
   m_instance = new CAndroidPowerSyscall();
-#elif defined(TARGET_POSIX) && defined(HAS_DBUS)
+#elif defined(TARGET_POSIX)
+#if defined(HAS_DBUS)
   if (CConsoleUPowerSyscall::HasConsoleKitAndUPower())
     m_instance = new CConsoleUPowerSyscall();
   else if (CConsoleDeviceKitPowerSyscall::HasDeviceConsoleKit())
@@ -82,10 +86,13 @@ void CPowerManager::Initialize()
     m_instance = new CLogindUPowerSyscall();
   else if (CUPowerSyscall::HasUPower())
     m_instance = new CUPowerSyscall();
-#ifdef HAS_HAL
-  else
+#if defined(HAS_HAL)
+  else if(1)
     m_instance = new CHALPowerSyscall();
-#endif
+#endif // HAS_HAL
+  else
+#endif // HAS_DBUS
+    m_instance = new CFallbackPowerSyscall();
 #elif defined(TARGET_WINDOWS)
   m_instance = new CWin32PowerSyscall();
 #endif
diff --git a/xbmc/powermanagement/linux/FallbackPowerSyscall.h b/xbmc/powermanagement/linux/FallbackPowerSyscall.h
new file mode 100644 (file)
index 0000000..a6ed27b
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ *      Copyright (C) 2005-2013 Team XBMC
+ *      http://xbmc.org
+ *
+ *  This Program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2, or (at your option)
+ *  any later version.
+ *
+ *  This Program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with XBMC; see the file COPYING.  If not, see
+ *  <http://www.gnu.org/licenses/>.
+ *
+ */
+#pragma once
+#include "powermanagement/IPowerSyscall.h"
+#include "system.h"
+#if defined(TARGET_POSIX)
+
+class CFallbackPowerSyscall : public CPowerSyscallWithoutEvents
+{
+public:
+  virtual bool Powerdown() {return true; }
+  virtual bool Suspend() {return false; }
+  virtual bool Hibernate() {return false; }
+  virtual bool Reboot() {return true; }
+
+  virtual bool CanPowerdown() {return true; }
+  virtual bool CanSuspend() {return false; }
+  virtual bool CanHibernate() {return false; }
+  virtual bool CanReboot() {return true; }
+  virtual int  BatteryLevel() {return 0; }
+};
+#endif