Commit ad1fdec21c291f199d6f5616d3317959ffea60cb
1 parent
84e22771
Exists in
master
Concerto de falha em merge no cacic_hardware.cpp
Showing
1 changed file
with
49 additions
and
62 deletions
Show diff stats
src/cacic_hardware.cpp
@@ -23,17 +23,59 @@ QJsonObject cacic_hardware::coletaWin() | @@ -23,17 +23,59 @@ QJsonObject cacic_hardware::coletaWin() | ||
23 | 23 | ||
24 | QJsonObject cacic_hardware::coletaLinux() | 24 | QJsonObject cacic_hardware::coletaLinux() |
25 | { | 25 | { |
26 | - QJsonObject coleta; | ||
27 | 26 | ||
28 | - return coleta; | ||
29 | -} | 27 | + OperatingSystem operatingSystem; |
28 | + ConsoleObject console; | ||
30 | 29 | ||
30 | + QJsonObject hardware; | ||
31 | 31 | ||
32 | -QJsonObject cacic_hardware::toJsonObject() | ||
33 | -{ | ||
34 | - QJsonObject coleta; | 32 | + QFile lshwFile("lshwJson.json"); |
33 | + if( lshwFile.exists() ) | ||
34 | + lshwFile.remove(); | ||
35 | + | ||
36 | + console("lshw -json >> lshwJson.json"); | ||
37 | + | ||
38 | + | ||
39 | + QJsonObject lshwJson = oCacic.getJsonFromFile("lshwJson.json")["children"].toArray().first().toObject(); | ||
40 | + | ||
41 | + if( lshwJson.contains("id") && lshwJson["id"] == "core") { | ||
42 | + if ( lshwJson["children"].isArray() ){ | ||
43 | + qDebug() << "IS ARRAY!!"; | ||
44 | + QJsonArray componentsArray = lshwJson["children"].toArray(); | ||
45 | + | ||
46 | + foreach(QJsonValue componentValue, componentsArray ) { | ||
47 | + QJsonObject component = componentValue.toObject(); | ||
48 | + | ||
49 | + /* TODO: | ||
50 | + * - Formatar direito as quantidades (memória,clock do cpu) | ||
51 | + * com unidades mais amigáveis para humanos em todos métodos. | ||
52 | + * | ||
53 | + * coletaLinuxMem | ||
54 | + * coletaLinuxCpu | ||
55 | + * coletaLinuxPci - a fazer | ||
56 | + */ | ||
57 | + | ||
58 | + if( component["id"] == "memory" ) { | ||
59 | + coletaLinuxMem(hardware,component); | ||
60 | + } else if ( component["id"] == "cpu" ) { | ||
61 | + coletaLinuxCpu(hardware,component); | ||
62 | + } else if ( component["id"] == "pci" ) { | ||
63 | + QJsonArray pciArray = component["children"].toArray(); | ||
64 | + | ||
65 | + foreach(QJsonValue pciValue, pciArray){ | ||
66 | + QJsonObject pciObject = pciValue.toObject(); | ||
67 | + | ||
68 | + coletaLinuxPci(hardware, pciObject); | ||
69 | + } | ||
35 | 70 | ||
36 | - return coleta; | 71 | + } |
72 | + | ||
73 | + } | ||
74 | + } | ||
75 | + | ||
76 | + } | ||
77 | + | ||
78 | + return hardware; | ||
37 | } | 79 | } |
38 | 80 | ||
39 | int cacic_hardware::wmi() | 81 | int cacic_hardware::wmi() |
@@ -188,61 +230,7 @@ int cacic_hardware::wmi() | @@ -188,61 +230,7 @@ int cacic_hardware::wmi() | ||
188 | // CoUninitialize(); | 230 | // CoUninitialize(); |
189 | 231 | ||
190 | return 0; // Program successfully completed. | 232 | return 0; // Program successfully completed. |
191 | -======= | ||
192 | - | ||
193 | - OperatingSystem operatingSystem; | ||
194 | - ConsoleObject console; | ||
195 | - | ||
196 | - QJsonObject hardware; | ||
197 | - | ||
198 | - QFile lshwFile("lshwJson.json"); | ||
199 | - if( lshwFile.exists() ) | ||
200 | - lshwFile.remove(); | ||
201 | - | ||
202 | - console("lshw -json >> lshwJson.json"); | ||
203 | - | ||
204 | - | ||
205 | - QJsonObject lshwJson = oCacic.getJsonFromFile("lshwJson.json")["children"].toArray().first().toObject(); | ||
206 | - | ||
207 | - if( lshwJson.contains("id") && lshwJson["id"] == "core") { | ||
208 | - if ( lshwJson["children"].isArray() ){ | ||
209 | - qDebug() << "IS ARRAY!!"; | ||
210 | - QJsonArray componentsArray = lshwJson["children"].toArray(); | ||
211 | - | ||
212 | - foreach(QJsonValue componentValue, componentsArray ) { | ||
213 | - QJsonObject component = componentValue.toObject(); | ||
214 | - | ||
215 | - /* TODO: | ||
216 | - * - Formatar direito as quantidades (memória,clock do cpu) | ||
217 | - * com unidades mais amigáveis para humanos em todos métodos. | ||
218 | - * | ||
219 | - * coletaLinuxMem | ||
220 | - * coletaLinuxCpu | ||
221 | - * coletaLinuxPci - a fazer | ||
222 | - */ | ||
223 | - | ||
224 | - if( component["id"] == "memory" ) { | ||
225 | - coletaLinuxMem(hardware,component); | ||
226 | - } else if ( component["id"] == "cpu" ) { | ||
227 | - coletaLinuxCpu(hardware,component); | ||
228 | - } else if ( component["id"] == "pci" ) { | ||
229 | - QJsonArray pciArray = component["children"].toArray(); | ||
230 | - | ||
231 | - foreach(QJsonValue pciValue, pciArray){ | ||
232 | - QJsonObject pciObject = pciValue.toObject(); | ||
233 | - | ||
234 | - coletaLinuxPci(hardware, pciObject); | ||
235 | - } | ||
236 | 233 | ||
237 | - } | ||
238 | - | ||
239 | - } | ||
240 | - } | ||
241 | - | ||
242 | - } | ||
243 | - | ||
244 | - | ||
245 | - return hardware; | ||
246 | } | 234 | } |
247 | 235 | ||
248 | void cacic_hardware::coletaLinuxMem(QJsonObject &hardware, const QJsonObject &component) | 236 | void cacic_hardware::coletaLinuxMem(QJsonObject &hardware, const QJsonObject &component) |
@@ -272,5 +260,4 @@ void cacic_hardware::coletaLinuxPci(QJsonObject &hardware, const QJsonObject &pc | @@ -272,5 +260,4 @@ void cacic_hardware::coletaLinuxPci(QJsonObject &hardware, const QJsonObject &pc | ||
272 | 260 | ||
273 | QJsonObject cacic_hardware::toJsonObject() { | 261 | QJsonObject cacic_hardware::toJsonObject() { |
274 | return coletaHardware; | 262 | return coletaHardware; |
275 | ->>>>>>> c87d0f3e5ae47bd0d7f7f8c5f5583bb46dd7235b | ||
276 | } | 263 | } |