Fix twitch

This commit is contained in:
Petr Mrázek 2013-12-14 01:18:54 +01:00
parent 1e96a0c8eb
commit bbd17b6224
5 changed files with 25 additions and 12 deletions

View File

@ -152,8 +152,17 @@ QStringList OneSixInstance::processMinecraftArgs(MojangAccountPtr account)
token_mapping["game_directory"] = absRootDir; token_mapping["game_directory"] = absRootDir;
QString absAssetsDir = QDir("assets/").absolutePath(); QString absAssetsDir = QDir("assets/").absolutePath();
token_mapping["game_assets"] = reconstructAssets(d->version).absolutePath(); token_mapping["game_assets"] = reconstructAssets(d->version).absolutePath();
//TODO: this is something new and not even fully implemented in the vanilla launcher.
token_mapping["user_properties"] = "{ }"; auto user = account->user();
QJsonObject userAttrs;
for(auto key: user.properties.keys())
{
auto array = QJsonArray::fromStringList(user.properties.values(key));
userAttrs.insert(key, array);
}
QJsonDocument value(userAttrs);
token_mapping["user_properties"] = value.toJson(QJsonDocument::Compact);
token_mapping["user_type"] = account->currentProfile()->legacy ? "legacy" : "mojang"; token_mapping["user_type"] = account->currentProfile()->legacy ? "legacy" : "mojang";
// 1.7.3+ assets tokens // 1.7.3+ assets tokens
token_mapping["assets_root"] = absAssetsDir; token_mapping["assets_root"] = absAssetsDir;

View File

@ -68,6 +68,7 @@ MojangAccountPtr MojangAccount::loadFromJson(const QJsonObject &object)
User u; User u;
QJsonObject userStructure = object.value("user").toObject(); QJsonObject userStructure = object.value("user").toObject();
u.id = userStructure.value("id").toString(); u.id = userStructure.value("id").toString();
/*
QJsonObject propMap = userStructure.value("properties").toObject(); QJsonObject propMap = userStructure.value("properties").toObject();
for(auto key: propMap.keys()) for(auto key: propMap.keys())
{ {
@ -75,6 +76,7 @@ MojangAccountPtr MojangAccount::loadFromJson(const QJsonObject &object)
for(auto value: values) for(auto value: values)
u.properties.insert(key, value.toString()); u.properties.insert(key, value.toString());
} }
*/
account->m_user = u; account->m_user = u;
} }
account->m_username = username; account->m_username = username;
@ -119,6 +121,7 @@ QJsonObject MojangAccount::saveToJson() const
QJsonObject userStructure; QJsonObject userStructure;
{ {
userStructure.insert("id", m_user.id); userStructure.insert("id", m_user.id);
/*
QJsonObject userAttrs; QJsonObject userAttrs;
for(auto key: m_user.properties.keys()) for(auto key: m_user.properties.keys())
{ {
@ -126,6 +129,7 @@ QJsonObject MojangAccount::saveToJson() const
userAttrs.insert(key, array); userAttrs.insert(key, array);
} }
userStructure.insert("properties", userAttrs); userStructure.insert("properties", userAttrs);
*/
} }
json.insert("user", userStructure); json.insert("user", userStructure);

View File

@ -122,6 +122,11 @@ public: /* queries */
return m_profiles; return m_profiles;
} }
const User & user()
{
return m_user;
}
//! Get the session ID required for legacy Minecraft versions //! Get the session ID required for legacy Minecraft versions
QString sessionId() const QString sessionId() const
{ {

View File

@ -162,23 +162,17 @@ bool AuthenticateTask::processResponse(QJsonObject responseData)
} }
// this is what the vanilla launcher passes to the userProperties launch param // this is what the vanilla launcher passes to the userProperties launch param
// doesn't seem to be used for anything so far? I don't get any of this data on my account
// (peterixxx)
// is it a good idea to log this?
if (responseData.contains("user")) if (responseData.contains("user"))
{ {
User u; User u;
auto obj = responseData.value("user").toObject(); auto obj = responseData.value("user").toObject();
u.id = obj.value("id").toString(); u.id = obj.value("id").toString();
QLOG_DEBUG() << "User ID: " << u.id ;
auto propArray = obj.value("properties").toArray(); auto propArray = obj.value("properties").toArray();
QLOG_DEBUG() << "User Properties: ";
for (auto prop : propArray) for (auto prop : propArray)
{ {
auto propTuple = prop.toObject(); auto propTuple = prop.toObject();
auto name = propTuple.value("name").toString(); auto name = propTuple.value("name").toString();
auto value = propTuple.value("value").toString(); auto value = propTuple.value("value").toString();
QLOG_DEBUG() << name << " : " << value;
u.properties.insert(name, value); u.properties.insert(name, value);
} }
m_account->m_user = u; m_account->m_user = u;

View File

@ -112,20 +112,21 @@ bool RefreshTask::processResponse(QJsonObject responseData)
// this is what the vanilla launcher passes to the userProperties launch param // this is what the vanilla launcher passes to the userProperties launch param
if (responseData.contains("user")) if (responseData.contains("user"))
{ {
User u;
auto obj = responseData.value("user").toObject(); auto obj = responseData.value("user").toObject();
auto userId = obj.value("id").toString(); u.id = obj.value("id").toString();
auto propArray = obj.value("properties").toArray(); auto propArray = obj.value("properties").toArray();
QLOG_DEBUG() << "User ID: " << userId;
QLOG_DEBUG() << "User Properties: ";
for (auto prop : propArray) for (auto prop : propArray)
{ {
auto propTuple = prop.toObject(); auto propTuple = prop.toObject();
auto name = propTuple.value("name").toString(); auto name = propTuple.value("name").toString();
auto value = propTuple.value("value").toString(); auto value = propTuple.value("value").toString();
QLOG_DEBUG() << name << " : " << value; u.properties.insert(name, value);
} }
m_account->m_user = u;
} }
// We've made it through the minefield of possible errors. Return true to indicate that // We've made it through the minefield of possible errors. Return true to indicate that
// we've succeeded. // we've succeeded.
QLOG_DEBUG() << "Finished reading refresh response."; QLOG_DEBUG() << "Finished reading refresh response.";