Merge branch 'develop' of https://github.com/PrismLauncher/PrismLauncher into clean_net
Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
This commit is contained in:
commit
061fdc1ada
38 changed files with 414 additions and 136 deletions
|
@ -67,12 +67,13 @@ void MSADeviceCodeStep::perform()
|
|||
{ "Accept", "application/json" },
|
||||
};
|
||||
m_response.reset(new QByteArray());
|
||||
m_task = Net::Upload::makeByteArray(url, m_response, payload);
|
||||
m_task->addHeaderProxy(new Net::RawHeaderProxy(headers));
|
||||
m_request = Net::Upload::makeByteArray(url, m_response, payload);
|
||||
m_request->addHeaderProxy(new Net::RawHeaderProxy(headers));
|
||||
|
||||
connect(m_task.get(), &Task::finished, this, &MSADeviceCodeStep::deviceAutorizationFinished);
|
||||
m_task.reset(new NetJob("MSADeviceCodeStep", APPLICATION->network()));
|
||||
m_task->setAskRetry(false);
|
||||
m_task->addNetAction(m_request);
|
||||
|
||||
m_task->setNetwork(APPLICATION->network());
|
||||
m_task->start();
|
||||
}
|
||||
|
||||
|
@ -117,7 +118,7 @@ void MSADeviceCodeStep::deviceAutorizationFinished()
|
|||
tr("Device authorization failed: %1").arg(rsp.error_description.isEmpty() ? rsp.error : rsp.error_description));
|
||||
return;
|
||||
}
|
||||
if (!m_task->wasSuccessful() || m_task->error() != QNetworkReply::NoError) {
|
||||
if (!m_request->wasSuccessful() || m_request->error() != QNetworkReply::NoError) {
|
||||
emit finished(AccountTaskState::STATE_FAILED_HARD, tr("Failed to retrieve device authorization"));
|
||||
qDebug() << *m_response;
|
||||
return;
|
||||
|
@ -145,8 +146,8 @@ void MSADeviceCodeStep::abort()
|
|||
{
|
||||
m_expiration_timer.stop();
|
||||
m_pool_timer.stop();
|
||||
if (m_task) {
|
||||
m_task->abort();
|
||||
if (m_request) {
|
||||
m_request->abort();
|
||||
}
|
||||
m_is_aborted = true;
|
||||
emit finished(AccountTaskState::STATE_FAILED_HARD, tr("Task aborted"));
|
||||
|
@ -179,13 +180,13 @@ void MSADeviceCodeStep::authenticateUser()
|
|||
{ "Accept", "application/json" },
|
||||
};
|
||||
m_response.reset(new QByteArray());
|
||||
m_task = Net::Upload::makeByteArray(url, m_response, payload);
|
||||
m_task->addHeaderProxy(new Net::RawHeaderProxy(headers));
|
||||
m_request = Net::Upload::makeByteArray(url, m_response, payload);
|
||||
m_request->addHeaderProxy(new Net::RawHeaderProxy(headers));
|
||||
|
||||
connect(m_task.get(), &Task::finished, this, &MSADeviceCodeStep::authenticationFinished);
|
||||
connect(m_request.get(), &Task::finished, this, &MSADeviceCodeStep::authenticationFinished);
|
||||
|
||||
m_task->setNetwork(APPLICATION->network());
|
||||
m_task->start();
|
||||
m_request->setNetwork(APPLICATION->network());
|
||||
m_request->start();
|
||||
}
|
||||
|
||||
struct AuthenticationResponse {
|
||||
|
@ -225,7 +226,7 @@ AuthenticationResponse parseAuthenticationResponse(const QByteArray& data)
|
|||
|
||||
void MSADeviceCodeStep::authenticationFinished()
|
||||
{
|
||||
if (m_task->error() == QNetworkReply::TimeoutError) {
|
||||
if (m_request->error() == QNetworkReply::TimeoutError) {
|
||||
// rfc8628#section-3.5
|
||||
// "On encountering a connection timeout, clients MUST unilaterally
|
||||
// reduce their polling frequency before retrying. The use of an
|
||||
|
@ -258,7 +259,7 @@ void MSADeviceCodeStep::authenticationFinished()
|
|||
tr("Device Access failed: %1").arg(rsp.error_description.isEmpty() ? rsp.error : rsp.error_description));
|
||||
return;
|
||||
}
|
||||
if (!m_task->wasSuccessful() || m_task->error() != QNetworkReply::NoError) {
|
||||
if (!m_request->wasSuccessful() || m_request->error() != QNetworkReply::NoError) {
|
||||
startPoolTimer(); // it failed so just try again without increasing the interval
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue