001-simplepm.patch 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. diff -Nur xbmc-12.3-Frodo.orig/xbmc/powermanagement/linux/LinuxPowerSyscall.cpp xbmc-12.3-Frodo/xbmc/powermanagement/linux/LinuxPowerSyscall.cpp
  2. --- xbmc-12.3-Frodo.orig/xbmc/powermanagement/linux/LinuxPowerSyscall.cpp 1970-01-01 01:00:00.000000000 +0100
  3. +++ xbmc-12.3-Frodo/xbmc/powermanagement/linux/LinuxPowerSyscall.cpp 2014-01-10 16:23:32.238217592 +0100
  4. @@ -0,0 +1,55 @@
  5. +/*
  6. + * Copyright (C) 2014 Team XBMC
  7. + * http://www.xbmc.org
  8. + *
  9. + * This Program is free software; you can redistribute it and/or modify
  10. + * it under the terms of the GNU General Public License as published by
  11. + * the Free Software Foundation; either version 2, or (at your option)
  12. + * any later version.
  13. + *
  14. + * This Program is distributed in the hope that it will be useful,
  15. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. + * GNU General Public License for more details.
  18. + *
  19. + * You should have received a copy of the GNU General Public License
  20. + * along with XBMC; see the file COPYING. If not, see
  21. + * <http://www.gnu.org/licenses/>.
  22. + *
  23. + */
  24. +
  25. +#if defined (_LINUX)
  26. +
  27. +#include <stdlib.h>
  28. +#include "LinuxPowerSyscall.h"
  29. +#include "utils/log.h"
  30. +
  31. +CLinuxPowerSyscall::CLinuxPowerSyscall()
  32. +{
  33. + CLog::Log(LOGINFO, "Selected LinuxPower as PowerSyscall");
  34. +}
  35. +
  36. +CLinuxPowerSyscall::~CLinuxPowerSyscall()
  37. +{ }
  38. +
  39. +bool CLinuxPowerSyscall::Powerdown()
  40. +{
  41. + system("/sbin/poweroff -F");
  42. + return 0;
  43. +}
  44. +
  45. +bool CLinuxPowerSyscall::Reboot()
  46. +{
  47. + system("/sbin/reboot -F");
  48. + return 0;
  49. +}
  50. +
  51. +int CLinuxPowerSyscall::BatteryLevel(void)
  52. +{ }
  53. +
  54. +bool CLinuxPowerSyscall::PumpPowerEvents(IPowerEventsCallback *callback)
  55. +{
  56. + return true;
  57. +}
  58. +
  59. +#endif
  60. diff -Nur xbmc-12.3-Frodo.orig/xbmc/powermanagement/linux/LinuxPowerSyscall.h xbmc-12.3-Frodo/xbmc/powermanagement/linux/LinuxPowerSyscall.h
  61. --- xbmc-12.3-Frodo.orig/xbmc/powermanagement/linux/LinuxPowerSyscall.h 1970-01-01 01:00:00.000000000 +0100
  62. +++ xbmc-12.3-Frodo/xbmc/powermanagement/linux/LinuxPowerSyscall.h 2014-01-10 14:57:23.365205874 +0100
  63. @@ -0,0 +1,44 @@
  64. +#pragma once
  65. +/*
  66. + * Copyright (C) 2014 Team XBMC
  67. + * http://www.xbmc.org
  68. + *
  69. + * This Program is free software; you can redistribute it and/or modify
  70. + * it under the terms of the GNU General Public License as published by
  71. + * the Free Software Foundation; either version 2, or (at your option)
  72. + * any later version.
  73. + *
  74. + * This Program is distributed in the hope that it will be useful,
  75. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  76. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  77. + * GNU General Public License for more details.
  78. + *
  79. + * You should have received a copy of the GNU General Public License
  80. + * along with XBMC; see the file COPYING. If not, see
  81. + * <http://www.gnu.org/licenses/>.
  82. + *
  83. + */
  84. +
  85. +#if defined (_LINUX)
  86. +#include "powermanagement/IPowerSyscall.h"
  87. +
  88. +class CLinuxPowerSyscall : public CPowerSyscallWithoutEvents
  89. +{
  90. +public:
  91. + CLinuxPowerSyscall();
  92. + ~CLinuxPowerSyscall();
  93. +
  94. + virtual bool Powerdown();
  95. + virtual bool Suspend(void) { return false; }
  96. + virtual bool Hibernate(void) { return false; }
  97. + virtual bool Reboot();
  98. +
  99. + virtual bool CanPowerdown(void) { return true; }
  100. + virtual bool CanSuspend(void) { return false; }
  101. + virtual bool CanHibernate(void) { return false; }
  102. + virtual bool CanReboot(void) { return true; }
  103. + virtual int BatteryLevel(void);
  104. +
  105. + virtual bool PumpPowerEvents(IPowerEventsCallback *callback);
  106. +};
  107. +#endif
  108. diff -Nur xbmc-12.3-Frodo.orig/xbmc/powermanagement/linux/Makefile xbmc-12.3-Frodo/xbmc/powermanagement/linux/Makefile
  109. --- xbmc-12.3-Frodo.orig/xbmc/powermanagement/linux/Makefile 2013-12-12 22:47:49.000000000 +0100
  110. +++ xbmc-12.3-Frodo/xbmc/powermanagement/linux/Makefile 2014-01-10 14:27:13.411383558 +0100
  111. @@ -2,7 +2,8 @@
  112. ConsoleUPowerSyscall.cpp \
  113. HALPowerSyscall.cpp \
  114. UPowerSyscall.cpp \
  115. - SystemdUPowerSyscall.cpp
  116. + SystemdUPowerSyscall.cpp \
  117. + LinuxPowerSyscall.cpp
  118. LIB=powermanagement_linux.a
  119. diff -Nur xbmc-12.3-Frodo.orig/xbmc/powermanagement/PowerManager.cpp xbmc-12.3-Frodo/xbmc/powermanagement/PowerManager.cpp
  120. --- xbmc-12.3-Frodo.orig/xbmc/powermanagement/PowerManager.cpp 2013-12-12 22:47:49.000000000 +0100
  121. +++ xbmc-12.3-Frodo/xbmc/powermanagement/PowerManager.cpp 2014-01-14 11:19:11.558337441 +0100
  122. @@ -46,6 +46,9 @@
  123. #include "linux/ConsoleDeviceKitPowerSyscall.h"
  124. #include "linux/SystemdUPowerSyscall.h"
  125. #include "linux/UPowerSyscall.h"
  126. +#ifdef HAS_SIMPLEPM
  127. +#include "linux/LinuxPowerSyscall.h"
  128. +#endif
  129. #ifdef HAS_HAL
  130. #include "linux/HALPowerSyscall.h"
  131. #endif
  132. @@ -83,6 +86,10 @@
  133. m_instance = new CSystemdUPowerSyscall();
  134. else if (CUPowerSyscall::HasUPower())
  135. m_instance = new CUPowerSyscall();
  136. +#ifdef HAS_SIMPLEPM
  137. + else
  138. + m_instance = new CLinuxPowerSyscall();
  139. +#endif
  140. #ifdef HAS_HAL
  141. else
  142. m_instance = new CHALPowerSyscall();