2021-05-03 18:07:26 +02:00
|
|
|
/* Copyright (C) 2021 Wildfire Games.
|
2018-08-22 14:48:27 +02:00
|
|
|
* This file is part of 0 A.D.
|
|
|
|
*
|
|
|
|
* 0 A.D. is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* 0 A.D. is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "precompiled.h"
|
|
|
|
|
|
|
|
#include "JSInterface_UserReport.h"
|
|
|
|
|
2018-10-06 00:19:28 +02:00
|
|
|
#include "ps/Filesystem.h"
|
|
|
|
#include "ps/Pyrogenesis.h"
|
2018-08-22 14:48:27 +02:00
|
|
|
#include "ps/UserReport.h"
|
2021-03-02 21:01:14 +01:00
|
|
|
#include "scriptinterface/FunctionWrapper.h"
|
2021-05-03 18:07:26 +02:00
|
|
|
#include "scriptinterface/ScriptRequest.h"
|
2018-08-22 14:48:27 +02:00
|
|
|
|
|
|
|
#include <string>
|
|
|
|
|
2021-03-02 21:01:14 +01:00
|
|
|
namespace JSI_UserReport
|
|
|
|
{
|
|
|
|
bool IsUserReportEnabled()
|
2018-08-22 14:48:27 +02:00
|
|
|
{
|
|
|
|
return g_UserReporter.IsReportingEnabled();
|
|
|
|
}
|
|
|
|
|
2021-03-02 21:01:14 +01:00
|
|
|
void SetUserReportEnabled(bool enabled)
|
2018-08-22 14:48:27 +02:00
|
|
|
{
|
|
|
|
g_UserReporter.SetReportingEnabled(enabled);
|
|
|
|
}
|
|
|
|
|
2021-03-02 21:01:14 +01:00
|
|
|
std::string GetUserReportStatus()
|
2018-08-22 14:48:27 +02:00
|
|
|
{
|
|
|
|
return g_UserReporter.GetStatus();
|
|
|
|
}
|
|
|
|
|
2021-03-02 21:01:14 +01:00
|
|
|
std::string GetUserReportLogPath()
|
2018-10-06 00:19:28 +02:00
|
|
|
{
|
|
|
|
return psLogDir().string8();
|
|
|
|
}
|
|
|
|
|
2021-03-02 21:01:14 +01:00
|
|
|
std::string GetUserReportConfigPath()
|
2018-10-06 00:19:28 +02:00
|
|
|
{
|
|
|
|
OsPath configPath;
|
|
|
|
WARN_IF_ERR(g_VFS->GetDirectoryRealPath("config/", configPath));
|
|
|
|
return configPath.string8();
|
|
|
|
}
|
|
|
|
|
2021-03-02 21:01:14 +01:00
|
|
|
void RegisterScriptFunctions(const ScriptRequest& rq)
|
2018-08-22 14:48:27 +02:00
|
|
|
{
|
2021-03-02 21:01:14 +01:00
|
|
|
ScriptFunction::Register<&IsUserReportEnabled>(rq, "IsUserReportEnabled");
|
|
|
|
ScriptFunction::Register<&SetUserReportEnabled>(rq, "SetUserReportEnabled");
|
|
|
|
ScriptFunction::Register<&GetUserReportStatus>(rq, "GetUserReportStatus");
|
|
|
|
ScriptFunction::Register<&GetUserReportLogPath>(rq, "GetUserReportLogPath");
|
|
|
|
ScriptFunction::Register<&GetUserReportConfigPath>(rq, "GetUserReportConfigPath");
|
|
|
|
}
|
2018-08-22 14:48:27 +02:00
|
|
|
}
|