Add option WITH_TDEHWLIB_DAEMONS

Fix incorrect use WITH_UPOWER
pull/16/head
Slávek Banko 11 years ago
parent 3c06aad156
commit 3a601abfd4

@ -83,6 +83,7 @@ OPTION( WITH_PCRE "Enable pcre regex support for kjs" ON )
OPTION( WITH_GCC_VISIBILITY "Enable fvisibility and fvisibility-inlines-hidden" ${WITH_ALL_OPTIONS} ) OPTION( WITH_GCC_VISIBILITY "Enable fvisibility and fvisibility-inlines-hidden" ${WITH_ALL_OPTIONS} )
OPTION( WITH_INOTIFY "Enable inotify support for tdeio" ON ) OPTION( WITH_INOTIFY "Enable inotify support for tdeio" ON )
OPTION( WITH_GAMIN "Enable FAM/GAMIN support" ${WITH_ALL_OPTIONS} ) OPTION( WITH_GAMIN "Enable FAM/GAMIN support" ${WITH_ALL_OPTIONS} )
option( WITH_TDEHWLIB_DAEMONS "Enable daemons for TDE hwlib" ${WITH_ALL_OPTIONS} )
option( WITH_UPOWER "Enable uPower support" ${WITH_ALL_OPTIONS} ) option( WITH_UPOWER "Enable uPower support" ${WITH_ALL_OPTIONS} )
option( WITH_UDISKS "Enable uDisks support" ${WITH_ALL_OPTIONS} ) option( WITH_UDISKS "Enable uDisks support" ${WITH_ALL_OPTIONS} )
option( WITH_UDISKS2 "Enable uDisks2 support" ${WITH_ALL_OPTIONS} ) option( WITH_UDISKS2 "Enable uDisks2 support" ${WITH_ALL_OPTIONS} )

@ -10,20 +10,24 @@
################################################# #################################################
add_subdirectory( hwlibdata ) add_subdirectory( hwlibdata )
add_subdirectory( hwlibdaemons ) tde_conditional_add_subdirectory( WITH_TDEHWLIB_DAEMONS hwlibdaemons )
add_subdirectory( networkbackends ) add_subdirectory( networkbackends )
if( NOT DBUS_SYSTEM_BUS ) if( NOT DBUS_SYSTEM_BUS )
set( DBUS_SYSTEM_BUS "unix:path=/var/run/dbus/system_bus_socket" CACHE INTERNAL "" FORCE ) set( DBUS_SYSTEM_BUS "unix:path=/var/run/dbus/system_bus_socket" CACHE INTERNAL "" FORCE )
endif() endif()
if( WITH_UPOWER OR WITH_UDISKS OR WITH_UDISKS2 OR if( WITH_TDEHWLIB_DAEMONS OR WITH_UPOWER OR WITH_UDISKS OR WITH_UDISKS2 OR
WITH_NETWORK_MANAGER_BACKEND OR WITH_CONSOLEKIT ) WITH_NETWORK_MANAGER_BACKEND OR WITH_CONSOLEKIT )
list( APPEND TDEHW_CUSTOM_INCLUDE_DIRS ${DBUS_TQT_INCLUDE_DIRS} ) list( APPEND TDEHW_CUSTOM_INCLUDE_DIRS ${DBUS_TQT_INCLUDE_DIRS} )
list( APPEND TDEHW_CUSTOM_LIBRARY_DIRS ${DBUS_TQT_LIBRARY_DIRS} ) list( APPEND TDEHW_CUSTOM_LIBRARY_DIRS ${DBUS_TQT_LIBRARY_DIRS} )
list( APPEND TDEHW_CUSTOM_LIBRARIES ${DBUS_TQT_LIBRARIES} ) list( APPEND TDEHW_CUSTOM_LIBRARIES ${DBUS_TQT_LIBRARIES} )
endif( ) endif( )
if( WITH_TDEHWLIB_DAEMONS )
add_definitions( -DWITH_TDEHWLIB_DAEMONS )
endif( )
if( WITH_UPOWER ) if( WITH_UPOWER )
add_definitions( -DWITH_UPOWER ) add_definitions( -DWITH_UPOWER )
endif( ) endif( )

