MCPcopy Create free account
hub / github.com/PCSX2/pcsx2 / Login

Method Login

pcsx2/Achievements.cpp:1795–1840  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1793}
1794
1795bool Achievements::Login(const char* username, const char* password, Error* error)
1796{
1797 auto lock = GetLock();
1798
1799 // We need to use a temporary client if achievements aren't currently active.
1800 rc_client_t* client = s_client;
1801 HTTPDownloader* http = s_http_downloader.get();
1802 const bool is_temporary_client = (client == nullptr);
1803 std::unique_ptr<HTTPDownloader> temporary_downloader;
1804 ScopedGuard temporary_client_guard = [&client, is_temporary_client, &temporary_downloader]() {
1805 if (is_temporary_client)
1806 DestroyClient(&client, &temporary_downloader);
1807 };
1808 if (is_temporary_client)
1809 {
1810 if (!CreateClient(&client, &temporary_downloader))
1811 {
1812 Error::SetString(error, "Failed to create client.");
1813 return false;
1814 }
1815 http = temporary_downloader.get();
1816 }
1817
1818 LoginWithPasswordParameters params = {username, error, nullptr, false};
1819
1820 params.request = rc_client_begin_login_with_password(client, username, password, ClientLoginWithPasswordCallback, &params);
1821 if (!params.request)
1822 {
1823 Error::SetString(error, "Failed to create login request.");
1824 return false;
1825 }
1826
1827 // Wait until the login request completes.
1828 http->WaitForAllRequests();
1829 pxAssert(!params.request);
1830
1831 // Success? Assume the callback set the error message.
1832 if (!params.result)
1833 return false;
1834
1835 // If we were't a temporary client, get the game loaded.
1836 if (VMManager::HasValidVM() && !is_temporary_client)
1837 BeginLoadGame();
1838
1839 return true;
1840}
1841
1842
1843void Achievements::ClientLoginWithPasswordCallback(int result, const char* error_message, rc_client_t* client, void* userdata)

Callers

nothing calls this directly

Calls 3

WaitForAllRequestsMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected