mirror of
https://github.com/PrismLauncher/PrismLauncher.git
synced 2026-07-01 10:56:57 +03:00
Use an owning QByteArray in ByteArraySink
Signed-off-by: TheKodeToad <TheKodeToad@proton.me>
This commit is contained in:
parent
2b84053011
commit
316121ba8f
70 changed files with 397 additions and 390 deletions
|
|
@ -66,8 +66,8 @@ void MSADeviceCodeStep::perform()
|
|||
{ "Content-Type", "application/x-www-form-urlencoded" },
|
||||
{ "Accept", "application/json" },
|
||||
};
|
||||
m_response.reset(new QByteArray());
|
||||
m_request = Net::Upload::makeByteArray(url, m_response.get(), payload);
|
||||
auto [request, response] = Net::Upload::makeByteArray(url, payload);
|
||||
m_request = request;
|
||||
m_request->addHeaderProxy(std::make_unique<Net::RawHeaderProxy>(headers));
|
||||
m_request->enableAutoRetry(true);
|
||||
|
||||
|
|
@ -75,7 +75,7 @@ void MSADeviceCodeStep::perform()
|
|||
m_task->setAskRetry(false);
|
||||
m_task->addNetAction(m_request);
|
||||
|
||||
connect(m_task.get(), &Task::finished, this, &MSADeviceCodeStep::deviceAuthorizationFinished);
|
||||
connect(m_task.get(), &Task::finished, this, [this, response] { deviceAuthorizationFinished(response); });
|
||||
|
||||
m_task->start();
|
||||
}
|
||||
|
|
@ -111,9 +111,9 @@ DeviceAuthorizationResponse parseDeviceAuthorizationResponse(const QByteArray& d
|
|||
};
|
||||
}
|
||||
|
||||
void MSADeviceCodeStep::deviceAuthorizationFinished()
|
||||
void MSADeviceCodeStep::deviceAuthorizationFinished(QByteArray* response)
|
||||
{
|
||||
auto rsp = parseDeviceAuthorizationResponse(*m_response);
|
||||
auto rsp = parseDeviceAuthorizationResponse(*response);
|
||||
if (!rsp.error.isEmpty() || !rsp.error_description.isEmpty()) {
|
||||
qWarning() << "Device authorization failed:" << rsp.error;
|
||||
emit finished(AccountTaskState::STATE_FAILED_HARD,
|
||||
|
|
@ -121,7 +121,7 @@ void MSADeviceCodeStep::deviceAuthorizationFinished()
|
|||
return;
|
||||
}
|
||||
if (!m_request->wasSuccessful() || m_request->error() != QNetworkReply::NoError) {
|
||||
qWarning() << "Device authorization failed:" << *m_response;
|
||||
qWarning() << "Device authorization failed:" << *response;
|
||||
emit finished(AccountTaskState::STATE_FAILED_HARD, tr("Failed to retrieve device authorization"));
|
||||
return;
|
||||
}
|
||||
|
|
@ -182,11 +182,11 @@ void MSADeviceCodeStep::authenticateUser()
|
|||
{ "Content-Type", "application/x-www-form-urlencoded" },
|
||||
{ "Accept", "application/json" },
|
||||
};
|
||||
m_response.reset(new QByteArray());
|
||||
m_request = Net::Upload::makeByteArray(url, m_response.get(), payload);
|
||||
auto [request, response] = Net::Upload::makeByteArray(url, payload);
|
||||
m_request = request;
|
||||
m_request->addHeaderProxy(std::make_unique<Net::RawHeaderProxy>(headers));
|
||||
|
||||
connect(m_request.get(), &Task::finished, this, &MSADeviceCodeStep::authenticationFinished);
|
||||
connect(m_request.get(), &Task::finished, this, [this, response] { authenticationFinished(response); });
|
||||
|
||||
m_request->setNetwork(APPLICATION->network());
|
||||
m_request->start();
|
||||
|
|
@ -227,7 +227,7 @@ AuthenticationResponse parseAuthenticationResponse(const QByteArray& data)
|
|||
obj.toVariantMap() };
|
||||
}
|
||||
|
||||
void MSADeviceCodeStep::authenticationFinished()
|
||||
void MSADeviceCodeStep::authenticationFinished(QByteArray* response)
|
||||
{
|
||||
if (m_request->error() == QNetworkReply::TimeoutError) {
|
||||
// rfc8628#section-3.5
|
||||
|
|
@ -239,7 +239,7 @@ void MSADeviceCodeStep::authenticationFinished()
|
|||
startPoolTimer();
|
||||
return;
|
||||
}
|
||||
auto rsp = parseAuthenticationResponse(*m_response);
|
||||
auto rsp = parseAuthenticationResponse(*response);
|
||||
if (rsp.error == "slow_down") {
|
||||
// rfc8628#section-3.5
|
||||
// "A variant of 'authorization_pending', the authorization request is
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue