mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-04 06:53:10 +02:00
moving logic to wallet, crashes currently
This commit is contained in:
parent
3a6f184278
commit
20635acf27
4 changed files with 32 additions and 17 deletions
|
@ -16,6 +16,16 @@ CheckoutProxy::CheckoutProxy(QObject* qmlObject, QObject* parent) : QmlWrapper(q
|
|||
}
|
||||
|
||||
WalletScriptingInterface::WalletScriptingInterface() {
|
||||
_contextOverlayInterface = DependencyManager::get<ContextOverlayInterface>();
|
||||
|
||||
_entityPropertyFlags += PROP_POSITION;
|
||||
_entityPropertyFlags += PROP_ROTATION;
|
||||
_entityPropertyFlags += PROP_MARKETPLACE_ID;
|
||||
_entityPropertyFlags += PROP_DIMENSIONS;
|
||||
_entityPropertyFlags += PROP_REGISTRATION_POINT;
|
||||
_entityPropertyFlags += PROP_CERTIFICATE_ID;
|
||||
_entityPropertyFlags += PROP_CLIENT_ONLY;
|
||||
_entityPropertyFlags += PROP_OWNING_AVATAR_ID;
|
||||
}
|
||||
|
||||
void WalletScriptingInterface::refreshWalletStatus() {
|
||||
|
@ -26,4 +36,16 @@ void WalletScriptingInterface::refreshWalletStatus() {
|
|||
void WalletScriptingInterface::setWalletStatus(const uint& status) {
|
||||
_walletStatus = status;
|
||||
emit DependencyManager::get<Wallet>()->walletStatusResult(status);
|
||||
}
|
||||
|
||||
void WalletScriptingInterface::proveAvatarEntityOwnershipVerification(const QUuid& entityID) {
|
||||
EntityItemProperties entityProperties = DependencyManager::get<EntityScriptingInterface>()->getEntityProperties(entityID, _entityPropertyFlags);
|
||||
if (!entityID.isNull() && entityProperties.getMarketplaceID().length() > 0) {
|
||||
if (!entityProperties.getClientOnly()) {
|
||||
qCDebug(entities) << "Failed to prove ownership of:" << entityID << "is not an avatar entity";
|
||||
emit _contextOverlayInterface->ownershipVerificationFailed(entityID);
|
||||
return;
|
||||
}
|
||||
_contextOverlayInterface->requestOwnershipVerification(entityID);
|
||||
}
|
||||
}
|
|
@ -21,6 +21,7 @@
|
|||
#include <OffscreenUi.h>
|
||||
#include "Application.h"
|
||||
#include "commerce/Wallet.h"
|
||||
#include "ui/overlays/ContextOverlayInterface.h"
|
||||
|
||||
class CheckoutProxy : public QmlWrapper {
|
||||
Q_OBJECT
|
||||
|
@ -33,12 +34,15 @@ class WalletScriptingInterface : public QObject, public Dependency {
|
|||
Q_OBJECT
|
||||
|
||||
Q_PROPERTY(uint walletStatus READ getWalletStatus WRITE setWalletStatus NOTIFY walletStatusChanged)
|
||||
QSharedPointer<ContextOverlayInterface> _contextOverlayInterface;
|
||||
|
||||
|
||||
public:
|
||||
WalletScriptingInterface();
|
||||
|
||||
Q_INVOKABLE void refreshWalletStatus();
|
||||
Q_INVOKABLE uint getWalletStatus() { return _walletStatus; }
|
||||
Q_INVOKABLE void proveAvatarEntityOwnershipVerification(const QUuid& entityID);
|
||||
// setWalletStatus() should never be made Q_INVOKABLE. If it were,
|
||||
// scripts could cause the Wallet to incorrectly report its status.
|
||||
void setWalletStatus(const uint& status);
|
||||
|
@ -49,6 +53,7 @@ signals:
|
|||
|
||||
private:
|
||||
uint _walletStatus;
|
||||
EntityPropertyFlags _entityPropertyFlags;
|
||||
};
|
||||
|
||||
#endif // hifi_WalletScriptingInterface_h
|
||||
|
|
|
@ -267,21 +267,10 @@ void ContextOverlayInterface::contextOverlays_hoverLeaveEntity(const EntityItemI
|
|||
}
|
||||
}
|
||||
|
||||
void ContextOverlayInterface::proveAvatarEntityOwnershipVerification(const QUuid& entityItemID) {
|
||||
EntityItemProperties entityProperties = _entityScriptingInterface->getEntityProperties(entityItemID, _entityPropertyFlags);
|
||||
_entityMarketplaceID = entityProperties.getMarketplaceID();
|
||||
if (!entityItemID.isNull() && _entityMarketplaceID.length() > 0) {
|
||||
if (!entityProperties.getClientOnly()) {
|
||||
qCDebug(entities) << "Failed to prove ownership of:" << entityItemID << "is not an avatar entity";
|
||||
emit ownershipVerificationFailed(entityItemID);
|
||||
return;
|
||||
}
|
||||
setLastInspectedEntity(entityItemID);
|
||||
requestOwnershipVerification();
|
||||
}
|
||||
}
|
||||
void ContextOverlayInterface::requestOwnershipVerification(const QUuid& entityID) {
|
||||
|
||||
setLastInspectedEntity(entityID);
|
||||
|
||||
void ContextOverlayInterface::requestOwnershipVerification() {
|
||||
EntityItemProperties entityProperties = _entityScriptingInterface->getEntityProperties(_lastInspectedEntity, _entityPropertyFlags);
|
||||
|
||||
auto nodeList = DependencyManager::get<NodeList>();
|
||||
|
@ -381,7 +370,7 @@ void ContextOverlayInterface::openInspectionCertificate() {
|
|||
_hmdScriptingInterface->openTablet();
|
||||
|
||||
setLastInspectedEntity(_currentEntityWithContextOverlay);
|
||||
requestOwnershipVerification();
|
||||
requestOwnershipVerification(_lastInspectedEntity);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -50,13 +50,13 @@ class ContextOverlayInterface : public QObject, public Dependency {
|
|||
public:
|
||||
ContextOverlayInterface();
|
||||
Q_INVOKABLE QUuid getCurrentEntityWithContextOverlay() { return _currentEntityWithContextOverlay; }
|
||||
Q_INVOKABLE void proveAvatarEntityOwnershipVerification(const QUuid& entityID);
|
||||
void setCurrentEntityWithContextOverlay(const QUuid& entityID) { _currentEntityWithContextOverlay = entityID; }
|
||||
void setLastInspectedEntity(const QUuid& entityID) { _challengeOwnershipTimeoutTimer.stop(); _lastInspectedEntity = entityID; }
|
||||
void setEnabled(bool enabled);
|
||||
bool getEnabled() { return _enabled; }
|
||||
bool getIsInMarketplaceInspectionMode() { return _isInMarketplaceInspectionMode; }
|
||||
void setIsInMarketplaceInspectionMode(bool mode) { _isInMarketplaceInspectionMode = mode; }
|
||||
void requestOwnershipVerification(const QUuid& entityID);
|
||||
|
||||
signals:
|
||||
void contextOverlayClicked(const QUuid& currentEntityWithContextOverlay);
|
||||
|
@ -92,7 +92,6 @@ private:
|
|||
bool _isInMarketplaceInspectionMode { false };
|
||||
|
||||
void openInspectionCertificate();
|
||||
void requestOwnershipVerification();
|
||||
void openMarketplace();
|
||||
void enableEntityHighlight(const EntityItemID& entityItemID);
|
||||
void disableEntityHighlight(const EntityItemID& entityItemID);
|
||||
|
|
Loading…
Reference in a new issue