@ -26,13 +26,13 @@
#include "config.h" #include "config.h"
// uPower // uPower
#if defined(WITH_UPOWER) #if defined(WITH_TDEHWLIB_DAEMONS)
#include <tqdbusdata.h> #include <tqdbusdata.h>
#include <tqdbusmessage.h> #include <tqdbusmessage.h>
#include <tqdbusproxy.h> #include <tqdbusproxy.h>
#include <tqdbusvariant.h> #include <tqdbusvariant.h>
#include <tqdbusconnection.h> #include <tqdbusconnection.h>
#endif // defined(WITH_UPOWER) #endif // defined(WITH_TDEHWLIB_DAEMONS)
TDEBacklightDevice::TDEBacklightDevice(TDEGenericDeviceType::TDEGenericDeviceType dt, TQString dn) : TDEGenericDevice(dt, dn) { TDEBacklightDevice::TDEBacklightDevice(TDEGenericDeviceType::TDEGenericDeviceType dt, TQString dn) : TDEGenericDevice(dt, dn) {
} }
@ -70,8 +70,9 @@ bool TDEBacklightDevice::canSetBrightness() {
if (rval == 0) { if (rval == 0) {
return TRUE; return TRUE;
} }
else {
#ifdef WITH_UPOWER #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()) {
TQT_DBusProxy hardwareControl("org.trinitydesktop.hardwarecontrol", "/org/trinitydesktop/hardwarecontrol", "org.trinitydesktop.hardwarecontrol.Brightness", dbusConn); TQT_DBusProxy hardwareControl("org.trinitydesktop.hardwarecontrol", "/org/trinitydesktop/hardwarecontrol", "org.trinitydesktop.hardwarecontrol.Brightness", dbusConn);
@ -83,21 +84,12 @@ bool TDEBacklightDevice::canSetBrightness() {
if (reply.type() == TQT_DBusMessage::ReplyMessage && reply.count() == 1) { if (reply.type() == TQT_DBusMessage::ReplyMessage && reply.count() == 1) {
return reply[0].toVariant().value.toBool(); return reply[0].toVariant().value.toBool();
} }
else {
return FALSE;
}
}
else {
return FALSE;
} }
} }
else {
return FALSE;
}
#else // WITH_UPOWER
return FALSE;
#endif// WITH_UPOWER
} }
#endif // WITH_TDEHWLIB_DAEMONS
return FALSE;
} }
int TDEBacklightDevice::rawBrightness() { int TDEBacklightDevice::rawBrightness() {
@ -105,6 +97,8 @@ int TDEBacklightDevice::rawBrightness() {
} }
void TDEBacklightDevice::setRawBrightness(int br) { void TDEBacklightDevice::setRawBrightness(int br) {
bool setRawBrightnessDone = FALSE;
TQString brightnessnode = systemPath() + "/brightness"; TQString brightnessnode = systemPath() + "/brightness";
TQString brightnessCommand = TQString("%1").arg(br); TQString brightnessCommand = TQString("%1").arg(br);
TQFile file( brightnessnode ); TQFile file( brightnessnode );
@ -112,9 +106,11 @@ void TDEBacklightDevice::setRawBrightness(int br) {
TQTextStream stream( &file ); TQTextStream stream( &file );
stream << brightnessCommand; stream << brightnessCommand;
file.close(); file.close();
setRawBrightnessDone = TRUE;
} }
#ifdef WITH_UPOWER
else { #ifdef WITH_TDEHWLIB_DAEMONS
if ( !setRawBrightnessDone ) {
TQT_DBusConnection dbusConn = TQT_DBusConnection::addConnection(TQT_DBusConnection::SystemBus); TQT_DBusConnection dbusConn = TQT_DBusConnection::addConnection(TQT_DBusConnection::SystemBus);
if (dbusConn.isConnected()) { if (dbusConn.isConnected()) {
TQT_DBusProxy hardwareControl("org.trinitydesktop.hardwarecontrol", "/org/trinitydesktop/hardwarecontrol", "org.trinitydesktop.hardwarecontrol.Brightness", dbusConn); TQT_DBusProxy hardwareControl("org.trinitydesktop.hardwarecontrol", "/org/trinitydesktop/hardwarecontrol", "org.trinitydesktop.hardwarecontrol.Brightness", dbusConn);
@ -122,17 +118,15 @@ void TDEBacklightDevice::setRawBrightness(int br) {
// set brightness // set brightness
TQValueList<TQT_DBusData> params; TQValueList<TQT_DBusData> params;
params << TQT_DBusData::fromString(brightnessnode) << TQT_DBusData::fromString(brightnessCommand); params << TQT_DBusData::fromString(brightnessnode) << TQT_DBusData::fromString(brightnessCommand);
hardwareControl.sendWithReply("SetBrightness", params); TQT_DBusMessage reply = hardwareControl.sendWithReply("SetBrightness", params);
} if (reply.type() == TQT_DBusMessage::ReplyMessage) {
else { setRawBrightnessDone = TRUE;
return; }
} }
} }
else {
return;
}
} }
#endif // WITH_UPOWER #endif // WITH_TDEHWLIB_DAEMONS
} }
#include "tdebacklightdevice.moc" #include "tdebacklightdevice.moc"

