tdehardwaredevices.h
00001 /* This file is part of the TDE libraries 00002 Copyright (C) 2012-2014 Timothy Pearson <kb9vqf@pearsoncomputing.net> 00003 00004 This library is free software; you can redistribute it and/or 00005 modify it under the terms of the GNU Library General Public 00006 License version 2 as published by the Free Software Foundation. 00007 00008 This library is distributed in the hope that it will be useful, 00009 but WITHOUT ANY WARRANTY; without even the implied warranty of 00010 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00011 Library General Public License for more details. 00012 00013 You should have received a copy of the GNU Library General Public License 00014 along with this library; see the file COPYING.LIB. If not, write to 00015 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00016 Boston, MA 02110-1301, USA. 00017 */ 00018 #ifndef _TDEHARDWAREDEVICES_H 00019 #define _TDEHARDWAREDEVICES_H 00020 00021 00022 // TDE includes 00023 #include <tqobject.h> 00024 #include <tqptrlist.h> 00025 #include <tqmap.h> 00026 #include <tqdict.h> 00027 #include <tqstring.h> 00028 #include <tqstringlist.h> 00029 00030 #include "tdelibs_export.h" 00031 #include "kicontheme.h" 00032 00033 #include "tdehwcommontypes.h" 00034 00035 // FIXME delete those headers after complete fixing everything in over modules 00036 #include "tdegenericdevice.h" 00037 #include "kiconloader.h" 00038 extern "C" { 00039 #include <libudev.h> 00040 } 00041 #include <stdio.h> 00042 #include <stdlib.h> 00043 #include <locale.h> 00044 #include <unistd.h> 00045 #include "tdestoragedevice.h" 00046 #include "tdecpudevice.h" 00047 #include "tdebatterydevice.h" 00048 #include "tdemainspowerdevice.h" 00049 #include "tdenetworkdevice.h" 00050 #include "tdebacklightdevice.h" 00051 #include "tdemonitordevice.h" 00052 #include "tdesensordevice.h" 00053 #include "tderootsystemdevice.h" 00054 #include "tdeeventdevice.h" 00055 #include "tdeinputdevice.h" 00056 #include "tdecryptographiccarddevice.h" 00057 00063 struct udev_device; 00064 00065 class KSimpleDirWatch; 00066 00067 class TDEGenericDevice; 00068 class TDEStorageDevice; 00069 class TDENetworkDevice; 00070 class TDEBacklightDevice; 00071 class TDEMonitorDevice; 00072 class TDESensorDevice; 00073 class TDERootSystemDevice; 00074 class TDEEventDevice; 00075 class TDEInputDevice; 00076 class TQSocketNotifier; 00077 00078 typedef TQPtrList<TDEGenericDevice> TDEGenericHardwareList; 00079 typedef TQMap<TQString, TQString> TDEDeviceIDMap; 00080 typedef TQDict<TDECPUDevice> TDECPUDeviceCache; 00081 00082 class TDECORE_EXPORT TDEHardwareDevices : public TQObject 00083 { 00084 Q_OBJECT 00085 00086 public: 00090 TDEHardwareDevices(); 00091 00095 ~TDEHardwareDevices(); 00096 00107 bool queryHardwareInformation(); 00108 00113 TDEGenericHardwareList listAllPhysicalDevices(); 00114 00120 TDEGenericHardwareList listByDeviceClass(TDEGenericDeviceType::TDEGenericDeviceType cl); 00121 00126 TDEGenericDevice* findBySystemPath(TQString syspath); 00127 00132 TDEGenericDevice* findByUniqueID(TQString uid); 00133 00138 TDEGenericDevice* findByDeviceNode(TQString devnode); 00139 00144 TDEStorageDevice* findDiskByUID(TQString uid); 00145 00150 TDECPUDevice* findCPUBySystemPath(TQString syspath, bool inCache); 00151 00160 TQString findPCIDeviceName(TQString vendorid, TQString modelid, TQString subvendorid, TQString submodelid); 00161 00170 TQString findUSBDeviceName(TQString vendorid, TQString modelid, TQString subvendorid, TQString submodelid); 00171 00177 TQString findPNPDeviceName(TQString pnpid); 00178 00184 TQString findMonitorManufacturerName(TQString dpyid); 00185 00191 TQString getFriendlyDeviceTypeStringFromType(TDEGenericDeviceType::TDEGenericDeviceType query); 00192 00199 TQPixmap getDeviceTypeIconFromType(TDEGenericDeviceType::TDEGenericDeviceType query, TDEIcon::StdSizes size); 00200 00205 TDERootSystemDevice* rootSystemDevice(); 00206 00212 void rescanDeviceInformation(TDEGenericDevice* hwdevice); 00213 00222 void rescanDeviceInformation(TDEGenericDevice* hwdevice, bool regenerateDeviceTree); 00223 00231 void setTriggerlessHardwareUpdatesEnabled(bool enable); 00232 00240 void setBatteryUpdatesEnabled(bool enable); 00241 00247 static TQString bytesToFriendlySizeString(double bytes); 00248 00249 signals: 00250 void hardwareAdded(TDEGenericDevice*); 00251 void hardwareRemoved(TDEGenericDevice*); 00252 void hardwareUpdated(TDEGenericDevice*); 00253 void mountTableModified(); 00254 void hardwareEvent(TDEHardwareEvent::TDEHardwareEvent, TQString uuid); 00255 00261 void eventDeviceKeyPressed(unsigned int keycode, TDEEventDevice* device); 00262 00263 private slots: 00264 void processHotPluggedHardware(); 00265 void processModifiedMounts(); 00266 void processModifiedCPUs(); 00267 void processBatteryDevices(); 00268 void processStatelessDevices(); 00269 void processEventDeviceKeyPressed(unsigned int keycode, TDEEventDevice* edevice); 00270 00271 private: 00272 void updateBlacklists(TDEGenericDevice* hwdevice, udev_device* dev); 00273 00274 private: 00275 TDEGenericDevice *classifyUnknownDevice(udev_device* dev, TDEGenericDevice* existingdevice=0, bool force_full_classification=true); 00276 TDEGenericDevice *classifyUnknownDeviceByExternalRules(udev_device* dev, TDEGenericDevice* existingdevice=0, bool classifySubDevices=false); 00277 void updateExistingDeviceInformation(TDEGenericDevice* existingdevice, udev_device* dev=NULL); 00278 00279 void updateParentDeviceInformation(); 00280 void updateParentDeviceInformation(TDEGenericDevice* hwdevice); 00281 00282 void addCoreSystemDevices(); 00283 00288 TQByteArray getEDID(TQString path); 00289 00294 TQPair<TQString,TQString> getEDIDMonitorName(TQString path); 00295 00296 struct udev *m_udevStruct; 00297 struct udev_monitor *m_udevMonitorStruct; 00298 TDEGenericHardwareList m_deviceList; 00299 int m_procMountsFd; 00300 KSimpleDirWatch* m_cpuWatch; 00301 TQTimer* m_cpuWatchTimer; 00302 TQTimer* m_batteryWatchTimer; 00303 TQTimer* m_deviceWatchTimer; 00304 00305 TQSocketNotifier* m_devScanNotifier; 00306 TQSocketNotifier* m_mountScanNotifier; 00307 00308 TQStringList m_mountTable; 00309 TQStringList m_cpuInfo; 00310 00311 TDEDeviceIDMap* pci_id_map; 00312 TDEDeviceIDMap* usb_id_map; 00313 TDEDeviceIDMap* pnp_id_map; 00314 TDEDeviceIDMap* dpy_id_map; 00315 00316 TDECPUDeviceCache m_cpuByPathCache; 00317 00318 friend class TDEGenericDevice; 00319 friend class TDEStorageDevice; 00320 friend class TDECPUDevice; 00321 }; 00322 00323 #endif // _TDEHARDWAREDEVICES_H
Trinity API Reference