From 591891306366e683416b187207fa2b94bdc263a8 Mon Sep 17 00:00:00 2001 From: Leslie Linden Date: Mon, 5 Dec 2011 13:37:37 -0800 Subject: First pass at connecting to the new marketplace API --- indra/newview/llinventorybridge.cpp | 2 +- indra/newview/llmarketplacefunctions.cpp | 24 ++-- indra/newview/llmarketplacefunctions.h | 17 ++- indra/newview/llpanelmarketplaceoutbox.cpp | 158 ++++++++++++++++----- indra/newview/llpanelmarketplaceoutbox.h | 19 ++- indra/newview/llsidepanelinventory.cpp | 2 +- indra/newview/llviewermedia.cpp | 61 -------- .../newview/skins/default/xui/en/notifications.xml | 18 ++- .../skins/default/xui/en/sidepanel_inventory.xml | 4 +- 9 files changed, 170 insertions(+), 135 deletions(-) (limited to 'indra') diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp index 0eaa0a4627..017dabe2ad 100644 --- a/indra/newview/llinventorybridge.cpp +++ b/indra/newview/llinventorybridge.cpp @@ -71,7 +71,7 @@ #include "llwearablelist.h" // Marketplace outbox current disabled -#define ENABLE_MERCHANT_OUTBOX_CONTEXT_MENU 1 // keep in sync with ENABLE_INVENTORY_DISPLAY_OUTBOX, ENABLE_MERCHANT_OUTBOX_PANEL +#define ENABLE_MERCHANT_OUTBOX_CONTEXT_MENU 1 // keep in sync with ENABLE_MERCHANT_OUTBOX_PANEL typedef std::pair two_uuids_t; typedef std::list two_uuids_list_t; diff --git a/indra/newview/llmarketplacefunctions.cpp b/indra/newview/llmarketplacefunctions.cpp index 99b0389413..1c189f6ee2 100644 --- a/indra/newview/llmarketplacefunctions.cpp +++ b/indra/newview/llmarketplacefunctions.cpp @@ -50,8 +50,9 @@ std::string getMarketplaceBaseURL() } } - url += "api/1/users/"; + url += "api/1/"; url += gAgent.getID().getString(); + url += "/inventory"; return url; } @@ -60,29 +61,20 @@ std::string getMarketplaceURL_InventoryImport() { std::string url = getMarketplaceBaseURL(); - url += "/inventory_import"; - - return url; -} - -std::string getMarketplaceURL_UserStatus() -{ - std::string url = getMarketplaceBaseURL(); - - url += "/user_status"; + url += "/import"; return url; } -static bool gMarketplaceSyncEnabled = true; +static bool gMarketplaceImportEnabled = true; -bool getMarketplaceSyncEnabled() +bool getMarketplaceImportEnabled() { - return gMarketplaceSyncEnabled; + return gMarketplaceImportEnabled; } -void setMarketplaceSyncEnabled(bool syncEnabled) +void setMarketplaceImportEnabled(bool importEnabled) { - gMarketplaceSyncEnabled = syncEnabled; + gMarketplaceImportEnabled = importEnabled; } diff --git a/indra/newview/llmarketplacefunctions.h b/indra/newview/llmarketplacefunctions.h index e80e6a471c..fda2fbb935 100644 --- a/indra/newview/llmarketplacefunctions.h +++ b/indra/newview/llmarketplacefunctions.h @@ -30,11 +30,20 @@ std::string getMarketplaceURL_InventoryImport(); -std::string getMarketplaceURL_UserStatus(); - -bool getMarketplaceSyncEnabled(); -void setMarketplaceSyncEnabled(bool syncEnabled); +bool getMarketplaceImportEnabled(); +void setMarketplaceImportEnabled(bool syncEnabled); + +namespace MarketplaceErrorCodes +{ + enum eCodes + { + IMPORT_DONE = 200, + IMPORT_PROCESSING = 202, + IMPORT_DONE_WITH_ERRORS = 409, + IMPORT_JOB_FAILED = 410, + }; +} #endif // LL_LLMARKETPLACEFUNCTIONS_H diff --git a/indra/newview/llpanelmarketplaceoutbox.cpp b/indra/newview/llpanelmarketplaceoutbox.cpp index 0ad4d56051..3c8817c199 100644 --- a/indra/newview/llpanelmarketplaceoutbox.cpp +++ b/indra/newview/llpanelmarketplaceoutbox.cpp @@ -59,9 +59,12 @@ const LLPanelMarketplaceOutbox::Params& LLPanelMarketplaceOutbox::getDefaultPara LLPanelMarketplaceOutbox::LLPanelMarketplaceOutbox(const Params& p) : LLPanel(p) , mInventoryPanel(NULL) - , mSyncButton(NULL) - , mSyncIndicator(NULL) - , mSyncInProgress(false) + , mImportButton(NULL) + , mImportFrameTimer(0) + , mImportGetPending(false) + , mImportIndicator(NULL) + , mImportInProgress(false) + , mOutboxButton(NULL) { } @@ -81,11 +84,13 @@ BOOL LLPanelMarketplaceOutbox::postBuild() void LLPanelMarketplaceOutbox::handleLoginComplete() { - mSyncButton = getChild("outbox_sync_btn"); - mSyncButton->setCommitCallback(boost::bind(&LLPanelMarketplaceOutbox::onSyncButtonClicked, this)); - mSyncButton->setEnabled(getMarketplaceSyncEnabled() && !isOutboxEmpty()); + mImportButton = getChild("outbox_import_btn"); + mImportButton->setCommitCallback(boost::bind(&LLPanelMarketplaceOutbox::onImportButtonClicked, this)); + mImportButton->setEnabled(getMarketplaceImportEnabled() && !isOutboxEmpty()); - mSyncIndicator = getChild("outbox_sync_indicator"); + mImportIndicator = getChild("outbox_import_indicator"); + + mOutboxButton = getChild("outbox_btn"); } void LLPanelMarketplaceOutbox::onFocusReceived() @@ -164,9 +169,9 @@ bool LLPanelMarketplaceOutbox::isOutboxEmpty() const return (getTotalItemCount() == 0); } -bool LLPanelMarketplaceOutbox::isSyncInProgress() const +bool LLPanelMarketplaceOutbox::isImportInProgress() const { - return mSyncInProgress; + return mImportInProgress; } @@ -185,25 +190,55 @@ void timeDelay(LLCoros::self& self, LLPanelMarketplaceOutbox* outboxPanel) waitForEventOn(self, "mainloop"); } - outboxPanel->onSyncComplete(true, LLSD::emptyMap()); + outboxPanel->onImportPostComplete(MarketplaceErrorCodes::IMPORT_DONE, LLSD::emptyMap()); gTimeDelayDebugFunc = ""; } -class LLInventorySyncResponder : public LLHTTPClient::Responder +class LLInventoryImportPostResponder : public LLHTTPClient::Responder { public: - LLInventorySyncResponder(LLPanelMarketplaceOutbox * outboxPanel) + LLInventoryImportPostResponder(LLPanelMarketplaceOutbox * outboxPanel) : LLCurl::Responder() , mOutboxPanel(outboxPanel) { } - + void completed(U32 status, const std::string& reason, const LLSD& content) { - llinfos << "inventory_import complete status: " << status << ", reason: " << reason << llendl; + llinfos << "inventory/import post status: " << status << ", reason: " << reason << llendl; + + if (isGoodStatus(status)) + { + // Complete success + llinfos << "success" << llendl; + } + else + { + llwarns << "failed" << llendl; + } + + mOutboxPanel->onImportPostComplete(status, content); + } + +private: + LLPanelMarketplaceOutbox * mOutboxPanel; +}; +class LLInventoryImportGetResponder : public LLHTTPClient::Responder +{ +public: + LLInventoryImportGetResponder(LLPanelMarketplaceOutbox * outboxPanel) + : LLCurl::Responder() + , mOutboxPanel(outboxPanel) + { + } + + void completed(U32 status, const std::string& reason, const LLSD& content) + { + llinfos << "inventory/import get status: " << status << ", reason: " << reason << llendl; + if (isGoodStatus(status)) { // Complete success @@ -214,37 +249,67 @@ public: llwarns << "failed" << llendl; } - mOutboxPanel->onSyncComplete(isGoodStatus(status), content); + mOutboxPanel->onImportGetComplete(status, content); } private: LLPanelMarketplaceOutbox * mOutboxPanel; }; -void LLPanelMarketplaceOutbox::onSyncButtonClicked() +void LLPanelMarketplaceOutbox::onImportButtonClicked() { - // Get the sync animation going - mSyncInProgress = true; - updateSyncButtonStatus(); + // Get the import animation going + mImportInProgress = true; + mImportFrameTimer = 0; + + updateImportButtonStatus(); // Make the url for the inventory import request std::string url = getMarketplaceURL_InventoryImport(); - llinfos << "http get: " << url << llendl; - LLHTTPClient::get(url, new LLInventorySyncResponder(this), LLViewerMedia::getHeaders()); + llinfos << "http post: " << url << llendl; + LLHTTPClient::post(url, LLSD(), new LLInventoryImportPostResponder(this), LLViewerMedia::getHeaders()); // Set a timer (for testing only) //gTimeDelayDebugFunc = LLCoros::instance().launch("LLPanelMarketplaceOutbox timeDelay", boost::bind(&timeDelay, _1, this)); } -void LLPanelMarketplaceOutbox::onSyncComplete(bool goodStatus, const LLSD& content) +void LLPanelMarketplaceOutbox::onImportPostComplete(U32 status, const LLSD& content) { - mSyncInProgress = false; - updateSyncButtonStatus(); + llinfos << "onImportPostComplete status = " << status << llendl; + llinfos << "onImportPostComplete content = " << content.asString() << llendl; +} + +void LLPanelMarketplaceOutbox::onImportGetComplete(U32 status, const LLSD& content) +{ + mImportGetPending = false; + mImportInProgress = (status == MarketplaceErrorCodes::IMPORT_PROCESSING); + updateImportButtonStatus(); + + if (!mImportInProgress) + { + if (status == MarketplaceErrorCodes::IMPORT_DONE) + { + LLNotificationsUtil::add("OutboxImportComplete", LLSD::emptyMap(), LLSD::emptyMap()); + } + else if (status == MarketplaceErrorCodes::IMPORT_DONE_WITH_ERRORS) + { + LLNotificationsUtil::add("OutboxImportHadErrors", LLSD::emptyMap(), LLSD::emptyMap()); + } + else + { + llassert(status == MarketplaceErrorCodes::IMPORT_JOB_FAILED); + LLNotificationsUtil::add("OutboxImportFailed", LLSD::emptyMap(), LLSD::emptyMap()); + } + } + + return; + + const LLSD& errors_list = content["errors"]; - if (goodStatus && (errors_list.size() == 0)) + if (errors_list.size() == 0) { LLNotificationsUtil::add("OutboxUploadComplete", LLSD::emptyMap(), LLSD::emptyMap()); } @@ -287,23 +352,23 @@ void LLPanelMarketplaceOutbox::onSyncComplete(bool goodStatus, const LLSD& conte } } -void LLPanelMarketplaceOutbox::updateSyncButtonStatus() +void LLPanelMarketplaceOutbox::updateImportButtonStatus() { - if (isSyncInProgress()) + if (isImportInProgress()) { - mSyncButton->setVisible(false); + mImportButton->setVisible(false); - mSyncIndicator->setVisible(true); - mSyncIndicator->reset(); - mSyncIndicator->start(); + mImportIndicator->setVisible(true); + mImportIndicator->reset(); + mImportIndicator->start(); } else { - mSyncIndicator->stop(); - mSyncIndicator->setVisible(false); + mImportIndicator->stop(); + mImportIndicator->setVisible(false); - mSyncButton->setVisible(true); - mSyncButton->setEnabled(getMarketplaceSyncEnabled() && !isOutboxEmpty()); + mImportButton->setVisible(true); + mImportButton->setEnabled(getMarketplaceImportEnabled() && !isOutboxEmpty()); } } @@ -335,17 +400,32 @@ void LLPanelMarketplaceOutbox::draw() LLStringUtil::format_map_t args; args["[NUM]"] = item_count_str; - getChild("outbox_btn")->setLabel(getString("OutboxLabelWithArg", args)); + mOutboxButton->setLabel(getString("OutboxLabelWithArg", args)); } else { - getChild("outbox_btn")->setLabel(getString("OutboxLabelNoArg")); + mOutboxButton->setLabel(getString("OutboxLabelNoArg")); } - if (!isSyncInProgress()) + if (!isImportInProgress()) { - mSyncButton->setEnabled(getMarketplaceSyncEnabled() && not_empty); + mImportButton->setEnabled(getMarketplaceImportEnabled() && not_empty); } + else + { + ++mImportFrameTimer; + + if ((mImportFrameTimer % 50 == 0) && !mImportGetPending) + { + mImportGetPending = true; + + std::string url = getMarketplaceURL_InventoryImport(); + + llinfos << "http get: " << url << llendl; + LLHTTPClient::get(url, new LLInventoryImportGetResponder(this), LLViewerMedia::getHeaders()); + } + } + LLPanel::draw(); } diff --git a/indra/newview/llpanelmarketplaceoutbox.h b/indra/newview/llpanelmarketplaceoutbox.h index c6b4a5abe2..a776ee0919 100644 --- a/indra/newview/llpanelmarketplaceoutbox.h +++ b/indra/newview/llpanelmarketplaceoutbox.h @@ -59,9 +59,10 @@ public: U32 getTotalItemCount() const; bool isOutboxEmpty() const; - bool isSyncInProgress() const; + bool isImportInProgress() const; - void onSyncComplete(bool goodStatus, const LLSD& content); + void onImportPostComplete(U32 status, const LLSD& content); + void onImportGetComplete(U32 status, const LLSD& content); /*virtual*/ BOOL handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, EDragAndDropType cargo_type, @@ -70,8 +71,8 @@ public: std::string& tooltip_msg); protected: - void onSyncButtonClicked(); - void updateSyncButtonStatus(); + void onImportButtonClicked(); + void updateImportButtonStatus(); void handleLoginComplete(); void onFocusReceived(); @@ -80,9 +81,13 @@ protected: private: LLInventoryPanel * mInventoryPanel; - LLButton * mSyncButton; - LLLoadingIndicator * mSyncIndicator; - bool mSyncInProgress; + LLButton * mImportButton; + U32 mImportFrameTimer; + bool mImportGetPending; + LLLoadingIndicator * mImportIndicator; + bool mImportInProgress; + + LLButton * mOutboxButton; }; diff --git a/indra/newview/llsidepanelinventory.cpp b/indra/newview/llsidepanelinventory.cpp index d556b8523e..19a81b93bf 100644 --- a/indra/newview/llsidepanelinventory.cpp +++ b/indra/newview/llsidepanelinventory.cpp @@ -69,7 +69,7 @@ static LLRegisterPanelClassWrapper t_inventory("sidepanel_ #define AUTO_EXPAND_INBOX 0 // Temporarily disabling the outbox until we straighten out the API -#define ENABLE_MERCHANT_OUTBOX_PANEL 1 // keep in sync with ENABLE_INVENTORY_DISPLAY_OUTBOX, ENABLE_MERCHANT_OUTBOX_CONTEXT_MENU +#define ENABLE_MERCHANT_OUTBOX_PANEL 1 // keep in sync with ENABLE_MERCHANT_OUTBOX_CONTEXT_MENU static const char * const INBOX_BUTTON_NAME = "inbox_btn"; static const char * const OUTBOX_BUTTON_NAME = "outbox_btn"; diff --git a/indra/newview/llviewermedia.cpp b/indra/newview/llviewermedia.cpp index a5bd0223cc..02d8036666 100644 --- a/indra/newview/llviewermedia.cpp +++ b/indra/newview/llviewermedia.cpp @@ -1386,64 +1386,6 @@ void LLViewerMedia::removeCookie(const std::string &name, const std::string &dom } -// This is defined in two files but I don't want to create a dependence between this and llsidepanelinventory -// just to be able to temporarily disable the outbox. -#define ENABLE_INVENTORY_DISPLAY_OUTBOX 1 // keep in sync with ENABLE_MERCHANT_OUTBOX_PANEL, ENABLE_MERCHANT_OUTBOX_CONTEXT_MENU - -class LLInventoryUserStatusResponder : public LLHTTPClient::Responder -{ -public: - LLInventoryUserStatusResponder() - : LLCurl::Responder() - { - } - - void completed(U32 status, const std::string& reason, const LLSD& content) - { - if (isGoodStatus(status)) - { - std::string merchantStatus = content[gAgent.getID().getString()].asString(); - llinfos << "Marketplace merchant status: " << merchantStatus << llendl; - - // Save the merchant status before turning on the display - gSavedSettings.setString("InventoryMarketplaceUserStatus", merchantStatus); - - // Complete success - gSavedSettings.setBOOL("InventoryDisplayInbox", true); - -#if ENABLE_INVENTORY_DISPLAY_OUTBOX - gSavedSettings.setBOOL("InventoryDisplayOutbox", true); -#endif - - setMarketplaceSyncEnabled(true); - } - else if (status == 401) - { - // API is available for use but OpenID authorization failed - gSavedSettings.setBOOL("InventoryDisplayInbox", true); - - setMarketplaceSyncEnabled(false); - } - else - { - setMarketplaceSyncEnabled(false); - - // API in unavailable - llinfos << "Marketplace API is unavailable -- Inbox may be disabled, status = " << status << ", reason = " << reason << llendl; - } - } -}; - - -void doOnetimeEarlyHTTPRequests() -{ - std::string url = getMarketplaceURL_UserStatus(); - - llinfos << "http get: " << url << llendl; - LLHTTPClient::get(url, new LLInventoryUserStatusResponder(), LLViewerMedia::getHeaders()); -} - - LLSD LLViewerMedia::getHeaders() { LLSD headers = LLSD::emptyMap(); @@ -1502,9 +1444,6 @@ void LLViewerMedia::setOpenIDCookie() LLHTTPClient::get(profile_url, new LLViewerMediaWebProfileResponder(raw_profile_url.getAuthority()), headers); - - // FUI: No longer perform the user_status query - //doOnetimeEarlyHTTPRequests(); } } diff --git a/indra/newview/skins/default/xui/en/notifications.xml b/indra/newview/skins/default/xui/en/notifications.xml index d925bf8f96..46a6da2450 100644 --- a/indra/newview/skins/default/xui/en/notifications.xml +++ b/indra/newview/skins/default/xui/en/notifications.xml @@ -213,9 +213,9 @@ Save changes to current clothing/body part? -Marketplace upload complete. +Marketplace import complete. @@ -223,14 +223,24 @@ Marketplace upload complete. -Marketplace upload completed with errors! Please correct the problems in your outbox and retry. Thanks. +Marketplace import completed with errors! Please correct the problems in your outbox and retry. Thanks. + +Marketplace import failed! Please try again later. Thanks. + + +