| 96 | |
| 97 | |
| 98 | void LaunchController::login() { |
| 99 | decideAccount(); |
| 100 | |
| 101 | // if no account is selected, we bail |
| 102 | if (!m_accountToUse) |
| 103 | { |
| 104 | emitFailed(tr("No account selected for launch.")); |
| 105 | return; |
| 106 | } |
| 107 | |
| 108 | // we try empty password first :) |
| 109 | QString password; |
| 110 | // we loop until the user succeeds in logging in or gives up |
| 111 | bool tryagain = true; |
| 112 | // the failure. the default failure. |
| 113 | const QString needLoginAgain = tr("Your account is currently not logged in. Please enter your password to log in again. <br /> <br /> This could be caused by a password change."); |
| 114 | QString failReason = needLoginAgain; |
| 115 | |
| 116 | while (tryagain) |
| 117 | { |
| 118 | m_session = std::make_shared<AuthSession>(); |
| 119 | m_session->wants_online = m_online; |
| 120 | m_accountToUse->fillSession(m_session); |
| 121 | |
| 122 | switch(m_accountToUse->accountState()) { |
| 123 | case AccountState::Offline: { |
| 124 | m_session->wants_online = false; |
| 125 | // NOTE: fallthrough is intentional |
| 126 | } |
| 127 | case AccountState::Online: { |
| 128 | if(!m_session->wants_online) { |
| 129 | QString usedname; |
| 130 | if(m_offlineName.isEmpty()) { |
| 131 | // we ask the user for a player name |
| 132 | bool ok = false; |
| 133 | QString lastOfflinePlayerName = APPLICATION->settings()->get("LastOfflinePlayerName").toString(); |
| 134 | usedname = lastOfflinePlayerName.isEmpty() ? m_session->player_name : lastOfflinePlayerName; |
| 135 | QString name = QInputDialog::getText( |
| 136 | m_parentWidget, |
| 137 | tr("Player name"), |
| 138 | tr("Choose your offline mode player name."), |
| 139 | QLineEdit::Normal, |
| 140 | usedname, |
| 141 | &ok |
| 142 | ); |
| 143 | if (!ok) |
| 144 | { |
| 145 | tryagain = false; |
| 146 | break; |
| 147 | } |
| 148 | if (name.length()) |
| 149 | { |
| 150 | usedname = name; |
| 151 | APPLICATION->settings()->set("LastOfflinePlayerName", usedname); |
| 152 | } |
| 153 | } |
| 154 | else { |
| 155 | usedname = m_offlineName; |
nothing calls this directly
no test coverage detected