mirror of
https://github.com/overte-org/overte.git
synced 2025-04-19 15:43:50 +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());
|
||||
}
|
||||
|
||||
WalletScriptingInterface::WalletScriptingInterface() {
|
||||
connect(DependencyManager::get<AccountManager>().data(),
|
||||
&AccountManager::limitedCommerceChanged, this, &WalletScriptingInterface::limitedCommerceChanged);
|
||||
}
|
||||
|
||||
void WalletScriptingInterface::refreshWalletStatus() {
|
||||
auto wallet = DependencyManager::get<Wallet>();
|
||||
wallet->getWalletStatus();
|
||||
|
@ -40,9 +45,3 @@ void WalletScriptingInterface::proveAvatarEntityOwnershipVerification(const QUui
|
|||
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 "commerce/Wallet.h"
|
||||
#include "ui/overlays/ContextOverlayInterface.h"
|
||||
#include <AccountManager.h>
|
||||
|
||||
class CheckoutProxy : public QmlWrapper {
|
||||
Q_OBJECT
|
||||
|
@ -45,6 +46,8 @@ class WalletScriptingInterface : public QObject, public Dependency {
|
|||
|
||||
public:
|
||||
|
||||
WalletScriptingInterface();
|
||||
|
||||
/**jsdoc
|
||||
* @function WalletScriptingInterface.refreshWalletStatus
|
||||
*/
|
||||
|
@ -66,8 +69,8 @@ public:
|
|||
// scripts could cause the Wallet to incorrectly report its status.
|
||||
void setWalletStatus(const uint& status);
|
||||
|
||||
bool getLimitedCommerce() { return _limitedCommerce; }
|
||||
void setLimitedCommerce(bool isLimited);
|
||||
bool getLimitedCommerce() { return DependencyManager::get<AccountManager>()->getLimitedCommerce(); }
|
||||
void setLimitedCommerce(bool isLimited) { DependencyManager::get<AccountManager>()->setLimitedCommerce(isLimited); };
|
||||
|
||||
signals:
|
||||
|
||||
|
@ -105,7 +108,6 @@ signals:
|
|||
|
||||
private:
|
||||
uint _walletStatus;
|
||||
bool _limitedCommerce = false;
|
||||
};
|
||||
|
||||
#endif // hifi_WalletScriptingInterface_h
|
||||
|
|
|
@ -837,3 +837,7 @@ void AccountManager::handleKeypairGenerationError() {
|
|||
// reset our waiting state for keypair response
|
||||
_isWaitingForKeypairResponse = false;
|
||||
}
|
||||
|
||||
void AccountManager::setLimitedCommerce(bool isLimited) {
|
||||
_limitedCommerce = isLimited;
|
||||
}
|
||||
|
|
|
@ -98,6 +98,9 @@ public:
|
|||
|
||||
void removeAccountFromFile();
|
||||
|
||||
bool getLimitedCommerce() { return _limitedCommerce; }
|
||||
void setLimitedCommerce(bool isLimited);
|
||||
|
||||
public slots:
|
||||
void requestAccessToken(const QString& login, const QString& password);
|
||||
void requestAccessTokenWithSteam(QByteArray authSessionTicket);
|
||||
|
@ -121,6 +124,7 @@ signals:
|
|||
void loginFailed();
|
||||
void logoutComplete();
|
||||
void newKeypair();
|
||||
void limitedCommerceChanged();
|
||||
|
||||
private slots:
|
||||
void handleKeypairGenerationError();
|
||||
|
@ -150,6 +154,8 @@ private:
|
|||
QByteArray _pendingPrivateKey;
|
||||
|
||||
QUuid _sessionID { QUuid::createUuid() };
|
||||
|
||||
bool _limitedCommerce { false };
|
||||
};
|
||||
|
||||
#endif // hifi_AccountManager_h
|
||||
|
|
|
@ -70,9 +70,9 @@ void RequestFilters::interceptHFWebEngineRequest(QWebEngineUrlRequestInfo& info,
|
|||
|
||||
// check if this is a request to a highfidelity URL
|
||||
bool isAuthable = isAuthableHighFidelityURL(info.requestUrl());
|
||||
auto accountManager = DependencyManager::get<AccountManager>();
|
||||
if (isAuthable) {
|
||||
// if we have an access token, add it to the right HTTP header for authorization
|
||||
auto accountManager = DependencyManager::get<AccountManager>();
|
||||
|
||||
if (accountManager->hasValidAccessToken()) {
|
||||
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 tokenStringMetaverse{ "Chrome/48.0 (HighFidelityInterface)" };
|
||||
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());
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue