mirror of
https://github.com/overte-org/overte.git
synced 2025-08-05 21:39:40 +02:00
Use AccountManager instead of settings
This commit is contained in:
parent
402c23e359
commit
d0854ca2ab
5 changed files with 22 additions and 12 deletions
|
@ -16,6 +16,11 @@ CheckoutProxy::CheckoutProxy(QObject* qmlObject, QObject* parent) : QmlWrapper(q
|
||||||
Q_ASSERT(QThread::currentThread() == qApp->thread());
|
Q_ASSERT(QThread::currentThread() == qApp->thread());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WalletScriptingInterface::WalletScriptingInterface() {
|
||||||
|
connect(DependencyManager::get<AccountManager>().data(),
|
||||||
|
&AccountManager::limitedCommerceChanged, this, &WalletScriptingInterface::limitedCommerceChanged);
|
||||||
|
}
|
||||||
|
|
||||||
void WalletScriptingInterface::refreshWalletStatus() {
|
void WalletScriptingInterface::refreshWalletStatus() {
|
||||||
auto wallet = DependencyManager::get<Wallet>();
|
auto wallet = DependencyManager::get<Wallet>();
|
||||||
wallet->getWalletStatus();
|
wallet->getWalletStatus();
|
||||||
|
@ -40,9 +45,3 @@ void WalletScriptingInterface::proveAvatarEntityOwnershipVerification(const QUui
|
||||||
qCDebug(entities) << "Failed to prove ownership of:" << entityID << "is not an avatar entity";
|
qCDebug(entities) << "Failed to prove ownership of:" << entityID << "is not an avatar entity";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void WalletScriptingInterface::setLimitedCommerce(bool isLimited) {
|
|
||||||
_limitedCommerce = isLimited;
|
|
||||||
Setting::Handle<bool> limitedCommerceSetting{ "limitedCommerce", false };
|
|
||||||
limitedCommerceSetting.set(_limitedCommerce);
|
|
||||||
}
|
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
#include "Application.h"
|
#include "Application.h"
|
||||||
#include "commerce/Wallet.h"
|
#include "commerce/Wallet.h"
|
||||||
#include "ui/overlays/ContextOverlayInterface.h"
|
#include "ui/overlays/ContextOverlayInterface.h"
|
||||||
|
#include <AccountManager.h>
|
||||||
|
|
||||||
class CheckoutProxy : public QmlWrapper {
|
class CheckoutProxy : public QmlWrapper {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -45,6 +46,8 @@ class WalletScriptingInterface : public QObject, public Dependency {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
WalletScriptingInterface();
|
||||||
|
|
||||||
/**jsdoc
|
/**jsdoc
|
||||||
* @function WalletScriptingInterface.refreshWalletStatus
|
* @function WalletScriptingInterface.refreshWalletStatus
|
||||||
*/
|
*/
|
||||||
|
@ -66,8 +69,8 @@ public:
|
||||||
// scripts could cause the Wallet to incorrectly report its status.
|
// scripts could cause the Wallet to incorrectly report its status.
|
||||||
void setWalletStatus(const uint& status);
|
void setWalletStatus(const uint& status);
|
||||||
|
|
||||||
bool getLimitedCommerce() { return _limitedCommerce; }
|
bool getLimitedCommerce() { return DependencyManager::get<AccountManager>()->getLimitedCommerce(); }
|
||||||
void setLimitedCommerce(bool isLimited);
|
void setLimitedCommerce(bool isLimited) { DependencyManager::get<AccountManager>()->setLimitedCommerce(isLimited); };
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|
||||||
|
@ -105,7 +108,6 @@ signals:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
uint _walletStatus;
|
uint _walletStatus;
|
||||||
bool _limitedCommerce = false;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // hifi_WalletScriptingInterface_h
|
#endif // hifi_WalletScriptingInterface_h
|
||||||
|
|
|
@ -837,3 +837,7 @@ void AccountManager::handleKeypairGenerationError() {
|
||||||
// reset our waiting state for keypair response
|
// reset our waiting state for keypair response
|
||||||
_isWaitingForKeypairResponse = false;
|
_isWaitingForKeypairResponse = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AccountManager::setLimitedCommerce(bool isLimited) {
|
||||||
|
_limitedCommerce = isLimited;
|
||||||
|
}
|
||||||
|
|
|
@ -98,6 +98,9 @@ public:
|
||||||
|
|
||||||
void removeAccountFromFile();
|
void removeAccountFromFile();
|
||||||
|
|
||||||
|
bool getLimitedCommerce() { return _limitedCommerce; }
|
||||||
|
void setLimitedCommerce(bool isLimited);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void requestAccessToken(const QString& login, const QString& password);
|
void requestAccessToken(const QString& login, const QString& password);
|
||||||
void requestAccessTokenWithSteam(QByteArray authSessionTicket);
|
void requestAccessTokenWithSteam(QByteArray authSessionTicket);
|
||||||
|
@ -121,6 +124,7 @@ signals:
|
||||||
void loginFailed();
|
void loginFailed();
|
||||||
void logoutComplete();
|
void logoutComplete();
|
||||||
void newKeypair();
|
void newKeypair();
|
||||||
|
void limitedCommerceChanged();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void handleKeypairGenerationError();
|
void handleKeypairGenerationError();
|
||||||
|
@ -150,6 +154,8 @@ private:
|
||||||
QByteArray _pendingPrivateKey;
|
QByteArray _pendingPrivateKey;
|
||||||
|
|
||||||
QUuid _sessionID { QUuid::createUuid() };
|
QUuid _sessionID { QUuid::createUuid() };
|
||||||
|
|
||||||
|
bool _limitedCommerce { false };
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // hifi_AccountManager_h
|
#endif // hifi_AccountManager_h
|
||||||
|
|
|
@ -70,9 +70,9 @@ void RequestFilters::interceptHFWebEngineRequest(QWebEngineUrlRequestInfo& info,
|
||||||
|
|
||||||
// check if this is a request to a highfidelity URL
|
// check if this is a request to a highfidelity URL
|
||||||
bool isAuthable = isAuthableHighFidelityURL(info.requestUrl());
|
bool isAuthable = isAuthableHighFidelityURL(info.requestUrl());
|
||||||
|
auto accountManager = DependencyManager::get<AccountManager>();
|
||||||
if (isAuthable) {
|
if (isAuthable) {
|
||||||
// if we have an access token, add it to the right HTTP header for authorization
|
// if we have an access token, add it to the right HTTP header for authorization
|
||||||
auto accountManager = DependencyManager::get<AccountManager>();
|
|
||||||
|
|
||||||
if (accountManager->hasValidAccessToken()) {
|
if (accountManager->hasValidAccessToken()) {
|
||||||
static const QString OAUTH_AUTHORIZATION_HEADER = "Authorization";
|
static const QString OAUTH_AUTHORIZATION_HEADER = "Authorization";
|
||||||
|
@ -85,9 +85,8 @@ void RequestFilters::interceptHFWebEngineRequest(QWebEngineUrlRequestInfo& info,
|
||||||
const QString tokenStringMobile{ "Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Mobile Safari/537.36" };
|
const QString tokenStringMobile{ "Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Mobile Safari/537.36" };
|
||||||
const QString tokenStringMetaverse{ "Chrome/48.0 (HighFidelityInterface)" };
|
const QString tokenStringMetaverse{ "Chrome/48.0 (HighFidelityInterface)" };
|
||||||
const QString tokenStringLimitedCommerce{ "Chrome/48.0 (HighFidelityInterface limitedCommerce)" };
|
const QString tokenStringLimitedCommerce{ "Chrome/48.0 (HighFidelityInterface limitedCommerce)" };
|
||||||
Setting::Handle<bool> limitedCommerceSetting{ "limitedCommerce", false };
|
|
||||||
|
|
||||||
const QString tokenString = !isAuthable ? tokenStringMobile : (limitedCommerceSetting.get() ? tokenStringLimitedCommerce : tokenStringMetaverse);
|
const QString tokenString = !isAuthable ? tokenStringMobile : (accountManager->getLimitedCommerce() ? tokenStringLimitedCommerce : tokenStringMetaverse);
|
||||||
info.setHttpHeader(USER_AGENT.toLocal8Bit(), tokenString.toLocal8Bit());
|
info.setHttpHeader(USER_AGENT.toLocal8Bit(), tokenString.toLocal8Bit());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue