diff options
Diffstat (limited to 'indra')
-rw-r--r-- | indra/newview/llfloateroutbox.cpp | 38 | ||||
-rw-r--r-- | indra/newview/llfloateroutbox.h | 1 | ||||
-rw-r--r-- | indra/newview/llmarketplacefunctions.cpp | 175 | ||||
-rw-r--r-- | indra/newview/llmarketplacefunctions.h | 4 | ||||
-rw-r--r-- | indra/newview/skins/default/xui/en/notifications.xml | 14 |
5 files changed, 157 insertions, 75 deletions
diff --git a/indra/newview/llfloateroutbox.cpp b/indra/newview/llfloateroutbox.cpp index 6ecf715588..28589f5e9a 100644 --- a/indra/newview/llfloateroutbox.cpp +++ b/indra/newview/llfloateroutbox.cpp @@ -250,12 +250,12 @@ void LLFloaterOutbox::setupOutbox(const LLUUID& outboxId) // Initialize the marketplace import API // - mImportBusy = true; - setStatusString(getString("OutboxInitializing")); - - LLMarketplaceInventoryImporter::getInstance()->initialize(); - LLMarketplaceInventoryImporter::getInstance()->setStatusChangedCallback(boost::bind(&LLFloaterOutbox::importStatusChanged, this, _1)); - LLMarketplaceInventoryImporter::getInstance()->setStatusReportCallback(boost::bind(&LLFloaterOutbox::importReportResults, this, _1, _2)); + LLMarketplaceInventoryImporter& importer = LLMarketplaceInventoryImporter::instance(); + + importer.setInitializationErrorCallback(boost::bind(&LLFloaterOutbox::initializationReportError, this, _1, _2)); + importer.setStatusChangedCallback(boost::bind(&LLFloaterOutbox::importStatusChanged, this, _1)); + importer.setStatusReportCallback(boost::bind(&LLFloaterOutbox::importReportResults, this, _1, _2)); + importer.initialize(); } void LLFloaterOutbox::setStatusString(const std::string& statusString) @@ -403,7 +403,7 @@ void LLFloaterOutbox::onImportButtonClicked() { mOutboxInventoryPanel->clearSelection(); - LLMarketplaceInventoryImporter::instance().triggerImport(); + mImportBusy = LLMarketplaceInventoryImporter::instance().triggerImport(); } void LLFloaterOutbox::onOutboxChanged() @@ -449,10 +449,14 @@ void LLFloaterOutbox::importStatusChanged(bool inProgress) { if (inProgress) { - if (!mImportBusy) + if (mImportBusy) { setStatusString(getString("OutboxImporting")); } + else + { + setStatusString(getString("OutboxInitializing")); + } mImportBusy = true; mImportButton->setEnabled(false); @@ -463,9 +467,25 @@ void LLFloaterOutbox::importStatusChanged(bool inProgress) mImportBusy = false; mImportButton->setEnabled(mOutboxItemCount > 0); mInventoryImportInProgress->setVisible(false); + } + + updateView(); +} - updateView(); +void LLFloaterOutbox::initializationReportError(U32 status, const LLSD& content) +{ + if (status != MarketplaceErrorCodes::IMPORT_DONE) + { + char status_string[16]; + sprintf(status_string, "%d", status); + + LLSD subs; + subs["[ERROR_CODE]"] = status_string; + + LLNotificationsUtil::add("OutboxInitFailed", subs); } + + updateView(); } void LLFloaterOutbox::showNotification(const LLSD& notify) diff --git a/indra/newview/llfloateroutbox.h b/indra/newview/llfloateroutbox.h index 6b4021807c..58b7d6ec98 100644 --- a/indra/newview/llfloateroutbox.h +++ b/indra/newview/llfloateroutbox.h @@ -71,6 +71,7 @@ protected: void importReportResults(U32 status, const LLSD& content); void importStatusChanged(bool inProgress); + void initializationReportError(U32 status, const LLSD& content); void onClose(bool app_quitting); void onOpen(const LLSD& key); diff --git a/indra/newview/llmarketplacefunctions.cpp b/indra/newview/llmarketplacefunctions.cpp index 9a83c5fcb7..ea6634a39e 100644 --- a/indra/newview/llmarketplacefunctions.cpp +++ b/indra/newview/llmarketplacefunctions.cpp @@ -97,14 +97,15 @@ namespace LLMarketplaceImport { // Basic interface for this namespace + bool hasSessionCookie(); bool inProgress(); bool resultPending(); U32 getResultStatus(); const LLSD& getResults(); - void establishMarketplaceSessionCookie(); - void pollStatus(); - void triggerImport(); + bool establishMarketplaceSessionCookie(); + bool pollStatus(); + bool triggerImport(); // Internal state variables @@ -116,7 +117,6 @@ namespace LLMarketplaceImport static U32 sImportResultStatus = 0; static LLSD sImportResults = LLSD::emptyMap(); - // Responders class LLImportPostResponder : public LLHTTPClient::Responder @@ -147,7 +147,12 @@ namespace LLMarketplaceImport void completedHeader(U32 status, const std::string& reason, const LLSD& content) { - sMarketplaceCookie = content["set-cookie"].asString(); + const std::string& set_cookie_string = content["set-cookie"].asString(); + + if (!set_cookie_string.empty()) + { + sMarketplaceCookie = set_cookie_string; + } } void completed(U32 status, const std::string& reason, const LLSD& content) @@ -158,6 +163,16 @@ namespace LLMarketplaceImport llinfos << " SLM GET reason: " << reason << llendl; llinfos << " SLM GET content: " << content.asString() << llendl; } + + if (status == MarketplaceErrorCodes::IMPORT_AUTHENTICATION_ERROR) + { + if (gSavedSettings.getBOOL("InventoryOutboxLogging")) + { + llinfos << " SLM GET clearing marketplace cookie due to authentication failure" << llendl; + } + + sMarketplaceCookie.clear(); + } sImportInProgress = (status == MarketplaceErrorCodes::IMPORT_PROCESSING); sImportGetPending = false; @@ -165,56 +180,14 @@ namespace LLMarketplaceImport sImportResults = content; } }; - - // Coroutine testing -/* - std::string gTimeDelayDebugFunc = ""; - - void timeDelay(LLCoros::self& self, LLPanelMarketplaceOutbox* outboxPanel) - { - waitForEventOn(self, "mainloop"); - - LLTimer delayTimer; - delayTimer.reset(); - delayTimer.setTimerExpirySec(5.0f); - - while (!delayTimer.hasExpired()) - { - waitForEventOn(self, "mainloop"); - } - - outboxPanel->onImportPostComplete(MarketplaceErrorCodes::IMPORT_DONE, LLSD::emptyMap()); - - gTimeDelayDebugFunc = ""; - } - - std::string gImportPollingFunc = ""; - - void importPoll(LLCoros::self& self, LLPanelMarketplaceOutbox* outboxPanel) + + // Basic API + + bool hasSessionCookie() { - waitForEventOn(self, "mainloop"); - - while (outboxPanel->isImportInProgress()) - { - LLTimer delayTimer; - delayTimer.reset(); - delayTimer.setTimerExpirySec(5.0f); - - while (!delayTimer.hasExpired()) - { - waitForEventOn(self, "mainloop"); - } - - //outboxPanel-> - } - - gImportPollingFunc = ""; + return !sMarketplaceCookie.empty(); } -*/ - - // Basic API - bool inProgress() { return sImportInProgress; @@ -246,8 +219,13 @@ namespace LLMarketplaceImport return url; } - void establishMarketplaceSessionCookie() + bool establishMarketplaceSessionCookie() { + if (hasSessionCookie()) + { + return false; + } + sImportInProgress = true; sImportGetPending = true; @@ -259,10 +237,17 @@ namespace LLMarketplaceImport } LLHTTPClient::get(url, new LLImportGetResponder(), LLViewerMedia::getHeaders()); + + return true; } - void pollStatus() + bool pollStatus() { + if (!hasSessionCookie()) + { + return false; + } + sImportGetPending = true; std::string url = getInventoryImportURL(); @@ -282,10 +267,17 @@ namespace LLMarketplaceImport } LLHTTPClient::get(url, new LLImportGetResponder(), headers); + + return true; } - void triggerImport() + bool triggerImport() { + if (!hasSessionCookie()) + { + return false; + } + sImportId = LLSD::emptyMap(); sImportInProgress = true; sImportPostPending = true; @@ -309,8 +301,7 @@ namespace LLMarketplaceImport LLHTTPClient::post(url, LLSD(), new LLImportPostResponder(), headers); - // Set a timer (for testing only) - //gTimeDelayDebugFunc = LLCoros::instance().launch("LLPanelMarketplaceOutbox timeDelay", boost::bind(&timeDelay, _1, this)); + return true; } } @@ -330,8 +321,10 @@ void LLMarketplaceInventoryImporter::update() } LLMarketplaceInventoryImporter::LLMarketplaceInventoryImporter() - : mImportInProgress(false) + : mAutoTriggerImport(false) + , mImportInProgress(false) , mInitialized(false) + , mErrorInitSignal(NULL) , mStatusChangedSignal(NULL) , mStatusReportSignal(NULL) { @@ -339,12 +332,24 @@ LLMarketplaceInventoryImporter::LLMarketplaceInventoryImporter() void LLMarketplaceInventoryImporter::initialize() { - if (!mInitialized) + llassert(!mInitialized); + + if (!LLMarketplaceImport::hasSessionCookie()) { LLMarketplaceImport::establishMarketplaceSessionCookie(); } } +boost::signals2::connection LLMarketplaceInventoryImporter::setInitializationErrorCallback(const status_report_signal_t::slot_type& cb) +{ + if (mErrorInitSignal == NULL) + { + mErrorInitSignal = new status_report_signal_t(); + } + + return mErrorInitSignal->connect(cb); +} + boost::signals2::connection LLMarketplaceInventoryImporter::setStatusChangedCallback(const status_changed_signal_t::slot_type& cb) { if (mStatusChangedSignal == NULL) @@ -367,9 +372,18 @@ boost::signals2::connection LLMarketplaceInventoryImporter::setStatusReportCallb bool LLMarketplaceInventoryImporter::triggerImport() { - LLMarketplaceImport::triggerImport(); + const bool import_triggered = LLMarketplaceImport::triggerImport(); - return LLMarketplaceImport::inProgress(); + if (!import_triggered) + { + mInitialized = false; + + initialize(); + + mAutoTriggerImport = true; + } + + return import_triggered; } void LLMarketplaceInventoryImporter::updateImport() @@ -378,7 +392,16 @@ void LLMarketplaceInventoryImporter::updateImport() if (in_progress && !LLMarketplaceImport::resultPending()) { - LLMarketplaceImport::pollStatus(); + const bool polling_status = LLMarketplaceImport::pollStatus(); + + if (!polling_status) + { + mInitialized = false; + + initialize(); + + mAutoTriggerImport = true; + } } if (mImportInProgress != in_progress) @@ -390,16 +413,36 @@ void LLMarketplaceInventoryImporter::updateImport() (*mStatusChangedSignal)(mImportInProgress); } - // If we are no longer in progress, report results - if (!mImportInProgress && mStatusReportSignal) + // If we are no longer in progress + if (!mImportInProgress) { if (mInitialized) { - (*mStatusReportSignal)(LLMarketplaceImport::getResultStatus(), LLMarketplaceImport::getResults()); + // Report results + if (mStatusReportSignal) + { + (*mStatusReportSignal)(LLMarketplaceImport::getResultStatus(), LLMarketplaceImport::getResults()); + } } else { - mInitialized = true; + // Look for results success + mInitialized = LLMarketplaceImport::hasSessionCookie(); + + if (mInitialized) + { + // Follow up with auto trigger of import + if (mAutoTriggerImport) + { + mAutoTriggerImport = false; + + triggerImport(); + } + } + else if (mErrorInitSignal) + { + (*mErrorInitSignal)(LLMarketplaceImport::getResultStatus(), LLMarketplaceImport::getResults()); + } } } } diff --git a/indra/newview/llmarketplacefunctions.h b/indra/newview/llmarketplacefunctions.h index f501f1ee8b..b2f6cb7521 100644 --- a/indra/newview/llmarketplacefunctions.h +++ b/indra/newview/llmarketplacefunctions.h @@ -46,6 +46,7 @@ namespace MarketplaceErrorCodes { IMPORT_DONE = 200, IMPORT_PROCESSING = 202, + IMPORT_AUTHENTICATION_ERROR = 401, IMPORT_DONE_WITH_ERRORS = 409, IMPORT_JOB_FAILED = 410, }; @@ -65,6 +66,7 @@ public: typedef boost::signals2::signal<void (bool)> status_changed_signal_t; typedef boost::signals2::signal<void (U32, const LLSD&)> status_report_signal_t; + boost::signals2::connection setInitializationErrorCallback(const status_report_signal_t::slot_type& cb); boost::signals2::connection setStatusChangedCallback(const status_changed_signal_t::slot_type& cb); boost::signals2::connection setStatusReportCallback(const status_report_signal_t::slot_type& cb); @@ -75,9 +77,11 @@ protected: void updateImport(); private: + bool mAutoTriggerImport; bool mImportInProgress; bool mInitialized; + status_report_signal_t * mErrorInitSignal; status_changed_signal_t * mStatusChangedSignal; status_report_signal_t * mStatusReportSignal; }; diff --git a/indra/newview/skins/default/xui/en/notifications.xml b/indra/newview/skins/default/xui/en/notifications.xml index bcb3a105ea..2269703cb6 100644 --- a/indra/newview/skins/default/xui/en/notifications.xml +++ b/indra/newview/skins/default/xui/en/notifications.xml @@ -252,6 +252,20 @@ Error [ERROR_CODE] yestext="OK"/> </notification> + <notification + icon="OutboxStatus_Error" + name="OutboxInitFailed" + type="outbox"> +Marketplace initialization failed + +Initialization with the Marketplace failed because of a system or network error. Try again later. + +Error [ERROR_CODE] + + <usetemplate + name="okbutton" + yestext="OK"/> + </notification> <notification |