mirror of
https://github.com/AleziaKurdis/overte.git
synced 2025-04-09 11:12:40 +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
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
color: "#C4C4C4"
|
||||
visible: LauncherState.lastLoginErrorMessage.length == 0
|
||||
text: "Use the account credentials you created at sign-up"
|
||||
anchors {
|
||||
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 {
|
||||
id: username
|
||||
width: 353
|
||||
|
@ -61,8 +81,8 @@ Item {
|
|||
color: "#7E8C81"
|
||||
seperatorColor: Qt.rgba(1, 1, 1, 0.3)
|
||||
anchors {
|
||||
top: instruction.bottom
|
||||
horizontalCenter: instruction.horizontalCenter
|
||||
top: error.bottom
|
||||
horizontalCenter: error.horizontalCenter
|
||||
topMargin: 24
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,8 +6,17 @@
|
|||
#include <QDir>
|
||||
#include <QFile>
|
||||
#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) {
|
||||
if (!(QFileInfo::exists(oldLauncherPath) && QFileInfo::exists(newLauncherPath))) {
|
||||
qDebug() << "old launcher: " << oldLauncherPath << "new launcher: " << newLauncherPath << " file does not exist";
|
||||
|
|
|
@ -5,13 +5,7 @@
|
|||
#include "Windows.h"
|
||||
#endif
|
||||
|
||||
//#define USE_STAGING
|
||||
|
||||
#ifdef USE_STAGING
|
||||
const QString METAVERSE_API_DOMAIN{ "https://staging.highfidelity.com" };
|
||||
#else
|
||||
const QString METAVERSE_API_DOMAIN{ "https://metaverse.highfidelity.com" };
|
||||
#endif
|
||||
QString getMetaverseAPIDomain();
|
||||
|
||||
void launchClient(const QString& clientPath, const QString& homePath, const QString& defaultScriptOverride,
|
||||
const QString& displayName, const QString& contentCachePath, QString loginResponseToken = QString());
|
||||
|
|
|
@ -69,6 +69,11 @@ bool LauncherState::shouldDownloadContentCache() const {
|
|||
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 =
|
||||
{ { "qml/SplashScreen.qml", "qml/HFBase/CreateAccountBase.qml", "qml/HFBase/LoginBase.qml", "DisplayName.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() {
|
||||
setApplicationState(ApplicationState::Init);
|
||||
requestBuilds();
|
||||
|
@ -300,7 +297,11 @@ void LauncherState::signup(QString email, QString username, QString password, QS
|
|||
loginRequest->deleteLater();
|
||||
|
||||
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");
|
||||
return;
|
||||
}
|
||||
|
@ -337,7 +338,11 @@ void LauncherState::login(QString username, QString password, QString displayNam
|
|||
request->deleteLater();
|
||||
|
||||
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");
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@ class LauncherState : public QObject {
|
|||
Q_PROPERTY(ApplicationState applicationState READ getApplicationState NOTIFY applicationStateChanged)
|
||||
Q_PROPERTY(float downloadProgress READ getDownloadProgress NOTIFY downloadProgressChanged)
|
||||
Q_PROPERTY(SignupRequest::Error lastSignupError MEMBER _lastSignupError NOTIFY lastSignupErrorChanged)
|
||||
Q_PROPERTY(QString lastLoginErrorMessage READ getLastLoginErrorMessage NOTIFY lastLoginErrorMessageChanged);
|
||||
Q_PROPERTY(QString buildVersion READ getBuildVersion)
|
||||
|
||||
public:
|
||||
|
@ -68,16 +69,8 @@ public:
|
|||
LaunchingHighFidelity
|
||||
};
|
||||
|
||||
enum LastLoginError {
|
||||
NONE = 0,
|
||||
ORGINIZATION,
|
||||
CREDENTIALS,
|
||||
LAST_ERROR_NUM
|
||||
};
|
||||
|
||||
Q_ENUM(UIState);
|
||||
Q_ENUM(ApplicationState)
|
||||
Q_ENUM(LastLoginError)
|
||||
|
||||
Q_INVOKABLE QString getCurrentUISource() const;
|
||||
|
||||
|
@ -88,10 +81,10 @@ public:
|
|||
|
||||
UIState getUIState() const;
|
||||
|
||||
QString getBuildVersion() { return QString(LAUNCHER_BUILD_VERSION); }
|
||||
void setLastLoginErrorMessage(const QString& msg);
|
||||
QString getLastLoginErrorMessage() const { return _lastLoginErrorMessage; }
|
||||
|
||||
void setLastLoginError(LastLoginError lastLoginError);
|
||||
LastLoginError getLastLoginError() const;
|
||||
QString getBuildVersion() { return QString(LAUNCHER_BUILD_VERSION); }
|
||||
|
||||
void setApplicationStateError(QString errorMessage);
|
||||
void setApplicationState(ApplicationState state);
|
||||
|
@ -137,6 +130,7 @@ signals:
|
|||
void applicationStateChanged();
|
||||
void downloadProgressChanged();
|
||||
void lastSignupErrorChanged();
|
||||
void lastLoginErrorMessageChanged();
|
||||
|
||||
private slots:
|
||||
void clientDownloadComplete();
|
||||
|
@ -167,8 +161,8 @@ private:
|
|||
ApplicationState _applicationState { ApplicationState::Init };
|
||||
UIState _uiState { UIState::SPLASH_SCREEN };
|
||||
LoginToken _loginResponse;
|
||||
LastLoginError _lastLoginError { NONE };
|
||||
SignupRequest::Error _lastSignupError{ SignupRequest::Error::None };
|
||||
QString _lastLoginErrorMessage{ "" };
|
||||
QString _displayName;
|
||||
QString _applicationErrorMessage;
|
||||
QString _currentClientVersion;
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
#include <QJsonObject>
|
||||
|
||||
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::ContentTypeHeader, "application/x-www-form-urlencoded");
|
||||
|
@ -28,11 +28,19 @@ void LoginRequest::receivedResponse() {
|
|||
|
||||
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();
|
||||
_error = Error::Unknown;
|
||||
emit finished();
|
||||
//setApplicationState(ApplicationState::UnexpectedError);
|
||||
return;
|
||||
}
|
||||
|
||||
if (statusCode >= 500 && statusCode < 600) {
|
||||
qDebug() << "Error logging in: " << reply->readAll();
|
||||
_error = Error::ServerError;
|
||||
emit finished();
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -44,7 +52,6 @@ void LoginRequest::receivedResponse() {
|
|||
qDebug() << "Error parsing response for login" << data;
|
||||
_error = Error::BadResponse;
|
||||
emit finished();
|
||||
//setApplicationStateError("Failed to login");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@ public:
|
|||
enum class Error {
|
||||
None = 0,
|
||||
Unknown,
|
||||
ServerError,
|
||||
BadResponse,
|
||||
BadUsernameOrPassword
|
||||
};
|
||||
|
|
|
@ -15,7 +15,7 @@ void SignupRequest::send(QNetworkAccessManager& nam, QString email, QString user
|
|||
|
||||
_state = State::Sending;
|
||||
|
||||
QUrl signupURL { METAVERSE_API_DOMAIN };
|
||||
QUrl signupURL { getMetaverseAPIDomain() };
|
||||
signupURL.setPath("/api/v1/user/channel_user");
|
||||
QNetworkRequest request(signupURL);
|
||||
|
||||
|
@ -27,7 +27,7 @@ void SignupRequest::send(QNetworkAccessManager& nam, QString email, QString user
|
|||
query.addQueryItem("username", username);
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ const QByteArray ACCESS_TOKEN_AUTHORIZATION_HEADER = "Authorization";
|
|||
void UserSettingsRequest::send(QNetworkAccessManager& nam, const LoginToken& token) {
|
||||
_state = State::Sending;
|
||||
|
||||
QUrl lockerURL = METAVERSE_API_DOMAIN;
|
||||
QUrl lockerURL{ getMetaverseAPIDomain() };
|
||||
lockerURL.setPath("/api/v1/user/locker");
|
||||
|
||||
QNetworkRequest lockerRequest(lockerURL);
|
||||
|
|
Loading…
Reference in a new issue