summaryrefslogtreecommitdiffstats
path: root/logic/auth
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2015-02-02 02:14:14 +0100
committerPetr Mrázek <peterix@gmail.com>2015-04-12 20:57:17 +0200
commitcd9d37aac402b0edd0f12b66fd7f2fdd5fe6dff5 (patch)
treed8dd6499e29fbf5196b0d5a20f0a0da386b575bb /logic/auth
parent28a39ef7ac3e3dfe4ea65d02af01d1a18e3d4af6 (diff)
downloadMultiMC-cd9d37aac402b0edd0f12b66fd7f2fdd5fe6dff5.tar
MultiMC-cd9d37aac402b0edd0f12b66fd7f2fdd5fe6dff5.tar.gz
MultiMC-cd9d37aac402b0edd0f12b66fd7f2fdd5fe6dff5.tar.lz
MultiMC-cd9d37aac402b0edd0f12b66fd7f2fdd5fe6dff5.tar.xz
MultiMC-cd9d37aac402b0edd0f12b66fd7f2fdd5fe6dff5.zip
SCRATCH nuke the overcomplicated logger, use a simple one.
Diffstat (limited to 'logic/auth')
-rw-r--r--logic/auth/MojangAccount.cpp8
-rw-r--r--logic/auth/MojangAccountList.cpp28
-rw-r--r--logic/auth/YggdrasilTask.cpp12
-rw-r--r--logic/auth/flows/AuthenticateTask.cpp18
-rw-r--r--logic/auth/flows/RefreshTask.cpp10
-rw-r--r--logic/auth/flows/ValidateTask.cpp2
6 files changed, 39 insertions, 39 deletions
diff --git a/logic/auth/MojangAccount.cpp b/logic/auth/MojangAccount.cpp
index 19c56ae6..69a24c09 100644
--- a/logic/auth/MojangAccount.cpp
+++ b/logic/auth/MojangAccount.cpp
@@ -26,14 +26,14 @@
#include <QStringList>
#include <QJsonDocument>
-#include <logger/QsLog.h>
+#include <QDebug>
MojangAccountPtr MojangAccount::loadFromJson(const QJsonObject &object)
{
// The JSON object must at least have a username for it to be valid.
if (!object.value("username").isString())
{
- QLOG_ERROR() << "Can't load Mojang account info from JSON object. Username field is "
+ qCritical() << "Can't load Mojang account info from JSON object. Username field is "
"missing or of the wrong type.";
return nullptr;
}
@@ -45,7 +45,7 @@ MojangAccountPtr MojangAccount::loadFromJson(const QJsonObject &object)
QJsonArray profileArray = object.value("profiles").toArray();
if (profileArray.size() < 1)
{
- QLOG_ERROR() << "Can't load Mojang account with username \"" << username
+ qCritical() << "Can't load Mojang account with username \"" << username
<< "\". No profiles found.";
return nullptr;
}
@@ -59,7 +59,7 @@ MojangAccountPtr MojangAccount::loadFromJson(const QJsonObject &object)
bool legacy = profileObject.value("legacy").toBool(false);
if (id.isEmpty() || name.isEmpty())
{
- QLOG_WARN() << "Unable to load a profile because it was missing an ID or a name.";
+ qWarning() << "Unable to load a profile because it was missing an ID or a name.";
continue;
}
profiles.append({id, name, legacy});
diff --git a/logic/auth/MojangAccountList.cpp b/logic/auth/MojangAccountList.cpp
index 94cdf8b5..abed9b24 100644
--- a/logic/auth/MojangAccountList.cpp
+++ b/logic/auth/MojangAccountList.cpp
@@ -24,7 +24,7 @@
#include <QJsonParseError>
#include <QDir>
-#include "logger/QsLog.h"
+#include <QDebug>
#include "logic/auth/MojangAccount.h"
#include <pathutils.h>
@@ -262,7 +262,7 @@ bool MojangAccountList::loadList(const QString &filePath)
path = m_listFilePath;
if (path.isEmpty())
{
- QLOG_ERROR() << "Can't load Mojang account list. No file path given and no default set.";
+ qCritical() << "Can't load Mojang account list. No file path given and no default set.";
return false;
}
@@ -272,7 +272,7 @@ bool MojangAccountList::loadList(const QString &filePath)
// TODO: We should probably report this error to the user.
if (!file.open(QIODevice::ReadOnly))
{
- QLOG_ERROR() << QString("Failed to read the account list file (%1).").arg(path).toUtf8();
+ qCritical() << QString("Failed to read the account list file (%1).").arg(path).toUtf8();
return false;
}
@@ -286,7 +286,7 @@ bool MojangAccountList::loadList(const QString &filePath)
// Fail if the JSON is invalid.
if (parseError.error != QJsonParseError::NoError)
{
- QLOG_ERROR() << QString("Failed to parse account list file: %1 at offset %2")
+ qCritical() << QString("Failed to parse account list file: %1 at offset %2")
.arg(parseError.errorString(), QString::number(parseError.offset))
.toUtf8();
return false;
@@ -295,7 +295,7 @@ bool MojangAccountList::loadList(const QString &filePath)
// Make sure the root is an object.
if (!jsonDoc.isObject())
{
- QLOG_ERROR() << "Invalid account list JSON: Root should be an array.";
+ qCritical() << "Invalid account list JSON: Root should be an array.";
return false;
}
@@ -305,7 +305,7 @@ bool MojangAccountList::loadList(const QString &filePath)
if (root.value("formatVersion").toVariant().toInt() != ACCOUNT_LIST_FORMAT_VERSION)
{
QString newName = "accounts-old.json";
- QLOG_WARN() << "Format version mismatch when loading account list. Existing one will be renamed to"
+ qWarning() << "Format version mismatch when loading account list. Existing one will be renamed to"
<< newName;
// Attempt to rename the old version.
@@ -327,7 +327,7 @@ bool MojangAccountList::loadList(const QString &filePath)
}
else
{
- QLOG_WARN() << "Failed to load an account.";
+ qWarning() << "Failed to load an account.";
}
}
// Load the active account.
@@ -343,7 +343,7 @@ bool MojangAccountList::saveList(const QString &filePath)
path = m_listFilePath;
if (path.isEmpty())
{
- QLOG_ERROR() << "Can't save Mojang account list. No file path given and no default set.";
+ qCritical() << "Can't save Mojang account list. No file path given and no default set.";
return false;
}
@@ -359,16 +359,16 @@ bool MojangAccountList::saveList(const QString &filePath)
badDir.removeRecursively();
}
- QLOG_INFO() << "Writing account list to" << path;
+ qDebug() << "Writing account list to" << path;
- QLOG_DEBUG() << "Building JSON data structure.";
+ qDebug() << "Building JSON data structure.";
// Build the JSON document to write to the list file.
QJsonObject root;
root.insert("formatVersion", ACCOUNT_LIST_FORMAT_VERSION);
// Build a list of accounts.
- QLOG_DEBUG() << "Building account array.";
+ qDebug() << "Building account array.";
QJsonArray accounts;
for (MojangAccountPtr account : m_accounts)
{
@@ -389,14 +389,14 @@ bool MojangAccountList::saveList(const QString &filePath)
QJsonDocument doc(root);
// Now that we're done building the JSON object, we can write it to the file.
- QLOG_DEBUG() << "Writing account list to file.";
+ qDebug() << "Writing account list to file.";
QFile file(path);
// Try to open the file and fail if we can't.
// TODO: We should probably report this error to the user.
if (!file.open(QIODevice::WriteOnly))
{
- QLOG_ERROR() << QString("Failed to read the account list file (%1).").arg(path).toUtf8();
+ qCritical() << QString("Failed to read the account list file (%1).").arg(path).toUtf8();
return false;
}
@@ -405,7 +405,7 @@ bool MojangAccountList::saveList(const QString &filePath)
file.setPermissions(QFile::ReadOwner|QFile::WriteOwner|QFile::ReadUser|QFile::WriteUser);
file.close();
- QLOG_INFO() << "Saved account list to" << path;
+ qDebug() << "Saved account list to" << path;
return true;
}
diff --git a/logic/auth/YggdrasilTask.cpp b/logic/auth/YggdrasilTask.cpp
index 6b5ed256..4d5c2594 100644
--- a/logic/auth/YggdrasilTask.cpp
+++ b/logic/auth/YggdrasilTask.cpp
@@ -26,7 +26,7 @@
#include <logic/auth/MojangAccount.h>
#include <logic/net/URLConstants.h>
-#include "logger/QsLog.h"
+#include <QDebug>
YggdrasilTask::YggdrasilTask(MojangAccount *account, QObject *parent)
: Task(parent), m_account(account)
@@ -94,9 +94,9 @@ void YggdrasilTask::sslErrors(QList<QSslError> errors)
int i = 1;
for (auto error : errors)
{
- QLOG_ERROR() << "LOGIN SSL Error #" << i << " : " << error.errorString();
+ qCritical() << "LOGIN SSL Error #" << i << " : " << error.errorString();
auto cert = error.certificate();
- QLOG_ERROR() << "Certificate in question:\n" << cert.toText();
+ qCritical() << "Certificate in question:\n" << cert.toText();
i++;
}
}
@@ -163,7 +163,7 @@ void YggdrasilTask::processReply()
"JSON response: %1 at offset %2.")
.arg(jsonError.errorString())
.arg(jsonError.offset));
- QLOG_ERROR() << replyData;
+ qCritical() << replyData;
}
return;
}
@@ -177,7 +177,7 @@ void YggdrasilTask::processReply()
// We were able to parse the server's response. Woo!
// Call processError. If a subclass has overridden it then they'll handle their
// stuff there.
- QLOG_DEBUG() << "The request failed, but the server gave us an error message. "
+ qDebug() << "The request failed, but the server gave us an error message. "
"Processing error.";
processError(doc.object());
}
@@ -185,7 +185,7 @@ void YggdrasilTask::processReply()
{
// The server didn't say anything regarding the error. Give the user an unknown
// error.
- QLOG_DEBUG()
+ qDebug()
<< "The request failed and the server gave no error message. Unknown error.";
changeState(STATE_FAILED_SOFT,
tr("An unknown error occurred when trying to communicate with the "
diff --git a/logic/auth/flows/AuthenticateTask.cpp b/logic/auth/flows/AuthenticateTask.cpp
index ed8c52fb..4141f00d 100644
--- a/logic/auth/flows/AuthenticateTask.cpp
+++ b/logic/auth/flows/AuthenticateTask.cpp
@@ -23,7 +23,7 @@
#include <QJsonArray>
#include <QVariant>
-#include "logger/QsLog.h"
+#include <QDebug>
AuthenticateTask::AuthenticateTask(MojangAccount * account, const QString &password,
QObject *parent)
@@ -74,11 +74,11 @@ void AuthenticateTask::processResponse(QJsonObject responseData)
{
// Read the response data. We need to get the client token, access token, and the selected
// profile.
- QLOG_DEBUG() << "Processing authentication response.";
- // QLOG_DEBUG() << responseData;
+ qDebug() << "Processing authentication response.";
+ // qDebug() << responseData;
// If we already have a client token, make sure the one the server gave us matches our
// existing one.
- QLOG_DEBUG() << "Getting client token.";
+ qDebug() << "Getting client token.";
QString clientToken = responseData.value("clientToken").toString("");
if (clientToken.isEmpty())
{
@@ -95,7 +95,7 @@ void AuthenticateTask::processResponse(QJsonObject responseData)
m_account->m_clientToken = clientToken;
// Now, we set the access token.
- QLOG_DEBUG() << "Getting access token.";
+ qDebug() << "Getting access token.";
QString accessToken = responseData.value("accessToken").toString("");
if (accessToken.isEmpty())
{
@@ -110,7 +110,7 @@ void AuthenticateTask::processResponse(QJsonObject responseData)
// Mojang hasn't yet implemented the profile system,
// but we might as well support what's there so we
// don't have trouble implementing it later.
- QLOG_DEBUG() << "Loading profile list.";
+ qDebug() << "Loading profile list.";
QJsonArray availableProfiles = responseData.value("availableProfiles").toArray();
QList<AccountProfile> loadedProfiles;
for (auto iter : availableProfiles)
@@ -126,7 +126,7 @@ void AuthenticateTask::processResponse(QJsonObject responseData)
// This should never happen, but we might as well
// warn about it if it does so we can debug it easily.
// You never know when Mojang might do something truly derpy.
- QLOG_WARN() << "Found entry in available profiles list with missing ID or name "
+ qWarning() << "Found entry in available profiles list with missing ID or name "
"field. Ignoring it.";
}
@@ -140,7 +140,7 @@ void AuthenticateTask::processResponse(QJsonObject responseData)
// We do need to make sure that the current profile that the server gave us
// is actually in the available profiles list.
// If it isn't, we'll just fail horribly (*shouldn't* ever happen, but you never know).
- QLOG_DEBUG() << "Setting current profile.";
+ qDebug() << "Setting current profile.";
QJsonObject currentProfile = responseData.value("selectedProfile").toObject();
QString currentProfileId = currentProfile.value("id").toString("");
if (currentProfileId.isEmpty())
@@ -173,7 +173,7 @@ void AuthenticateTask::processResponse(QJsonObject responseData)
// We've made it through the minefield of possible errors. Return true to indicate that
// we've succeeded.
- QLOG_DEBUG() << "Finished reading authentication response.";
+ qDebug() << "Finished reading authentication response.";
changeState(STATE_SUCCEEDED);
}
diff --git a/logic/auth/flows/RefreshTask.cpp b/logic/auth/flows/RefreshTask.cpp
index 4ca73b21..2216c7e4 100644
--- a/logic/auth/flows/RefreshTask.cpp
+++ b/logic/auth/flows/RefreshTask.cpp
@@ -22,7 +22,7 @@
#include <QJsonArray>
#include <QVariant>
-#include "logger/QsLog.h"
+#include <QDebug>
RefreshTask::RefreshTask(MojangAccount *account) : YggdrasilTask(account)
{
@@ -63,9 +63,9 @@ void RefreshTask::processResponse(QJsonObject responseData)
{
// Read the response data. We need to get the client token, access token, and the selected
// profile.
- QLOG_DEBUG() << "Processing authentication response.";
+ qDebug() << "Processing authentication response.";
- // QLOG_DEBUG() << responseData;
+ // qDebug() << responseData;
// If we already have a client token, make sure the one the server gave us matches our
// existing one.
QString clientToken = responseData.value("clientToken").toString("");
@@ -82,7 +82,7 @@ void RefreshTask::processResponse(QJsonObject responseData)
}
// Now, we set the access token.
- QLOG_DEBUG() << "Getting new access token.";
+ qDebug() << "Getting new access token.";
QString accessToken = responseData.value("accessToken").toString("");
if (accessToken.isEmpty())
{
@@ -120,7 +120,7 @@ void RefreshTask::processResponse(QJsonObject responseData)
// We've made it through the minefield of possible errors. Return true to indicate that
// we've succeeded.
- QLOG_DEBUG() << "Finished reading refresh response.";
+ qDebug() << "Finished reading refresh response.";
// Reset the access token.
m_account->m_accessToken = accessToken;
changeState(STATE_SUCCEEDED);
diff --git a/logic/auth/flows/ValidateTask.cpp b/logic/auth/flows/ValidateTask.cpp
index f3a8a23e..21afb596 100644
--- a/logic/auth/flows/ValidateTask.cpp
+++ b/logic/auth/flows/ValidateTask.cpp
@@ -23,7 +23,7 @@
#include <QJsonArray>
#include <QVariant>
-#include "logger/QsLog.h"
+#include <QDebug>
ValidateTask::ValidateTask(MojangAccount * account, QObject *parent)
: YggdrasilTask(account, parent)