dd the beginings of the Aegisub Reporter, this is my first C++ program from scratch. (yes, that's a disclaimer)

What's left to be done:
  * Crash support. (only works for 'reports')
  * UI cleanups.
  * Interfacing with Aegisub to get proper metrics.
  * OSX support.
  * Windows support. (someone else will have to do this)
  * Server-side code.

There's probably a lot of other things I'm forgetting, anyone is free to commit to this, if you want to make major changes let me know beforehand.

Originally committed to SVN as r3475.
This commit is contained in:
Amar Takhar 2009-09-03 06:53:55 +00:00
parent 1155d1bcf8
commit 930f593d6a
24 changed files with 1943 additions and 8 deletions

View file

@ -22,7 +22,7 @@ m4_define([libswscale_required_version], [0.7.1]) # (r18642)
m4_define([lua_auto4_required_version], [5.1]) m4_define([lua_auto4_required_version], [5.1])
m4_define([portaudio_required_version], [19]) m4_define([portaudio_required_version], [19])
m4_define([pulseaudio_required_version], [0.5]) m4_define([pulseaudio_required_version], [0.5])
m4_define([curl_required_version], [7.19.2])
m4_define([fontconfig_required_version], [2.4]) m4_define([fontconfig_required_version], [2.4])
m4_define([freetype_required_version], [9.7.0]) m4_define([freetype_required_version], [9.7.0])
m4_define([pkgconfig_required_version], [0.20]) m4_define([pkgconfig_required_version], [0.20])
@ -333,6 +333,22 @@ if test "$agi_cv_with_openglu" = "no" && test "$build_darwin" != "yes"; then
AC_MSG_FAILURE([Please install a working OpenGL GLU library.]) AC_MSG_FAILURE([Please install a working OpenGL GLU library.])
fi fi
#######
## cURL
#######
PKG_CHECK_MODULES(LIBCURL, libcurl >= curl_required_version,,
[AC_MSG_FAILURE([aegisub requires >= cURL curl_required_version])])
AC_AGI_COMPILE([cURL], [curl], [$LIBCURL_CFLAGS], [$LIBCURL_LIBS],[
#include <curl/curl.h>
int main(void) {
CURL *handle = curl_easy_init();
}])
if test "$agi_cv_with_curl" = "no"; then
AC_MSG_FAILURE([Please install a working cURL library.])
fi
########### ###########
## Freetype ## Freetype
@ -1109,17 +1125,18 @@ AM_CONDITIONAL([FOUND_VIDEO_PROVIDER], [test "$found_video_provider" = "yes"])
# Makefiles # Makefiles
AC_CONFIG_FILES([ AC_CONFIG_FILES([
Makefile Makefile
automation/Makefile
desktop/Makefile
libass/Makefile
libffms/Makefile
po/Makefile.in
reporter/Makefile
src/Makefile src/Makefile
src/bitmaps/Makefile src/bitmaps/Makefile
src/libresrc/Makefile
src/libosxutil/Makefile src/libosxutil/Makefile
universalchardet/Makefile src/libresrc/Makefile
libffms/Makefile
libass/Makefile
automation/Makefile
po/Makefile.in
desktop/Makefile
tools/Makefile tools/Makefile
universalchardet/Makefile
]) ])
# Files that need substitution. # Files that need substitution.

View file

@ -0,0 +1,38 @@
AUTOMAKE_OPTIONS = foreign
AM_CXXFLAGS =
bin_PROGRAMS = reporter
if PRECOMPILED_HEADER
BUILT_SOURCES = wx_pre.h.gch
AM_CXXFLAGS += -include wx_pre.h -Winvalid-pch -fpch-deps -fpch-preprocess
nodist_reporter_SOURCES = wx_prec.h.gch
endif
reporter_CPPFLAGS = -Iinclude @LIBCURL_CFLAGS@ @WX_CPPFLAGS@
reporter_LDFLAGS = @WX_LIBS@ @LIBCURL_LIBS@
if PRECOMPILED_HEADER
# This doesn't depend on Makefile on purpose, you should already know what you're doing when using this.
wx_pre.h.gch: wx_pre.h
@CXX@ @WX_CPPFLAGS@ @CXXFLAGS@ @DEBUG_FLAGS@ wx_pre.h
endif
reporter_SOURCES = \
aegisub.cpp \
main.cpp \
name_map.cpp \
platform.cpp \
platform_unix.cpp \
platform_unix_bsd.cpp \
progress.cpp \
report.cpp \
upload.cpp \
view.cpp
reporter_SOURCES += \
*.h \
include/*.h

View file

@ -0,0 +1,47 @@
// Copyright (c) 2009, Amar Takhar <verm@aegisub.org>
//
// 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$
/// @@file aegisub.cpp
/// @brief Aegisub specific configuration options and properties.
#ifndef R_PRECOMP
#include <wx/fileconf.h>
#include <wx/wfstream.h>
#include <wx/stdpaths.h>
#endif
#include "aegisub.h"
#include "../acconf.h"
Aegisub::Aegisub() {
wxStandardPathsBase &paths = wxStandardPaths::Get();
// Using ifdefs is a pain but it's much easier to centralise this.
#ifdef __UNIX__
wxString configdir = wxString::Format("%s/.aegisub-%s", paths.GetUserConfigDir(), _T(AEGISUB_VERSION_DATA));
#elif __APPLE__
wxString configdir = wxString::Format("%s/Aegisub-%s", paths.GetUserConfigDir(), _T(AEGISUB_VERSION_DATA));
#else
wxString configdir = wxString::Format("%s/Aegisub", paths.GetUserConfigDir());
#endif
wxFileInputStream file(wxString::Format("%s/config.dat", configdir));
conf = new wxFileConfig(file);
conf->SetExpandEnvVars(false);
}
wxString Aegisub::Read(wxString key) {
return conf->Read(key);
}

View file

@ -0,0 +1,29 @@
// Copyright (c) 2009, Amar Takhar <verm@aegisub.org>
//
// 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$
/// @@file aegisub.h
/// @see aegisub.cpp
class Aegisub {
private:
wxFileConfig *conf;
public:
Aegisub();
~Aegisub();
void Config(wxString config);
wxString Read(wxString key);
};

View file

@ -0,0 +1,103 @@
// Copyright (c) 2009, Amar Takhar <verm@aegisub.org>
//
// 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$
/// @@file platform.h
/// @brief API for gathering platform information.
/// @see platform.cpp
#ifndef R_PRECOMP
#include <wx/platinfo.h>
#include <wx/string.h>
#endif
/// @brief Grab platform-specific information.
class Platform {
public:
/// @brief Constructor
Platform() {};
/// @brief Destructor
virtual ~Platform() {};
// Get platform instance.
static Platform* GetPlatform();
// These are platform agnostic.
// From wxPlatformInfo
wxString ArchName(); /// Architecture
wxString OSFamily(); /// OS Family
wxString OSName(); /// OS Name
wxString Endian(); /// Endian
// From <wx/gdicmn.h>
wxString DisplayColour(); /// Is the display colour?
wxString DisplayDepth(); /// Depth
wxString DisplaySize(); /// Size
wxString DisplayPPI(); /// Pixels Per Inch
// Misc
wxString Signature(); /// Report signature.
wxString wxVersion(); /// wxWidgets version.
wxString Locale(); /// Locale
wxString Language(); /// Language currently in use
wxString SystemLanguage(); /// System language
wxString Date(); /// Date
wxString Time(); /// Time
wxString TimeZone(); /// TimeZone
// The following are all platform-specific.
// Misc
virtual wxString OSVersion()=0;
// Hardware
virtual wxString CPUId()=0;
virtual wxString CPUSpeed()=0;
virtual wxString CPUCount()=0;
virtual wxString CPUCores()=0;
virtual wxString CPUFeatures()=0;
virtual wxString CPUFeatures2()=0;
virtual wxString Memory()=0;
virtual wxString Video()=0;
// Windows
#ifdef __WINDOWS__
virtual wxString ServicePack()=0;
virtual wxString DriverGraphicsVersion()=0;
virtual wxString DirectShowFilters()=0;
virtual wxString AntiVirus()=0;
virtual wxString FireWall()=0;
virtual wxString DLLVersions()=0;
#endif
// Unix
#ifdef __UNIX__
virtual wxString UnixLibraries()=0;
virtual wxString DesktopEnvironment()=0;
#endif
// OS X
#ifdef __OSX__
virtual wxString PatchLevel()=0;
virtual wxString QuickTimeExt()=0;
virtual wxString HardwareModel()=0;
#endif
private:
void Init();
const wxPlatformInfo plat;
wxLocale *locale;
};

149
aegisub/reporter/main.cpp Normal file
View file

@ -0,0 +1,149 @@
// Copyright (c) 2009, Amar Takhar <verm@aegisub.org>
//
// 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$
/// @@file main.cpp
/// @brief Main loop
#ifndef R_PRECOMP
#include <wx/app.h>
#include <wx/window.h>
#include <wx/log.h>
#include <wx/cmdline.h>
#include <wx/wxchar.h>
#include <wx/sizer.h>
#include <wx/stattext.h>
#include <wx/panel.h>
#include <wx/font.h>
#include <wx/button.h>
#include <wx/textctrl.h>
#include <wx/intl.h>
#endif
#include <locale.h>
#include "main.h"
#include "view.h"
#include "upload.h"
/// @brief Init the reporter.
bool Reporter::OnInit()
{
if ( !wxApp::OnInit() )
return false;
wxApp::CheckBuildOptions(WX_BUILD_OPTIONS_SIGNATURE, _("Reporter"));
static const wxCmdLineEntryDesc cmdLineDesc[] = {
{ 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, "h", "help", "This help message", wxCMD_LINE_VAL_NONE, wxCMD_LINE_OPTION_HELP },
{ wxCMD_LINE_NONE, NULL, NULL, NULL, wxCMD_LINE_VAL_NONE, NULL}
};
wxCmdLineParser parser(cmdLineDesc, argc, argv);
switch ( parser.Parse() ) {
case -1:
break; // Help
case 0:
break; // OK
default:
wxLogMessage(_T("Syntax error."));
break;
}
setlocale(LC_NUMERIC, "C");
setlocale(LC_CTYPE, "C");
wxLocale *locale = new wxLocale();
locale->Init(wxLANGUAGE_ENGLISH);
#ifdef __WINDOWS__
locale->AddCatalogLookupPathPrefix(StandardPaths::DecodePath(_T("?data/locale")));
locale->AddCatalog(_T("reporter"));
#else
locale->AddCatalog("reporter");
#endif
locale->AddCatalog(_T("wxstd"));
setlocale(LC_NUMERIC, "C");
setlocale(LC_CTYPE, "C");
mFrame *frame = new mFrame(_("Aegisub Reporter"));
SetTopWindow(frame);
Report *r = new Report;
frame->SetReport(r);
return true;
}
/// Main frame.
/// @param window_title Window title.
mFrame::mFrame(const wxString &window_title)
: wxFrame(NULL, wxID_ANY, window_title, wxDefaultPosition, wxSize(300,-1)) {
wxBoxSizer *topSizer = new wxBoxSizer(wxVERTICAL);
wxStaticBoxSizer *msgSizer = new wxStaticBoxSizer(wxVERTICAL, this, "");
topSizer->Add(msgSizer, 1, wxALL, 5);
wxStaticText *title = new wxStaticText(this, -1,_("Welcome to the Aegisub Reporter!"), wxDefaultPosition, wxSize(325,-1), wxALIGN_CENTRE|wxST_NO_AUTORESIZE);
msgSizer->Add(title, 1, wxALL, 5);
title->SetFont(wxFont(11, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD));
wxStaticText *msg = new wxStaticText(this, -1,_("In order to better help us target development, and improve Aegisub we would like you to submit some information about your system and setup."));
msg->Wrap(325);
msgSizer->Add(msg, 1, wxALL, 5);
wxStaticText *notice = new wxStaticText(this, -1,_("This information is completely anonymous, no personal information is sent along it is strictly used for targeting new features and the future direction of Aegisub."));
notice->Wrap(325);
msgSizer->Add(notice, 1, wxALL, 5);
notice->SetFont(wxFont(11, wxFONTFAMILY_SWISS, wxFONTSTYLE_ITALIC, wxFONTWEIGHT_NORMAL));
msgSizer->Add(new wxButton(this, 42, "View Report"), 0, wxALL, 10 );
wxStdDialogButtonSizer *stdButton = new wxStdDialogButtonSizer();
stdButton->AddButton(new wxButton(this, wxID_OK, _("Submit")));
stdButton->AddButton(new wxButton(this, wxID_CANCEL, _("Cancel")));
stdButton->Realize();
topSizer->Add(stdButton, 1, wxALL, 5);
this->SetSizerAndFit(topSizer);
// Is there a better way to do this?
this->SetMinSize(wxSize(360,-1));
this->SetMaxSize(this->GetEffectiveMinSize());
this->SetMinSize(this->GetEffectiveMinSize());
this->Show(true);
}
/// @brief View report.
void mFrame::ReportView(wxCommandEvent& WXUNUSED(event)) {
View View(this, r);
View.ShowModal();
}
/// @brief Cancel reporter.
void mFrame::Cancel(wxCommandEvent& WXUNUSED(event)) {
Close(true);
}
/// @brief Submit report
void mFrame::Submit(wxCommandEvent& WXUNUSED(event)) {
Progress *progress = new Progress::Progress(this);
Upload *upload = new Upload::Upload(progress);
upload->Report(_("./test.xml"));
}

61
aegisub/reporter/main.h Normal file
View file

@ -0,0 +1,61 @@
// Copyright (c) 2009, Amar Takhar <verm@aegisub.org>
//
// 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$
/// @@file main.h
/// @see main.cpp
#ifndef R_PRECOMP
#include <wx/frame.h>
#include <wx/event.h>
#include <wx/window.h>
#include <wx/dialog.h>
#include <wx/progdlg.h>
#endif
#include "report.h"
/// @brief Reporter
class Reporter : public wxApp {
public:
virtual bool OnInit();
private:
Report *r;
};
IMPLEMENT_APP(Reporter)
/// @brief Main frame.
class mFrame : public wxFrame {
public:
mFrame(const wxString& window_title);
void Submit(wxCommandEvent& event);
void Cancel(wxCommandEvent& event);
void ReportView(wxCommandEvent& event);
void SetReport(Report *report) { r = report; }
private:
Report *r;
DECLARE_EVENT_TABLE()
};
BEGIN_EVENT_TABLE(mFrame, wxFrame)
EVT_BUTTON(wxID_OK, mFrame::Submit)
EVT_BUTTON(wxID_CANCEL, mFrame::Cancel)
EVT_BUTTON(42, mFrame::ReportView)
END_EVENT_TABLE()

View file

@ -0,0 +1,88 @@
// Copyright (c) 2009, Amar Takhar <verm@aegisub.org>
//
// 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$
/// @@file name_map.cpp
/// @brief XML element -> human readable name mappings.
#include "report.h"
#define _TT(x) x /// No-op macro for nMap.
/// @brief Load readable names of XML elements.
const Report::nameMap Report::HumanNames() {
nameMap nMap;
nMap.insert(nPair("antivirus", _TT("AntiVirus Installed")));
nMap.insert(nPair("arch", _TT("Architecture")));
nMap.insert(nPair("colour", _TT("Colour Screen")));
nMap.insert(nPair("colour", _TT("Colour")));
nMap.insert(nPair("cores", _TT("Cores")));
nMap.insert(nPair("count", _TT("Count")));
nMap.insert(nPair("cpu", _TT("CPU")));
nMap.insert(nPair("depth", _TT("Depth")));
nMap.insert(nPair("display", _TT("Display")));
nMap.insert(nPair("dll", _TT("DLL")));
nMap.insert(nPair("dshowfilter", _TT("DirectShow Filters")));
nMap.insert(nPair("features", _TT("Features")));
nMap.insert(nPair("features2", _TT("Features2")));
nMap.insert(nPair("firewall", _TT("Firewall Installed")));
nMap.insert(nPair("general", _TT("General")));
nMap.insert(nPair("graphicsver", _TT("Graphics Driver Version")));
nMap.insert(nPair("hardware", _TT("Hardware")));
nMap.insert(nPair("id", _TT("Id")));
nMap.insert(nPair("lang", _TT("Language")));
nMap.insert(nPair("lib", _TT("Libraries")));
nMap.insert(nPair("locale", _TT("Locale")));
nMap.insert(nPair("memory", _TT("Memory")));
nMap.insert(nPair("model", _TT("Model")));
nMap.insert(nPair("osendian", _TT("Endian")));
nMap.insert(nPair("osfamily", _TT("OS Family")));
nMap.insert(nPair("osname", _TT("OS Name")));
nMap.insert(nPair("osx", _TT("OS X")));
nMap.insert(nPair("osversion", _TT("OS Version")));
nMap.insert(nPair("patch", _TT("Patch")));
nMap.insert(nPair("ppi", _TT("Pixels Per Inch")));
nMap.insert(nPair("quicktimeext", _TT("QuickTime Extensions")));
nMap.insert(nPair("size", _TT("Size")));
nMap.insert(nPair("sp", _TT("Service Pack")));
nMap.insert(nPair("speed", _TT("Speed")));
nMap.insert(nPair("syslang", _TT("System Language")));
nMap.insert(nPair("unix", _TT("Unix")));
nMap.insert(nPair("video", _TT("Video")));
nMap.insert(nPair("windows", _TT("Windows")));
nMap.insert(nPair("wxversion", _TT("wx Version")));
nMap.insert(nPair("signature", _TT("Signature")));
nMap.insert(nPair("date", _TT("Date")));
nMap.insert(nPair("aegisub", _TT("Aegisub")));
nMap.insert(nPair("spelllang", _TT("Spelling Language")));
nMap.insert(nPair("lastversion", _TT("Last Version")));
nMap.insert(nPair("thesauruslang", _TT("Thesaurus Language")));
nMap.insert(nPair("audioplayer", _TT("Audio Player")));
nMap.insert(nPair("audioprovider", _TT("Audio Provider")));
nMap.insert(nPair("videoprovider", _TT("Video Provider")));
nMap.insert(nPair("subtitleprovider", _TT("Subtitles Provider")));
nMap.insert(nPair("savecharset", _TT("Save Charset")));
nMap.insert(nPair("gridfontsize", _TT("Grid Font Size")));
nMap.insert(nPair("editfontsize", _TT("Edit Font Size")));
nMap.insert(nPair("spectrum", _TT("Spectrum Enabled")));
nMap.insert(nPair("spectrumqual", _TT("Spectrum Quality")));
nMap.insert(nPair("calltips", _TT("Call Tips Enabled")));
nMap.insert(nPair("medusakeys", _TT("Medusa Hotkeys Enabled")));
nMap.insert(nPair("desktopenv", _TT("Desktop Environment")));
return nMap;
}

View file

@ -0,0 +1,112 @@
// Copyright (c) 2009, Amar Takhar <verm@aegisub.org>
//
// 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$
/// @@file platform.cpp
/// @brief Base functions for the Platform class.
#ifndef R_PRECOMP
#include <wx/gdicmn.h> // Display* functions.
#include <wx/version.h> // Version info.
#include <wx/intl.h> // Locale info.
#endif
#include "include/platform.h"
#include "platform_unix.h"
#include "platform_unix_bsd.h"
/// @brief Constructor.
Platform* Platform::GetPlatform() {
#ifdef __UNIX__
# ifdef __FREEBSD__
Platform *p = new PlatformUnixBSD;
# else
Platform *p = new PlatformUnix;
# endif
#endif // __UNIX__
p->Init();
return p;
}
/// @brief Init variables to avoid duplicate instantiations.
void Platform::Init() {
locale = new wxLocale();
locale->Init();
}
wxString Platform::ArchName() {
return plat.GetArchName();
};
wxString Platform::OSFamily() {
return plat.GetOperatingSystemFamilyName();
};
wxString Platform::OSName() {
return plat.GetOperatingSystemIdName();
};
wxString Platform::Endian() {
return plat.GetEndiannessName();
};
wxString Platform::DisplayColour() {
return wxString::Format(L"%d", wxColourDisplay());
}
wxString Platform::DisplayDepth() {
return wxString::Format(L"%d", wxDisplayDepth());
}
wxString Platform::DisplaySize() {
int x, y;
wxDisplaySize(&x, &y);
return wxString::Format(L"%d %d", x, y);
}
wxString Platform::DisplayPPI() {
return wxString::Format(L"%d %d", wxGetDisplayPPI().GetWidth(), wxGetDisplayPPI().GetHeight());
}
wxString Platform::wxVersion() {
return wxString::Format(L"%d.%d.%d.%d", wxMAJOR_VERSION, wxMINOR_VERSION, wxRELEASE_NUMBER, wxSUBRELEASE_NUMBER);
}
wxString Platform::Locale() {
return wxLocale().GetSysName();
}
wxString Platform::Language() {
const wxLanguageInfo *info = locale->GetLanguageInfo(locale->GetLanguage());
return info->CanonicalName;
}
wxString Platform::SystemLanguage() {
const wxLanguageInfo *info = locale->GetLanguageInfo(locale->GetSystemLanguage());
return info->CanonicalName;
}
wxString Platform::Date() {
return "";
}
wxString Platform::Signature() {
return "";
}
wxString Platform::DesktopEnvironment() {
return "";
}

View file

@ -0,0 +1,78 @@
// Copyright (c) 2009, Amar Takhar <verm@aegisub.org>
//
// 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$
/// @@file platform_unix.cpp
/// @brief Unix Platform extension.
#ifndef R_PRECOMP
#include <wx/string.h>
#include <wx/apptrait.h>
#endif
#include "include/platform.h"
#include "platform_unix.h"
extern "C" {
#include <sys/utsname.h>
}
wxString PlatformUnix::OSVersion() {
struct utsname name;
if (uname(&name) != -1) {
return name.release;
}
return "";
}
wxString PlatformUnix::DesktopEnvironment() {
return wxTheApp->GetTraits()->GetDesktopEnvironment();
}
wxString PlatformUnix::CPUId() {
return "";
};
wxString PlatformUnix::CPUSpeed() {
return "";
};
wxString PlatformUnix::CPUCores() {
return "";
};
wxString PlatformUnix::CPUCount() {
return "";
};
wxString PlatformUnix::CPUFeatures() {
return "";
};
wxString PlatformUnix::CPUFeatures2() {
return "";
};
wxString PlatformUnix::Memory() {
return "";
};
wxString PlatformUnix::Video() {
return "";
};
wxString PlatformUnix::UnixLibraries() {
return "";
};

View file

@ -0,0 +1,42 @@
// Copyright (c) 2009, Amar Takhar <verm@aegisub.org>
//
// 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$
/// @@file platform_unix.h
/// @brief @see platform_unix.cpp
class Platform;
/// @brief General Unix functions.
class PlatformUnix : public Platform {
public:
PlatformUnix() {};
virtual ~PlatformUnix() {};
wxString OSVersion();
wxString DesktopEnvironment();
// Hardware
virtual wxString CPUId();
virtual wxString CPUSpeed();
virtual wxString CPUCores();
virtual wxString CPUCount();
virtual wxString CPUFeatures();
virtual wxString CPUFeatures2();
virtual wxString Memory();
virtual wxString Video();
// Unix Specific
virtual wxString UnixLibraries();
};

View file

@ -0,0 +1,77 @@
// Copyright (c) 2009, Amar Takhar <verm@aegisub.org>
//
// 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$
/// @@file platform_unix_bsd.cpp
/// @brief BSD Platform extensions.
#ifndef R_PRECOMP
#include <wx/string.h>
#endif
#include "include/platform.h"
#include "platform_unix.h"
#include "platform_unix_bsd.h"
extern "C" {
#include <sys/utsname.h>
#include <sys/types.h>
#include <sys/sysctl.h>
}
wxString PlatformUnixBSD::CPUId() {
char id[300];
size_t len = sizeof(id);
sysctlbyname("hw.model", &id, &len, NULL, 0);
return wxString::Format("%s", id);
};
wxString PlatformUnixBSD::CPUSpeed() {
return "";
};
wxString PlatformUnixBSD::CPUCores() {
return "";
};
wxString PlatformUnixBSD::CPUCount() {
int proc;
size_t len = sizeof(proc);
sysctlbyname("hw.ncpu", &proc, &len, NULL, 0);
return wxString::Format("%d", proc);
};
wxString PlatformUnixBSD::CPUFeatures() {
return "";
};
wxString PlatformUnixBSD::CPUFeatures2() {
return "";
};
wxString PlatformUnixBSD::Memory() {
uint64_t memory;
size_t len = sizeof(memory);
sysctlbyname("hw.physmem", &memory, &len, NULL, 0);
return wxString::Format("%d", memory);
return "";
};
wxString PlatformUnixBSD::Video() {
return "";
};
wxString PlatformUnixBSD::UnixLibraries() {
return "";
};

View file

@ -0,0 +1,40 @@
// Copyright (c) 2009, Amar Takhar <verm@aegisub.org>
//
// 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$
/// @@file platform_unix_bsd.h
/// @brief @see platform_unix_bsd.cpp
class Platform;
/// @brief BSD values.
class PlatformUnixBSD : public PlatformUnix {
public:
PlatformUnixBSD() {};
virtual ~PlatformUnixBSD() {};
// Hardware
virtual wxString CPUId();
virtual wxString CPUSpeed();
virtual wxString CPUCores();
virtual wxString CPUCount();
virtual wxString CPUFeatures();
virtual wxString CPUFeatures2();
virtual wxString Memory();
virtual wxString Video();
// Unix Specific
virtual wxString UnixLibraries();
};

View file

@ -0,0 +1,40 @@
// Copyright (c) 2009, Amar Takhar <verm@aegisub.org>
//
// 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$
/// @@file progress.cpp
/// @brief Progress bar when uploading data.
#include "progress.h"
/// @brief Constructor
/// @param frame Main frame.
Progress::Progress(wxWindow *frame)
: wxProgressDialog(_("Progress"), _("Sending data, please wait."), 100, frame, wxPD_CAN_ABORT|wxPD_ELAPSED_TIME|wxPD_ESTIMATED_TIME|wxPD_REMAINING_TIME|wxPD_AUTO_HIDE) {
}
/// @brief Cancel the transfer.
/// This closes the dialog.
void Progress::Cancel(wxCommandEvent& WXUNUSED(event)) {
printf("close");
Destroy();
}
BEGIN_EVENT_TABLE(Progress, wxProgressDialog)
EVT_BUTTON(wxID_CLOSE, Progress::Cancel)
EVT_BUTTON(wxID_CANCEL, Progress::Cancel)
EVT_CLOSE(Progress::Close)
END_EVENT_TABLE()

View file

@ -0,0 +1,31 @@
// Copyright (c) 2009, Amar Takhar <verm@aegisub.org>
//
// 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$
/// @@file progress.h
/// @see progress.cpp
/// @class Progress
/// @brief Progress bar.
/// @note The Constructor decleration is in main.cpp
class Progress: public wxProgressDialog {
public:
Progress(wxWindow *frame);
private:
/// @brief No-op incase the user hits the window manager close button.
void Close(wxCloseEvent &event) {};
void Cancel(wxCommandEvent& event);
DECLARE_EVENT_TABLE()
};

205
aegisub/reporter/report.cpp Normal file
View file

@ -0,0 +1,205 @@
// Copyright (c) 2009, Amar Takhar <verm@aegisub.org>
//
// 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$
/// @@file report.cpp
/// @brief Generation and manipulation of reports.
#ifndef R_PRECOMP
#include <wx/intl.h>
#endif
#include "report.h"
#include "platform.h"
#include "aegisub.h"
/// @brief Contstructor
Report::Report() {
ReportCreate();
}
/// @brief Create report layout and add contents.
/// @return Document.
Report::XMLReport Report::ReportCreate() {
// So we can use GetString() below.
locale = new wxLocale();
doc.doc = new wxXmlDocument();
doc.report = new wxXmlNode(wxXML_ELEMENT_NODE, "report");
doc.doc->SetRoot(doc.report);
Platform *p = Platform::GetPlatform();
doc.general = new wxXmlNode(doc.report, wxXML_ELEMENT_NODE, "general");
Add(doc.general, "signature", p->Signature());
Add(doc.general, "date", p->Date());
Add(doc.general, "arch", p->ArchName());
Add(doc.general, "osfamily", p->OSFamily());
Add(doc.general, "osname", p->OSName());
Add(doc.general, "osendian", p->Endian());
Add(doc.general, "osversion", p->OSVersion());
Add(doc.general, "wxversion", p->wxVersion());
Add(doc.general, "locale", p->Locale());
Add(doc.general, "lang", p->Language());
Add(doc.general, "syslang", p->SystemLanguage());
doc.aegisub = new wxXmlNode(wxXML_ELEMENT_NODE, "aegisub");
doc.report->AddChild(doc.aegisub);
Aegisub *config = new Aegisub::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"));
Add(doc.aegisub, "audioplayer", config->Read("Config/audio player"));
Add(doc.aegisub, "audioprovider", config->Read("Config/audio provider"));
Add(doc.aegisub, "videoprovider", config->Read("Config/video provider"));
Add(doc.aegisub, "subtitleprovider", config->Read("Config/subtitles provider"));
Add(doc.aegisub, "savecharset", config->Read("Config/save charset"));
Add(doc.aegisub, "gridfontsize", config->Read("Config/grid font size"));
Add(doc.aegisub, "editfontsize", config->Read("Config/edit font size"));
Add(doc.aegisub, "spectrum", config->Read("Config/audio spectrum"));
Add(doc.aegisub, "spectrumqual", config->Read("Config/audio spectrum quality"));
Add(doc.aegisub, "calltips", config->Read("Config/call tips enabled"));
Add(doc.aegisub, "medusakeys", config->Read("Config/audio medusa timing hotkeys"));
doc.hardware = new wxXmlNode(wxXML_ELEMENT_NODE, "hardware");
doc.report->AddChild(doc.hardware);
Add(doc.hardware, "memory", p->Memory());
Add(doc.hardware, "video", p->Video());
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());
#ifdef __WINDOWS__
doc.windows = new wxXmlNode(wxXML_ELEMENT_NODE, "windows");
doc.report->AddChild(doc.windows);
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, "dll", p->DLLVersions());
#endif
#ifdef __UNIX__
doc.unixx = new wxXmlNode(wxXML_ELEMENT_NODE, "unix");
doc.report->AddChild(doc.unixx);
Add(doc.unixx, "desktopenv", p->DesktopEnvironment());
Add(doc.unixx, "lib", p->UnixLibraries());
#endif
#ifdef __APPLE__
doc.osx = new wxXmlNode(wxXML_ELEMENT_NODE, "osx");
doc.report->AddChild(doc.osx);
Add(doc.osx, "patch", p->PatchLevel);
Add(doc.osx, "quicktimeext", p->QuickTimeExt);
Add(doc.osx, "model", p->HardwareModel);
#endif
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(std::string(name.utf8_str()))) != 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 - (round(depth * 2.5));
int bgcolour = 185 + (depth * 25);
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();
}
}
/// @brief Fill wxListView with report contents.
/// @param listview wxListview to fill.
void Report::Fill(wxString *text, wxListView *listView) {
listView->InsertColumn(0, _("Entry"), wxLIST_FORMAT_RIGHT);
listView->InsertColumn(1, _("Text"), wxLIST_FORMAT_LEFT, 100);
//wxString *text = new wxString();
ProcessNode(doc.report, text, listView);
listView->SetColumnWidth(0, wxLIST_AUTOSIZE);
listView->SetColumnWidth(1, wxLIST_AUTOSIZE);
}
/// @brief Return Report as Text for the Clipboard.
wxString Report::AsText() {
return "not implimented.";
}

62
aegisub/reporter/report.h Normal file
View file

@ -0,0 +1,62 @@
// Copyright (c) 2009, Amar Takhar <verm@aegisub.org>
//
// 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$
/// @@file report.h
/// @see report.cpp
#ifndef R_PRECOMP
#include <wx/xml/xml.h>
#include <wx/listctrl.h>
#endif
#include <map>
#pragma once
class Report {
public:
Report();
~Report() {};
void Fill(wxString *text, wxListView *listView);
wxString AsText();
private:
struct lst_comp {
bool operator() (const wxString &a, const wxString &b) { return a.Cmp(b) < 0; }
};
typedef std::map<std::string, std::string, lst_comp> nameMap;
typedef std::pair<std::string, std::string> nPair;
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;
};

315
aegisub/reporter/sha256.c Normal file
View file

@ -0,0 +1,315 @@
/*-
* Copyright 2005 Colin Percival
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $FreeBSD: src/lib/libmd/sha256c.c,v 1.1 2005/03/09 19:23:04 cperciva Exp $
* $Id$
*/
#include <string.h>
#include "sha256.h"
static __inline uint32_t
be32dec(const void *pp)
{
unsigned char const *p = (unsigned char const *)pp;
return ((p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3]);
}
static __inline void
be32enc(void *pp, uint32_t u)
{
unsigned char *p = (unsigned char *)pp;
p[0] = (u >> 24) & 0xff;
p[1] = (u >> 16) & 0xff;
p[2] = (u >> 8) & 0xff;
p[3] = u & 0xff;
}
#if BYTE_ORDER == BIG_ENDIAN
/* Copy a vector of big-endian uint32_t into a vector of bytes */
#define be32enc_vect(dst, src, len) \
memcpy((void *)dst, (const void *)src, (size_t)len)
/* Copy a vector of bytes into a vector of big-endian uint32_t */
#define be32dec_vect(dst, src, len) \
memcpy((void *)dst, (const void *)src, (size_t)len)
#else /* BYTE_ORDER != BIG_ENDIAN */
/*
* Encode a length len/4 vector of (uint32_t) into a length len vector of
* (unsigned char) in big-endian form. Assumes len is a multiple of 4.
*/
static void
be32enc_vect(unsigned char *dst, const uint32_t *src, size_t len)
{
size_t i;
for (i = 0; i < len / 4; i++)
be32enc(dst + i * 4, src[i]);
}
/*
* Decode a big-endian length len vector of (unsigned char) into a length
* len/4 vector of (uint32_t). Assumes len is a multiple of 4.
*/
static void
be32dec_vect(uint32_t *dst, const unsigned char *src, size_t len)
{
size_t i;
for (i = 0; i < len / 4; i++)
dst[i] = be32dec(src + i * 4);
}
#endif /* BYTE_ORDER != BIG_ENDIAN */
/* Elementary functions used by SHA256 */
#define Ch(x, y, z) ((x & (y ^ z)) ^ z)
#define Maj(x, y, z) ((x & (y | z)) | (y & z))
#define SHR(x, n) (x >> n)
#define ROTR(x, n) ((x >> n) | (x << (32 - n)))
#define S0(x) (ROTR(x, 2) ^ ROTR(x, 13) ^ ROTR(x, 22))
#define S1(x) (ROTR(x, 6) ^ ROTR(x, 11) ^ ROTR(x, 25))
#define s0(x) (ROTR(x, 7) ^ ROTR(x, 18) ^ SHR(x, 3))
#define s1(x) (ROTR(x, 17) ^ ROTR(x, 19) ^ SHR(x, 10))
/* SHA256 round function */
#define RND(a, b, c, d, e, f, g, h, k) \
t0 = h + S1(e) + Ch(e, f, g) + k; \
t1 = S0(a) + Maj(a, b, c); \
d += t0; \
h = t0 + t1;
/* Adjusted round function for rotating state */
#define RNDr(S, W, i, k) \
RND(S[(64 - i) % 8], S[(65 - i) % 8], \
S[(66 - i) % 8], S[(67 - i) % 8], \
S[(68 - i) % 8], S[(69 - i) % 8], \
S[(70 - i) % 8], S[(71 - i) % 8], \
W[i] + k)
/*
* SHA256 block compression function. The 256-bit state is transformed via
* the 512-bit input block to produce a new state.
*/
static void
SHA256_Transform(uint32_t * state, const unsigned char block[64])
{
uint32_t W[64];
uint32_t S[8];
uint32_t t0, t1;
int i;
/* 1. Prepare message schedule W. */
be32dec_vect(W, block, 64);
for (i = 16; i < 64; i++)
W[i] = s1(W[i - 2]) + W[i - 7] + s0(W[i - 15]) + W[i - 16];
/* 2. Initialize working variables. */
memcpy(S, state, 32);
/* 3. Mix. */
RNDr(S, W, 0, 0x428a2f98);
RNDr(S, W, 1, 0x71374491);
RNDr(S, W, 2, 0xb5c0fbcf);
RNDr(S, W, 3, 0xe9b5dba5);
RNDr(S, W, 4, 0x3956c25b);
RNDr(S, W, 5, 0x59f111f1);
RNDr(S, W, 6, 0x923f82a4);
RNDr(S, W, 7, 0xab1c5ed5);
RNDr(S, W, 8, 0xd807aa98);
RNDr(S, W, 9, 0x12835b01);
RNDr(S, W, 10, 0x243185be);
RNDr(S, W, 11, 0x550c7dc3);
RNDr(S, W, 12, 0x72be5d74);
RNDr(S, W, 13, 0x80deb1fe);
RNDr(S, W, 14, 0x9bdc06a7);
RNDr(S, W, 15, 0xc19bf174);
RNDr(S, W, 16, 0xe49b69c1);
RNDr(S, W, 17, 0xefbe4786);
RNDr(S, W, 18, 0x0fc19dc6);
RNDr(S, W, 19, 0x240ca1cc);
RNDr(S, W, 20, 0x2de92c6f);
RNDr(S, W, 21, 0x4a7484aa);
RNDr(S, W, 22, 0x5cb0a9dc);
RNDr(S, W, 23, 0x76f988da);
RNDr(S, W, 24, 0x983e5152);
RNDr(S, W, 25, 0xa831c66d);
RNDr(S, W, 26, 0xb00327c8);
RNDr(S, W, 27, 0xbf597fc7);
RNDr(S, W, 28, 0xc6e00bf3);
RNDr(S, W, 29, 0xd5a79147);
RNDr(S, W, 30, 0x06ca6351);
RNDr(S, W, 31, 0x14292967);
RNDr(S, W, 32, 0x27b70a85);
RNDr(S, W, 33, 0x2e1b2138);
RNDr(S, W, 34, 0x4d2c6dfc);
RNDr(S, W, 35, 0x53380d13);
RNDr(S, W, 36, 0x650a7354);
RNDr(S, W, 37, 0x766a0abb);
RNDr(S, W, 38, 0x81c2c92e);
RNDr(S, W, 39, 0x92722c85);
RNDr(S, W, 40, 0xa2bfe8a1);
RNDr(S, W, 41, 0xa81a664b);
RNDr(S, W, 42, 0xc24b8b70);
RNDr(S, W, 43, 0xc76c51a3);
RNDr(S, W, 44, 0xd192e819);
RNDr(S, W, 45, 0xd6990624);
RNDr(S, W, 46, 0xf40e3585);
RNDr(S, W, 47, 0x106aa070);
RNDr(S, W, 48, 0x19a4c116);
RNDr(S, W, 49, 0x1e376c08);
RNDr(S, W, 50, 0x2748774c);
RNDr(S, W, 51, 0x34b0bcb5);
RNDr(S, W, 52, 0x391c0cb3);
RNDr(S, W, 53, 0x4ed8aa4a);
RNDr(S, W, 54, 0x5b9cca4f);
RNDr(S, W, 55, 0x682e6ff3);
RNDr(S, W, 56, 0x748f82ee);
RNDr(S, W, 57, 0x78a5636f);
RNDr(S, W, 58, 0x84c87814);
RNDr(S, W, 59, 0x8cc70208);
RNDr(S, W, 60, 0x90befffa);
RNDr(S, W, 61, 0xa4506ceb);
RNDr(S, W, 62, 0xbef9a3f7);
RNDr(S, W, 63, 0xc67178f2);
/* 4. Mix local working variables into global state */
for (i = 0; i < 8; i++)
state[i] += S[i];
}
static unsigned char PAD[64] = {
0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
/* Add padding and terminating bit-count. */
static void
SHA256_Pad(SHA256_CTX * ctx)
{
unsigned char len[8];
uint32_t r, plen;
/*
* Convert length to a vector of bytes -- we do this now rather
* than later because the length will change after we pad.
*/
be32enc_vect(len, ctx->count, 8);
/* Add 1--64 bytes so that the resulting length is 56 mod 64 */
r = (ctx->count[1] >> 3) & 0x3f;
plen = (r < 56) ? (56 - r) : (120 - r);
SHA256_Update(ctx, PAD, (size_t)plen);
/* Add the terminating bit-count */
SHA256_Update(ctx, len, 8);
}
/* SHA-256 initialization. Begins a SHA-256 operation. */
void
SHA256_Init(SHA256_CTX * ctx)
{
/* Zero bits processed so far */
ctx->count[0] = ctx->count[1] = 0;
/* Magic initialization constants */
ctx->state[0] = 0x6A09E667;
ctx->state[1] = 0xBB67AE85;
ctx->state[2] = 0x3C6EF372;
ctx->state[3] = 0xA54FF53A;
ctx->state[4] = 0x510E527F;
ctx->state[5] = 0x9B05688C;
ctx->state[6] = 0x1F83D9AB;
ctx->state[7] = 0x5BE0CD19;
}
/* Add bytes into the hash */
void
SHA256_Update(SHA256_CTX * ctx, const unsigned char *src, size_t len)
{
uint32_t bitlen[2];
uint32_t r;
/* Number of bytes left in the buffer from previous updates */
r = (ctx->count[1] >> 3) & 0x3f;
/* Convert the length into a number of bits */
bitlen[1] = ((uint32_t)len) << 3;
bitlen[0] = (uint32_t)(len >> 29);
/* Update number of bits */
if ((ctx->count[1] += bitlen[1]) < bitlen[1])
ctx->count[0]++;
ctx->count[0] += bitlen[0];
/* Handle the case where we don't need to perform any transforms */
if (len < 64 - r) {
memcpy(&ctx->buf[r], src, len);
return;
}
/* Finish the current block */
memcpy(&ctx->buf[r], src, 64 - r);
SHA256_Transform(ctx->state, ctx->buf);
src += 64 - r;
len -= 64 - r;
/* Perform complete blocks */
while (len >= 64) {
SHA256_Transform(ctx->state, src);
src += 64;
len -= 64;
}
/* Copy left over data into buffer */
memcpy(ctx->buf, src, len);
}
/*
* SHA-256 finalization. Pads the input data, exports the hash value,
* and clears the context state.
*/
void
SHA256_Final(unsigned char digest[32], SHA256_CTX * ctx)
{
/* Add padding */
SHA256_Pad(ctx);
/* Write the hash */
be32enc_vect(digest, ctx->state, 32);
/* Clear the context state */
memset((void *)ctx, 0, sizeof(*ctx));
}

45
aegisub/reporter/sha256.h Normal file
View file

@ -0,0 +1,45 @@
/*-
* Copyright 2005 Colin Percival
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $FreeBSD: src/lib/libmd/sha256.h,v 1.1 2005/03/09 19:23:04 cperciva Exp $
* $Id$
*/
#ifndef _SHA256_H_
#define _SHA256_H_
#include <stdint.h>
typedef struct SHA256Context {
uint32_t state[8];
uint32_t count[2];
unsigned char buf[64];
} SHA256_CTX;
void SHA256_Init(SHA256_CTX *);
void SHA256_Update(SHA256_CTX *, const unsigned char *, size_t);
void SHA256_Final(unsigned char [32], SHA256_CTX *);
#endif /* !_SHA256_H_ */

145
aegisub/reporter/upload.cpp Normal file
View file

@ -0,0 +1,145 @@
// Copyright (c) 2009, Amar Takhar <verm@aegisub.org>
//
// 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$
/// @@file upload.cpp
/// @brief Handle uploading of data.
#ifndef R_PRECOMP
#include <wx/file.h>
#endif
#include "upload.h"
/// @brief Constructor.
Upload::Upload(Progress *prog) {
/// XXX: error checking.
progress = prog;
handle = curl_easy_init();
// curl_easy_setopt(handle, CURLOPT_VERBOSE, 1L);
curl_easy_setopt(handle, CURLOPT_USERAGENT, "Reporter v1.0");
curl_easy_setopt(handle, CURLOPT_READFUNCTION, CBRead);
curl_easy_setopt(handle, CURLOPT_PROGRESSFUNCTION, CBProgress);
curl_easy_setopt(handle, CURLOPT_NOPROGRESS, 0L);
curl_easy_setopt(handle, CURLOPT_PROGRESSDATA, progress);
}
/// @brief Destructor.
Upload::~Upload() {
curl_free(handle);
}
/// @brief Submit an XML report.
/// @param report filename of the report.
void Upload::Report(wxString report) {
wxFile file(report, wxFile::read);
SendFile("http://reporter.darkbeer.org/PUT/", file);
}
/// @brief Progress callback.
/// @param p pointer to progress info.
/// @param dlt download size.
/// @param dln downloaded.
/// @param ult upload size.
/// @param uln uploaded.
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)
// Returning non-zero will cause curl to abort the transfer.
return 1;
}
return 0;
}
/// @brief Callback to read data from a FD.
/// @param p buffer to fill.
/// @param size byte length.
/// @param nmemb object size.
/// @param filep FP to read from.
size_t Upload::CBRead(char *p, size_t size, size_t nmemb, void *filep) {
// This is on purpose to wx doesn't close the fp, curl does that for us.
wxFile *file = new wxFile((int)filep);
if (file->Eof())
return 0;
int ret = file->Read(p, file->Length());
if (ret == wxInvalidOffset)
return CURL_READFUNC_ABORT;
return ret;
}
/// @brief Send a file to the server
/// @param file file to send.
/// @return 1/0 for success/failure.
bool Upload::SendFile(const char *url, wxFile &file) {
progress->Update(0, _("Connecting..."));
curl_easy_setopt(handle, CURLOPT_URL, url);
Error(curl_easy_perform(handle));
curl_easy_setopt(handle, CURLOPT_UPLOAD, 1L);
curl_easy_setopt(handle, CURLOPT_PUT, 1L);
curl_easy_setopt(handle, CURLOPT_READDATA, file.fd());
curl_easy_setopt(handle, CURLOPT_INFILESIZE_LARGE, (curl_off_t)file.Length());
CURLcode res = curl_easy_perform(handle);
Error(res);
curl_easy_setopt(handle, CURLOPT_HTTPGET, 1L); // Reset to HTTP GET
curl_easy_cleanup(handle);
if (res == CURLE_OK)
return 1;
return 0;
}
/// @brief Handle error codes
/// @param error CURLcode.
void Upload::Error(CURLcode error) {
switch (error) {
case CURLE_OK:
progress->Update(0, _("Sending data..."));
break;
case CURLE_COULDNT_RESOLVE_HOST:
progress->Update(0, _("Couldn't resolve host."));
break;
case CURLE_COULDNT_CONNECT:
progress->Update(0, _("Couldn't connect to server."));
break;
case CURLE_SEND_ERROR: // socket error
case CURLE_RECV_ERROR: // socket error
progress->Update(0, _("Connection error."));
break;
case CURLE_GOT_NOTHING: // no response from server
case CURLE_HTTP_RETURNED_ERROR: // HTTP error >= 400
progress->Update(0, _("Server error."));
break;
case CURLE_OPERATION_TIMEDOUT:
progress->Update(0, _("Operation timeout."));
break;
default:
progress->Update(0, wxString::Format("Transfer error. (%d)\n", error));
}
}

