| 492 | } |
| 493 | |
| 494 | QHash<QString, USBDeviceInfo> Interception_Worker::parseUSBIDs(const QString &filePath) |
| 495 | { |
| 496 | QHash<QString, USBDeviceInfo> usbIDs; |
| 497 | |
| 498 | QFile file(filePath); |
| 499 | if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { |
| 500 | qDebug() << "Failed to open USB IDs file."; |
| 501 | return usbIDs; |
| 502 | } |
| 503 | |
| 504 | QTextStream in(&file); |
| 505 | QString line; |
| 506 | QString currentVendorId; |
| 507 | QString currentVendorName; |
| 508 | while (!in.atEnd()) { |
| 509 | line = in.readLine(); |
| 510 | |
| 511 | if (line.startsWith('#') || line.trimmed().isEmpty()) |
| 512 | continue; |
| 513 | |
| 514 | if (line.startsWith('\t')) { |
| 515 | // Product line |
| 516 | QStringList fields = line.trimmed().split(" ", QKeyMapperQtCompat::SkipEmptyParts); |
| 517 | if (fields.size() < 2) |
| 518 | continue; |
| 519 | |
| 520 | QString productId = fields[0]; |
| 521 | QString productName = fields[1]; |
| 522 | USBDeviceInfo deviceInfo; |
| 523 | deviceInfo.vendorName = currentVendorName; |
| 524 | deviceInfo.productName = productName; |
| 525 | usbIDs[currentVendorId + productId] = deviceInfo; |
| 526 | } else { |
| 527 | // Vendor line |
| 528 | QStringList fields = line.trimmed().split(" ", QKeyMapperQtCompat::SkipEmptyParts); |
| 529 | if (fields.size() < 2) |
| 530 | continue; |
| 531 | |
| 532 | QString productId = QString("0000"); |
| 533 | currentVendorId = fields[0]; |
| 534 | currentVendorName = fields[1]; |
| 535 | USBDeviceInfo deviceInfo; |
| 536 | deviceInfo.vendorName = currentVendorName; |
| 537 | usbIDs[currentVendorId + productId] = deviceInfo; |
| 538 | } |
| 539 | } |
| 540 | |
| 541 | file.close(); |
| 542 | return usbIDs; |
| 543 | } |
| 544 | |
| 545 | QString Interception_Worker::getDeviceDescriptionByHardwareID(const QString &hardwareID) |
| 546 | { |