PowerComponentDBus.h 970 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #ifndef POWERCOMPONENTDBUS_H
  2. #define POWERCOMPONENTDBUS_H
  3. #include "PowerComponent.h"
  4. class PowerComponentDBus : public PowerComponent
  5. {
  6. public:
  7. PowerComponentDBus() : PowerComponent(0) {};
  8. ~PowerComponentDBus() {};
  9. public Q_SLOTS:
  10. virtual int getPowerCapabilities() override
  11. {
  12. int flags = 0;
  13. if (isPowerMethodAvailable("CanPowerOff"))
  14. flags |= CAP_POWER_OFF;
  15. if (isPowerMethodAvailable("CanReboot"))
  16. flags |= CAP_REBOOT;
  17. if (isPowerMethodAvailable("CanSuspend"))
  18. flags |= CAP_SUSPEND;
  19. return flags;
  20. }
  21. virtual bool PowerOff();
  22. virtual bool Reboot();
  23. virtual bool Suspend() { return callPowerMethod("Suspend"); }
  24. private:
  25. bool callPowerMethod(QString method);
  26. bool isPowerMethodAvailable(QString method);
  27. unsigned int screensaver_inhibit_cookie = 0;
  28. protected:
  29. virtual void doDisableScreensaver();
  30. virtual void doEnableScreensaver();
  31. };
  32. #endif // POWERCOMPONENTDBUS_H