20 #include "tdegenericdevice.h"
24 #include "tdeglobal.h"
27 #include "tdehardwaredevices.h"
31 TDEGenericDevice::TDEGenericDevice(TDEGenericDeviceType::TDEGenericDeviceType dt, TQString dn) : TQObject() {
36 m_friendlyName = TQString::null;
37 m_blacklistedForUpdate =
false;
40 TDEGenericDevice::~TDEGenericDevice() {
43 TDEGenericDeviceType::TDEGenericDeviceType TDEGenericDevice::type() {
47 TQString TDEGenericDevice::name() {
51 void TDEGenericDevice::internalSetName(TQString dn) {
55 TQString TDEGenericDevice::vendorName() {
59 void TDEGenericDevice::internalSetVendorName(TQString vn) {
63 TQString TDEGenericDevice::vendorModel() {
67 void TDEGenericDevice::internalSetVendorModel(TQString vm) {
71 TQString TDEGenericDevice::serialNumber() {
72 return m_serialNumber;
75 void TDEGenericDevice::internalSetSerialNumber(TQString sn) {
79 TQString TDEGenericDevice::systemPath() {
80 if (!m_systemPath.endsWith(
"/")) {
86 void TDEGenericDevice::internalSetSystemPath(TQString sp) {
90 TQString TDEGenericDevice::deviceNode() {
94 void TDEGenericDevice::internalSetDeviceNode(TQString dn) {
98 TQString TDEGenericDevice::deviceBus() {
102 void TDEGenericDevice::internalSetDeviceBus(TQString db) {
106 TQString TDEGenericDevice::uniqueID() {
107 m_uniqueID = m_systemPath+m_deviceNode;
111 TQString TDEGenericDevice::vendorID() {
115 void TDEGenericDevice::internalSetVendorID(TQString
id) {
117 m_vendorID.replace(
"0x",
"");
120 TQString TDEGenericDevice::modelID() {
124 void TDEGenericDevice::internalSetModelID(TQString
id) {
126 m_modelID.replace(
"0x",
"");
129 TQString TDEGenericDevice::vendorEncoded() {
133 void TDEGenericDevice::internalSetVendorEncoded(TQString
id) {
137 TQString TDEGenericDevice::modelEncoded() {
141 void TDEGenericDevice::internalSetModelEncoded(TQString
id) {
145 TQString TDEGenericDevice::subVendorID() {
146 return m_subvendorID;
149 void TDEGenericDevice::internalSetSubVendorID(TQString
id) {
151 m_subvendorID.replace(
"0x",
"");
154 TQString TDEGenericDevice::PCIClass() {
158 void TDEGenericDevice::internalSetPCIClass(TQString cl) {
160 m_pciClass.replace(
"0x",
"");
163 TQString TDEGenericDevice::moduleAlias() {
167 void TDEGenericDevice::internalSetModuleAlias(TQString ma) {
171 TQString TDEGenericDevice::deviceDriver() {
172 return m_deviceDriver;
175 void TDEGenericDevice::internalSetDeviceDriver(TQString dr) {
179 TQString TDEGenericDevice::subsystem() {
183 void TDEGenericDevice::internalSetSubsystem(TQString ss) {
187 TQString TDEGenericDevice::subModelID() {
191 void TDEGenericDevice::internalSetSubModelID(TQString
id) {
193 m_submodelID.replace(
"0x",
"");
196 void TDEGenericDevice::internalSetParentDevice(TDEGenericDevice* pd) {
200 TDEGenericDevice* TDEGenericDevice::parentDevice() {
201 return m_parentDevice;
205 return TDEGlobal::hardwareDevices()->getDeviceTypeIconFromType(type(), size);
208 bool TDEGenericDevice::blacklistedForUpdate() {
209 return m_blacklistedForUpdate;
212 void TDEGenericDevice::internalSetBlacklistedForUpdate(
bool bl) {
213 m_blacklistedForUpdate = bl;
216 TQString TDEGenericDevice::friendlyDeviceType() {
217 return TDEGlobal::hardwareDevices()->getFriendlyDeviceTypeStringFromType(type());
220 TQString TDEGenericDevice::busID() {
221 TQString busid = m_systemPath;
222 busid = busid.remove(0, busid.findRev(
"/")+1);
223 busid = busid.remove(0, busid.find(
":")+1);
227 TQString TDEGenericDevice::friendlyName() {
228 if (m_friendlyName.isNull()) {
229 if (type() == TDEGenericDeviceType::RootSystem) {
230 m_friendlyName =
"Linux System";
232 else if (type() == TDEGenericDeviceType::Root) {
233 TQString friendlyDriverName = systemPath();
234 friendlyDriverName.truncate(friendlyDriverName.length()-1);
235 friendlyDriverName.remove(0, friendlyDriverName.findRev(
"/")+1);
236 m_friendlyName = friendlyDriverName;
238 else if (m_modAlias.lower().startsWith(
"pci")) {
239 m_friendlyName = TDEGlobal::hardwareDevices()->findPCIDeviceName(m_vendorID, m_modelID, m_subvendorID, m_submodelID);
241 else if (m_modAlias.lower().startsWith(
"usb")) {
242 m_friendlyName = TDEGlobal::hardwareDevices()->findUSBDeviceName(m_vendorID, m_modelID, m_subvendorID, m_submodelID);
245 TQString acpigentype = systemPath();
246 acpigentype.truncate(acpigentype.length()-1);
247 acpigentype.remove(0, acpigentype.findRev(
"/")+1);
248 TQString pnpgentype = acpigentype;
249 pnpgentype.truncate(pnpgentype.find(
":"));
250 if (pnpgentype.startsWith(
"PNP")) {
251 m_friendlyName = TDEGlobal::hardwareDevices()->findPNPDeviceName(pnpgentype);
253 else if (acpigentype.startsWith(
"device:")) {
254 acpigentype.remove(0, acpigentype.findRev(
":")+1);
255 acpigentype.prepend(
"0x");
256 m_friendlyName =
i18n(
"ACPI Node %1").arg(acpigentype.toUInt(0,0));
261 if (m_friendlyName.isNull()) {
264 if (!m_vendorName.isNull() && !m_vendorModel.isNull()) {
265 m_friendlyName = m_vendorName +
" " + m_vendorModel;
269 if (m_friendlyName.isNull()) {
272 if (type() == TDEGenericDeviceType::CPU) {
273 m_friendlyName =
name();
275 else if (type() == TDEGenericDeviceType::Event) {
276 if (m_systemPath.contains(
"PNP0C0D")) {
277 m_friendlyName =
i18n(
"ACPI Lid Switch");
279 else if (m_systemPath.contains(
"PNP0C0E") || m_systemPath.contains(
"/LNXSLPBN")) {
280 m_friendlyName =
i18n(
"ACPI Sleep Button");
282 else if (m_systemPath.contains(
"PNP0C0C") || m_systemPath.contains(
"/LNXPWRBN")) {
283 m_friendlyName =
i18n(
"ACPI Power Button");
285 else if (m_parentDevice) {
287 return m_parentDevice->friendlyName();
290 m_friendlyName =
i18n(
"Generic Event Device");
293 else if (type() == TDEGenericDeviceType::Input) {
294 if (m_systemPath.contains(
"PNP0C0D")) {
295 m_friendlyName =
i18n(
"ACPI Lid Switch");
297 else if (m_systemPath.contains(
"PNP0C0E") || m_systemPath.contains(
"/LNXSLPBN")) {
298 m_friendlyName =
i18n(
"ACPI Sleep Button");
300 else if (m_systemPath.contains(
"PNP0C0C") || m_systemPath.contains(
"/LNXPWRBN")) {
301 m_friendlyName =
i18n(
"ACPI Power Button");
303 else if (m_parentDevice) {
305 return m_parentDevice->friendlyName();
308 m_friendlyName =
i18n(
"Generic Input Device");
312 else if (!m_deviceDriver.isNull()) {
313 TQString friendlyDriverName = m_deviceDriver.lower();
314 friendlyDriverName[0] = friendlyDriverName[0].upper();
315 m_friendlyName =
i18n(
"Generic %1 Device").arg(friendlyDriverName);
317 else if (m_systemPath.lower().startsWith(
"/sys/devices/virtual")) {
318 TQString friendlyDriverName = systemPath();
319 friendlyDriverName.truncate(friendlyDriverName.length()-1);
320 friendlyDriverName.remove(0, friendlyDriverName.findRev(
"/")+1);
321 if (!friendlyDriverName.isNull()) {
322 m_friendlyName =
i18n(
"Virtual Device %1").arg(friendlyDriverName);
325 m_friendlyName =
i18n(
"Unknown Virtual Device");
330 m_friendlyName =
i18n(
"Unknown Device") +
" " +
name();
334 return m_friendlyName;
337 TQString TDEGenericDevice::detailedFriendlyName() {
338 return friendlyName();
341 #include "tdegenericdevice.moc"
StdSizes
These are the standard sizes for icons.
TQString i18n(const char *text)
i18n is the function that does everything you need to translate a string.
const char * name(StdAction id)