Line data Source code
1 : /* Copyright (C) 2021 Wildfire Games.
2 : * This file is part of 0 A.D.
3 : *
4 : * 0 A.D. is free software: you can redistribute it and/or modify
5 : * it under the terms of the GNU General Public License as published by
6 : * the Free Software Foundation, either version 2 of the License, or
7 : * (at your option) any later version.
8 : *
9 : * 0 A.D. is distributed in the hope that it will be useful,
10 : * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 : * GNU General Public License for more details.
13 : *
14 : * You should have received a copy of the GNU General Public License
15 : * along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.
16 : */
17 :
18 : #include "precompiled.h"
19 :
20 : #include "JSInterface_UserReport.h"
21 :
22 : #include "ps/Filesystem.h"
23 : #include "ps/Pyrogenesis.h"
24 : #include "ps/UserReport.h"
25 : #include "scriptinterface/FunctionWrapper.h"
26 : #include "scriptinterface/ScriptRequest.h"
27 :
28 : #include <string>
29 :
30 : namespace JSI_UserReport
31 : {
32 0 : bool IsUserReportEnabled()
33 : {
34 0 : return g_UserReporter.IsReportingEnabled();
35 : }
36 :
37 0 : void SetUserReportEnabled(bool enabled)
38 : {
39 0 : g_UserReporter.SetReportingEnabled(enabled);
40 0 : }
41 :
42 0 : std::string GetUserReportStatus()
43 : {
44 0 : return g_UserReporter.GetStatus();
45 : }
46 :
47 0 : std::string GetUserReportLogPath()
48 : {
49 0 : return psLogDir().string8();
50 : }
51 :
52 0 : std::string GetUserReportConfigPath()
53 : {
54 0 : OsPath configPath;
55 0 : WARN_IF_ERR(g_VFS->GetDirectoryRealPath("config/", configPath));
56 0 : return configPath.string8();
57 : }
58 :
59 12 : void RegisterScriptFunctions(const ScriptRequest& rq)
60 : {
61 12 : ScriptFunction::Register<&IsUserReportEnabled>(rq, "IsUserReportEnabled");
62 12 : ScriptFunction::Register<&SetUserReportEnabled>(rq, "SetUserReportEnabled");
63 12 : ScriptFunction::Register<&GetUserReportStatus>(rq, "GetUserReportStatus");
64 12 : ScriptFunction::Register<&GetUserReportLogPath>(rq, "GetUserReportLogPath");
65 12 : ScriptFunction::Register<&GetUserReportConfigPath>(rq, "GetUserReportConfigPath");
66 12 : }
67 3 : }
|