diff options
Diffstat (limited to 'tdecore/tdehw/tdehardwaredevices.h')
-rw-r--r-- | tdecore/tdehw/tdehardwaredevices.h | 832 |
1 files changed, 31 insertions, 801 deletions
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 |