43
aegisub/reporter/upload.h Normal file
View file

@ -0,0 +1,43 @@
// Copyright (c) 2009, Amar Takhar <verm@aegisub.org>
//
// 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$
/// @@file upload.h
/// @see upload.cpp
#ifndef R_PRECMP
#include <wx/file.h>
#endif
#include <curl/curl.h>
#include "progress.h"
/// @class Upload
/// @brief Upload files to the server.
class Upload {
private:
/// Curl handle.
CURL *handle;
/// Progress instance.
Progress *progress;
static int CBProgress(void *p, double dt, double dc, double ut, double uc);
static size_t CBRead(char *p, size_t size, size_t nmemb, void *filep);
void Error(CURLcode error);
public:
Upload(Progress *prog);
~Upload();
void Report(wxString report);
bool SendFile(const char *url, wxFile &file);
};

77
aegisub/reporter/view.cpp Normal file
View file

@ -0,0 +1,77 @@
// Copyright (c) 2009, Amar Takhar <verm@aegisub.org>
//
// 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$
/// @@file view.cpp
/// @brief View report in a human readable way.
#ifndef R_PRECOMP
#include <wx/window.h>
#include <wx/sizer.h>
#include <wx/button.h>
#include <wx/clipbrd.h>
#endif
#include "view.h"
/// @brief View report dialog.
/// @param frame Parent frame.
/// @param r Report instance.
View::View(wxWindow *frame, Report *r)
: wxDialog (frame, wxID_ANY, _("View Report"), wxDefaultPosition, wxDefaultSize, wxCAPTION | wxCLOSE_BOX | wxRESIZE_BORDER, _("View Report"))
{
wxSizer *topSizer = new wxBoxSizer(wxVERTICAL);
wxSizer *listSizer = new wxBoxSizer(wxHORIZONTAL);
wxListView *listView = new wxListView(this,wxID_ANY,wxDefaultPosition,wxDefaultSize);
// Fill the list with the actual report.
text = new wxString();
r->Fill(text, listView);
listSizer->Add(listView, 1, wxEXPAND);
topSizer->Add(listSizer, 1, wxEXPAND | wxALL, 0);
wxStdDialogButtonSizer *stdButton = new wxStdDialogButtonSizer();
stdButton->AddButton(new wxButton(this, wxID_CLOSE, _("Close")));
stdButton->AddButton(new wxButton(this, wxID_SAVE, _("Copy to clipboard")));
stdButton->Realize();
topSizer->Add(stdButton, 0, wxALL | wxCENTRE | wxSHRINK, 5);
this->SetSizerAndFit(topSizer);
this->SetSize(wxSize(500,550));
}
/// @brief Close dialog
void View::CloseDialog(wxCommandEvent& WXUNUSED(event)) {
Close(true);
}
/// @brief Copy report to clipboard
void View::Clipboard(wxCommandEvent& WXUNUSED(event)) {
if (wxTheClipboard->Open()) {
#ifdef __UNIX__
wxTheClipboard->UsePrimarySelection(true);
#endif
wxTheClipboard->SetData( new wxTextDataObject(*text));
wxTheClipboard->Flush();
wxTheClipboard->Close();
}
}
BEGIN_EVENT_TABLE(View, wxDialog)
EVT_BUTTON(wxID_CLOSE, View::CloseDialog)
EVT_BUTTON(wxID_SAVE, View::Clipboard)
END_EVENT_TABLE()

