1
// Copyright (c) 2009, Amar Takhar <verm@aegisub.org>
3
// Permission to use, copy, modify, and distribute this software for any
4
// purpose with or without fee is hereby granted, provided that the above
5
// copyright notice and this permission notice appear in all copies.
7
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
8
// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
9
// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
10
// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
11
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
12
// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
13
// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18
/// @brief Generation and manipulation of reports.
26
#include <libaegisub/io.h>
27
#include <libaegisub/cajun/elements.h>
28
#include <libaegisub/cajun/writer.h>
32
#include "include/platform.h"
35
/// @brief Contstructor
40
Platform *p = Platform::GetPlatform();
43
json::Object& general = root["General"];
44
general["Signature"] = p->Signature();
45
general["Date"] = p->Date();
46
general["Architecture"] = p->ArchName();
47
general["OS Family"] = p->OSFamily();
48
general["OS Name"] = p->OSName();
49
general["Endian"] = p->Endian();
50
general["OS Version"] = p->OSVersion();
51
general["wx Version"] = p->wxVersion();
52
general["Locale"] = p->Locale();
53
general["Language"] = p->Language();
54
general["System Language"] = p->SystemLanguage();
57
json::Object& aegisub = root["Aegisub"];
58
aegisub["Last Version"] = a.GetString("Version/Last Version");
59
aegisub["Spelling Language"] = a.GetString("Tool/Spell Checker/Language");
60
aegisub["Thesaurus Language"] = a.GetString("Tool/Thesaurus/Language");
61
aegisub["Audio Player"] = a.GetString("Audio/Player");
62
aegisub["Audio Provider"] = a.GetString("Audio/Provider");
63
aegisub["Video Provider"] = a.GetString("Video/Provider");
64
aegisub["Subtitles Provider"] = a.GetString("Subtitle/Provider");
65
aegisub["Save Charset"] = a.GetString("App/Save Charset");
66
aegisub["Grid Font Size"] = a.GetInt("Grid/Font Size");
67
aegisub["Edit Font Size"] = a.GetInt("Subtitle/Edit Box/Font Size");
68
aegisub["Spectrum Enabled"] = a.GetBool("Audio/Spectrum");
69
aegisub["Spectrum Quality"] = a.GetInt("Audio/Renderer/Spectrum/Quality");
70
aegisub["Call Tips Enabled"] = a.GetBool("App/Call Tips");
71
aegisub["Medusa Hotkeys Enabled"] = a.GetBool("Audio/Medusa Timing Hotkeys");
73
root["Aegisub"]["Error"] = json::String("Config file is corrupted");
76
json::Object& hardware = root["Hardware"];
77
hardware["Memory Size"] = 0;
79
json::Object& cpu = root["CPU"];
80
cpu["Id"] = p->CPUId();
81
cpu["Speed"] = p->CPUSpeed();
82
cpu["Count"] = p->CPUCount();
83
cpu["Cores"] = p->CPUCores();
84
cpu["Features"] = p->CPUFeatures();
85
cpu["Features2"] = p->CPUFeatures2();
87
json::Object& display = root["Display"];
88
display["Depth"] = p->DisplayDepth();
89
display["Size"] = p->DisplaySize();
90
display["Pixels Per Inch"] = p->DisplayPPI();
92
json::Object& gl = display["OpenGL"];
93
gl["Vendor"] = p->OpenGLVendor();
94
gl["Renderer"] = p->OpenGLRenderer();
95
gl["Version"] = p->OpenGLVersion();
96
gl["Extensions"] = p->OpenGLExt();
97
display["OpenGL"] = gl;
100
json::Object& windows = root["Windows"];
101
windows["Service Pack"] = json::String();
102
windows["Graphics Driver Version"] = json::String();
103
windows["DirectShow Filters"] = json::String();
104
windows["AntiVirus Installed"] = json::Boolean();
105
windows["Firewall Installed"] = json::Boolean();
106
windows["DLL"] = json::String();
110
json::Object& u_nix = root["Unix"];
111
u_nix["Desktop Environment"] = p->DesktopEnvironment();
112
u_nix["Libraries"] = p->UnixLibraries();
116
json::Object& osx = root["OS X"];
117
osx["Patch"] = p->PatchLevel();
118
osx["Model"] = p->HardwareModel();
121
agi::io::Save file("./t.json");
122
json::Writer::Write(root, file.Get());
126
/// @brief Return Report as Text for the Clipboard.
127
void Report::Save(std::string filename) {
128
// agi::io::Save file(filename);
129
// json::Writer::Write(root, file.Get());