|
|
@ -89,12 +89,6 @@ void TDERootSystemDevice::internalSetDiskSpaceNeededForHibernation(unsigned long
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool TDERootSystemDevice::canSetHibernationMethod() {
|
|
|
|
bool TDERootSystemDevice::canSetHibernationMethod() {
|
|
|
|
TQString hibernationnode = "/sys/power/disk";
|
|
|
|
|
|
|
|
int rval = access (hibernationnode.ascii(), W_OK);
|
|
|
|
|
|
|
|
if (rval == 0) {
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef WITH_TDEHWLIB_DAEMONS
|
|
|
|
#ifdef WITH_TDEHWLIB_DAEMONS
|
|
|
|
{
|
|
|
|
{
|
|
|
|
TQT_DBusConnection dbusConn = TQT_DBusConnection::addConnection(TQT_DBusConnection::SystemBus);
|
|
|
|
TQT_DBusConnection dbusConn = TQT_DBusConnection::addConnection(TQT_DBusConnection::SystemBus);
|
|
|
@ -113,18 +107,16 @@ bool TDERootSystemDevice::canSetHibernationMethod() {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif // WITH_TDEHWLIB_DAEMONS
|
|
|
|
#endif // WITH_TDEHWLIB_DAEMONS
|
|
|
|
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
TQString hibernationnode = "/sys/power/disk";
|
|
|
|
}
|
|
|
|
int rval = access(hibernationnode.ascii(), W_OK);
|
|
|
|
|
|
|
|
|
|
|
|
bool TDERootSystemDevice::canFreeze() {
|
|
|
|
|
|
|
|
TQString statenode = "/sys/power/state";
|
|
|
|
|
|
|
|
int rval = access (statenode.ascii(), W_OK);
|
|
|
|
|
|
|
|
if (rval == 0) {
|
|
|
|
if (rval == 0) {
|
|
|
|
if (powerStates().contains(TDESystemPowerState::Freeze)) {
|
|
|
|
return true;
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool TDERootSystemDevice::canFreeze() {
|
|
|
|
#ifdef WITH_TDEHWLIB_DAEMONS
|
|
|
|
#ifdef WITH_TDEHWLIB_DAEMONS
|
|
|
|
{
|
|
|
|
{
|
|
|
|
TQT_DBusConnection dbusConn = TQT_DBusConnection::addConnection(TQT_DBusConnection::SystemBus);
|
|
|
|
TQT_DBusConnection dbusConn = TQT_DBusConnection::addConnection(TQT_DBusConnection::SystemBus);
|
|
|
@ -143,18 +135,18 @@ bool TDERootSystemDevice::canFreeze() {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif // WITH_TDEHWLIB_DAEMONS
|
|
|
|
#endif // WITH_TDEHWLIB_DAEMONS
|
|
|
|
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool TDERootSystemDevice::canStandby() {
|
|
|
|
|
|
|
|
TQString statenode = "/sys/power/state";
|
|
|
|
TQString statenode = "/sys/power/state";
|
|
|
|
int rval = access (statenode.ascii(), W_OK);
|
|
|
|
int rval = access(statenode.ascii(), W_OK);
|
|
|
|
if (rval == 0) {
|
|
|
|
if (rval == 0) {
|
|
|
|
if (powerStates().contains(TDESystemPowerState::Standby)) {
|
|
|
|
if (powerStates().contains(TDESystemPowerState::Freeze)) {
|
|
|
|
return TRUE;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool TDERootSystemDevice::canStandby() {
|
|
|
|
#ifdef WITH_TDEHWLIB_DAEMONS
|
|
|
|
#ifdef WITH_TDEHWLIB_DAEMONS
|
|
|
|
{
|
|
|
|
{
|
|
|
|
TQT_DBusConnection dbusConn = TQT_DBusConnection::addConnection(TQT_DBusConnection::SystemBus);
|
|
|
|
TQT_DBusConnection dbusConn = TQT_DBusConnection::addConnection(TQT_DBusConnection::SystemBus);
|
|
|
@ -173,36 +165,18 @@ bool TDERootSystemDevice::canStandby() {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif // WITH_TDEHWLIB_DAEMONS
|
|
|
|
#endif // WITH_TDEHWLIB_DAEMONS
|
|
|
|
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool TDERootSystemDevice::canSuspend() {
|
|
|
|
|
|
|
|
TQString statenode = "/sys/power/state";
|
|
|
|
TQString statenode = "/sys/power/state";
|
|
|
|
int rval = access (statenode.ascii(), W_OK);
|
|
|
|
int rval = access(statenode.ascii(), W_OK);
|
|
|
|
if (rval == 0) {
|
|
|
|
if (rval == 0) {
|
|
|
|
if (powerStates().contains(TDESystemPowerState::Suspend)) {
|
|
|
|
if (powerStates().contains(TDESystemPowerState::Standby)) {
|
|
|
|
return TRUE;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef WITH_TDEHWLIB_DAEMONS
|
|
|
|
return false;
|
|
|
|
{
|
|
|
|
}
|
|
|
|
TQT_DBusConnection dbusConn = TQT_DBusConnection::addConnection(TQT_DBusConnection::SystemBus);
|
|
|
|
|
|
|
|
if (dbusConn.isConnected()) {
|
|
|
|
|
|
|
|
// can suspend?
|
|
|
|
|
|
|
|
TQT_DBusMessage msg = TQT_DBusMessage::methodCall(
|
|
|
|
|
|
|
|
"org.trinitydesktop.hardwarecontrol",
|
|
|
|
|
|
|
|
"/org/trinitydesktop/hardwarecontrol",
|
|
|
|
|
|
|
|
"org.trinitydesktop.hardwarecontrol.Power",
|
|
|
|
|
|
|
|
"CanSuspend");
|
|
|
|
|
|
|
|
TQT_DBusMessage reply = dbusConn.sendWithReply(msg);
|
|
|
|
|
|
|
|
if (reply.type() == TQT_DBusMessage::ReplyMessage && reply.count() == 1) {
|
|
|
|
|
|
|
|
return reply[0].toBool();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // WITH_TDEHWLIB_DAEMONS
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool TDERootSystemDevice::canSuspend() {
|
|
|
|
#ifdef WITH_LOGINDPOWER
|
|
|
|
#ifdef WITH_LOGINDPOWER
|
|
|
|
{
|
|
|
|
{
|
|
|
|
TQT_DBusConnection dbusConn = TQT_DBusConnection::addConnection(TQT_DBusConnection::SystemBus);
|
|
|
|
TQT_DBusConnection dbusConn = TQT_DBusConnection::addConnection(TQT_DBusConnection::SystemBus);
|
|
|
@ -283,30 +257,16 @@ bool TDERootSystemDevice::canSuspend() {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif // WITH_HAL
|
|
|
|
#endif // WITH_HAL
|
|
|
|
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool TDERootSystemDevice::canHybridSuspend() {
|
|
|
|
|
|
|
|
TQString statenode = "/sys/power/state";
|
|
|
|
|
|
|
|
TQString disknode = "/sys/power/disk";
|
|
|
|
|
|
|
|
int state_rval = access (statenode.ascii(), W_OK);
|
|
|
|
|
|
|
|
int disk_rval = access (disknode.ascii(), W_OK);
|
|
|
|
|
|
|
|
if (state_rval == 0 && disk_rval == 0) {
|
|
|
|
|
|
|
|
if (powerStates().contains(TDESystemPowerState::HybridSuspend)) {
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef WITH_TDEHWLIB_DAEMONS
|
|
|
|
#ifdef WITH_TDEHWLIB_DAEMONS
|
|
|
|
{
|
|
|
|
{
|
|
|
|
TQT_DBusConnection dbusConn = TQT_DBusConnection::addConnection(TQT_DBusConnection::SystemBus);
|
|
|
|
TQT_DBusConnection dbusConn = TQT_DBusConnection::addConnection(TQT_DBusConnection::SystemBus);
|
|
|
|
if (dbusConn.isConnected()) {
|
|
|
|
if (dbusConn.isConnected()) {
|
|
|
|
// can hybrid suspend?
|
|
|
|
// can suspend?
|
|
|
|
TQT_DBusMessage msg = TQT_DBusMessage::methodCall(
|
|
|
|
TQT_DBusMessage msg = TQT_DBusMessage::methodCall(
|
|
|
|
"org.trinitydesktop.hardwarecontrol",
|
|
|
|
"org.trinitydesktop.hardwarecontrol",
|
|
|
|
"/org/trinitydesktop/hardwarecontrol",
|
|
|
|
"/org/trinitydesktop/hardwarecontrol",
|
|
|
|
"org.trinitydesktop.hardwarecontrol.Power",
|
|
|
|
"org.trinitydesktop.hardwarecontrol.Power",
|
|
|
|
"CanHybridSuspend");
|
|
|
|
"CanSuspend");
|
|
|
|
TQT_DBusMessage reply = dbusConn.sendWithReply(msg);
|
|
|
|
TQT_DBusMessage reply = dbusConn.sendWithReply(msg);
|
|
|
|
if (reply.type() == TQT_DBusMessage::ReplyMessage && reply.count() == 1) {
|
|
|
|
if (reply.type() == TQT_DBusMessage::ReplyMessage && reply.count() == 1) {
|
|
|
|
return reply[0].toBool();
|
|
|
|
return reply[0].toBool();
|
|
|
@ -315,6 +275,18 @@ bool TDERootSystemDevice::canHybridSuspend() {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif // WITH_TDEHWLIB_DAEMONS
|
|
|
|
#endif // WITH_TDEHWLIB_DAEMONS
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TQString statenode = "/sys/power/state";
|
|
|
|
|
|
|
|
int rval = access(statenode.ascii(), W_OK);
|
|
|
|
|
|
|
|
if (rval == 0) {
|
|
|
|
|
|
|
|
if (powerStates().contains(TDESystemPowerState::Suspend)) {
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool TDERootSystemDevice::canHybridSuspend() {
|
|
|
|
#ifdef WITH_LOGINDPOWER
|
|
|
|
#ifdef WITH_LOGINDPOWER
|
|
|
|
{
|
|
|
|
{
|
|
|
|
TQT_DBusConnection dbusConn = TQT_DBusConnection::addConnection(TQT_DBusConnection::SystemBus);
|
|
|
|
TQT_DBusConnection dbusConn = TQT_DBusConnection::addConnection(TQT_DBusConnection::SystemBus);
|
|
|
@ -356,30 +328,16 @@ bool TDERootSystemDevice::canHybridSuspend() {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif // WITH_HAL
|
|
|
|
#endif // WITH_HAL
|
|
|
|
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool TDERootSystemDevice::canHibernate() {
|
|
|
|
|
|
|
|
TQString statenode = "/sys/power/state";
|
|
|
|
|
|
|
|
TQString disknode = "/sys/power/disk";
|
|
|
|
|
|
|
|
int state_rval = access (statenode.ascii(), W_OK);
|
|
|
|
|
|
|
|
int disk_rval = access (disknode.ascii(), W_OK);
|
|
|
|
|
|
|
|
if (state_rval == 0 && disk_rval == 0) {
|
|
|
|
|
|
|
|
if (powerStates().contains(TDESystemPowerState::Hibernate)) {
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef WITH_TDEHWLIB_DAEMONS
|
|
|
|
#ifdef WITH_TDEHWLIB_DAEMONS
|
|
|
|
{
|
|
|
|
{
|
|
|
|
TQT_DBusConnection dbusConn = TQT_DBusConnection::addConnection(TQT_DBusConnection::SystemBus);
|
|
|
|
TQT_DBusConnection dbusConn = TQT_DBusConnection::addConnection(TQT_DBusConnection::SystemBus);
|
|
|
|
if (dbusConn.isConnected()) {
|
|
|
|
if (dbusConn.isConnected()) {
|
|
|
|
// can hibernate?
|
|
|
|
// can hybrid suspend?
|
|
|
|
TQT_DBusMessage msg = TQT_DBusMessage::methodCall(
|
|
|
|
TQT_DBusMessage msg = TQT_DBusMessage::methodCall(
|
|
|
|
"org.trinitydesktop.hardwarecontrol",
|
|
|
|
"org.trinitydesktop.hardwarecontrol",
|
|
|
|
"/org/trinitydesktop/hardwarecontrol",
|
|
|
|
"/org/trinitydesktop/hardwarecontrol",
|
|
|
|
"org.trinitydesktop.hardwarecontrol.Power",
|
|
|
|
"org.trinitydesktop.hardwarecontrol.Power",
|
|
|
|
"CanHibernate");
|
|
|
|
"CanHybridSuspend");
|
|
|
|
TQT_DBusMessage reply = dbusConn.sendWithReply(msg);
|
|
|
|
TQT_DBusMessage reply = dbusConn.sendWithReply(msg);
|
|
|
|
if (reply.type() == TQT_DBusMessage::ReplyMessage && reply.count() == 1) {
|
|
|
|
if (reply.type() == TQT_DBusMessage::ReplyMessage && reply.count() == 1) {
|
|
|
|
return reply[0].toBool();
|
|
|
|
return reply[0].toBool();
|
|
|
@ -388,6 +346,20 @@ bool TDERootSystemDevice::canHibernate() {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif // WITH_TDEHWLIB_DAEMONS
|
|
|
|
#endif // WITH_TDEHWLIB_DAEMONS
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TQString statenode = "/sys/power/state";
|
|
|
|
|
|
|
|
TQString disknode = "/sys/power/disk";
|
|
|
|
|
|
|
|
int state_rval = access(statenode.ascii(), W_OK);
|
|
|
|
|
|
|
|
int disk_rval = access(disknode.ascii(), W_OK);
|
|
|
|
|
|
|
|
if (state_rval == 0 && disk_rval == 0) {
|
|
|
|
|
|
|
|
if (powerStates().contains(TDESystemPowerState::HybridSuspend)) {
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool TDERootSystemDevice::canHibernate() {
|
|
|
|
#ifdef WITH_LOGINDPOWER
|
|
|
|
#ifdef WITH_LOGINDPOWER
|
|
|
|
{
|
|
|
|
{
|
|
|
|
TQT_DBusConnection dbusConn = TQT_DBusConnection::addConnection(TQT_DBusConnection::SystemBus);
|
|
|
|
TQT_DBusConnection dbusConn = TQT_DBusConnection::addConnection(TQT_DBusConnection::SystemBus);
|
|
|
@ -468,14 +440,42 @@ bool TDERootSystemDevice::canHibernate() {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif // WITH_HAL
|
|
|
|
#endif // WITH_HAL
|
|
|
|
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
#ifdef WITH_TDEHWLIB_DAEMONS
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
TQT_DBusConnection dbusConn = TQT_DBusConnection::addConnection(TQT_DBusConnection::SystemBus);
|
|
|
|
|
|
|
|
if (dbusConn.isConnected()) {
|
|
|
|
|
|
|
|
// can hibernate?
|
|
|
|
|
|
|
|
TQT_DBusMessage msg = TQT_DBusMessage::methodCall(
|
|
|
|
|
|
|
|
"org.trinitydesktop.hardwarecontrol",
|
|
|
|
|
|
|
|
"/org/trinitydesktop/hardwarecontrol",
|
|
|
|
|
|
|
|
"org.trinitydesktop.hardwarecontrol.Power",
|
|
|
|
|
|
|
|
"CanHibernate");
|
|
|
|
|
|
|
|
TQT_DBusMessage reply = dbusConn.sendWithReply(msg);
|
|
|
|
|
|
|
|
if (reply.type() == TQT_DBusMessage::ReplyMessage && reply.count() == 1) {
|
|
|
|
|
|
|
|
return reply[0].toBool();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // WITH_TDEHWLIB_DAEMONS
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TQString statenode = "/sys/power/state";
|
|
|
|
|
|
|
|
TQString disknode = "/sys/power/disk";
|
|
|
|
|
|
|
|
int state_rval = access(statenode.ascii(), W_OK);
|
|
|
|
|
|
|
|
int disk_rval = access(disknode.ascii(), W_OK);
|
|
|
|
|
|
|
|
if (state_rval == 0 && disk_rval == 0) {
|
|
|
|
|
|
|
|
if (powerStates().contains(TDESystemPowerState::Hibernate)) {
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool TDERootSystemDevice::canPowerOff() {
|
|
|
|
bool TDERootSystemDevice::canPowerOff() {
|
|
|
|
TDEConfig config("ksmserverrc", true);
|
|
|
|
TDEConfig config("ksmserverrc", true);
|
|
|
|
config.setGroup("General" );
|
|
|
|
config.setGroup("General" );
|
|
|
|
if (!config.readBoolEntry( "offerShutdown", true )) {
|
|
|
|
if (!config.readBoolEntry( "offerShutdown", true )) {
|
|
|
|
return FALSE;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef WITH_LOGINDPOWER
|
|
|
|
#ifdef WITH_LOGINDPOWER
|
|
|
@ -518,16 +518,17 @@ bool TDERootSystemDevice::canPowerOff() {
|
|
|
|
// Can we power down this system?
|
|
|
|
// Can we power down this system?
|
|
|
|
// This should probably be checked via DCOP and therefore interface with TDM
|
|
|
|
// This should probably be checked via DCOP and therefore interface with TDM
|
|
|
|
// if ( DM().canShutdown() ) {
|
|
|
|
// if ( DM().canShutdown() ) {
|
|
|
|
// return TRUE;
|
|
|
|
// return true;
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
return TRUE;
|
|
|
|
return true;
|
|
|
|
|
|
|
|
//return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool TDERootSystemDevice::canReboot() {
|
|
|
|
bool TDERootSystemDevice::canReboot() {
|
|
|
|
TDEConfig config("ksmserverrc", true);
|
|
|
|
TDEConfig config("ksmserverrc", true);
|
|
|
|
config.setGroup("General" );
|
|
|
|
config.setGroup("General" );
|
|
|
|
if (!config.readBoolEntry( "offerShutdown", true )) {
|
|
|
|
if (!config.readBoolEntry( "offerShutdown", true )) {
|
|
|
|
return FALSE;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef WITH_LOGINDPOWER
|
|
|
|
#ifdef WITH_LOGINDPOWER
|
|
|
@ -570,15 +571,21 @@ bool TDERootSystemDevice::canReboot() {
|
|
|
|
// Can we power down this system?
|
|
|
|
// Can we power down this system?
|
|
|
|
// This should probably be checked via DCOP and therefore interface with TDM
|
|
|
|
// This should probably be checked via DCOP and therefore interface with TDM
|
|
|
|
// if ( DM().canShutdown() ) {
|
|
|
|
// if ( DM().canShutdown() ) {
|
|
|
|
// return TRUE;
|
|
|
|
// return true;
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
return TRUE;
|
|
|
|
return true;
|
|
|
|
|
|
|
|
//return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void TDERootSystemDevice::setHibernationMethod(TDESystemHibernationMethod::TDESystemHibernationMethod hm) {
|
|
|
|
void TDERootSystemDevice::setHibernationMethod(TDESystemHibernationMethod::TDESystemHibernationMethod hm) {
|
|
|
|
TQString hibernationnode = "/sys/power/disk";
|
|
|
|
#ifdef WITH_TDEHWLIB_DAEMONS
|
|
|
|
TQFile file( hibernationnode );
|
|
|
|
{
|
|
|
|
if ( file.open( IO_WriteOnly ) ) {
|
|
|
|
TQT_DBusConnection dbusConn = TQT_DBusConnection::addConnection(TQT_DBusConnection::SystemBus);
|
|
|
|
|
|
|
|
if (dbusConn.isConnected()) {
|
|
|
|
|
|
|
|
TQT_DBusProxy hardwareControl("org.trinitydesktop.hardwarecontrol", "/org/trinitydesktop/hardwarecontrol", "org.trinitydesktop.hardwarecontrol.Power", dbusConn);
|
|
|
|
|
|
|
|
if (hardwareControl.canSend()) {
|
|
|
|
|
|
|
|
// set hibernation method
|
|
|
|
|
|
|
|
TQValueList<TQT_DBusData> params;
|
|
|
|
TQString hibernationCommand;
|
|
|
|
TQString hibernationCommand;
|
|
|
|
if (hm == TDESystemHibernationMethod::Platform) {
|
|
|
|
if (hm == TDESystemHibernationMethod::Platform) {
|
|
|
|
hibernationCommand = "platform";
|
|
|
|
hibernationCommand = "platform";
|
|
|
@ -598,20 +605,19 @@ void TDERootSystemDevice::setHibernationMethod(TDESystemHibernationMethod::TDESy
|
|
|
|
else if (hm == TDESystemHibernationMethod::Suspend) {
|
|
|
|
else if (hm == TDESystemHibernationMethod::Suspend) {
|
|
|
|
hibernationCommand = "suspend";
|
|
|
|
hibernationCommand = "suspend";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
TQTextStream stream( &file );
|
|
|
|
params << TQT_DBusData::fromString(hibernationCommand);
|
|
|
|
stream << hibernationCommand;
|
|
|
|
TQT_DBusMessage reply = hardwareControl.sendWithReply("SetHibernationMethod", params);
|
|
|
|
file.close();
|
|
|
|
if (reply.type() == TQT_DBusMessage::ReplyMessage) {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // WITH_TDEHWLIB_DAEMONS
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef WITH_TDEHWLIB_DAEMONS
|
|
|
|
TQString hibernationnode = "/sys/power/disk";
|
|
|
|
{
|
|
|
|
TQFile file( hibernationnode );
|
|
|
|
TQT_DBusConnection dbusConn = TQT_DBusConnection::addConnection(TQT_DBusConnection::SystemBus);
|
|
|
|
if ( file.open( IO_WriteOnly ) ) {
|
|
|
|
if (dbusConn.isConnected()) {
|
|
|
|
|
|
|
|
TQT_DBusProxy hardwareControl("org.trinitydesktop.hardwarecontrol", "/org/trinitydesktop/hardwarecontrol", "org.trinitydesktop.hardwarecontrol.Power", dbusConn);
|
|
|
|
|
|
|
|
if (hardwareControl.canSend()) {
|
|
|
|
|
|
|
|
// set hibernation method
|
|
|
|
|
|
|
|
TQValueList<TQT_DBusData> params;
|
|
|
|
|
|
|
|
TQString hibernationCommand;
|
|
|
|
TQString hibernationCommand;
|
|
|
|
if (hm == TDESystemHibernationMethod::Platform) {
|
|
|
|
if (hm == TDESystemHibernationMethod::Platform) {
|
|
|
|
hibernationCommand = "platform";
|
|
|
|
hibernationCommand = "platform";
|
|
|
@ -631,16 +637,11 @@ void TDERootSystemDevice::setHibernationMethod(TDESystemHibernationMethod::TDESy
|
|
|
|
else if (hm == TDESystemHibernationMethod::Suspend) {
|
|
|
|
else if (hm == TDESystemHibernationMethod::Suspend) {
|
|
|
|
hibernationCommand = "suspend";
|
|
|
|
hibernationCommand = "suspend";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
params << TQT_DBusData::fromString(hibernationCommand);
|
|
|
|
TQTextStream stream( &file );
|
|
|
|
TQT_DBusMessage reply = hardwareControl.sendWithReply("SetHibernationMethod", params);
|
|
|
|
stream << hibernationCommand;
|
|
|
|
if (reply.type() == TQT_DBusMessage::ReplyMessage) {
|
|
|
|
file.close();
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // WITH_TDEHWLIB_DAEMONS
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool check_CanSetSuspend(char* state, char* disk, char* mem) {
|
|
|
|
bool check_CanSetSuspend(char* state, char* disk, char* mem) {
|
|
|
@ -720,145 +721,6 @@ bool TDERootSystemDevice::setPowerState(TDESystemPowerState::TDESystemPowerState
|
|
|
|
if ((ps == TDESystemPowerState::Freeze) || (ps == TDESystemPowerState::Standby) ||
|
|
|
|
if ((ps == TDESystemPowerState::Freeze) || (ps == TDESystemPowerState::Standby) ||
|
|
|
|
(ps == TDESystemPowerState::Suspend) || (ps == TDESystemPowerState::Hibernate) ||
|
|
|
|
(ps == TDESystemPowerState::Suspend) || (ps == TDESystemPowerState::Hibernate) ||
|
|
|
|
(ps == TDESystemPowerState::HybridSuspend)) {
|
|
|
|
(ps == TDESystemPowerState::HybridSuspend)) {
|
|
|
|
TQString statenode = "/sys/power/state";
|
|
|
|
|
|
|
|
TQString disknode = "/sys/power/disk";
|
|
|
|
|
|
|
|
TQString memnode = "/sys/power/mem_sleep";
|
|
|
|
|
|
|
|
TQFile statefile( statenode );
|
|
|
|
|
|
|
|
TQFile diskfile( disknode );
|
|
|
|
|
|
|
|
TQFile memfile( memnode );
|
|
|
|
|
|
|
|
TQString stateCommand = TQString::null;
|
|
|
|
|
|
|
|
TQString diskCommand = TQString::null;
|
|
|
|
|
|
|
|
TQString memCommand = TQString::null;
|
|
|
|
|
|
|
|
bool stateWriteOk = false;
|
|
|
|
|
|
|
|
bool diskWriteOk = false;
|
|
|
|
|
|
|
|
bool memWriteOk = false;
|
|
|
|
|
|
|
|
if (ps == TDESystemPowerState::Freeze) {
|
|
|
|
|
|
|
|
if (check_CanSetSuspend("freeze", NULL, NULL)) {
|
|
|
|
|
|
|
|
stateCommand = "freeze";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
stateCommand = "mem";
|
|
|
|
|
|
|
|
diskCommand = "s2idle";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (ps == TDESystemPowerState::Standby) {
|
|
|
|
|
|
|
|
if (check_CanSetSuspend("standby", NULL, NULL)) {
|
|
|
|
|
|
|
|
stateCommand = "standby";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
stateCommand = "mem";
|
|
|
|
|
|
|
|
diskCommand = "shallow";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (ps == TDESystemPowerState::Suspend) {
|
|
|
|
|
|
|
|
stateCommand = "mem";
|
|
|
|
|
|
|
|
if (check_CanSetSuspend("mem", NULL, "deep")) {
|
|
|
|
|
|
|
|
diskCommand = "deep";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (ps == TDESystemPowerState::HybridSuspend) {
|
|
|
|
|
|
|
|
stateCommand = "disk";
|
|
|
|
|
|
|
|
diskCommand = "suspend";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (ps == TDESystemPowerState::Hibernate) {
|
|
|
|
|
|
|
|
stateCommand = "disk";
|
|
|
|
|
|
|
|
if (check_CanSetSuspend("disk", "shutdown", NULL)) {
|
|
|
|
|
|
|
|
diskCommand = "shutdown";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
diskCommand = "platform";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
memWriteOk = (memCommand == TQString::null);
|
|
|
|
|
|
|
|
if (memCommand != TQString::null && memfile.open( IO_WriteOnly )) {
|
|
|
|
|
|
|
|
memWriteOk = true;
|
|
|
|
|
|
|
|
TQTextStream memstream( &memfile );
|
|
|
|
|
|
|
|
memstream << memCommand;
|
|
|
|
|
|
|
|
memfile.close();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (memWriteOk) {
|
|
|
|
|
|
|
|
diskWriteOk = (diskCommand == TQString::null);
|
|
|
|
|
|
|
|
if (diskCommand != TQString::null && diskfile.open( IO_WriteOnly )) {
|
|
|
|
|
|
|
|
diskWriteOk = true;
|
|
|
|
|
|
|
|
TQTextStream diskstream( &diskfile );
|
|
|
|
|
|
|
|
diskstream << diskCommand;
|
|
|
|
|
|
|
|
diskfile.close();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (diskWriteOk) {
|
|
|
|
|
|
|
|
if (stateCommand != TQString::null && statefile.open( IO_WriteOnly )) {
|
|
|
|
|
|
|
|
TQTextStream statestream( &statefile );
|
|
|
|
|
|
|
|
statestream << stateCommand;
|
|
|
|
|
|
|
|
statefile.close();
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef WITH_TDEHWLIB_DAEMONS
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
TQT_DBusConnection dbusConn;
|
|
|
|
|
|
|
|
dbusConn = TQT_DBusConnection::addConnection(TQT_DBusConnection::SystemBus);
|
|
|
|
|
|
|
|
if ( dbusConn.isConnected() ) {
|
|
|
|
|
|
|
|
if (ps == TDESystemPowerState::Freeze) {
|
|
|
|
|
|
|
|
TQT_DBusMessage msg = TQT_DBusMessage::methodCall(
|
|
|
|
|
|
|
|
"org.trinitydesktop.hardwarecontrol",
|
|
|
|
|
|
|
|
"/org/trinitydesktop/hardwarecontrol",
|
|
|
|
|
|
|
|
"org.trinitydesktop.hardwarecontrol.Power",
|
|
|
|
|
|
|
|
"Freeze");
|
|
|
|
|
|
|
|
TQT_DBusMessage reply = dbusConn.sendWithReply(msg);
|
|
|
|
|
|
|
|
if (reply.type() == TQT_DBusMessage::ReplyMessage) {
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (ps == TDESystemPowerState::Standby) {
|
|
|
|
|
|
|
|
TQT_DBusMessage msg = TQT_DBusMessage::methodCall(
|
|
|
|
|
|
|
|
"org.trinitydesktop.hardwarecontrol",
|
|
|
|
|
|
|
|
"/org/trinitydesktop/hardwarecontrol",
|
|
|
|
|
|
|
|
"org.trinitydesktop.hardwarecontrol.Power",
|
|
|
|
|
|
|
|
"Standby");
|
|
|
|
|
|
|
|
TQT_DBusMessage reply = dbusConn.sendWithReply(msg);
|
|
|
|
|
|
|
|
if (reply.type() == TQT_DBusMessage::ReplyMessage) {
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (ps == TDESystemPowerState::Suspend) {
|
|
|
|
|
|
|
|
TQT_DBusMessage msg = TQT_DBusMessage::methodCall(
|
|
|
|
|
|
|
|
"org.trinitydesktop.hardwarecontrol",
|
|
|
|
|
|
|
|
"/org/trinitydesktop/hardwarecontrol",
|
|
|
|
|
|
|
|
"org.trinitydesktop.hardwarecontrol.Power",
|
|
|
|
|
|
|
|
"Suspend");
|
|
|
|
|
|
|
|
TQT_DBusMessage reply = dbusConn.sendWithReply(msg);
|
|
|
|
|
|
|
|
if (reply.type() == TQT_DBusMessage::ReplyMessage) {
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (ps == TDESystemPowerState::HybridSuspend) {
|
|
|
|
|
|
|
|
TQT_DBusMessage msg = TQT_DBusMessage::methodCall(
|
|
|
|
|
|
|
|
"org.trinitydesktop.hardwarecontrol",
|
|
|
|
|
|
|
|
"/org/trinitydesktop/hardwarecontrol",
|
|
|
|
|
|
|
|
"org.trinitydesktop.hardwarecontrol.Power",
|
|
|
|
|
|
|
|
"HybridSuspend");
|
|
|
|
|
|
|
|
TQT_DBusMessage reply = dbusConn.sendWithReply(msg);
|
|
|
|
|
|
|
|
if (reply.type() == TQT_DBusMessage::ReplyMessage) {
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (ps == TDESystemPowerState::Hibernate) {
|
|
|
|
|
|
|
|
TQT_DBusMessage msg = TQT_DBusMessage::methodCall(
|
|
|
|
|
|
|
|
"org.trinitydesktop.hardwarecontrol",
|
|
|
|
|
|
|
|
"/org/trinitydesktop/hardwarecontrol",
|
|
|
|
|
|
|
|
"org.trinitydesktop.hardwarecontrol.Power",
|
|
|
|
|
|
|
|
"Hibernate");
|
|
|
|
|
|
|
|
TQT_DBusMessage reply = dbusConn.sendWithReply(msg);
|
|
|
|
|
|
|
|
if (reply.type() == TQT_DBusMessage::ReplyMessage) {
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // WITH_TDEHWLIB_DAEMONS
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef WITH_LOGINDPOWER
|
|
|
|
#ifdef WITH_LOGINDPOWER
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// No support for "freeze" in org.freedesktop.login1
|
|
|
|
// No support for "freeze" in org.freedesktop.login1
|
|
|
@ -1013,6 +875,145 @@ bool TDERootSystemDevice::setPowerState(TDESystemPowerState::TDESystemPowerState
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif // WITH_HAL
|
|
|
|
#endif // WITH_HAL
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef WITH_TDEHWLIB_DAEMONS
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
TQT_DBusConnection dbusConn;
|
|
|
|
|
|
|
|
dbusConn = TQT_DBusConnection::addConnection(TQT_DBusConnection::SystemBus);
|
|
|
|
|
|
|
|
if ( dbusConn.isConnected() ) {
|
|
|
|
|
|
|
|
if (ps == TDESystemPowerState::Freeze) {
|
|
|
|
|
|
|
|
TQT_DBusMessage msg = TQT_DBusMessage::methodCall(
|
|
|
|
|
|
|
|
"org.trinitydesktop.hardwarecontrol",
|
|
|
|
|
|
|
|
"/org/trinitydesktop/hardwarecontrol",
|
|
|
|
|
|
|
|
"org.trinitydesktop.hardwarecontrol.Power",
|
|
|
|
|
|
|
|
"Freeze");
|
|
|
|
|
|
|
|
TQT_DBusMessage reply = dbusConn.sendWithReply(msg);
|
|
|
|
|
|
|
|
if (reply.type() == TQT_DBusMessage::ReplyMessage) {
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (ps == TDESystemPowerState::Standby) {
|
|
|
|
|
|
|
|
TQT_DBusMessage msg = TQT_DBusMessage::methodCall(
|
|
|
|
|
|
|
|
"org.trinitydesktop.hardwarecontrol",
|
|
|
|
|
|
|
|
"/org/trinitydesktop/hardwarecontrol",
|
|
|
|
|
|
|
|
"org.trinitydesktop.hardwarecontrol.Power",
|
|
|
|
|
|
|
|
"Standby");
|
|
|
|
|
|
|
|
TQT_DBusMessage reply = dbusConn.sendWithReply(msg);
|
|
|
|
|
|
|
|
if (reply.type() == TQT_DBusMessage::ReplyMessage) {
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (ps == TDESystemPowerState::Suspend) {
|
|
|
|
|
|
|
|
TQT_DBusMessage msg = TQT_DBusMessage::methodCall(
|
|
|
|
|
|
|
|
"org.trinitydesktop.hardwarecontrol",
|
|
|
|
|
|
|
|
"/org/trinitydesktop/hardwarecontrol",
|
|
|
|
|
|
|
|
"org.trinitydesktop.hardwarecontrol.Power",
|
|
|
|
|
|
|
|
"Suspend");
|
|
|
|
|
|
|
|
TQT_DBusMessage reply = dbusConn.sendWithReply(msg);
|
|
|
|
|
|
|
|
if (reply.type() == TQT_DBusMessage::ReplyMessage) {
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (ps == TDESystemPowerState::HybridSuspend) {
|
|
|
|
|
|
|
|
TQT_DBusMessage msg = TQT_DBusMessage::methodCall(
|
|
|
|
|
|
|
|
"org.trinitydesktop.hardwarecontrol",
|
|
|
|
|
|
|
|
"/org/trinitydesktop/hardwarecontrol",
|
|
|
|
|
|
|
|
"org.trinitydesktop.hardwarecontrol.Power",
|
|
|
|
|
|
|
|
"HybridSuspend");
|
|
|
|
|
|
|
|
TQT_DBusMessage reply = dbusConn.sendWithReply(msg);
|
|
|
|
|
|
|
|
if (reply.type() == TQT_DBusMessage::ReplyMessage) {
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (ps == TDESystemPowerState::Hibernate) {
|
|
|
|
|
|
|
|
TQT_DBusMessage msg = TQT_DBusMessage::methodCall(
|
|
|
|
|
|
|
|
"org.trinitydesktop.hardwarecontrol",
|
|
|
|
|
|
|
|
"/org/trinitydesktop/hardwarecontrol",
|
|
|
|
|
|
|
|
"org.trinitydesktop.hardwarecontrol.Power",
|
|
|
|
|
|
|
|
"Hibernate");
|
|
|
|
|
|
|
|
TQT_DBusMessage reply = dbusConn.sendWithReply(msg);
|
|
|
|
|
|
|
|
if (reply.type() == TQT_DBusMessage::ReplyMessage) {
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // WITH_TDEHWLIB_DAEMONS
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TQString statenode = "/sys/power/state";
|
|
|
|
|
|
|
|
TQString disknode = "/sys/power/disk";
|
|
|
|
|
|
|
|
TQString memnode = "/sys/power/mem_sleep";
|
|
|
|
|
|
|
|
TQFile statefile( statenode );
|
|
|
|
|
|
|
|
TQFile diskfile( disknode );
|
|
|
|
|
|
|
|
TQFile memfile( memnode );
|
|
|
|
|
|
|
|
TQString stateCommand = TQString::null;
|
|
|
|
|
|
|
|
TQString diskCommand = TQString::null;
|
|
|
|
|
|
|
|
TQString memCommand = TQString::null;
|
|
|
|
|
|
|
|
bool stateWriteOk = false;
|
|
|
|
|
|
|
|
bool diskWriteOk = false;
|
|
|
|
|
|
|
|
bool memWriteOk = false;
|
|
|
|
|
|
|
|
if (ps == TDESystemPowerState::Freeze) {
|
|
|
|
|
|
|
|
if (check_CanSetSuspend("freeze", NULL, NULL)) {
|
|
|
|
|
|
|
|
stateCommand = "freeze";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
stateCommand = "mem";
|
|
|
|
|
|
|
|
diskCommand = "s2idle";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (ps == TDESystemPowerState::Standby) {
|
|
|
|
|
|
|
|
if (check_CanSetSuspend("standby", NULL, NULL)) {
|
|
|
|
|
|
|
|
stateCommand = "standby";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
stateCommand = "mem";
|
|
|
|
|
|
|
|
diskCommand = "shallow";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (ps == TDESystemPowerState::Suspend) {
|
|
|
|
|
|
|
|
stateCommand = "mem";
|
|
|
|
|
|
|
|
if (check_CanSetSuspend("mem", NULL, "deep")) {
|
|
|
|
|
|
|
|
diskCommand = "deep";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (ps == TDESystemPowerState::HybridSuspend) {
|
|
|
|
|
|
|
|
stateCommand = "disk";
|
|
|
|
|
|
|
|
diskCommand = "suspend";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (ps == TDESystemPowerState::Hibernate) {
|
|
|
|
|
|
|
|
stateCommand = "disk";
|
|
|
|
|
|
|
|
if (check_CanSetSuspend("disk", "shutdown", NULL)) {
|
|
|
|
|
|
|
|
diskCommand = "shutdown";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
diskCommand = "platform";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
memWriteOk = (memCommand == TQString::null);
|
|
|
|
|
|
|
|
if (memCommand != TQString::null && memfile.open( IO_WriteOnly )) {
|
|
|
|
|
|
|
|
memWriteOk = true;
|
|
|
|
|
|
|
|
TQTextStream memstream( &memfile );
|
|
|
|
|
|
|
|
memstream << memCommand;
|
|
|
|
|
|
|
|
memfile.close();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (memWriteOk) {
|
|
|
|
|
|
|
|
diskWriteOk = (diskCommand == TQString::null);
|
|
|
|
|
|
|
|
if (diskCommand != TQString::null && diskfile.open( IO_WriteOnly )) {
|
|
|
|
|
|
|
|
diskWriteOk = true;
|
|
|
|
|
|
|
|
TQTextStream diskstream( &diskfile );
|
|
|
|
|
|
|
|
diskstream << diskCommand;
|
|
|
|
|
|
|
|
diskfile.close();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (diskWriteOk) {
|
|
|
|
|
|
|
|
if (stateCommand != TQString::null && statefile.open( IO_WriteOnly )) {
|
|
|
|
|
|
|
|
TQTextStream statestream( &statefile );
|
|
|
|
|
|
|
|
statestream << stateCommand;
|
|
|
|
|
|
|
|
statefile.close();
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (ps == TDESystemPowerState::PowerOff) {
|
|
|
|
else if (ps == TDESystemPowerState::PowerOff) {
|
|
|
@ -1038,6 +1039,7 @@ bool TDERootSystemDevice::setPowerState(TDESystemPowerState::TDESystemPowerState
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif // WITH_LOGINDPOWER
|
|
|
|
#endif // WITH_LOGINDPOWER
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef WITH_CONSOLEKIT
|
|
|
|
#ifdef WITH_CONSOLEKIT
|
|
|
|
{
|
|
|
|
{
|
|
|
|
TQT_DBusConnection dbusConn;
|
|
|
|
TQT_DBusConnection dbusConn;
|
|
|
@ -1055,6 +1057,7 @@ bool TDERootSystemDevice::setPowerState(TDESystemPowerState::TDESystemPowerState
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif // WITH_CONSOLEKIT
|
|
|
|
#endif // WITH_CONSOLEKIT
|
|
|
|
|
|
|
|
|
|
|
|
// Power down the system using a DCOP command
|
|
|
|
// Power down the system using a DCOP command
|
|
|
|
/* As found at http://lists.kde.org/?l=kde-linux&m=115770988603387
|
|
|
|
/* As found at http://lists.kde.org/?l=kde-linux&m=115770988603387
|
|
|
|
Logout parameters explanation:
|
|
|
|
Logout parameters explanation:
|
|
|
@ -1105,6 +1108,7 @@ bool TDERootSystemDevice::setPowerState(TDESystemPowerState::TDESystemPowerState
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif // WITH_LOGINDPOWER
|
|
|
|
#endif // WITH_LOGINDPOWER
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef WITH_CONSOLEKIT
|
|
|
|
#ifdef WITH_CONSOLEKIT
|
|
|
|
{
|
|
|
|
{
|
|
|
|
TQT_DBusConnection dbusConn;
|
|
|
|
TQT_DBusConnection dbusConn;
|
|
|
@ -1122,6 +1126,7 @@ bool TDERootSystemDevice::setPowerState(TDESystemPowerState::TDESystemPowerState
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif // WITH_CONSOLEKIT
|
|
|
|
#endif // WITH_CONSOLEKIT
|
|
|
|
|
|
|
|
|
|
|
|
// Power down the system using a DCOP command
|
|
|
|
// Power down the system using a DCOP command
|
|
|
|
// See above PowerOff section for logout() parameters explanation
|
|
|
|
// See above PowerOff section for logout() parameters explanation
|
|
|
|
TQByteArray data;
|
|
|
|
TQByteArray data;
|
|
|
|