From e1469154ea2359c0a468c2fc9ce61a13242c449d Mon Sep 17 00:00:00 2001 From: Thomas Goyne Date: Sat, 3 Oct 2009 17:16:52 +0000 Subject: [PATCH] Create vcproj for reporter and make it build (but not be very useful) on windows. Originally committed to SVN as r3610. --- .../build/reporter_2008/reporter_2008.vcproj | 474 ++++++++++++++++++ aegisub/reporter/aegisub.cpp | 5 + aegisub/reporter/aegisub.h | 1 - aegisub/reporter/libraries.cpp | 68 +++ aegisub/reporter/main.cpp | 8 +- aegisub/reporter/platform.cpp | 5 +- aegisub/reporter/r_pre.cpp | 23 + aegisub/reporter/r_pre.h | 6 + aegisub/reporter/report.cpp | 56 +-- aegisub/reporter/report.h | 2 +- aegisub/reporter/upload.cpp | 4 +- 11 files changed, 614 insertions(+), 38 deletions(-) create mode 100644 aegisub/build/reporter_2008/reporter_2008.vcproj create mode 100644 aegisub/reporter/libraries.cpp create mode 100644 aegisub/reporter/r_pre.cpp diff --git a/aegisub/build/reporter_2008/reporter_2008.vcproj b/aegisub/build/reporter_2008/reporter_2008.vcproj new file mode 100644 index 000000000..196548a8d --- /dev/null +++ b/aegisub/build/reporter_2008/reporter_2008.vcproj @@ -0,0 +1,474 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/aegisub/reporter/aegisub.cpp b/aegisub/reporter/aegisub.cpp index 815e95367..dc813bbb7 100644 --- a/aegisub/reporter/aegisub.cpp +++ b/aegisub/reporter/aegisub.cpp @@ -25,7 +25,12 @@ #endif #include "aegisub.h" + +#ifdef __WINDOWS__ +#include "../src/config.h" +#else #include "../acconf.h" +#endif Aegisub::Aegisub() { wxStandardPathsBase &paths = wxStandardPaths::Get(); diff --git a/aegisub/reporter/aegisub.h b/aegisub/reporter/aegisub.h index 32aaee499..da2950bbb 100644 --- a/aegisub/reporter/aegisub.h +++ b/aegisub/reporter/aegisub.h @@ -33,4 +33,3 @@ public: void Config(wxString config); wxString Read(wxString key); }; - diff --git a/aegisub/reporter/libraries.cpp b/aegisub/reporter/libraries.cpp new file mode 100644 index 000000000..b480e4875 --- /dev/null +++ b/aegisub/reporter/libraries.cpp @@ -0,0 +1,68 @@ +// Copyright (c) 2009, Amar Takhar +// +// Permission to use, copy, modify, and distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +// +// $Id: libraries.cpp 3601 2009-09-28 08:08:16Z verm $ + +/// @file libraries.cpp +/// @brief Pragmas for automatically linking in required libraries during Windows build +/// @ingroup base + +#if __VISUALC__ >= 1200 +// wxWidgets +#if wxCHECK_VERSION(2, 9, 0) +#ifdef __WXDEBUG__ +#pragma comment(lib, "wxzlibd.lib") +#pragma comment(lib, "wxpngd.lib") +#pragma comment(lib, "wxregexud.lib") +#pragma comment(lib, "wxbase29ud.lib") +#pragma comment(lib, "wxbase29ud_net.lib") +#pragma comment(lib, "wxmsw29ud_media.lib") +#pragma comment(lib, "wxmsw29ud_core.lib") +#pragma comment(lib, "wxmsw29ud_adv.lib") +#pragma comment(lib, "wxmsw29ud_gl.lib") +#pragma comment(lib, "wxmsw29ud_stc.lib") +#pragma comment(lib, "wxscintillad.lib") +#pragma comment(lib, "wxbase29ud_xml.lib") +#pragma comment(lib, "wxexpatd.lib") +#else +#pragma comment(lib, "wxzlib.lib") +#pragma comment(lib, "wxpng.lib") +#pragma comment(lib, "wxregexu.lib") +#pragma comment(lib, "wxbase29u.lib") +#pragma comment(lib, "wxbase29u_net.lib") +#pragma comment(lib, "wxmsw29u_media.lib") +#pragma comment(lib, "wxmsw29u_core.lib") +#pragma comment(lib, "wxmsw29u_adv.lib") +#pragma comment(lib, "wxmsw29u_gl.lib") +#pragma comment(lib, "wxmsw29u_stc.lib") +#pragma comment(lib, "wxscintilla.lib") +#pragma comment(lib, "wxbase29u_xml.lib") +#pragma comment(lib, "wxexpat.lib") +#endif + +#else +#error "wxWidgets 2.9 is required" +#endif // wxWidgets + +// Standard Win32 Libraries +#pragma comment(lib, "comctl32.lib") +#pragma comment(lib, "rpcrt4.lib") +#pragma comment(lib, "ws2_32.lib") +#pragma comment(lib, "winmm.lib") +#pragma comment(lib, "wldap32.lib") + +#pragma comment(lib, "libcurl.lib") + +#endif // VisualC + diff --git a/aegisub/reporter/main.cpp b/aegisub/reporter/main.cpp index 68695d4e4..5f02459ab 100644 --- a/aegisub/reporter/main.cpp +++ b/aegisub/reporter/main.cpp @@ -77,7 +77,7 @@ bool Reporter::OnInit() wxLocale *locale = new wxLocale(); locale->Init(wxLANGUAGE_ENGLISH); #ifdef __WINDOWS__ - locale->AddCatalogLookupPathPrefix(StandardPaths::DecodePath(_T("?data/locale"))); + //locale->AddCatalogLookupPathPrefix(Aegisub::DecodePath(_T("?data/locale"))); locale->AddCatalog(_T("reporter")); #else locale->AddCatalog("reporter"); @@ -86,7 +86,6 @@ bool Reporter::OnInit() setlocale(LC_NUMERIC, "C"); setlocale(LC_CTYPE, "C"); - mFrame *frame = new mFrame(_("Aegisub Reporter")); Report *r = new Report; @@ -96,7 +95,6 @@ bool Reporter::OnInit() return false; } - SetTopWindow(frame); frame->SetReport(r); @@ -158,8 +156,8 @@ void mFrame::Cancel(wxCommandEvent& WXUNUSED(event)) { /// @brief Submit report void mFrame::Submit(wxCommandEvent& WXUNUSED(event)) { - Progress *progress = new Progress::Progress(this); - Upload *upload = new Upload::Upload(progress); + Progress *progress = new Progress(this); + Upload *upload = new Upload(progress); upload->Report(_("./test.xml")); } diff --git a/aegisub/reporter/platform.cpp b/aegisub/reporter/platform.cpp index 18e2bf736..b16481474 100644 --- a/aegisub/reporter/platform.cpp +++ b/aegisub/reporter/platform.cpp @@ -45,7 +45,6 @@ extern "C" { /// @brief Constructor. Platform* Platform::GetPlatform() { - #ifdef __UNIX__ # if defined(__FREEBSD__) Platform *p = new PlatformUnixBSD; @@ -56,6 +55,8 @@ Platform* Platform::GetPlatform() { # else Platform *p = new PlatformUnix; # endif +#else + Platform *p = NULL; #endif // __UNIX__ p->Init(); return p; @@ -160,9 +161,11 @@ wxString Platform::Signature() { return ""; } +#ifdef __UNIX__ wxString Platform::DesktopEnvironment() { return ""; } +#endif wxString Platform::OpenGLVendor() { return GetVideoInfo(VIDEO_VENDOR); diff --git a/aegisub/reporter/r_pre.cpp b/aegisub/reporter/r_pre.cpp new file mode 100644 index 000000000..7bc4cfeae --- /dev/null +++ b/aegisub/reporter/r_pre.cpp @@ -0,0 +1,23 @@ +// Copyright (c) 2009, Amar Takhar +// +// Permission to use, copy, modify, and distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +// +// $Id: r_pre.h 3591 2009-09-27 03:12:17Z greg $ + +/// @file wx_pre.h +/// @brief Precompiled header. +/// @ingroup base + +#ifndef R_PRE +#include "r_pre.h" +#endif diff --git a/aegisub/reporter/r_pre.h b/aegisub/reporter/r_pre.h index c652d111d..8e8b0f107 100644 --- a/aegisub/reporter/r_pre.h +++ b/aegisub/reporter/r_pre.h @@ -18,8 +18,12 @@ /// @brief Precompiled header. /// @ingroup base +#ifdef __cplusplus + #define R_PRECOMP +#define _CRT_SECURE_NO_WARNINGS + // C + System. #include #include @@ -63,3 +67,5 @@ #include #include #include + +#endif diff --git a/aegisub/reporter/report.cpp b/aegisub/reporter/report.cpp index 2efe5da3e..1d775a0f1 100644 --- a/aegisub/reporter/report.cpp +++ b/aegisub/reporter/report.cpp @@ -24,7 +24,7 @@ #endif #include "report.h" -#include "platform.h" +#include "include/platform.h" #include "aegisub.h" /// @brief Contstructor @@ -43,7 +43,7 @@ Report::XMLReport Report::ReportCreate() { doc.report = new wxXmlNode(wxXML_ELEMENT_NODE, "report"); doc.doc->SetRoot(doc.report); - Platform *p = Platform::GetPlatform(); + Platform *p = Platform::GetPlatform(); doc.general = new wxXmlNode(doc.report, wxXML_ELEMENT_NODE, "general"); Add(doc.general, "signature", p->Signature()); @@ -61,7 +61,7 @@ Report::XMLReport Report::ReportCreate() { doc.aegisub = new wxXmlNode(wxXML_ELEMENT_NODE, "aegisub"); doc.report->AddChild(doc.aegisub); - Aegisub *config = new Aegisub::Aegisub(); + Aegisub *config = new Aegisub(); Add(doc.aegisub, "lastversion", config->Read("Config/last version")); Add(doc.aegisub, "spelllang", config->Read("Config/spell checker language")); Add(doc.aegisub, "thesauruslang", config->Read("Config/thesaurus language")); @@ -81,29 +81,29 @@ Report::XMLReport Report::ReportCreate() { doc.report->AddChild(doc.hardware); Add(doc.hardware, "memory", p->Memory()); - 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 *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"); - doc.hardware->AddChild(display); - Add(display, "depth", p->DisplayDepth()); - Add(display, "colour", p->DisplayColour()); - Add(display, "size", p->DisplaySize()); - Add(display, "ppi", p->DisplayPPI()); + wxXmlNode *display = new wxXmlNode(wxXML_ELEMENT_NODE, "display"); + doc.hardware->AddChild(display); + Add(display, "depth", p->DisplayDepth()); + Add(display, "colour", p->DisplayColour()); + Add(display, "size", p->DisplaySize()); + Add(display, "ppi", p->DisplayPPI()); - wxXmlNode *display_gl = new wxXmlNode(wxXML_ELEMENT_NODE, "opengl"); - display->AddChild(display_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()); + 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__ doc.windows = new wxXmlNode(wxXML_ELEMENT_NODE, "windows"); @@ -111,8 +111,8 @@ Report::XMLReport Report::ReportCreate() { Add(doc.windows, "sp", p->ServicePack()); Add(doc.windows, "graphicsver", p->DriverGraphicsVersion()); Add(doc.windows, "dshowfilter", p->DirectShowFilters()); - Add(doc.windows, "antivirus", p->()); - Add(doc.windows, "firewall", p->()); + //Add(doc.windows, "antivirus", p->()); + //Add(doc.windows, "firewall", p->()); Add(doc.windows, "dll", p->DLLVersions()); #endif @@ -143,7 +143,7 @@ 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)); + tmp->AddChild(new wxXmlNode(wxXML_TEXT_NODE, node, text)); parent->AddChild(tmp); } @@ -172,7 +172,7 @@ void Report::ProcessNode(wxXmlNode *node, wxString *text, wxListView *listView) int depth = child->GetDepth(); if (child->GetChildren()->GetType() == wxXML_ELEMENT_NODE) { - int font_size = 15 - (round(depth * 2)); + 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)); @@ -195,7 +195,7 @@ void Report::ProcessNode(wxXmlNode *node, wxString *text, wxListView *listView) void Report::Fill(wxString *text, wxListView *listView) { listView->InsertColumn(0, _("Entry"), wxLIST_FORMAT_RIGHT); - listView->InsertColumn(1, _("Text"), wxLIST_FORMAT_LEFT, 100); + listView->InsertColumn(1, _("Text"), wxLIST_FORMAT_LEFT, 100); ProcessNode(doc.report, text, listView); diff --git a/aegisub/reporter/report.h b/aegisub/reporter/report.h index a80739dcc..1356d33fc 100644 --- a/aegisub/reporter/report.h +++ b/aegisub/reporter/report.h @@ -44,7 +44,7 @@ public: private: /// Comparison callback for nameMap. struct lst_comp { - bool operator() (const wxString &a, const wxString &b) { return a.Cmp(b) < 0; } + bool operator() (const wxString &a, const wxString &b) const { return a.Cmp(b) < 0; } }; /// Map of internal XML elements to human readable names. diff --git a/aegisub/reporter/upload.cpp b/aegisub/reporter/upload.cpp index d239d5915..26967cbc5 100644 --- a/aegisub/reporter/upload.cpp +++ b/aegisub/reporter/upload.cpp @@ -63,11 +63,11 @@ int Upload::CBProgress(void *p, double dlt, double dln, double ult, double uln) if (uln > 0) { Progress *progress = (Progress*) p; // Update returns false if the user has hit abort. - if (progress->Update(round(ult / uln) * 100) == false) + if (!progress->Update(floor(ult / uln + 0.5) * 100)) // Returning non-zero will cause curl to abort the transfer. return 1; } - return 0; + return 0; }