| 73 | } |
| 74 | |
| 75 | int MSALoginDialog::exec() |
| 76 | { |
| 77 | // Setup the login task and start it |
| 78 | m_account = MinecraftAccount::createBlankMSA(); |
| 79 | m_authflow_task = m_account->login(false); |
| 80 | connect(m_authflow_task.get(), &Task::failed, this, &MSALoginDialog::onTaskFailed); |
| 81 | connect(m_authflow_task.get(), &Task::succeeded, this, &QDialog::accept); |
| 82 | connect(m_authflow_task.get(), &Task::aborted, this, &MSALoginDialog::reject); |
| 83 | connect(m_authflow_task.get(), &Task::status, this, &MSALoginDialog::onAuthFlowStatus); |
| 84 | connect(m_authflow_task.get(), &AuthFlow::authorizeWithBrowser, this, &MSALoginDialog::authorizeWithBrowser); |
| 85 | connect(m_authflow_task.get(), &AuthFlow::authorizeWithBrowserWithExtra, this, &MSALoginDialog::authorizeWithBrowserWithExtra); |
| 86 | connect(ui->buttonBox->button(QDialogButtonBox::Cancel), &QPushButton::clicked, m_authflow_task.get(), &Task::abort); |
| 87 | |
| 88 | m_devicecode_task.reset(new AuthFlow(m_account->accountData(), AuthFlow::Action::DeviceCode)); |
| 89 | connect(m_devicecode_task.get(), &Task::failed, this, &MSALoginDialog::onTaskFailed); |
| 90 | connect(m_devicecode_task.get(), &Task::succeeded, this, &QDialog::accept); |
| 91 | connect(m_devicecode_task.get(), &Task::aborted, this, &MSALoginDialog::reject); |
| 92 | connect(m_devicecode_task.get(), &Task::status, this, &MSALoginDialog::onDeviceFlowStatus); |
| 93 | connect(m_devicecode_task.get(), &AuthFlow::authorizeWithBrowser, this, &MSALoginDialog::authorizeWithBrowser); |
| 94 | connect(m_devicecode_task.get(), &AuthFlow::authorizeWithBrowserWithExtra, this, &MSALoginDialog::authorizeWithBrowserWithExtra); |
| 95 | connect(ui->buttonBox->button(QDialogButtonBox::Cancel), &QPushButton::clicked, m_devicecode_task.get(), &Task::abort); |
| 96 | QMetaObject::invokeMethod(m_authflow_task.get(), &Task::start, Qt::QueuedConnection); |
| 97 | QMetaObject::invokeMethod(m_devicecode_task.get(), &Task::start, Qt::QueuedConnection); |
| 98 | |
| 99 | return QDialog::exec(); |
| 100 | } |
| 101 | |
| 102 | MSALoginDialog::~MSALoginDialog() |
| 103 | { |
no test coverage detected