From f93604c399c889e06980554e1cb59a833e7f847d Mon Sep 17 00:00:00 2001 From: Logan Dethrow Date: Thu, 15 Nov 2012 15:20:05 -0500 Subject: WIP Working on adding http request to increment the COF version when a change is made to an item in an agent's current outfit folder. SH-3339 --- indra/newview/llpaneleditwearable.cpp | 42 +++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) (limited to 'indra/newview/llpaneleditwearable.cpp') diff --git a/indra/newview/llpaneleditwearable.cpp b/indra/newview/llpaneleditwearable.cpp index 7832156a0e..9862c98cc8 100644 --- a/indra/newview/llpaneleditwearable.cpp +++ b/indra/newview/llpaneleditwearable.cpp @@ -1028,6 +1028,46 @@ void LLPanelEditWearable::updatePanelPickerControls(LLWearableType::EType type) } } +//static +void LLPanelEditWearable::incrementCofVersion() +{ + // Create a response handler + LLHTTPClient::ResponderPtr responderPtr = LLHTTPClient::ResponderPtr(new LLMaturityPreferencesResponder(this)); + + // Look up the capability to POST to. + std::string url = gAgent.getRegion()->getCapability("IncrementCofVersion"); + + // If we don't have a region, report it as an error + if (getRegion() == NULL) + { + responderPtr->error(0U, "region is not defined"); + } + else + { + // Find the capability to send maturity preference + std::string url = getRegion()->getCapability("UpdateAgentInformation"); + + // 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 + { + // Set new access preference + LLSD access_prefs = LLSD::emptyMap(); + access_prefs["max"] = LLViewerRegion::accessToShortString(pPreferredMaturity); + + LLSD body = LLSD::emptyMap(); + body["access_prefs"] = access_prefs; + llinfos << "Sending viewer preferred maturity to '" << LLViewerRegion::accessToString(pPreferredMaturity) + << "' via capability to: " << url << llendl; + LLSD headers; + LLHTTPClient::post(url, body, responderPtr, headers, 30.0f); + } + } +} + void LLPanelEditWearable::saveChanges(bool force_save_as) { if (!mWearablePtr || !isDirty()) @@ -1050,6 +1090,8 @@ void LLPanelEditWearable::saveChanges(bool force_save_as) { gAgentWearables.saveWearable(mWearablePtr->getType(), index, TRUE, new_name); } + + LLPanelEditWearable::incrementCofVersion(); } void LLPanelEditWearable::revertChanges() -- cgit v1.2.3 From ee810bf2abe230769bd5ee81dc76e54d5fcda34c Mon Sep 17 00:00:00 2001 From: Logan Dethrow Date: Fri, 16 Nov 2012 17:07:45 -0500 Subject: WIP First buildable code after adding support for SH-3339. --- indra/newview/llpaneleditwearable.cpp | 96 ++++++++++++++++++++++++----------- 1 file changed, 65 insertions(+), 31 deletions(-) (limited to 'indra/newview/llpaneleditwearable.cpp') diff --git a/indra/newview/llpaneleditwearable.cpp b/indra/newview/llpaneleditwearable.cpp index 9862c98cc8..997edbab07 100644 --- a/indra/newview/llpaneleditwearable.cpp +++ b/indra/newview/llpaneleditwearable.cpp @@ -26,6 +26,8 @@ #include "llviewerprecompiledheaders.h" +#include + #include "llpaneleditwearable.h" #include "llpanel.h" #include "llviewerwearable.h" @@ -47,6 +49,7 @@ #include "llscrollingpanelparam.h" #include "llradiogroup.h" #include "llnotificationsutil.h" +#include "llhttpclient.h" #include "llcolorswatch.h" #include "lltexturectrl.h" @@ -1028,44 +1031,75 @@ 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() +void LLPanelEditWearable::incrementCofVersion(S32 retries) { - // Create a response handler - LLHTTPClient::ResponderPtr responderPtr = LLHTTPClient::ResponderPtr(new LLMaturityPreferencesResponder(this)); + // Create a response handler + LLHTTPClient::ResponderPtr responderPtr = LLHTTPClient::ResponderPtr(new LLIncrementCofVersionResponder(retries)); - // Look up the capability to POST to. - std::string url = gAgent.getRegion()->getCapability("IncrementCofVersion"); + // 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 we don't have a region, report it as an error - if (getRegion() == NULL) + // If the capability is not defined, report it as an error + if (url.empty()) { - responderPtr->error(0U, "region is not defined"); + responderPtr->error(0U, "capability 'UpdateAgentInformation' is not defined for region"); } else { - // Find the capability to send maturity preference - std::string url = getRegion()->getCapability("UpdateAgentInformation"); - - // 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 - { - // Set new access preference - LLSD access_prefs = LLSD::emptyMap(); - access_prefs["max"] = LLViewerRegion::accessToShortString(pPreferredMaturity); - - LLSD body = LLSD::emptyMap(); - body["access_prefs"] = access_prefs; - llinfos << "Sending viewer preferred maturity to '" << LLViewerRegion::accessToString(pPreferredMaturity) - << "' via capability to: " << url << llendl; - LLSD headers; - LLHTTPClient::post(url, body, responderPtr, headers, 30.0f); - } - } + 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) @@ -1091,7 +1125,7 @@ void LLPanelEditWearable::saveChanges(bool force_save_as) gAgentWearables.saveWearable(mWearablePtr->getType(), index, TRUE, new_name); } - LLPanelEditWearable::incrementCofVersion(); + LLPanelEditWearable::incrementCofVersion(0); } void LLPanelEditWearable::revertChanges() -- cgit v1.2.3 From 2aa56069f458441daa74a86a8805763482f02fd6 Mon Sep 17 00:00:00 2001 From: Logan Dethrow Date: Mon, 19 Nov 2012 14:26:59 -0500 Subject: WIP SH-3339 Only try to increment the cof version if in a server bake region. --- indra/newview/llpaneleditwearable.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'indra/newview/llpaneleditwearable.cpp') diff --git a/indra/newview/llpaneleditwearable.cpp b/indra/newview/llpaneleditwearable.cpp index 997edbab07..ad55936cab 100644 --- a/indra/newview/llpaneleditwearable.cpp +++ b/indra/newview/llpaneleditwearable.cpp @@ -1070,6 +1070,12 @@ void LLIncrementCofVersionResponder::error(U32 pStatus, const std::string& pReas LLPanelEditWearable::incrementCofVersion(mRetries++); } +//static +void LLPanelEditWearable::incrementCofVersion() +{ + incrementCofVersion(0); +} + //static void LLPanelEditWearable::incrementCofVersion(S32 retries) { @@ -1125,7 +1131,10 @@ void LLPanelEditWearable::saveChanges(bool force_save_as) gAgentWearables.saveWearable(mWearablePtr->getType(), index, TRUE, new_name); } - LLPanelEditWearable::incrementCofVersion(0); + if (gAgentAvatarp->isUsingServerBakes()) + { + LLPanelEditWearable::incrementCofVersion(0); + } } void LLPanelEditWearable::revertChanges() -- cgit v1.2.3 From 81219ad03b59a5fcd80ee450b7606c6bb64f4c7d Mon Sep 17 00:00:00 2001 From: Logan Dethrow Date: Mon, 19 Nov 2012 16:30:14 -0500 Subject: Moved implementation of incrementCofVersion to llappearancemgr.cpp. Changed retry logic to use the more robust mRetryPolicy instead of my own previous implementation. --- indra/newview/llpaneleditwearable.cpp | 79 +---------------------------------- 1 file changed, 1 insertion(+), 78 deletions(-) (limited to 'indra/newview/llpaneleditwearable.cpp') 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(); } } -- cgit v1.2.3 From 632addf63dd6db5cffc18fd351b1899b30fc9062 Mon Sep 17 00:00:00 2001 From: Logan Dethrow Date: Mon, 19 Nov 2012 16:56:03 -0500 Subject: Removed a few unnecessary include lines. --- indra/newview/llpaneleditwearable.cpp | 3 --- 1 file changed, 3 deletions(-) (limited to 'indra/newview/llpaneleditwearable.cpp') diff --git a/indra/newview/llpaneleditwearable.cpp b/indra/newview/llpaneleditwearable.cpp index 2bc952dcae..3e7db06bdf 100644 --- a/indra/newview/llpaneleditwearable.cpp +++ b/indra/newview/llpaneleditwearable.cpp @@ -26,8 +26,6 @@ #include "llviewerprecompiledheaders.h" -#include - #include "llpaneleditwearable.h" #include "llpanel.h" #include "llviewerwearable.h" @@ -49,7 +47,6 @@ #include "llscrollingpanelparam.h" #include "llradiogroup.h" #include "llnotificationsutil.h" -#include "llhttpclient.h" #include "llcolorswatch.h" #include "lltexturectrl.h" -- cgit v1.2.3 From 3565f6f36db90e1a9a5918d8087f9dc0ab61eb69 Mon Sep 17 00:00:00 2001 From: Logan Dethrow Date: Thu, 13 Dec 2012 18:07:50 -0500 Subject: WIP SH-3339. Commit to merge from trunk to get build fixes, etc. --- indra/newview/llpaneleditwearable.cpp | 54 +++++++++++++++++++++-------------- 1 file changed, 32 insertions(+), 22 deletions(-) (limited to 'indra/newview/llpaneleditwearable.cpp') diff --git a/indra/newview/llpaneleditwearable.cpp b/indra/newview/llpaneleditwearable.cpp index 3e7db06bdf..650e1809cf 100644 --- a/indra/newview/llpaneleditwearable.cpp +++ b/indra/newview/llpaneleditwearable.cpp @@ -1028,33 +1028,43 @@ void LLPanelEditWearable::updatePanelPickerControls(LLWearableType::EType type) } } +void LLPanelEditWearable::incrementCofVersionLegacy() +{ + +} + void LLPanelEditWearable::saveChanges(bool force_save_as) { - if (!mWearablePtr || !isDirty()) - { - // do nothing if no unsaved changes - return; - } + if (!mWearablePtr || !isDirty()) + { + // do nothing if no unsaved changes + return; + } - U32 index = gAgentWearables.getWearableIndex(mWearablePtr); + U32 index = gAgentWearables.getWearableIndex(mWearablePtr); - std::string new_name = mNameEditor->getText(); - if (force_save_as) - { - // the name of the wearable has changed, re-save wearable with new name - LLAppearanceMgr::instance().removeCOFItemLinks(mWearablePtr->getItemID()); - gAgentWearables.saveWearableAs(mWearablePtr->getType(), index, new_name, FALSE); - mNameEditor->setText(mWearableItem->getName()); - } - else - { - gAgentWearables.saveWearable(mWearablePtr->getType(), index, TRUE, new_name); - } + std::string new_name = mNameEditor->getText(); + if (force_save_as) + { + // the name of the wearable has changed, re-save wearable with new name + LLAppearanceMgr::instance().removeCOFItemLinks(mWearablePtr->getItemID()); + gAgentWearables.saveWearableAs(mWearablePtr->getType(), index, new_name, FALSE); + mNameEditor->setText(mWearableItem->getName()); + } + else + { + gAgentWearables.saveWearable(mWearablePtr->getType(), index, TRUE, new_name); + } - if (gAgentAvatarp->isUsingServerBakes()) - { - LLAppearanceMgr::getInstance()->incrementCofVersion(); - } + if (getRegion() && getRegion()->getCentralBakeVersion() > 0) + { + LLAppearanceMgr::getInstance()->incrementCofVersion(); + } + else + { + // *HACK This should be removed when all regions support the IncrementCOFVersion capability. + incrementCofVersionLegacy(); + } } void LLPanelEditWearable::revertChanges() -- cgit v1.2.3