• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • tdecore
 

tdecore

  • tdecore
tdehardwaredevices.h
1 /* This file is part of the TDE libraries
2  Copyright (C) 2012 Timothy Pearson <kb9vqf@pearsoncomputing.net>
3 
4  This library is free software; you can redistribute it and/or
5  modify it under the terms of the GNU Library General Public
6  License version 2 as published by the Free Software Foundation.
7 
8  This library is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11  Library General Public License for more details.
12 
13  You should have received a copy of the GNU Library General Public License
14  along with this library; see the file COPYING.LIB. If not, write to
15  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16  Boston, MA 02110-1301, USA.
17 */
18 #ifndef _TDEHARDWAREDEVICES_H
19 #define _TDEHARDWAREDEVICES_H
20 
21 // TDE includes
22 #include <tqobject.h>
23 #include <tqstring.h>
24 #include <tqptrlist.h>
25 #include <tqstringlist.h>
26 #include "kiconloader.h"
27 #include "tdelibs_export.h"
28 
29 // udev includes
30 #include <libudev.h>
31 #include <stdio.h>
32 #include <stdlib.h>
33 #include <locale.h>
34 #include <unistd.h>
35 
42 class TDENetworkConnectionManager;
43 
44 namespace TDEHardwareEvent {
45 enum TDEHardwareEvent {
46  HardwareListModified,
47  MountTableModified,
48  HardwareAdded,
49  HardwareRemoved,
50  HardwareUpdated,
51  Other,
52  Last = Other
53 };
54 };
55 
56 // Keep readGenericDeviceTypeFromString(), getFriendlyDeviceTypeStringFromType(), and getDeviceTypeIconFromType() in tdehardwaredevices.cpp in sync with this enum
57 namespace TDEGenericDeviceType {
58 enum TDEGenericDeviceType {
59  Root,
60  RootSystem,
61  CPU,
62  GPU,
63  RAM,
64  Bus,
65  I2C,
66  MDIO,
67  Mainboard,
68  Disk,
69  SCSI,
70  StorageController,
71  Mouse,
72  Keyboard,
73  HID,
74  Modem,
75  Monitor,
76  Network,
77  Printer,
78  Scanner,
79  Sound,
80  VideoCapture,
81  IEEE1394,
82  PCMCIA,
83  Camera,
84  TextIO,
85  Serial,
86  Parallel,
87  Peripheral,
88  Backlight,
89  Battery,
90  PowerSupply,
91  Dock,
92  ThermalSensor,
93  ThermalControl,
94  BlueTooth,
95  Bridge,
96  Platform,
97  Cryptography,
98  Event,
99  Input,
100  PNP,
101  OtherACPI,
102  OtherUSB,
103  OtherMultimedia,
104  OtherPeripheral,
105  OtherSensor,
106  OtherVirtual,
107  Other,
108  Last = Other
109 };
110 };
111 
112 // Keep readDiskDeviceSubtypeFromString() in tdehardwaredevices.cpp in sync with this enum
113 namespace TDEDiskDeviceType {
114 enum TDEDiskDeviceType {
115  Null = 0x00000000,
116  MediaDevice = 0x00000001,
117  Floppy = 0x00000002,
118  CDROM = 0x00000004,
119  CDRW = 0x00000008,
120  DVDROM = 0x00000010,
121  DVDRAM = 0x00000020,
122  DVDRW = 0x00000040,
123  BDROM = 0x00000080,
124  BDRW = 0x00000100,
125  Zip = 0x00000200,
126  Jaz = 0x00000400,
127  Camera = 0x00000800,
128  LUKS = 0x00001000,
129  OtherCrypted = 0x00002000,
130  CDAudio = 0x00004000,
131  CDVideo = 0x00008000,
132  DVDVideo = 0x00010000,
133  BDVideo = 0x00020000,
134  Flash = 0x00040000,
135  USB = 0x00080000,
136  Tape = 0x00100000,
137  HDD = 0x00200000,
138  Optical = 0x00400000,
139  RAM = 0x00800000,
140  Loop = 0x01000000,
141  CompactFlash = 0x02000000,
142  MemoryStick = 0x04000000,
143  SmartMedia = 0x08000000,
144  SDMMC = 0x10000000,
145  UnlockedCrypt = 0x20000000,
146  Other = 0x80000000
147 };
148 
149 inline TDEDiskDeviceType operator|(TDEDiskDeviceType a, TDEDiskDeviceType b)
150 {
151  return static_cast<TDEDiskDeviceType>(static_cast<int>(a) | static_cast<int>(b));
152 }
153 
154 inline TDEDiskDeviceType operator&(TDEDiskDeviceType a, TDEDiskDeviceType b)
155 {
156  return static_cast<TDEDiskDeviceType>(static_cast<int>(a) & static_cast<int>(b));
157 }
158 
159 inline TDEDiskDeviceType operator~(TDEDiskDeviceType a)
160 {
161  return static_cast<TDEDiskDeviceType>(~static_cast<int>(a));
162 }
163 };
164 
165 namespace TDEDiskDeviceStatus {
166 enum TDEDiskDeviceStatus {
167  Null = 0x00000000,
168  Mountable = 0x00000001,
169  Removable = 0x00000002,
170  Inserted = 0x00000004,
171  Blank = 0x00000008,
172  UsedByDevice = 0x00000010,
173  UsesDevice = 0x00000020,
174  ContainsFilesystem = 0x00000040,
175  Hotpluggable = 0x00000080,
176  Other = 0x80000000
177 };
178 
179 inline TDEDiskDeviceStatus operator|(TDEDiskDeviceStatus a, TDEDiskDeviceStatus b)
180 {
181  return static_cast<TDEDiskDeviceStatus>(static_cast<int>(a) | static_cast<int>(b));
182 }
183 
184 inline TDEDiskDeviceStatus operator&(TDEDiskDeviceStatus a, TDEDiskDeviceStatus b)
185 {
186  return static_cast<TDEDiskDeviceStatus>(static_cast<int>(a) & static_cast<int>(b));
187 }
188 
189 inline TDEDiskDeviceStatus operator~(TDEDiskDeviceStatus a)
190 {
191  return static_cast<TDEDiskDeviceStatus>(~static_cast<int>(a));
192 }
193 };
194 
195 class TDECORE_EXPORT TDESensorCluster
196 {
197  public:
201  TDESensorCluster();
202 
203  TQString label;
204  double current;
205  double minimum;
206  double maximum;
207  double warning;
208  double critical;
209 };
210 
211 class TDECORE_EXPORT TDEGenericDevice : public TQObject
212 {
213  Q_OBJECT
214 
215  public:
220  TDEGenericDevice(TDEGenericDeviceType::TDEGenericDeviceType dt, TQString dn=TQString::null);
221 
225  ~TDEGenericDevice();
226 
230  TDEGenericDeviceType::TDEGenericDeviceType type();
231 
235  TQString name();
236 
240  TQString vendorName();
241 
245  TQString vendorModel();
246 
250  TQString serialNumber();
251 
258  virtual TQString friendlyName();
259 
263  TQString deviceBus();
264 
270  TQString systemPath();
271 
277  TQString deviceNode();
278 
282  bool blacklistedForUpdate();
283 
287  TQString uniqueID();
288 
292  TQString vendorID();
293 
297  TQString modelID();
298 
302  TQString vendorEncoded();
303 
307  TQString modelEncoded();
308 
312  TQString subVendorID();
313 
317  TQString subModelID();
318 
322  TQString PCIClass();
323 
327  TQString moduleAlias();
328 
332  TQString deviceDriver();
333 
337  TQString subsystem();
338 
342  TDEGenericDevice* parentDevice();
343 
347  virtual TQString friendlyDeviceType();
348 
352  TQString busID();
353 
359  virtual TQPixmap icon(TDEIcon::StdSizes size);
360 
361  protected:
366  void internalSetName(TQString dn);
367 
372  void internalSetVendorName(TQString vn);
373 
378  void internalSetVendorModel(TQString vm);
379 
384  void internalSetSerialNumber(TQString sn);
385 
390  void internalSetDeviceBus(TQString db);
391 
398  void internalSetSystemPath(TQString sp);
399 
406  void internalSetDeviceNode(TQString sn);
407 
412  void internalSetBlacklistedForUpdate(bool bl);
413 
418  void internalSetVendorID(TQString id);
419 
424  void internalSetModelID(TQString id);
425 
430  void internalSetVendorEncoded(TQString id);
431 
436  void internalSetModelEncoded(TQString id);
437 
442  void internalSetSubVendorID(TQString id);
443 
448  void internalSetSubModelID(TQString id);
449 
454  void internalSetPCIClass(TQString cl);
455 
460  void internalSetModuleAlias(TQString ma);
461 
466  void internalSetDeviceDriver(TQString dr);
467 
472  void internalSetSubsystem(TQString ss);
473 
478  void internalSetParentDevice(TDEGenericDevice* pd);
479 
480  private:
481  TDEGenericDeviceType::TDEGenericDeviceType m_deviceType;
482  TQString m_deviceName;
483  TQString m_systemPath;
484  TQString m_deviceNode;
485  TQString m_vendorName;
486  TQString m_vendorModel;
487  TQString m_serialNumber;
488  TQString m_deviceBus;
489  TQString m_uniqueID;
490  TQString m_vendorID;
491  TQString m_modelID;
492  TQString m_vendorenc;
493  TQString m_modelenc;
494  TQString m_subvendorID;
495  TQString m_submodelID;
496  TQString m_pciClass;
497  TQString m_modAlias;
498  TQString m_deviceDriver;
499  TQString m_subsystem;
500  TQString m_friendlyName;
501  bool m_blacklistedForUpdate;
502  TDEGenericDevice* m_parentDevice;
503 
504  // Internal use only!
505  TQStringList m_externalSubtype;
506  TQString m_externalRulesFile;
507  TQString m_udevtype;
508  TQString m_udevdevicetypestring;
509  TQString udevdevicetypestring_alt;
510 
511  friend class TDEHardwareDevices;
512 };
513 
514 class TDECORE_EXPORT TDEStorageDevice : public TDEGenericDevice
515 {
516  public:
521  TDEStorageDevice(TDEGenericDeviceType::TDEGenericDeviceType dt, TQString dn=TQString::null);
522 
526  ~TDEStorageDevice();
527 
531  TQString diskLabel();
532 
536  TQString diskUUID();
537 
541  TDEDiskDeviceType::TDEDiskDeviceType diskType();
542 
546  TDEDiskDeviceStatus::TDEDiskDeviceStatus diskStatus();
547 
551  bool mediaInserted();
552 
556  TQString fileSystemName();
557 
561  TQString fileSystemUsage();
562 
566  TQStringList holdingDevices();
567 
571  TQStringList slaveDevices();
572 
583  TQString mountDevice(TQString mediaName=TQString::null, TQString mountOptions=TQString::null, TQString* errRet=0, int* retcode=0);
584 
596  TQString mountEncryptedDevice(TQString passphrase, TQString mediaName=TQString::null, TQString mountOptions=TQString::null, TQString* errRet=0, int* retcode=0);
597 
606  bool unmountDevice(TQString* errRet, int* retcode=0);
607 
611  TQString mountPath();
612 
616  unsigned long long deviceSize();
617 
621  TQString deviceFriendlySize();
622 
630  TQPixmap icon(TDEIcon::StdSizes size);
631 
637  TQString friendlyName();
638 
644  TQString friendlyDeviceType();
645 
649  bool isDiskOfType(TDEDiskDeviceType::TDEDiskDeviceType tf);
650 
654  bool checkDiskStatus(TDEDiskDeviceStatus::TDEDiskDeviceStatus sf);
655 
662  bool lockDriveMedia(bool lock);
663 
669  bool ejectDriveMedia();
670 
676  bool ejectDrive();
677 
678  protected:
683  void internalSetDiskLabel(TQString dn);
684 
689  void internalSetDiskUUID(TQString id);
690 
695  void internalSetDiskType(TDEDiskDeviceType::TDEDiskDeviceType tf);
696 
701  void internalSetDiskStatus(TDEDiskDeviceStatus::TDEDiskDeviceStatus st);
702 
707  void internalSetMediaInserted(bool inserted);
708 
713  void internalSetFileSystemName(TQString fn);
714 
719  void internalSetFileSystemUsage(TQString fu);
720 
725  void internalSetHoldingDevices(TQStringList hd);
726 
731  void internalSetSlaveDevices(TQStringList sd);
732 
733  private:
734  TDEDiskDeviceType::TDEDiskDeviceType m_diskType;
735  TDEDiskDeviceStatus::TDEDiskDeviceStatus m_diskStatus;
736  TQString m_diskName;
737  TQString m_diskUUID;
738  TQString m_fileSystemName;
739  TQString m_fileSystemUsage;
740  bool m_mediaInserted;
741  TQString m_mountPath;
742  TQStringList m_holdingDevices;
743  TQStringList m_slaveDevices;
744 
745  friend class TDEHardwareDevices;
746 };
747 
748 class TDECORE_EXPORT TDECPUDevice : public TDEGenericDevice
749 {
750  public:
755  TDECPUDevice(TDEGenericDeviceType::TDEGenericDeviceType dt, TQString dn=TQString::null);
756 
760  ~TDECPUDevice();
761 
765  double frequency();
766 
770  double minFrequency();
771 
775  double maxFrequency();
776 
780  double transitionLatency();
781 
785  TQString governor();
786 
790  TQString scalingDriver();
791 
795  TQStringList dependentProcessors();
796 
800  TQStringList availableFrequencies();
801 
805  TQStringList availableGovernors();
806 
810  bool canSetGovernor();
811 
815  void setGovernor(TQString gv);
816 
820  bool canSetMaximumScalingFrequency();
821 
825  void setMaximumScalingFrequency(double fr);
826 
830  int coreNumber();
831 
832  protected:
837  void internalSetFrequency(double fr);
838 
843  void internalSetMinFrequency(double fr);
844 
849  void internalSetMaxFrequency(double fr);
850 
855  void internalSetTransitionLatency(double tl);
856 
861  void internalSetGovernor(TQString gr);
862 
867  void internalSetScalingDriver(TQString dr);
868 
873  void internalSetDependentProcessors(TQStringList dp);
874 
879  void internalSetAvailableFrequencies(TQStringList af);
880 
885  void internalSetAvailableGovernors(TQStringList gp);
886 
891  void internalSetCoreNumber(int cn);
892 
893  private:
894  double m_frequency;
895  double m_minfrequency;
896  double m_maxfrequency;
897  double m_transitionlatency;
898  TQString m_governor;
899  TQString m_scalingdriver;
900  TQStringList m_tiedprocs;
901  TQStringList m_frequencies;
902  TQStringList m_governers;
903  int m_corenumber;
904 
905  friend class TDEHardwareDevices;
906 };
907 
908 namespace TDEBatteryStatus {
909 enum TDEBatteryStatus {
910  Charging,
911  Discharging,
912  Full,
913  Unknown = 0x80000000
914 };
915 };
916 
917 class TDECORE_EXPORT TDEBatteryDevice : public TDEGenericDevice
918 {
919  public:
924  TDEBatteryDevice(TDEGenericDeviceType::TDEGenericDeviceType dt, TQString dn=TQString::null);
925 
929  ~TDEBatteryDevice();
930 
934  double voltage();
935 
939  double minimumVoltage();
940 
944  double maximumVoltage();
945 
949  double maximumDesignVoltage();
950 
954  double energy();
955 
959  double alarmEnergy();
960 
964  double maximumEnergy();
965 
969  double maximumDesignEnergy();
970 
974  double dischargeRate();
975 
979  double timeRemaining();
980 
984  TQString technology();
985 
989  TDEBatteryStatus::TDEBatteryStatus status();
990 
994  bool installed();
995 
999  double chargePercent();
1000 
1001  protected:
1006  void internalSetVoltage(double vt);
1007 
1012  void internalSetMinimumVoltage(double vt);
1013 
1018  void internalSetMaximumVoltage(double vt);
1019 
1024  void internalSetMaximumDesignVoltage(double vt);
1025 
1030  void internalSetEnergy(double vt);
1031 
1036  void internalSetAlarmEnergy(double vt);
1037 
1042  void internalSetMaximumEnergy(double vt);
1043 
1048  void internalSetMaximumDesignEnergy(double vt);
1049 
1054  void internalSetDischargeRate(double vt);
1055 
1060  void internalSetTimeRemaining(double tr);
1061 
1066  void internalSetTechnology(TQString tc);
1067 
1072  void internalSetStatus(TQString tc);
1073 
1078  void internalSetInstalled(bool tc);
1079 
1080  private:
1081  double m_currentVoltage;
1082  double m_minimumVoltage;
1083  double m_maximumVoltage;
1084  double m_maximumDesignVoltage;
1085  double m_alarmEnergy;
1086  double m_currentEnergy;
1087  double m_maximumEnergy;
1088  double m_maximumDesignEnergy;
1089  double m_dischargeRate;
1090  double m_timeRemaining;
1091  TQString m_technology;
1092  TDEBatteryStatus::TDEBatteryStatus m_status;
1093  bool m_installed;
1094 
1095  friend class TDEHardwareDevices;
1096 };
1097 
1098 class TDECORE_EXPORT TDEMainsPowerDevice : public TDEGenericDevice
1099 {
1100  public:
1105  TDEMainsPowerDevice(TDEGenericDeviceType::TDEGenericDeviceType dt, TQString dn=TQString::null);
1106 
1110  ~TDEMainsPowerDevice();
1111 
1115  bool online();
1116 
1117  protected:
1122  void internalSetOnline(bool vt);
1123 
1124  private:
1125  bool m_online;
1126 
1127  friend class TDEHardwareDevices;
1128 };
1129 
1130 class TDECORE_EXPORT TDENetworkDevice : public TDEGenericDevice
1131 {
1132  public:
1137  TDENetworkDevice(TDEGenericDeviceType::TDEGenericDeviceType dt, TQString dn=TQString::null);
1138 
1142  ~TDENetworkDevice();
1143 
1147  TQString macAddress();
1148 
1152  TQString state();
1153 
1157  bool carrierPresent();
1158 
1162  bool dormant();
1163 
1167  TQString ipV4Address();
1168 
1172  TQString ipV6Address();
1173 
1177  TQString ipV4Netmask();
1178 
1182  TQString ipV6Netmask();
1183 
1187  TQString ipV4Broadcast();
1188 
1192  TQString ipV6Broadcast();
1193 
1197  TQString ipV4Destination();
1198 
1202  TQString ipV6Destination();
1203 
1207  double rxBytes();
1208 
1212  double txBytes();
1213 
1217  double rxPackets();
1218 
1222  double txPackets();
1223 
1227  TDENetworkConnectionManager* connectionManager();
1228 
1229  protected:
1234  void internalSetMacAddress(TQString ma);
1235 
1240  void internalSetState(TQString st);
1241 
1246  void internalSetCarrierPresent(bool cp);
1247 
1252  void internalSetDormant(bool dm);
1253 
1258  void internalSetIpV4Address(TQString ad);
1259 
1264  void internalSetIpV6Address(TQString ad);
1265 
1270  void internalSetIpV4Netmask(TQString nm);
1271 
1276  void internalSetIpV6Netmask(TQString nm);
1277 
1282  void internalSetIpV4Broadcast(TQString br);
1283 
1288  void internalSetIpV6Broadcast(TQString br);
1289 
1294  void internalSetIpV4Destination(TQString ds);
1295 
1300  void internalSetIpV6Destination(TQString ds);
1301 
1306  void internalSetRxBytes(double rx);
1307 
1312  void internalSetTxBytes(double tx);
1313 
1318  void internalSetRxPackets(double rx);
1319 
1324  void internalSetTxPackets(double tx);
1325 
1329  void internalSetConnectionManager(TDENetworkConnectionManager* mgr);
1330 
1331  private:
1332  TQString m_macAddress;
1333  TQString m_state;
1334  bool m_carrier;
1335  bool m_dormant;
1336  TQString m_ipV4Address;
1337  TQString m_ipV6Address;
1338  TQString m_ipV4Netmask;
1339  TQString m_ipV6Netmask;
1340  TQString m_ipV4Broadcast;
1341  TQString m_ipV6Broadcast;
1342  TQString m_ipV4Destination;
1343  TQString m_ipV6Destination;
1344  double m_rxbytes;
1345  double m_txbytes;
1346  double m_rxpackets;
1347  double m_txpackets;
1348  TDENetworkConnectionManager* m_connectionManager;
1349 
1350  friend class TDEHardwareDevices;
1351 };
1352 
1353 namespace TDEDisplayPowerLevel {
1354 enum TDEDisplayPowerLevel {
1355  On,
1356  Standby,
1357  Suspend,
1358  Off
1359 };
1360 };
1361 
1362 class TDECORE_EXPORT TDEBacklightDevice : public TDEGenericDevice
1363 {
1364  public:
1369  TDEBacklightDevice(TDEGenericDeviceType::TDEGenericDeviceType dt, TQString dn=TQString::null);
1370 
1374  ~TDEBacklightDevice();
1375 
1379  TDEDisplayPowerLevel::TDEDisplayPowerLevel powerLevel();
1380 
1384  int brightnessSteps();
1385 
1389  double brightnessPercent();
1390 
1394  bool canSetBrightness();
1395 
1399  int rawBrightness();
1400 
1404  void setRawBrightness(int br);
1405 
1406  protected:
1411  void internalSetPowerLevel(TDEDisplayPowerLevel::TDEDisplayPowerLevel pl);
1412 
1417  void internalSetMaximumRawBrightness(int br);
1418 
1423  void internalSetCurrentRawBrightness(int br);
1424 
1425  private:
1426  TDEDisplayPowerLevel::TDEDisplayPowerLevel m_powerLevel;
1427  int m_currentBrightness;
1428  int m_maximumBrightness;
1429 
1430  friend class TDEHardwareDevices;
1431 };
1432 
1433 typedef TQPair<unsigned int, unsigned int> TDEResolutionPair;
1434 typedef TQValueList< TDEResolutionPair > TDEResolutionList;
1435 
1436 class TDECORE_EXPORT TDEMonitorDevice : public TDEGenericDevice
1437 {
1438  public:
1443  TDEMonitorDevice(TDEGenericDeviceType::TDEGenericDeviceType dt, TQString dn=TQString::null);
1444 
1448  ~TDEMonitorDevice();
1449 
1453  bool connected();
1454 
1458  bool enabled();
1459 
1463  TQByteArray edid();
1464 
1468  TDEResolutionList resolutions();
1469 
1473  TQString portType();
1474 
1478  TDEDisplayPowerLevel::TDEDisplayPowerLevel powerLevel();
1479 
1480  protected:
1485  void internalSetConnected(bool cn);
1486 
1491  void internalSetEnabled(bool en);
1492 
1497  void internalSetEdid(TQByteArray ed);
1498 
1503  void internalSetResolutions(TDEResolutionList rs);
1504 
1509  void internalSetPortType(TQString pt);
1510 
1515  void internalSetPowerLevel(TDEDisplayPowerLevel::TDEDisplayPowerLevel pl);
1516 
1517  private:
1518  bool m_connected;
1519  bool m_enabled;
1520  TQByteArray m_edid;
1521  TDEResolutionList m_resolutions;
1522  TQString m_portType;
1523  TDEDisplayPowerLevel::TDEDisplayPowerLevel m_powerLevel;
1524 
1525  friend class TDEHardwareDevices;
1526 };
1527 
1528 
1529 typedef TQMap<TQString, TDESensorCluster> TDESensorClusterMap;
1530 
1531 class TDECORE_EXPORT TDESensorDevice : public TDEGenericDevice
1532 {
1533  public:
1538  TDESensorDevice(TDEGenericDeviceType::TDEGenericDeviceType dt, TQString dn=TQString::null);
1539 
1543  ~TDESensorDevice();
1544 
1548  TDESensorClusterMap values();
1549 
1550  protected:
1555  void internalSetValues(TDESensorClusterMap cl);
1556 
1557  private:
1558  TDESensorClusterMap m_sensorValues;
1559 
1560  friend class TDEHardwareDevices;
1561 };
1562 
1563 namespace TDESystemFormFactor {
1564 enum TDESystemFormFactor {
1565  Unclassified,
1566  Desktop,
1567  Laptop,
1568  Server,
1569  Other = 0x80000000
1570 };
1571 };
1572 
1573 namespace TDESystemPowerState {
1574 enum TDESystemPowerState {
1575  Active,
1576  Standby,
1577  Suspend,
1578  Hibernate,
1579  PowerOff,
1580  Reboot
1581 };
1582 };
1583 
1584 namespace TDESystemHibernationMethod {
1585 enum TDESystemHibernationMethod {
1586  Unsupported,
1587  Platform,
1588  Shutdown,
1589  Reboot,
1590  TestProc,
1591  Test
1592 };
1593 };
1594 
1595 typedef TQValueList<TDESystemPowerState::TDESystemPowerState> TDESystemPowerStateList;
1596 typedef TQValueList<TDESystemHibernationMethod::TDESystemHibernationMethod> TDESystemHibernationMethodList;
1597 
1598 class TDECORE_EXPORT TDERootSystemDevice : public TDEGenericDevice
1599 {
1600  public:
1605  TDERootSystemDevice(TDEGenericDeviceType::TDEGenericDeviceType dt, TQString dn=TQString::null);
1606 
1610  ~TDERootSystemDevice();
1611 
1615  TDESystemFormFactor::TDESystemFormFactor formFactor();
1616 
1620  TDESystemPowerStateList powerStates();
1621 
1625  TDESystemHibernationMethodList hibernationMethods();
1626 
1630  TDESystemHibernationMethod::TDESystemHibernationMethod hibernationMethod();
1631 
1635  unsigned long diskSpaceNeededForHibernation();
1636 
1640  bool canSetHibernationMethod();
1641 
1645  bool canStandby();
1646 
1650  bool canSuspend();
1651 
1655  bool canHibernate();
1656 
1660  bool canPowerOff();
1661 
1665  bool canReboot();
1666 
1670  void setHibernationMethod(TDESystemHibernationMethod::TDESystemHibernationMethod hm);
1671 
1676  bool setPowerState(TDESystemPowerState::TDESystemPowerState ps);
1677 
1678  protected:
1683  void internalSetFormFactor(TDESystemFormFactor::TDESystemFormFactor ff);
1684 
1689  void internalSetPowerStates(TDESystemPowerStateList ps);
1690 
1695  void internalSetHibernationMethods(TDESystemHibernationMethodList hm);
1696 
1701  void internalSetHibernationMethod(TDESystemHibernationMethod::TDESystemHibernationMethod hm);
1702 
1707  void internalSetDiskSpaceNeededForHibernation(unsigned long sz);
1708 
1709  private:
1710  TDESystemFormFactor::TDESystemFormFactor m_formFactor;
1711  TDESystemPowerStateList m_powerStates;
1712  TDESystemHibernationMethodList m_hibernationMethods;
1713  TDESystemHibernationMethod::TDESystemHibernationMethod m_hibernationMethod;
1714  unsigned long m_hibernationSpace;
1715 
1716  friend class TDEHardwareDevices;
1717 };
1718 
1719 namespace TDEEventDeviceType {
1720 enum TDEEventDeviceType {
1721  Unknown,
1722  ACPILidSwitch,
1723  ACPISleepButton,
1724  ACPIPowerButton,
1725  Other = 0x80000000
1726 };
1727 };
1728 
1729 // Keep friendlySwitchList() in tdehardwaredevices.cpp in sync with this enum
1730 namespace TDESwitchType {
1731 enum TDESwitchType {
1732  Null = 0x00000000,
1733  Lid = 0x00000001,
1734  TabletMode = 0x00000002,
1735  HeadphoneInsert = 0x00000004,
1736  RFKill = 0x00000008,
1737  Radio = 0x00000010,
1738  MicrophoneInsert = 0x00000020,
1739  Dock = 0x00000040,
1740  LineOutInsert = 0x00000080,
1741  JackPhysicalInsert = 0x00000100,
1742  VideoOutInsert = 0x00000200,
1743  CameraLensCover = 0x00000400,
1744  KeypadSlide = 0x00000800,
1745  FrontProximity = 0x00001000,
1746  RotateLock = 0x00002000,
1747  LineInInsert = 0x00004000
1748 };
1749 
1750 inline TDESwitchType operator|(TDESwitchType a, TDESwitchType b)
1751 {
1752  return static_cast<TDESwitchType>(static_cast<int>(a) | static_cast<int>(b));
1753 }
1754 
1755 inline TDESwitchType operator&(TDESwitchType a, TDESwitchType b)
1756 {
1757  return static_cast<TDESwitchType>(static_cast<int>(a) & static_cast<int>(b));
1758 }
1759 
1760 inline TDESwitchType operator~(TDESwitchType a)
1761 {
1762  return static_cast<TDESwitchType>(~static_cast<int>(a));
1763 }
1764 };
1765 
1766 class TQSocketNotifier;
1767 
1768 class TDECORE_EXPORT TDEEventDevice : public TDEGenericDevice
1769 {
1770  Q_OBJECT
1771 
1772  public:
1777  TDEEventDevice(TDEGenericDeviceType::TDEGenericDeviceType dt, TQString dn=TQString::null);
1778 
1782  ~TDEEventDevice();
1783 
1787  TDEEventDeviceType::TDEEventDeviceType eventType();
1788 
1792  TDESwitchType::TDESwitchType providedSwitches();
1793 
1797  TDESwitchType::TDESwitchType activeSwitches();
1798 
1803  static TQStringList friendlySwitchList(TDESwitchType::TDESwitchType switches);
1804 
1805  protected:
1810  void internalSetEventType(TDEEventDeviceType::TDEEventDeviceType et);
1811 
1816  void internalSetProvidedSwitches(TDESwitchType::TDESwitchType sl);
1817 
1822  void internalSetActiveSwitches(TDESwitchType::TDESwitchType sl);
1823 
1828  void internalStartFdMonitoring(TDEHardwareDevices* hwmanager);
1829 
1830  protected slots:
1831  void eventReceived();
1832 
1833  signals:
1839  void keyPressed(unsigned int keycode, TDEEventDevice* device);
1840 
1841  private:
1842  TDEEventDeviceType::TDEEventDeviceType m_eventType;
1843  TDESwitchType::TDESwitchType m_providedSwitches;
1844  TDESwitchType::TDESwitchType m_switchActive;
1845 
1846  int m_fd;
1847  bool m_fdMonitorActive;
1848  TQSocketNotifier* m_eventNotifier;
1849 
1850  friend class TDEHardwareDevices;
1851 };
1852 
1853 namespace TDEInputDeviceType {
1854 enum TDEInputDeviceType {
1855  Unknown,
1856  ACPILidSwitch,
1857  ACPISleepButton,
1858  ACPIPowerButton,
1859  Other = 0x80000000
1860 };
1861 };
1862 
1863 class TDECORE_EXPORT TDEInputDevice : public TDEGenericDevice
1864 {
1865  public:
1870  TDEInputDevice(TDEGenericDeviceType::TDEGenericDeviceType dt, TQString dn=TQString::null);
1871 
1875  ~TDEInputDevice();
1876 
1880  TDEInputDeviceType::TDEInputDeviceType inputType();
1881 
1882  protected:
1887  void internalSetInputType(TDEInputDeviceType::TDEInputDeviceType it);
1888 
1889  private:
1890  TDEInputDeviceType::TDEInputDeviceType m_inputType;
1891 
1892  friend class TDEHardwareDevices;
1893 };
1894 
1895 typedef TQPtrList<TDEGenericDevice> TDEGenericHardwareList;
1896 typedef TQMap<TQString, TQString> TDEDeviceIDMap;
1897 
1898 class KSimpleDirWatch;
1899 
1900 class TDECORE_EXPORT TDEHardwareDevices : public TQObject
1901 {
1902  Q_OBJECT
1903 
1904  public:
1908  TDEHardwareDevices();
1909 
1913  ~TDEHardwareDevices();
1914 
1925  bool queryHardwareInformation();
1926 
1931  TDEGenericHardwareList listAllPhysicalDevices();
1932 
1938  TDEGenericHardwareList listByDeviceClass(TDEGenericDeviceType::TDEGenericDeviceType cl);
1939 
1944  TDEGenericDevice* findBySystemPath(TQString syspath);
1945 
1950  TDEGenericDevice* findByUniqueID(TQString uid);
1951 
1956  TDEGenericDevice* findByDeviceNode(TQString devnode);
1957 
1962  TDEStorageDevice* findDiskByUID(TQString uid);
1963 
1972  TQString findPCIDeviceName(TQString vendorid, TQString modelid, TQString subvendorid, TQString submodelid);
1973 
1982  TQString findUSBDeviceName(TQString vendorid, TQString modelid, TQString subvendorid, TQString submodelid);
1983 
1989  TQString findPNPDeviceName(TQString pnpid);
1990 
1996  TQString findMonitorManufacturerName(TQString dpyid);
1997 
2003  TQString getFriendlyDeviceTypeStringFromType(TDEGenericDeviceType::TDEGenericDeviceType query);
2004 
2011  TQPixmap getDeviceTypeIconFromType(TDEGenericDeviceType::TDEGenericDeviceType query, TDEIcon::StdSizes size);
2012 
2017  TDERootSystemDevice* rootSystemDevice();
2018 
2024  void rescanDeviceInformation(TDEGenericDevice* hwdevice);
2025 
2031  static TQString bytesToFriendlySizeString(double bytes);
2032 
2033  signals:
2034  void hardwareAdded(TDEGenericDevice*);
2035  void hardwareRemoved(TDEGenericDevice*);
2036  void hardwareUpdated(TDEGenericDevice*);
2037  void mountTableModified();
2038  void hardwareEvent(TDEHardwareEvent::TDEHardwareEvent, TQString uuid);
2039 
2045  void eventDeviceKeyPressed(unsigned int keycode, TDEEventDevice* device);
2046 
2047  private slots:
2048  void processHotPluggedHardware();
2049  void processModifiedMounts();
2050  void processModifiedCPUs();
2051  void processStatelessDevices();
2052  void processEventDeviceKeyPressed(unsigned int keycode, TDEEventDevice* edevice);
2053 
2054  private:
2055  void updateBlacklists(TDEGenericDevice* hwdevice, udev_device* dev);
2056 
2057  private:
2058  TDEGenericDevice *classifyUnknownDevice(udev_device* dev, TDEGenericDevice* existingdevice=0, bool force_full_classification=true);
2059  TDEGenericDevice *classifyUnknownDeviceByExternalRules(udev_device* dev, TDEGenericDevice* existingdevice=0, bool classifySubDevices=false);
2060 
2061  void updateParentDeviceInformation();
2062  void updateParentDeviceInformation(TDEGenericDevice* hwdevice);
2063 
2064  void addCoreSystemDevices();
2065 
2070  TQByteArray getEDID(TQString path);
2071 
2076  TQPair<TQString,TQString> getEDIDMonitorName(TQString path);
2077 
2078  struct udev *m_udevStruct;
2079  struct udev_monitor *m_udevMonitorStruct;
2080  TDEGenericHardwareList m_deviceList;
2081  int m_procMountsFd;
2082  KSimpleDirWatch* m_cpuWatch;
2083  TQTimer* m_cpuWatchTimer;
2084  TQTimer* m_deviceWatchTimer;
2085 
2086  TQSocketNotifier* m_devScanNotifier;
2087  TQSocketNotifier* m_mountScanNotifier;
2088 
2089  TQStringList m_mountTable;
2090  TQStringList m_cpuInfo;
2091 
2092  TDEDeviceIDMap* pci_id_map;
2093  TDEDeviceIDMap* usb_id_map;
2094  TDEDeviceIDMap* pnp_id_map;
2095  TDEDeviceIDMap* dpy_id_map;
2096 
2097  friend class TDEGenericDevice;
2098  friend class TDEStorageDevice;
2099  friend class TDECPUDevice;
2100 };
2101 
2102 #endif // _TDEHARDWAREDEVICES_H

tdecore

Skip menu "tdecore"
  • Main Page
  • Modules
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

tdecore

Skip menu "tdecore"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • knewstuff
  • libtdemid
  • libtdescreensaver
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdeioslave
  •   http
  • tdemdi
  •   tdemdi
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tdecore by doxygen 1.8.3.1
This website is maintained by Timothy Pearson.