* Remove all vestiges of XML.

* Generate the report in the constructor.

Originally committed to SVN as r5118.
This commit is contained in:
Amar Takhar 2011-01-03 14:28:24 +00:00
parent 22c797a5d1
commit c041bb8884
7 changed files with 20 additions and 72 deletions

View file

@ -209,8 +209,8 @@ public:
virtual wxString DriverGraphicsVersion()=0; virtual wxString DriverGraphicsVersion()=0;
/// Directshow filters installed /// Directshow filters installed
/// @return wxXmlNode of filters installed /// @return json::Object of filters installed
/// @retval A wxXmlNode in the format of: /// @retval A json::Object format of:
/// \verbatim /// \verbatim
/// <filter> /// <filter>
/// <name version="[version]">[name]</name> /// <name version="[version]">[name]</name>
@ -229,12 +229,10 @@ public:
virtual wxString Firewall()=0; virtual wxString Firewall()=0;
/// DLL versions used /// DLL versions used
/// @return wxXmlNode of DLLs used /// @return json::Array of DLLs used
/// @retval A wxXmlNode in the format of: /// @retval A json::Array in the format of:
/// \verbatim /// \verbatim
/// <dll> /// { "version", "name" }
/// <file version="[version]">[name]</file>
/// </dll>
/// \endverbatim /// \endverbatim
virtual wxString DLLVersions()=0; virtual wxString DLLVersions()=0;
#endif #endif
@ -244,13 +242,11 @@ public:
//@{ //@{
#ifdef __UNIX__ #ifdef __UNIX__
/// Dynamic libraries used /// Library versions used
/// @return wxXmlNode of libraries used /// @return json::Array of DLLs used
/// @retval A wxXmlNode in the format of: /// @retval A json::Array in the format of:
/// \verbatim /// \verbatim
/// <lib> /// { "version", "name" }
/// <file version="[version]">[name]</file>
/// </lib>
/// \endverbatim /// \endverbatim
virtual std::string UnixLibraries()=0; virtual std::string UnixLibraries()=0;
@ -271,12 +267,10 @@ public:
virtual wxString PatchLevel()=0; virtual wxString PatchLevel()=0;
/// QuickTime extensions /// QuickTime extensions
/// @return wxXmlNode of extensions used /// @return json::Array of extensions used
/// @retval A wxXmlNode in the format of: /// @retval A json::Array in the format of:
/// \verbatim /// \verbatim
/// <quicktime> /// { "version", "name" }
/// <ext version="[version]">[name]</file>
/// </quicktime>
/// \endverbatim /// \endverbatim
virtual wxString QuickTimeExt()=0; virtual wxString QuickTimeExt()=0;

View file

@ -33,7 +33,6 @@
#pragma comment(lib, "wxmsw29ud_gl.lib") #pragma comment(lib, "wxmsw29ud_gl.lib")
#pragma comment(lib, "wxmsw29ud_stc.lib") #pragma comment(lib, "wxmsw29ud_stc.lib")
#pragma comment(lib, "wxscintillad.lib") #pragma comment(lib, "wxscintillad.lib")
#pragma comment(lib, "wxbase29ud_xml.lib")
#pragma comment(lib, "wxexpatd.lib") #pragma comment(lib, "wxexpatd.lib")
#else #else
#pragma comment(lib, "wxzlib.lib") #pragma comment(lib, "wxzlib.lib")
@ -47,7 +46,6 @@
#pragma comment(lib, "wxmsw29u_gl.lib") #pragma comment(lib, "wxmsw29u_gl.lib")
#pragma comment(lib, "wxmsw29u_stc.lib") #pragma comment(lib, "wxmsw29u_stc.lib")
#pragma comment(lib, "wxscintilla.lib") #pragma comment(lib, "wxscintilla.lib")
#pragma comment(lib, "wxbase29u_xml.lib")
#pragma comment(lib, "wxexpat.lib") #pragma comment(lib, "wxexpat.lib")
#endif #endif

View file

