mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 21:57:00 +02:00
Merge branch 'qt-launcher' of github.com:danteruiz/hifi into qt-launcher
This commit is contained in:
commit
946e984f00
9 changed files with 68 additions and 38 deletions
|
@ -42,6 +42,7 @@ Item {
|
||||||
horizontalAlignment: Text.AlignHCenter
|
horizontalAlignment: Text.AlignHCenter
|
||||||
verticalAlignment: Text.AlignVCenter
|
verticalAlignment: Text.AlignVCenter
|
||||||
color: "#C4C4C4"
|
color: "#C4C4C4"
|
||||||
|
visible: LauncherState.lastLoginErrorMessage.length == 0
|
||||||
text: "Use the account credentials you created at sign-up"
|
text: "Use the account credentials you created at sign-up"
|
||||||
anchors {
|
anchors {
|
||||||
left: root.left
|
left: root.left
|
||||||
|
@ -51,6 +52,25 @@ Item {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Text {
|
||||||
|
id: error
|
||||||
|
width: 425
|
||||||
|
height: 22
|
||||||
|
font.family: "Graphik"
|
||||||
|
font.pixelSize: 14
|
||||||
|
horizontalAlignment: Text.AlignHCenter
|
||||||
|
verticalAlignment: Text.AlignVCenter
|
||||||
|
color: "#FF9999"
|
||||||
|
visible: LauncherState.lastLoginErrorMessage.length > 0
|
||||||
|
text: LauncherState.lastLoginErrorMessage
|
||||||
|
anchors {
|
||||||
|
left: root.left
|
||||||
|
right: root.right
|
||||||
|
top: title.bottom
|
||||||
|
topMargin: 18
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
HFTextField {
|
HFTextField {
|
||||||
id: username
|
id: username
|
||||||
width: 353
|
width: 353
|
||||||
|
@ -61,8 +81,8 @@ Item {
|
||||||
color: "#7E8C81"
|
color: "#7E8C81"
|
||||||
seperatorColor: Qt.rgba(1, 1, 1, 0.3)
|
seperatorColor: Qt.rgba(1, 1, 1, 0.3)
|
||||||
anchors {
|
anchors {
|
||||||
top: instruction.bottom
|
top: error.bottom
|
||||||
horizontalCenter: instruction.horizontalCenter
|
horizontalCenter: error.horizontalCenter
|
||||||
topMargin: 24
|
topMargin: 24
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,8 +6,17 @@
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
|
#include <QProcessEnvironment>
|
||||||
|
|
||||||
|
|
||||||
|
QString getMetaverseAPIDomain() {
|
||||||
|
QProcessEnvironment processEnvironment = QProcessEnvironment::systemEnvironment();
|
||||||
|
if (processEnvironment.contains("HIFI_METAVERSE_URL")) {
|
||||||
|
return processEnvironment.value("HIFI_METAVERSE_URL");
|
||||||
|
}
|
||||||
|
return "https://metaverse.highfidelity.com";
|
||||||
|
}
|
||||||
|
|
||||||
void swapLaunchers(const QString& oldLauncherPath, const QString& newLauncherPath) {
|
void swapLaunchers(const QString& oldLauncherPath, const QString& newLauncherPath) {
|
||||||
if (!(QFileInfo::exists(oldLauncherPath) && QFileInfo::exists(newLauncherPath))) {
|
if (!(QFileInfo::exists(oldLauncherPath) && QFileInfo::exists(newLauncherPath))) {
|
||||||
qDebug() << "old launcher: " << oldLauncherPath << "new launcher: " << newLauncherPath << " file does not exist";
|
qDebug() << "old launcher: " << oldLauncherPath << "new launcher: " << newLauncherPath << " file does not exist";
|
||||||
|
|
|
@ -5,13 +5,7 @@
|
||||||
#include "Windows.h"
|
#include "Windows.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//#define USE_STAGING
|
QString getMetaverseAPIDomain();
|
||||||
|
|
||||||
#ifdef USE_STAGING
|
|
||||||
const QString METAVERSE_API_DOMAIN{ "https://staging.highfidelity.com" };
|
|
||||||
#else
|
|
||||||
const QString METAVERSE_API_DOMAIN{ "https://metaverse.highfidelity.com" };
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void launchClient(const QString& clientPath, const QString& homePath, const QString& defaultScriptOverride,
|
void launchClient(const QString& clientPath, const QString& homePath, const QString& defaultScriptOverride,
|
||||||
const QString& displayName, const QString& contentCachePath, QString loginResponseToken = QString());
|
const QString& displayName, const QString& contentCachePath, QString loginResponseToken = QString());
|
||||||
|
|
|
@ -69,6 +69,11 @@ bool LauncherState::shouldDownloadContentCache() const {
|
||||||
return !_contentCacheURL.isEmpty() && !QFile::exists(getContentCachePath());
|
return !_contentCacheURL.isEmpty() && !QFile::exists(getContentCachePath());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LauncherState::setLastLoginErrorMessage(const QString& msg) {
|
||||||
|
_lastLoginErrorMessage = msg;
|
||||||
|
emit lastLoginErrorMessageChanged();
|
||||||
|
}
|
||||||
|
|
||||||
static const std::array<QString, LauncherState::UIState::UI_STATE_NUM> QML_FILE_FOR_UI_STATE =
|
static const std::array<QString, LauncherState::UIState::UI_STATE_NUM> QML_FILE_FOR_UI_STATE =
|
||||||
{ { "qml/SplashScreen.qml", "qml/HFBase/CreateAccountBase.qml", "qml/HFBase/LoginBase.qml", "DisplayName.qml",
|
{ { "qml/SplashScreen.qml", "qml/HFBase/CreateAccountBase.qml", "qml/HFBase/LoginBase.qml", "DisplayName.qml",
|
||||||
"qml/Download.qml", "qml/DownloadFinished.qml", "qml/HFBase/Error.qml" } };
|
"qml/Download.qml", "qml/DownloadFinished.qml", "qml/HFBase/Error.qml" } };
|
||||||
|
@ -144,14 +149,6 @@ LauncherState::UIState LauncherState::getUIState() const {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void LauncherState::setLastLoginError(LastLoginError lastLoginError) {
|
|
||||||
_lastLoginError = lastLoginError;
|
|
||||||
}
|
|
||||||
|
|
||||||
LauncherState::LastLoginError LauncherState::getLastLoginError() const {
|
|
||||||
return _lastLoginError;
|
|
||||||
}
|
|
||||||
|
|
||||||
void LauncherState::restart() {
|
void LauncherState::restart() {
|
||||||
setApplicationState(ApplicationState::Init);
|
setApplicationState(ApplicationState::Init);
|
||||||
requestBuilds();
|
requestBuilds();
|
||||||
|
@ -300,7 +297,11 @@ void LauncherState::signup(QString email, QString username, QString password, QS
|
||||||
loginRequest->deleteLater();
|
loginRequest->deleteLater();
|
||||||
|
|
||||||
auto err = loginRequest->getError();
|
auto err = loginRequest->getError();
|
||||||
if (err != LoginRequest::Error::None) {
|
if (err == LoginRequest::Error::BadUsernameOrPassword) {
|
||||||
|
setLastLoginErrorMessage("Bad username or password");
|
||||||
|
setApplicationState(ApplicationState::WaitingForLogin);
|
||||||
|
return;
|
||||||
|
} else if (err != LoginRequest::Error::None) {
|
||||||
setApplicationStateError("Failed to login");
|
setApplicationStateError("Failed to login");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -337,7 +338,11 @@ void LauncherState::login(QString username, QString password, QString displayNam
|
||||||
request->deleteLater();
|
request->deleteLater();
|
||||||
|
|
||||||
auto err = request->getError();
|
auto err = request->getError();
|
||||||
if (err != LoginRequest::Error::None) {
|
if (err == LoginRequest::Error::BadUsernameOrPassword) {
|
||||||
|
setLastLoginErrorMessage("Bad username or password");
|
||||||
|
setApplicationState(ApplicationState::WaitingForLogin);
|
||||||
|
return;
|
||||||
|
} else if (err != LoginRequest::Error::None) {
|
||||||
setApplicationStateError("Failed to login");
|
setApplicationStateError("Failed to login");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,6 +25,7 @@ class LauncherState : public QObject {
|
||||||
Q_PROPERTY(ApplicationState applicationState READ getApplicationState NOTIFY applicationStateChanged)
|
Q_PROPERTY(ApplicationState applicationState READ getApplicationState NOTIFY applicationStateChanged)
|
||||||
Q_PROPERTY(float downloadProgress READ getDownloadProgress NOTIFY downloadProgressChanged)
|
Q_PROPERTY(float downloadProgress READ getDownloadProgress NOTIFY downloadProgressChanged)
|
||||||
Q_PROPERTY(SignupRequest::Error lastSignupError MEMBER _lastSignupError NOTIFY lastSignupErrorChanged)
|
Q_PROPERTY(SignupRequest::Error lastSignupError MEMBER _lastSignupError NOTIFY lastSignupErrorChanged)
|
||||||
|
Q_PROPERTY(QString lastLoginErrorMessage READ getLastLoginErrorMessage NOTIFY lastLoginErrorMessageChanged);
|
||||||
Q_PROPERTY(QString buildVersion READ getBuildVersion)
|
Q_PROPERTY(QString buildVersion READ getBuildVersion)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -68,16 +69,8 @@ public:
|
||||||
LaunchingHighFidelity
|
LaunchingHighFidelity
|
||||||
};
|
};
|
||||||
|
|
||||||
enum LastLoginError {
|
|
||||||
NONE = 0,
|
|
||||||
ORGINIZATION,
|
|
||||||
CREDENTIALS,
|
|
||||||
LAST_ERROR_NUM
|
|
||||||
};
|
|
||||||
|
|
||||||
Q_ENUM(UIState);
|
Q_ENUM(UIState);
|
||||||
Q_ENUM(ApplicationState)
|
Q_ENUM(ApplicationState)
|
||||||
Q_ENUM(LastLoginError)
|
|
||||||
|
|
||||||
Q_INVOKABLE QString getCurrentUISource() const;
|
Q_INVOKABLE QString getCurrentUISource() const;
|
||||||
|
|
||||||
|
@ -88,10 +81,10 @@ public:
|
||||||
|
|
||||||
UIState getUIState() const;
|
UIState getUIState() const;
|
||||||
|
|
||||||
QString getBuildVersion() { return QString(LAUNCHER_BUILD_VERSION); }
|
void setLastLoginErrorMessage(const QString& msg);
|
||||||
|
QString getLastLoginErrorMessage() const { return _lastLoginErrorMessage; }
|
||||||
|
|
||||||
void setLastLoginError(LastLoginError lastLoginError);
|
QString getBuildVersion() { return QString(LAUNCHER_BUILD_VERSION); }
|
||||||
LastLoginError getLastLoginError() const;
|
|
||||||
|
|
||||||
void setApplicationStateError(QString errorMessage);
|
void setApplicationStateError(QString errorMessage);
|
||||||
void setApplicationState(ApplicationState state);
|
void setApplicationState(ApplicationState state);
|
||||||
|
@ -137,6 +130,7 @@ signals:
|
||||||
void applicationStateChanged();
|
void applicationStateChanged();
|
||||||
void downloadProgressChanged();
|
void downloadProgressChanged();
|
||||||
void lastSignupErrorChanged();
|
void lastSignupErrorChanged();
|
||||||
|
void lastLoginErrorMessageChanged();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void clientDownloadComplete();
|
void clientDownloadComplete();
|
||||||
|
@ -167,8 +161,8 @@ private:
|
||||||
ApplicationState _applicationState { ApplicationState::Init };
|
ApplicationState _applicationState { ApplicationState::Init };
|
||||||
UIState _uiState { UIState::SPLASH_SCREEN };
|
UIState _uiState { UIState::SPLASH_SCREEN };
|
||||||
LoginToken _loginResponse;
|
LoginToken _loginResponse;
|
||||||
LastLoginError _lastLoginError { NONE };
|
|
||||||
SignupRequest::Error _lastSignupError{ SignupRequest::Error::None };
|
SignupRequest::Error _lastSignupError{ SignupRequest::Error::None };
|
||||||
|
QString _lastLoginErrorMessage{ "" };
|
||||||
QString _displayName;
|
QString _displayName;
|
||||||
QString _applicationErrorMessage;
|
QString _applicationErrorMessage;
|
||||||
QString _currentClientVersion;
|
QString _currentClientVersion;
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
#include <QJsonObject>
|
#include <QJsonObject>
|
||||||
|
|
||||||
void LoginRequest::send(QNetworkAccessManager& nam, QString username, QString password) {
|
void LoginRequest::send(QNetworkAccessManager& nam, QString username, QString password) {
|
||||||
QNetworkRequest request(QUrl(METAVERSE_API_DOMAIN + "/oauth/token"));
|
QNetworkRequest request(QUrl(getMetaverseAPIDomain() + "/oauth/token"));
|
||||||
|
|
||||||
request.setHeader(QNetworkRequest::UserAgentHeader, getHTTPUserAgent());
|
request.setHeader(QNetworkRequest::UserAgentHeader, getHTTPUserAgent());
|
||||||
request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");
|
request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");
|
||||||
|
@ -28,11 +28,19 @@ void LoginRequest::receivedResponse() {
|
||||||
|
|
||||||
auto reply = static_cast<QNetworkReply*>(sender());
|
auto reply = static_cast<QNetworkReply*>(sender());
|
||||||
|
|
||||||
if (reply->error()) {
|
auto statusCode = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
|
||||||
|
|
||||||
|
if (statusCode < 100) {
|
||||||
qDebug() << "Error logging in: " << reply->readAll();
|
qDebug() << "Error logging in: " << reply->readAll();
|
||||||
_error = Error::Unknown;
|
_error = Error::Unknown;
|
||||||
emit finished();
|
emit finished();
|
||||||
//setApplicationState(ApplicationState::UnexpectedError);
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (statusCode >= 500 && statusCode < 600) {
|
||||||
|
qDebug() << "Error logging in: " << reply->readAll();
|
||||||
|
_error = Error::ServerError;
|
||||||
|
emit finished();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,7 +52,6 @@ void LoginRequest::receivedResponse() {
|
||||||
qDebug() << "Error parsing response for login" << data;
|
qDebug() << "Error parsing response for login" << data;
|
||||||
_error = Error::BadResponse;
|
_error = Error::BadResponse;
|
||||||
emit finished();
|
emit finished();
|
||||||
//setApplicationStateError("Failed to login");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,7 @@ public:
|
||||||
enum class Error {
|
enum class Error {
|
||||||
None = 0,
|
None = 0,
|
||||||
Unknown,
|
Unknown,
|
||||||
|
ServerError,
|
||||||
BadResponse,
|
BadResponse,
|
||||||
BadUsernameOrPassword
|
BadUsernameOrPassword
|
||||||
};
|
};
|
||||||
|
|
|
@ -15,7 +15,7 @@ void SignupRequest::send(QNetworkAccessManager& nam, QString email, QString user
|
||||||
|
|
||||||
_state = State::Sending;
|
_state = State::Sending;
|
||||||
|
|
||||||
QUrl signupURL { METAVERSE_API_DOMAIN };
|
QUrl signupURL { getMetaverseAPIDomain() };
|
||||||
signupURL.setPath("/api/v1/user/channel_user");
|
signupURL.setPath("/api/v1/user/channel_user");
|
||||||
QNetworkRequest request(signupURL);
|
QNetworkRequest request(signupURL);
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ void SignupRequest::send(QNetworkAccessManager& nam, QString email, QString user
|
||||||
query.addQueryItem("username", username);
|
query.addQueryItem("username", username);
|
||||||
query.addQueryItem("password", password);
|
query.addQueryItem("password", password);
|
||||||
|
|
||||||
auto reply = nam.post(request, query.toString().toUtf8());
|
auto reply = nam.put(request, query.toString().toUtf8());
|
||||||
QObject::connect(reply, &QNetworkReply::finished, this, &SignupRequest::receivedResponse);
|
QObject::connect(reply, &QNetworkReply::finished, this, &SignupRequest::receivedResponse);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ const QByteArray ACCESS_TOKEN_AUTHORIZATION_HEADER = "Authorization";
|
||||||
void UserSettingsRequest::send(QNetworkAccessManager& nam, const LoginToken& token) {
|
void UserSettingsRequest::send(QNetworkAccessManager& nam, const LoginToken& token) {
|
||||||
_state = State::Sending;
|
_state = State::Sending;
|
||||||
|
|
||||||
QUrl lockerURL = METAVERSE_API_DOMAIN;
|
QUrl lockerURL{ getMetaverseAPIDomain() };
|
||||||
lockerURL.setPath("/api/v1/user/locker");
|
lockerURL.setPath("/api/v1/user/locker");
|
||||||
|
|
||||||
QNetworkRequest lockerRequest(lockerURL);
|
QNetworkRequest lockerRequest(lockerURL);
|
||||||
|
|
Loading…
Reference in a new issue