mirror of
https://github.com/UltimMC/Launcher.git
synced 2025-10-03 08:41:42 +00:00
UltimMC: Actually make profile for local accounts, fixes #334
This commit is contained in:
@@ -220,7 +220,7 @@ set(MINECRAFT_SOURCES
|
|||||||
minecraft/auth/Yggdrasil.h
|
minecraft/auth/Yggdrasil.h
|
||||||
|
|
||||||
minecraft/auth/providers/BaseAuthProvider.h
|
minecraft/auth/providers/BaseAuthProvider.h
|
||||||
minecraft/auth/providers/DummyAuthProvider.h
|
minecraft/auth/providers/LocalAuthProvider.h
|
||||||
minecraft/auth/providers/ElybyAuthProvider.h
|
minecraft/auth/providers/ElybyAuthProvider.h
|
||||||
minecraft/auth/providers/MojangAuthProvider.h
|
minecraft/auth/providers/MojangAuthProvider.h
|
||||||
minecraft/auth/providers/MicrosoftAuthProvider.h
|
minecraft/auth/providers/MicrosoftAuthProvider.h
|
||||||
@@ -231,6 +231,8 @@ set(MINECRAFT_SOURCES
|
|||||||
minecraft/auth/flows/Mojang.h
|
minecraft/auth/flows/Mojang.h
|
||||||
minecraft/auth/flows/MSA.cpp
|
minecraft/auth/flows/MSA.cpp
|
||||||
minecraft/auth/flows/MSA.h
|
minecraft/auth/flows/MSA.h
|
||||||
|
minecraft/auth/flows/Local.cpp
|
||||||
|
minecraft/auth/flows/Local.h
|
||||||
|
|
||||||
minecraft/auth/steps/EntitlementsStep.cpp
|
minecraft/auth/steps/EntitlementsStep.cpp
|
||||||
minecraft/auth/steps/EntitlementsStep.h
|
minecraft/auth/steps/EntitlementsStep.h
|
||||||
@@ -246,6 +248,8 @@ set(MINECRAFT_SOURCES
|
|||||||
minecraft/auth/steps/MinecraftProfileStep.h
|
minecraft/auth/steps/MinecraftProfileStep.h
|
||||||
minecraft/auth/steps/MSAStep.cpp
|
minecraft/auth/steps/MSAStep.cpp
|
||||||
minecraft/auth/steps/MSAStep.h
|
minecraft/auth/steps/MSAStep.h
|
||||||
|
minecraft/auth/steps/LocalStep.cpp
|
||||||
|
minecraft/auth/steps/LocalStep.h
|
||||||
minecraft/auth/steps/XboxAuthorizationStep.cpp
|
minecraft/auth/steps/XboxAuthorizationStep.cpp
|
||||||
minecraft/auth/steps/XboxAuthorizationStep.h
|
minecraft/auth/steps/XboxAuthorizationStep.h
|
||||||
minecraft/auth/steps/XboxProfileStep.cpp
|
minecraft/auth/steps/XboxProfileStep.cpp
|
||||||
|
@@ -121,13 +121,89 @@ void LaunchController::login() {
|
|||||||
m_session->wants_online = m_online;
|
m_session->wants_online = m_online;
|
||||||
m_accountToUse->fillSession(m_session);
|
m_accountToUse->fillSession(m_session);
|
||||||
|
|
||||||
|
if (m_accountToUse->typeString() == "local" || m_accountToUse->typeString() == "elyby") {
|
||||||
|
launchInstance();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
switch(m_accountToUse->accountState()) {
|
switch(m_accountToUse->accountState()) {
|
||||||
case AccountState::Offline: {
|
case AccountState::Offline: {
|
||||||
m_session->wants_online = false;
|
m_session->wants_online = false;
|
||||||
// NOTE: fallthrough is intentional
|
// NOTE: fallthrough is intentional
|
||||||
}
|
}
|
||||||
case AccountState::Online: {
|
case AccountState::Online: {
|
||||||
launchInstance();
|
if(!m_session->wants_online) {
|
||||||
|
QString usedname;
|
||||||
|
if(m_offlineName.isEmpty()) {
|
||||||
|
// we ask the user for a player name
|
||||||
|
bool ok = false;
|
||||||
|
QString lastOfflinePlayerName = APPLICATION->settings()->get("LastOfflinePlayerName").toString();
|
||||||
|
usedname = lastOfflinePlayerName.isEmpty() ? m_session->player_name : lastOfflinePlayerName;
|
||||||
|
QString name = QInputDialog::getText(
|
||||||
|
m_parentWidget,
|
||||||
|
tr("Player name"),
|
||||||
|
tr("Choose your offline mode player name."),
|
||||||
|
QLineEdit::Normal,
|
||||||
|
usedname,
|
||||||
|
&ok
|
||||||
|
);
|
||||||
|
if (!ok)
|
||||||
|
{
|
||||||
|
tryagain = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (name.length())
|
||||||
|
{
|
||||||
|
usedname = name;
|
||||||
|
APPLICATION->settings()->set("LastOfflinePlayerName", usedname);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
usedname = m_offlineName;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_session->MakeOffline(usedname);
|
||||||
|
// offline flavored game from here :3
|
||||||
|
}
|
||||||
|
if(m_accountToUse->ownsMinecraft()) {
|
||||||
|
if(!m_accountToUse->hasProfile()) {
|
||||||
|
// Now handle setting up a profile name here...
|
||||||
|
ProfileSetupDialog dialog(m_accountToUse, m_parentWidget);
|
||||||
|
if (dialog.exec() == QDialog::Accepted)
|
||||||
|
{
|
||||||
|
tryagain = true;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
emitFailed(tr("Received undetermined session status during login."));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// we own Minecraft, there is a profile, it's all ready to go!
|
||||||
|
launchInstance();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// play demo ?
|
||||||
|
QMessageBox box(m_parentWidget);
|
||||||
|
box.setWindowTitle(tr("Play demo?"));
|
||||||
|
box.setText(tr("This account does not own Minecraft.\nYou need to purchase the game first to play it.\n\nDo you want to play the demo?"));
|
||||||
|
box.setIcon(QMessageBox::Warning);
|
||||||
|
auto demoButton = box.addButton(tr("Play Demo"), QMessageBox::ButtonRole::YesRole);
|
||||||
|
auto cancelButton = box.addButton(tr("Cancel"), QMessageBox::ButtonRole::NoRole);
|
||||||
|
box.setDefaultButton(cancelButton);
|
||||||
|
|
||||||
|
box.exec();
|
||||||
|
if(box.clickedButton() == demoButton) {
|
||||||
|
// play demo here
|
||||||
|
m_session->MakeDemo();
|
||||||
|
launchInstance();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
emitFailed(tr("Launch cancelled - account does not own Minecraft."));
|
||||||
|
}
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
case AccountState::Errored:
|
case AccountState::Errored:
|
||||||
|
@@ -316,10 +316,6 @@ QStringList MinecraftInstance::javaArguments() const
|
|||||||
{
|
{
|
||||||
QStringList args;
|
QStringList args;
|
||||||
|
|
||||||
if (m_injector) {
|
|
||||||
args.append(m_injector->javaArg);
|
|
||||||
}
|
|
||||||
|
|
||||||
// custom args go first. we want to override them if we have our own here.
|
// custom args go first. we want to override them if we have our own here.
|
||||||
args.append(extraArguments());
|
args.append(extraArguments());
|
||||||
|
|
||||||
@@ -370,6 +366,11 @@ QStringList MinecraftInstance::javaArguments() const
|
|||||||
|
|
||||||
args << "-Duser.language=en";
|
args << "-Duser.language=en";
|
||||||
|
|
||||||
|
if (m_injector) {
|
||||||
|
args << m_injector->javaArg;
|
||||||
|
args << "-Dauthlibinjector.noShowServerName";
|
||||||
|
}
|
||||||
|
|
||||||
return args;
|
return args;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -916,15 +917,11 @@ shared_qobject_ptr<LaunchTask> MinecraftInstance::createLaunchTask(AuthSessionPt
|
|||||||
process->appendStep(step);
|
process->appendStep(step);
|
||||||
}
|
}
|
||||||
|
|
||||||
// if we aren't in offline mode,.
|
if(session->status != AuthSession::PlayableOffline)
|
||||||
/*if(session->status != AuthSession::PlayableOffline)
|
|
||||||
{
|
|
||||||
process->appendStep(new ClaimAccount(pptr, session));
|
|
||||||
}*/
|
|
||||||
|
|
||||||
// do update only if we're in online mode
|
|
||||||
if (session->wants_online)
|
|
||||||
{
|
{
|
||||||
|
if(!session->demo) {
|
||||||
|
process->appendStep(new ClaimAccount(pptr, session));
|
||||||
|
}
|
||||||
process->appendStep(new Update(pptr, Net::Mode::Online));
|
process->appendStep(new Update(pptr, Net::Mode::Online));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@@ -314,9 +314,18 @@ bool AccountData::resumeStateFromV3(QJsonObject data) {
|
|||||||
if(typeS == "MSA") {
|
if(typeS == "MSA") {
|
||||||
type = AccountType::MSA;
|
type = AccountType::MSA;
|
||||||
provider = AuthProviders::lookup("MSA");
|
provider = AuthProviders::lookup("MSA");
|
||||||
} else {
|
} else if (typeS == "Mojang"){
|
||||||
type = AccountType::Mojang;
|
type = AccountType::Mojang;
|
||||||
provider = AuthProviders::lookup(typeS);
|
provider = AuthProviders::lookup("mojang");
|
||||||
|
} else if (typeS == "Local") {
|
||||||
|
type = AccountType::Local;
|
||||||
|
provider = AuthProviders::lookup("local");
|
||||||
|
} else if (typeS == "Elyby") {
|
||||||
|
type = AccountType::Elyby;
|
||||||
|
provider = AuthProviders::lookup("elyby");
|
||||||
|
} else {
|
||||||
|
qWarning() << "Failed to parse account data: type is not recognized.";
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(type == AccountType::Mojang) {
|
if(type == AccountType::Mojang) {
|
||||||
@@ -349,7 +358,7 @@ bool AccountData::resumeStateFromV3(QJsonObject data) {
|
|||||||
QJsonObject AccountData::saveState() const {
|
QJsonObject AccountData::saveState() const {
|
||||||
QJsonObject output;
|
QJsonObject output;
|
||||||
if(type == AccountType::Mojang) {
|
if(type == AccountType::Mojang) {
|
||||||
output["type"] = provider->id();
|
output["type"] = "Mojang";
|
||||||
if(legacy) {
|
if(legacy) {
|
||||||
output["legacy"] = true;
|
output["legacy"] = true;
|
||||||
}
|
}
|
||||||
@@ -366,6 +375,10 @@ QJsonObject AccountData::saveState() const {
|
|||||||
tokenToJSONV3(output, userToken, "utoken");
|
tokenToJSONV3(output, userToken, "utoken");
|
||||||
tokenToJSONV3(output, xboxApiToken, "xrp-main");
|
tokenToJSONV3(output, xboxApiToken, "xrp-main");
|
||||||
tokenToJSONV3(output, mojangservicesToken, "xrp-mc");
|
tokenToJSONV3(output, mojangservicesToken, "xrp-mc");
|
||||||
|
} else if (type == AccountType::Local) {
|
||||||
|
output["type"] = "Local";
|
||||||
|
} else if (type == AccountType::Elyby) {
|
||||||
|
output["type"] = "Elyby";
|
||||||
}
|
}
|
||||||
|
|
||||||
tokenToJSONV3(output, yggdrasilToken, "ygg");
|
tokenToJSONV3(output, yggdrasilToken, "ygg");
|
||||||
@@ -419,8 +432,7 @@ QString AccountData::profileId() const {
|
|||||||
|
|
||||||
QString AccountData::profileName() const {
|
QString AccountData::profileName() const {
|
||||||
if(minecraftProfile.name.size() == 0) {
|
if(minecraftProfile.name.size() == 0) {
|
||||||
// Fix for too long of a name
|
return QObject::tr("No profile (%1)").arg(accountDisplayString());
|
||||||
return QObject::tr("%1").arg(accountDisplayString());
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return minecraftProfile.name;
|
return minecraftProfile.name;
|
||||||
@@ -429,7 +441,8 @@ QString AccountData::profileName() const {
|
|||||||
|
|
||||||
QString AccountData::accountDisplayString() const {
|
QString AccountData::accountDisplayString() const {
|
||||||
switch(type) {
|
switch(type) {
|
||||||
case AccountType::Mojang: {
|
case AccountType::Mojang:
|
||||||
|
case AccountType::Elyby: {
|
||||||
return userName();
|
return userName();
|
||||||
}
|
}
|
||||||
case AccountType::MSA: {
|
case AccountType::MSA: {
|
||||||
@@ -438,6 +451,9 @@ QString AccountData::accountDisplayString() const {
|
|||||||
}
|
}
|
||||||
return "Xbox profile missing";
|
return "Xbox profile missing";
|
||||||
}
|
}
|
||||||
|
case AccountType::Local: {
|
||||||
|
return "<Local>";
|
||||||
|
}
|
||||||
default: {
|
default: {
|
||||||
return "Invalid Account";
|
return "Invalid Account";
|
||||||
}
|
}
|
||||||
|
@@ -40,7 +40,9 @@ struct MinecraftProfile {
|
|||||||
|
|
||||||
enum class AccountType {
|
enum class AccountType {
|
||||||
MSA,
|
MSA,
|
||||||
Mojang
|
Mojang,
|
||||||
|
Local,
|
||||||
|
Elyby
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class AccountState {
|
enum class AccountState {
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
#include "AuthProviders.h"
|
#include "AuthProviders.h"
|
||||||
#include "providers/ElybyAuthProvider.h"
|
#include "providers/ElybyAuthProvider.h"
|
||||||
#include "providers/DummyAuthProvider.h"
|
#include "providers/LocalAuthProvider.h"
|
||||||
#include "providers/MojangAuthProvider.h"
|
#include "providers/MojangAuthProvider.h"
|
||||||
#include "providers/MicrosoftAuthProvider.h"
|
#include "providers/MicrosoftAuthProvider.h"
|
||||||
#include "../../AuthServer.h"
|
#include "../../AuthServer.h"
|
||||||
@@ -19,7 +19,7 @@ namespace AuthProviders
|
|||||||
void load(std::shared_ptr<AuthServer> authserver)
|
void load(std::shared_ptr<AuthServer> authserver)
|
||||||
{
|
{
|
||||||
REGISTER_AUTH_PROVIDER(ElybyAuthProvider);
|
REGISTER_AUTH_PROVIDER(ElybyAuthProvider);
|
||||||
REGISTER_AUTH_PROVIDER(DummyAuthProvider);
|
REGISTER_AUTH_PROVIDER(LocalAuthProvider);
|
||||||
REGISTER_AUTH_PROVIDER(MojangAuthProvider);
|
REGISTER_AUTH_PROVIDER(MojangAuthProvider);
|
||||||
REGISTER_AUTH_PROVIDER(MicrosoftAuthProvider);
|
REGISTER_AUTH_PROVIDER(MicrosoftAuthProvider);
|
||||||
}
|
}
|
||||||
|
@@ -31,11 +31,13 @@
|
|||||||
#include "AuthProviders.h"
|
#include "AuthProviders.h"
|
||||||
#include "flows/MSA.h"
|
#include "flows/MSA.h"
|
||||||
#include "flows/Mojang.h"
|
#include "flows/Mojang.h"
|
||||||
|
#include "flows/Local.h"
|
||||||
|
|
||||||
MinecraftAccount::MinecraftAccount(QObject* parent) : QObject(parent) {
|
MinecraftAccount::MinecraftAccount(QObject* parent) : QObject(parent) {
|
||||||
data.internalId = QUuid::createUuid().toString().remove(QRegExp("[{}-]"));
|
data.internalId = QUuid::createUuid().toString().remove(QRegExp("[{}-]"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
MinecraftAccountPtr MinecraftAccount::loadFromJsonV2(const QJsonObject& json) {
|
MinecraftAccountPtr MinecraftAccount::loadFromJsonV2(const QJsonObject& json) {
|
||||||
MinecraftAccountPtr account(new MinecraftAccount());
|
MinecraftAccountPtr account(new MinecraftAccount());
|
||||||
if(account->data.resumeStateFromV2(json)) {
|
if(account->data.resumeStateFromV2(json)) {
|
||||||
@@ -58,7 +60,62 @@ MinecraftAccountPtr MinecraftAccount::createFromUsername(const QString &username
|
|||||||
account->data.type = AccountType::Mojang;
|
account->data.type = AccountType::Mojang;
|
||||||
account->data.yggdrasilToken.extra["userName"] = username;
|
account->data.yggdrasilToken.extra["userName"] = username;
|
||||||
account->data.yggdrasilToken.extra["clientToken"] = QUuid::createUuid().toString().remove(QRegExp("[{}-]"));
|
account->data.yggdrasilToken.extra["clientToken"] = QUuid::createUuid().toString().remove(QRegExp("[{}-]"));
|
||||||
|
return account;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Taken from Prism Launcher, just for compatibility with their UUIDs
|
||||||
|
static QUuid uuidFromUsername(QString username)
|
||||||
|
{
|
||||||
|
auto input = QString("OfflinePlayer:%1").arg(username).toUtf8();
|
||||||
|
|
||||||
|
// basically a reimplementation of Java's UUID#nameUUIDFromBytes
|
||||||
|
QByteArray digest = QCryptographicHash::hash(input, QCryptographicHash::Md5);
|
||||||
|
|
||||||
|
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||||
|
auto bOr = [](QByteArray& array, int index, char value) { array[index] = array.at(index) | value; };
|
||||||
|
auto bAnd = [](QByteArray& array, int index, char value) { array[index] = array.at(index) & value; };
|
||||||
|
#else
|
||||||
|
auto bOr = [](QByteArray& array, qsizetype index, char value) { array[index] |= value; };
|
||||||
|
auto bAnd = [](QByteArray& array, qsizetype index, char value) { array[index] &= value; };
|
||||||
|
#endif
|
||||||
|
bAnd(digest, 6, (char)0x0f); // clear version
|
||||||
|
bOr(digest, 6, (char)0x30); // set to version 3
|
||||||
|
bAnd(digest, 8, (char)0x3f); // clear variant
|
||||||
|
bOr(digest, 8, (char)0x80); // set to IETF variant
|
||||||
|
|
||||||
|
return QUuid::fromRfc4122(digest);
|
||||||
|
}
|
||||||
|
|
||||||
|
MinecraftAccountPtr MinecraftAccount::createLocal(const QString &username)
|
||||||
|
{
|
||||||
|
MinecraftAccountPtr account = new MinecraftAccount();
|
||||||
|
account->data.type = AccountType::Local;
|
||||||
|
account->data.yggdrasilToken.validity = Katabasis::Validity::Certain;
|
||||||
|
account->data.yggdrasilToken.issueInstant = QDateTime::currentDateTimeUtc();
|
||||||
|
account->data.yggdrasilToken.extra["userName"] = username;
|
||||||
|
account->data.yggdrasilToken.extra["clientToken"] = QUuid::createUuid().toString().remove(QRegExp("[{}-]"));
|
||||||
|
account->data.minecraftProfile.id = uuidFromUsername(username).toString().remove(QRegExp("[{}-]"));
|
||||||
account->data.minecraftProfile.id = account->data.internalId;
|
account->data.minecraftProfile.id = account->data.internalId;
|
||||||
|
account->data.minecraftProfile.name = username;
|
||||||
|
account->data.minecraftProfile.validity = Katabasis::Validity::Certain;
|
||||||
|
account->data.minecraftEntitlement.ownsMinecraft = true;
|
||||||
|
account->data.minecraftEntitlement.canPlayMinecraft = true;
|
||||||
|
return account;
|
||||||
|
}
|
||||||
|
|
||||||
|
MinecraftAccountPtr MinecraftAccount::createElyby(const QString &username)
|
||||||
|
{
|
||||||
|
MinecraftAccountPtr account = new MinecraftAccount();
|
||||||
|
account->data.type = AccountType::Elyby;
|
||||||
|
account->data.yggdrasilToken.extra["userName"] = username;
|
||||||
|
account->data.yggdrasilToken.extra["clientToken"] = QUuid::createUuid().toString().remove(QRegExp("[{}-]"));
|
||||||
|
account->data.minecraftProfile.id = account->data.internalId;
|
||||||
|
account->data.minecraftProfile.name = username;
|
||||||
|
account->data.minecraftProfile.validity = Katabasis::Validity::Certain;
|
||||||
|
account->data.validity_ = Katabasis::Validity::Certain;
|
||||||
|
account->data.minecraftEntitlement.ownsMinecraft = true;
|
||||||
|
account->data.minecraftEntitlement.canPlayMinecraft = true;
|
||||||
|
account->data.minecraftEntitlement.validity = Katabasis::Validity::Certain;
|
||||||
return account;
|
return account;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -113,6 +170,16 @@ shared_qobject_ptr<AccountTask> MinecraftAccount::loginMSA() {
|
|||||||
return m_currentTask;
|
return m_currentTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
shared_qobject_ptr<AccountTask> MinecraftAccount::loginLocal() {
|
||||||
|
Q_ASSERT(m_currentTask.get() == nullptr);
|
||||||
|
|
||||||
|
m_currentTask.reset(new LocalLogin(&data));
|
||||||
|
connect(m_currentTask.get(), SIGNAL(succeeded()), SLOT(authSucceeded()));
|
||||||
|
connect(m_currentTask.get(), SIGNAL(failed(QString)), SLOT(authFailed(QString)));
|
||||||
|
emit activityChanged(true);
|
||||||
|
return m_currentTask;
|
||||||
|
}
|
||||||
|
|
||||||
shared_qobject_ptr<AccountTask> MinecraftAccount::refresh() {
|
shared_qobject_ptr<AccountTask> MinecraftAccount::refresh() {
|
||||||
if(m_currentTask) {
|
if(m_currentTask) {
|
||||||
return m_currentTask;
|
return m_currentTask;
|
||||||
@@ -121,9 +188,12 @@ shared_qobject_ptr<AccountTask> MinecraftAccount::refresh() {
|
|||||||
if(data.type == AccountType::MSA) {
|
if(data.type == AccountType::MSA) {
|
||||||
m_currentTask.reset(new MSASilent(&data));
|
m_currentTask.reset(new MSASilent(&data));
|
||||||
}
|
}
|
||||||
else {
|
else if (data.type == AccountType::Mojang) {
|
||||||
m_currentTask.reset(new MojangRefresh(&data));
|
m_currentTask.reset(new MojangRefresh(&data));
|
||||||
}
|
}
|
||||||
|
else if (data.type == AccountType::Local) {
|
||||||
|
m_currentTask.reset(new LocalRefresh(&data));
|
||||||
|
}
|
||||||
|
|
||||||
connect(m_currentTask.get(), SIGNAL(succeeded()), SLOT(authSucceeded()));
|
connect(m_currentTask.get(), SIGNAL(succeeded()), SLOT(authSucceeded()));
|
||||||
connect(m_currentTask.get(), SIGNAL(failed(QString)), SLOT(authFailed(QString)));
|
connect(m_currentTask.get(), SIGNAL(failed(QString)), SLOT(authFailed(QString)));
|
||||||
|
@@ -74,6 +74,10 @@ public: /* construction */
|
|||||||
|
|
||||||
static MinecraftAccountPtr createFromUsername(const QString &username);
|
static MinecraftAccountPtr createFromUsername(const QString &username);
|
||||||
|
|
||||||
|
static MinecraftAccountPtr createLocal(const QString &username);
|
||||||
|
|
||||||
|
static MinecraftAccountPtr createElyby(const QString &username);
|
||||||
|
|
||||||
static MinecraftAccountPtr createBlankMSA();
|
static MinecraftAccountPtr createBlankMSA();
|
||||||
|
|
||||||
static MinecraftAccountPtr loadFromJsonV2(const QJsonObject &json);
|
static MinecraftAccountPtr loadFromJsonV2(const QJsonObject &json);
|
||||||
@@ -92,6 +96,8 @@ public: /* manipulation */
|
|||||||
|
|
||||||
shared_qobject_ptr<AccountTask> loginMSA();
|
shared_qobject_ptr<AccountTask> loginMSA();
|
||||||
|
|
||||||
|
shared_qobject_ptr<AccountTask> loginLocal();
|
||||||
|
|
||||||
shared_qobject_ptr<AccountTask> refresh();
|
shared_qobject_ptr<AccountTask> refresh();
|
||||||
|
|
||||||
shared_qobject_ptr<AccountTask> currentTask();
|
shared_qobject_ptr<AccountTask> currentTask();
|
||||||
@@ -161,6 +167,14 @@ public: /* queries */
|
|||||||
return "msa";
|
return "msa";
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case AccountType::Local: {
|
||||||
|
return "local";
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case AccountType::Elyby: {
|
||||||
|
return "elyby";
|
||||||
|
}
|
||||||
|
break;
|
||||||
default: {
|
default: {
|
||||||
return "unknown";
|
return "unknown";
|
||||||
}
|
}
|
||||||
|
17
launcher/minecraft/auth/flows/Local.cpp
Normal file
17
launcher/minecraft/auth/flows/Local.cpp
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
#include "Local.h"
|
||||||
|
|
||||||
|
#include "minecraft/auth/steps/LocalStep.h"
|
||||||
|
|
||||||
|
LocalRefresh::LocalRefresh(
|
||||||
|
AccountData *data,
|
||||||
|
QObject *parent
|
||||||
|
) : AuthFlow(data, parent) {
|
||||||
|
m_steps.append(new LocalStep(m_data));
|
||||||
|
}
|
||||||
|
|
||||||
|
LocalLogin::LocalLogin(
|
||||||
|
AccountData *data,
|
||||||
|
QObject *parent
|
||||||
|
): AuthFlow(data, parent) {
|
||||||
|
m_steps.append(new LocalStep(m_data));
|
||||||
|
}
|
22
launcher/minecraft/auth/flows/Local.h
Normal file
22
launcher/minecraft/auth/flows/Local.h
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "AuthFlow.h"
|
||||||
|
|
||||||
|
class LocalRefresh : public AuthFlow
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit LocalRefresh(
|
||||||
|
AccountData *data,
|
||||||
|
QObject *parent = 0
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
class LocalLogin : public AuthFlow
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit LocalLogin(
|
||||||
|
AccountData *data,
|
||||||
|
QObject *parent = 0
|
||||||
|
);
|
||||||
|
};
|
@@ -9,14 +9,14 @@
|
|||||||
|
|
||||||
#include "BaseAuthProvider.h"
|
#include "BaseAuthProvider.h"
|
||||||
|
|
||||||
class DummyAuthProvider : public BaseAuthProvider
|
class LocalAuthProvider : public BaseAuthProvider
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QString id()
|
QString id()
|
||||||
{
|
{
|
||||||
return "dummy";
|
return "local";
|
||||||
}
|
}
|
||||||
|
|
||||||
QString displayName()
|
QString displayName()
|
||||||
@@ -24,7 +24,7 @@ public:
|
|||||||
return "Local";
|
return "Local";
|
||||||
}
|
}
|
||||||
|
|
||||||
bool dummyAuth()
|
bool localAuth()
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
23
launcher/minecraft/auth/steps/LocalStep.cpp
Normal file
23
launcher/minecraft/auth/steps/LocalStep.cpp
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
#include "LocalStep.h"
|
||||||
|
|
||||||
|
#include "Application.h"
|
||||||
|
|
||||||
|
// This step does nothing but just log that we created a local account.
|
||||||
|
|
||||||
|
LocalStep::LocalStep(AccountData* data) : AuthStep(data) {}
|
||||||
|
LocalStep::~LocalStep() noexcept = default;
|
||||||
|
|
||||||
|
QString LocalStep::describe()
|
||||||
|
{
|
||||||
|
return tr("Creating local account.");
|
||||||
|
}
|
||||||
|
|
||||||
|
void LocalStep::rehydrate()
|
||||||
|
{
|
||||||
|
// NOOP
|
||||||
|
}
|
||||||
|
|
||||||
|
void LocalStep::perform()
|
||||||
|
{
|
||||||
|
emit finished(AccountTaskState::STATE_WORKING, tr("Created local account."));
|
||||||
|
}
|
19
launcher/minecraft/auth/steps/LocalStep.h
Normal file
19
launcher/minecraft/auth/steps/LocalStep.h
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <QObject>
|
||||||
|
|
||||||
|
#include "QObjectPtr.h"
|
||||||
|
#include "minecraft/auth/AuthStep.h"
|
||||||
|
|
||||||
|
#include <katabasis/DeviceFlow.h>
|
||||||
|
|
||||||
|
class LocalStep : public AuthStep {
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit LocalStep(AccountData* data);
|
||||||
|
virtual ~LocalStep() noexcept;
|
||||||
|
|
||||||
|
void perform() override;
|
||||||
|
void rehydrate() override;
|
||||||
|
|
||||||
|
QString describe() override;
|
||||||
|
};
|
@@ -42,7 +42,6 @@ void MinecraftProfileStep::onRequestDone(
|
|||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
qDebug() << data;
|
qDebug() << data;
|
||||||
#endif
|
#endif
|
||||||
/*
|
|
||||||
if (error == QNetworkReply::ContentNotFoundError) {
|
if (error == QNetworkReply::ContentNotFoundError) {
|
||||||
// NOTE: Succeed even if we do not have a profile. This is a valid account state.
|
// NOTE: Succeed even if we do not have a profile. This is a valid account state.
|
||||||
if(m_data->type == AccountType::Mojang) {
|
if(m_data->type == AccountType::Mojang) {
|
||||||
@@ -70,23 +69,21 @@ void MinecraftProfileStep::onRequestDone(
|
|||||||
tr("Minecraft Java profile acquisition failed.")
|
tr("Minecraft Java profile acquisition failed.")
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}*/
|
}
|
||||||
/*if(!Parsers::parseMinecraftProfile(data, m_data->minecraftProfile)) {
|
if(!Parsers::parseMinecraftProfile(data, m_data->minecraftProfile)) {
|
||||||
m_data->minecraftProfile = MinecraftProfile();
|
m_data->minecraftProfile = MinecraftProfile();
|
||||||
emit finished(
|
emit finished(
|
||||||
AccountTaskState::STATE_FAILED_SOFT,
|
AccountTaskState::STATE_FAILED_SOFT,
|
||||||
tr("Minecraft Java profile response could not be parsed")
|
tr("Minecraft Java profile response could not be parsed")
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}*/
|
}
|
||||||
|
|
||||||
if(m_data->type == AccountType::Mojang) {
|
if(m_data->type == AccountType::Mojang) {
|
||||||
//auto validProfile = m_data->minecraftProfile.validity == Katabasis::Validity::Certain;
|
auto validProfile = m_data->minecraftProfile.validity == Katabasis::Validity::Certain;
|
||||||
// IDK if this should be modified or not but still just to be sure
|
m_data->minecraftEntitlement.canPlayMinecraft = validProfile;
|
||||||
m_data->minecraftEntitlement.canPlayMinecraft = true;
|
m_data->minecraftEntitlement.ownsMinecraft = validProfile;
|
||||||
m_data->minecraftEntitlement.ownsMinecraft = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
emit finished(
|
emit finished(
|
||||||
AccountTaskState::STATE_WORKING,
|
AccountTaskState::STATE_WORKING,
|
||||||
tr("Minecraft Java profile acquisition succeeded.")
|
tr("Minecraft Java profile acquisition succeeded.")
|
||||||
|
@@ -27,12 +27,11 @@ void LocalLoginDialog::accept()
|
|||||||
setUserInputsEnabled(false);
|
setUserInputsEnabled(false);
|
||||||
ui->progressBar->setVisible(true);
|
ui->progressBar->setVisible(true);
|
||||||
|
|
||||||
m_account = MinecraftAccount::createFromUsername(ui->userTextBox->text());
|
m_account = MinecraftAccount::createLocal(ui->userTextBox->text());
|
||||||
m_account->setProvider(AuthProviders::lookup("dummy"));
|
m_account->setProvider(AuthProviders::lookup("local"));
|
||||||
|
|
||||||
// Setup the login task and start it
|
// Setup the login task and start it
|
||||||
const char *dummy_password = " ";
|
m_loginTask = m_account->loginLocal();
|
||||||
m_loginTask = m_account->login(QString::fromLatin1(dummy_password));
|
|
||||||
connect(m_loginTask.get(), &Task::failed, this, &LocalLoginDialog::onTaskFailed);
|
connect(m_loginTask.get(), &Task::failed, this, &LocalLoginDialog::onTaskFailed);
|
||||||
connect(m_loginTask.get(), &Task::succeeded, this, &LocalLoginDialog::onTaskSucceeded);
|
connect(m_loginTask.get(), &Task::succeeded, this, &LocalLoginDialog::onTaskSucceeded);
|
||||||
connect(m_loginTask.get(), &Task::status, this, &LocalLoginDialog::onTaskStatus);
|
connect(m_loginTask.get(), &Task::status, this, &LocalLoginDialog::onTaskStatus);
|
||||||
|
@@ -30,7 +30,7 @@ LoginDialog::LoginDialog(QWidget *parent) : QDialog(parent), ui(new Ui::LoginDia
|
|||||||
for(auto provider: AuthProviders::getAll()) {
|
for(auto provider: AuthProviders::getAll()) {
|
||||||
auto providerId = provider->id();
|
auto providerId = provider->id();
|
||||||
// Exclude Microsoft and Local accounts from here...
|
// Exclude Microsoft and Local accounts from here...
|
||||||
if (providerId != "MSA" && providerId != "dummy") {
|
if (providerId != "MSA" && providerId != "local") {
|
||||||
QRadioButton *button = new QRadioButton(provider->displayName());
|
QRadioButton *button = new QRadioButton(provider->displayName());
|
||||||
m_radioButtons[providerId] = button;
|
m_radioButtons[providerId] = button;
|
||||||
ui->radioLayout->addWidget(button);
|
ui->radioLayout->addWidget(button);
|
||||||
|
@@ -59,9 +59,7 @@ ProfileSetupDialog::~ProfileSetupDialog()
|
|||||||
|
|
||||||
void ProfileSetupDialog::on_buttonBox_accepted()
|
void ProfileSetupDialog::on_buttonBox_accepted()
|
||||||
{
|
{
|
||||||
//setNameStatus(NameStatus::Available);
|
setupProfile(currentCheck);
|
||||||
accept();
|
|
||||||
//setupProfile(currentCheck);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProfileSetupDialog::on_buttonBox_rejected()
|
void ProfileSetupDialog::on_buttonBox_rejected()
|
||||||
@@ -173,8 +171,7 @@ void ProfileSetupDialog::checkFinished(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
setNameStatus(NameStatus::Available);
|
setNameStatus(NameStatus::Error, tr("Failed to check name availability."));
|
||||||
//setNameStatus(NameStatus::Error, tr("Failed to check name availability."));
|
|
||||||
}
|
}
|
||||||
isChecking = false;
|
isChecking = false;
|
||||||
}
|
}
|
||||||
@@ -241,7 +238,7 @@ void ProfileSetupDialog::setupProfileFinished(
|
|||||||
requestor->deleteLater();
|
requestor->deleteLater();
|
||||||
|
|
||||||
isWorking = false;
|
isWorking = false;
|
||||||
if(error != QNetworkReply::NoError) {
|
if(error == QNetworkReply::NoError) {
|
||||||
/*
|
/*
|
||||||
* data contains the profile in the response
|
* data contains the profile in the response
|
||||||
* ... we could parse it and update the account, but let's just return back to the normal login flow instead...
|
* ... we could parse it and update the account, but let's just return back to the normal login flow instead...
|
||||||
|
@@ -215,24 +215,19 @@ void AccountListPage::updateButtonStates()
|
|||||||
QModelIndexList selection = ui->listView->selectionModel()->selectedIndexes();
|
QModelIndexList selection = ui->listView->selectionModel()->selectedIndexes();
|
||||||
bool hasSelection = selection.size() > 0;
|
bool hasSelection = selection.size() > 0;
|
||||||
bool accountIsReady = false;
|
bool accountIsReady = false;
|
||||||
|
bool accountIsOnline = false;
|
||||||
if (hasSelection)
|
if (hasSelection)
|
||||||
{
|
{
|
||||||
QModelIndex selected = selection.first();
|
QModelIndex selected = selection.first();
|
||||||
MinecraftAccountPtr account = selected.data(AccountList::PointerRole).value<MinecraftAccountPtr>();
|
MinecraftAccountPtr account = selected.data(AccountList::PointerRole).value<MinecraftAccountPtr>();
|
||||||
accountIsReady = !account->isActive();
|
accountIsReady = !account->isActive();
|
||||||
|
accountIsOnline = account->typeString() != "local" && account->typeString() != "elyby";
|
||||||
}
|
}
|
||||||
ui->actionRemove->setEnabled(accountIsReady);
|
ui->actionRemove->setEnabled(accountIsReady);
|
||||||
ui->actionSetDefault->setEnabled(accountIsReady);
|
ui->actionSetDefault->setEnabled(accountIsReady);
|
||||||
// Don't enable skin change buttons for dummy and ely.by accounts, they don't work.
|
ui->actionUploadSkin->setEnabled(accountIsReady && accountIsOnline);
|
||||||
if (hasSelection) {
|
ui->actionDeleteSkin->setEnabled(accountIsReady && accountIsOnline);
|
||||||
QModelIndex selected = selection.first();
|
ui->actionRefresh->setEnabled(accountIsReady && accountIsOnline);
|
||||||
MinecraftAccountPtr account = selected.data(AccountList::PointerRole).value<MinecraftAccountPtr>();
|
|
||||||
if (account->provider()->id() != "dummy" && account->provider()->id() != "elyby") {
|
|
||||||
ui->actionUploadSkin->setEnabled(accountIsReady);
|
|
||||||
ui->actionDeleteSkin->setEnabled(accountIsReady);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ui->actionRefresh->setEnabled(accountIsReady);
|
|
||||||
|
|
||||||
if(m_accounts->defaultAccount().get() == nullptr) {
|
if(m_accounts->defaultAccount().get() == nullptr) {
|
||||||
ui->actionNoDefault->setEnabled(false);
|
ui->actionNoDefault->setEnabled(false);
|
||||||
|
Reference in New Issue
Block a user