@ -50,7 +50,7 @@ bool Reporter::OnInit()
static const wxCmdLineEntryDesc cmdLineDesc[] = { static const wxCmdLineEntryDesc cmdLineDesc[] = {
{ wxCMD_LINE_SWITCH, "c", "crash", "Launch in crash mode.", wxCMD_LINE_VAL_NONE, NULL }, { wxCMD_LINE_SWITCH, "c", "crash", "Launch in crash mode.", wxCMD_LINE_VAL_NONE, NULL },
{ wxCMD_LINE_SWITCH, "r", "report", "Launch in Report mode.", wxCMD_LINE_VAL_NONE, NULL }, { wxCMD_LINE_SWITCH, "r", "report", "Launch in Report mode.", wxCMD_LINE_VAL_NONE, NULL },
{ wxCMD_LINE_SWITCH, "x", "xml", "Dump XML file", wxCMD_LINE_VAL_NONE, NULL }, { wxCMD_LINE_SWITCH, "j", "json", "Dump JSON file", wxCMD_LINE_VAL_NONE, NULL },
{ wxCMD_LINE_SWITCH, "h", "help", "This help message", wxCMD_LINE_VAL_NONE, wxCMD_LINE_OPTION_HELP }, { wxCMD_LINE_SWITCH, "h", "help", "This help message", wxCMD_LINE_VAL_NONE, wxCMD_LINE_OPTION_HELP },
{ wxCMD_LINE_NONE, NULL, NULL, NULL, wxCMD_LINE_VAL_NONE, NULL} { wxCMD_LINE_NONE, NULL, NULL, NULL, wxCMD_LINE_VAL_NONE, NULL}
}; };
@ -91,9 +91,9 @@ bool Reporter::OnInit()
mFrame *frame = new mFrame(_("Aegisub Reporter")); mFrame *frame = new mFrame(_("Aegisub Reporter"));
// Report *r = new Report; // Report *r = new Report;
if (parser.Found("x")) { if (parser.Found("j")) {
r->Save("report.xml"); r->Save("report.json");
wxPrintf("Report saved to report.xml\n"); std::cout << "Report saved to report.json" << std::endl;
return false; return false;
} }
@ -160,6 +160,6 @@ void mFrame::Cancel(wxCommandEvent& WXUNUSED(event)) {
void mFrame::Submit(wxCommandEvent& WXUNUSED(event)) { void mFrame::Submit(wxCommandEvent& WXUNUSED(event)) {
Progress *progress = new Progress(this); Progress *progress = new Progress(this);
Upload *upload = new Upload(progress); Upload *upload = new Upload(progress);
upload->Report(_("./test.xml")); upload->Report(_("./test.json"));
} }

View file

@ -66,6 +66,5 @@
#include <wx/wx.h> #include <wx/wx.h>
#include <wx/wxchar.h> #include <wx/wxchar.h>
#include <wx/wxprec.h> #include <wx/wxprec.h>
#include <wx/xml/xml.h>
#endif #endif

View file

@ -33,13 +33,6 @@
/// @brief Contstructor /// @brief Contstructor
Report::Report() { Report::Report() {
ReportCreate();
}
/// @brief Create report layout and add contents.
/// @return Document.
Report::XMLReport Report::ReportCreate() {
json::Object root; json::Object root;
@ -132,10 +125,9 @@ Report::XMLReport Report::ReportCreate() {
osx["Model"] = json::String(p->HardwareModel()); osx["Model"] = json::String(p->HardwareModel());
#endif #endif
return doc;
} }
/// @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);
} }

View file

@ -21,7 +21,6 @@
#ifndef R_PRECOMP #ifndef R_PRECOMP
#include <map> #include <map>
#include <wx/xml/xml.h>
#include <wx/listctrl.h> #include <wx/listctrl.h>
#endif #endif
@ -33,43 +32,9 @@ public:
Report(); Report();
~Report() {}; ~Report() {};
/// Fill wxListView with report contents. /// Save JSON report to a file.
/// @param text pointer to text buffer
/// @param listview wxListview to fill
void Fill(wxString *text, wxListView *listView);
/// Save XML report to a file.
void Save(wxString file); void Save(wxString file);
private: private:
/// Comparison callback for nameMap.
struct lst_comp {
bool operator() (const wxString &a, const wxString &b) const { return a.Cmp(b) < 0; }
};
/// Map of internal XML elements to human readable names.
typedef std::map<wxString, wxString, lst_comp> nameMap;
/// element->human name pairs.
typedef std::pair<wxString, wxString> nPair;
/// Struct to hold generatex XML Report.
struct XMLReport {
wxXmlDocument *doc; /// Parent document.
wxXmlNode *report; /// Root node.
wxXmlNode *general; /// General.
wxXmlNode *aegisub; /// Aegisub related..
wxXmlNode *hardware; /// Hardware.
wxXmlNode *windows; /// Windows specific.
wxXmlNode *unixx; /// Unix specific.
wxXmlNode *osx; /// OS X specific.
};
XMLReport ReportCreate();
XMLReport doc;
void Add(wxXmlNode *parent, wxString node, wxString text);
const nameMap HumanNames();
nameMap nMap;
void ProcessNode(wxXmlNode *node, wxString *text, wxListView *listView);
wxLocale *locale; wxLocale *locale;
}; };

View file

@ -47,7 +47,7 @@ Upload::~Upload() {
} }
/// @brief Submit an XML report. /// @brief Submit a JSON report.
/// @param report filename of the report. /// @param report filename of the report.
void Upload::Report(wxString report) { void Upload::Report(wxString report) {
wxFile file(report, wxFile::read); wxFile file(report, wxFile::read);