@ -30,13 +30,13 @@
#include "config.h" #include "config.h"
// uPower // uPower
#if defined(WITH_UPOWER) #if defined(WITH_TDEHWLIB_DAEMONS)
#include <tqdbusdata.h> #include <tqdbusdata.h>
#include <tqdbusmessage.h> #include <tqdbusmessage.h>
#include <tqdbusproxy.h> #include <tqdbusproxy.h>
#include <tqdbusvariant.h> #include <tqdbusvariant.h>
#include <tqdbusconnection.h> #include <tqdbusconnection.h>
#endif // defined(WITH_UPOWER) #endif // defined(WITH_TDEHWLIB_DAEMONS)
TDECPUDevice::TDECPUDevice(TDEGenericDeviceType::TDEGenericDeviceType dt, TQString dn) : TDEGenericDevice(dt, dn) { TDECPUDevice::TDECPUDevice(TDEGenericDeviceType::TDEGenericDeviceType dt, TQString dn) : TDEGenericDevice(dt, dn) {
@ -132,8 +132,9 @@ bool TDECPUDevice::canSetGovernor() {
if (rval == 0) { if (rval == 0) {
return TRUE; return TRUE;
} }
else {
#ifdef WITH_UPOWER #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()) {
TQT_DBusProxy hardwareControl("org.trinitydesktop.hardwarecontrol", "/org/trinitydesktop/hardwarecontrol", "org.trinitydesktop.hardwarecontrol.CPUGovernor", dbusConn); TQT_DBusProxy hardwareControl("org.trinitydesktop.hardwarecontrol", "/org/trinitydesktop/hardwarecontrol", "org.trinitydesktop.hardwarecontrol.CPUGovernor", dbusConn);
@ -145,33 +146,28 @@ bool TDECPUDevice::canSetGovernor() {
if (reply.type() == TQT_DBusMessage::ReplyMessage && reply.count() == 1) { if (reply.type() == TQT_DBusMessage::ReplyMessage && reply.count() == 1) {
return reply[0].toVariant().value.toBool(); return reply[0].toVariant().value.toBool();
} }
else {
return FALSE;
}
}
else {
return FALSE;
} }
} }
else {
return FALSE;
}
#else // WITH_UPOWER
return FALSE;
#endif// WITH_UPOWER
} }
#endif // WITH_TDEHWLIB_DAEMONS
return FALSE;
} }
void TDECPUDevice::setGovernor(TQString gv) { void TDECPUDevice::setGovernor(TQString gv) {
bool setGovernorDone = FALSE;
TQString governornode = systemPath() + "/cpufreq/scaling_governor"; TQString governornode = systemPath() + "/cpufreq/scaling_governor";
TQFile file( governornode ); TQFile file( governornode );
if ( file.open( IO_WriteOnly ) ) { if ( file.open( IO_WriteOnly ) ) {
TQTextStream stream( &file ); TQTextStream stream( &file );
stream << gv.lower(); stream << gv.lower();
file.close(); file.close();
setGovernorDone = TRUE;
} }
#ifdef WITH_UPOWER
else { #ifdef WITH_TDEHWLIB_DAEMONS
if ( !setGovernorDone ) {
TQT_DBusConnection dbusConn = TQT_DBusConnection::addConnection(TQT_DBusConnection::SystemBus); TQT_DBusConnection dbusConn = TQT_DBusConnection::addConnection(TQT_DBusConnection::SystemBus);
if (dbusConn.isConnected()) { if (dbusConn.isConnected()) {
TQT_DBusProxy hardwareControl("org.trinitydesktop.hardwarecontrol", "/org/trinitydesktop/hardwarecontrol", "org.trinitydesktop.hardwarecontrol.CPUGovernor", dbusConn); TQT_DBusProxy hardwareControl("org.trinitydesktop.hardwarecontrol", "/org/trinitydesktop/hardwarecontrol", "org.trinitydesktop.hardwarecontrol.CPUGovernor", dbusConn);
@ -179,20 +175,19 @@ void TDECPUDevice::setGovernor(TQString gv) {
// set CPU governor // set CPU governor
TQValueList<TQT_DBusData> params; TQValueList<TQT_DBusData> params;
params << TQT_DBusData::fromInt32(coreNumber()) << TQT_DBusData::fromString(gv.lower()); params << TQT_DBusData::fromInt32(coreNumber()) << TQT_DBusData::fromString(gv.lower());
hardwareControl.sendWithReply("SetCPUGovernor", params); TQT_DBusMessage reply = hardwareControl.sendWithReply("SetCPUGovernor", params);
} if (reply.type() == TQT_DBusMessage::ReplyMessage) {
else { setGovernorDone = TRUE;
return; }
} }
} }
else {
return;
}
} }
#endif // WITH_UPOWER #endif // WITH_TDEHWLIB_DAEMONS
// Force update of the device information object // Force update of the device information object
TDEGlobal::hardwareDevices()->processModifiedCPUs(); if ( setGovernorDone ) {
TDEGlobal::hardwareDevices()->processModifiedCPUs();
}
} }
bool TDECPUDevice::canSetMaximumScalingFrequency() { bool TDECPUDevice::canSetMaximumScalingFrequency() {

Loading…
Cancel
Save