Added the beginnings of our power management daemon. Currently does nothing except tell the roster to shut down when you press the power button (in conjuction with acpi_button, of course). Eventually will do things like display low power warnings, spin down hard disks, and display the requisite power info deskbar replicant.
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@11466 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
#include <Messenger.h>
|
||||
#include <Roster.h>
|
||||
|
||||
#include "power_button_monitor.h"
|
||||
|
||||
#define B_SYSTEM_SHUTDOWN 0x12d
|
||||
static const char *kRosterSignature = "application/x-vnd.Be-ROST";
|
||||
|
||||
PowerButtonMonitor::PowerButtonMonitor() : BHandler ("power_button_monitor") {
|
||||
power_button_fd = open("/dev/power/button/power",O_RDONLY);
|
||||
}
|
||||
|
||||
PowerButtonMonitor::~PowerButtonMonitor() {
|
||||
if (power_button_fd > 0)
|
||||
close(power_button_fd);
|
||||
}
|
||||
|
||||
void PowerButtonMonitor::MessageReceived(BMessage *msg) {
|
||||
if (msg->what != POLL_POWER_BUTTON_STATUS)
|
||||
return;
|
||||
|
||||
if (power_button_fd <= 0)
|
||||
return;
|
||||
|
||||
bool button_pressed;
|
||||
read(power_button_fd,&button_pressed,1);
|
||||
|
||||
if (button_pressed)
|
||||
BMessenger(kRosterSignature).SendMessage(B_SYSTEM_SHUTDOWN);
|
||||
}
|
||||
Reference in New Issue
Block a user