diff options
author | Leslie Linden <leslie@lindenlab.com> | 2011-12-06 11:19:58 -0800 |
---|---|---|
committer | Leslie Linden <leslie@lindenlab.com> | 2011-12-06 11:19:58 -0800 |
commit | a255fadfab359931d591c6a874abbea5fcf13526 (patch) | |
tree | 495f73b982ff51c37e34f9b253d5dd11f399f133 /indra | |
parent | 3236cbd585860f76a14c4837c70cb5823a4fd7d5 (diff) |
Updated to trigger a 'get' to establish marketplace session cookie when outbox panel created.
Diffstat (limited to 'indra')
-rw-r--r-- | indra/newview/llmarketplacefunctions.cpp | 4 | ||||
-rw-r--r-- | indra/newview/llpanelmarketplaceoutbox.cpp | 194 | ||||
-rw-r--r-- | indra/newview/llpanelmarketplaceoutbox.h | 6 | ||||
-rw-r--r-- | indra/newview/llviewermedia.cpp | 1 | ||||
-rw-r--r-- | indra/newview/skins/default/xui/en/notifications.xml | 2 |
5 files changed, 129 insertions, 78 deletions
diff --git a/indra/newview/llmarketplacefunctions.cpp b/indra/newview/llmarketplacefunctions.cpp index 1c189f6ee2..2f8c5bc9ee 100644 --- a/indra/newview/llmarketplacefunctions.cpp +++ b/indra/newview/llmarketplacefunctions.cpp @@ -52,7 +52,7 @@ std::string getMarketplaceBaseURL() url += "api/1/"; url += gAgent.getID().getString(); - url += "/inventory"; + url += "/inventory/"; return url; } @@ -61,7 +61,7 @@ std::string getMarketplaceURL_InventoryImport() { std::string url = getMarketplaceBaseURL(); - url += "/import"; + url += "import/"; return url; } 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<LLOutboxFolderViewFolder *>(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(); } diff --git a/indra/newview/llpanelmarketplaceoutbox.h b/indra/newview/llpanelmarketplaceoutbox.h index a776ee0919..9cbb9cf21b 100644 --- a/indra/newview/llpanelmarketplaceoutbox.h +++ b/indra/newview/llpanelmarketplaceoutbox.h @@ -62,7 +62,7 @@ public: bool isImportInProgress() const; void onImportPostComplete(U32 status, const LLSD& content); - void onImportGetComplete(U32 status, const LLSD& content); + void onImportGetComplete(U32 status, const LLSD& content, bool ignoreResults); /*virtual*/ BOOL handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, EDragAndDropType cargo_type, @@ -77,6 +77,10 @@ protected: void handleLoginComplete(); void onFocusReceived(); void onSelectionChange(); + + void importPostTrigger(); + void importGetTrigger(); + void establishMarketplaceSessionCookie(); private: LLInventoryPanel * mInventoryPanel; diff --git a/indra/newview/llviewermedia.cpp b/indra/newview/llviewermedia.cpp index 02d8036666..eb7a4aa538 100644 --- a/indra/newview/llviewermedia.cpp +++ b/indra/newview/llviewermedia.cpp @@ -1390,6 +1390,7 @@ LLSD LLViewerMedia::getHeaders() { LLSD headers = LLSD::emptyMap(); headers["Accept"] = "*/*"; + headers["Content-Type"] = "application/xml"; headers["Cookie"] = sOpenIDCookie; headers["User-Agent"] = getCurrentUserAgent(); diff --git a/indra/newview/skins/default/xui/en/notifications.xml b/indra/newview/skins/default/xui/en/notifications.xml index 46a6da2450..8d0d76b58e 100644 --- a/indra/newview/skins/default/xui/en/notifications.xml +++ b/indra/newview/skins/default/xui/en/notifications.xml @@ -235,7 +235,7 @@ Marketplace import completed with errors! Please correct the problems in your o icon="alertmodal.tga" name="OutboxImportFailed" type="alertmodal"> -Marketplace import failed! Please try again later. Thanks. +Marketplace import failed with error [ERROR_CODE]! Please try again later. Thanks. <usetemplate name="okbutton" yestext="Rats!"/> |