mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 11:28:03 +02:00
Round 2
This commit is contained in:
parent
acdd1e32e4
commit
733df8391f
12 changed files with 93 additions and 44 deletions
|
@ -80,7 +80,6 @@ Rectangle {
|
||||||
root.activeView = "checkoutFailure";
|
root.activeView = "checkoutFailure";
|
||||||
} else {
|
} else {
|
||||||
root.itemHref = result.data.download_url;
|
root.itemHref = result.data.download_url;
|
||||||
console.log("ZRF TEST " + root.itemHref);
|
|
||||||
root.activeView = "checkoutSuccess";
|
root.activeView = "checkoutSuccess";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,6 @@
|
||||||
#include "Ledger.h"
|
#include "Ledger.h"
|
||||||
#include "Wallet.h"
|
#include "Wallet.h"
|
||||||
#include <AccountManager.h>
|
#include <AccountManager.h>
|
||||||
#include "scripting/WalletScriptingInterface.h"
|
|
||||||
|
|
||||||
HIFI_QML_DEF(QmlCommerce)
|
HIFI_QML_DEF(QmlCommerce)
|
||||||
|
|
||||||
|
@ -29,37 +28,12 @@ QmlCommerce::QmlCommerce(QQuickItem* parent) : OffscreenQmlDialog(parent) {
|
||||||
connect(ledger.data(), &Ledger::historyResult, this, &QmlCommerce::historyResult);
|
connect(ledger.data(), &Ledger::historyResult, this, &QmlCommerce::historyResult);
|
||||||
connect(wallet.data(), &Wallet::keyFilePathIfExistsResult, this, &QmlCommerce::keyFilePathIfExistsResult);
|
connect(wallet.data(), &Wallet::keyFilePathIfExistsResult, this, &QmlCommerce::keyFilePathIfExistsResult);
|
||||||
connect(ledger.data(), &Ledger::accountResult, this, &QmlCommerce::accountResult);
|
connect(ledger.data(), &Ledger::accountResult, this, &QmlCommerce::accountResult);
|
||||||
connect(ledger.data(), &Ledger::accountResult, this, [&]() {
|
connect(wallet.data(), &Wallet::walletStatusResult, this, &QmlCommerce::walletStatusResult);
|
||||||
auto wallet = DependencyManager::get<Wallet>();
|
|
||||||
auto walletScriptingInterface = DependencyManager::get<WalletScriptingInterface>();
|
|
||||||
uint status;
|
|
||||||
|
|
||||||
if (wallet->getKeyFilePath() == "" || !wallet->getSecurityImage()) {
|
|
||||||
status = (uint)WalletStatus::WALLET_STATUS_NOT_SET_UP;
|
|
||||||
} else if (!wallet->walletIsAuthenticatedWithPassphrase()) {
|
|
||||||
status = (uint)WalletStatus::WALLET_STATUS_NOT_AUTHENTICATED;
|
|
||||||
} else {
|
|
||||||
status = (uint)WalletStatus::WALLET_STATUS_READY;
|
|
||||||
}
|
|
||||||
|
|
||||||
walletScriptingInterface->setWalletStatus(status);
|
|
||||||
emit walletStatusResult(status);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlCommerce::getWalletStatus() {
|
void QmlCommerce::getWalletStatus() {
|
||||||
auto walletScriptingInterface = DependencyManager::get<WalletScriptingInterface>();
|
auto wallet = DependencyManager::get<Wallet>();
|
||||||
uint status;
|
wallet->getWalletStatus();
|
||||||
|
|
||||||
if (DependencyManager::get<AccountManager>()->isLoggedIn()) {
|
|
||||||
// This will set account info for the wallet, allowing us to decrypt and display the security image.
|
|
||||||
account();
|
|
||||||
} else {
|
|
||||||
status = (uint)WalletStatus::WALLET_STATUS_NOT_LOGGED_IN;
|
|
||||||
emit walletStatusResult(status);
|
|
||||||
walletScriptingInterface->setWalletStatus(status);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlCommerce::getLoginStatus() {
|
void QmlCommerce::getLoginStatus() {
|
||||||
|
|
|
@ -27,13 +27,6 @@ class QmlCommerce : public OffscreenQmlDialog {
|
||||||
public:
|
public:
|
||||||
QmlCommerce(QQuickItem* parent = nullptr);
|
QmlCommerce(QQuickItem* parent = nullptr);
|
||||||
|
|
||||||
enum WalletStatus {
|
|
||||||
WALLET_STATUS_NOT_LOGGED_IN = 0,
|
|
||||||
WALLET_STATUS_NOT_SET_UP,
|
|
||||||
WALLET_STATUS_NOT_AUTHENTICATED,
|
|
||||||
WALLET_STATUS_READY
|
|
||||||
};
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void walletStatusResult(uint walletStatus);
|
void walletStatusResult(uint walletStatus);
|
||||||
|
|
||||||
|
|
|
@ -282,9 +282,27 @@ void initializeAESKeys(unsigned char* ivec, unsigned char* ckey, const QByteArra
|
||||||
|
|
||||||
Wallet::Wallet() {
|
Wallet::Wallet() {
|
||||||
auto nodeList = DependencyManager::get<NodeList>();
|
auto nodeList = DependencyManager::get<NodeList>();
|
||||||
|
auto ledger = DependencyManager::get<Ledger>();
|
||||||
auto& packetReceiver = nodeList->getPacketReceiver();
|
auto& packetReceiver = nodeList->getPacketReceiver();
|
||||||
|
|
||||||
packetReceiver.registerListener(PacketType::ChallengeOwnership, this, "handleChallengeOwnershipPacket");
|
packetReceiver.registerListener(PacketType::ChallengeOwnership, this, "handleChallengeOwnershipPacket");
|
||||||
|
|
||||||
|
connect(ledger.data(), &Ledger::accountResult, this, [&]() {
|
||||||
|
auto wallet = DependencyManager::get<Wallet>();
|
||||||
|
auto walletScriptingInterface = DependencyManager::get<WalletScriptingInterface>();
|
||||||
|
uint status;
|
||||||
|
|
||||||
|
if (wallet->getKeyFilePath() == "" || !wallet->getSecurityImage()) {
|
||||||
|
status = (uint)WalletStatus::WALLET_STATUS_NOT_SET_UP;
|
||||||
|
} else if (!wallet->walletIsAuthenticatedWithPassphrase()) {
|
||||||
|
status = (uint)WalletStatus::WALLET_STATUS_NOT_AUTHENTICATED;
|
||||||
|
} else {
|
||||||
|
status = (uint)WalletStatus::WALLET_STATUS_READY;
|
||||||
|
}
|
||||||
|
|
||||||
|
walletScriptingInterface->setWalletStatus(status);
|
||||||
|
emit walletStatusResult(status);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Wallet::~Wallet() {
|
Wallet::~Wallet() {
|
||||||
|
@ -682,3 +700,23 @@ bool Wallet::verifyOwnerChallenge(const QByteArray& encryptedText, const QString
|
||||||
decryptedText = QString("hello");
|
decryptedText = QString("hello");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Wallet::account() {
|
||||||
|
auto ledger = DependencyManager::get<Ledger>();
|
||||||
|
ledger->account();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Wallet::getWalletStatus() {
|
||||||
|
auto walletScriptingInterface = DependencyManager::get<WalletScriptingInterface>();
|
||||||
|
uint status;
|
||||||
|
|
||||||
|
if (DependencyManager::get<AccountManager>()->isLoggedIn()) {
|
||||||
|
// This will set account info for the wallet, allowing us to decrypt and display the security image.
|
||||||
|
account();
|
||||||
|
} else {
|
||||||
|
status = (uint)WalletStatus::WALLET_STATUS_NOT_LOGGED_IN;
|
||||||
|
emit walletStatusResult(status);
|
||||||
|
walletScriptingInterface->setWalletStatus(status);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
#include <DependencyManager.h>
|
#include <DependencyManager.h>
|
||||||
#include <Node.h>
|
#include <Node.h>
|
||||||
#include <ReceivedMessage.h>
|
#include <ReceivedMessage.h>
|
||||||
|
#include "scripting/WalletScriptingInterface.h"
|
||||||
|
|
||||||
#include <QPixmap>
|
#include <QPixmap>
|
||||||
|
|
||||||
|
@ -50,10 +51,20 @@ public:
|
||||||
|
|
||||||
void reset();
|
void reset();
|
||||||
|
|
||||||
|
void getWalletStatus();
|
||||||
|
enum WalletStatus {
|
||||||
|
WALLET_STATUS_NOT_LOGGED_IN = 0,
|
||||||
|
WALLET_STATUS_NOT_SET_UP,
|
||||||
|
WALLET_STATUS_NOT_AUTHENTICATED,
|
||||||
|
WALLET_STATUS_READY
|
||||||
|
};
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void securityImageResult(bool exists);
|
void securityImageResult(bool exists);
|
||||||
void keyFilePathIfExistsResult(const QString& path);
|
void keyFilePathIfExistsResult(const QString& path);
|
||||||
|
|
||||||
|
void walletStatusResult(uint walletStatus);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void handleChallengeOwnershipPacket(QSharedPointer<ReceivedMessage> packet, SharedNodePointer sendingNode);
|
void handleChallengeOwnershipPacket(QSharedPointer<ReceivedMessage> packet, SharedNodePointer sendingNode);
|
||||||
|
|
||||||
|
@ -71,6 +82,8 @@ private:
|
||||||
bool readSecurityImage(const QString& inputFilePath, unsigned char** outputBufferPtr, int* outputBufferLen);
|
bool readSecurityImage(const QString& inputFilePath, unsigned char** outputBufferPtr, int* outputBufferLen);
|
||||||
|
|
||||||
bool verifyOwnerChallenge(const QByteArray& encryptedText, const QString& publicKey, QString& decryptedText);
|
bool verifyOwnerChallenge(const QByteArray& encryptedText, const QString& publicKey, QString& decryptedText);
|
||||||
|
|
||||||
|
void account();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // hifi_Wallet_h
|
#endif // hifi_Wallet_h
|
||||||
|
|
|
@ -18,6 +18,11 @@ CheckoutProxy::CheckoutProxy(QObject* qmlObject, QObject* parent) : QmlWrapper(q
|
||||||
WalletScriptingInterface::WalletScriptingInterface() {
|
WalletScriptingInterface::WalletScriptingInterface() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WalletScriptingInterface::refreshWalletStatus() {
|
||||||
|
auto wallet = DependencyManager::get<Wallet>();
|
||||||
|
wallet->getWalletStatus();
|
||||||
|
}
|
||||||
|
|
||||||
static const QString CHECKOUT_QML_PATH = qApp->applicationDirPath() + "../../../qml/hifi/commerce/checkout/Checkout.qml";
|
static const QString CHECKOUT_QML_PATH = qApp->applicationDirPath() + "../../../qml/hifi/commerce/checkout/Checkout.qml";
|
||||||
void WalletScriptingInterface::buy(const QString& name, const QString& id, const int& price, const QString& href) {
|
void WalletScriptingInterface::buy(const QString& name, const QString& id, const int& price, const QString& href) {
|
||||||
if (QThread::currentThread() != thread()) {
|
if (QThread::currentThread() != thread()) {
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
#include <ui/QmlWrapper.h>
|
#include <ui/QmlWrapper.h>
|
||||||
#include <OffscreenUi.h>
|
#include <OffscreenUi.h>
|
||||||
#include "Application.h"
|
#include "Application.h"
|
||||||
|
#include "commerce/Wallet.h"
|
||||||
|
|
||||||
class CheckoutProxy : public QmlWrapper {
|
class CheckoutProxy : public QmlWrapper {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -36,6 +37,7 @@ class WalletScriptingInterface : public QObject, public Dependency {
|
||||||
public:
|
public:
|
||||||
WalletScriptingInterface();
|
WalletScriptingInterface();
|
||||||
|
|
||||||
|
Q_INVOKABLE void refreshWalletStatus();
|
||||||
Q_INVOKABLE uint getWalletStatus() { return _walletStatus; }
|
Q_INVOKABLE uint getWalletStatus() { return _walletStatus; }
|
||||||
void setWalletStatus(const uint& status) { _walletStatus = status; }
|
void setWalletStatus(const uint& status) { _walletStatus = status; }
|
||||||
|
|
||||||
|
@ -43,6 +45,7 @@ public:
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void walletStatusChanged();
|
void walletStatusChanged();
|
||||||
|
void walletNotSetup();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
uint _walletStatus;
|
uint _walletStatus;
|
||||||
|
|
|
@ -41,6 +41,7 @@ ContextOverlayInterface::ContextOverlayInterface() {
|
||||||
_entityPropertyFlags += PROP_MARKETPLACE_ID;
|
_entityPropertyFlags += PROP_MARKETPLACE_ID;
|
||||||
_entityPropertyFlags += PROP_DIMENSIONS;
|
_entityPropertyFlags += PROP_DIMENSIONS;
|
||||||
_entityPropertyFlags += PROP_REGISTRATION_POINT;
|
_entityPropertyFlags += PROP_REGISTRATION_POINT;
|
||||||
|
_entityPropertyFlags += PROP_CERTIFICATE_ID;
|
||||||
|
|
||||||
auto entityTreeRenderer = DependencyManager::get<EntityTreeRenderer>().data();
|
auto entityTreeRenderer = DependencyManager::get<EntityTreeRenderer>().data();
|
||||||
connect(entityTreeRenderer, SIGNAL(mousePressOnEntity(const EntityItemID&, const PointerEvent&)), this, SLOT(createOrDestroyContextOverlay(const EntityItemID&, const PointerEvent&)));
|
connect(entityTreeRenderer, SIGNAL(mousePressOnEntity(const EntityItemID&, const PointerEvent&)), this, SLOT(createOrDestroyContextOverlay(const EntityItemID&, const PointerEvent&)));
|
||||||
|
@ -176,7 +177,12 @@ bool ContextOverlayInterface::createOrDestroyContextOverlay(const EntityItemID&
|
||||||
|
|
||||||
bool ContextOverlayInterface::contextOverlayFilterPassed(const EntityItemID& entityItemID) {
|
bool ContextOverlayInterface::contextOverlayFilterPassed(const EntityItemID& entityItemID) {
|
||||||
EntityItemProperties entityProperties = _entityScriptingInterface->getEntityProperties(entityItemID, _entityPropertyFlags);
|
EntityItemProperties entityProperties = _entityScriptingInterface->getEntityProperties(entityItemID, _entityPropertyFlags);
|
||||||
return (entityProperties.getMarketplaceID().length() != 0);
|
Setting::Handle<bool> _settingSwitch{ "commerce", false };
|
||||||
|
if (_settingSwitch.get()) {
|
||||||
|
return (entityProperties.getCertificateID().length() != 0);
|
||||||
|
} else {
|
||||||
|
return (entityProperties.getMarketplaceID().length() != 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ContextOverlayInterface::destroyContextOverlay(const EntityItemID& entityItemID, const PointerEvent& event) {
|
bool ContextOverlayInterface::destroyContextOverlay(const EntityItemID& entityItemID, const PointerEvent& event) {
|
||||||
|
|
|
@ -16,6 +16,8 @@
|
||||||
(function () { // BEGIN LOCAL_SCOPE
|
(function () { // BEGIN LOCAL_SCOPE
|
||||||
Script.include("/~/system/libraries/accountUtils.js");
|
Script.include("/~/system/libraries/accountUtils.js");
|
||||||
|
|
||||||
|
var MARKETPLACE_URL = "https://metaverse.highfidelity.com/marketplace";
|
||||||
|
|
||||||
// Function Name: onButtonClicked()
|
// Function Name: onButtonClicked()
|
||||||
//
|
//
|
||||||
// Description:
|
// Description:
|
||||||
|
@ -88,6 +90,9 @@
|
||||||
case 'goToPurchases':
|
case 'goToPurchases':
|
||||||
tablet.pushOntoStack(MARKETPLACE_PURCHASES_QML_PATH);
|
tablet.pushOntoStack(MARKETPLACE_PURCHASES_QML_PATH);
|
||||||
break;
|
break;
|
||||||
|
case 'goToMarketplaceItemPage':
|
||||||
|
tablet.gotoWebScreen(MARKETPLACE_URL + '/items/' + message.itemId, MARKETPLACES_INJECT_SCRIPT_URL);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
print('Unrecognized message from QML:', JSON.stringify(message));
|
print('Unrecognized message from QML:', JSON.stringify(message));
|
||||||
}
|
}
|
||||||
|
|
|
@ -334,7 +334,6 @@
|
||||||
$('body').addClass("code-injected");
|
$('body').addClass("code-injected");
|
||||||
|
|
||||||
maybeAddLogInButton();
|
maybeAddLogInButton();
|
||||||
maybeAddSetupWalletButton();
|
|
||||||
changeDropdownMenu();
|
changeDropdownMenu();
|
||||||
|
|
||||||
var purchaseButton = $('#side-info').find('.btn').first();
|
var purchaseButton = $('#side-info').find('.btn').first();
|
||||||
|
|
|
@ -129,6 +129,10 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function openWallet() {
|
||||||
|
tablet.pushOntoStack(MARKETPLACE_WALLET_QML_PATH);
|
||||||
|
}
|
||||||
|
|
||||||
function setCertificateInfo(currentEntityWithContextOverlay, itemMarketplaceId) {
|
function setCertificateInfo(currentEntityWithContextOverlay, itemMarketplaceId) {
|
||||||
wireEventBridge(true);
|
wireEventBridge(true);
|
||||||
tablet.sendToQml({
|
tablet.sendToQml({
|
||||||
|
@ -158,6 +162,7 @@
|
||||||
Entities.canWriteAssetsChanged.connect(onCanWriteAssetsChanged);
|
Entities.canWriteAssetsChanged.connect(onCanWriteAssetsChanged);
|
||||||
ContextOverlay.contextOverlayClicked.connect(setCertificateInfo);
|
ContextOverlay.contextOverlayClicked.connect(setCertificateInfo);
|
||||||
GlobalServices.myUsernameChanged.connect(onUsernameChanged);
|
GlobalServices.myUsernameChanged.connect(onUsernameChanged);
|
||||||
|
Wallet.refreshWalletStatus();
|
||||||
|
|
||||||
function onMessage(message) {
|
function onMessage(message) {
|
||||||
|
|
||||||
|
@ -214,7 +219,7 @@
|
||||||
} else if (parsedJsonMessage.type === "LOGIN") {
|
} else if (parsedJsonMessage.type === "LOGIN") {
|
||||||
openLoginWindow();
|
openLoginWindow();
|
||||||
} else if (parsedJsonMessage.type === "WALLET_SETUP") {
|
} else if (parsedJsonMessage.type === "WALLET_SETUP") {
|
||||||
tablet.pushOntoStack(MARKETPLACE_WALLET_QML_PATH);
|
openWallet();
|
||||||
} else if (parsedJsonMessage.type === "MY_ITEMS") {
|
} else if (parsedJsonMessage.type === "MY_ITEMS") {
|
||||||
referrerURL = MARKETPLACE_URL_INITIAL;
|
referrerURL = MARKETPLACE_URL_INITIAL;
|
||||||
filterText = "";
|
filterText = "";
|
||||||
|
@ -281,16 +286,22 @@
|
||||||
case 'purchases_openWallet':
|
case 'purchases_openWallet':
|
||||||
case 'checkout_openWallet':
|
case 'checkout_openWallet':
|
||||||
case 'checkout_setUpClicked':
|
case 'checkout_setUpClicked':
|
||||||
tablet.pushOntoStack(MARKETPLACE_WALLET_QML_PATH);
|
openWallet();
|
||||||
break;
|
break;
|
||||||
case 'purchases_walletNotSetUp':
|
case 'purchases_walletNotSetUp':
|
||||||
case 'checkout_walletNotSetUp':
|
|
||||||
wireEventBridge(true);
|
wireEventBridge(true);
|
||||||
tablet.sendToQml({
|
tablet.sendToQml({
|
||||||
method: 'updateWalletReferrer',
|
method: 'updateWalletReferrer',
|
||||||
referrer: "purchases"
|
referrer: "purchases"
|
||||||
});
|
});
|
||||||
tablet.pushOntoStack(MARKETPLACE_WALLET_QML_PATH);
|
openWallet();
|
||||||
|
case 'checkout_walletNotSetUp':
|
||||||
|
wireEventBridge(true);
|
||||||
|
tablet.sendToQml({
|
||||||
|
method: 'updateWalletReferrer',
|
||||||
|
referrer: message.itemId
|
||||||
|
});
|
||||||
|
openWallet();
|
||||||
break;
|
break;
|
||||||
case 'checkout_cancelClicked':
|
case 'checkout_cancelClicked':
|
||||||
tablet.gotoWebScreen(MARKETPLACE_URL + '/items/' + message.params, MARKETPLACES_INJECT_SCRIPT_URL);
|
tablet.gotoWebScreen(MARKETPLACE_URL + '/items/' + message.params, MARKETPLACES_INJECT_SCRIPT_URL);
|
||||||
|
|
|
@ -95,13 +95,15 @@
|
||||||
EDIT_ERROR: 4,
|
EDIT_ERROR: 4,
|
||||||
TABLET: 5,
|
TABLET: 5,
|
||||||
CONNECTION: 6,
|
CONNECTION: 6,
|
||||||
|
WALLET: 7,
|
||||||
properties: [
|
properties: [
|
||||||
{ text: "Snapshot" },
|
{ text: "Snapshot" },
|
||||||
{ text: "Level of Detail" },
|
{ text: "Level of Detail" },
|
||||||
{ text: "Connection Refused" },
|
{ text: "Connection Refused" },
|
||||||
{ text: "Edit error" },
|
{ text: "Edit error" },
|
||||||
{ text: "Tablet" },
|
{ text: "Tablet" },
|
||||||
{ text: "Connection" }
|
{ text: "Connection" },
|
||||||
|
{ text: "Wallet" }
|
||||||
],
|
],
|
||||||
getTypeFromMenuItem: function (menuItemName) {
|
getTypeFromMenuItem: function (menuItemName) {
|
||||||
var type;
|
var type;
|
||||||
|
@ -691,6 +693,7 @@
|
||||||
Window.notifyEditError = onEditError;
|
Window.notifyEditError = onEditError;
|
||||||
Window.notify = onNotify;
|
Window.notify = onNotify;
|
||||||
Tablet.tabletNotification.connect(tabletNotification);
|
Tablet.tabletNotification.connect(tabletNotification);
|
||||||
|
Wallet.walletNotSetup.connect(walletNotSetup);
|
||||||
|
|
||||||
Messages.subscribe(NOTIFICATIONS_MESSAGE_CHANNEL);
|
Messages.subscribe(NOTIFICATIONS_MESSAGE_CHANNEL);
|
||||||
Messages.messageReceived.connect(onMessageReceived);
|
Messages.messageReceived.connect(onMessageReceived);
|
||||||
|
|
Loading…
Reference in a new issue