From 5af39ea28be1a76ec0c3042a0bf34e7d64835c18 Mon Sep 17 00:00:00 2001 From: Leslie Linden Date: Fri, 16 Sep 2011 11:46:37 -0700 Subject: EXP-1169 FIX -- No synch error icon given on Outbox on Agni where API does not exist * Moved marketplace URL related functions into a new file llmarketplacefunctions.cpp/h. This will the future home of more marketplace-related functions. * Disabled sync button when the marketplace API is unavailable. --- indra/newview/llpanelmarketplaceoutbox.cpp | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) (limited to 'indra/newview/llpanelmarketplaceoutbox.cpp') diff --git a/indra/newview/llpanelmarketplaceoutbox.cpp b/indra/newview/llpanelmarketplaceoutbox.cpp index 73fb92ff72..2764527c44 100644 --- a/indra/newview/llpanelmarketplaceoutbox.cpp +++ b/indra/newview/llpanelmarketplaceoutbox.cpp @@ -35,6 +35,7 @@ #include "lleventcoro.h" #include "llinventorypanel.h" #include "llloadingindicator.h" +#include "llmarketplacefunctions.h" #include "llnotificationsutil.h" #include "llpanelmarketplaceinbox.h" #include "llsdutil.h" @@ -82,7 +83,7 @@ void LLPanelMarketplaceOutbox::handleLoginComplete() { mSyncButton = getChild("outbox_sync_btn"); mSyncButton->setCommitCallback(boost::bind(&LLPanelMarketplaceOutbox::onSyncButtonClicked, this)); - mSyncButton->setEnabled(!isOutboxEmpty()); + mSyncButton->setEnabled(getMarketplaceSyncEnabled() && !isOutboxEmpty()); mSyncIndicator = getChild("outbox_sync_indicator"); } @@ -223,20 +224,7 @@ void LLPanelMarketplaceOutbox::onSyncButtonClicked() updateSyncButtonStatus(); // Make the url for the inventory import request - std::string url = "https://marketplace.secondlife.com/"; - - if (!LLGridManager::getInstance()->isInProductionGrid()) - { - std::string gridLabel = LLGridManager::getInstance()->getGridLabel(); - url = llformat("https://marketplace.%s.lindenlab.com/", utf8str_tolower(gridLabel).c_str()); - - // TEMP for Jim's pdp - //url = "http://pdp24.lindenlab.com:3000/"; - } - - url += "api/1/users/"; - url += gAgent.getID().getString(); - url += "/inventory_import"; + std::string url = getMarketplaceURL_InventoryImport(); llinfos << "http get: " << url << llendl; LLHTTPClient::get(url, new LLInventorySyncResponder(this), LLViewerMedia::getHeaders()); @@ -311,7 +299,7 @@ void LLPanelMarketplaceOutbox::updateSyncButtonStatus() mSyncIndicator->setVisible(false); mSyncButton->setVisible(true); - mSyncButton->setEnabled(!isOutboxEmpty()); + mSyncButton->setEnabled(getMarketplaceSyncEnabled() && !isOutboxEmpty()); } } @@ -352,7 +340,7 @@ void LLPanelMarketplaceOutbox::draw() if (!isSyncInProgress()) { - mSyncButton->setEnabled(not_empty); + mSyncButton->setEnabled(getMarketplaceSyncEnabled() && not_empty); } LLPanel::draw(); -- cgit v1.2.3 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/llpanelmarketplaceoutbox.cpp | 158 ++++++++++++++++++++++------- 1 file changed, 119 insertions(+), 39 deletions(-) (limited to 'indra/newview/llpanelmarketplaceoutbox.cpp') 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(); } -- cgit v1.2.3 From 3236cbd585860f76a14c4837c70cb5823a4fd7d5 Mon Sep 17 00:00:00 2001 From: Leslie Linden Date: Mon, 5 Dec 2011 14:23:49 -0800 Subject: Windows build fix --- indra/newview/llpanelmarketplaceoutbox.cpp | 89 +++++++++++++++--------------- 1 file changed, 43 insertions(+), 46 deletions(-) (limited to 'indra/newview/llpanelmarketplaceoutbox.cpp') diff --git a/indra/newview/llpanelmarketplaceoutbox.cpp b/indra/newview/llpanelmarketplaceoutbox.cpp index 3c8817c199..6a2bf58701 100644 --- a/indra/newview/llpanelmarketplaceoutbox.cpp +++ b/indra/newview/llpanelmarketplaceoutbox.cpp @@ -303,53 +303,50 @@ void LLPanelMarketplaceOutbox::onImportGetComplete(U32 status, const LLSD& conte } } - return; - - - - const LLSD& errors_list = content["errors"]; - - if (errors_list.size() == 0) - { - LLNotificationsUtil::add("OutboxUploadComplete", LLSD::emptyMap(), LLSD::emptyMap()); - } - else - { - LLNotificationsUtil::add("OutboxUploadHadErrors", LLSD::emptyMap(), LLSD::emptyMap()); - } - - llinfos << "Marketplace upload llsd:" << llendl; - llinfos << ll_pretty_print_sd(content) << llendl; - llinfos << llendl; - const LLSD& imported_list = content["imported"]; - LLSD::array_const_iterator it = imported_list.beginArray(); - for ( ; it != imported_list.endArray(); ++it) - { - LLUUID imported_folder = (*it).asUUID(); - llinfos << "Successfully uploaded folder " << imported_folder.asString() << " to marketplace." << llendl; - } - - for (it = errors_list.beginArray(); it != errors_list.endArray(); ++it) - { - const LLSD& item_error_map = (*it); - - LLUUID error_folder = item_error_map["folder_id"].asUUID(); - const std::string& error_string = item_error_map["identifier"].asString(); - LLUUID error_item = item_error_map["item_id"].asUUID(); - const std::string& error_item_name = item_error_map["item_name"].asString(); - const std::string& error_message = item_error_map["message"].asString(); - - llinfos << "Error item " << error_folder.asString() << ", " << error_string << ", " - << error_item.asString() << ", " << error_item_name << ", " << error_message << llendl; - - LLFolderViewFolder * item_folder = mInventoryPanel->getRootFolder()->getFolderByID(error_folder); - LLOutboxFolderViewFolder * outbox_item_folder = dynamic_cast(item_folder); - - llassert(outbox_item_folder); - - outbox_item_folder->setErrorString(error_string); - } + //const LLSD& errors_list = content["errors"]; + + //if (errors_list.size() == 0) + //{ + // LLNotificationsUtil::add("OutboxUploadComplete", LLSD::emptyMap(), LLSD::emptyMap()); + //} + //else + //{ + // LLNotificationsUtil::add("OutboxUploadHadErrors", LLSD::emptyMap(), LLSD::emptyMap()); + //} + + //llinfos << "Marketplace upload llsd:" << llendl; + //llinfos << ll_pretty_print_sd(content) << llendl; + //llinfos << llendl; + + //const LLSD& imported_list = content["imported"]; + //LLSD::array_const_iterator it = imported_list.beginArray(); + //for ( ; it != imported_list.endArray(); ++it) + //{ + // LLUUID imported_folder = (*it).asUUID(); + // llinfos << "Successfully uploaded folder " << imported_folder.asString() << " to marketplace." << llendl; + //} + + //for (it = errors_list.beginArray(); it != errors_list.endArray(); ++it) + //{ + // const LLSD& item_error_map = (*it); + + // LLUUID error_folder = item_error_map["folder_id"].asUUID(); + // const std::string& error_string = item_error_map["identifier"].asString(); + // LLUUID error_item = item_error_map["item_id"].asUUID(); + // const std::string& error_item_name = item_error_map["item_name"].asString(); + // const std::string& error_message = item_error_map["message"].asString(); + + // llinfos << "Error item " << error_folder.asString() << ", " << error_string << ", " + // << error_item.asString() << ", " << error_item_name << ", " << error_message << llendl; + // + // LLFolderViewFolder * item_folder = mInventoryPanel->getRootFolder()->getFolderByID(error_folder); + // LLOutboxFolderViewFolder * outbox_item_folder = dynamic_cast(item_folder); + + // llassert(outbox_item_folder); + + // outbox_item_folder->setErrorString(error_string); + //} } void LLPanelMarketplaceOutbox::updateImportButtonStatus() -- cgit v1.2.3 From a255fadfab359931d591c6a874abbea5fcf13526 Mon Sep 17 00:00:00 2001 From: Leslie Linden Date: Tue, 6 Dec 2011 11:19:58 -0800 Subject: Updated to trigger a 'get' to establish marketplace session cookie when outbox panel created. --- indra/newview/llpanelmarketplaceoutbox.cpp | 194 ++++++++++++++++++----------- 1 file changed, 120 insertions(+), 74 deletions(-) (limited to 'indra/newview/llpanelmarketplaceoutbox.cpp') diff --git a/indra/newview/llpanelmarketplaceoutbox.cpp b/indra/newview/llpanelmarketplaceoutbox.cpp index 6a2bf58701..99d744891a 100644 --- a/indra/newview/llpanelmarketplaceoutbox.cpp +++ b/indra/newview/llpanelmarketplaceoutbox.cpp @@ -140,6 +140,11 @@ LLInventoryPanel * LLPanelMarketplaceOutbox::setupInventoryPanel() // Hide the placeholder text outbox_inventory_placeholder->setVisible(FALSE); + // Establish marketplace cookies for http client + establishMarketplaceSessionCookie(); + + updateImportButtonStatus(); + return mInventoryPanel; } @@ -195,6 +200,28 @@ void timeDelay(LLCoros::self& self, LLPanelMarketplaceOutbox* outboxPanel) gTimeDelayDebugFunc = ""; } +std::string gImportPollingFunc = ""; + +void importPoll(LLCoros::self& self, LLPanelMarketplaceOutbox* outboxPanel) +{ + waitForEventOn(self, "mainloop"); + + while (outboxPanel->isImportInProgress()) + { + LLTimer delayTimer; + delayTimer.reset(); + delayTimer.setTimerExpirySec(5.0f); + + while (!delayTimer.hasExpired()) + { + waitForEventOn(self, "mainloop"); + } + + //outboxPanel-> + } + + gImportPollingFunc = ""; +} class LLInventoryImportPostResponder : public LLHTTPClient::Responder { @@ -207,16 +234,16 @@ public: void completed(U32 status, const std::string& reason, const LLSD& content) { - llinfos << "inventory/import post status: " << status << ", reason: " << reason << llendl; + llinfos << "*** Marketplace *** " << "inventory/import post status: " << status << ", reason: " << reason << llendl; if (isGoodStatus(status)) { // Complete success - llinfos << "success" << llendl; + llinfos << "*** Marketplace *** " << "success" << llendl; } else { - llwarns << "failed" << llendl; + llwarns << "*** Marketplace *** " << "failed" << llendl; } mOutboxPanel->onImportPostComplete(status, content); @@ -229,64 +256,119 @@ private: class LLInventoryImportGetResponder : public LLHTTPClient::Responder { public: - LLInventoryImportGetResponder(LLPanelMarketplaceOutbox * outboxPanel) + LLInventoryImportGetResponder(LLPanelMarketplaceOutbox * outboxPanel, bool ignoreResults) : LLCurl::Responder() + , mIgnoreResults(ignoreResults) , mOutboxPanel(outboxPanel) { } void completed(U32 status, const std::string& reason, const LLSD& content) { - llinfos << "inventory/import get status: " << status << ", reason: " << reason << llendl; + llinfos << "*** Marketplace *** " << "inventory/import get status: " << status << ", reason: " << reason << llendl; if (isGoodStatus(status)) { // Complete success - llinfos << "success" << llendl; + llinfos << "*** Marketplace *** " << "success" << llendl; } else { - llwarns << "failed" << llendl; + llwarns << "*** Marketplace *** " << "failed" << llendl; } - mOutboxPanel->onImportGetComplete(status, content); + mOutboxPanel->onImportGetComplete(status, content, mIgnoreResults); } private: + bool mIgnoreResults; LLPanelMarketplaceOutbox * mOutboxPanel; }; -void LLPanelMarketplaceOutbox::onImportButtonClicked() +void LLPanelMarketplaceOutbox::importPostTrigger() { - // 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 post: " << url << llendl; - LLHTTPClient::post(url, LLSD(), new LLInventoryImportPostResponder(this), LLViewerMedia::getHeaders()); - + + LLSD headers = LLViewerMedia::getHeaders(); + headers["Connection"] = "Keep-Alive"; + + llinfos << "*** Marketplace *** " << "http post: " << url << llendl; + llinfos << "*** Marketplace *** " << "headers: " << ll_pretty_print_sd(headers) << llendl; + + LLHTTPClient::post(url, LLSD(), new LLInventoryImportPostResponder(this), headers); + // Set a timer (for testing only) //gTimeDelayDebugFunc = LLCoros::instance().launch("LLPanelMarketplaceOutbox timeDelay", boost::bind(&timeDelay, _1, this)); } +void LLPanelMarketplaceOutbox::importGetTrigger() +{ + mImportGetPending = true; + + std::string url = getMarketplaceURL_InventoryImport(); + LLSD headers = LLViewerMedia::getHeaders(); + + llinfos << "*** Marketplace *** " << "http get: " << url << llendl; + llinfos << "*** Marketplace *** " << "headers: " << ll_pretty_print_sd(headers) << llendl; + + const bool do_not_ignore_results = false; + + LLHTTPClient::get(url, new LLInventoryImportGetResponder(this, do_not_ignore_results), headers); +} + +void LLPanelMarketplaceOutbox::establishMarketplaceSessionCookie() +{ + mImportInProgress = true; + mImportGetPending = true; + + std::string url = getMarketplaceURL_InventoryImport(); + LLSD headers = LLViewerMedia::getHeaders(); + + const bool ignore_results = true; + + LLHTTPClient::get(url, new LLInventoryImportGetResponder(this, ignore_results), headers); +} + void LLPanelMarketplaceOutbox::onImportPostComplete(U32 status, const LLSD& content) { - llinfos << "onImportPostComplete status = " << status << llendl; - llinfos << "onImportPostComplete content = " << content.asString() << llendl; + llinfos << "*** Marketplace *** " << "status = " << status << llendl; + llinfos << "*** Marketplace *** " << "content = " << ll_pretty_print_sd(content) << llendl; + + mImportInProgress = (status == MarketplaceErrorCodes::IMPORT_DONE); + updateImportButtonStatus(); + + if (!mImportInProgress) + { + char status_string[16]; + sprintf(status_string, "%d", status); + + LLSD subs; + subs["ERROR_CODE"] = status_string; + + LLNotificationsUtil::add("OutboxImportFailed", subs, LLSD::emptyMap()); + } + + // The POST request returns the IMPORT_DONE code on success + //if (status == MarketplaceErrorCodes::IMPORT_DONE) + //{ + // gImportPollingFunc = LLCoros::instance().launch("LLPanelMarketplaceOutbox importPoll", boost::bind(&importPoll, _1, this)); + //} } -void LLPanelMarketplaceOutbox::onImportGetComplete(U32 status, const LLSD& content) +void LLPanelMarketplaceOutbox::onImportGetComplete(U32 status, const LLSD& content, bool ignoreResults) { + llinfos << "*** Marketplace *** " << "status = " << status << llendl; + llinfos << "*** Marketplace *** " << "content = " << ll_pretty_print_sd(content) << llendl; + mImportGetPending = false; mImportInProgress = (status == MarketplaceErrorCodes::IMPORT_PROCESSING); updateImportButtonStatus(); - if (!mImportInProgress) + if (!mImportInProgress && !ignoreResults) { if (status == MarketplaceErrorCodes::IMPORT_DONE) { @@ -298,55 +380,16 @@ void LLPanelMarketplaceOutbox::onImportGetComplete(U32 status, const LLSD& conte } else { - llassert(status == MarketplaceErrorCodes::IMPORT_JOB_FAILED); + char status_string[16]; + sprintf(status_string, "%d", status); + + LLSD subs; + subs["ERROR_CODE"] = status_string; + + //llassert(status == MarketplaceErrorCodes::IMPORT_JOB_FAILED); LLNotificationsUtil::add("OutboxImportFailed", LLSD::emptyMap(), LLSD::emptyMap()); } } - - - //const LLSD& errors_list = content["errors"]; - - //if (errors_list.size() == 0) - //{ - // LLNotificationsUtil::add("OutboxUploadComplete", LLSD::emptyMap(), LLSD::emptyMap()); - //} - //else - //{ - // LLNotificationsUtil::add("OutboxUploadHadErrors", LLSD::emptyMap(), LLSD::emptyMap()); - //} - - //llinfos << "Marketplace upload llsd:" << llendl; - //llinfos << ll_pretty_print_sd(content) << llendl; - //llinfos << llendl; - - //const LLSD& imported_list = content["imported"]; - //LLSD::array_const_iterator it = imported_list.beginArray(); - //for ( ; it != imported_list.endArray(); ++it) - //{ - // LLUUID imported_folder = (*it).asUUID(); - // llinfos << "Successfully uploaded folder " << imported_folder.asString() << " to marketplace." << llendl; - //} - - //for (it = errors_list.beginArray(); it != errors_list.endArray(); ++it) - //{ - // const LLSD& item_error_map = (*it); - - // LLUUID error_folder = item_error_map["folder_id"].asUUID(); - // const std::string& error_string = item_error_map["identifier"].asString(); - // LLUUID error_item = item_error_map["item_id"].asUUID(); - // const std::string& error_item_name = item_error_map["item_name"].asString(); - // const std::string& error_message = item_error_map["message"].asString(); - - // llinfos << "Error item " << error_folder.asString() << ", " << error_string << ", " - // << error_item.asString() << ", " << error_item_name << ", " << error_message << llendl; - // - // LLFolderViewFolder * item_folder = mInventoryPanel->getRootFolder()->getFolderByID(error_folder); - // LLOutboxFolderViewFolder * outbox_item_folder = dynamic_cast(item_folder); - - // llassert(outbox_item_folder); - - // outbox_item_folder->setErrorString(error_string); - //} } void LLPanelMarketplaceOutbox::updateImportButtonStatus() @@ -380,12 +423,21 @@ U32 LLPanelMarketplaceOutbox::getTotalItemCount() const if (outbox_folder) { item_count += outbox_folder->getFoldersCount(); + item_count += outbox_folder->getItemsCount(); } } return item_count; } +void LLPanelMarketplaceOutbox::onImportButtonClicked() +{ + importPostTrigger(); + + // Get the import animation going + updateImportButtonStatus(); +} + void LLPanelMarketplaceOutbox::draw() { const U32 item_count = getTotalItemCount(); @@ -414,15 +466,9 @@ void LLPanelMarketplaceOutbox::draw() 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()); + importGetTrigger(); } } - LLPanel::draw(); } -- cgit v1.2.3 From 40f9de414fbd5755b7c040f786030157cf083771 Mon Sep 17 00:00:00 2001 From: Leslie Linden Date: Tue, 6 Dec 2011 11:45:21 -0800 Subject: Added code to set up the marketplace session cookie and use it for subsequent posts and gets to the inventory import API --- indra/newview/llpanelmarketplaceoutbox.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'indra/newview/llpanelmarketplaceoutbox.cpp') diff --git a/indra/newview/llpanelmarketplaceoutbox.cpp b/indra/newview/llpanelmarketplaceoutbox.cpp index 99d744891a..d4b0bead4c 100644 --- a/indra/newview/llpanelmarketplaceoutbox.cpp +++ b/indra/newview/llpanelmarketplaceoutbox.cpp @@ -50,6 +50,8 @@ static LLRegisterPanelClassWrapper t_panel_marketplace_outbox("panel_marketplace_outbox"); +static std::string sMarketplaceCookie; + const LLPanelMarketplaceOutbox::Params& LLPanelMarketplaceOutbox::getDefaultParams() { return LLUICtrlFactory::getDefaultParams(); @@ -263,6 +265,15 @@ public: { } + void completedHeader(U32 status, const std::string& reason, const LLSD& content) + { + std::string cookie = content["set-cookie"].asString(); + + llinfos << "*** Marketplace *** " << "inventory/import headers set-cookie: " << cookie << llendl; + + sMarketplaceCookie = cookie; + } + void completed(U32 status, const std::string& reason, const LLSD& content) { llinfos << "*** Marketplace *** " << "inventory/import get status: " << status << ", reason: " << reason << llendl; @@ -295,6 +306,7 @@ void LLPanelMarketplaceOutbox::importPostTrigger() LLSD headers = LLViewerMedia::getHeaders(); headers["Connection"] = "Keep-Alive"; + headers["Cookie"] = sMarketplaceCookie; llinfos << "*** Marketplace *** " << "http post: " << url << llendl; llinfos << "*** Marketplace *** " << "headers: " << ll_pretty_print_sd(headers) << llendl; @@ -311,6 +323,7 @@ void LLPanelMarketplaceOutbox::importGetTrigger() std::string url = getMarketplaceURL_InventoryImport(); LLSD headers = LLViewerMedia::getHeaders(); + headers["Cookie"] = sMarketplaceCookie; llinfos << "*** Marketplace *** " << "http get: " << url << llendl; llinfos << "*** Marketplace *** " << "headers: " << ll_pretty_print_sd(headers) << llendl; -- cgit v1.2.3 From 83cc0becf859275a810da4ce0ccb0d7f8147d614 Mon Sep 17 00:00:00 2001 From: Leslie Linden Date: Tue, 6 Dec 2011 11:51:09 -0800 Subject: Turning off marketplace logging verbosity by default --- indra/newview/llpanelmarketplaceoutbox.cpp | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'indra/newview/llpanelmarketplaceoutbox.cpp') diff --git a/indra/newview/llpanelmarketplaceoutbox.cpp b/indra/newview/llpanelmarketplaceoutbox.cpp index d4b0bead4c..d7e4ed8bec 100644 --- a/indra/newview/llpanelmarketplaceoutbox.cpp +++ b/indra/newview/llpanelmarketplaceoutbox.cpp @@ -48,9 +48,14 @@ #include "llfolderview.h" #include "llinventoryfunctions.h" + +// Turn this on to get a bunch of console output for marketplace API calls, headers and status +#define DEBUG_MARKETPLACE_HTTP_API 0 + + static LLRegisterPanelClassWrapper t_panel_marketplace_outbox("panel_marketplace_outbox"); -static std::string sMarketplaceCookie; +static std::string sMarketplaceCookie = ""; const LLPanelMarketplaceOutbox::Params& LLPanelMarketplaceOutbox::getDefaultParams() { @@ -236,6 +241,7 @@ public: void completed(U32 status, const std::string& reason, const LLSD& content) { +#if DEBUG_MARKETPLACE_HTTP_API llinfos << "*** Marketplace *** " << "inventory/import post status: " << status << ", reason: " << reason << llendl; if (isGoodStatus(status)) @@ -247,6 +253,7 @@ public: { llwarns << "*** Marketplace *** " << "failed" << llendl; } +#endif // DEBUG_MARKETPLACE_HTTP_API mOutboxPanel->onImportPostComplete(status, content); } @@ -269,13 +276,16 @@ public: { std::string cookie = content["set-cookie"].asString(); +#if DEBUG_MARKETPLACE_HTTP_API llinfos << "*** Marketplace *** " << "inventory/import headers set-cookie: " << cookie << llendl; +#endif // DEBUG_MARKETPLACE_HTTP_API sMarketplaceCookie = cookie; } void completed(U32 status, const std::string& reason, const LLSD& content) { +#if DEBUG_MARKETPLACE_HTTP_API llinfos << "*** Marketplace *** " << "inventory/import get status: " << status << ", reason: " << reason << llendl; if (isGoodStatus(status)) @@ -287,6 +297,7 @@ public: { llwarns << "*** Marketplace *** " << "failed" << llendl; } +#endif // DEBUG_MARKETPLACE_HTTP_API mOutboxPanel->onImportGetComplete(status, content, mIgnoreResults); } @@ -308,8 +319,10 @@ void LLPanelMarketplaceOutbox::importPostTrigger() headers["Connection"] = "Keep-Alive"; headers["Cookie"] = sMarketplaceCookie; +#if DEBUG_MARKETPLACE_HTTP_API llinfos << "*** Marketplace *** " << "http post: " << url << llendl; llinfos << "*** Marketplace *** " << "headers: " << ll_pretty_print_sd(headers) << llendl; +#endif // DEBUG_MARKETPLACE_HTTP_API LLHTTPClient::post(url, LLSD(), new LLInventoryImportPostResponder(this), headers); @@ -325,8 +338,10 @@ void LLPanelMarketplaceOutbox::importGetTrigger() LLSD headers = LLViewerMedia::getHeaders(); headers["Cookie"] = sMarketplaceCookie; +#if DEBUG_MARKETPLACE_HTTP_API llinfos << "*** Marketplace *** " << "http get: " << url << llendl; llinfos << "*** Marketplace *** " << "headers: " << ll_pretty_print_sd(headers) << llendl; +#endif // DEBUG_MARKETPLACE_HTTP_API const bool do_not_ignore_results = false; @@ -348,8 +363,10 @@ void LLPanelMarketplaceOutbox::establishMarketplaceSessionCookie() void LLPanelMarketplaceOutbox::onImportPostComplete(U32 status, const LLSD& content) { +#if DEBUG_MARKETPLACE_HTTP_API llinfos << "*** Marketplace *** " << "status = " << status << llendl; llinfos << "*** Marketplace *** " << "content = " << ll_pretty_print_sd(content) << llendl; +#endif // DEBUG_MARKETPLACE_HTTP_API mImportInProgress = (status == MarketplaceErrorCodes::IMPORT_DONE); updateImportButtonStatus(); @@ -374,8 +391,10 @@ void LLPanelMarketplaceOutbox::onImportPostComplete(U32 status, const LLSD& cont void LLPanelMarketplaceOutbox::onImportGetComplete(U32 status, const LLSD& content, bool ignoreResults) { +#if DEBUG_MARKETPLACE_HTTP_API llinfos << "*** Marketplace *** " << "status = " << status << llendl; llinfos << "*** Marketplace *** " << "content = " << ll_pretty_print_sd(content) << llendl; +#endif // DEBUG_MARKETPLACE_HTTP_API mImportGetPending = false; mImportInProgress = (status == MarketplaceErrorCodes::IMPORT_PROCESSING); -- cgit v1.2.3 From 35020db3a9310742c9759673e3aa1bbb1d7aa02f Mon Sep 17 00:00:00 2001 From: Leslie Linden Date: Wed, 7 Dec 2011 15:04:39 -0800 Subject: Refactored marketplace inventory import HTTP requests and surrounding support to remove it from the UI panel code. --- indra/newview/llpanelmarketplaceoutbox.cpp | 304 ++++------------------------- 1 file changed, 36 insertions(+), 268 deletions(-) (limited to 'indra/newview/llpanelmarketplaceoutbox.cpp') diff --git a/indra/newview/llpanelmarketplaceoutbox.cpp b/indra/newview/llpanelmarketplaceoutbox.cpp index d7e4ed8bec..e3af7fd906 100644 --- a/indra/newview/llpanelmarketplaceoutbox.cpp +++ b/indra/newview/llpanelmarketplaceoutbox.cpp @@ -55,8 +55,6 @@ static LLRegisterPanelClassWrapper t_panel_marketplace_outbox("panel_marketplace_outbox"); -static std::string sMarketplaceCookie = ""; - const LLPanelMarketplaceOutbox::Params& LLPanelMarketplaceOutbox::getDefaultParams() { return LLUICtrlFactory::getDefaultParams(); @@ -67,10 +65,7 @@ LLPanelMarketplaceOutbox::LLPanelMarketplaceOutbox(const Params& p) : LLPanel(p) , mInventoryPanel(NULL) , mImportButton(NULL) - , mImportFrameTimer(0) - , mImportGetPending(false) , mImportIndicator(NULL) - , mImportInProgress(false) , mOutboxButton(NULL) { } @@ -93,7 +88,7 @@ void LLPanelMarketplaceOutbox::handleLoginComplete() { mImportButton = getChild("outbox_import_btn"); mImportButton->setCommitCallback(boost::bind(&LLPanelMarketplaceOutbox::onImportButtonClicked, this)); - mImportButton->setEnabled(getMarketplaceImportEnabled() && !isOutboxEmpty()); + mImportButton->setEnabled(!isOutboxEmpty()); mImportIndicator = getChild("outbox_import_indicator"); @@ -147,286 +142,73 @@ LLInventoryPanel * LLPanelMarketplaceOutbox::setupInventoryPanel() // Hide the placeholder text outbox_inventory_placeholder->setVisible(FALSE); - // Establish marketplace cookies for http client - establishMarketplaceSessionCookie(); + // Set up marketplace importer + LLMarketplaceInventoryImporter::getInstance()->initialize(); + LLMarketplaceInventoryImporter::getInstance()->setStatusChangedCallback(boost::bind(&LLPanelMarketplaceOutbox::importStatusChanged, this, _1)); + LLMarketplaceInventoryImporter::getInstance()->setStatusReportCallback(boost::bind(&LLPanelMarketplaceOutbox::importReportResults, this, _1, _2)); updateImportButtonStatus(); return mInventoryPanel; } -BOOL LLPanelMarketplaceOutbox::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, - EDragAndDropType cargo_type, - void* cargo_data, - EAcceptance* accept, - std::string& tooltip_msg) +void LLPanelMarketplaceOutbox::importReportResults(U32 status, const LLSD& content) { - BOOL handled = LLPanel::handleDragAndDrop(x, y, mask, drop, cargo_type, cargo_data, accept, tooltip_msg); - - if (!handled && mInventoryPanel && mInventoryPanel->getRootFolder()) + if (status == MarketplaceErrorCodes::IMPORT_DONE) { - handled = mInventoryPanel->getRootFolder()->handleDragAndDropFromChild(mask,drop,cargo_type,cargo_data,accept,tooltip_msg); - - if (handled) - { - mInventoryPanel->getRootFolder()->setDragAndDropThisFrame(); - } + LLNotificationsUtil::add("OutboxImportComplete", LLSD::emptyMap(), LLSD::emptyMap()); } - - return handled; -} - -bool LLPanelMarketplaceOutbox::isOutboxEmpty() const -{ - return (getTotalItemCount() == 0); -} - -bool LLPanelMarketplaceOutbox::isImportInProgress() const -{ - return mImportInProgress; -} - - -std::string gTimeDelayDebugFunc = ""; - -void timeDelay(LLCoros::self& self, LLPanelMarketplaceOutbox* outboxPanel) -{ - waitForEventOn(self, "mainloop"); - - LLTimer delayTimer; - delayTimer.reset(); - delayTimer.setTimerExpirySec(5.0f); - - while (!delayTimer.hasExpired()) + else if (status == MarketplaceErrorCodes::IMPORT_DONE_WITH_ERRORS) { - waitForEventOn(self, "mainloop"); + LLNotificationsUtil::add("OutboxImportHadErrors", LLSD::emptyMap(), LLSD::emptyMap()); } - - outboxPanel->onImportPostComplete(MarketplaceErrorCodes::IMPORT_DONE, LLSD::emptyMap()); - - gTimeDelayDebugFunc = ""; -} - -std::string gImportPollingFunc = ""; - -void importPoll(LLCoros::self& self, LLPanelMarketplaceOutbox* outboxPanel) -{ - waitForEventOn(self, "mainloop"); - - while (outboxPanel->isImportInProgress()) + else { - LLTimer delayTimer; - delayTimer.reset(); - delayTimer.setTimerExpirySec(5.0f); + char status_string[16]; + sprintf(status_string, "%d", status); - while (!delayTimer.hasExpired()) - { - waitForEventOn(self, "mainloop"); - } + LLSD subs; + subs["ERROR_CODE"] = status_string; - //outboxPanel-> + //llassert(status == MarketplaceErrorCodes::IMPORT_JOB_FAILED); + LLNotificationsUtil::add("OutboxImportFailed", LLSD::emptyMap(), LLSD::emptyMap()); } - - gImportPollingFunc = ""; } -class LLInventoryImportPostResponder : public LLHTTPClient::Responder +void LLPanelMarketplaceOutbox::importStatusChanged(bool inProgress) { -public: - LLInventoryImportPostResponder(LLPanelMarketplaceOutbox * outboxPanel) - : LLCurl::Responder() - , mOutboxPanel(outboxPanel) - { - } - - void completed(U32 status, const std::string& reason, const LLSD& content) - { -#if DEBUG_MARKETPLACE_HTTP_API - llinfos << "*** Marketplace *** " << "inventory/import post status: " << status << ", reason: " << reason << llendl; - - if (isGoodStatus(status)) - { - // Complete success - llinfos << "*** Marketplace *** " << "success" << llendl; - } - else - { - llwarns << "*** Marketplace *** " << "failed" << llendl; - } -#endif // DEBUG_MARKETPLACE_HTTP_API - - mOutboxPanel->onImportPostComplete(status, content); - } - -private: - LLPanelMarketplaceOutbox * mOutboxPanel; -}; + updateImportButtonStatus(); +} -class LLInventoryImportGetResponder : public LLHTTPClient::Responder +BOOL LLPanelMarketplaceOutbox::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, + EDragAndDropType cargo_type, + void* cargo_data, + EAcceptance* accept, + std::string& tooltip_msg) { -public: - LLInventoryImportGetResponder(LLPanelMarketplaceOutbox * outboxPanel, bool ignoreResults) - : LLCurl::Responder() - , mIgnoreResults(ignoreResults) - , mOutboxPanel(outboxPanel) - { - } + BOOL handled = LLPanel::handleDragAndDrop(x, y, mask, drop, cargo_type, cargo_data, accept, tooltip_msg); - void completedHeader(U32 status, const std::string& reason, const LLSD& content) + if (!handled && mInventoryPanel && mInventoryPanel->getRootFolder()) { - std::string cookie = content["set-cookie"].asString(); - -#if DEBUG_MARKETPLACE_HTTP_API - llinfos << "*** Marketplace *** " << "inventory/import headers set-cookie: " << cookie << llendl; -#endif // DEBUG_MARKETPLACE_HTTP_API - - sMarketplaceCookie = cookie; - } + handled = mInventoryPanel->getRootFolder()->handleDragAndDropFromChild(mask,drop,cargo_type,cargo_data,accept,tooltip_msg); - void completed(U32 status, const std::string& reason, const LLSD& content) - { -#if DEBUG_MARKETPLACE_HTTP_API - llinfos << "*** Marketplace *** " << "inventory/import get status: " << status << ", reason: " << reason << llendl; - - if (isGoodStatus(status)) - { - // Complete success - llinfos << "*** Marketplace *** " << "success" << llendl; - } - else + if (handled) { - llwarns << "*** Marketplace *** " << "failed" << llendl; + mInventoryPanel->getRootFolder()->setDragAndDropThisFrame(); } -#endif // DEBUG_MARKETPLACE_HTTP_API - - mOutboxPanel->onImportGetComplete(status, content, mIgnoreResults); - } - -private: - bool mIgnoreResults; - LLPanelMarketplaceOutbox * mOutboxPanel; -}; - -void LLPanelMarketplaceOutbox::importPostTrigger() -{ - mImportInProgress = true; - mImportFrameTimer = 0; - - // Make the url for the inventory import request - std::string url = getMarketplaceURL_InventoryImport(); - - LLSD headers = LLViewerMedia::getHeaders(); - headers["Connection"] = "Keep-Alive"; - headers["Cookie"] = sMarketplaceCookie; - -#if DEBUG_MARKETPLACE_HTTP_API - llinfos << "*** Marketplace *** " << "http post: " << url << llendl; - llinfos << "*** Marketplace *** " << "headers: " << ll_pretty_print_sd(headers) << llendl; -#endif // DEBUG_MARKETPLACE_HTTP_API - - LLHTTPClient::post(url, LLSD(), new LLInventoryImportPostResponder(this), headers); - - // Set a timer (for testing only) - //gTimeDelayDebugFunc = LLCoros::instance().launch("LLPanelMarketplaceOutbox timeDelay", boost::bind(&timeDelay, _1, this)); -} - -void LLPanelMarketplaceOutbox::importGetTrigger() -{ - mImportGetPending = true; - - std::string url = getMarketplaceURL_InventoryImport(); - LLSD headers = LLViewerMedia::getHeaders(); - headers["Cookie"] = sMarketplaceCookie; - -#if DEBUG_MARKETPLACE_HTTP_API - llinfos << "*** Marketplace *** " << "http get: " << url << llendl; - llinfos << "*** Marketplace *** " << "headers: " << ll_pretty_print_sd(headers) << llendl; -#endif // DEBUG_MARKETPLACE_HTTP_API - - const bool do_not_ignore_results = false; - - LLHTTPClient::get(url, new LLInventoryImportGetResponder(this, do_not_ignore_results), headers); -} - -void LLPanelMarketplaceOutbox::establishMarketplaceSessionCookie() -{ - mImportInProgress = true; - mImportGetPending = true; - - std::string url = getMarketplaceURL_InventoryImport(); - LLSD headers = LLViewerMedia::getHeaders(); - - const bool ignore_results = true; - - LLHTTPClient::get(url, new LLInventoryImportGetResponder(this, ignore_results), headers); -} - -void LLPanelMarketplaceOutbox::onImportPostComplete(U32 status, const LLSD& content) -{ -#if DEBUG_MARKETPLACE_HTTP_API - llinfos << "*** Marketplace *** " << "status = " << status << llendl; - llinfos << "*** Marketplace *** " << "content = " << ll_pretty_print_sd(content) << llendl; -#endif // DEBUG_MARKETPLACE_HTTP_API - - mImportInProgress = (status == MarketplaceErrorCodes::IMPORT_DONE); - updateImportButtonStatus(); - - if (!mImportInProgress) - { - char status_string[16]; - sprintf(status_string, "%d", status); - - LLSD subs; - subs["ERROR_CODE"] = status_string; - - LLNotificationsUtil::add("OutboxImportFailed", subs, LLSD::emptyMap()); } - // The POST request returns the IMPORT_DONE code on success - //if (status == MarketplaceErrorCodes::IMPORT_DONE) - //{ - // gImportPollingFunc = LLCoros::instance().launch("LLPanelMarketplaceOutbox importPoll", boost::bind(&importPoll, _1, this)); - //} + return handled; } -void LLPanelMarketplaceOutbox::onImportGetComplete(U32 status, const LLSD& content, bool ignoreResults) +bool LLPanelMarketplaceOutbox::isOutboxEmpty() const { -#if DEBUG_MARKETPLACE_HTTP_API - llinfos << "*** Marketplace *** " << "status = " << status << llendl; - llinfos << "*** Marketplace *** " << "content = " << ll_pretty_print_sd(content) << llendl; -#endif // DEBUG_MARKETPLACE_HTTP_API - - mImportGetPending = false; - mImportInProgress = (status == MarketplaceErrorCodes::IMPORT_PROCESSING); - updateImportButtonStatus(); - - if (!mImportInProgress && !ignoreResults) - { - 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 - { - char status_string[16]; - sprintf(status_string, "%d", status); - - LLSD subs; - subs["ERROR_CODE"] = status_string; - - //llassert(status == MarketplaceErrorCodes::IMPORT_JOB_FAILED); - LLNotificationsUtil::add("OutboxImportFailed", LLSD::emptyMap(), LLSD::emptyMap()); - } - } + return (getTotalItemCount() == 0); } void LLPanelMarketplaceOutbox::updateImportButtonStatus() { - if (isImportInProgress()) + if (LLMarketplaceInventoryImporter::instance().isImportInProgress()) { mImportButton->setVisible(false); @@ -440,7 +222,7 @@ void LLPanelMarketplaceOutbox::updateImportButtonStatus() mImportIndicator->setVisible(false); mImportButton->setVisible(true); - mImportButton->setEnabled(getMarketplaceImportEnabled() && !isOutboxEmpty()); + mImportButton->setEnabled(!isOutboxEmpty()); } } @@ -464,7 +246,7 @@ U32 LLPanelMarketplaceOutbox::getTotalItemCount() const void LLPanelMarketplaceOutbox::onImportButtonClicked() { - importPostTrigger(); + LLMarketplaceInventoryImporter::instance().triggerImport(); // Get the import animation going updateImportButtonStatus(); @@ -488,19 +270,5 @@ void LLPanelMarketplaceOutbox::draw() mOutboxButton->setLabel(getString("OutboxLabelNoArg")); } - if (!isImportInProgress()) - { - mImportButton->setEnabled(getMarketplaceImportEnabled() && not_empty); - } - else - { - ++mImportFrameTimer; - - if ((mImportFrameTimer % 50 == 0) && !mImportGetPending) - { - importGetTrigger(); - } - } - LLPanel::draw(); } -- cgit v1.2.3 From a7b04c9dd44274b3548402de2f4a9b8bc20e3e50 Mon Sep 17 00:00:00 2001 From: Leslie Linden Date: Fri, 9 Dec 2011 10:31:16 -0800 Subject: * Removed old inventory window outbox. * Added centered progress indicator for outbox. --- indra/newview/llpanelmarketplaceoutbox.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'indra/newview/llpanelmarketplaceoutbox.cpp') diff --git a/indra/newview/llpanelmarketplaceoutbox.cpp b/indra/newview/llpanelmarketplaceoutbox.cpp index e3af7fd906..6c2363eb7f 100644 --- a/indra/newview/llpanelmarketplaceoutbox.cpp +++ b/indra/newview/llpanelmarketplaceoutbox.cpp @@ -84,6 +84,8 @@ BOOL LLPanelMarketplaceOutbox::postBuild() return TRUE; } +// DO WE NEED THIS FILE AT ALL? + void LLPanelMarketplaceOutbox::handleLoginComplete() { mImportButton = getChild("outbox_import_btn"); @@ -100,7 +102,7 @@ void LLPanelMarketplaceOutbox::onFocusReceived() LLSidepanelInventory * sidepanel_inventory = LLFloaterSidePanelContainer::getPanel("inventory"); if (sidepanel_inventory) { - sidepanel_inventory->clearSelections(true, true, false); + sidepanel_inventory->clearSelections(true, true); } } -- cgit v1.2.3 From af32a74b77ffc2110de821e0159de8eb5aa0f454 Mon Sep 17 00:00:00 2001 From: Leslie Linden Date: Thu, 5 Jan 2012 16:30:15 -0800 Subject: EXP-1757 FIX -- Merchant Outbox shows as empty when first opening/initializing even when populated * Updated merchant outbox floater to not wait for initialization to complete before displaying outbox inventory contents. --- indra/newview/llpanelmarketplaceoutbox.cpp | 276 ----------------------------- 1 file changed, 276 deletions(-) delete mode 100644 indra/newview/llpanelmarketplaceoutbox.cpp (limited to 'indra/newview/llpanelmarketplaceoutbox.cpp') diff --git a/indra/newview/llpanelmarketplaceoutbox.cpp b/indra/newview/llpanelmarketplaceoutbox.cpp deleted file mode 100644 index 6c2363eb7f..0000000000 --- a/indra/newview/llpanelmarketplaceoutbox.cpp +++ /dev/null @@ -1,276 +0,0 @@ -/** - * @file llpanelmarketplaceoutbox.cpp - * @brief Panel for marketplace outbox - * -* $LicenseInfo:firstyear=2011&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -#include "llviewerprecompiledheaders.h" - -#include "llpanelmarketplaceoutbox.h" -#include "llpanelmarketplaceoutboxinventory.h" - -#include "llappviewer.h" -#include "llbutton.h" -#include "llcoros.h" -#include "lleventcoro.h" -#include "llfloatersidepanelcontainer.h" -#include "llinventorypanel.h" -#include "llloadingindicator.h" -#include "llmarketplacefunctions.h" -#include "llnotificationsutil.h" -#include "llpanelmarketplaceinbox.h" -#include "llsdutil.h" -#include "llsidepanelinventory.h" -#include "lltimer.h" -#include "llviewernetwork.h" -#include "llagent.h" -#include "llviewermedia.h" -#include "llfolderview.h" -#include "llinventoryfunctions.h" - - -// Turn this on to get a bunch of console output for marketplace API calls, headers and status -#define DEBUG_MARKETPLACE_HTTP_API 0 - - -static LLRegisterPanelClassWrapper t_panel_marketplace_outbox("panel_marketplace_outbox"); - -const LLPanelMarketplaceOutbox::Params& LLPanelMarketplaceOutbox::getDefaultParams() -{ - return LLUICtrlFactory::getDefaultParams(); -} - -// protected -LLPanelMarketplaceOutbox::LLPanelMarketplaceOutbox(const Params& p) - : LLPanel(p) - , mInventoryPanel(NULL) - , mImportButton(NULL) - , mImportIndicator(NULL) - , mOutboxButton(NULL) -{ -} - -LLPanelMarketplaceOutbox::~LLPanelMarketplaceOutbox() -{ -} - -// virtual -BOOL LLPanelMarketplaceOutbox::postBuild() -{ - LLAppViewer::instance()->setOnLoginCompletedCallback(boost::bind(&LLPanelMarketplaceOutbox::handleLoginComplete, this)); - - LLFocusableElement::setFocusReceivedCallback(boost::bind(&LLPanelMarketplaceOutbox::onFocusReceived, this)); - - return TRUE; -} - -// DO WE NEED THIS FILE AT ALL? - -void LLPanelMarketplaceOutbox::handleLoginComplete() -{ - mImportButton = getChild("outbox_import_btn"); - mImportButton->setCommitCallback(boost::bind(&LLPanelMarketplaceOutbox::onImportButtonClicked, this)); - mImportButton->setEnabled(!isOutboxEmpty()); - - mImportIndicator = getChild("outbox_import_indicator"); - - mOutboxButton = getChild("outbox_btn"); -} - -void LLPanelMarketplaceOutbox::onFocusReceived() -{ - LLSidepanelInventory * sidepanel_inventory = LLFloaterSidePanelContainer::getPanel("inventory"); - if (sidepanel_inventory) - { - sidepanel_inventory->clearSelections(true, true); - } -} - -void LLPanelMarketplaceOutbox::onSelectionChange() -{ - LLSidepanelInventory* sidepanel_inventory = LLFloaterSidePanelContainer::getPanel("inventory"); - if (sidepanel_inventory) - { - sidepanel_inventory->updateVerbs(); - } -} - -LLInventoryPanel * LLPanelMarketplaceOutbox::setupInventoryPanel() -{ - LLView * outbox_inventory_placeholder = getChild("outbox_inventory_placeholder_panel"); - LLView * outbox_inventory_parent = outbox_inventory_placeholder->getParent(); - - mInventoryPanel = - LLUICtrlFactory::createFromFile("panel_outbox_inventory.xml", - outbox_inventory_parent, - LLInventoryPanel::child_registry_t::instance()); - - llassert(mInventoryPanel); - - // Reshape the inventory to the proper size - LLRect inventory_placeholder_rect = outbox_inventory_placeholder->getRect(); - mInventoryPanel->setShape(inventory_placeholder_rect); - - // Set the sort order newest to oldest - mInventoryPanel->setSortOrder(LLInventoryFilter::SO_DATE); - mInventoryPanel->getFilter()->markDefault(); - - // Set selection callback for proper update of inventory status buttons - mInventoryPanel->setSelectCallback(boost::bind(&LLPanelMarketplaceOutbox::onSelectionChange, this)); - - // Set up the note to display when the outbox is empty - mInventoryPanel->getFilter()->setEmptyLookupMessage("InventoryOutboxNoItems"); - - // Hide the placeholder text - outbox_inventory_placeholder->setVisible(FALSE); - - // Set up marketplace importer - LLMarketplaceInventoryImporter::getInstance()->initialize(); - LLMarketplaceInventoryImporter::getInstance()->setStatusChangedCallback(boost::bind(&LLPanelMarketplaceOutbox::importStatusChanged, this, _1)); - LLMarketplaceInventoryImporter::getInstance()->setStatusReportCallback(boost::bind(&LLPanelMarketplaceOutbox::importReportResults, this, _1, _2)); - - updateImportButtonStatus(); - - return mInventoryPanel; -} - -void LLPanelMarketplaceOutbox::importReportResults(U32 status, const LLSD& content) -{ - 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 - { - char status_string[16]; - sprintf(status_string, "%d", status); - - LLSD subs; - subs["ERROR_CODE"] = status_string; - - //llassert(status == MarketplaceErrorCodes::IMPORT_JOB_FAILED); - LLNotificationsUtil::add("OutboxImportFailed", LLSD::emptyMap(), LLSD::emptyMap()); - } -} - -void LLPanelMarketplaceOutbox::importStatusChanged(bool inProgress) -{ - updateImportButtonStatus(); -} - -BOOL LLPanelMarketplaceOutbox::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, - EDragAndDropType cargo_type, - void* cargo_data, - EAcceptance* accept, - std::string& tooltip_msg) -{ - BOOL handled = LLPanel::handleDragAndDrop(x, y, mask, drop, cargo_type, cargo_data, accept, tooltip_msg); - - if (!handled && mInventoryPanel && mInventoryPanel->getRootFolder()) - { - handled = mInventoryPanel->getRootFolder()->handleDragAndDropFromChild(mask,drop,cargo_type,cargo_data,accept,tooltip_msg); - - if (handled) - { - mInventoryPanel->getRootFolder()->setDragAndDropThisFrame(); - } - } - - return handled; -} - -bool LLPanelMarketplaceOutbox::isOutboxEmpty() const -{ - return (getTotalItemCount() == 0); -} - -void LLPanelMarketplaceOutbox::updateImportButtonStatus() -{ - if (LLMarketplaceInventoryImporter::instance().isImportInProgress()) - { - mImportButton->setVisible(false); - - mImportIndicator->setVisible(true); - mImportIndicator->reset(); - mImportIndicator->start(); - } - else - { - mImportIndicator->stop(); - mImportIndicator->setVisible(false); - - mImportButton->setVisible(true); - mImportButton->setEnabled(!isOutboxEmpty()); - } -} - -U32 LLPanelMarketplaceOutbox::getTotalItemCount() const -{ - U32 item_count = 0; - - if (mInventoryPanel) - { - const LLFolderViewFolder * outbox_folder = mInventoryPanel->getRootFolder(); - - if (outbox_folder) - { - item_count += outbox_folder->getFoldersCount(); - item_count += outbox_folder->getItemsCount(); - } - } - - return item_count; -} - -void LLPanelMarketplaceOutbox::onImportButtonClicked() -{ - LLMarketplaceInventoryImporter::instance().triggerImport(); - - // Get the import animation going - updateImportButtonStatus(); -} - -void LLPanelMarketplaceOutbox::draw() -{ - const U32 item_count = getTotalItemCount(); - const bool not_empty = (item_count > 0); - - if (not_empty) - { - std::string item_count_str = llformat("%d", item_count); - - LLStringUtil::format_map_t args; - args["[NUM]"] = item_count_str; - mOutboxButton->setLabel(getString("OutboxLabelWithArg", args)); - } - else - { - mOutboxButton->setLabel(getString("OutboxLabelNoArg")); - } - - LLPanel::draw(); -} -- cgit v1.2.3