diff --git a/src/crashlog.cpp b/src/crashlog.cpp index 682d35f7c1..eae4a3bef8 100644 --- a/src/crashlog.cpp +++ b/src/crashlog.cpp @@ -122,6 +122,9 @@ void CrashLog::FillCrashLog() if (!this->TryExecute("libraries", [&info]() { SurveyLibraries(info["libraries"]); return true; })) { info["libraries"] = "crashed while gathering information"; } + if (!this->TryExecute("plugins", [&info]() { SurveyPlugins(info["plugins"]); return true; })) { + info["plugins"] = "crashed while gathering information"; + } } { diff --git a/src/network/network_survey.cpp b/src/network/network_survey.cpp index 5e73ffb0b0..59d9b22d60 100644 --- a/src/network/network_survey.cpp +++ b/src/network/network_survey.cpp @@ -61,6 +61,7 @@ std::string NetworkSurveyHandler::CreatePayload(Reason reason, bool for_preview) SurveyFont(info["font"]); SurveyCompiler(info["compiler"]); SurveyLibraries(info["libraries"]); + SurveyPlugins(info["plugins"]); } { diff --git a/src/survey.cpp b/src/survey.cpp index 6f71c869bb..fd76e22e8f 100644 --- a/src/survey.cpp +++ b/src/survey.cpp @@ -34,6 +34,8 @@ #include "base_media_base.h" #include "blitter/factory.hpp" +#include "social_integration.h" + #ifdef WITH_ALLEGRO # include #endif /* WITH_ALLEGRO */ @@ -81,6 +83,16 @@ NLOHMANN_JSON_SERIALIZE_ENUM(GRFStatus, { {GRFStatus::GCS_ACTIVATED, "activated"}, }) +NLOHMANN_JSON_SERIALIZE_ENUM(SocialIntegrationPlugin::State, { + {SocialIntegrationPlugin::State::RUNNING, "running"}, + {SocialIntegrationPlugin::State::FAILED, "failed"}, + {SocialIntegrationPlugin::State::PLATFORM_NOT_RUNNING, "platform_not_running"}, + {SocialIntegrationPlugin::State::UNLOADED, "unloaded"}, + {SocialIntegrationPlugin::State::DUPLICATE, "duplicate"}, + {SocialIntegrationPlugin::State::UNSUPPORTED_API, "unsupported_api"}, +}) + + /** Lookup table to convert a VehicleType to a string. */ static const std::string _vehicle_type_to_string[] = { "train", @@ -435,6 +447,26 @@ void SurveyLibraries(nlohmann::json &survey) #endif } +/** + * Convert plugin information to JSON. + * + * @param survey The JSON object. + */ +void SurveyPlugins(nlohmann::json &survey) +{ + auto _plugins = SocialIntegration::GetPlugins(); + + for (auto &plugin : _plugins) { + auto &platform = survey[plugin->social_platform]; + platform.push_back({ + {"name", plugin->name}, + {"version", plugin->version}, + {"basepath", plugin->basepath}, + {"state", plugin->state}, + }); + } +} + /** * Change the bytes of memory into a textual version rounded up to the biggest unit. * diff --git a/src/survey.h b/src/survey.h index aae16d4bf4..0e74641a27 100644 --- a/src/survey.h +++ b/src/survey.h @@ -21,6 +21,7 @@ void SurveyFont(nlohmann::json &survey); void SurveyGameScript(nlohmann::json &survey); void SurveyGrfs(nlohmann::json &survey); void SurveyLibraries(nlohmann::json &survey); +void SurveyPlugins(nlohmann::json &survey); void SurveyOpenTTD(nlohmann::json &survey); void SurveySettings(nlohmann::json &survey, bool skip_if_default); void SurveyTimers(nlohmann::json &survey);