Use the new private roster API to shutdown.
Maybe we should have a confirmation alert the first time ? Btw, the power_button driver should really implement select() or some other non-polling mechanism, it sux having to waste cpu. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42934 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
397fbc47bb
commit
0fa0204f7c
@ -1,5 +1,7 @@
|
||||
SubDir HAIKU_TOP src servers power ;
|
||||
|
||||
UsePrivateHeaders app ;
|
||||
|
||||
AddResources power_daemon : power_daemon.rdef ;
|
||||
|
||||
Server power_daemon :
|
||||
|
@ -1,10 +1,10 @@
|
||||
#include <Messenger.h>
|
||||
#include <Roster.h>
|
||||
|
||||
#include <RosterPrivate.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);
|
||||
@ -22,9 +22,13 @@ void PowerButtonMonitor::MessageReceived(BMessage *msg) {
|
||||
if (power_button_fd <= 0)
|
||||
return;
|
||||
|
||||
bool button_pressed;
|
||||
uint8 button_pressed;
|
||||
read(power_button_fd,&button_pressed,1);
|
||||
|
||||
if (button_pressed)
|
||||
BMessenger(kRosterSignature).SendMessage(B_SYSTEM_SHUTDOWN);
|
||||
if (button_pressed) {
|
||||
BRoster roster;
|
||||
BRoster::Private rosterPrivate(roster);
|
||||
|
||||
rosterPrivate.ShutDown(false, false, false);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user