From 7e8a770b309b61e87ca9cf133d2cec41552e90fc Mon Sep 17 00:00:00 2001 From: LillyJadeKatrin Date: Mon, 10 Apr 2023 23:56:15 -0400 Subject: [PATCH] Added StartRASession to AchievementManager Added a call to the RetroAchievements Start Session API to AchievementManager. This is primarily for client-side activation, so it doesn't return much of value, aside from its success/error information, but I'm storing the return structure in case this changes in the future. --- Source/Core/Core/AchievementManager.cpp | 14 ++++++++++++++ Source/Core/Core/AchievementManager.h | 2 ++ 2 files changed, 16 insertions(+) diff --git a/Source/Core/Core/AchievementManager.cpp b/Source/Core/Core/AchievementManager.cpp index 4cd3aad766..6239563167 100644 --- a/Source/Core/Core/AchievementManager.cpp +++ b/Source/Core/Core/AchievementManager.cpp @@ -92,6 +92,20 @@ AchievementManager::ResolveHash(std::array game_hash) return r_type; } +AchievementManager::ResponseType AchievementManager::StartRASession() +{ + rc_api_start_session_response_t session_data{}; + std::string username = Config::Get(Config::RA_USERNAME); + std::string api_token = Config::Get(Config::RA_API_TOKEN); + rc_api_start_session_request_t start_session_request = { + .username = username.c_str(), .api_token = api_token.c_str(), .game_id = m_game_id}; + ResponseType r_type = Request( + start_session_request, &session_data, rc_api_init_start_session_request, + rc_api_process_start_session_response); + rc_api_destroy_start_session_response(&session_data); + return r_type; +} + // Every RetroAchievements API call, with only a partial exception for fetch_image, follows // the same design pattern (here, X is the name of the call): // Create a specific rc_api_X_request_t struct and populate with the necessary values diff --git a/Source/Core/Core/AchievementManager.h b/Source/Core/Core/AchievementManager.h index 4132db23af..c16c140670 100644 --- a/Source/Core/Core/AchievementManager.h +++ b/Source/Core/Core/AchievementManager.h @@ -43,6 +43,7 @@ private: ResponseType VerifyCredentials(const std::string& password); ResponseType ResolveHash(std::array game_hash); + ResponseType StartRASession(); template ResponseType Request(RcRequest rc_request, RcResponse* rc_response, @@ -55,6 +56,7 @@ private: rc_api_login_response_t m_login_data{}; + Common::WorkQueueThread> m_queue; }; // class AchievementManager