mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-07-23 03:46:52 +02:00
Still need to send correct thing to metaverse
This commit is contained in:
parent
f5a8187fe2
commit
4046c873bd
9 changed files with 70 additions and 19 deletions
|
@ -137,11 +137,27 @@ Rectangle {
|
||||||
console.log("Failed to get Available Updates", result.data.message);
|
console.log("Failed to get Available Updates", result.data.message);
|
||||||
} else {
|
} else {
|
||||||
root.availableUpdatesReceived = true;
|
root.availableUpdatesReceived = true;
|
||||||
if (result.data.updates.indexOf(root.itemId) > -1) {
|
for (var i = 0; i < result.data.updates.length; i++) {
|
||||||
root.isUpdating = true;
|
if (result.data.updates[i].item_id === root.itemId) {
|
||||||
|
root.isUpdating = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onUpdateItemResult: {
|
||||||
|
if (result.status !== 'success') {
|
||||||
|
failureErrorText.text = result.message;
|
||||||
|
root.activeView = "checkoutFailure";
|
||||||
|
} else {
|
||||||
|
root.itemHref = result.data.download_url;
|
||||||
|
if (result.data.categories.indexOf("Wearables") > -1) {
|
||||||
|
root.itemType = "wearable";
|
||||||
|
}
|
||||||
|
root.activeView = "checkoutSuccess";
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onItemIdChanged: {
|
onItemIdChanged: {
|
||||||
|
@ -447,7 +463,7 @@ Rectangle {
|
||||||
id: itemPriceText;
|
id: itemPriceText;
|
||||||
text: root.isUpdating ? "FREE\nUPGRADE" : ((root.itemPrice === -1) ? "--" : root.itemPrice);
|
text: root.isUpdating ? "FREE\nUPGRADE" : ((root.itemPrice === -1) ? "--" : root.itemPrice);
|
||||||
// Text size
|
// Text size
|
||||||
size: 26;
|
size: root.isUpdating ? 20 : 26;
|
||||||
// Anchors
|
// Anchors
|
||||||
anchors.top: parent.top;
|
anchors.top: parent.top;
|
||||||
anchors.right: parent.right;
|
anchors.right: parent.right;
|
||||||
|
@ -569,7 +585,9 @@ Rectangle {
|
||||||
text: root.isUpdating ? "CONFIRM UPDATE" : (((root.isCertified) ? ((ownershipStatusReceived && balanceReceived && availableUpdatesReceived) ?
|
text: root.isUpdating ? "CONFIRM UPDATE" : (((root.isCertified) ? ((ownershipStatusReceived && balanceReceived && availableUpdatesReceived) ?
|
||||||
(viewInMyPurchasesButton.visible ? "Buy It Again" : "Confirm Purchase") : "--") : "Get Item"));
|
(viewInMyPurchasesButton.visible ? "Buy It Again" : "Confirm Purchase") : "--") : "Get Item"));
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if (root.isCertified) {
|
if (root.isUpdating) {
|
||||||
|
Commerce.updateItem(root.itemId);
|
||||||
|
} else if (root.isCertified) {
|
||||||
if (!root.shouldBuyWithControlledFailure) {
|
if (!root.shouldBuyWithControlledFailure) {
|
||||||
if (root.itemType === "contentSet" && !Entities.canReplaceContent()) {
|
if (root.itemType === "contentSet" && !Entities.canReplaceContent()) {
|
||||||
lightboxPopup.titleText = "Purchase Content Set";
|
lightboxPopup.titleText = "Purchase Content Set";
|
||||||
|
@ -1020,12 +1038,12 @@ Rectangle {
|
||||||
switch (message.method) {
|
switch (message.method) {
|
||||||
case 'updateCheckoutQML':
|
case 'updateCheckoutQML':
|
||||||
root.isUpdating = message.params.isUpdating;
|
root.isUpdating = message.params.isUpdating;
|
||||||
itemId = message.params.itemId;
|
root.itemId = message.params.itemId;
|
||||||
itemName = message.params.itemName;
|
root.itemName = message.params.itemName.trim();
|
||||||
root.itemPrice = message.params.itemPrice;
|
root.itemPrice = message.params.itemPrice;
|
||||||
itemHref = message.params.itemHref;
|
root.itemHref = message.params.itemHref;
|
||||||
referrer = message.params.referrer;
|
root.referrer = message.params.referrer;
|
||||||
itemAuthor = message.params.itemAuthor;
|
root.itemAuthor = message.params.itemAuthor;
|
||||||
refreshBuyUI();
|
refreshBuyUI();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -1056,11 +1074,9 @@ Rectangle {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (root.isUpdating) {
|
if (root.isUpdating) {
|
||||||
buyText.text = "By agreeing to update, you agree to trade in your old item for the update that replaces it.";
|
buyText.text = "By pressing \"Confirm Update\", you agree to trade in your old item for the updated item that replaces it.";
|
||||||
buyTextContainer.color = "#FFC3CD";
|
buyTextContainer.color = "#FFFFFF";
|
||||||
buyTextContainer.border.color = "#F3808F";
|
buyTextContainer.border.color = "#FFFFFF";
|
||||||
buyGlyph.text = hifi.glyphs.alert;
|
|
||||||
buyGlyph.size = 54;
|
|
||||||
} else if (root.itemType === "contentSet" && !Entities.canReplaceContent()) {
|
} else if (root.itemType === "contentSet" && !Entities.canReplaceContent()) {
|
||||||
buyText.text = "The domain owner must enable 'Replace Content' permissions for you in this " +
|
buyText.text = "The domain owner must enable 'Replace Content' permissions for you in this " +
|
||||||
"<b>domain's server settings</b> before you can replace this domain's content with <b>" + root.itemName + "</b>";
|
"<b>domain's server settings</b> before you can replace this domain's content with <b>" + root.itemName + "</b>";
|
||||||
|
|
|
@ -50,11 +50,12 @@ Item {
|
||||||
property bool isInstalled;
|
property bool isInstalled;
|
||||||
property string upgradeUrl;
|
property string upgradeUrl;
|
||||||
property string upgradeTitle;
|
property string upgradeTitle;
|
||||||
|
property bool isShowingMyItems;
|
||||||
|
|
||||||
property string originalStatusText;
|
property string originalStatusText;
|
||||||
property string originalStatusColor;
|
property string originalStatusColor;
|
||||||
|
|
||||||
height: root.upgradeUrl === "" ? 110 : 150;
|
height: (root.upgradeUrl === "" || root.isShowingMyItems) ? 110 : 150;
|
||||||
width: parent.width;
|
width: parent.width;
|
||||||
|
|
||||||
Connections {
|
Connections {
|
||||||
|
@ -647,7 +648,7 @@ Item {
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
id: upgradeAvailableContainer;
|
id: upgradeAvailableContainer;
|
||||||
visible: root.upgradeUrl !== "";
|
visible: root.upgradeUrl !== "" && !root.isShowingMyItems;
|
||||||
anchors.top: itemContainer.bottom;
|
anchors.top: itemContainer.bottom;
|
||||||
anchors.bottom: parent.bottom;
|
anchors.bottom: parent.bottom;
|
||||||
anchors.left: parent.left;
|
anchors.left: parent.left;
|
||||||
|
|
|
@ -400,6 +400,7 @@ Rectangle {
|
||||||
isInstalled: model.isInstalled;
|
isInstalled: model.isInstalled;
|
||||||
upgradeUrl: model.upgrade_url;
|
upgradeUrl: model.upgrade_url;
|
||||||
upgradeTitle: model.upgrade_title;
|
upgradeTitle: model.upgrade_title;
|
||||||
|
isShowingMyItems: root.isShowingMyItems;
|
||||||
itemType: {
|
itemType: {
|
||||||
if (model.root_file_url.indexOf(".fst") > -1) {
|
if (model.root_file_url.indexOf(".fst") > -1) {
|
||||||
"avatar";
|
"avatar";
|
||||||
|
|
|
@ -53,6 +53,7 @@ Handler(transferHfcToNode)
|
||||||
Handler(transferHfcToUsername)
|
Handler(transferHfcToUsername)
|
||||||
Handler(alreadyOwned)
|
Handler(alreadyOwned)
|
||||||
Handler(availableUpdates)
|
Handler(availableUpdates)
|
||||||
|
Handler(updateItem)
|
||||||
|
|
||||||
void Ledger::send(const QString& endpoint, const QString& success, const QString& fail, QNetworkAccessManager::Operation method, AccountManagerAuth::Type authType, QJsonObject request) {
|
void Ledger::send(const QString& endpoint, const QString& success, const QString& fail, QNetworkAccessManager::Operation method, AccountManagerAuth::Type authType, QJsonObject request) {
|
||||||
auto accountManager = DependencyManager::get<AccountManager>();
|
auto accountManager = DependencyManager::get<AccountManager>();
|
||||||
|
@ -372,3 +373,14 @@ void Ledger::getAvailableUpdates() {
|
||||||
request["public_keys"] = QJsonArray::fromStringList(wallet->listPublicKeys());
|
request["public_keys"] = QJsonArray::fromStringList(wallet->listPublicKeys());
|
||||||
send(endpoint, "availableUpdatesSuccess", "availableUpdatesFailure", QNetworkAccessManager::PutOperation, AccountManagerAuth::Required, request);
|
send(endpoint, "availableUpdatesSuccess", "availableUpdatesFailure", QNetworkAccessManager::PutOperation, AccountManagerAuth::Required, request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Ledger::updateItem(const QString& hfc_key, const QString& asset_id, const QString& inventory_key) {
|
||||||
|
QJsonObject transaction;
|
||||||
|
transaction["hfc_key"] = hfc_key;
|
||||||
|
transaction["cost"] = 0;
|
||||||
|
transaction["asset_id"] = asset_id;
|
||||||
|
transaction["inventory_key"] = inventory_key;
|
||||||
|
QJsonDocument transactionDoc{ transaction };
|
||||||
|
auto transactionString = transactionDoc.toJson(QJsonDocument::Compact);
|
||||||
|
signedSend("transaction", transactionString, hfc_key, "update_item", "updateItemSuccess", "updateItemFailure");
|
||||||
|
}
|
||||||
|
|
|
@ -37,6 +37,7 @@ public:
|
||||||
void transferHfcToUsername(const QString& hfc_key, const QString& username, const int& amount, const QString& optionalMessage);
|
void transferHfcToUsername(const QString& hfc_key, const QString& username, const int& amount, const QString& optionalMessage);
|
||||||
void alreadyOwned(const QString& marketplaceId);
|
void alreadyOwned(const QString& marketplaceId);
|
||||||
void getAvailableUpdates();
|
void getAvailableUpdates();
|
||||||
|
void updateItem(const QString& hfc_key, const QString& asset_id, const QString& inventory_key);
|
||||||
|
|
||||||
enum CertificateStatus {
|
enum CertificateStatus {
|
||||||
CERTIFICATE_STATUS_UNKNOWN = 0,
|
CERTIFICATE_STATUS_UNKNOWN = 0,
|
||||||
|
@ -59,6 +60,7 @@ signals:
|
||||||
void transferHfcToUsernameResult(QJsonObject result);
|
void transferHfcToUsernameResult(QJsonObject result);
|
||||||
void alreadyOwnedResult(QJsonObject result);
|
void alreadyOwnedResult(QJsonObject result);
|
||||||
void availableUpdatesResult(QJsonObject result);
|
void availableUpdatesResult(QJsonObject result);
|
||||||
|
void updateItemResult(QJsonObject result);
|
||||||
|
|
||||||
void updateCertificateStatus(const QString& certID, uint certStatus);
|
void updateCertificateStatus(const QString& certID, uint certStatus);
|
||||||
|
|
||||||
|
@ -87,6 +89,8 @@ public slots:
|
||||||
void alreadyOwnedFailure(QNetworkReply& reply);
|
void alreadyOwnedFailure(QNetworkReply& reply);
|
||||||
void availableUpdatesSuccess(QNetworkReply& reply);
|
void availableUpdatesSuccess(QNetworkReply& reply);
|
||||||
void availableUpdatesFailure(QNetworkReply& reply);
|
void availableUpdatesFailure(QNetworkReply& reply);
|
||||||
|
void updateItemSuccess(QNetworkReply& reply);
|
||||||
|
void updateItemFailure(QNetworkReply& reply);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QJsonObject apiResponse(const QString& label, QNetworkReply& reply);
|
QJsonObject apiResponse(const QString& label, QNetworkReply& reply);
|
||||||
|
|
|
@ -39,6 +39,7 @@ QmlCommerce::QmlCommerce() {
|
||||||
connect(ledger.data(), &Ledger::transferHfcToNodeResult, this, &QmlCommerce::transferHfcToNodeResult);
|
connect(ledger.data(), &Ledger::transferHfcToNodeResult, this, &QmlCommerce::transferHfcToNodeResult);
|
||||||
connect(ledger.data(), &Ledger::transferHfcToUsernameResult, this, &QmlCommerce::transferHfcToUsernameResult);
|
connect(ledger.data(), &Ledger::transferHfcToUsernameResult, this, &QmlCommerce::transferHfcToUsernameResult);
|
||||||
connect(ledger.data(), &Ledger::availableUpdatesResult, this, &QmlCommerce::availableUpdatesResult);
|
connect(ledger.data(), &Ledger::availableUpdatesResult, this, &QmlCommerce::availableUpdatesResult);
|
||||||
|
connect(ledger.data(), &Ledger::updateItemResult, this, &QmlCommerce::updateItemResult);
|
||||||
|
|
||||||
auto accountManager = DependencyManager::get<AccountManager>();
|
auto accountManager = DependencyManager::get<AccountManager>();
|
||||||
connect(accountManager.data(), &AccountManager::usernameChanged, this, [&]() {
|
connect(accountManager.data(), &AccountManager::usernameChanged, this, [&]() {
|
||||||
|
@ -349,3 +350,16 @@ void QmlCommerce::getAvailableUpdates() {
|
||||||
auto ledger = DependencyManager::get<Ledger>();
|
auto ledger = DependencyManager::get<Ledger>();
|
||||||
ledger->getAvailableUpdates();
|
ledger->getAvailableUpdates();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QmlCommerce::updateItem(const QString& marketplaceId) {
|
||||||
|
auto ledger = DependencyManager::get<Ledger>();
|
||||||
|
auto wallet = DependencyManager::get<Wallet>();
|
||||||
|
QStringList keys = wallet->listPublicKeys();
|
||||||
|
if (keys.count() == 0) {
|
||||||
|
QJsonObject result{ { "status", "fail" },{ "message", "Uninitialized Wallet." } };
|
||||||
|
return emit updateItemResult(result);
|
||||||
|
}
|
||||||
|
QString key = keys[0];
|
||||||
|
// For now, we receive at the same key that pays for it.
|
||||||
|
ledger->updateItem(key, marketplaceId, key);
|
||||||
|
}
|
||||||
|
|
|
@ -44,6 +44,7 @@ signals:
|
||||||
void certificateInfoResult(QJsonObject result);
|
void certificateInfoResult(QJsonObject result);
|
||||||
void alreadyOwnedResult(QJsonObject result);
|
void alreadyOwnedResult(QJsonObject result);
|
||||||
void availableUpdatesResult(QJsonObject result);
|
void availableUpdatesResult(QJsonObject result);
|
||||||
|
void updateItemResult(QJsonObject result);
|
||||||
|
|
||||||
void updateCertificateStatus(const QString& certID, uint certStatus);
|
void updateCertificateStatus(const QString& certID, uint certStatus);
|
||||||
|
|
||||||
|
@ -90,6 +91,7 @@ protected:
|
||||||
Q_INVOKABLE bool openApp(const QString& appHref);
|
Q_INVOKABLE bool openApp(const QString& appHref);
|
||||||
|
|
||||||
Q_INVOKABLE void getAvailableUpdates();
|
Q_INVOKABLE void getAvailableUpdates();
|
||||||
|
Q_INVOKABLE void updateItem(const QString& marketplaceId);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString _appsPath;
|
QString _appsPath;
|
||||||
|
|
|
@ -262,6 +262,7 @@
|
||||||
isUpdating: true,
|
isUpdating: true,
|
||||||
itemId: id,
|
itemId: id,
|
||||||
itemName: name,
|
itemName: name,
|
||||||
|
itemPrice: 0,
|
||||||
itemHref: href,
|
itemHref: href,
|
||||||
referrer: referrer,
|
referrer: referrer,
|
||||||
itemAuthor: author
|
itemAuthor: author
|
||||||
|
@ -436,7 +437,7 @@
|
||||||
var cost = $('.item-cost').text();
|
var cost = $('.item-cost').text();
|
||||||
if (availability !== 'available') {
|
if (availability !== 'available') {
|
||||||
purchaseButton.html('UNAVAILABLE (' + availability + ')');
|
purchaseButton.html('UNAVAILABLE (' + availability + ')');
|
||||||
} else if (url.indexOf('edition=' != -1)) {
|
} else if (window.location.href.indexOf('edition=' != -1)) {
|
||||||
purchaseButton.html('UPDATE FOR FREE');
|
purchaseButton.html('UPDATE FOR FREE');
|
||||||
} else if (parseInt(cost) > 0 && $('#side-info').find('#buyItemButton').size() === 0) {
|
} else if (parseInt(cost) > 0 && $('#side-info').find('#buyItemButton').size() === 0) {
|
||||||
purchaseButton.html('PURCHASE <span class="hifi-glyph hifi-glyph-hfc" style="filter:invert(1);background-size:20px;' +
|
purchaseButton.html('PURCHASE <span class="hifi-glyph hifi-glyph-hfc" style="filter:invert(1);background-size:20px;' +
|
||||||
|
@ -444,7 +445,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
purchaseButton.on('click', function () {
|
purchaseButton.on('click', function () {
|
||||||
if (url.indexOf('edition=' != -1)) {
|
if (window.location.href.indexOf('edition=' != -1)) {
|
||||||
updateButtonClicked(window.location.pathname.split("/")[3],
|
updateButtonClicked(window.location.pathname.split("/")[3],
|
||||||
$('#top-center').find('h1').text(),
|
$('#top-center').find('h1').text(),
|
||||||
$('#creator').find('.value').text(),
|
$('#creator').find('.value').text(),
|
||||||
|
|
|
@ -561,7 +561,7 @@ var selectionDisplay = null; // for gridTool.js to ignore
|
||||||
tablet.gotoWebScreen(MARKETPLACE_URL_INITIAL, MARKETPLACES_INJECT_SCRIPT_URL);
|
tablet.gotoWebScreen(MARKETPLACE_URL_INITIAL, MARKETPLACES_INJECT_SCRIPT_URL);
|
||||||
break;
|
break;
|
||||||
case 'updateItemClicked':
|
case 'updateItemClicked':
|
||||||
tablet.gotoWebScreen(message.upgradeUrl + "?edition=" + message.itemEdition + "&upgradeUrl=" + message.upgradeUrl,
|
tablet.gotoWebScreen(message.upgradeUrl + "?edition=" + message.itemEdition,
|
||||||
MARKETPLACES_INJECT_SCRIPT_URL);
|
MARKETPLACES_INJECT_SCRIPT_URL);
|
||||||
break;
|
break;
|
||||||
case 'passphrasePopup_cancelClicked':
|
case 'passphrasePopup_cancelClicked':
|
||||||
|
|
Loading…
Reference in a new issue