From 20635acf27d5501e431288576ac5cad98dac571c Mon Sep 17 00:00:00 2001 From: Liv Erickson Date: Fri, 26 Jan 2018 17:13:39 -0800 Subject: [PATCH] moving logic to wallet, crashes currently --- .../scripting/WalletScriptingInterface.cpp | 22 +++++++++++++++++++ .../src/scripting/WalletScriptingInterface.h | 5 +++++ .../ui/overlays/ContextOverlayInterface.cpp | 19 ++++------------ .../src/ui/overlays/ContextOverlayInterface.h | 3 +-- 4 files changed, 32 insertions(+), 17 deletions(-) diff --git a/interface/src/scripting/WalletScriptingInterface.cpp b/interface/src/scripting/WalletScriptingInterface.cpp index 71a7076bdf..8d6dc7bbcd 100644 --- a/interface/src/scripting/WalletScriptingInterface.cpp +++ b/interface/src/scripting/WalletScriptingInterface.cpp @@ -16,6 +16,16 @@ CheckoutProxy::CheckoutProxy(QObject* qmlObject, QObject* parent) : QmlWrapper(q } WalletScriptingInterface::WalletScriptingInterface() { + _contextOverlayInterface = DependencyManager::get(); + + _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()->walletStatusResult(status); +} + +void WalletScriptingInterface::proveAvatarEntityOwnershipVerification(const QUuid& entityID) { + EntityItemProperties entityProperties = DependencyManager::get()->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); + } } \ No newline at end of file diff --git a/interface/src/scripting/WalletScriptingInterface.h b/interface/src/scripting/WalletScriptingInterface.h index 5469e732c7..c725c34685 100644 --- a/interface/src/scripting/WalletScriptingInterface.h +++ b/interface/src/scripting/WalletScriptingInterface.h @@ -21,6 +21,7 @@ #include #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; + 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 diff --git a/interface/src/ui/overlays/ContextOverlayInterface.cpp b/interface/src/ui/overlays/ContextOverlayInterface.cpp index d86d441e3b..4a5aa3d0f4 100644 --- a/interface/src/ui/overlays/ContextOverlayInterface.cpp +++ b/interface/src/ui/overlays/ContextOverlayInterface.cpp @@ -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(); @@ -381,7 +370,7 @@ void ContextOverlayInterface::openInspectionCertificate() { _hmdScriptingInterface->openTablet(); setLastInspectedEntity(_currentEntityWithContextOverlay); - requestOwnershipVerification(); + requestOwnershipVerification(_lastInspectedEntity); } } diff --git a/interface/src/ui/overlays/ContextOverlayInterface.h b/interface/src/ui/overlays/ContextOverlayInterface.h index 04416299d6..4063b28785 100644 --- a/interface/src/ui/overlays/ContextOverlayInterface.h +++ b/interface/src/ui/overlays/ContextOverlayInterface.h @@ -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);