Commit 0946450fd6271bbf075a79176b3e80bc1f49ba47

Authored by Thiago Rocha
1 parent ad1fdec2
Exists in master

Criado método coletaLinuxPci e alterado alguns detalhes.

Showing 2 changed files with 43 additions and 5 deletions   Show diff stats
src/cacic_hardware.cpp
... ... @@ -40,7 +40,7 @@ QJsonObject cacic_hardware::coletaLinux()
40 40  
41 41 if( lshwJson.contains("id") && lshwJson["id"] == "core") {
42 42 if ( lshwJson["children"].isArray() ){
43   - qDebug() << "IS ARRAY!!";
  43 +// qDebug() << "IS ARRAY!!";
44 44 QJsonArray componentsArray = lshwJson["children"].toArray();
45 45  
46 46 foreach(QJsonValue componentValue, componentsArray ) {
... ... @@ -52,7 +52,7 @@ QJsonObject cacic_hardware::coletaLinux()
52 52 *
53 53 * coletaLinuxMem
54 54 * coletaLinuxCpu
55   - * coletaLinuxPci - a fazer
  55 + * coletaLinuxPci
56 56 */
57 57  
58 58 if( component["id"] == "memory" ) {
... ... @@ -256,6 +256,46 @@ void cacic_hardware::coletaLinuxCpu(QJsonObject &amp;hardware, const QJsonObject &amp;co
256 256 void cacic_hardware::coletaLinuxPci(QJsonObject &hardware, const QJsonObject &pciJson)
257 257 {
258 258  
  259 + QJsonObject pciMember;
  260 +
  261 + if ( pciJson["id"] == "multimedia") {
  262 + pciMember["description"] = pciJson["description"];
  263 + pciMember["product"] = pciJson["product"];
  264 + pciMember["vendor"] = pciJson["vendor"];
  265 +
  266 + hardware["multimedia"] = pciMember;
  267 + } else if (pciJson["id"].toString().contains("pci:") ) {
  268 + QJsonArray pciChildren = pciJson["children"].toArray();
  269 +
  270 + foreach( QJsonValue pciChild, pciChildren ) {
  271 + QJsonObject pciChildJson = pciChild.toObject();
  272 +
  273 + if( pciChildJson["id"] == "network" &&
  274 + ( pciChildJson["description"].toString().contains("Wireless") ||
  275 + pciChildJson["product"].toString().contains("Wireless") )) {
  276 + pciMember["description"] = pciChildJson["description"];
  277 + pciMember["product"] = pciChildJson["product"];
  278 + pciMember["vendor"] = pciChildJson["vendor"];
  279 + pciMember["logicalname"] = pciChildJson["logicalname"];
  280 + pciMember["serial"] = pciChildJson["serial"];
  281 + pciMember["firmware"] = pciChildJson["configuration"].toObject()["firmware"];
  282 +
  283 + hardware["wireless_card"] = pciMember;
  284 + } else if( pciChildJson["id"] == "network" ) {
  285 + pciMember["description"] = pciChildJson["description"];
  286 + pciMember["product"] = pciChildJson["product"];
  287 + pciMember["vendor"] = pciChildJson["vendor"];
  288 + pciMember["logicalname"] = pciChildJson["logicalname"];
  289 + pciMember["serial"] = pciChildJson["serial"];
  290 + pciMember["capacity"] = QJsonValue::fromVariant(
  291 + oCacic.convertDouble(pciChildJson["capacity"].toDouble(), 0) +
  292 + " bits/s" );
  293 +
  294 + hardware["ethernet_card"] = pciMember;
  295 + }
  296 +
  297 + }
  298 + }
259 299 }
260 300  
261 301 QJsonObject cacic_hardware::toJsonObject() {
... ...
src/cacic_hardware.h
1 1 #ifndef CACIC_HARDWARE_H
2 2 #define CACIC_HARDWARE_H
3 3 #include <ccacic.h>
4   -#include <querysink.h>
5 4 #include <QtCore>
6 5 #include <QJsonArray>
7 6 #include <QJsonArray>
... ... @@ -11,6 +10,7 @@
11 10 #include <operatingsystem.h>
12 11  
13 12 #if defined(Q_OS_WIN)
  13 + #include <querysink.h>
14 14 #define _WIN32_DCOM
15 15 #include <iostream>
16 16 //using namespace std;
... ... @@ -26,8 +26,6 @@ public:
26 26 cacic_hardware();
27 27 void iniciaColeta();
28 28 QJsonObject toJsonObject();
29   - QJsonObject coletaWin();
30   - QJsonObject coletaLinux();
31 29  
32 30 private:
33 31 int wmi();
... ...