|
|
@ -7,12 +7,63 @@
|
|
|
|
#include <string.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include <tqdbusconnection.h>
|
|
|
|
|
|
|
|
#include <tqdbusdata.h>
|
|
|
|
|
|
|
|
#include <tqdbusdatamap.h>
|
|
|
|
|
|
|
|
#include <tqdbuserror.h>
|
|
|
|
|
|
|
|
#include <tqdbusmessage.h>
|
|
|
|
|
|
|
|
#include <tqdbusproxy.h>
|
|
|
|
|
|
|
|
#include <tqdbusvariant.h>
|
|
|
|
|
|
|
|
|
|
|
|
// Input devices
|
|
|
|
// Input devices
|
|
|
|
#include <linux/input.h>
|
|
|
|
#include <linux/input.h>
|
|
|
|
|
|
|
|
|
|
|
|
#define BITS_PER_LONG (sizeof(long) * 8)
|
|
|
|
#define BITS_PER_LONG (sizeof(long) * 8)
|
|
|
|
#define NUM_BITS(x) ((((x) - 1) / BITS_PER_LONG) + 1)
|
|
|
|
#define NUM_BITS(x) ((((x) - 1) / BITS_PER_LONG) + 1)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool checkPolKitAuthorization(DBusMessage* msg, const TQString &action_id)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (!msg) {
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
TQT_DBusConnection dbusConn = TQT_DBusConnection::addConnection(TQT_DBusConnection::SystemBus);
|
|
|
|
|
|
|
|
if (!dbusConn.isConnected()) {
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
TQT_DBusProxy polkitProxy("org.freedesktop.PolicyKit1", "/org/freedesktop/PolicyKit1/Authority",
|
|
|
|
|
|
|
|
"org.freedesktop.PolicyKit1.Authority", dbusConn);
|
|
|
|
|
|
|
|
if (polkitProxy.canSend()) {
|
|
|
|
|
|
|
|
// Check whether the requested action is authorized
|
|
|
|
|
|
|
|
TQString sender(dbus_message_get_sender(msg));
|
|
|
|
|
|
|
|
TQT_DBusVariant sysname;
|
|
|
|
|
|
|
|
sysname.value = TQT_DBusData::fromString(sender);
|
|
|
|
|
|
|
|
sysname.signature = sysname.value.buildDBusSignature();
|
|
|
|
|
|
|
|
TQT_DBusDataMap<TQString> subjectMap = TQT_DBusDataMap<TQString>();
|
|
|
|
|
|
|
|
subjectMap.insert(TQString("name"), TQT_DBusData::fromVariant(sysname));
|
|
|
|
|
|
|
|
TQValueList<TQT_DBusData> subjectStruct;
|
|
|
|
|
|
|
|
subjectStruct << TQT_DBusData::fromString("system-bus-name");
|
|
|
|
|
|
|
|
subjectStruct << TQT_DBusData::fromStringKeyMap(subjectMap);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TQMap<TQString, TQString> detailsMap;
|
|
|
|
|
|
|
|
detailsMap.insert(TQString(""), TQString(""));
|
|
|
|
|
|
|
|
TQT_DBusDataMap<TQString> dbusDetailsMap(detailsMap);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TQValueList<TQT_DBusData> params;
|
|
|
|
|
|
|
|
params << TQT_DBusData::fromStruct(subjectStruct);
|
|
|
|
|
|
|
|
params << TQT_DBusData::fromString(action_id);
|
|
|
|
|
|
|
|
params << TQT_DBusData::fromStringKeyMap(dbusDetailsMap);
|
|
|
|
|
|
|
|
params << TQT_DBusData::fromUInt32(0); // No user interaction
|
|
|
|
|
|
|
|
params << TQT_DBusData::fromString(""); // No cancellation
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TQT_DBusMessage reply = polkitProxy.sendWithReply("CheckAuthorization", params);
|
|
|
|
|
|
|
|
if (reply.type() == TQT_DBusMessage::ReplyMessage && reply.count() == 1) {
|
|
|
|
|
|
|
|
return (reply[0].toStruct())[0].toBool();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void reply_Bool(DBusMessage* msg, DBusConnection* conn, int value) {
|
|
|
|
void reply_Bool(DBusMessage* msg, DBusConnection* conn, int value) {
|
|
|
|
DBusMessage* reply;
|
|
|
|
DBusMessage* reply;
|
|
|
|
DBusMessageIter args;
|
|
|
|
DBusMessageIter args;
|
|
|
@ -513,7 +564,7 @@ void reply_Introspect(DBusMessage* msg, DBusConnection* conn) {
|
|
|
|
size_t size = 4096;
|
|
|
|
size_t size = 4096;
|
|
|
|
const char* member = dbus_message_get_member(msg);
|
|
|
|
const char* member = dbus_message_get_member(msg);
|
|
|
|
const char *path = dbus_message_get_path(msg);
|
|
|
|
const char *path = dbus_message_get_path(msg);
|
|
|
|
char *data = malloc(size);
|
|
|
|
char *data = new char[size];
|
|
|
|
|
|
|
|
|
|
|
|
// compose reply
|
|
|
|
// compose reply
|
|
|
|
strncpy(data,
|
|
|
|
strncpy(data,
|
|
|
@ -632,7 +683,7 @@ void reply_Introspect(DBusMessage* msg, DBusConnection* conn) {
|
|
|
|
|
|
|
|
|
|
|
|
// free the reply
|
|
|
|
// free the reply
|
|
|
|
dbus_message_unref(reply);
|
|
|
|
dbus_message_unref(reply);
|
|
|
|
free((void*)data);
|
|
|
|
delete[] data;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void reply_PropertiesGetAll(DBusMessage* msg, DBusConnection* conn) {
|
|
|
|
void reply_PropertiesGetAll(DBusMessage* msg, DBusConnection* conn) {
|
|
|
@ -667,11 +718,8 @@ void reply_PropertiesGetAll(DBusMessage* msg, DBusConnection* conn) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void error_UnknownMessage(DBusMessage* msg, DBusConnection* conn) {
|
|
|
|
void error_UnknownMessage(DBusMessage* msg, DBusConnection* conn) {
|
|
|
|
DBusMessage* reply;
|
|
|
|
|
|
|
|
dbus_uint32_t serial = 0;
|
|
|
|
|
|
|
|
const char* member = dbus_message_get_member(msg);
|
|
|
|
const char* member = dbus_message_get_member(msg);
|
|
|
|
const char* interface = dbus_message_get_interface(msg);
|
|
|
|
const char* interface = dbus_message_get_interface(msg);
|
|
|
|
|
|
|
|
|
|
|
|
// print message
|
|
|
|
// print message
|
|
|
|
fprintf(stderr, "[tde_dbus_hardwarecontrol] Unknown method '%s' called on interface '%s', ignoring\n", member, interface);
|
|
|
|
fprintf(stderr, "[tde_dbus_hardwarecontrol] Unknown method '%s' called on interface '%s', ignoring\n", member, interface);
|
|
|
|
if (DBUS_MESSAGE_TYPE_METHOD_CALL != dbus_message_get_type(msg)) {
|
|
|
|
if (DBUS_MESSAGE_TYPE_METHOD_CALL != dbus_message_get_type(msg)) {
|
|
|
@ -679,12 +727,13 @@ void error_UnknownMessage(DBusMessage* msg, DBusConnection* conn) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// create a reply from the message
|
|
|
|
// create a reply from the message
|
|
|
|
reply = dbus_message_new_error_printf(msg,
|
|
|
|
DBusMessage* reply = dbus_message_new_error_printf(msg,
|
|
|
|
"org.freedesktop.DBus.Error.UnknownMethod",
|
|
|
|
"org.freedesktop.DBus.Error.UnknownMethod",
|
|
|
|
"Method \"%s\" on interface \"%s\" doesn't exist",
|
|
|
|
"Method \"%s\" on interface \"%s\" doesn't exist",
|
|
|
|
member, interface);
|
|
|
|
member, interface);
|
|
|
|
|
|
|
|
|
|
|
|
// send the reply && flush the connection
|
|
|
|
// send the reply && flush the connection
|
|
|
|
|
|
|
|
dbus_uint32_t serial = 0;
|
|
|
|
if (!dbus_connection_send(conn, reply, &serial)) {
|
|
|
|
if (!dbus_connection_send(conn, reply, &serial)) {
|
|
|
|
fprintf(stderr, "[tde_dbus_hardwarecontrol] %s: dbus_connection_send failed\n", member);
|
|
|
|
fprintf(stderr, "[tde_dbus_hardwarecontrol] %s: dbus_connection_send failed\n", member);
|
|
|
|
return;
|
|
|
|
return;
|
|
|
@ -695,6 +744,23 @@ void error_UnknownMessage(DBusMessage* msg, DBusConnection* conn) {
|
|
|
|
dbus_message_unref(reply);
|
|
|
|
dbus_message_unref(reply);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void error_PolkitAccessDenied(DBusMessage* msg, DBusConnection* conn) {
|
|
|
|
|
|
|
|
// create a reply from the message
|
|
|
|
|
|
|
|
DBusMessage* reply = dbus_message_new_error(msg,
|
|
|
|
|
|
|
|
"org.freedesktop.DBus.Error.AccessDenied", "Permission denied.");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// send the reply && flush the connection
|
|
|
|
|
|
|
|
dbus_uint32_t serial = 0;
|
|
|
|
|
|
|
|
if (!dbus_connection_send(conn, reply, &serial)) {
|
|
|
|
|
|
|
|
fprintf(stderr, "[tde_dbus_hardwarecontrol] error_PolkitAccessDenied: dbus_connection_send failed\n");
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
dbus_connection_flush(conn);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// free the reply
|
|
|
|
|
|
|
|
dbus_message_unref(reply);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void listen() {
|
|
|
|
void listen() {
|
|
|
|
DBusMessage* msg;
|
|
|
|
DBusMessage* msg;
|
|
|
|
DBusConnection* conn;
|
|
|
|
DBusConnection* conn;
|
|
|
@ -753,69 +819,129 @@ void listen() {
|
|
|
|
reply_SetBrightness(msg, conn);
|
|
|
|
reply_SetBrightness(msg, conn);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (dbus_message_is_method_call(msg, "org.trinitydesktop.hardwarecontrol.Power", "CanFreeze")) {
|
|
|
|
else if (dbus_message_is_method_call(msg, "org.trinitydesktop.hardwarecontrol.Power", "CanFreeze")) {
|
|
|
|
bool result = CanSetPowerState("freeze", NULL, NULL) || CanSetPowerState("mem", NULL, "s2idle");
|
|
|
|
bool result = checkPolKitAuthorization(msg, "org.trinitydesktop.hardwarecontrol.power.freeze");
|
|
|
|
reply_Bool(msg, conn, result);
|
|
|
|
if (!result) {
|
|
|
|
|
|
|
|
error_PolkitAccessDenied(msg, conn);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
result = CanSetPowerState("freeze", NULL, NULL) || CanSetPowerState("mem", NULL, "s2idle");
|
|
|
|
|
|
|
|
reply_Bool(msg, conn, result);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (dbus_message_is_method_call(msg, "org.trinitydesktop.hardwarecontrol.Power", "Freeze")) {
|
|
|
|
else if (dbus_message_is_method_call(msg, "org.trinitydesktop.hardwarecontrol.Power", "Freeze")) {
|
|
|
|
bool result = false;
|
|
|
|
bool result = checkPolKitAuthorization(msg, "org.trinitydesktop.hardwarecontrol.power.freeze");
|
|
|
|
if (CanSetPowerState("freeze", NULL, NULL)) {
|
|
|
|
if (!result) {
|
|
|
|
result = SetPowerState("freeze", NULL, NULL);
|
|
|
|
error_PolkitAccessDenied(msg, conn);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (CanSetPowerState("mem", NULL, "s2idle")) {
|
|
|
|
else {
|
|
|
|
result = SetPowerState("mem", NULL, "s2idle");
|
|
|
|
result = false;
|
|
|
|
|
|
|
|
if (CanSetPowerState("freeze", NULL, NULL)) {
|
|
|
|
|
|
|
|
result = SetPowerState("freeze", NULL, NULL);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (CanSetPowerState("mem", NULL, "s2idle")) {
|
|
|
|
|
|
|
|
result = SetPowerState("mem", NULL, "s2idle");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
reply_Bool(msg, conn, result);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
reply_Bool(msg, conn, result);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (dbus_message_is_method_call(msg, "org.trinitydesktop.hardwarecontrol.Power", "CanStandby")) {
|
|
|
|
else if (dbus_message_is_method_call(msg, "org.trinitydesktop.hardwarecontrol.Power", "CanStandby")) {
|
|
|
|
bool result = CanSetPowerState("standby", NULL, NULL) || CanSetPowerState("mem", NULL, "shallow");
|
|
|
|
bool result = checkPolKitAuthorization(msg, "org.trinitydesktop.hardwarecontrol.power.standby");
|
|
|
|
reply_Bool(msg, conn, result);
|
|
|
|
if (!result) {
|
|
|
|
|
|
|
|
error_PolkitAccessDenied(msg, conn);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
result = CanSetPowerState("standby", NULL, NULL) || CanSetPowerState("mem", NULL, "shallow");
|
|
|
|
|
|
|
|
reply_Bool(msg, conn, result);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (dbus_message_is_method_call(msg, "org.trinitydesktop.hardwarecontrol.Power", "Standby")) {
|
|
|
|
else if (dbus_message_is_method_call(msg, "org.trinitydesktop.hardwarecontrol.Power", "Standby")) {
|
|
|
|
bool result = false;
|
|
|
|
bool result = checkPolKitAuthorization(msg, "org.trinitydesktop.hardwarecontrol.power.standby");
|
|
|
|
if (CanSetPowerState("standby", NULL, NULL)) {
|
|
|
|
if (!result) {
|
|
|
|
result = SetPowerState("standby", NULL, NULL);
|
|
|
|
error_PolkitAccessDenied(msg, conn);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (CanSetPowerState("mem", NULL, "shallow")) {
|
|
|
|
else {
|
|
|
|
result = SetPowerState("mem", NULL, "shallow");
|
|
|
|
result = false;
|
|
|
|
|
|
|
|
if (CanSetPowerState("standby", NULL, NULL)) {
|
|
|
|
|
|
|
|
result = SetPowerState("standby", NULL, NULL);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (CanSetPowerState("mem", NULL, "shallow")) {
|
|
|
|
|
|
|
|
result = SetPowerState("mem", NULL, "shallow");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
reply_Bool(msg, conn, result);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
reply_Bool(msg, conn, result);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (dbus_message_is_method_call(msg, "org.trinitydesktop.hardwarecontrol.Power", "CanSuspend")) {
|
|
|
|
else if (dbus_message_is_method_call(msg, "org.trinitydesktop.hardwarecontrol.Power", "CanSuspend")) {
|
|
|
|
bool result = (CanSetPowerState("mem", NULL, NULL) && access("/sys/power/mem_sleep", R_OK) != 0) ||
|
|
|
|
bool result = checkPolKitAuthorization(msg, "org.trinitydesktop.hardwarecontrol.power.suspend");
|
|
|
|
CanSetPowerState("mem", NULL, "deep");
|
|
|
|
if (!result) {
|
|
|
|
reply_Bool(msg, conn, result);
|
|
|
|
error_PolkitAccessDenied(msg, conn);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
result = (CanSetPowerState("mem", NULL, NULL) && access("/sys/power/mem_sleep", R_OK) != 0) ||
|
|
|
|
|
|
|
|
CanSetPowerState("mem", NULL, "deep");
|
|
|
|
|
|
|
|
reply_Bool(msg, conn, result);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (dbus_message_is_method_call(msg, "org.trinitydesktop.hardwarecontrol.Power", "Suspend")) {
|
|
|
|
else if (dbus_message_is_method_call(msg, "org.trinitydesktop.hardwarecontrol.Power", "Suspend")) {
|
|
|
|
bool result = false;
|
|
|
|
bool result = checkPolKitAuthorization(msg, "org.trinitydesktop.hardwarecontrol.power.suspend");
|
|
|
|
if (CanSetPowerState("mem", NULL, NULL) && access("/sys/power/mem_sleep", R_OK) != 0) {
|
|
|
|
if (!result) {
|
|
|
|
result = SetPowerState("mem", NULL, NULL);
|
|
|
|
error_PolkitAccessDenied(msg, conn);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (CanSetPowerState("mem", NULL, "deep")) {
|
|
|
|
else {
|
|
|
|
result = SetPowerState("mem", NULL, "deep");
|
|
|
|
result = false;
|
|
|
|
|
|
|
|
if (CanSetPowerState("mem", NULL, NULL) && access("/sys/power/mem_sleep", R_OK) != 0) {
|
|
|
|
|
|
|
|
result = SetPowerState("mem", NULL, NULL);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (CanSetPowerState("mem", NULL, "deep")) {
|
|
|
|
|
|
|
|
result = SetPowerState("mem", NULL, "deep");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
reply_Bool(msg, conn, result);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
reply_Bool(msg, conn, result);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (dbus_message_is_method_call(msg, "org.trinitydesktop.hardwarecontrol.Power", "CanHybridSuspend")) {
|
|
|
|
else if (dbus_message_is_method_call(msg, "org.trinitydesktop.hardwarecontrol.Power", "CanHybridSuspend")) {
|
|
|
|
bool result = CanSetPowerState("disk", "suspend", NULL);
|
|
|
|
bool result = checkPolKitAuthorization(msg, "org.trinitydesktop.hardwarecontrol.power.hybridsuspend");
|
|
|
|
reply_Bool(msg, conn, result);
|
|
|
|
if (!result) {
|
|
|
|
|
|
|
|
error_PolkitAccessDenied(msg, conn);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
result = CanSetPowerState("disk", "suspend", NULL);
|
|
|
|
|
|
|
|
reply_Bool(msg, conn, result);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (dbus_message_is_method_call(msg, "org.trinitydesktop.hardwarecontrol.Power", "HybridSuspend")) {
|
|
|
|
else if (dbus_message_is_method_call(msg, "org.trinitydesktop.hardwarecontrol.Power", "HybridSuspend")) {
|
|
|
|
bool result = SetPowerState("disk", "suspend", NULL);
|
|
|
|
bool result = checkPolKitAuthorization(msg, "org.trinitydesktop.hardwarecontrol.power.hybridsuspend");
|
|
|
|
reply_Bool(msg, conn, result);
|
|
|
|
if (!result) {
|
|
|
|
|
|
|
|
error_PolkitAccessDenied(msg, conn);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
result = SetPowerState("disk", "suspend", NULL);
|
|
|
|
|
|
|
|
reply_Bool(msg, conn, result);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (dbus_message_is_method_call(msg, "org.trinitydesktop.hardwarecontrol.Power", "CanHibernate")) {
|
|
|
|
else if (dbus_message_is_method_call(msg, "org.trinitydesktop.hardwarecontrol.Power", "CanHibernate")) {
|
|
|
|
bool result = CanSetPowerState("disk", "shutdown", NULL) || CanSetPowerState("disk", "platform", NULL);
|
|
|
|
bool result = checkPolKitAuthorization(msg, "org.trinitydesktop.hardwarecontrol.power.hibernate");
|
|
|
|
reply_Bool(msg, conn, result);
|
|
|
|
if (!result) {
|
|
|
|
|
|
|
|
error_PolkitAccessDenied(msg, conn);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
result = CanSetPowerState("disk", "shutdown", NULL) || CanSetPowerState("disk", "platform", NULL);
|
|
|
|
|
|
|
|
reply_Bool(msg, conn, result);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (dbus_message_is_method_call(msg, "org.trinitydesktop.hardwarecontrol.Power", "Hibernate")) {
|
|
|
|
else if (dbus_message_is_method_call(msg, "org.trinitydesktop.hardwarecontrol.Power", "Hibernate")) {
|
|
|
|
bool result = false;
|
|
|
|
bool result = checkPolKitAuthorization(msg, "org.trinitydesktop.hardwarecontrol.power.hibernate");
|
|
|
|
if (CanSetPowerState("disk", "shutdown", NULL)) {
|
|
|
|
if (!result) {
|
|
|
|
result = SetPowerState("disk", "shutdown", NULL);
|
|
|
|
error_PolkitAccessDenied(msg, conn);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (CanSetPowerState("disk", "platform", NULL)) {
|
|
|
|
else {
|
|
|
|
result = SetPowerState("disk", "platform", NULL);
|
|
|
|
result = false;
|
|
|
|
|
|
|
|
if (CanSetPowerState("disk", "shutdown", NULL)) {
|
|
|
|
|
|
|
|
result = SetPowerState("disk", "shutdown", NULL);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (CanSetPowerState("disk", "platform", NULL)) {
|
|
|
|
|
|
|
|
result = SetPowerState("disk", "platform", NULL);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
reply_Bool(msg, conn, result);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
reply_Bool(msg, conn, result);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (dbus_message_is_method_call(msg, "org.trinitydesktop.hardwarecontrol.Power", "CanSetHibernationMethod")) {
|
|
|
|
else if (dbus_message_is_method_call(msg, "org.trinitydesktop.hardwarecontrol.Power", "CanSetHibernationMethod")) {
|
|
|
|
reply_CanSetHibernationMethod(msg, conn);
|
|
|
|
reply_CanSetHibernationMethod(msg, conn);
|