mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 13:18:38 +02:00
more code review feedback
This commit is contained in:
parent
0928b1bff1
commit
635c7533b9
4 changed files with 24 additions and 33 deletions
|
@ -305,36 +305,28 @@ void LoginDialog::createFailed(QNetworkReply* reply) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto root = doc.object();
|
auto root = doc.object();
|
||||||
auto data = root["data"].toObject();
|
auto data = root["data"];
|
||||||
auto error = data["error"].toObject();
|
auto error = data["error"];
|
||||||
auto oculusError = data["oculus"];
|
auto oculusError = data["oculus"];
|
||||||
auto user = error["username"].toArray();
|
auto user = error["username"].toArray();
|
||||||
auto uid = error["uid"].toArray();
|
auto uid = error["uid"].toArray();
|
||||||
auto email = error["email"].toArray();
|
auto email = error["email"].toArray();
|
||||||
auto password = error["password"].toArray();
|
auto password = error["password"].toArray();
|
||||||
QString reply;
|
QString reply;
|
||||||
if (!uid.isEmpty()) {
|
if (uid[0].isString()) {
|
||||||
if (uid[0].isString()) {
|
emit handleCreateFailed("Oculus ID " + uid[0].toString() + ".");
|
||||||
emit handleCreateFailed("Oculus ID " + uid[0].toString() + ".");
|
return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (!user.isEmpty()) {
|
if (user[0].isString()) {
|
||||||
if (user[0].isString()) {
|
reply = "Username " + user[0].toString() + ".";
|
||||||
reply = "Username " + user[0].toString() + ".";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (!email.isEmpty()) {
|
if (email[0].isString()) {
|
||||||
if (email[0].isString()) {
|
reply.append((!reply.isEmpty()) ? "\n" : "");
|
||||||
reply.append((!reply.isEmpty()) ? "\n" : "");
|
reply.append("Email " + email[0].toString() + ".");
|
||||||
reply.append("Email " + email[0].toString() + ".");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (!password.isEmpty()) {
|
if (password[0].isString()) {
|
||||||
if (password[0].isString()) {
|
reply.append((!reply.isEmpty()) ? "\n" : "");
|
||||||
reply.append((!reply.isEmpty()) ? "\n" : "");
|
reply.append("Password " + password[0].toString() + ".");
|
||||||
reply.append("Password " + password[0].toString() + ".");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (!oculusError.isNull() && !oculusError.isUndefined()) {
|
if (!oculusError.isNull() && !oculusError.isUndefined()) {
|
||||||
emit handleCreateFailed("Could not verify token with Oculus. Please try again.");
|
emit handleCreateFailed("Could not verify token with Oculus. Please try again.");
|
||||||
|
|
|
@ -17,10 +17,10 @@ class OculusPlatformPlugin {
|
||||||
public:
|
public:
|
||||||
virtual ~OculusPlatformPlugin() = default;
|
virtual ~OculusPlatformPlugin() = default;
|
||||||
|
|
||||||
virtual QString getName() = 0;
|
virtual QString getName() const = 0;
|
||||||
virtual QString getOculusUserID() = 0;
|
virtual QString getOculusUserID() const = 0;
|
||||||
|
|
||||||
virtual bool isRunning() = 0;
|
virtual bool isRunning() const = 0;
|
||||||
|
|
||||||
virtual void requestNonceAndUserID(NonceUserIDCallback callback) = 0;
|
virtual void requestNonceAndUserID(NonceUserIDCallback callback) = 0;
|
||||||
|
|
||||||
|
|
|
@ -62,11 +62,9 @@ void OculusAPIPlugin::handleOVREvents() {
|
||||||
ovrUserHandle user = ovr_Message_GetUser(message);
|
ovrUserHandle user = ovr_Message_GetUser(message);
|
||||||
_user = ovr_User_GetOculusID(user);
|
_user = ovr_User_GetOculusID(user);
|
||||||
// went all the way through the `requestNonceAndUserID()` pipeline successfully.
|
// went all the way through the `requestNonceAndUserID()` pipeline successfully.
|
||||||
_nonceChanged = true;
|
|
||||||
} else {
|
} else {
|
||||||
qCDebug(oculusLog) << "Oculus Platform user retrieval failed" << QString(ovr_Error_GetMessage(ovr_Message_GetError(message)));
|
qCDebug(oculusLog) << "Oculus Platform user retrieval failed" << QString(ovr_Error_GetMessage(ovr_Message_GetError(message)));
|
||||||
// emit the signal so we don't hang for it anywhere else.
|
// emit the signal so we don't hang for it anywhere else.
|
||||||
_nonceChanged = true;
|
|
||||||
_user = "";
|
_user = "";
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -79,8 +77,8 @@ void OculusAPIPlugin::handleOVREvents() {
|
||||||
} else {
|
} else {
|
||||||
qCDebug(oculusLog) << "Oculus Platform user ID retrieval failed" << QString(ovr_Error_GetMessage(ovr_Message_GetError(message)));
|
qCDebug(oculusLog) << "Oculus Platform user ID retrieval failed" << QString(ovr_Error_GetMessage(ovr_Message_GetError(message)));
|
||||||
// emit the signal so we don't hang for it anywhere else.
|
// emit the signal so we don't hang for it anywhere else.
|
||||||
_nonceChanged = true;
|
|
||||||
}
|
}
|
||||||
|
_userIDChanged = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ovrMessage_User_GetUserProof: {
|
case ovrMessage_User_GetUserProof: {
|
||||||
|
@ -92,15 +90,15 @@ void OculusAPIPlugin::handleOVREvents() {
|
||||||
qCDebug(oculusLog) << "Oculus Platform nonce retrieval failed" << QString(ovr_Error_GetMessage(ovr_Message_GetError(message)));
|
qCDebug(oculusLog) << "Oculus Platform nonce retrieval failed" << QString(ovr_Error_GetMessage(ovr_Message_GetError(message)));
|
||||||
_nonce = "";
|
_nonce = "";
|
||||||
// emit the signal so we don't hang for it anywhere else.
|
// emit the signal so we don't hang for it anywhere else.
|
||||||
_nonceChanged = true;
|
|
||||||
}
|
}
|
||||||
|
_nonceChanged = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_nonceChanged) {
|
if (_nonceChanged && _userIDChanged) {
|
||||||
_nonceUserIDCallback(_nonce, QString::number(_userID));
|
_nonceUserIDCallback(_nonce, QString::number(_userID));
|
||||||
_nonceChanged = false;
|
_nonceChanged = _userIDChanged = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// free the message handle to cleanup and not leak
|
// free the message handle to cleanup and not leak
|
||||||
|
|
|
@ -18,10 +18,10 @@ class OculusAPIPlugin : public OculusPlatformPlugin {
|
||||||
public:
|
public:
|
||||||
OculusAPIPlugin();
|
OculusAPIPlugin();
|
||||||
virtual ~OculusAPIPlugin();
|
virtual ~OculusAPIPlugin();
|
||||||
QString getName() { return NAME; }
|
QString getName() const { return NAME; }
|
||||||
QString getOculusUserID() { return _user; };
|
QString getOculusUserID() const { return _user; };
|
||||||
|
|
||||||
bool isRunning();
|
bool isRunning() const;
|
||||||
|
|
||||||
virtual void requestNonceAndUserID(NonceUserIDCallback callback);
|
virtual void requestNonceAndUserID(NonceUserIDCallback callback);
|
||||||
|
|
||||||
|
@ -32,6 +32,7 @@ private:
|
||||||
NonceUserIDCallback _nonceUserIDCallback;
|
NonceUserIDCallback _nonceUserIDCallback;
|
||||||
QString _nonce;
|
QString _nonce;
|
||||||
bool _nonceChanged{ false };
|
bool _nonceChanged{ false };
|
||||||
|
bool _userIDChanged{ false };
|
||||||
QString _user;
|
QString _user;
|
||||||
ovrID _userID;
|
ovrID _userID;
|
||||||
ovrSession _session;
|
ovrSession _session;
|
||||||
|
|
Loading…
Reference in a new issue