summaryrefslogtreecommitdiffstats
path: root/tdecore/tdehardwaredevices.h
diff options
context:
space:
mode:
Diffstat (limited to 'tdecore/tdehardwaredevices.h')
-rw-r--r--tdecore/tdehardwaredevices.h235
1 files changed, 232 insertions, 3 deletions
diff --git a/tdecore/tdehardwaredevices.h b/tdecore/tdehardwaredevices.h
index d80b86432..e56217cbe 100644
--- a/tdecore/tdehardwaredevices.h
+++ b/tdecore/tdehardwaredevices.h
@@ -21,6 +21,7 @@
// TDE includes
#include <tqstring.h>
#include <tqptrlist.h>
+#include <tqtimer.h>
#include "tdelibs_export.h"
// udev includes
@@ -42,13 +43,17 @@ enum TDEGenericDeviceType {
GPU,
RAM,
Mainboard,
- FixedDisk,
- RemovableDisk,
+ Disk,
StorageController,
+ Mouse,
+ Keyboard,
HID,
Network,
Printer,
Scanner,
+ Sound,
+ IEEE1394,
+ Camera,
TextIO,
Peripheral,
Battery,
@@ -63,6 +68,80 @@ enum TDEGenericDeviceType {
};
};
+namespace TDEDiskDeviceType {
+enum TDEDiskDeviceType {
+ Floppy = 0x00000002,
+ CDROM = 0x00000004,
+ CDRW = 0x00000008,
+ DVDROM = 0x00000010,
+ DVDRAM = 0x00000020,
+ DVDRW = 0x00000040,
+ BDROM = 0x00000080,
+ BDRW = 0x00000100,
+ Zip = 0x00000200,
+ Jaz = 0x00000400,
+ Camera = 0x00000800,
+ LUKS = 0x00001000,
+ OtherCrypted = 0x00002000,
+ CDAudio = 0x00004000,
+ CDVideo = 0x00008000,
+ DVDVideo = 0x00010000,
+ BDVideo = 0x00020000,
+ Flash = 0x00040000,
+ USB = 0x00080000,
+ Tape = 0x00100000,
+ HDD = 0x00200000,
+ Optical = 0x00400000,
+ RAM = 0x00800000,
+ Loop = 0x01000000,
+ CompactFlash = 0x02000000,
+ MemoryStick = 0x04000000,
+ SmartMedia = 0x08000000,
+ SDMMC = 0x10000000,
+ Other = 0x80000000
+};
+
+inline TDEDiskDeviceType operator|(TDEDiskDeviceType a, TDEDiskDeviceType b)
+{
+ return static_cast<TDEDiskDeviceType>(static_cast<int>(a) | static_cast<int>(b));
+}
+
+inline TDEDiskDeviceType operator&(TDEDiskDeviceType a, TDEDiskDeviceType b)
+{
+ return static_cast<TDEDiskDeviceType>(static_cast<int>(a) & static_cast<int>(b));
+}
+
+inline TDEDiskDeviceType operator~(TDEDiskDeviceType a)
+{
+ return static_cast<TDEDiskDeviceType>(~static_cast<int>(a));
+}
+};
+
+namespace TDEDiskDeviceStatus {
+enum TDEDiskDeviceStatus {
+ Mountable = 0x00000001,
+ Removable = 0x00000002,
+ Inserted = 0x00000004,
+ Blank = 0x00000008,
+ Other = 0x80000000
+};
+
+inline TDEDiskDeviceStatus operator|(TDEDiskDeviceStatus a, TDEDiskDeviceStatus b)
+{
+ return static_cast<TDEDiskDeviceStatus>(static_cast<int>(a) | static_cast<int>(b));
+}
+
+inline TDEDiskDeviceStatus operator&(TDEDiskDeviceStatus a, TDEDiskDeviceStatus b)
+{
+ return static_cast<TDEDiskDeviceStatus>(static_cast<int>(a) & static_cast<int>(b));
+}
+
+inline TDEDiskDeviceStatus operator~(TDEDiskDeviceStatus a)
+{
+ return static_cast<TDEDiskDeviceStatus>(~static_cast<int>(a));
+}
+};
+
class TDECORE_EXPORT TDEGenericDevice
{
public:
@@ -93,6 +172,36 @@ class TDECORE_EXPORT TDEGenericDevice
void setName(TQString dn);
/**
+ * @return a TQString with the vendor name, if any
+ */
+ TQString &vendorName();
+
+ /**
+ * @param a TQString with the vendor name, if any
+ */
+ void setVendorName(TQString vn);
+
+ /**
+ * @return a TQString with the vendor model, if any
+ */
+ TQString &vendorModel();
+
+ /**
+ * @param a TQString with the vendor model, if any
+ */
+ void setVendorModel(TQString vm);
+
+ /**
+ * @return a TQString with the device bus name, if any
+ */
+ TQString &deviceBus();
+
+ /**
+ * @param a TQString with the device bus name, if any
+ */
+ void setDeviceBus(TQString db);
+
+ /**
* @return a TQString with the system path, if any
*
* This method is non-portable, so be careful!
@@ -125,12 +234,117 @@ class TDECORE_EXPORT TDEGenericDevice
TQString m_deviceName;
TQString m_systemPath;
TQString m_deviceNode;
+ TQString m_vendorName;
+ TQString m_vendorModel;
+ TQString m_deviceBus;
+};
+
+class TDECORE_EXPORT TDEStorageDevice : public TDEGenericDevice
+{
+ public:
+ /**
+ * Constructor.
+ * @param Device type
+ */
+ TDEStorageDevice(TDEGenericDeviceType::TDEGenericDeviceType dt, TQString dn=TQString::null);
+
+ /**
+ * Destructor.
+ */
+ ~TDEStorageDevice();
+
+ /**
+ * @return a TQString with the disk or partition label, if any
+ */
+ TQString &diskLabel();
+
+ /**
+ * @param a TQString with the disk or partition label, if any
+ */
+ void setDiskLabel(TQString dn);
+
+ /**
+ * @return a TQString with the disk UUID, if any
+ */
+ TQString &diskUUID();
+
+ /**
+ * @param a TQString with the disk UUID, if any
+ */
+ void setDiskUUID(TQString id);
+
+ /**
+ * @return an OR-ed combination of TDEDiskDeviceType::TDEDiskDeviceType type flags
+ */
+ TDEDiskDeviceType::TDEDiskDeviceType diskType();
+
+ /**
+ * @param an OR-ed combination of TDEDiskDeviceType::TDEDiskDeviceType type flags
+ */
+ void setDiskType(TDEDiskDeviceType::TDEDiskDeviceType tf);
+
+ /**
+ * @return an OR-ed combination of TDEDiskDeviceStatus::TDEDiskDeviceStatus type flags
+ */
+ TDEDiskDeviceStatus::TDEDiskDeviceStatus diskStatus();
+
+ /**
+ * @param an OR-ed combination of TDEDiskDeviceStatus::TDEDiskDeviceStatus type flags
+ */
+ void setDiskStatus(TDEDiskDeviceStatus::TDEDiskDeviceStatus st);
+
+ /**
+ * @return true if media inserted, false if no media available
+ */
+ bool mediaInserted();
+
+ /**
+ * @param a bool with the media status
+ */
+ void setMediaInserted(bool inserted);
+
+ /**
+ * @return a TQString with the filesystem name, if any
+ */
+ TQString &fileSystemName();
+
+ /**
+ * @param a TQString with the filesystem name, if any
+ */
+ void setFileSystemName(TQString fn);
+
+ /**
+ * @return a TQString with the filesystem usage string, if any
+ */
+ TQString &fileSystemUsage();
+
+ /**
+ * @param a TQString with the filesystem usage string, if any
+ */
+ void setFileSystemUsage(TQString fu);
+
+ /**
+ * @return a TQString with the mount path, if mounted
+ */
+ TQString mountPath();
+
+ private:
+ TDEDiskDeviceType::TDEDiskDeviceType m_diskType;
+ TDEDiskDeviceStatus::TDEDiskDeviceStatus m_diskStatus;
+ TQString m_diskName;
+ TQString m_diskUUID;
+ TQString m_fileSystemName;
+ TQString m_fileSystemUsage;
+ bool m_mediaInserted;
+ TQString m_mountPath;
};
typedef TQPtrList<TDEGenericDevice> TDEGenericHardwareList;
-class TDECORE_EXPORT TDEHardwareDevices
+class TDECORE_EXPORT TDEHardwareDevices : TQObject
{
+ Q_OBJECT
+
public:
/**
* Constructor.
@@ -160,9 +374,24 @@ class TDECORE_EXPORT TDEHardwareDevices
*/
TQPtrList<TDEGenericDevice> &listAllPhysicalDevices();
+ signals:
+ void hardwareAdded(TDEGenericDevice);
+ void hardwareRemoved(TDEGenericDevice);
+ void mountTableModified();
+
+ private slots:
+ void checkForHotPluggedHardware();
+ void checkForModifiedMounts();
+
private:
+ TDEGenericDevice *classifyUnknownDevice(udev_device* dev);
+
struct udev *m_udevStruct;
+ struct udev_monitor *m_udevMonitorStruct;
TDEGenericHardwareList m_deviceList;
+
+ TQTimer* m_devScanTimer;
+ TQTimer* m_mountScanTimer;
};
#endif \ No newline at end of file