| 584 | } |
| 585 | |
| 586 | void BaseAPI::putSystemInfo(QJsonObject& system) |
| 587 | { |
| 588 | if (!_sysInfo.init) |
| 589 | { |
| 590 | _sysInfo.init = true; |
| 591 | |
| 592 | _sysInfo.kernelType = QSysInfo::kernelType(); |
| 593 | _sysInfo.kernelVersion = QSysInfo::kernelVersion(); |
| 594 | _sysInfo.architecture = QSysInfo::currentCpuArchitecture(); |
| 595 | _sysInfo.wordSize = QString::number(QSysInfo::WordSize); |
| 596 | _sysInfo.productType = QSysInfo::productType(); |
| 597 | _sysInfo.productVersion = QSysInfo::productVersion(); |
| 598 | _sysInfo.prettyName = QSysInfo::prettyProductName(); |
| 599 | _sysInfo.hostName = QHostInfo::localHostName(); |
| 600 | _sysInfo.domainName = QHostInfo::localDomainName(); |
| 601 | |
| 602 | #ifdef _WIN32 |
| 603 | QString cpucorp = "wmic cpu get name"; |
| 604 | QProcess windowscpu; |
| 605 | windowscpu.startCommand(cpucorp); |
| 606 | windowscpu.waitForFinished(); |
| 607 | QString result = windowscpu.readAllStandardOutput().trimmed(); |
| 608 | if (result.startsWith("Name", Qt::CaseInsensitive)) |
| 609 | result = result.right(result.size()-4).trimmed(); |
| 610 | _sysInfo.cpuModelName = result; |
| 611 | #else |
| 612 | QString cpuString; |
| 613 | QFile file("/proc/cpuinfo"); |
| 614 | |
| 615 | if (file.exists() && file.open(QFile::ReadOnly | QFile::Text)) |
| 616 | { |
| 617 | QTextStream in(&file); |
| 618 | |
| 619 | while (in.readLineInto(&cpuString)) |
| 620 | { |
| 621 | bool more = false; |
| 622 | |
| 623 | if (_sysInfo.cpuModelType.isEmpty()) |
| 624 | { |
| 625 | QString match = "model\t"; |
| 626 | if (cpuString.startsWith(match, Qt::CaseInsensitive)) |
| 627 | _sysInfo.cpuModelType = cpuString.right(cpuString.length() - match.length() - 2).trimmed(); |
| 628 | else |
| 629 | more = true; |
| 630 | } |
| 631 | |
| 632 | if (_sysInfo.cpuModelName.isEmpty()) |
| 633 | { |
| 634 | QString match = "model name\t"; |
| 635 | |
| 636 | if (cpuString.startsWith(match, Qt::CaseInsensitive)) |
| 637 | _sysInfo.cpuModelName = cpuString.right(cpuString.length() - match.length() - 2).trimmed(); |
| 638 | else |
| 639 | more = true; |
| 640 | } |
| 641 | |
| 642 | if (_sysInfo.cpuHardware.isEmpty()) |
| 643 | { |