Add JSON stubs, remove a bunch of now obsolete code.
Originally committed to SVN as r5113.
This commit is contained in:
parent
e35badd20a
commit
4118580bb6
6 changed files with 65 additions and 148 deletions
|
@ -145,33 +145,33 @@ public:
|
||||||
/// CPU ID string
|
/// CPU ID string
|
||||||
/// @return CPU ID
|
/// @return CPU ID
|
||||||
/// @retval Any, ex: Intel(R) Pentium(R) M processor 1600MHz
|
/// @retval Any, ex: Intel(R) Pentium(R) M processor 1600MHz
|
||||||
virtual wxString CPUId()=0;
|
virtual std::string CPUId()=0;
|
||||||
|
|
||||||
/// CPU Speed
|
/// CPU Speed
|
||||||
/// @return Speed
|
/// @return Speed
|
||||||
/// @retval Integer
|
/// @retval Integer
|
||||||
virtual wxString CPUSpeed()=0;
|
virtual std::string CPUSpeed()=0;
|
||||||
|
|
||||||
/// CPU Count
|
/// CPU Count
|
||||||
/// @return Count
|
/// @return Count
|
||||||
/// @retval Integer
|
/// @retval Integer
|
||||||
virtual wxString CPUCount()=0;
|
virtual int CPUCount()=0;
|
||||||
|
|
||||||
/// CPU Cores
|
/// CPU Cores
|
||||||
/// @return Cores
|
/// @return Cores
|
||||||
/// @retval Integer
|
/// @retval Integer
|
||||||
virtual wxString CPUCores()=0;
|
virtual int CPUCores()=0;
|
||||||
|
|
||||||
/// CPU Features
|
/// CPU Features
|
||||||
/// @return Features set 1
|
/// @return Features set 1
|
||||||
/// @retval FPU,VME,DE,PSE,TSC,MSR...
|
/// @retval FPU,VME,DE,PSE,TSC,MSR...
|
||||||
virtual wxString CPUFeatures()=0;
|
virtual std::string CPUFeatures()=0;
|
||||||
|
|
||||||
/// CPU Features2
|
/// CPU Features2
|
||||||
/// @return Features set 2
|
/// @return Features set 2
|
||||||
/// @retval CPU-specific features
|
/// @retval CPU-specific features
|
||||||
/// @note "EST,TM2" on my P-M, or "SYSCALL,NX,MMX+,LM,3DNow!+,3DNow!" on an Opteron
|
/// @note "EST,TM2" on my P-M, or "SYSCALL,NX,MMX+,LM,3DNow!+,3DNow!" on an Opteron
|
||||||
virtual wxString CPUFeatures2()=0;
|
virtual std::string CPUFeatures2()=0;
|
||||||
|
|
||||||
/// System memory
|
/// System memory
|
||||||
/// @return Memory
|
/// @return Memory
|
||||||
|
@ -257,7 +257,7 @@ public:
|
||||||
/// <file version="[version]">[name]</file>
|
/// <file version="[version]">[name]</file>
|
||||||
/// </lib>
|
/// </lib>
|
||||||
/// \endverbatim
|
/// \endverbatim
|
||||||
virtual wxString UnixLibraries()=0;
|
virtual std::string UnixLibraries()=0;
|
||||||
|
|
||||||
/// Desktop environment
|
/// Desktop environment
|
||||||
/// @return Environment
|
/// @return Environment
|
||||||
|
|
|
@ -29,14 +29,14 @@ public:
|
||||||
wxString DesktopEnvironment();
|
wxString DesktopEnvironment();
|
||||||
|
|
||||||
// Hardware
|
// Hardware
|
||||||
virtual wxString CPUId() { return ""; }
|
virtual std::string CPUId() { return ""; }
|
||||||
virtual wxString CPUSpeed() { return ""; }
|
virtual std::string CPUSpeed() { return ""; }
|
||||||
virtual wxString CPUCores() { return ""; }
|
virtual int CPUCores() { return 0; }
|
||||||
virtual wxString CPUCount() { return ""; }
|
virtual int CPUCount() { return 0; }
|
||||||
virtual wxString CPUFeatures() { return ""; }
|
virtual std::string CPUFeatures() { return ""; }
|
||||||
virtual wxString CPUFeatures2() { return ""; }
|
virtual std::string CPUFeatures2() { return ""; }
|
||||||
virtual uint64_t Memory() { return 0; }
|
virtual uint64_t Memory() { return 0; }
|
||||||
|
|
||||||
// Unix Specific
|
// Unix Specific
|
||||||
virtual wxString UnixLibraries() { return ""; };
|
virtual std::string UnixLibraries() { return ""; };
|
||||||
};
|
};
|
||||||
|
|
|
@ -32,33 +32,33 @@ extern "C" {
|
||||||
#include "platform_unix_bsd.h"
|
#include "platform_unix_bsd.h"
|
||||||
|
|
||||||
|
|
||||||
wxString PlatformUnixBSD::CPUId() {
|
std::string PlatformUnixBSD::CPUId() {
|
||||||
char id[300];
|
char id[300];
|
||||||
size_t len = sizeof(id);
|
size_t len = sizeof(id);
|
||||||
sysctlbyname("hw.model", &id, &len, NULL, 0);
|
sysctlbyname("hw.model", &id, &len, NULL, 0);
|
||||||
return wxString::Format("%s", id);
|
return id;
|
||||||
};
|
};
|
||||||
|
|
||||||
wxString PlatformUnixBSD::CPUSpeed() {
|
std::string PlatformUnixBSD::CPUSpeed() {
|
||||||
return "";
|
return "";
|
||||||
};
|
};
|
||||||
|
|
||||||
wxString PlatformUnixBSD::CPUCores() {
|
int PlatformUnixBSD::CPUCores() {
|
||||||
return "";
|
return 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
wxString PlatformUnixBSD::CPUCount() {
|
int PlatformUnixBSD::CPUCount() {
|
||||||
int proc;
|
int proc;
|
||||||
size_t len = sizeof(proc);
|
size_t len = sizeof(proc);
|
||||||
sysctlbyname("hw.ncpu", &proc, &len, NULL, 0);
|
sysctlbyname("hw.ncpu", &proc, &len, NULL, 0);
|
||||||
return wxString::Format("%d", proc);
|
return proc;
|
||||||
};
|
};
|
||||||
|
|
||||||
wxString PlatformUnixBSD::CPUFeatures() {
|
std::string PlatformUnixBSD::CPUFeatures() {
|
||||||
return "";
|
return "";
|
||||||
};
|
};
|
||||||
|
|
||||||
wxString PlatformUnixBSD::CPUFeatures2() {
|
std::string PlatformUnixBSD::CPUFeatures2() {
|
||||||
return "";
|
return "";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -69,6 +69,6 @@ uint64_t PlatformUnixBSD::Memory() {
|
||||||
return memory;
|
return memory;
|
||||||
};
|
};
|
||||||
|
|
||||||
wxString PlatformUnixBSD::UnixLibraries() {
|
std::string PlatformUnixBSD::UnixLibraries() {
|
||||||
return "";
|
return "";
|
||||||
};
|
};
|
||||||
|
|
|
@ -27,14 +27,14 @@ public:
|
||||||
virtual ~PlatformUnixBSD() {};
|
virtual ~PlatformUnixBSD() {};
|
||||||
|
|
||||||
// Hardware
|
// Hardware
|
||||||
virtual wxString CPUId();
|
virtual std::string CPUId();
|
||||||
virtual wxString CPUSpeed();
|
virtual std::string CPUSpeed();
|
||||||
virtual wxString CPUCores();
|
virtual int CPUCores();
|
||||||
virtual wxString CPUCount();
|
virtual int CPUCount();
|
||||||
virtual wxString CPUFeatures();
|
virtual std::string CPUFeatures();
|
||||||
virtual wxString CPUFeatures2();
|
virtual std::string CPUFeatures2();
|
||||||
virtual uint64_t Memory();
|
virtual uint64_t Memory();
|
||||||
|
|
||||||
// Unix Specific
|
// Unix Specific
|
||||||
virtual wxString UnixLibraries();
|
virtual std::string UnixLibraries();
|
||||||
};
|
};
|
||||||
|
|
|
@ -86,139 +86,56 @@ Report::XMLReport Report::ReportCreate() {
|
||||||
|
|
||||||
|
|
||||||
json::Object cpu;
|
json::Object cpu;
|
||||||
cpu["Id"] = json::String();
|
cpu["Id"] = json::String(p->CPUId());
|
||||||
cpu["Speed"] = json::String();
|
cpu["Speed"] = json::String(p->CPUSpeed());
|
||||||
cpu["Count"] = json::String();
|
cpu["Count"] = json::Number(p->CPUCount());
|
||||||
cpu["Cores"] = json::String();
|
cpu["Cores"] = json::Number(p->CPUCores());
|
||||||
cpu["Features"] = json::String();
|
cpu["Features"] = json::String(p->CPUFeatures());
|
||||||
cpu["Features2"] = json::String();
|
cpu["Features2"] = json::String(p->CPUFeatures2());
|
||||||
|
|
||||||
|
|
||||||
|
json::Object display;
|
||||||
|
// display["Depth"] = json::Number(p->DisplayDepth());
|
||||||
|
// display["Colour"] = json::Number(p->DisplayColour());
|
||||||
|
// display["Size"] = json::String(p->DisplaySize());
|
||||||
|
// display["Pixels Per Inch"] = json::Number(p->DisplayPPI());
|
||||||
|
|
||||||
/*
|
|
||||||
wxXmlNode *cpu = new wxXmlNode(wxXML_ELEMENT_NODE, CPU);
|
|
||||||
doc.hardware->AddChild(cpu);
|
|
||||||
Add(cpu, Id, p->CPUId());
|
|
||||||
Add(cpu, Speed, p->CPUSpeed());
|
|
||||||
Add(cpu, Count, p->CPUCount());
|
|
||||||
Add(cpu, Cores, p->CPUCores());
|
|
||||||
Add(cpu, Features, p->CPUFeatures());
|
|
||||||
Add(cpu, Features2, p->CPUFeatures2());
|
|
||||||
|
|
||||||
wxXmlNode *display = new wxXmlNode(wxXML_ELEMENT_NODE, Display);
|
// json::Object gl;
|
||||||
doc.hardware->AddChild(display);
|
// gl["Vendor"] = json::String(p->OpenGLVendor());
|
||||||
Add(display, Depth, p->DisplayDepth());
|
// gl["Renderer"] = json::String(p->OpenGLRenderer());
|
||||||
Add(display, Colour Screen, p->DisplayColour());
|
// gl["Version"] = json::String(p->OpenGLVersion());
|
||||||
Add(display, Size, p->DisplaySize());
|
// gl["Extensions"] = json::String(p->OpenGLExt());
|
||||||
Add(display, Pixels Per Inch, p->DisplayPPI());
|
// display["OpenGL"] = gl;
|
||||||
|
|
||||||
wxXmlNode *display_gl = new wxXmlNode(wxXML_ELEMENT_NODE, OpenGL);
|
|
||||||
display->AddChild(display_gl);
|
|
||||||
|
|
||||||
Add(display_gl, Vendor, p->OpenGLVendor());
|
|
||||||
Add(display_gl, Renderer, p->OpenGLRenderer());
|
|
||||||
Add(display_gl, Version, p->OpenGLVersion());
|
|
||||||
Add(display_gl, Extensions, p->OpenGLExt());
|
|
||||||
|
|
||||||
#ifdef __WINDOWS__
|
#ifdef __WINDOWS__
|
||||||
doc.windows = new wxXmlNode(wxXML_ELEMENT_NODE, Windows);
|
json::Object windows;
|
||||||
doc.report->AddChild(doc.windows);
|
windows["Service Pack"] = json::String();
|
||||||
Add(doc.windows, Service Pack, p->ServicePack());
|
windows["Graphics Driver Version"] = json::String();
|
||||||
Add(doc.windows, Graphics Driver Version, p->DriverGraphicsVersion());
|
windows["DirectShow Filters"] = json::String();
|
||||||
Add(doc.windows, DirectShow Filters, p->DirectShowFilters());
|
windows["AntiVirus Installed"] = json::Boolean();
|
||||||
Add(doc.windows, AntiVirus Installed, p->AntiVirus());
|
windows["Firewall Installed"] = json::Boolean();
|
||||||
Add(doc.windows, Firewall Installed, p->Firewall());
|
windows["DLL"] = json::String();
|
||||||
Add(doc.windows, DLL, p->DLLVersions());
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __UNIX__
|
#ifdef __UNIX__
|
||||||
doc.unixx = new wxXmlNode(wxXML_ELEMENT_NODE, Unix);
|
json::Object u_nix;
|
||||||
doc.report->AddChild(doc.unixx);
|
// u_nix["Desktop Environment"] = json::String(p->DesktopEnvironment());
|
||||||
Add(doc.unixx, Desktop Environment, p->DesktopEnvironment());
|
// u_nix["Libraries"] = json::String(p->UnixLibraries());
|
||||||
Add(doc.unixx, Libraries, p->UnixLibraries());
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
doc.osx = new wxXmlNode(wxXML_ELEMENT_NODE, OS X);
|
json::Object osx;
|
||||||
doc.report->AddChild(doc.osx);
|
osx["Patch"] = json::String(p->PatchLevel());
|
||||||
Add(doc.osx, Patch, p->PatchLevel());
|
osx["QuickTime Extensions"] = json::String(p->QuickTimeExt());
|
||||||
Add(doc.osx, QuickTime Extensions, p->QuickTimeExt());
|
osx["Model"] = json::String(p->HardwareModel());
|
||||||
Add(doc.osx, Model, p->HardwareModel());
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
*/
|
|
||||||
return doc;
|
return doc;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @brief Add a new XML node.
|
|
||||||
/// @param parent Parent nodee
|
|
||||||
/// @param node Name of the new node
|
|
||||||
/// @param text Contents
|
|
||||||
void Report::Add(wxXmlNode *parent, wxString node, wxString text) {
|
|
||||||
// Using AddChild() keeps the nodes in their natural order. It's slower but our
|
|
||||||
// document is pretty small. Doing it the faster way results in reverse-ordered nodes.
|
|
||||||
wxXmlNode *tmp = new wxXmlNode(wxXML_ELEMENT_NODE, node);
|
|
||||||
tmp->AddChild(new wxXmlNode(wxXML_TEXT_NODE, node, text));
|
|
||||||
parent->AddChild(tmp);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @brief Recursive function to populate listView and text-based for Clipboard.
|
|
||||||
/// @param node Node to parse.
|
|
||||||
/// @param listView wxListView to populate.
|
|
||||||
void Report::ProcessNode(wxXmlNode *node, wxString *text, wxListView *listView) {
|
|
||||||
wxString node_name;
|
|
||||||
nameMap::iterator names;
|
|
||||||
nameMap nMap = HumanNames();
|
|
||||||
|
|
||||||
wxXmlNode *child = node->GetChildren();
|
|
||||||
|
|
||||||
while (child) {
|
|
||||||
wxString name = child->GetName();
|
|
||||||
|
|
||||||
if ((names = nMap.find(name)) != nMap.end()) {
|
|
||||||
node_name = locale->GetString(names->second);
|
|
||||||
} else {
|
|
||||||
wxLogDebug("Report::ProcessNode Unknown node found: \"%s\" (add it to nMap)\n", name);
|
|
||||||
node_name = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
wxListItem column;
|
|
||||||
int row = listView->GetItemCount();
|
|
||||||
int depth = child->GetDepth();
|
|
||||||
|
|
||||||
if (child->GetChildren()->GetType() == wxXML_ELEMENT_NODE) {
|
|
||||||
int font_size = 15 - floor(depth * 2 + 0.5);
|
|
||||||
int bgcolour = 155 + (depth * 20);
|
|
||||||
listView->InsertItem(row,node_name);
|
|
||||||
listView->SetItemFont(row, wxFont(font_size, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD));
|
|
||||||
listView->SetItemBackgroundColour(row, wxColour(bgcolour,bgcolour,bgcolour, wxALPHA_OPAQUE));
|
|
||||||
if (depth == 1) text->Append("\n");
|
|
||||||
text->Append(wxString::Format("%s\n", node_name.Pad((depth*2)-2, ' ', 0)));
|
|
||||||
ProcessNode(child, text, listView);
|
|
||||||
} else {
|
|
||||||
wxString content = child->GetNodeContent();
|
|
||||||
listView->InsertItem(row,node_name);
|
|
||||||
listView->SetItem(row,1, content);
|
|
||||||
text->Append(wxString::Format("%-22s: %s\n", node_name.Pad((depth*2)-2, ' ', 0), content));
|
|
||||||
}
|
|
||||||
|
|
||||||
child = child->GetNext();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Report::Fill(wxString *text, wxListView *listView) {
|
|
||||||
|
|
||||||
listView->InsertColumn(0, _("Entry"), wxLIST_FORMAT_RIGHT);
|
|
||||||
listView->InsertColumn(1, _("Text"), wxLIST_FORMAT_LEFT, 100);
|
|
||||||
|
|
||||||
ProcessNode(doc.report, text, listView);
|
|
||||||
|
|
||||||
listView->SetColumnWidth(0, wxLIST_AUTOSIZE);
|
|
||||||
listView->SetColumnWidth(1, wxLIST_AUTOSIZE);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @brief Return Report as Text for the Clipboard.
|
/// @brief Return Report as Text for the Clipboard.
|
||||||
void Report::Save(wxString file) {
|
void Report::Save(wxString file) {
|
||||||
doc.doc->Save(file);
|
doc.doc->Save(file);
|
||||||
|
|
|
@ -41,7 +41,7 @@ View::View(wxWindow *frame, Report *r)
|
||||||
|
|
||||||
// Fill the list with the actual report.
|
// Fill the list with the actual report.
|
||||||
text = new wxString();
|
text = new wxString();
|
||||||
r->Fill(text, listView);
|
// r->Fill(text, listView);
|
||||||
|
|
||||||
listSizer->Add(listView, 1, wxEXPAND);
|
listSizer->Add(listView, 1, wxEXPAND);
|
||||||
topSizer->Add(listSizer, 1, wxEXPAND | wxALL, 0);
|
topSizer->Add(listSizer, 1, wxEXPAND | wxALL, 0);
|
||||||
|
|
Loading…
Reference in a new issue