summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGolubev Alexander <fatzer2@gmail.com>2013-07-27 06:39:01 +0400
committerGolubev Alexander <fatzer2@gmail.com>2013-07-27 11:20:30 +0400
commite7708ec743e1c504cbae2ab523858589caeae62f (patch)
tree39fbcc9b900e673b7fab0e5fabc4d82a1cce4286
parent4b775b444d1558705c4aa9a0b5f1d18e2a81f092 (diff)
downloadtdelibs-e7708ec743e1c504cbae2ab523858589caeae62f.tar.gz
tdelibs-e7708ec743e1c504cbae2ab523858589caeae62f.zip
complete tdehardwaredevices split
-rw-r--r--tdecore/tdehw/CMakeLists.txt8
-rw-r--r--tdecore/tdehw/networkbackends/network-manager/network-manager.cpp3
-rw-r--r--tdecore/tdehw/tdebacklightdevice.cpp138
-rw-r--r--tdecore/tdehw/tdebacklightdevice.h97
-rw-r--r--tdecore/tdehw/tdebatterydevice.cpp2
-rw-r--r--tdecore/tdehw/tdecpudevice.cpp9
-rw-r--r--tdecore/tdehw/tdeeventdevice.cpp146
-rw-r--r--tdecore/tdehw/tdeeventdevice.h161
-rw-r--r--tdecore/tdehw/tdegenericdevice.cpp2
-rw-r--r--tdecore/tdehw/tdegenericdevice.h56
-rw-r--r--tdecore/tdehw/tdehardwaredevices.cpp920
-rw-r--r--tdecore/tdehw/tdehardwaredevices.h832
-rw-r--r--tdecore/tdehw/tdehwcommontypes.h100
-rw-r--r--tdecore/tdehw/tdeinputdevice.cpp38
-rw-r--r--tdecore/tdehw/tdeinputdevice.h67
-rw-r--r--tdecore/tdehw/tdemainspowerdevice.cpp2
-rw-r--r--tdecore/tdehw/tdemonitordevice.cpp78
-rw-r--r--tdecore/tdehw/tdemonitordevice.h122
-rw-r--r--tdecore/tdehw/tdenetworkconnections.cpp10
-rw-r--r--tdecore/tdehw/tdenetworkdevice.cpp188
-rw-r--r--tdecore/tdehw/tdenetworkdevice.h252
-rw-r--r--tdecore/tdehw/tderootsystemdevice.cpp440
-rw-r--r--tdecore/tdehw/tderootsystemdevice.h182
-rw-r--r--tdecore/tdehw/tdesensordevice.cpp47
-rw-r--r--tdecore/tdehw/tdesensordevice.h75
-rw-r--r--tdecore/tdehw/tdestoragedevice.cpp33
26 files changed, 2233 insertions, 1775 deletions
diff --git a/tdecore/tdehw/CMakeLists.txt b/tdecore/tdehw/CMakeLists.txt
index 4496d3f2d..1bcec6db7 100644
--- a/tdecore/tdehw/CMakeLists.txt
+++ b/tdecore/tdehw/CMakeLists.txt
@@ -41,7 +41,7 @@ if( WITH_CONSOLEKIT )
endif( )
if( WITH_NETWORK_MANAGER_BACKEND )
- list( APPEND TDEHW_CUSTOM_INCLUDE_DIR ${CMAKE_CURRENT_BINARY_DIR}/networkbackends/network-manager/dbus )
+ list( APPEND TDEHW_CUSTOM_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/networkbackends/network-manager )
list( APPEND TDEHW_CUSTOM_LIBRARIES network_manager_backend-static )
endif( WITH_NETWORK_MANAGER_BACKEND )
@@ -65,6 +65,8 @@ link_directories(
install( FILES tdehardwaredevices.h tdenetworkconnections.h tdegenericdevice.h
tdestoragedevice.h tdecpudevice.h tdebatterydevice.h tdemainspowerdevice.h
+ tdenetworkdevice.h tdebacklightdevice.h tdemonitordevice.h
+ tdesensordevice.h tderootsystemdevice.h tdeeventdevice.h tdeinputdevice.h
DESTINATION ${INCLUDE_INSTALL_DIR} )
@@ -75,7 +77,9 @@ set( target tdehw )
set( ${target}_SRCS
tdehardwaredevices.cpp tdenetworkconnections.cpp tdegenericdevice.cpp
tdestoragedevice.cpp tdecpudevice.cpp tdebatterydevice.cpp
- tdemainspowerdevice.cpp
+ tdemainspowerdevice.cpp tdenetworkdevice.cpp tdebacklightdevice.cpp
+ tdemonitordevice.cpp tdesensordevice.cpp tderootsystemdevice.cpp
+ tdeeventdevice.cpp tdeinputdevice.cpp
)
tde_add_library( ${target} STATIC_PIC AUTOMOC
diff --git a/tdecore/tdehw/networkbackends/network-manager/network-manager.cpp b/tdecore/tdehw/networkbackends/network-manager/network-manager.cpp
index a7295beac..af056de4b 100644
--- a/tdecore/tdehw/networkbackends/network-manager/network-manager.cpp
+++ b/tdecore/tdehw/networkbackends/network-manager/network-manager.cpp
@@ -22,6 +22,7 @@
#include "tdeconfig.h"
#include "tdehardwaredevices.h"
+#include "tdenetworkdevice.h"
#include "network-manager.h"
#include "network-manager_p.h"
@@ -5624,4 +5625,4 @@ TDENetworkConnectionManager_BackendNMPrivate::~TDENetworkConnectionManager_Backe
}
#include "network-manager.moc"
-#include "network-manager_p.moc" \ No newline at end of file
+#include "network-manager_p.moc"
diff --git a/tdecore/tdehw/tdebacklightdevice.cpp b/tdecore/tdehw/tdebacklightdevice.cpp
new file mode 100644
index 000000000..0ce5533e0
--- /dev/null
+++ b/tdecore/tdehw/tdebacklightdevice.cpp
@@ -0,0 +1,138 @@
+/* This file is part of the TDE libraries
+ Copyright (C) 2012 Timothy Pearson <kb9vqf@pearsoncomputing.net>
+ (C) 2013 Golubev Alexander <fatzer2@gmail.com>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License version 2 as published by the Free Software Foundation.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "tdebacklightdevice.h"
+
+#include <unistd.h>
+
+#include <tqfile.h>
+
+#include "config.h"
+
+// uPower
+#if defined(WITH_UPOWER)
+ #include <tqdbusdata.h>
+ #include <tqdbusmessage.h>
+ #include <tqdbusproxy.h>
+ #include <tqdbusvariant.h>
+ #include <tqdbusconnection.h>
+#endif // defined(WITH_UPOWER)
+
+TDEBacklightDevice::TDEBacklightDevice(TDEGenericDeviceType::TDEGenericDeviceType dt, TQString dn) : TDEGenericDevice(dt, dn) {
+}
+
+TDEBacklightDevice::~TDEBacklightDevice() {
+}
+
+TDEDisplayPowerLevel::TDEDisplayPowerLevel TDEBacklightDevice::powerLevel() {
+ return m_powerLevel;
+}
+
+void TDEBacklightDevice::internalSetPowerLevel(TDEDisplayPowerLevel::TDEDisplayPowerLevel pl) {
+ m_powerLevel = pl;
+}
+
+void TDEBacklightDevice::internalSetMaximumRawBrightness(int br) {
+ m_maximumBrightness = br;
+}
+
+void TDEBacklightDevice::internalSetCurrentRawBrightness(int br) {
+ m_currentBrightness = br;
+}
+
+int TDEBacklightDevice::brightnessSteps() {
+ return m_maximumBrightness + 1;
+}
+
+double TDEBacklightDevice::brightnessPercent() {
+ return (((m_currentBrightness*1.0)/m_maximumBrightness)*100.0);
+}
+
+bool TDEBacklightDevice::canSetBrightness() {
+ TQString brightnessnode = systemPath() + "/brightness";
+ int rval = access (brightnessnode.ascii(), W_OK);
+ if (rval == 0) {
+ return TRUE;
+ }
+ else {
+#ifdef WITH_UPOWER
+ TQT_DBusConnection dbusConn = TQT_DBusConnection::addConnection(TQT_DBusConnection::SystemBus);
+ if (dbusConn.isConnected()) {
+ TQT_DBusProxy hardwareControl("org.trinitydesktop.hardwarecontrol", "/org/trinitydesktop/hardwarecontrol", "org.trinitydesktop.hardwarecontrol.Brightness", dbusConn);
+ if (hardwareControl.canSend()) {
+ // can set brightness?
+ TQValueList<TQT_DBusData> params;
+ params << TQT_DBusData::fromString(brightnessnode);
+ TQT_DBusMessage reply = hardwareControl.sendWithReply("CanSetBrightness", params);
+ if (reply.type() == TQT_DBusMessage::ReplyMessage && reply.count() == 1) {
+ return reply[0].toVariant().value.toBool();
+ }
+ else {
+ return FALSE;
+ }
+ }
+ else {
+ return FALSE;
+ }
+ }
+ else {
+ return FALSE;
+ }
+#else // WITH_UPOWER
+ return FALSE;
+#endif// WITH_UPOWER
+ }
+}
+
+int TDEBacklightDevice::rawBrightness() {
+ return m_currentBrightness;
+}
+
+void TDEBacklightDevice::setRawBrightness(int br) {
+ TQString brightnessnode = systemPath() + "/brightness";
+ TQString brightnessCommand = TQString("%1").arg(br);
+ TQFile file( brightnessnode );
+ if ( file.open( IO_WriteOnly ) ) {
+ TQTextStream stream( &file );
+ stream << brightnessCommand;
+ file.close();
+ }
+#ifdef WITH_UPOWER
+ else {
+ TQT_DBusConnection dbusConn = TQT_DBusConnection::addConnection(TQT_DBusConnection::SystemBus);
+ if (dbusConn.isConnected()) {
+ TQT_DBusProxy hardwareControl("org.trinitydesktop.hardwarecontrol", "/org/trinitydesktop/hardwarecontrol", "org.trinitydesktop.hardwarecontrol.Brightness", dbusConn);
+ if (hardwareControl.canSend()) {
+ // set brightness
+ TQValueList<TQT_DBusData> params;
+ params << TQT_DBusData::fromString(brightnessnode) << TQT_DBusData::fromString(brightnessCommand);
+ hardwareControl.sendWithReply("SetBrightness", params);
+ }
+ else {
+ return;
+ }
+ }
+ else {
+ return;
+ }
+ }
+#endif // WITH_UPOWER
+}
+
+#include "tdebacklightdevice.moc"
diff --git a/tdecore/tdehw/tdebacklightdevice.h b/tdecore/tdehw/tdebacklightdevice.h
new file mode 100644
index 000000000..b61d4f92f
--- /dev/null
+++ b/tdecore/tdehw/tdebacklightdevice.h
@@ -0,0 +1,97 @@
+/* This file is part of the TDE libraries
+ Copyright (C) 2012 Timothy Pearson <kb9vqf@pearsoncomputing.net>
+ (C) 2013 Golubev Alexander <fatzer2@gmail.com>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License version 2 as published by the Free Software Foundation.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef _TDEBACKLIGHTDEVICE_H
+#define _TDEBACKLIGHTDEVICE_H
+
+#include "tdegenericdevice.h"
+#include "tdehwcommontypes.h"
+
+class TDECORE_EXPORT TDEBacklightDevice : public TDEGenericDevice
+{
+ public:
+ /**
+ * Constructor.
+ * @param Device type
+ */
+ TDEBacklightDevice(TDEGenericDeviceType::TDEGenericDeviceType dt, TQString dn=TQString::null);
+
+ /**
+ * Destructor.
+ */
+ ~TDEBacklightDevice();
+
+ /**
+ * @return a TDEDisplayPowerLevel::TDEDisplayPowerLevel with the current power level
+ */
+ TDEDisplayPowerLevel::TDEDisplayPowerLevel powerLevel();
+
+ /**
+ * @return an integer with the number of discrete control steps available
+ */
+ int brightnessSteps();
+
+ /**
+ * @return a double with the current brightness percentage
+ */
+ double brightnessPercent();
+
+ /**
+ * @return TRUE if permissions allow brightness can be set, FALSE if not
+ */
+ bool canSetBrightness();
+
+ /**
+ * @return an int with the current raw brightness
+ */
+ int rawBrightness();
+
+ /**
+ * @param br an integer with the new raw brightness value
+ */
+ void setRawBrightness(int br);
+
+ protected:
+ /**
+ * @param pl a TDEDisplayPowerLevel::TDEDisplayPowerLevel with the current power level
+ * @internal
+ */
+ void internalSetPowerLevel(TDEDisplayPowerLevel::TDEDisplayPowerLevel pl);
+
+ /**
+ * @param br an integer with the maximum raw brightness value
+ * @internal
+ */
+ void internalSetMaximumRawBrightness(int br);
+
+ /**
+ * @param br an integer with the current raw brightness value
+ * @internal
+ */
+ void internalSetCurrentRawBrightness(int br);
+
+ private:
+ TDEDisplayPowerLevel::TDEDisplayPowerLevel m_powerLevel;
+ int m_currentBrightness;
+ int m_maximumBrightness;
+
+ friend class TDEHardwareDevices;
+};
+
+#endif // _TDEBACKLIGHTDEVICE_H
diff --git a/tdecore/tdehw/tdebatterydevice.cpp b/tdecore/tdehw/tdebatterydevice.cpp
index 0245d2c67..781fb994b 100644
--- a/tdecore/tdehw/tdebatterydevice.cpp
+++ b/tdecore/tdehw/tdebatterydevice.cpp
@@ -19,6 +19,8 @@
#include "tdebatterydevice.h"
+#include "config.h"
+
TDEBatteryDevice::TDEBatteryDevice(TDEGenericDeviceType::TDEGenericDeviceType dt, TQString dn) : TDEGenericDevice(dt, dn) {
}
diff --git a/tdecore/tdehw/tdecpudevice.cpp b/tdecore/tdehw/tdecpudevice.cpp
index 268682727..b6b4b9bf4 100644
--- a/tdecore/tdehw/tdecpudevice.cpp
+++ b/tdecore/tdehw/tdecpudevice.cpp
@@ -23,6 +23,12 @@
#include <tqfile.h>
+#include "tdeglobal.h"
+
+#include "tdehardwaredevices.h"
+
+#include "config.h"
+
// uPower
#if defined(WITH_UPOWER)
#include <tqdbusdata.h>
@@ -32,9 +38,6 @@
#include <tqdbusconnection.h>
#endif // defined(WITH_UPOWER)
-#include <tdeglobal.h>
-
-#include "tdehardwaredevices.h"
TDECPUDevice::TDECPUDevice(TDEGenericDeviceType::TDEGenericDeviceType dt, TQString dn) : TDEGenericDevice(dt, dn) {
m_frequency = -1;
diff --git a/tdecore/tdehw/tdeeventdevice.cpp b/tdecore/tdehw/tdeeventdevice.cpp
new file mode 100644
index 000000000..a98bc78c3
--- /dev/null
+++ b/tdecore/tdehw/tdeeventdevice.cpp
@@ -0,0 +1,146 @@
+/* This file is part of the TDE libraries
+ Copyright (C) 2012 Timothy Pearson <kb9vqf@pearsoncomputing.net>
+ (C) 2013 Golubev Alexander <fatzer2@gmail.com>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License version 2 as published by the Free Software Foundation.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "tdeeventdevice.h"
+
+#include <unistd.h>
+#include <linux/input.h>
+
+#include <tqsocketnotifier.h>
+
+#include "tdelocale.h"
+
+#include "tdehardwaredevices.h"
+
+#include "config.h"
+
+TDEEventDevice::TDEEventDevice(TDEGenericDeviceType::TDEGenericDeviceType dt, TQString dn) : TDEGenericDevice(dt, dn) {
+ m_fd = -1;
+ m_fdMonitorActive = false;
+}
+
+TDEEventDevice::~TDEEventDevice() {
+ if (m_fd >= 0) {
+ close(m_fd);
+ }
+}
+
+TDEEventDeviceType::TDEEventDeviceType TDEEventDevice::eventType() {
+ return m_eventType;
+}
+
+void TDEEventDevice::internalSetEventType(TDEEventDeviceType::TDEEventDeviceType et) {
+ m_eventType = et;
+}
+
+TDESwitchType::TDESwitchType TDEEventDevice::providedSwitches() {
+ return m_providedSwitches;
+}
+
+void TDEEventDevice::internalSetProvidedSwitches(TDESwitchType::TDESwitchType sl) {
+ m_providedSwitches = sl;
+}
+
+TDESwitchType::TDESwitchType TDEEventDevice::activeSwitches() {
+ return m_switchActive;
+}
+
+void TDEEventDevice::internalSetActiveSwitches(TDESwitchType::TDESwitchType sl) {
+ m_switchActive = sl;
+}
+
+// Keep this in sync with the TDESwitchType definition in the header
+TQStringList TDEEventDevice::friendlySwitchList(TDESwitchType::TDESwitchType switches) {
+ TQStringList ret;
+
+ if (switches & TDESwitchType::Lid) {
+ ret.append(i18n("Lid Switch"));
+ }
+ if (switches & TDESwitchType::TabletMode) {
+ ret.append(i18n("Tablet Mode"));
+ }
+ if (switches & TDESwitchType::HeadphoneInsert) {
+ ret.append(i18n("Headphone Inserted"));
+ }
+ if (switches & TDESwitchType::RFKill) {
+ ret.append(i18n("Radio Frequency Device Kill Switch"));
+ }
+ if (switches & TDESwitchType::Radio) {
+ ret.append(i18n("Enable Radio"));
+ }
+ if (switches & TDESwitchType::MicrophoneInsert) {
+ ret.append(i18n("Microphone Inserted"));
+ }
+ if (switches & TDESwitchType::Dock) {
+ ret.append(i18n("Docked"));
+ }
+ if (switches & TDESwitchType::LineOutInsert) {
+ ret.append(i18n("Line Out Inserted"));
+ }
+ if (switches & TDESwitchType::JackPhysicalInsert) {
+ ret.append(i18n("Physical Jack Inserted"));
+ }
+ if (switches & TDESwitchType::VideoOutInsert) {
+ ret.append(i18n("Video Out Inserted"));
+ }
+ if (switches & TDESwitchType::CameraLensCover) {
+ ret.append(i18n("Camera Lens Cover"));
+ }
+ if (switches & TDESwitchType::KeypadSlide) {
+ ret.append(i18n("Keypad Slide"));
+ }
+ if (switches & TDESwitchType::FrontProximity) {
+ ret.append(i18n("Front Proximity"));
+ }
+ if (switches & TDESwitchType::RotateLock) {
+ ret.append(i18n("Rotate Lock"));
+ }
+ if (switches & TDESwitchType::LineInInsert) {
+ ret.append(i18n("Line In Inserted"));
+ }
+
+ return ret;
+}
+
+void TDEEventDevice::internalStartFdMonitoring(TDEHardwareDevices* hwmanager) {
+ if (!m_fdMonitorActive) {
+ // For security and performance reasons, only monitor known ACPI buttons
+ if (eventType() != TDEEventDeviceType::Unknown) {
+ if (m_fd >= 0) {
+ m_eventNotifier = new TQSocketNotifier(m_fd, TQSocketNotifier::Read, this);
+ connect( m_eventNotifier, TQT_SIGNAL(activated(int)), this, TQT_SLOT(eventReceived()) );
+ }
+ connect( this, TQT_SIGNAL(keyPressed(unsigned int, TDEEventDevice*)), hwmanager, TQT_SLOT(processEventDeviceKeyPressed(unsigned int, TDEEventDevice*)) );
+ }
+ m_fdMonitorActive = true;
+ }
+}
+
+void TDEEventDevice::eventReceived() {
+ struct input_event ev;
+ int r;
+ r = read(m_fd, &ev, sizeof(struct input_event));
+ if (r > 0) {
+ if (ev.type == EV_KEY) {
+ emit keyPressed(ev.code, this);
+ }
+ }
+}
+
+#include "tdeeventdevice.moc"
diff --git a/tdecore/tdehw/tdeeventdevice.h b/tdecore/tdehw/tdeeventdevice.h
new file mode 100644
index 000000000..50aea54ef
--- /dev/null
+++ b/tdecore/tdehw/tdeeventdevice.h
@@ -0,0 +1,161 @@
+/* This file is part of the TDE libraries
+ Copyright (C) 2012 Timothy Pearson <kb9vqf@pearsoncomputing.net>
+ (C) 2013 Golubev Alexander <fatzer2@gmail.com>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License version 2 as published by the Free Software Foundation.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef _TDEEVENTDEVICE_H
+#define _TDEEVENTDEVICE_H
+
+#include "tdegenericdevice.h"
+
+class TDEHardwareDevices;
+
+namespace TDEEventDeviceType {
+enum TDEEventDeviceType {
+ Unknown,
+ ACPILidSwitch,
+ ACPISleepButton,
+ ACPIPowerButton,
+ Other = 0x80000000
+};
+};
+
+// Keep friendlySwitchList() in tdehardwaredevices.cpp in sync with this enum
+namespace TDESwitchType {
+enum TDESwitchType {
+ Null = 0x00000000,
+ Lid = 0x00000001,
+ TabletMode = 0x00000002,
+ HeadphoneInsert = 0x00000004,
+ RFKill = 0x00000008,
+ Radio = 0x00000010,
+ MicrophoneInsert = 0x00000020,
+ Dock = 0x00000040,
+ LineOutInsert = 0x00000080,
+ JackPhysicalInsert = 0x00000100,
+ VideoOutInsert = 0x00000200,
+ CameraLensCover = 0x00000400,
+ KeypadSlide = 0x00000800,
+ FrontProximity = 0x00001000,
+ RotateLock = 0x00002000,
+ LineInInsert = 0x00004000
+};
+
+inline TDESwitchType operator|(TDESwitchType a, TDESwitchType b)
+{
+ return static_cast<TDESwitchType>(static_cast<int>(a) | static_cast<int>(b));
+}
+
+inline TDESwitchType operator&(TDESwitchType a, TDESwitchType b)
+{
+ return static_cast<TDESwitchType>(static_cast<int>(a) & static_cast<int>(b));
+}
+
+inline TDESwitchType operator~(TDESwitchType a)
+{
+ return static_cast<TDESwitchType>(~static_cast<int>(a));
+}
+};
+
+class TQSocketNotifier;
+
+class TDECORE_EXPORT TDEEventDevice : public TDEGenericDevice
+{
+ Q_OBJECT
+
+ public:
+ /**
+ * Constructor.
+ * @param Device type
+ */
+ TDEEventDevice(TDEGenericDeviceType::TDEGenericDeviceType dt, TQString dn=TQString::null);
+
+ /**
+ * Destructor.
+ */
+ ~TDEEventDevice();
+
+ /**
+ * @return a TDEEventDeviceType::TDEEventDeviceType with the event device type, if known
+ */
+ TDEEventDeviceType::TDEEventDeviceType eventType();
+
+ /**
+ * @return a TDESwitchType::TDESwitchType with all switches provided by this device
+ */
+ TDESwitchType::TDESwitchType providedSwitches();
+
+ /**
+ * @return a TDESwitchType::TDESwitchType with all active switches provided by this device
+ */
+ TDESwitchType::TDESwitchType activeSwitches();
+
+ /**
+ * @param switches a TDESwitchType::TDESwitchType with any switch flags set
+ * @return a TQStringList with friendly names for all set switch flags
+ */
+ static TQStringList friendlySwitchList(TDESwitchType::TDESwitchType switches);
+
+ protected:
+ /**
+ * @param et a TDEEventDeviceType::TDEEventDeviceType with the event device type, if known
+ * @internal
+ */
+ void internalSetEventType(TDEEventDeviceType::TDEEventDeviceType et);
+
+ /**
+ * @param sl a TDESwitchType::TDESwitchType with all switches provided by this device
+ * @internal
+ */
+ void internalSetProvidedSwitches(TDESwitchType::TDESwitchType sl);
+
+ /**
+ * @param sl a TDESwitchType::TDESwitchType with all active switches provided by this device
+ * @internal
+ */
+ void internalSetActiveSwitches(TDESwitchType::TDESwitchType sl);
+
+ /**
+ * @param hwmanager the master hardware manager
+ * @internal
+ */
+ void internalStartFdMonitoring(TDEHardwareDevices* hwmanager);
+
+ protected slots:
+ void eventReceived();
+
+ signals:
+ /**
+ * @param keycode the code of the key that was pressed/released
+ * See include/linux/input.h for a complete list of keycodes
+ * @param device a TDEEventDevice* with the device that received the event
+ */
+ void keyPressed(unsigned int keycode, TDEEventDevice* device);
+
+ private:
+ TDEEventDeviceType::TDEEventDeviceType m_eventType;
+ TDESwitchType::TDESwitchType m_providedSwitches;
+ TDESwitchType::TDESwitchType m_switchActive;
+
+ int m_fd;
+ bool m_fdMonitorActive;
+ TQSocketNotifier* m_eventNotifier;
+
+ friend class TDEHardwareDevices;
+};
+
+#endif // _TDEEVENTDEVICE_H
diff --git a/tdecore/tdehw/tdegenericdevice.cpp b/tdecore/tdehw/tdegenericdevice.cpp
index a2d99c310..5f51a8b61 100644
--- a/tdecore/tdehw/tdegenericdevice.cpp
+++ b/tdecore/tdehw/tdegenericdevice.cpp
@@ -26,6 +26,8 @@
#include "tdehardwaredevices.h"
+#include "config.h"
+
TDEGenericDevice::TDEGenericDevice(TDEGenericDeviceType::TDEGenericDeviceType dt, TQString dn) : TQObject() {
m_deviceType = dt;
m_deviceName = dn;
diff --git a/tdecore/tdehw/tdegenericdevice.h b/tdecore/tdehw/tdegenericdevice.h
index 5e9958118..f2abd5582 100644
--- a/tdecore/tdehw/tdegenericdevice.h
+++ b/tdecore/tdehw/tdegenericdevice.h
@@ -26,61 +26,7 @@
#include "tdelibs_export.h"
#include "kicontheme.h"
-// Keep readGenericDeviceTypeFromString(), getFriendlyDeviceTypeStringFromType(), and getDeviceTypeIconFromType() in tdehardwaredevices.cpp in sync with this enum
-namespace TDEGenericDeviceType {
-enum TDEGenericDeviceType {
- Root,
- RootSystem,
- CPU,
- GPU,
- RAM,
- Bus,
- I2C,
- MDIO,
- Mainboard,
- Disk,
- SCSI,
- StorageController,
- Mouse,
- Keyboard,
- HID,
- Modem,
- Monitor,
- Network,
- Printer,
- Scanner,
- Sound,
- VideoCapture,
- IEEE1394,
- PCMCIA,
- Camera,
- TextIO,
- Serial,
- Parallel,
- Peripheral,
- Backlight,
- Battery,
- PowerSupply,
- Dock,
- ThermalSensor,
- ThermalControl,
- BlueTooth,
- Bridge,
- Platform,
- Cryptography,
- Event,
- Input,
- PNP,
- OtherACPI,
- OtherUSB,
- OtherMultimedia,
- OtherPeripheral,
- OtherSensor,
- OtherVirtual,
- Other,
- Last = Other
-};
-};
+#include "tdehwcommontypes.h"
class TDECORE_EXPORT TDEGenericDevice : public TQObject
{
diff --git a/tdecore/tdehw/tdehardwaredevices.cpp b/tdecore/tdehw/tdehardwaredevices.cpp
index 3cf62e8af..08646d17d 100644
--- a/tdecore/tdehw/tdehardwaredevices.cpp
+++ b/tdecore/tdehw/tdehardwaredevices.cpp
@@ -16,60 +16,56 @@
Boston, MA 02110-1301, USA.
*/
-#include <tdehardwaredevices.h>
+#include "tdehardwaredevices.h"
#include <tqfile.h>
#include <tqdir.h>
-#include <tqstringlist.h>
+#include <tqtimer.h>
#include <tqsocketnotifier.h>
+#include <tqstringlist.h>
-#include <tdeglobal.h>
-#include <tdelocale.h>
#include <tdeconfig.h>
-#include <tdetempfile.h>
-#include <ksimpledirwatch.h>
#include <kstandarddirs.h>
+#include <tdeglobal.h>
+#include <tdelocale.h>
+
#include <tdeapplication.h>
#include <dcopclient.h>
#include <libudev.h>
+#include <stdlib.h>
+#include <unistd.h>
#include <fcntl.h>
-// Backlight devices
-#include <linux/fb.h>
-
-// Input devices
-#include <linux/input.h>
-
// Network devices
#include <sys/types.h>
#include <ifaddrs.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <arpa/inet.h>
-#include <sys/socket.h>
#include <netdb.h>
-// Network connection manager
-#include "tdenetworkconnections.h"
+// Backlight devices
+#include <linux/fb.h>
-// Compile-time configuration
-#include "config.h"
+// Input devices
+#include <linux/input.h>
-#ifdef WITH_NETWORK_MANAGER_BACKEND
- #include "networkbackends/network-manager/network-manager.h"
-#endif // WITH_NETWORK_MANAGER_BACKEND
+#include "kiconloader.h"
+
+#include "tdegenericdevice.h"
+#include "tdestoragedevice.h"
+#include "tdecpudevice.h"
+#include "tdebatterydevice.h"
+#include "tdemainspowerdevice.h"
+#include "tdenetworkdevice.h"
+#include "tdebacklightdevice.h"
+#include "tdemonitordevice.h"
+#include "tdesensordevice.h"
+#include "tderootsystemdevice.h"
+#include "tdeeventdevice.h"
+#include "tdeinputdevice.h"
-// uPower
-#if defined(WITH_UPOWER) || defined(WITH_CONSOLEKIT)
- #include <tqdbusdata.h>
- #include <tqdbusmessage.h>
- #include <tqdbusproxy.h>
- #include <tqdbusvariant.h>
- #include <tqdbusconnection.h>
-#endif // defined(WITH_UPOWER)
+#include "config.h"
// BEGIN BLOCK
// Copied from include/linux/genhd.h
@@ -100,868 +96,6 @@ unsigned int reverse_bits(register unsigned int x)
#define BIT_IS_SET(bits, n) (bits[n >> 3] & (1 << (n & 0x7)))
-TDESensorCluster::TDESensorCluster() {
- label = TQString::null;
- current = -1;
- minimum = -1;
- maximum = -1;
- warning = -1;
- critical = -1;
-}
-
-TDESensorDevice::TDESensorDevice(TDEGenericDeviceType::TDEGenericDeviceType dt, TQString dn) : TDEGenericDevice(dt, dn) {
-}
-
-TDESensorDevice::~TDESensorDevice() {
-}
-
-TDESensorClusterMap TDESensorDevice::values() {
- return m_sensorValues;
-}
-
-void TDESensorDevice::internalSetValues(TDESensorClusterMap cl) {
- m_sensorValues = cl;
-}
-
-TDERootSystemDevice::TDERootSystemDevice(TDEGenericDeviceType::TDEGenericDeviceType dt, TQString dn) : TDEGenericDevice(dt, dn) {
- m_hibernationSpace = -1;
-}
-
-TDERootSystemDevice::~TDERootSystemDevice() {
-}
-
-TDESystemFormFactor::TDESystemFormFactor TDERootSystemDevice::formFactor() {
- return m_formFactor;
-}
-
-void TDERootSystemDevice::internalSetFormFactor(TDESystemFormFactor::TDESystemFormFactor ff) {
- m_formFactor = ff;
-}
-
-TDESystemPowerStateList TDERootSystemDevice::powerStates() {
- return m_powerStates;
-}
-
-void TDERootSystemDevice::internalSetPowerStates(TDESystemPowerStateList ps) {
- m_powerStates = ps;
-}
-
-TDESystemHibernationMethodList TDERootSystemDevice::hibernationMethods() {
- return m_hibernationMethods;
-}
-
-void TDERootSystemDevice::internalSetHibernationMethods(TDESystemHibernationMethodList hm) {
- m_hibernationMethods = hm;
-}
-
-TDESystemHibernationMethod::TDESystemHibernationMethod TDERootSystemDevice::hibernationMethod() {
- return m_hibernationMethod;
-}
-
-void TDERootSystemDevice::internalSetHibernationMethod(TDESystemHibernationMethod::TDESystemHibernationMethod hm) {
- m_hibernationMethod = hm;
-}
-
-unsigned long TDERootSystemDevice::diskSpaceNeededForHibernation() {
- return m_hibernationSpace;
-}
-
-void TDERootSystemDevice::internalSetDiskSpaceNeededForHibernation(unsigned long sz) {
- m_hibernationSpace = sz;
-}
-
-bool TDERootSystemDevice::canSetHibernationMethod() {
- TQString hibernationnode = "/sys/power/disk";
- int rval = access (hibernationnode.ascii(), W_OK);
- if (rval == 0) {
- return TRUE;
- }
- else {
- return FALSE;
- }
-}
-
-bool TDERootSystemDevice::canStandby() {
- TQString statenode = "/sys/power/state";
- int rval = access (statenode.ascii(), W_OK);
- if (rval == 0) {
- if (powerStates().contains(TDESystemPowerState::Standby)) {
- return TRUE;
- }
- else {
- return FALSE;
- }
- }
- else {
- return FALSE;
- }
-}
-
-bool TDERootSystemDevice::canSuspend() {
- TQString statenode = "/sys/power/state";
- int rval = access (statenode.ascii(), W_OK);
- if (rval == 0) {
- if (powerStates().contains(TDESystemPowerState::Suspend)) {
- return TRUE;
- }
- else {
- return FALSE;
- }
- }
- else {
-#ifdef WITH_UPOWER
- TQT_DBusConnection dbusConn = TQT_DBusConnection::addConnection(TQT_DBusConnection::SystemBus);
- if (dbusConn.isConnected()) {
- TQT_DBusProxy upowerProperties("org.freedesktop.UPower", "/org/freedesktop/UPower", "org.freedesktop.DBus.Properties", dbusConn);
- if (upowerProperties.canSend()) {
- // can suspend?
- TQValueList<TQT_DBusData> params;
- params << TQT_DBusData::fromString(upowerProperties.interface()) << TQT_DBusData::fromString("CanSuspend");
- TQT_DBusMessage reply = upowerProperties.sendWithReply("Get", params);
- if (reply.type() == TQT_DBusMessage::ReplyMessage && reply.count() == 1) {
- return reply[0].toVariant().value.toBool();
- }
- else {
- return FALSE;
- }
- }
- else {
- return FALSE;
- }
- }
- else {
- return FALSE;
- }
-#else // WITH_UPOWER
- return FALSE;
-#endif// WITH_UPOWER
- }
-}
-
-bool TDERootSystemDevice::canHibernate() {
- TQString statenode = "/sys/power/state";
- int rval = access (statenode.ascii(), W_OK);
- if (rval == 0) {
- if (powerStates().contains(TDESystemPowerState::Hibernate)) {
- return TRUE;
- }
- else {
- return FALSE;
- }
- }
- else {
-#ifdef WITH_UPOWER
- TQT_DBusConnection dbusConn = TQT_DBusConnection::addConnection(TQT_DBusConnection::SystemBus);
- if (dbusConn.isConnected()) {
- TQT_DBusProxy upowerProperties("org.freedesktop.UPower", "/org/freedesktop/UPower", "org.freedesktop.DBus.Properties", dbusConn);
- if (upowerProperties.canSend()) {
- // can hibernate?
- TQValueList<TQT_DBusData> params;
- params << TQT_DBusData::fromString(upowerProperties.interface()) << TQT_DBusData::fromString("CanHibernate");
- TQT_DBusMessage reply = upowerProperties.sendWithReply("Get", params);
- if (reply.type() == TQT_DBusMessage::ReplyMessage && reply.count() == 1) {
- return reply[0].toVariant().value.toBool();
- }
- else {
- return FALSE;
- }
- }
- else {
- return FALSE;
- }
- }
- else {
- return FALSE;
- }
-#else // WITH_UPOWER
- return FALSE;
-#endif// WITH_UPOWER
- }
-}
-
-bool TDERootSystemDevice::canPowerOff() {
- TDEConfig *config = TDEGlobal::config();
- config->reparseConfiguration(); // config may have changed in the KControl module
-
- config->setGroup("General" );
- bool maysd = false;
-#ifdef WITH_CONSOLEKIT
- if (config->readBoolEntry( "offerShutdown", true )) {
- TQT_DBusConnection dbusConn = TQT_DBusConnection::addConnection(TQT_DBusConnection::SystemBus);
- if (dbusConn.isConnected()) {
- TQT_DBusProxy consoleKitManager("org.freedesktop.ConsoleKit", "/org/freedesktop/ConsoleKit/Manager", "org.freedesktop.ConsoleKit.Manager", dbusConn);
- if (consoleKitManager.canSend()) {
- // can power off?
- TQValueList<TQT_DBusData> params;
- TQT_DBusMessage reply = consoleKitManager.sendWithReply("CanStop", params);
- if (reply.type() == TQT_DBusMessage::ReplyMessage && reply.count() == 1) {
- maysd = reply[0].toBool();
- }
- else {
- maysd = false;
- }
- }
- else {
- maysd = false;
- }
- }
- else {
- maysd = false;
- }
- }
-#else // WITH_CONSOLEKIT
- // FIXME
- // Can we power down this system?
- // This should probably be checked via DCOP and therefore interface with KDM
- if (config->readBoolEntry( "offerShutdown", true )/* && DM().canShutdown()*/) { // FIXME
- maysd = true;
- }
-#endif // WITH_CONSOLEKIT
-
- return maysd;
-}
-
-bool TDERootSystemDevice::canReboot() {
- TDEConfig *config = TDEGlobal::config();
- config->reparseConfiguration(); // config may have changed in the KControl module
-
- config->setGroup("General" );
- bool mayrb = false;
-#ifdef WITH_CONSOLEKIT
- if (config->readBoolEntry( "offerShutdown", true )) {
- TQT_DBusConnection dbusConn = TQT_DBusConnection::addConnection(TQT_DBusConnection::SystemBus);
- if (dbusConn.isConnected()) {
- TQT_DBusProxy consoleKitManager("org.freedesktop.ConsoleKit", "/org/freedesktop/ConsoleKit/Manager", "org.freedesktop.ConsoleKit.Manager", dbusConn);
- if (consoleKitManager.canSend()) {
- // can reboot?
- TQValueList<TQT_DBusData> params;
- TQT_DBusMessage reply = consoleKitManager.sendWithReply("CanRestart", params);
- if (reply.type() == TQT_DBusMessage::ReplyMessage && reply.count() == 1) {
- mayrb = reply[0].toBool();
- }
- else {
- mayrb = false;
- }
- }
- else {
- mayrb = false;
- }
- }
- else {
- mayrb = false;
- }
- }
-#else // WITH_CONSOLEKIT
- // FIXME
- // Can we power down this system?
- // This should probably be checked via DCOP and therefore interface with KDM
- if (config->readBoolEntry( "offerShutdown", true )/* && DM().canShutdown()*/) { // FIXME
- mayrb = true;
- }
-#endif // WITH_CONSOLEKIT
-
- return mayrb;
-}
-
-void TDERootSystemDevice::setHibernationMethod(TDESystemHibernationMethod::TDESystemHibernationMethod hm) {
- TQString hibernationnode = "/sys/power/disk";
- TQFile file( hibernationnode );
- if ( file.open( IO_WriteOnly ) ) {
- TQString hibernationCommand;
- if (hm == TDESystemHibernationMethod::Platform) {
- hibernationCommand = "platform";
- }
- if (hm == TDESystemHibernationMethod::Shutdown) {
- hibernationCommand = "shutdown";
- }
- if (hm == TDESystemHibernationMethod::Reboot) {
- hibernationCommand = "reboot";
- }
- if (hm == TDESystemHibernationMethod::TestProc) {
- hibernationCommand = "testproc";
- }
- if (hm == TDESystemHibernationMethod::Test) {
- hibernationCommand = "test";
- }
- TQTextStream stream( &file );
- stream << hibernationCommand;
- file.close();
- }
-}
-
-bool TDERootSystemDevice::setPowerState(TDESystemPowerState::TDESystemPowerState ps) {
- if ((ps == TDESystemPowerState::Standby) || (ps == TDESystemPowerState::Suspend) || (ps == TDESystemPowerState::Hibernate)) {
- TQString statenode = "/sys/power/state";
- TQFile file( statenode );
- if ( file.open( IO_WriteOnly ) ) {
- TQString powerCommand;
- if (ps == TDESystemPowerState::Standby) {
- powerCommand = "standby";
- }
- if (ps == TDESystemPowerState::Suspend) {
- powerCommand = "mem";
- }
- if (ps == TDESystemPowerState::Hibernate) {
- powerCommand = "disk";
- }
- TQTextStream stream( &file );
- stream << powerCommand;
- file.close();
- return true;
- }
- else {
-#ifdef WITH_UPOWER
- TQT_DBusConnection dbusConn;
- dbusConn = TQT_DBusConnection::addConnection(TQT_DBusConnection::SystemBus);
- if ( dbusConn.isConnected() ) {
- if (ps == TDESystemPowerState::Suspend) {
- TQT_DBusMessage msg = TQT_DBusMessage::methodCall(
- "org.freedesktop.UPower",
- "/org/freedesktop/UPower",
- "org.freedesktop.UPower",
- "Suspend");
- dbusConn.sendWithReply(msg);
- return true;
- }
- else if (ps == TDESystemPowerState::Hibernate) {
- TQT_DBusMessage msg = TQT_DBusMessage::methodCall(
- "org.freedesktop.UPower",
- "/org/freedesktop/UPower",
- "org.freedesktop.UPower",
- "Hibernate");
- dbusConn.sendWithReply(msg);
- return true;
- }
- else {
- return false;
- }
- }
- else {
- return false;
- }
-#else // WITH_UPOWER
- return false;
-#endif // WITH_UPOWER
- }
- }
- else if (ps == TDESystemPowerState::PowerOff) {
-#ifdef WITH_CONSOLEKIT
- TDEConfig *config = TDEGlobal::config();
- config->reparseConfiguration(); // config may have changed in the KControl module
- config->setGroup("General" );
- if (config->readBoolEntry( "offerShutdown", true )) {
- TQT_DBusConnection dbusConn;
- dbusConn = TQT_DBusConnection::addConnection(TQT_DBusConnection::SystemBus);
- if ( dbusConn.isConnected() ) {
- TQT_DBusMessage msg = TQT_DBusMessage::methodCall(
- "org.freedesktop.ConsoleKit",
- "/org/freedesktop/ConsoleKit/Manager",
- "org.freedesktop.ConsoleKit.Manager",
- "Stop");
- dbusConn.sendWithReply(msg);
- return true;
- }
- else {
- return false;
- }
- }
- else {
- return false;
- }
-#else // WITH_CONSOLEKIT
- // Power down the system using a DCOP command
- // Values are explained at http://lists.kde.org/?l=kde-linux&m=115770988603387
- TQByteArray data;
- TQDataStream arg(data, IO_WriteOnly);
- arg << (int)0 << (int)2 << (int)2;
- if ( kapp->dcopClient()->send("ksmserver", "default", "logout(int,int,int)", data) ) {
- return true;
- }
- return false;
-#endif // WITH_CONSOLEKIT
- }
- else if (ps == TDESystemPowerState::Reboot) {
-#ifdef WITH_CONSOLEKIT
- TDEConfig *config = TDEGlobal::config();
- config->reparseConfiguration(); // config may have changed in the KControl module
- config->setGroup("General" );
- if (config->readBoolEntry( "offerShutdown", true )) {
- TQT_DBusConnection dbusConn;
- dbusConn = TQT_DBusConnection::addConnection(TQT_DBusConnection::SystemBus);
- if ( dbusConn.isConnected() ) {
- TQT_DBusMessage msg = TQT_DBusMessage::methodCall(
- "org.freedesktop.ConsoleKit",
- "/org/freedesktop/ConsoleKit/Manager",
- "org.freedesktop.ConsoleKit.Manager",
- "Restart");
- dbusConn.sendWithReply(msg);
- return true;
- }
- else {
- return false;
- }
- }
- else {
- return false;
- }
-#else // WITH_CONSOLEKIT
- // Power down the system using a DCOP command
- // Values are explained at http://lists.kde.org/?l=kde-linux&m=115770988603387
- TQByteArray data;
- TQDataStream arg(data, IO_WriteOnly);
- arg << (int)0 << (int)1 << (int)2;
- if ( kapp->dcopClient()->send("ksmserver", "default", "logout(int,int,int)", data) ) {
- return true;
- }
- return false;
-#endif // WITH_CONSOLEKIT
- }
- else if (ps == TDESystemPowerState::Active) {
- // Ummm...we're already active...
- return true;
- }
-
- return false;
-}
-
-TDENetworkDevice::TDENetworkDevice(TDEGenericDeviceType::TDEGenericDeviceType dt, TQString dn) : TDEGenericDevice(dt, dn) {
- m_rxbytes = -1;
- m_txbytes = -1;
- m_rxpackets = -1;
- m_txpackets = -1;
- m_connectionManager = NULL;
-}
-
-TDENetworkDevice::~TDENetworkDevice() {
- if (m_connectionManager) {
- delete m_connectionManager;
- }
-}
-
-TQString TDENetworkDevice::macAddress() {
- return m_macAddress;
-}
-
-void TDENetworkDevice::internalSetMacAddress(TQString ma) {
- m_macAddress = ma;
-}
-
-TQString TDENetworkDevice::state() {
- return m_state;
-}
-
-void TDENetworkDevice::internalSetState(TQString st) {
- m_state = st;
-}
-
-bool TDENetworkDevice::carrierPresent() {
- return m_carrier;
-}
-
-void TDENetworkDevice::internalSetCarrierPresent(bool cp) {
- m_carrier = cp;
-}
-
-bool TDENetworkDevice::dormant() {
- return m_dormant;
-}
-
-void TDENetworkDevice::internalSetDormant(bool dm) {
- m_dormant = dm;
-}
-
-TQString TDENetworkDevice::ipV4Address() {
- return m_ipV4Address;
-}
-
-void TDENetworkDevice::internalSetIpV4Address(TQString ad) {
- m_ipV4Address = ad;
-}
-
-TQString TDENetworkDevice::ipV6Address() {
- return m_ipV6Address;
-}
-
-void TDENetworkDevice::internalSetIpV6Address(TQString ad) {
- m_ipV6Address = ad;
-}
-
-TQString TDENetworkDevice::ipV4Netmask() {
- return m_ipV4Netmask;
-}
-
-void TDENetworkDevice::internalSetIpV4Netmask(TQString nm) {
- m_ipV4Netmask = nm;
-}
-
-TQString TDENetworkDevice::ipV6Netmask() {
- return m_ipV6Netmask;
-}
-
-void TDENetworkDevice::internalSetIpV6Netmask(TQString nm) {
- m_ipV6Netmask = nm;
-}
-
-TQString TDENetworkDevice::ipV4Broadcast() {
- return m_ipV4Broadcast;
-}
-
-void TDENetworkDevice::internalSetIpV4Broadcast(TQString br) {
- m_ipV4Broadcast = br;
-}
-
-TQString TDENetworkDevice::ipV6Broadcast() {
- return m_ipV6Broadcast;
-}
-
-void TDENetworkDevice::internalSetIpV6Broadcast(TQString br) {
- m_ipV6Broadcast = br;
-}
-
-TQString TDENetworkDevice::ipV4Destination() {
- return m_ipV4Destination;
-}
-
-void TDENetworkDevice::internalSetIpV4Destination(TQString ds) {
- m_ipV4Destination = ds;
-}
-
-TQString TDENetworkDevice::ipV6Destination() {
- return m_ipV6Destination;
-}
-
-void TDENetworkDevice::internalSetIpV6Destination(TQString ds) {
- m_ipV6Destination = ds;
-}
-
-double TDENetworkDevice::rxBytes() {
- return m_rxbytes;
-}
-
-void TDENetworkDevice::internalSetRxBytes(double rx) {
- m_rxbytes = rx;
-}
-
-double TDENetworkDevice::txBytes() {
- return m_txbytes;
-}
-
-void TDENetworkDevice::internalSetTxBytes(double tx) {
- m_txbytes = tx;
-}
-
-double TDENetworkDevice::rxPackets() {
- return m_rxpackets;
-}
-
-void TDENetworkDevice::internalSetRxPackets(double rx) {
- m_rxpackets = rx;
-}
-
-double TDENetworkDevice::txPackets() {
- return m_txpackets;
-}
-
-void TDENetworkDevice::internalSetTxPackets(double tx) {
- m_txpackets = tx;
-}
-
-TDENetworkConnectionManager* TDENetworkDevice::connectionManager() {
-#ifdef WITH_NETWORK_MANAGER_BACKEND
- if (!m_connectionManager) {
- m_connectionManager = new TDENetworkConnectionManager_BackendNM(m_macAddress);
- }
-#endif // WITH_NETWORK_MANAGER_BACKEND
-
- return m_connectionManager;
-}
-
-void TDENetworkDevice::internalSetConnectionManager(TDENetworkConnectionManager* mgr) {
- m_connectionManager = mgr;
-}
-
-TDEBacklightDevice::TDEBacklightDevice(TDEGenericDeviceType::TDEGenericDeviceType dt, TQString dn) : TDEGenericDevice(dt, dn) {
-}
-
-TDEBacklightDevice::~TDEBacklightDevice() {
-}
-
-TDEDisplayPowerLevel::TDEDisplayPowerLevel TDEBacklightDevice::powerLevel() {
- return m_powerLevel;
-}
-
-void TDEBacklightDevice::internalSetPowerLevel(TDEDisplayPowerLevel::TDEDisplayPowerLevel pl) {
- m_powerLevel = pl;
-}
-
-void TDEBacklightDevice::internalSetMaximumRawBrightness(int br) {
- m_maximumBrightness = br;
-}
-
-void TDEBacklightDevice::internalSetCurrentRawBrightness(int br) {
- m_currentBrightness = br;
-}
-
-int TDEBacklightDevice::brightnessSteps() {
- return m_maximumBrightness + 1;
-}
-
-double TDEBacklightDevice::brightnessPercent() {
- return (((m_currentBrightness*1.0)/m_maximumBrightness)*100.0);
-}
-
-bool TDEBacklightDevice::canSetBrightness() {
- TQString brightnessnode = systemPath() + "/brightness";
- int rval = access (brightnessnode.ascii(), W_OK);
- if (rval == 0) {
- return TRUE;
- }
- else {
-#ifdef WITH_UPOWER
- TQT_DBusConnection dbusConn = TQT_DBusConnection::addConnection(TQT_DBusConnection::SystemBus);
- if (dbusConn.isConnected()) {
- TQT_DBusProxy hardwareControl("org.trinitydesktop.hardwarecontrol", "/org/trinitydesktop/hardwarecontrol", "org.trinitydesktop.hardwarecontrol.Brightness", dbusConn);
- if (hardwareControl.canSend()) {
- // can set brightness?
- TQValueList<TQT_DBusData> params;
- params << TQT_DBusData::fromString(brightnessnode);
- TQT_DBusMessage reply = hardwareControl.sendWithReply("CanSetBrightness", params);
- if (reply.type() == TQT_DBusMessage::ReplyMessage && reply.count() == 1) {
- return reply[0].toVariant().value.toBool();
- }
- else {
- return FALSE;
- }
- }
- else {
- return FALSE;
- }
- }
- else {
- return FALSE;
- }
-#else // WITH_UPOWER
- return FALSE;
-#endif// WITH_UPOWER
- }
-}
-
-int TDEBacklightDevice::rawBrightness() {
- return m_currentBrightness;
-}
-
-void TDEBacklightDevice::setRawBrightness(int br) {
- TQString brightnessnode = systemPath() + "/brightness";
- TQString brightnessCommand = TQString("%1").arg(br);
- TQFile file( brightnessnode );
- if ( file.open( IO_WriteOnly ) ) {
- TQTextStream stream( &file );
- stream << brightnessCommand;
- file.close();
- }
-#ifdef WITH_UPOWER
- else {
- TQT_DBusConnection dbusConn = TQT_DBusConnection::addConnection(TQT_DBusConnection::SystemBus);
- if (dbusConn.isConnected()) {
- TQT_DBusProxy hardwareControl("org.trinitydesktop.hardwarecontrol", "/org/trinitydesktop/hardwarecontrol", "org.trinitydesktop.hardwarecontrol.Brightness", dbusConn);
- if (hardwareControl.canSend()) {
- // set brightness
- TQValueList<TQT_DBusData> params;
- params << TQT_DBusData::fromString(brightnessnode) << TQT_DBusData::fromString(brightnessCommand);
- hardwareControl.sendWithReply("SetBrightness", params);
- }
- else {
- return;
- }
- }
- else {
- return;
- }
- }
-#endif // WITH_UPOWER
-}
-
-TDEMonitorDevice::TDEMonitorDevice(TDEGenericDeviceType::TDEGenericDeviceType dt, TQString dn) : TDEGenericDevice(dt, dn) {
-}
-
-TDEMonitorDevice::~TDEMonitorDevice() {
-}
-
-bool TDEMonitorDevice::connected() {
- return m_connected;
-}
-
-void TDEMonitorDevice::internalSetConnected(bool cn) {
- m_connected = cn;
-}
-
-bool TDEMonitorDevice::enabled() {
- return m_enabled;
-}
-
-void TDEMonitorDevice::internalSetEnabled(bool en) {
- m_enabled = en;
-}
-
-TQByteArray TDEMonitorDevice::edid() {
- return m_edid;
-}
-
-void TDEMonitorDevice::internalSetEdid(TQByteArray ed) {
- m_edid = ed;
-}
-
-TDEResolutionList TDEMonitorDevice::resolutions() {
- return m_resolutions;
-}
-
-void TDEMonitorDevice::internalSetResolutions(TDEResolutionList rs) {
- m_resolutions = rs;
-}
-
-TQString TDEMonitorDevice::portType() {
- return m_portType;
-}
-
-void TDEMonitorDevice::internalSetPortType(TQString pt) {
- m_portType = pt;
-}
-
-TDEDisplayPowerLevel::TDEDisplayPowerLevel TDEMonitorDevice::powerLevel() {
- return m_powerLevel;
-}
-
-void TDEMonitorDevice::internalSetPowerLevel(TDEDisplayPowerLevel::TDEDisplayPowerLevel pl) {
- m_powerLevel = pl;
-}
-
-TDEEventDevice::TDEEventDevice(TDEGenericDeviceType::TDEGenericDeviceType dt, TQString dn) : TDEGenericDevice(dt, dn) {
- m_fd = -1;
- m_fdMonitorActive = false;
-}
-
-TDEEventDevice::~TDEEventDevice() {
- if (m_fd >= 0) {
- close(m_fd);
- }
-}
-
-TDEEventDeviceType::TDEEventDeviceType TDEEventDevice::eventType() {
- return m_eventType;
-}
-
-void TDEEventDevice::internalSetEventType(TDEEventDeviceType::TDEEventDeviceType et) {
- m_eventType = et;
-}
-
-TDESwitchType::TDESwitchType TDEEventDevice::providedSwitches() {
- return m_providedSwitches;
-}
-
-void TDEEventDevice::internalSetProvidedSwitches(TDESwitchType::TDESwitchType sl) {
- m_providedSwitches = sl;
-}
-
-TDESwitchType::TDESwitchType TDEEventDevice::activeSwitches() {
- return m_switchActive;
-}
-
-void TDEEventDevice::internalSetActiveSwitches(TDESwitchType::TDESwitchType sl) {
- m_switchActive = sl;
-}
-
-// Keep this in sync with the TDESwitchType definition in the header
-TQStringList TDEEventDevice::friendlySwitchList(TDESwitchType::TDESwitchType switches) {
- TQStringList ret;
-
- if (switches & TDESwitchType::Lid) {
- ret.append(i18n("Lid Switch"));
- }
- if (switches & TDESwitchType::TabletMode) {
- ret.append(i18n("Tablet Mode"));
- }
- if (switches & TDESwitchType::HeadphoneInsert) {
- ret.append(i18n("Headphone Inserted"));
- }
- if (switches & TDESwitchType::RFKill) {
- ret.append(i18n("Radio Frequency Device Kill Switch"));
- }
- if (switches & TDESwitchType::Radio) {
- ret.append(i18n("Enable Radio"));
- }
- if (switches & TDESwitchType::MicrophoneInsert) {
- ret.append(i18n("Microphone Inserted"));
- }
- if (switches & TDESwitchType::Dock) {
- ret.append(i18n("Docked"));
- }
- if (switches & TDESwitchType::LineOutInsert) {
- ret.append(i18n("Line Out Inserted"));
- }
- if (switches & TDESwitchType::JackPhysicalInsert) {
- ret.append(i18n("Physical Jack Inserted"));
- }
- if (switches & TDESwitchType::VideoOutInsert) {
- ret.append(i18n("Video Out Inserted"));
- }
- if (switches & TDESwitchType::CameraLensCover) {
- ret.append(i18n("Camera Lens Cover"));
- }
- if (switches & TDESwitchType::KeypadSlide) {
- ret.append(i18n("Keypad Slide"));
- }
- if (switches & TDESwitchType::FrontProximity) {
- ret.append(i18n("Front Proximity"));
- }
- if (switches & TDESwitchType::RotateLock) {
- ret.append(i18n("Rotate Lock"));
- }
- if (switches & TDESwitchType::LineInInsert) {
- ret.append(i18n("Line In Inserted"));
- }
-
- return ret;
-}
-
-void TDEEventDevice::internalStartFdMonitoring(TDEHardwareDevices* hwmanager) {
- if (!m_fdMonitorActive) {
- // For security and performance reasons, only monitor known ACPI buttons
- if (eventType() != TDEEventDeviceType::Unknown) {
- if (m_fd >= 0) {
- m_eventNotifier = new TQSocketNotifier(m_fd, TQSocketNotifier::Read, this);
- connect( m_eventNotifier, TQT_SIGNAL(activated(int)), this, TQT_SLOT(eventReceived()) );
- }
- connect( this, TQT_SIGNAL(keyPressed(unsigned int, TDEEventDevice*)), hwmanager, TQT_SLOT(processEventDeviceKeyPressed(unsigned int, TDEEventDevice*)) );
- }
- m_fdMonitorActive = true;
- }
-}
-
-void TDEEventDevice::eventReceived() {
- struct input_event ev;
- int r;
- r = read(m_fd, &ev, sizeof(struct input_event));
- if (r > 0) {
- if (ev.type == EV_KEY) {
- emit keyPressed(ev.code, this);
- }
- }
-}
-
-TDEInputDevice::TDEInputDevice(TDEGenericDeviceType::TDEGenericDeviceType dt, TQString dn) : TDEGenericDevice(dt, dn) {
-}
-
-TDEInputDevice::~TDEInputDevice() {
-}
-
-TDEInputDeviceType::TDEInputDeviceType TDEInputDevice::inputType() {
- return m_inputType;
-}
-
-void TDEInputDevice::internalSetInputType(TDEInputDeviceType::TDEInputDeviceType it) {
- m_inputType = it;
-}
-
TDEHardwareDevices::TDEHardwareDevices() {
// Initialize members
pci_id_map = 0;
diff --git a/tdecore/tdehw/tdehardwaredevices.h b/tdecore/tdehw/tdehardwaredevices.h
index 200999bf1..4d97ac7c5 100644
--- a/tdecore/tdehw/tdehardwaredevices.h
+++ b/tdecore/tdehw/tdehardwaredevices.h
@@ -18,834 +18,64 @@
#ifndef _TDEHARDWAREDEVICES_H
#define _TDEHARDWAREDEVICES_H
+
// TDE includes
#include <tqobject.h>
-#include <tqstring.h>
#include <tqptrlist.h>
+#include <tqmap.h>
+#include <tqstring.h>
#include <tqstringlist.h>
-#include "kiconloader.h"
+
#include "tdelibs_export.h"
+#include "kicontheme.h"
+
+#include "tdehwcommontypes.h"
-// udev includes
+// FIXME delete those headers after complete fixing everything in over modules
+/*
+#include "tdegenericdevice.h"
+#include "kiconloader.h"
#include <libudev.h>
#include <stdio.h>
#include <stdlib.h>
#include <locale.h>
#include <unistd.h>
-
-// FIXME delete those headers after complete porting
-#include "tdegenericdevice.h"
#include "tdestoragedevice.h"
#include "tdecpudevice.h"
-#include "tdemainspowerdevice.h"
#include "tdebatterydevice.h"
+#include "tdemainspowerdevice.h"
+#include "tdenetworkdevice.h"
+#include "tdebacklightdevice.h"
+#include "tdemonitordevice.h"
+#include "tdesensordevice.h"
+#include "tderootsystemdevice.h"
+#include "tdeeventdevice.h"
+#include "tdeinputdevice.h"
+*/
/**
* Hardware Device Access and Monitoring Library
*
* @author Timothy Pearson
*/
+struct udev_device;
-class TDENetworkConnectionManager;
-
-namespace TDEHardwareEvent {
-enum TDEHardwareEvent {
- HardwareListModified,
- MountTableModified,
- HardwareAdded,
- HardwareRemoved,
- HardwareUpdated,
- Other,
- Last = Other
-};
-};
-
-class TDECORE_EXPORT TDESensorCluster
-{
- public:
- /**
- * Constructor.
- */
- TDESensorCluster();
-
- TQString label;
- double current;
- double minimum;
- double maximum;
- double warning;
- double critical;
-};
-
-class TDECORE_EXPORT TDENetworkDevice : public TDEGenericDevice
-{
- public:
- /**
- * Constructor.
- * @param Device type
- */
- TDENetworkDevice(TDEGenericDeviceType::TDEGenericDeviceType dt, TQString dn=TQString::null);
-
- /**
- * Destructor.
- */
- ~TDENetworkDevice();
-
- /**
- * @return a TQString containing the network device's MAC address
- */
- TQString macAddress();
-
- /**
- * @return a TQString containing the network device's operational state
- */
- TQString state();
-
- /**
- * @return TRUE if carrier is present, FALSE if not
- */
- bool carrierPresent();
-
- /**
- * @return TRUE if device is dormant, FALSE if not
- */
- bool dormant();
-
- /**
- * @return a TQString containing the network device's IPv4 address
- */
- TQString ipV4Address();
-
- /**
- * @return a TQString containing the network device's IPv6 address
- */
- TQString ipV6Address();
-
- /**
- * @return a TQString containing the network device's IPv4 netmask
- */
- TQString ipV4Netmask();
-
- /**
- * @return a TQString containing the network device's IPv6 netmask
- */
- TQString ipV6Netmask();
-
- /**
- * @return a TQString containing the network device's IPv4 broadcast
- */
- TQString ipV4Broadcast();
-
- /**
- * @return a TQString containing the network device's IPv6 broadcast
- */
- TQString ipV6Broadcast();
-
- /**
- * @return a TQString containing the network device's IPv4 destination
- */
- TQString ipV4Destination();
-
- /**
- * @return a TQString containing the network device's IPv6 destination
- */
- TQString ipV6Destination();
-
- /**
- * @return a double with the number of received bytes, if available
- */
- double rxBytes();
-
- /**
- * @return a double with the number of transmitted bytes, if available
- */
- double txBytes();
-
- /**
- * @return a double with the number of received packets, if available
- */
- double rxPackets();
-
- /**
- * @return a double with the number of transmitted packets, if available
- */
- double txPackets();
-
- /**
- * @return a pointer to a TDENetworkConnectionManager object, if available
- */
- TDENetworkConnectionManager* connectionManager();
-
- protected:
- /**
- * @param ma a TQString containing the network device's MAC address
- * @internal
- */
- void internalSetMacAddress(TQString ma);
-
- /**
- * @param st a TQString containing the network device's operational state
- * @internal
- */
- void internalSetState(TQString st);
-
- /**
- * @param TRUE if carrier is present, FALSE if not
- * @internal
- */
- void internalSetCarrierPresent(bool cp);
-
- /**
- * @param TRUE if device is dormant, FALSE if not
- * @internal
- */
- void internalSetDormant(bool dm);
-
- /**
- * @param ad a TQString containing the network device's IPv4 address
- * @internal
- */
- void internalSetIpV4Address(TQString ad);
-
- /**
- * @param ad a TQString containing the network device's IPv6 address
- * @internal
- */
- void internalSetIpV6Address(TQString ad);
-
- /**
- * @param nm a TQString containing the network device's IPv4 netmask
- * @internal
- */
- void internalSetIpV4Netmask(TQString nm);
-
- /**
- * @param nm a TQString containing the network device's IPv6 netmask
- * @internal
- */
- void internalSetIpV6Netmask(TQString nm);
-
- /**
- * @param br a TQString containing the network device's IPv4 broadcast
- * @internal
- */
- void internalSetIpV4Broadcast(TQString br);
-
- /**
- * @param br a TQString containing the network device's IPv6 broadcast
- * @internal
- */
- void internalSetIpV6Broadcast(TQString br);
-
- /**
- * @param ds a TQString containing the network device's IPv4 destination
- * @internal
- */
- void internalSetIpV4Destination(TQString ds);
-
- /**
- * @param ds a TQString containing the network device's IPv6 destination
- * @internal
- */
- void internalSetIpV6Destination(TQString ds);
-
- /**
- * @param rx a double with the number of received bytes, if available
- * @internal
- */
- void internalSetRxBytes(double rx);
-
- /**
- * @param tx a double with the number of transmitted bytes, if available
- * @internal
- */
- void internalSetTxBytes(double tx);
-
- /**
- * @param rx a double with the number of received packets, if available
- * @internal
- */
- void internalSetRxPackets(double rx);
-
- /**
- * @param tx a double with the number of transmitted packets, if available
- * @internal
- */
- void internalSetTxPackets(double tx);
-
- /**
- * @param mgr a pointer to a TDENetworkConnectionManager object, if available
- */
- void internalSetConnectionManager(TDENetworkConnectionManager* mgr);
-
- private:
- TQString m_macAddress;
- TQString m_state;
- bool m_carrier;
- bool m_dormant;
- TQString m_ipV4Address;
- TQString m_ipV6Address;
- TQString m_ipV4Netmask;
- TQString m_ipV6Netmask;
- TQString m_ipV4Broadcast;
- TQString m_ipV6Broadcast;
- TQString m_ipV4Destination;
- TQString m_ipV6Destination;
- double m_rxbytes;
- double m_txbytes;
- double m_rxpackets;
- double m_txpackets;
- TDENetworkConnectionManager* m_connectionManager;
-
- friend class TDEHardwareDevices;
-};
-
-namespace TDEDisplayPowerLevel {
-enum TDEDisplayPowerLevel {
- On,
- Standby,
- Suspend,
- Off
-};
-};
-
-class TDECORE_EXPORT TDEBacklightDevice : public TDEGenericDevice
-{
- public:
- /**
- * Constructor.
- * @param Device type
- */
- TDEBacklightDevice(TDEGenericDeviceType::TDEGenericDeviceType dt, TQString dn=TQString::null);
-
- /**
- * Destructor.
- */
- ~TDEBacklightDevice();
-
- /**
- * @return a TDEDisplayPowerLevel::TDEDisplayPowerLevel with the current power level
- */
- TDEDisplayPowerLevel::TDEDisplayPowerLevel powerLevel();
-
- /**
- * @return an integer with the number of discrete control steps available
- */
- int brightnessSteps();
-
- /**
- * @return a double with the current brightness percentage
- */
- double brightnessPercent();
-
- /**
- * @return TRUE if permissions allow brightness can be set, FALSE if not
- */
- bool canSetBrightness();
-
- /**
- * @return an int with the current raw brightness
- */
- int rawBrightness();
-
- /**
- * @param br an integer with the new raw brightness value
- */
- void setRawBrightness(int br);
-
- protected:
- /**
- * @param pl a TDEDisplayPowerLevel::TDEDisplayPowerLevel with the current power level
- * @internal
- */
- void internalSetPowerLevel(TDEDisplayPowerLevel::TDEDisplayPowerLevel pl);
-
- /**
- * @param br an integer with the maximum raw brightness value
- * @internal
- */
- void internalSetMaximumRawBrightness(int br);
-
- /**
- * @param br an integer with the current raw brightness value
- * @internal
- */
- void internalSetCurrentRawBrightness(int br);
-
- private:
- TDEDisplayPowerLevel::TDEDisplayPowerLevel m_powerLevel;
- int m_currentBrightness;
- int m_maximumBrightness;
-
- friend class TDEHardwareDevices;
-};
-
-typedef TQPair<unsigned int, unsigned int> TDEResolutionPair;
-typedef TQValueList< TDEResolutionPair > TDEResolutionList;
-
-class TDECORE_EXPORT TDEMonitorDevice : public TDEGenericDevice
-{
- public:
- /**
- * Constructor.
- * @param Device type
- */
- TDEMonitorDevice(TDEGenericDeviceType::TDEGenericDeviceType dt, TQString dn=TQString::null);
-
- /**
- * Destructor.
- */
- ~TDEMonitorDevice();
-
- /**
- * @return TRUE if a monitor is connected, FALSE if not
- */
- bool connected();
-
- /**
- * @return TRUE if this port is enabled, FALSE if not
- */
- bool enabled();
-
- /**
- * @return a TQByteArray containing this monitor's EDID information
- */
- TQByteArray edid();
-
- /**
- * @return a TDEResolutionList containing this monitor's supported resolutions
- */
- TDEResolutionList resolutions();
-
- /**
- * @return a TQString containing the display port type
- */
- TQString portType();
-
- /**
- * @return a TDEDisplayPowerLevel::TDEDisplayPowerLevel with the current power level
- */
- TDEDisplayPowerLevel::TDEDisplayPowerLevel powerLevel();
-
- protected:
- /**
- * @param TRUE if a monitor is connected, FALSE if not
- * @internal
- */
- void internalSetConnected(bool cn);
-
- /**
- * @param TRUE if this port is enabled, FALSE if not
- * @internal
- */
- void internalSetEnabled(bool en);
-
- /**
- * @param ed a TQByteArray containing this monitor's EDID information
- * @internal
- */
- void internalSetEdid(TQByteArray ed);
-
- /**
- * @param rs a TDEResolutionList containing this monitor's supported resolutions
- * @internal
- */
- void internalSetResolutions(TDEResolutionList rs);
-
- /**
- * @param pt a TQString containing the display port type
- * @internal
- */
- void internalSetPortType(TQString pt);
-
- /**
- * @param pl a TDEDisplayPowerLevel::TDEDisplayPowerLevel with the current power level
- * @internal
- */
- void internalSetPowerLevel(TDEDisplayPowerLevel::TDEDisplayPowerLevel pl);
-
- private:
- bool m_connected;
- bool m_enabled;
- TQByteArray m_edid;
- TDEResolutionList m_resolutions;
- TQString m_portType;
- TDEDisplayPowerLevel::TDEDisplayPowerLevel m_powerLevel;
-
- friend class TDEHardwareDevices;
-};
-
-
-typedef TQMap<TQString, TDESensorCluster> TDESensorClusterMap;
-
-class TDECORE_EXPORT TDESensorDevice : public TDEGenericDevice
-{
- public:
- /**
- * Constructor.
- * @param Device type
- */
- TDESensorDevice(TDEGenericDeviceType::TDEGenericDeviceType dt, TQString dn=TQString::null);
-
- /**
- * Destructor.
- */
- ~TDESensorDevice();
-
- /**
- * @return a TDESensorClusterMap with the current sensor values
- */
- TDESensorClusterMap values();
-
- protected:
- /**
- * @param a TDESensorClusterMap with the current sensor values
- * @internal
- */
- void internalSetValues(TDESensorClusterMap cl);
-
- private:
- TDESensorClusterMap m_sensorValues;
-
- friend class TDEHardwareDevices;
-};
-
-namespace TDESystemFormFactor {
-enum TDESystemFormFactor {
- Unclassified,
- Desktop,
- Laptop,
- Server,
- Other = 0x80000000
-};
-};
-
-namespace TDESystemPowerState {
-enum TDESystemPowerState {
- Active,
- Standby,
- Suspend,
- Hibernate,
- PowerOff,
- Reboot
-};
-};
-
-namespace TDESystemHibernationMethod {
-enum TDESystemHibernationMethod {
- Unsupported,
- Platform,
- Shutdown,
- Reboot,
- TestProc,
- Test
-};
-};
-
-typedef TQValueList<TDESystemPowerState::TDESystemPowerState> TDESystemPowerStateList;
-typedef TQValueList<TDESystemHibernationMethod::TDESystemHibernationMethod> TDESystemHibernationMethodList;
-
-class TDECORE_EXPORT TDERootSystemDevice : public TDEGenericDevice
-{
- public:
- /**
- * Constructor.
- * @param Device type
- */
- TDERootSystemDevice(TDEGenericDeviceType::TDEGenericDeviceType dt, TQString dn=TQString::null);
-
- /**
- * Destructor.
- */
- ~TDERootSystemDevice();
-
- /**
- * @return a TDESystemFormFactor::TDESystemFormFactor with the system's form factor
- */
- TDESystemFormFactor::TDESystemFormFactor formFactor();
-
- /**
- * @return a TDESystemPowerStateList with all available power states
- */
- TDESystemPowerStateList powerStates();
-
- /**
- * @return a TDESystemHibernationMethodList with all available hibernation methods
- */
- TDESystemHibernationMethodList hibernationMethods();
-
- /**
- * @return a TDESystemHibernationMethod::TDESystemHibernationMethod with the current hibernation method
- */
- TDESystemHibernationMethod::TDESystemHibernationMethod hibernationMethod();
-
- /**
- * @return an unsigned long with the number of bytes required to hibernate
- */
- unsigned long diskSpaceNeededForHibernation();
-
- /**
- * @return TRUE if permissions allow the hibernation method to be set, FALSE if not
- */
- bool canSetHibernationMethod();
-
- /**
- * @return TRUE if hardware and permissions allow the system to enter standby, FALSE if not
- */
- bool canStandby();
-
- /**
- * @return TRUE if hardware and permissions allow the system to be suspended, FALSE if not
- */
- bool canSuspend();
-
- /**
- * @return TRUE if hardware and permissions allow the system to be hibernated, FALSE if not
- */
- bool canHibernate();
-
- /**
- * @return TRUE if permissions allow the system to be powered down, FALSE if not
- */
- bool canPowerOff();
-
- /**
- * @return TRUE if permissions allow the system to be rebooted, FALSE if not
- */
- bool canReboot();
-
- /**
- * @param hm a TDESystemHibernationMethod::TDESystemHibernationMethod with the desired hibernation method
- */
- void setHibernationMethod(TDESystemHibernationMethod::TDESystemHibernationMethod hm);
-
- /**
- * @param ps a TDESystemPowerState::TDESystemPowerState with the desired power state
- * @return TRUE if power state was set
- */
- bool setPowerState(TDESystemPowerState::TDESystemPowerState ps);
-
- protected:
- /**
- * @param ff a TDESystemFormFactor::TDESystemFormFactor with the system's form factor
- * @internal
- */
- void internalSetFormFactor(TDESystemFormFactor::TDESystemFormFactor ff);
-
- /**
- * @param ps a TDESystemPowerStateList with all available power states
- * @internal
- */
- void internalSetPowerStates(TDESystemPowerStateList ps);
-
- /**
- * @param hm a TDESystemHibernationMethodList with all available hibernation methods
- * @internal
- */
- void internalSetHibernationMethods(TDESystemHibernationMethodList hm);
-
- /**
- * @param hm a TDESystemHibernationMethod::TDESystemHibernationMethod with the current hibernation method
- * @internal
- */
- void internalSetHibernationMethod(TDESystemHibernationMethod::TDESystemHibernationMethod hm);
-
- /**
- * @param sz an unsigned long with the number of bytes required to hibernate
- * @internal
- */
- void internalSetDiskSpaceNeededForHibernation(unsigned long sz);
-
- private:
- TDESystemFormFactor::TDESystemFormFactor m_formFactor;
- TDESystemPowerStateList m_powerStates;
- TDESystemHibernationMethodList m_hibernationMethods;
- TDESystemHibernationMethod::TDESystemHibernationMethod m_hibernationMethod;
- unsigned long m_hibernationSpace;
-
- friend class TDEHardwareDevices;
-};
-
-namespace TDEEventDeviceType {
-enum TDEEventDeviceType {
- Unknown,
- ACPILidSwitch,
- ACPISleepButton,
- ACPIPowerButton,
- Other = 0x80000000
-};
-};
-
-// Keep friendlySwitchList() in tdehardwaredevices.cpp in sync with this enum
-namespace TDESwitchType {
-enum TDESwitchType {
- Null = 0x00000000,
- Lid = 0x00000001,
- TabletMode = 0x00000002,
- HeadphoneInsert = 0x00000004,
- RFKill = 0x00000008,
- Radio = 0x00000010,
- MicrophoneInsert = 0x00000020,
- Dock = 0x00000040,
- LineOutInsert = 0x00000080,
- JackPhysicalInsert = 0x00000100,
- VideoOutInsert = 0x00000200,
- CameraLensCover = 0x00000400,
- KeypadSlide = 0x00000800,
- FrontProximity = 0x00001000,
- RotateLock = 0x00002000,
- LineInInsert = 0x00004000
-};
-
-inline TDESwitchType operator|(TDESwitchType a, TDESwitchType b)
-{
- return static_cast<TDESwitchType>(static_cast<int>(a) | static_cast<int>(b));
-}
-
-inline TDESwitchType operator&(TDESwitchType a, TDESwitchType b)
-{
- return static_cast<TDESwitchType>(static_cast<int>(a) & static_cast<int>(b));
-}
-
-inline TDESwitchType operator~(TDESwitchType a)
-{
- return static_cast<TDESwitchType>(~static_cast<int>(a));
-}
-};
+class KSimpleDirWatch;
+class TDEGenericDevice;
+class TDEStorageDevice;
+class TDENetworkDevice;
+class TDEBacklightDevice;
+class TDEMonitorDevice;
+class TDESensorDevice;
+class TDERootSystemDevice;
+class TDEEventDevice;
+class TDEInputDevice;
class TQSocketNotifier;
-class TDECORE_EXPORT TDEEventDevice : public TDEGenericDevice
-{
- Q_OBJECT
-
- public:
- /**
- * Constructor.
- * @param Device type
- */
- TDEEventDevice(TDEGenericDeviceType::TDEGenericDeviceType dt, TQString dn=TQString::null);
-
- /**
- * Destructor.
- */
- ~TDEEventDevice();
-
- /**
- * @return a TDEEventDeviceType::TDEEventDeviceType with the event device type, if known
- */
- TDEEventDeviceType::TDEEventDeviceType eventType();
-
- /**
- * @return a TDESwitchType::TDESwitchType with all switches provided by this device
- */
- TDESwitchType::TDESwitchType providedSwitches();
-
- /**
- * @return a TDESwitchType::TDESwitchType with all active switches provided by this device
- */
- TDESwitchType::TDESwitchType activeSwitches();
-
- /**
- * @param switches a TDESwitchType::TDESwitchType with any switch flags set
- * @return a TQStringList with friendly names for all set switch flags
- */
- static TQStringList friendlySwitchList(TDESwitchType::TDESwitchType switches);
-
- protected:
- /**
- * @param et a TDEEventDeviceType::TDEEventDeviceType with the event device type, if known
- * @internal
- */
- void internalSetEventType(TDEEventDeviceType::TDEEventDeviceType et);
-
- /**
- * @param sl a TDESwitchType::TDESwitchType with all switches provided by this device
- * @internal
- */
- void internalSetProvidedSwitches(TDESwitchType::TDESwitchType sl);
-
- /**
- * @param sl a TDESwitchType::TDESwitchType with all active switches provided by this device
- * @internal
- */
- void internalSetActiveSwitches(TDESwitchType::TDESwitchType sl);
-
- /**
- * @param hwmanager the master hardware manager
- * @internal
- */
- void internalStartFdMonitoring(TDEHardwareDevices* hwmanager);
-
- protected slots:
- void eventReceived();
-
- signals:
- /**
- * @param keycode the code of the key that was pressed/released
- * See include/linux/input.h for a complete list of keycodes
- * @param device a TDEEventDevice* with the device that received the event
- */
- void keyPressed(unsigned int keycode, TDEEventDevice* device);
-
- private:
- TDEEventDeviceType::TDEEventDeviceType m_eventType;
- TDESwitchType::TDESwitchType m_providedSwitches;
- TDESwitchType::TDESwitchType m_switchActive;
-
- int m_fd;
- bool m_fdMonitorActive;
- TQSocketNotifier* m_eventNotifier;
-
- friend class TDEHardwareDevices;
-};
-
-namespace TDEInputDeviceType {
-enum TDEInputDeviceType {
- Unknown,
- ACPILidSwitch,
- ACPISleepButton,
- ACPIPowerButton,
- Other = 0x80000000
-};
-};
-
-class TDECORE_EXPORT TDEInputDevice : public TDEGenericDevice
-{
- public:
- /**
- * Constructor.
- * @param Device type
- */
- TDEInputDevice(TDEGenericDeviceType::TDEGenericDeviceType dt, TQString dn=TQString::null);
-
- /**
- * Destructor.
- */
- ~TDEInputDevice();
-
- /**
- * @return a TDEInputDeviceType::TDEInputDeviceType with the input device type, if known
- */
- TDEInputDeviceType::TDEInputDeviceType inputType();
-
- protected:
- /**
- * @param it a TDEInputDeviceType::TDEInputDeviceType with the input device type, if known
- * @internal
- */
- void internalSetInputType(TDEInputDeviceType::TDEInputDeviceType it);
-
- private:
- TDEInputDeviceType::TDEInputDeviceType m_inputType;
-
- friend class TDEHardwareDevices;
-};
-
typedef TQPtrList<TDEGenericDevice> TDEGenericHardwareList;
typedef TQMap<TQString, TQString> TDEDeviceIDMap;
-class KSimpleDirWatch;
-
class TDECORE_EXPORT TDEHardwareDevices : public TQObject
{
Q_OBJECT
diff --git a/tdecore/tdehw/tdehwcommontypes.h b/tdecore/tdehw/tdehwcommontypes.h
new file mode 100644
index 000000000..095672669
--- /dev/null
+++ b/tdecore/tdehw/tdehwcommontypes.h
@@ -0,0 +1,100 @@
+/* This file is part of the TDE libraries
+ Copyright (C) 2012 Timothy Pearson <kb9vqf@pearsoncomputing.net>
+ (C) 2013 Golubev Alexander <fatzer2@gmail.com>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License version 2 as published by the Free Software Foundation.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef _TDEHWCOMMON_H
+#define _TDEHWCOMMON_H
+
+// Keep readGenericDeviceTypeFromString(), getFriendlyDeviceTypeStringFromType(), and getDeviceTypeIconFromType() in tdehardwaredevices.cpp in sync with this enum
+namespace TDEGenericDeviceType {
+enum TDEGenericDeviceType {
+ Root,
+ RootSystem,
+ CPU,
+ GPU,
+ RAM,
+ Bus,
+ I2C,
+ MDIO,
+ Mainboard,
+ Disk,
+ SCSI,
+ StorageController,
+ Mouse,
+ Keyboard,
+ HID,
+ Modem,
+ Monitor,
+ Network,
+ Printer,
+ Scanner,
+ Sound,
+ VideoCapture,
+ IEEE1394,
+ PCMCIA,
+ Camera,
+ TextIO,
+ Serial,
+ Parallel,
+ Peripheral,
+ Backlight,
+ Battery,
+ PowerSupply,
+ Dock,
+ ThermalSensor,
+ ThermalControl,
+ BlueTooth,
+ Bridge,
+ Platform,
+ Cryptography,
+ Event,
+ Input,
+ PNP,
+ OtherACPI,
+ OtherUSB,
+ OtherMultimedia,
+ OtherPeripheral,
+ OtherSensor,
+ OtherVirtual,
+ Other,
+ Last = Other
+};
+};
+
+namespace TDEDisplayPowerLevel {
+enum TDEDisplayPowerLevel {
+ On,
+ Standby,
+ Suspend,
+ Off
+};
+};
+
+namespace TDEHardwareEvent {
+enum TDEHardwareEvent {
+ HardwareListModified,
+ MountTableModified,
+ HardwareAdded,
+ HardwareRemoved,
+ HardwareUpdated,
+ Other,
+ Last = Other
+};
+};
+
+#endif // _TDEHWCOMMON_H
diff --git a/tdecore/tdehw/tdeinputdevice.cpp b/tdecore/tdehw/tdeinputdevice.cpp
new file mode 100644
index 000000000..c4e649e94
--- /dev/null
+++ b/tdecore/tdehw/tdeinputdevice.cpp
@@ -0,0 +1,38 @@
+/* This file is part of the TDE libraries
+ Copyright (C) 2012 Timothy Pearson <kb9vqf@pearsoncomputing.net>
+ (C) 2013 Golubev Alexander <fatzer2@gmail.com>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License version 2 as published by the Free Software Foundation.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "tdeinputdevice.h"
+
+#include "config.h"
+
+TDEInputDevice::TDEInputDevice(TDEGenericDeviceType::TDEGenericDeviceType dt, TQString dn) : TDEGenericDevice(dt, dn) {
+}
+
+TDEInputDevice::~TDEInputDevice() {
+}
+
+TDEInputDeviceType::TDEInputDeviceType TDEInputDevice::inputType() {
+ return m_inputType;
+}
+
+void TDEInputDevice::internalSetInputType(TDEInputDeviceType::TDEInputDeviceType it) {
+ m_inputType = it;
+}
+
+#include "tdeinputdevice.moc"
diff --git a/tdecore/tdehw/tdeinputdevice.h b/tdecore/tdehw/tdeinputdevice.h
new file mode 100644
index 000000000..410ff3e1e
--- /dev/null
+++ b/tdecore/tdehw/tdeinputdevice.h
@@ -0,0 +1,67 @@
+/* This file is part of the TDE libraries
+ Copyright (C) 2012 Timothy Pearson <kb9vqf@pearsoncomputing.net>
+ (C) 2013 Golubev Alexander <fatzer2@gmail.com>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License version 2 as published by the Free Software Foundation.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef _TDEINPUTDEVICE_H
+#define _TDEINPUTDEVICE_H
+
+#include "tdegenericdevice.h"
+
+namespace TDEInputDeviceType {
+enum TDEInputDeviceType {
+ Unknown,
+ ACPILidSwitch,
+ ACPISleepButton,
+ ACPIPowerButton,
+ Other = 0x80000000
+};
+};
+
+class TDECORE_EXPORT TDEInputDevice : public TDEGenericDevice
+{
+ public:
+ /**
+ * Constructor.
+ * @param Device type
+ */
+ TDEInputDevice(TDEGenericDeviceType::TDEGenericDeviceType dt, TQString dn=TQString::null);
+
+ /**
+ * Destructor.
+ */
+ ~TDEInputDevice();
+
+ /**
+ * @return a TDEInputDeviceType::TDEInputDeviceType with the input device type, if known
+ */
+ TDEInputDeviceType::TDEInputDeviceType inputType();
+
+ protected:
+ /**
+ * @param it a TDEInputDeviceType::TDEInputDeviceType with the input device type, if known
+ * @internal
+ */
+ void internalSetInputType(TDEInputDeviceType::TDEInputDeviceType it);
+
+ private:
+ TDEInputDeviceType::TDEInputDeviceType m_inputType;
+
+ friend class TDEHardwareDevices;
+};
+
+#endif // _TDEINPUTDEVICE_H
diff --git a/tdecore/tdehw/tdemainspowerdevice.cpp b/tdecore/tdehw/tdemainspowerdevice.cpp
index 60eb4f169..981f0a343 100644
--- a/tdecore/tdehw/tdemainspowerdevice.cpp
+++ b/tdecore/tdehw/tdemainspowerdevice.cpp
@@ -19,6 +19,8 @@
#include "tdemainspowerdevice.h"
+#include "config.h"
+
TDEMainsPowerDevice::TDEMainsPowerDevice(TDEGenericDeviceType::TDEGenericDeviceType dt, TQString dn) : TDEGenericDevice(dt, dn) {
}
diff --git a/tdecore/tdehw/tdemonitordevice.cpp b/tdecore/tdehw/tdemonitordevice.cpp
new file mode 100644
index 000000000..94b32f7b6
--- /dev/null
+++ b/tdecore/tdehw/tdemonitordevice.cpp
@@ -0,0 +1,78 @@
+/* This file is part of the TDE libraries
+ Copyright (C) 2012 Timothy Pearson <kb9vqf@pearsoncomputing.net>
+ (C) 2013 Golubev Alexander <fatzer2@gmail.com>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License version 2 as published by the Free Software Foundation.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "tdemonitordevice.h"
+
+#include "config.h"
+
+TDEMonitorDevice::TDEMonitorDevice(TDEGenericDeviceType::TDEGenericDeviceType dt, TQString dn) : TDEGenericDevice(dt, dn) {
+}
+
+TDEMonitorDevice::~TDEMonitorDevice() {
+}
+
+bool TDEMonitorDevice::connected() {
+ return m_connected;
+}
+
+void TDEMonitorDevice::internalSetConnected(bool cn) {
+ m_connected = cn;
+}
+
+bool TDEMonitorDevice::enabled() {
+ return m_enabled;
+}
+
+void TDEMonitorDevice::internalSetEnabled(bool en) {
+ m_enabled = en;
+}
+
+TQByteArray TDEMonitorDevice::edid() {
+ return m_edid;
+}
+
+void TDEMonitorDevice::internalSetEdid(TQByteArray ed) {
+ m_edid = ed;
+}
+
+TDEResolutionList TDEMonitorDevice::resolutions() {
+ return m_resolutions;
+}
+
+void TDEMonitorDevice::internalSetResolutions(TDEResolutionList rs) {
+ m_resolutions = rs;
+}
+
+TQString TDEMonitorDevice::portType() {
+ return m_portType;
+}
+
+void TDEMonitorDevice::internalSetPortType(TQString pt) {
+ m_portType = pt;
+}
+
+TDEDisplayPowerLevel::TDEDisplayPowerLevel TDEMonitorDevice::powerLevel() {
+ return m_powerLevel;
+}
+
+void TDEMonitorDevice::internalSetPowerLevel(TDEDisplayPowerLevel::TDEDisplayPowerLevel pl) {
+ m_powerLevel = pl;
+}
+
+#include "tdemonitordevice.moc"
diff --git a/tdecore/tdehw/tdemonitordevice.h b/tdecore/tdehw/tdemonitordevice.h
new file mode 100644
index 000000000..a4fd81f49
--- /dev/null
+++ b/tdecore/tdehw/tdemonitordevice.h
@@ -0,0 +1,122 @@
+/* This file is part of the TDE libraries
+ Copyright (C) 2012 Timothy Pearson <kb9vqf@pearsoncomputing.net>
+ (C) 2013 Golubev Alexander <fatzer2@gmail.com>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License version 2 as published by the Free Software Foundation.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef _TDEMONITORDEVICE_H
+#define _TDEMONITORDEVICE_H
+
+#include "tdegenericdevice.h"
+#include "tdehwcommontypes.h"
+
+typedef TQPair<unsigned int, unsigned int> TDEResolutionPair;
+typedef TQValueList< TDEResolutionPair > TDEResolutionList;
+
+class TDECORE_EXPORT TDEMonitorDevice : public TDEGenericDevice
+{
+ public:
+ /**
+ * Constructor.
+ * @param Device type
+ */
+ TDEMonitorDevice(TDEGenericDeviceType::TDEGenericDeviceType dt, TQString dn=TQString::null);
+
+ /**
+ * Destructor.
+ */
+ ~TDEMonitorDevice();
+
+ /**
+ * @return TRUE if a monitor is connected, FALSE if not
+ */
+ bool connected();
+
+ /**
+ * @return TRUE if this port is enabled, FALSE if not
+ */
+ bool enabled();
+
+ /**
+ * @return a TQByteArray containing this monitor's EDID information
+ */
+ TQByteArray edid();
+
+ /**
+ * @return a TDEResolutionList containing this monitor's supported resolutions
+ */
+ TDEResolutionList resolutions();
+
+ /**
+ * @return a TQString containing the display port type
+ */
+ TQString portType();
+
+ /**
+ * @return a TDEDisplayPowerLevel::TDEDisplayPowerLevel with the current power level
+ */
+ TDEDisplayPowerLevel::TDEDisplayPowerLevel powerLevel();
+
+ protected:
+ /**
+ * @param TRUE if a monitor is connected, FALSE if not
+ * @internal
+ */
+ void internalSetConnected(bool cn);
+
+ /**
+ * @param TRUE if this port is enabled, FALSE if not
+ * @internal
+ */
+ void internalSetEnabled(bool en);
+
+ /**
+ * @param ed a TQByteArray containing this monitor's EDID information
+ * @internal
+ */
+ void internalSetEdid(TQByteArray ed);
+
+ /**
+ * @param rs a TDEResolutionList containing this monitor's supported resolutions
+ * @internal
+ */
+ void internalSetResolutions(TDEResolutionList rs);
+
+ /**
+ * @param pt a TQString containing the display port type
+ * @internal
+ */
+ void internalSetPortType(TQString pt);
+
+ /**
+ * @param pl a TDEDisplayPowerLevel::TDEDisplayPowerLevel with the current power level
+ * @internal
+ */
+ void internalSetPowerLevel(TDEDisplayPowerLevel::TDEDisplayPowerLevel pl);
+
+ private:
+ bool m_connected;
+ bool m_enabled;
+ TQByteArray m_edid;
+ TDEResolutionList m_resolutions;
+ TQString m_portType;
+ TDEDisplayPowerLevel::TDEDisplayPowerLevel m_powerLevel;
+
+ friend class TDEHardwareDevices;
+};
+
+
+#endif // _TDEMONITORDEVICE_H
diff --git a/tdecore/tdehw/tdenetworkconnections.cpp b/tdecore/tdehw/tdenetworkconnections.cpp
index 6227b095f..934c8f602 100644
--- a/tdecore/tdehw/tdenetworkconnections.cpp
+++ b/tdecore/tdehw/tdenetworkconnections.cpp
@@ -19,21 +19,23 @@
#include "tdehardwaredevices.h"
#include "tdenetworkconnections.h"
-#include "config.h"
-
#include <tqtimer.h>
#include <tdelocale.h>
+#include "tdenetworkdevice.h"
// #define DEBUG_SIGNAL_QUEUE 1
+#include "config.h"
+
#ifdef WITH_NETWORK_MANAGER_BACKEND
-#include "networkbackends/network-manager/network-manager.h"
+#include "network-manager.h"
#endif // WITH_NETWORK_MANAGER_BACKEND
#define SET_BIT(x, y) (x |= 1 << y)
#define TEST_BIT(x, y) ((x & (1 << y)) >> y)
+
/*================================================================================================*/
/* TDENetworkSearchDomain */
/*================================================================================================*/
@@ -1103,4 +1105,4 @@ TDENetworkWiFiAPInfo* TDEGlobalNetworkManager::findAccessPointByBSSID(TDEMACAddr
/* End */
/*================================================================================================*/
-#include "tdenetworkconnections.moc" \ No newline at end of file
+#include "tdenetworkconnections.moc"
diff --git a/tdecore/tdehw/tdenetworkdevice.cpp b/tdecore/tdehw/tdenetworkdevice.cpp
new file mode 100644
index 000000000..f49eca9e6
--- /dev/null
+++ b/tdecore/tdehw/tdenetworkdevice.cpp
@@ -0,0 +1,188 @@
+/* This file is part of the TDE libraries
+ Copyright (C) 2012 Timothy Pearson <kb9vqf@pearsoncomputing.net>
+ (C) 2013 Golubev Alexander <fatzer2@gmail.com>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License version 2 as published by the Free Software Foundation.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "tdenetworkdevice.h"
+
+// Network connection manager
+#include "tdenetworkconnections.h"
+
+#include "config.h"
+
+#ifdef WITH_NETWORK_MANAGER_BACKEND
+ #include "network-manager.h"
+#endif // WITH_NETWORK_MANAGER_BACKEND
+
+
+TDENetworkDevice::TDENetworkDevice(TDEGenericDeviceType::TDEGenericDeviceType dt, TQString dn) : TDEGenericDevice(dt, dn) {
+ m_rxbytes = -1;
+ m_txbytes = -1;
+ m_rxpackets = -1;
+ m_txpackets = -1;
+ m_connectionManager = NULL;
+}
+
+TDENetworkDevice::~TDENetworkDevice() {
+ if (m_connectionManager) {
+ delete m_connectionManager;
+ }
+}
+
+TQString TDENetworkDevice::macAddress() {
+ return m_macAddress;
+}
+
+void TDENetworkDevice::internalSetMacAddress(TQString ma) {
+ m_macAddress = ma;
+}
+
+TQString TDENetworkDevice::state() {
+ return m_state;
+}
+
+void TDENetworkDevice::internalSetState(TQString st) {
+ m_state = st;
+}
+
+bool TDENetworkDevice::carrierPresent() {
+ return m_carrier;
+}
+
+void TDENetworkDevice::internalSetCarrierPresent(bool cp) {
+ m_carrier = cp;
+}
+
+bool TDENetworkDevice::dormant() {
+ return m_dormant;
+}
+
+void TDENetworkDevice::internalSetDormant(bool dm) {
+ m_dormant = dm;
+}
+
+TQString TDENetworkDevice::ipV4Address() {
+ return m_ipV4Address;
+}
+
+void TDENetworkDevice::internalSetIpV4Address(TQString ad) {
+ m_ipV4Address = ad;
+}
+
+TQString TDENetworkDevice::ipV6Address() {
+ return m_ipV6Address;
+}
+
+void TDENetworkDevice::internalSetIpV6Address(TQString ad) {
+ m_ipV6Address = ad;
+}
+
+TQString TDENetworkDevice::ipV4Netmask() {
+ return m_ipV4Netmask;
+}
+
+void TDENetworkDevice::internalSetIpV4Netmask(TQString nm) {
+ m_ipV4Netmask = nm;
+}
+
+TQString TDENetworkDevice::ipV6Netmask() {
+ return m_ipV6Netmask;
+}
+
+void TDENetworkDevice::internalSetIpV6Netmask(TQString nm) {
+ m_ipV6Netmask = nm;
+}
+
+TQString TDENetworkDevice::ipV4Broadcast() {
+ return m_ipV4Broadcast;
+}
+
+void TDENetworkDevice::internalSetIpV4Broadcast(TQString br) {
+ m_ipV4Broadcast = br;
+}
+
+TQString TDENetworkDevice::ipV6Broadcast() {
+ return m_ipV6Broadcast;
+}
+
+void TDENetworkDevice::internalSetIpV6Broadcast(TQString br) {
+ m_ipV6Broadcast = br;
+}
+
+TQString TDENetworkDevice::ipV4Destination() {
+ return m_ipV4Destination;
+}
+
+void TDENetworkDevice::internalSetIpV4Destination(TQString ds) {
+ m_ipV4Destination = ds;
+}
+
+TQString TDENetworkDevice::ipV6Destination() {
+ return m_ipV6Destination;
+}
+
+void TDENetworkDevice::internalSetIpV6Destination(TQString ds) {
+ m_ipV6Destination = ds;
+}
+
+double TDENetworkDevice::rxBytes() {
+ return m_rxbytes;
+}
+
+void TDENetworkDevice::internalSetRxBytes(double rx) {
+ m_rxbytes = rx;
+}
+
+double TDENetworkDevice::txBytes() {
+ return m_txbytes;
+}
+
+void TDENetworkDevice::internalSetTxBytes(double tx) {
+ m_txbytes = tx;
+}
+
+double TDENetworkDevice::rxPackets() {
+ return m_rxpackets;
+}
+
+void TDENetworkDevice::internalSetRxPackets(double rx) {
+ m_rxpackets = rx;
+}
+
+double TDENetworkDevice::txPackets() {
+ return m_txpackets;
+}
+
+void TDENetworkDevice::internalSetTxPackets(double tx) {
+ m_txpackets = tx;
+}
+
+TDENetworkConnectionManager* TDENetworkDevice::connectionManager() {
+#ifdef WITH_NETWORK_MANAGER_BACKEND
+ if (!m_connectionManager) {
+ m_connectionManager = new TDENetworkConnectionManager_BackendNM(m_macAddress);
+ }
+#endif // WITH_NETWORK_MANAGER_BACKEND
+
+ return m_connectionManager;
+}
+
+void TDENetworkDevice::internalSetConnectionManager(TDENetworkConnectionManager* mgr) {
+ m_connectionManager = mgr;
+}
+
+#include "tdenetworkdevice.moc"
diff --git a/tdecore/tdehw/tdenetworkdevice.h b/tdecore/tdehw/tdenetworkdevice.h
new file mode 100644
index 000000000..04cee1512
--- /dev/null
+++ b/tdecore/tdehw/tdenetworkdevice.h
@@ -0,0 +1,252 @@
+/* This file is part of the TDE libraries
+ Copyright (C) 2012 Timothy Pearson <kb9vqf@pearsoncomputing.net>
+ (C) 2013 Golubev Alexander <fatzer2@gmail.com>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License version 2 as published by the Free Software Foundation.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef _TDENETWORKDEVICE_H
+#define _TDENETWORKDEVICE_H
+
+#include "tdegenericdevice.h"
+
+#include "config.h"
+
+class TDENetworkConnectionManager;
+
+class TDECORE_EXPORT TDENetworkDevice : public TDEGenericDevice
+{
+ public:
+ /**
+ * Constructor.
+ * @param Device type
+ */
+ TDENetworkDevice(TDEGenericDeviceType::TDEGenericDeviceType dt, TQString dn=TQString::null);
+
+ /**
+ * Destructor.
+ */
+ ~TDENetworkDevice();
+
+ /**
+ * @return a TQString containing the network device's MAC address
+ */
+ TQString macAddress();
+
+ /**
+ * @return a TQString containing the network device's operational state
+ */
+ TQString state();
+
+ /**
+ * @return TRUE if carrier is present, FALSE if not
+ */
+ bool carrierPresent();
+
+ /**
+ * @return TRUE if device is dormant, FALSE if not
+ */
+ bool dormant();
+
+ /**
+ * @return a TQString containing the network device's IPv4 address
+ */
+ TQString ipV4Address();
+
+ /**
+ * @return a TQString containing the network device's IPv6 address
+ */
+ TQString ipV6Address();
+
+ /**
+ * @return a TQString containing the network device's IPv4 netmask
+ */
+ TQString ipV4Netmask();
+
+ /**
+ * @return a TQString containing the network device's IPv6 netmask
+ */
+ TQString ipV6Netmask();
+
+ /**
+ * @return a TQString containing the network device's IPv4 broadcast
+ */
+ TQString ipV4Broadcast();
+
+ /**
+ * @return a TQString containing the network device's IPv6 broadcast
+ */
+ TQString ipV6Broadcast();
+
+ /**
+ * @return a TQString containing the network device's IPv4 destination
+ */
+ TQString ipV4Destination();
+
+ /**
+ * @return a TQString containing the network device's IPv6 destination
+ */
+ TQString ipV6Destination();
+
+ /**
+ * @return a double with the number of received bytes, if available
+ */
+ double rxBytes();
+
+ /**
+ * @return a double with the number of transmitted bytes, if available
+ */
+ double txBytes();
+
+ /**
+ * @return a double with the number of received packets, if available
+ */
+ double rxPackets();
+
+ /**
+ * @return a double with the number of transmitted packets, if available
+ */
+ double txPackets();
+
+ /**
+ * @return a pointer to a TDENetworkConnectionManager object, if available
+ */
+ TDENetworkConnectionManager* connectionManager();
+
+ protected:
+ /**
+ * @param ma a TQString containing the network device's MAC address
+ * @internal
+ */
+ void internalSetMacAddress(TQString ma);
+
+ /**
+ * @param st a TQString containing the network device's operational state
+ * @internal
+ */
+ void internalSetState(TQString st);
+
+ /**
+ * @param TRUE if carrier is present, FALSE if not
+ * @internal
+ */
+ void internalSetCarrierPresent(bool cp);
+
+ /**
+ * @param TRUE if device is dormant, FALSE if not
+ * @internal
+ */
+ void internalSetDormant(bool dm);
+
+ /**
+ * @param ad a TQString containing the network device's IPv4 address
+ * @internal
+ */
+ void internalSetIpV4Address(TQString ad);
+
+ /**
+ * @param ad a TQString containing the network device's IPv6 address
+ * @internal
+ */
+ void internalSetIpV6Address(TQString ad);
+
+ /**
+ * @param nm a TQString containing the network device's IPv4 netmask
+ * @internal
+ */
+ void internalSetIpV4Netmask(TQString nm);
+
+ /**
+ * @param nm a TQString containing the network device's IPv6 netmask
+ * @internal
+ */
+ void internalSetIpV6Netmask(TQString nm);
+
+ /**
+ * @param br a TQString containing the network device's IPv4 broadcast
+ * @internal
+ */
+ void internalSetIpV4Broadcast(TQString br);
+
+ /**
+ * @param br a TQString containing the network device's IPv6 broadcast
+ * @internal
+ */
+ void internalSetIpV6Broadcast(TQString br);
+
+ /**
+ * @param ds a TQString containing the network device's IPv4 destination
+ * @internal
+ */
+ void internalSetIpV4Destination(TQString ds);
+
+ /**
+ * @param ds a TQString containing the network device's IPv6 destination
+ * @internal
+ */
+ void internalSetIpV6Destination(TQString ds);
+
+ /**
+ * @param rx a double with the number of received bytes, if available
+ * @internal
+ */
+ void internalSetRxBytes(double rx);
+
+ /**
+ * @param tx a double with the number of transmitted bytes, if available
+ * @internal
+ */
+ void internalSetTxBytes(double tx);
+
+ /**
+ * @param rx a double with the number of received packets, if available
+ * @internal
+ */
+ void internalSetRxPackets(double rx);
+
+ /**
+ * @param tx a double with the number of transmitted packets, if available
+ * @internal
+ */
+ void internalSetTxPackets(double tx);
+
+ /**
+ * @param mgr a pointer to a TDENetworkConnectionManager object, if available
+ */
+ void internalSetConnectionManager(TDENetworkConnectionManager* mgr);
+
+ private:
+ TQString m_macAddress;
+ TQString m_state;
+ bool m_carrier;
+ bool m_dormant;
+ TQString m_ipV4Address;
+ TQString m_ipV6Address;
+ TQString m_ipV4Netmask;
+ TQString m_ipV6Netmask;
+ TQString m_ipV4Broadcast;
+ TQString m_ipV6Broadcast;
+ TQString m_ipV4Destination;
+ TQString m_ipV6Destination;
+ double m_rxbytes;
+ double m_txbytes;
+ double m_rxpackets;
+ double m_txpackets;
+ TDENetworkConnectionManager* m_connectionManager;
+
+ friend class TDEHardwareDevices;
+};
+
+#endif // _TDENETWORKDEVICE_H
diff --git a/tdecore/tdehw/tderootsystemdevice.cpp b/tdecore/tdehw/tderootsystemdevice.cpp
new file mode 100644
index 000000000..4047df104
--- /dev/null
+++ b/tdecore/tdehw/tderootsystemdevice.cpp
@@ -0,0 +1,440 @@
+/* This file is part of the TDE libraries
+ Copyright (C) 2012 Timothy Pearson <kb9vqf@pearsoncomputing.net>
+ (C) 2013 Golubev Alexander <fatzer2@gmail.com>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License version 2 as published by the Free Software Foundation.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "tderootsystemdevice.h"
+
+#include <unistd.h>
+
+#include <tqfile.h>
+
+#include "tdeglobal.h"
+#include "tdeconfig.h"
+
+#include "config.h"
+
+#if defined(WITH_UPOWER) || defined(WITH_CONSOLEKIT)
+ #include <tqdbusdata.h>
+ #include <tqdbusmessage.h>
+ #include <tqdbusproxy.h>
+ #include <tqdbusvariant.h>
+ #include <tqdbusconnection.h>
+#endif // defined(WITH_UPOWER) || defined(WITH_CONSOLEKIT)
+
+TDERootSystemDevice::TDERootSystemDevice(TDEGenericDeviceType::TDEGenericDeviceType dt, TQString dn) : TDEGenericDevice(dt, dn) {
+ m_hibernationSpace = -1;
+}
+
+TDERootSystemDevice::~TDERootSystemDevice() {
+}
+
+TDESystemFormFactor::TDESystemFormFactor TDERootSystemDevice::formFactor() {
+ return m_formFactor;
+}
+
+void TDERootSystemDevice::internalSetFormFactor(TDESystemFormFactor::TDESystemFormFactor ff) {
+ m_formFactor = ff;
+}
+
+TDESystemPowerStateList TDERootSystemDevice::powerStates() {
+ return m_powerStates;
+}
+
+void TDERootSystemDevice::internalSetPowerStates(TDESystemPowerStateList ps) {
+ m_powerStates = ps;
+}
+
+TDESystemHibernationMethodList TDERootSystemDevice::hibernationMethods() {
+ return m_hibernationMethods;
+}
+
+void TDERootSystemDevice::internalSetHibernationMethods(TDESystemHibernationMethodList hm) {
+ m_hibernationMethods = hm;
+}
+
+TDESystemHibernationMethod::TDESystemHibernationMethod TDERootSystemDevice::hibernationMethod() {
+ return m_hibernationMethod;
+}
+
+void TDERootSystemDevice::internalSetHibernationMethod(TDESystemHibernationMethod::TDESystemHibernationMethod hm) {
+ m_hibernationMethod = hm;
+}
+
+unsigned long TDERootSystemDevice::diskSpaceNeededForHibernation() {
+ return m_hibernationSpace;
+}
+
+void TDERootSystemDevice::internalSetDiskSpaceNeededForHibernation(unsigned long sz) {
+ m_hibernationSpace = sz;
+}
+
+bool TDERootSystemDevice::canSetHibernationMethod() {
+ TQString hibernationnode = "/sys/power/disk";
+ int rval = access (hibernationnode.ascii(), W_OK);
+ if (rval == 0) {
+ return TRUE;
+ }
+ else {
+ return FALSE;
+ }
+}
+
+bool TDERootSystemDevice::canStandby() {
+ TQString statenode = "/sys/power/state";
+ int rval = access (statenode.ascii(), W_OK);
+ if (rval == 0) {
+ if (powerStates().contains(TDESystemPowerState::Standby)) {
+ return TRUE;
+ }
+ else {
+ return FALSE;
+ }
+ }
+ else {
+ return FALSE;
+ }
+}
+
+bool TDERootSystemDevice::canSuspend() {
+ TQString statenode = "/sys/power/state";
+ int rval = access (statenode.ascii(), W_OK);
+ if (rval == 0) {
+ if (powerStates().contains(TDESystemPowerState::Suspend)) {
+ return TRUE;
+ }
+ else {
+ return FALSE;
+ }
+ }
+ else {
+#ifdef WITH_UPOWER
+ TQT_DBusConnection dbusConn = TQT_DBusConnection::addConnection(TQT_DBusConnection::SystemBus);
+ if (dbusConn.isConnected()) {
+ TQT_DBusProxy upowerProperties("org.freedesktop.UPower", "/org/freedesktop/UPower", "org.freedesktop.DBus.Properties", dbusConn);
+ if (upowerProperties.canSend()) {
+ // can suspend?
+ TQValueList<TQT_DBusData> params;
+ params << TQT_DBusData::fromString(upowerProperties.interface()) << TQT_DBusData::fromString("CanSuspend");
+ TQT_DBusMessage reply = upowerProperties.sendWithReply("Get", params);
+ if (reply.type() == TQT_DBusMessage::ReplyMessage && reply.count() == 1) {
+ return reply[0].toVariant().value.toBool();
+ }
+ else {
+ return FALSE;
+ }
+ }
+ else {
+ return FALSE;
+ }
+ }
+ else {
+ return FALSE;
+ }
+#else // WITH_UPOWER
+ return FALSE;
+#endif// WITH_UPOWER
+ }
+}
+
+bool TDERootSystemDevice::canHibernate() {
+ TQString statenode = "/sys/power/state";
+ int rval = access (statenode.ascii(), W_OK);
+ if (rval == 0) {
+ if (powerStates().contains(TDESystemPowerState::Hibernate)) {
+ return TRUE;
+ }
+ else {
+ return FALSE;
+ }
+ }
+ else {
+#ifdef WITH_UPOWER
+ TQT_DBusConnection dbusConn = TQT_DBusConnection::addConnection(TQT_DBusConnection::SystemBus);
+ if (dbusConn.isConnected()) {
+ TQT_DBusProxy upowerProperties("org.freedesktop.UPower", "/org/freedesktop/UPower", "org.freedesktop.DBus.Properties", dbusConn);
+ if (upowerProperties.canSend()) {
+ // can hibernate?
+ TQValueList<TQT_DBusData> params;
+ params << TQT_DBusData::fromString(upowerProperties.interface()) << TQT_DBusData::fromString("CanHibernate");
+ TQT_DBusMessage reply = upowerProperties.sendWithReply("Get", params);
+ if (reply.type() == TQT_DBusMessage::ReplyMessage && reply.count() == 1) {
+ return reply[0].toVariant().value.toBool();
+ }
+ else {
+ return FALSE;
+ }
+ }
+ else {
+ return FALSE;
+ }
+ }
+ else {
+ return FALSE;
+ }
+#else // WITH_UPOWER
+ return FALSE;
+#endif// WITH_UPOWER
+ }
+}
+
+bool TDERootSystemDevice::canPowerOff() {
+ TDEConfig *config = TDEGlobal::config();
+ config->reparseConfiguration(); // config may have changed in the KControl module
+
+ config->setGroup("General" );
+ bool maysd = false;
+#ifdef WITH_CONSOLEKIT
+ if (config->readBoolEntry( "offerShutdown", true )) {
+ TQT_DBusConnection dbusConn = TQT_DBusConnection::addConnection(TQT_DBusConnection::SystemBus);
+ if (dbusConn.isConnected()) {
+ TQT_DBusProxy consoleKitManager("org.freedesktop.ConsoleKit", "/org/freedesktop/ConsoleKit/Manager", "org.freedesktop.ConsoleKit.Manager", dbusConn);
+ if (consoleKitManager.canSend()) {
+ // can power off?
+ TQValueList<TQT_DBusData> params;
+ TQT_DBusMessage reply = consoleKitManager.sendWithReply("CanStop", params);
+ if (reply.type() == TQT_DBusMessage::ReplyMessage && reply.count() == 1) {
+ maysd = reply[0].toBool();
+ }
+ else {
+ maysd = false;
+ }
+ }
+ else {
+ maysd = false;
+ }
+ }
+ else {
+ maysd = false;
+ }
+ }
+#else // WITH_CONSOLEKIT
+ // FIXME
+ // Can we power down this system?
+ // This should probably be checked via DCOP and therefore interface with KDM
+ if (config->readBoolEntry( "offerShutdown", true )/* && DM().canShutdown()*/) { // FIXME
+ maysd = true;
+ }
+#endif // WITH_CONSOLEKIT
+
+ return maysd;
+}
+
+bool TDERootSystemDevice::canReboot() {
+ TDEConfig *config = TDEGlobal::config();
+ config->reparseConfiguration(); // config may have changed in the KControl module
+
+ config->setGroup("General" );
+ bool mayrb = false;
+#ifdef WITH_CONSOLEKIT
+ if (config->readBoolEntry( "offerShutdown", true )) {
+ TQT_DBusConnection dbusConn = TQT_DBusConnection::addConnection(TQT_DBusConnection::SystemBus);
+ if (dbusConn.isConnected()) {
+ TQT_DBusProxy consoleKitManager("org.freedesktop.ConsoleKit", "/org/freedesktop/ConsoleKit/Manager", "org.freedesktop.ConsoleKit.Manager", dbusConn);
+ if (consoleKitManager.canSend()) {
+ // can reboot?
+ TQValueList<TQT_DBusData> params;
+ TQT_DBusMessage reply = consoleKitManager.sendWithReply("CanRestart", params);
+ if (reply.type() == TQT_DBusMessage::ReplyMessage && reply.count() == 1) {
+ mayrb = reply[0].toBool();
+ }
+ else {
+ mayrb = false;
+ }
+ }
+ else {
+ mayrb = false;
+ }
+ }
+ else {
+ mayrb = false;
+ }
+ }
+#else // WITH_CONSOLEKIT
+ // FIXME
+ // Can we power down this system?
+ // This should probably be checked via DCOP and therefore interface with KDM
+ if (config->readBoolEntry( "offerShutdown", true )/* && DM().canShutdown()*/) { // FIXME
+ mayrb = true;
+ }
+#endif // WITH_CONSOLEKIT
+
+ return mayrb;
+}
+
+void TDERootSystemDevice::setHibernationMethod(TDESystemHibernationMethod::TDESystemHibernationMethod hm) {
+ TQString hibernationnode = "/sys/power/disk";
+ TQFile file( hibernationnode );
+ if ( file.open( IO_WriteOnly ) ) {
+ TQString hibernationCommand;
+ if (hm == TDESystemHibernationMethod::Platform) {
+ hibernationCommand = "platform";
+ }
+ if (hm == TDESystemHibernationMethod::Shutdown) {
+ hibernationCommand = "shutdown";
+ }
+ if (hm == TDESystemHibernationMethod::Reboot) {
+ hibernationCommand = "reboot";
+ }
+ if (hm == TDESystemHibernationMethod::TestProc) {
+ hibernationCommand = "testproc";
+ }
+ if (hm == TDESystemHibernationMethod::Test) {
+ hibernationCommand = "test";
+ }
+ TQTextStream stream( &file );
+ stream << hibernationCommand;
+ file.close();
+ }
+}
+
+bool TDERootSystemDevice::setPowerState(TDESystemPowerState::TDESystemPowerState ps) {
+ if ((ps == TDESystemPowerState::Standby) || (ps == TDESystemPowerState::Suspend) || (ps == TDESystemPowerState::Hibernate)) {
+ TQString statenode = "/sys/power/state";
+ TQFile file( statenode );
+ if ( file.open( IO_WriteOnly ) ) {
+ TQString powerCommand;
+ if (ps == TDESystemPowerState::Standby) {
+ powerCommand = "standby";
+ }
+ if (ps == TDESystemPowerState::Suspend) {
+ powerCommand = "mem";
+ }
+ if (ps == TDESystemPowerState::Hibernate) {
+ powerCommand = "disk";
+ }
+ TQTextStream stream( &file );
+ stream << powerCommand;
+ file.close();
+ return true;
+ }
+ else {
+#ifdef WITH_UPOWER
+ TQT_DBusConnection dbusConn;
+ dbusConn = TQT_DBusConnection::addConnection(TQT_DBusConnection::SystemBus);
+ if ( dbusConn.isConnected() ) {
+ if (ps == TDESystemPowerState::Suspend) {
+ TQT_DBusMessage msg = TQT_DBusMessage::methodCall(
+ "org.freedesktop.UPower",
+ "/org/freedesktop/UPower",
+ "org.freedesktop.UPower",
+ "Suspend");
+ dbusConn.sendWithReply(msg);
+ return true;
+ }
+ else if (ps == TDESystemPowerState::Hibernate) {
+ TQT_DBusMessage msg = TQT_DBusMessage::methodCall(
+ "org.freedesktop.UPower",
+ "/org/freedesktop/UPower",
+ "org.freedesktop.UPower",
+ "Hibernate");
+ dbusConn.sendWithReply(msg);
+ return true;
+ }
+ else {
+ return false;
+ }
+ }
+ else {
+ return false;
+ }
+#else // WITH_UPOWER
+ return false;
+#endif // WITH_UPOWER
+ }
+ }
+ else if (ps == TDESystemPowerState::PowerOff) {
+#ifdef WITH_CONSOLEKIT
+ TDEConfig *config = TDEGlobal::config();
+ config->reparseConfiguration(); // config may have changed in the KControl module
+ config->setGroup("General" );
+ if (config->readBoolEntry( "offerShutdown", true )) {
+ TQT_DBusConnection dbusConn;
+ dbusConn = TQT_DBusConnection::addConnection(TQT_DBusConnection::SystemBus);
+ if ( dbusConn.isConnected() ) {
+ TQT_DBusMessage msg = TQT_DBusMessage::methodCall(
+ "org.freedesktop.ConsoleKit",
+ "/org/freedesktop/ConsoleKit/Manager",
+ "org.freedesktop.ConsoleKit.Manager",
+ "Stop");
+ dbusConn.sendWithReply(msg);
+ return true;
+ }
+ else {
+ return false;
+ }
+ }
+ else {
+ return false;
+ }
+#else // WITH_CONSOLEKIT
+ // Power down the system using a DCOP command
+ // Values are explained at http://lists.kde.org/?l=kde-linux&m=115770988603387
+ TQByteArray data;
+ TQDataStream arg(data, IO_WriteOnly);
+ arg << (int)0 << (int)2 << (int)2;
+ if ( kapp->dcopClient()->send("ksmserver", "default", "logout(int,int,int)", data) ) {
+ return true;
+ }
+ return false;
+#endif // WITH_CONSOLEKIT
+ }
+ else if (ps == TDESystemPowerState::Reboot) {
+#ifdef WITH_CONSOLEKIT
+ TDEConfig *config = TDEGlobal::config();
+ config->reparseConfiguration(); // config may have changed in the KControl module
+ config->setGroup("General" );
+ if (config->readBoolEntry( "offerShutdown", true )) {
+ TQT_DBusConnection dbusConn;
+ dbusConn = TQT_DBusConnection::addConnection(TQT_DBusConnection::SystemBus);
+ if ( dbusConn.isConnected() ) {
+ TQT_DBusMessage msg = TQT_DBusMessage::methodCall(
+ "org.freedesktop.ConsoleKit",
+ "/org/freedesktop/ConsoleKit/Manager",
+ "org.freedesktop.ConsoleKit.Manager",
+ "Restart");
+ dbusConn.sendWithReply(msg);
+ return true;
+ }
+ else {
+ return false;
+ }
+ }
+ else {
+ return false;
+ }
+#else // WITH_CONSOLEKIT
+ // Power down the system using a DCOP command
+ // Values are explained at http://lists.kde.org/?l=kde-linux&m=115770988603387
+ TQByteArray data;
+ TQDataStream arg(data, IO_WriteOnly);
+ arg << (int)0 << (int)1 << (int)2;
+ if ( kapp->dcopClient()->send("ksmserver", "default", "logout(int,int,int)", data) ) {
+ return true;
+ }
+ return false;
+#endif // WITH_CONSOLEKIT
+ }
+ else if (ps == TDESystemPowerState::Active) {
+ // Ummm...we're already active...
+ return true;
+ }
+
+ return false;
+}
+
+#include "tderootsystemdevice.moc"
diff --git a/tdecore/tdehw/tderootsystemdevice.h b/tdecore/tdehw/tderootsystemdevice.h
new file mode 100644
index 000000000..1c94fe1eb
--- /dev/null
+++ b/tdecore/tdehw/tderootsystemdevice.h
@@ -0,0 +1,182 @@
+/* This file is part of the TDE libraries
+ Copyright (C) 2012 Timothy Pearson <kb9vqf@pearsoncomputing.net>
+ (C) 2013 Golubev Alexander <fatzer2@gmail.com>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License version 2 as published by the Free Software Foundation.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef _TDEROOTSYSTEMDEVICE_H
+#define _TDEROOTSYSTEMDEVICE_H
+
+#include "tdegenericdevice.h"
+#include "tdehwcommontypes.h"
+
+namespace TDESystemFormFactor {
+enum TDESystemFormFactor {
+ Unclassified,
+ Desktop,
+ Laptop,
+ Server,
+ Other = 0x80000000
+};
+};
+
+namespace TDESystemPowerState {
+enum TDESystemPowerState {
+ Active,
+ Standby,
+ Suspend,
+ Hibernate,
+ PowerOff,
+ Reboot
+};
+};
+
+namespace TDESystemHibernationMethod {
+enum TDESystemHibernationMethod {
+ Unsupported,
+ Platform,
+ Shutdown,
+ Reboot,
+ TestProc,
+ Test
+};
+};
+
+typedef TQValueList<TDESystemPowerState::TDESystemPowerState> TDESystemPowerStateList;
+typedef TQValueList<TDESystemHibernationMethod::TDESystemHibernationMethod> TDESystemHibernationMethodList;
+
+class TDECORE_EXPORT TDERootSystemDevice : public TDEGenericDevice
+{
+ public:
+ /**
+ * Constructor.
+ * @param Device type
+ */
+ TDERootSystemDevice(TDEGenericDeviceType::TDEGenericDeviceType dt, TQString dn=TQString::null);
+
+ /**
+ * Destructor.
+ */
+ ~TDERootSystemDevice();
+
+ /**
+ * @return a TDESystemFormFactor::TDESystemFormFactor with the system's form factor
+ */
+ TDESystemFormFactor::TDESystemFormFactor formFactor();
+
+ /**
+ * @return a TDESystemPowerStateList with all available power states
+ */
+ TDESystemPowerStateList powerStates();
+
+ /**
+ * @return a TDESystemHibernationMethodList with all available hibernation methods
+ */
+ TDESystemHibernationMethodList hibernationMethods();
+
+ /**
+ * @return a TDESystemHibernationMethod::TDESystemHibernationMethod with the current hibernation method
+ */
+ TDESystemHibernationMethod::TDESystemHibernationMethod hibernationMethod();
+
+ /**
+ * @return an unsigned long with the number of bytes required to hibernate
+ */
+ unsigned long diskSpaceNeededForHibernation();
+
+ /**
+ * @return TRUE if permissions allow the hibernation method to be set, FALSE if not
+ */
+ bool canSetHibernationMethod();
+
+ /**
+ * @return TRUE if hardware and permissions allow the system to enter standby, FALSE if not
+ */
+ bool canStandby();
+
+ /**
+ * @return TRUE if hardware and permissions allow the system to be suspended, FALSE if not
+ */
+ bool canSuspend();
+
+ /**
+ * @return TRUE if hardware and permissions allow the system to be hibernated, FALSE if not
+ */
+ bool canHibernate();
+
+ /**
+ * @return TRUE if permissions allow the system to be powered down, FALSE if not
+ */
+ bool canPowerOff();
+
+ /**
+ * @return TRUE if permissions allow the system to be rebooted, FALSE if not
+ */
+ bool canReboot();
+
+ /**
+ * @param hm a TDESystemHibernationMethod::TDESystemHibernationMethod with the desired hibernation method
+ */
+ void setHibernationMethod(TDESystemHibernationMethod::TDESystemHibernationMethod hm);
+
+ /**
+ * @param ps a TDESystemPowerState::TDESystemPowerState with the desired power state
+ * @return TRUE if power state was set
+ */
+ bool setPowerState(TDESystemPowerState::TDESystemPowerState ps);
+
+ protected:
+ /**
+ * @param ff a TDESystemFormFactor::TDESystemFormFactor with the system's form factor
+ * @internal
+ */
+ void internalSetFormFactor(TDESystemFormFactor::TDESystemFormFactor ff);
+
+ /**
+ * @param ps a TDESystemPowerStateList with all available power states
+ * @internal
+ */
+ void internalSetPowerStates(TDESystemPowerStateList ps);
+
+ /**
+ * @param hm a TDESystemHibernationMethodList with all available hibernation methods
+ * @internal
+ */
+ void internalSetHibernationMethods(TDESystemHibernationMethodList hm);
+
+ /**
+ * @param hm a TDESystemHibernationMethod::TDESystemHibernationMethod with the current hibernation method
+ * @internal
+ */
+ void internalSetHibernationMethod(TDESystemHibernationMethod::TDESystemHibernationMethod hm);
+
+ /**
+ * @param sz an unsigned long with the number of bytes required to hibernate
+ * @internal
+ */
+ void internalSetDiskSpaceNeededForHibernation(unsigned long sz);
+
+ private:
+ TDESystemFormFactor::TDESystemFormFactor m_formFactor;
+ TDESystemPowerStateList m_powerStates;
+ TDESystemHibernationMethodList m_hibernationMethods;
+ TDESystemHibernationMethod::TDESystemHibernationMethod m_hibernationMethod;
+ unsigned long m_hibernationSpace;
+
+ friend class TDEHardwareDevices;
+};
+
+#endif // _TDEROOTSYSTEMDEVICE_H
diff --git a/tdecore/tdehw/tdesensordevice.cpp b/tdecore/tdehw/tdesensordevice.cpp
new file mode 100644
index 000000000..11c8b65bf
--- /dev/null
+++ b/tdecore/tdehw/tdesensordevice.cpp
@@ -0,0 +1,47 @@
+/* This file is part of the TDE libraries
+ Copyright (C) 2012 Timothy Pearson <kb9vqf@pearsoncomputing.net>
+ (C) 2013 Golubev Alexander <fatzer2@gmail.com>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License version 2 as published by the Free Software Foundation.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "tdesensordevice.h"
+
+#include "config.h"
+
+TDESensorCluster::TDESensorCluster() {
+ label = TQString::null;
+ current = -1;
+ minimum = -1;
+ maximum = -1;
+ warning = -1;
+ critical = -1;
+}
+
+TDESensorDevice::TDESensorDevice(TDEGenericDeviceType::TDEGenericDeviceType dt, TQString dn) : TDEGenericDevice(dt, dn) {
+}
+
+TDESensorDevice::~TDESensorDevice() {
+}
+
+TDESensorClusterMap TDESensorDevice::values() {
+ return m_sensorValues;
+}
+
+void TDESensorDevice::internalSetValues(TDESensorClusterMap cl) {
+ m_sensorValues = cl;
+}
+
+#include "tdesensordevice.moc"
diff --git a/tdecore/tdehw/tdesensordevice.h b/tdecore/tdehw/tdesensordevice.h
new file mode 100644
index 000000000..fb36ca589
--- /dev/null
+++ b/tdecore/tdehw/tdesensordevice.h
@@ -0,0 +1,75 @@
+/* This file is part of the TDE libraries
+ Copyright (C) 2012 Timothy Pearson <kb9vqf@pearsoncomputing.net>
+ (C) 2013 Golubev Alexander <fatzer2@gmail.com>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License version 2 as published by the Free Software Foundation.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef _TDESENSORDEVICE_H
+#define _TDESENSORDEVICE_H
+
+#include "tdegenericdevice.h"
+
+class TDECORE_EXPORT TDESensorCluster
+{
+ public:
+ /**
+ * Constructor.
+ */
+ TDESensorCluster();
+
+ TQString label;
+ double current;
+ double minimum;
+ double maximum;
+ double warning;
+ double critical;
+};
+
+typedef TQMap<TQString, TDESensorCluster> TDESensorClusterMap;
+
+class TDECORE_EXPORT TDESensorDevice : public TDEGenericDevice
+{
+ public:
+ /**
+ * Constructor.
+ * @param Device type
+ */
+ TDESensorDevice(TDEGenericDeviceType::TDEGenericDeviceType dt, TQString dn=TQString::null);
+
+ /**
+ * Destructor.
+ */
+ ~TDESensorDevice();
+
+ /**
+ * @return a TDESensorClusterMap with the current sensor values
+ */
+ TDESensorClusterMap values();
+
+ protected:
+ /**
+ * @param a TDESensorClusterMap with the current sensor values
+ * @internal
+ */
+ void internalSetValues(TDESensorClusterMap cl);
+
+ private:
+ TDESensorClusterMap m_sensorValues;
+
+ friend class TDEHardwareDevices;
+};
+
+#endif // _TDESENSORDEVICE_H
diff --git a/tdecore/tdehw/tdestoragedevice.cpp b/tdecore/tdehw/tdestoragedevice.cpp
index 8c3538ade..ac80b8856 100644
--- a/tdecore/tdehw/tdestoragedevice.cpp
+++ b/tdecore/tdehw/tdestoragedevice.cpp
@@ -21,25 +21,9 @@
#include <unistd.h>
#include <fcntl.h>
-
#include <sys/ioctl.h>
#include <linux/cdrom.h>
-// uDisks2 integration
-#if defined(WITH_UDISKS) || defined(WITH_UDISKS2)
- #include <tqdbusdata.h>
- #include <tqdbusmessage.h>
- #include <tqdbusproxy.h>
- #include <tqdbusvariant.h>
- #include <tqdbusconnection.h>
- #include <tqdbuserror.h>
- #include <tqdbusdatamap.h>
- #include <tqdbusobjectpath.h>
-#endif // defined(WITH_UDISKS) || defined(WITH_UDISKS2)
-#if defined(WITH_UDISKS)
- #include "tqdbusdatalist.h"
-#endif // ddefined(WITH_UDISKS)
-
#include <tqpixmap.h>
#include <tqfile.h>
@@ -50,6 +34,23 @@
#include "tdehardwaredevices.h"
+#include "config.h"
+
+// uDisks2 integration
+#if defined(WITH_UDISKS) || defined(WITH_UDISKS2)
+ #include <tqdbusdata.h>
+ #include <tqdbusmessage.h>
+ #include <tqdbusproxy.h>
+ #include <tqdbusvariant.h>
+ #include <tqdbusconnection.h>
+ #include <tqdbuserror.h>
+ #include <tqdbusdatamap.h>
+ #include <tqdbusobjectpath.h>
+#endif // defined(WITH_UDISKS) || defined(WITH_UDISKS2)
+#if defined(WITH_UDISKS)
+ #include "tqdbusdatalist.h"
+#endif // ddefined(WITH_UDISKS)
+
TDEStorageDevice::TDEStorageDevice(TDEGenericDeviceType::TDEGenericDeviceType dt, TQString dn) : TDEGenericDevice(dt, dn), m_mediaInserted(true) {
m_diskType = TDEDiskDeviceType::Null;
m_diskStatus = TDEDiskDeviceStatus::Null;