diff options
-rwxr-xr-x | indra/newview/llappearancemgr.cpp | 75 | ||||
-rwxr-xr-x | indra/newview/llappearancemgr.h | 2 | ||||
-rw-r--r-- | indra/newview/llpaneleditwearable.cpp | 79 | ||||
-rw-r--r-- | indra/newview/llpaneleditwearable.h | 3 |
4 files changed, 78 insertions, 81 deletions
diff --git a/indra/newview/llappearancemgr.cpp b/indra/newview/llappearancemgr.cpp index 4e103bb75e..e3ac052961 100755 --- a/indra/newview/llappearancemgr.cpp +++ b/indra/newview/llappearancemgr.cpp @@ -2776,6 +2776,81 @@ void LLAppearanceMgr::requestServerAppearanceUpdate(LLCurl::ResponderPtr respond mLastUpdateRequestCOFVersion = cof_version; } +class LLIncrementCofVersionResponder : public LLHTTPClient::Responder +{ +public: + LLIncrementCofVersionResponder() : LLHTTPClient::Responder() + { + mRetryPolicy = new LLAdaptiveRetryPolicy(1.0, 16.0, 2.0, 5); + } + + virtual ~LLIncrementCofVersionResponder() + { + } + + virtual void result(const LLSD &pContent) + { + llinfos << "Successfully incremented agent's COF." << llendl; + S32 new_version = pContent["category"]["version"].asInteger(); + + LLAppearanceMgr* app_mgr = LLAppearanceMgr::getInstance(); + + // cof_version should have increased + llassert(new_version > app_mgr->mLastUpdateRequestCOFVersion); + + app_mgr->mLastUpdateRequestCOFVersion = new_version; + } + virtual void error(U32 pStatus, const std::string& pReason) + { + llwarns << "While attempting to increment the agent's cof we got an error because '" + << pReason << "' [status:" << pStatus << "]" << llendl; + F32 seconds_to_wait; + if (mRetryPolicy->shouldRetry(pStatus,seconds_to_wait)) + { + llinfos << "retrying" << llendl; + doAfterInterval(boost::bind(&LLAppearanceMgr::incrementCofVersion, + LLAppearanceMgr::getInstance(), + LLHTTPClient::ResponderPtr(this)), + seconds_to_wait); + } + else + { + llwarns << "giving up after too many retries" << llendl; + } + } + + LLPointer<LLHTTPRetryPolicy> mRetryPolicy; +}; + +void LLAppearanceMgr::incrementCofVersion(LLHTTPClient::ResponderPtr responder_ptr) +{ + // If we don't have a region, report it as an error + if (gAgent.getRegion() == NULL) + { + llwarns << "Region not set, cannot request cof_version increment" << llendl; + return; + } + + std::string url = gAgent.getRegion()->getCapability("IncrementCofVersion"); + if (url.empty()) + { + llwarns << "No cap for IncrementCofVersion." << llendl; + return; + } + + llinfos << "Requesting cof_version be incremented via capability to: " + << url << llendl; + LLSD headers; + LLSD body = LLSD::emptyMap(); + + if (!responder_ptr.get()) + { + responder_ptr = LLHTTPClient::ResponderPtr(new LLIncrementCofVersionResponder()); + } + + LLHTTPClient::get(url, body, responder_ptr, headers, 30.0f); +} + class LLShowCreatedOutfit: public LLInventoryCallback { public: diff --git a/indra/newview/llappearancemgr.h b/indra/newview/llappearancemgr.h index 01ed66711c..525402c215 100755 --- a/indra/newview/llappearancemgr.h +++ b/indra/newview/llappearancemgr.h @@ -189,6 +189,8 @@ public: void requestServerAppearanceUpdate(LLCurl::ResponderPtr responder_ptr = NULL); + void incrementCofVersion(LLHTTPClient::ResponderPtr responder_ptr = NULL); + protected: LLAppearanceMgr(); ~LLAppearanceMgr(); diff --git a/indra/newview/llpaneleditwearable.cpp b/indra/newview/llpaneleditwearable.cpp index ad55936cab..2bc952dcae 100644 --- a/indra/newview/llpaneleditwearable.cpp +++ b/indra/newview/llpaneleditwearable.cpp @@ -1031,83 +1031,6 @@ void LLPanelEditWearable::updatePanelPickerControls(LLWearableType::EType type) } } -class LLIncrementCofVersionResponder : public LLHTTPClient::Responder -{ -public: - LLIncrementCofVersionResponder(S32 retries); - virtual ~LLIncrementCofVersionResponder(); - - virtual void result(const LLSD &pContent); - virtual void error(U32 pStatus, const std::string& pReason); - -protected: - -private: - LLAgent *mAgent; - S32 mRetries; -}; - -LLIncrementCofVersionResponder::LLIncrementCofVersionResponder(S32 retries) - : LLHTTPClient::Responder(), - mRetries(retries) -{ -} - -LLIncrementCofVersionResponder::~LLIncrementCofVersionResponder() -{ -} - -void LLIncrementCofVersionResponder::result(const LLSD &pContent) -{ - lldebugs << "Successfully incremented agent's COF." << llendl; - -} - -void LLIncrementCofVersionResponder::error(U32 pStatus, const std::string& pReason) -{ - llwarns << "While attempting to increment the agent's cof we got an error because '" - << pReason << "' [status:" << pStatus << "]" << llendl; - LLPanelEditWearable::incrementCofVersion(mRetries++); -} - -//static -void LLPanelEditWearable::incrementCofVersion() -{ - incrementCofVersion(0); -} - -//static -void LLPanelEditWearable::incrementCofVersion(S32 retries) -{ - // Create a response handler - LLHTTPClient::ResponderPtr responderPtr = LLHTTPClient::ResponderPtr(new LLIncrementCofVersionResponder(retries)); - - // If we don't have a region, report it as an error - if (gAgent.getRegion() == NULL) - { - responderPtr->error(0U, "region is not defined"); - } - else - { - // Find the capability to send maturity preference - std::string url = gAgent.getRegion()->getCapability("IncrementCofVersion"); - - // If the capability is not defined, report it as an error - if (url.empty()) - { - responderPtr->error(0U, "capability 'UpdateAgentInformation' is not defined for region"); - } - else - { - llinfos << "Requesting cof_version be incremented via capability to: " - << url << llendl; - LLSD headers; - LLSD body = LLSD::emptyMap(); - LLHTTPClient::post(url, body, responderPtr, headers, 30.0f); - } - } -} - void LLPanelEditWearable::saveChanges(bool force_save_as) { if (!mWearablePtr || !isDirty()) @@ -1133,7 +1056,7 @@ void LLPanelEditWearable::saveChanges(bool force_save_as) if (gAgentAvatarp->isUsingServerBakes()) { - LLPanelEditWearable::incrementCofVersion(0); + LLAppearanceMgr::getInstance()->incrementCofVersion(); } } diff --git a/indra/newview/llpaneleditwearable.h b/indra/newview/llpaneleditwearable.h index 67217f8751..cd29a5d764 100644 --- a/indra/newview/llpaneleditwearable.h +++ b/indra/newview/llpaneleditwearable.h @@ -78,9 +78,6 @@ public: virtual void setVisible(BOOL visible); - static void incrementCofVersion(); - static void incrementCofVersion(S32 retries); - private: typedef std::map<F32, LLViewerVisualParam*> value_map_t; |