40
aegisub/reporter/view.h Normal file
View file

@ -0,0 +1,40 @@
// Copyright (c) 2009, Amar Takhar <verm@aegisub.org>
//
// 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$
/// @@file view.h
/// @see view.cpp
#ifndef R_PRECOMP
#include <wx/frame.h>
#include <wx/event.h>
#include <wx/window.h>
#include <wx/dialog.h>
#endif
#include "report.h"
class View: public wxDialog {
public:
View(wxWindow *frame, Report *r);
~View() {};
private:
Report *r;
wxString *text;
void CloseDialog(wxCommandEvent& event);
void Clipboard(wxCommandEvent& event);
DECLARE_EVENT_TABLE()
};

51
aegisub/reporter/wx_pre.h Normal file
View file

@ -0,0 +1,51 @@
// Copyright (c) 2009, Amar Takhar <verm@aegisub.org>
//
// 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$
/// @@file wx_pre.h
/// @brief Precompiled header.
#define R_PRECOMP
#include <wx/wxprec.h>
#include <wx/app.h>
#include <wx/button.h>
#include <wx/cmdline.h>
#include <wx/dialog.h>
#include <wx/event.h>
#include <wx/font.h>
#include <wx/frame.h>
#include <wx/gdicmn.h>
#include <wx/intl.h>
#include <wx/log.h>
#include <wx/panel.h>
#include <wx/sizer.h>
#include <wx/stattext.h>
#include <wx/string.h>
#include <wx/version.h>
#include <wx/window.h>
#include <wx/wx.h>
#include <wx/wxchar.h>
#include <wx/xml/xml.h>
#include <wx/listctrl.h>
#include <wx/clipbrd.h>
#include <wx/intl.h>
#include <wx/file.h>
#include <wx/progdlg.h>
#include <wx/fileconf.h>
#include <wx/wfstream.h>
#include <wx/apptrait.h>
#include <wx/stdpaths.h>