diff options
Diffstat (limited to 'indra/newview/llfloaterregioninfo.cpp')
-rwxr-xr-x | indra/newview/llfloaterregioninfo.cpp | 221 |
1 files changed, 221 insertions, 0 deletions
diff --git a/indra/newview/llfloaterregioninfo.cpp b/indra/newview/llfloaterregioninfo.cpp index 73c0963a1d..43f0ba10a1 100755 --- a/indra/newview/llfloaterregioninfo.cpp +++ b/indra/newview/llfloaterregioninfo.cpp @@ -92,6 +92,11 @@ #include "llagentui.h" #include "llmeshrepository.h" #include "llfloaterregionrestarting.h" +#include "llpanelexperiencelisteditor.h" +#include <boost/function.hpp> +#include "llfloaterexperiencepicker.h" +#include "llexperiencecache.h" +#include "llpanelexperiences.h" const S32 TERRAIN_TEXTURE_COUNT = 4; const S32 CORNER_COUNT = 4; @@ -215,6 +220,14 @@ BOOL LLFloaterRegionInfo::postBuild() panel->buildFromFile("panel_region_debug.xml"); mTab->addTabPanel(panel); + if(!gAgent.getRegion()->getCapability("RegionExperiences").empty()) + { + panel = new LLPanelRegionExperiences; + mInfoPanels.push_back(panel); + panel->buildFromFile("panel_region_experiences.xml"); + mTab->addTabPanel(panel); + } + gMessageSystem->setHandlerFunc( "EstateOwnerMessage", &processEstateOwnerRequest); @@ -3464,3 +3477,211 @@ void LLPanelEnvironmentInfo::onRegionSettingsApplied(bool ok) LLEnvManagerNew::instance().requestRegionSettings(); } } + +BOOL LLPanelRegionExperiences::postBuild() +{ + mAllowed = setupList("panel_allowed"); + mTrusted = setupList("panel_trusted"); + mBlocked = setupList("panel_blocked"); + mOwned = LLPanelExperiences::create("owned"); + LLPanel* pOwned = findChild<LLPanel>("panel_owned"); + pOwned->addChild(mOwned); + mOwned->setShape(pOwned->getRect()); + return LLPanelRegionInfo::postBuild(); +} + +LLPanelExperienceListEditor* LLPanelRegionExperiences::setupList( const char* control_name ) +{ + LLPanelExperienceListEditor* child = findChild<LLPanelExperienceListEditor>(control_name); + if(child) + { + child->getChild<LLTextBox>("text_name")->setText(getString(control_name)); + } + + return child; +} + + + + +boost::signals2::connection LLPanelRegionExperiences::processResponse( LLPanelExperienceListEditor* panel, boost::signals2::connection& conn, const LLSD& content ) +{ + if(conn.connected()) + { + conn.disconnect(); + } + panel->setExperienceIds(content); + + return panel->setChangedCallback(boost::bind(&LLPanelRegionExperiences::listChanged, this)); +} + + + +void LLPanelRegionExperiences::processResponse( const LLSD& content ) +{ + mAllowedConnection=processResponse(mAllowed, mAllowedConnection, content["allowed"]); + mBlockedConnection=processResponse(mBlocked, mBlockedConnection, content["blocked"]); + mTrustedConnection=processResponse(mTrusted, mTrustedConnection, content["trusted"]); + disableButton("apply_btn"); +} + + +class LLRegionExperienceResponder : public LLHTTPClient::Responder +{ +public: + typedef boost::function<void (const LLSD&)> callback_t; + + callback_t mCallback; + + LLRegionExperienceResponder(callback_t callback) : mCallback(callback) { } + + void completed(U32 status, const std::string& reason, const LLSD& content) + { + if (isGoodStatus(status)) + { + mCallback(content); + } + else + { + llwarns << "experience responder failed [status:" << status << "]: " << content << llendl; + } + } +}; + + +void LLPanelRegionExperiences::infoCallback(LLHandle<LLPanelRegionExperiences> handle, const LLSD& content) +{ + + if(handle.isDead()) + return; + + LLPanelRegionExperiences* floater = handle.get(); + if (floater) + { + floater->processResponse(content); + } + +} + + +void LLPanelRegionExperiences::ownedCallback( LLHandle<LLPanelRegionExperiences> handle, const LLSD& content ) +{ + if(handle.isDead()) + return; + + LLPanelRegionExperiences* floater = handle.get(); + if (floater && content.has("experience_ids")) + { + const LLSD& ids = content["experience_ids"]; + floater->getChild<LLButton>("btn_buy")->setEnabled(ids.beginArray() == ids.endArray()); + + floater->setOwnedExperiences(content["experience_ids"]); + } +} + + +bool LLPanelRegionExperiences::FilterExisting(const LLSD& experience) +{ + LLUUID id = experience[LLExperienceCache::EXPERIENCE_ID].asUUID(); + return mAllowed->getExperienceIds().find(id) != mAllowed->getExperienceIds().end() || + mBlocked->getExperienceIds().find(id) != mBlocked->getExperienceIds().end() || + mTrusted->getExperienceIds().find(id) != mTrusted->getExperienceIds().end() ; +} + + +bool LLPanelRegionExperiences::refreshFromRegion(LLViewerRegion* region) +{ + BOOL allow_modify = gAgent.isGodlike() || (region && region->canManageEstate()); + + mAllowed->loading(); + mAllowed->setReadonly(!allow_modify); + // remove grid-wide experiences + mAllowed->addFilter(boost::bind(LLFloaterExperiencePicker::FilterWithProperty, _1, LLExperienceCache::PROPERTY_GRID)); + // and stuff only in another list + mAllowed->addFilter(boost::bind(&LLPanelRegionExperiences::FilterExisting, this, _1)); + + mBlocked->loading(); + mBlocked->setReadonly(!allow_modify); + // only grid-wide experiences + mBlocked->addFilter(boost::bind(LLFloaterExperiencePicker::FilterWithoutProperty, _1, LLExperienceCache::PROPERTY_GRID)); + // but not privileged ones + mBlocked->addFilter(boost::bind(LLFloaterExperiencePicker::FilterWithProperty, _1, LLExperienceCache::PROPERTY_PRIVILEGED)); + mBlocked->addFilter(boost::bind(&LLPanelRegionExperiences::FilterExisting, this, _1)); + + mTrusted->loading(); + mTrusted->setReadonly(!allow_modify); + mTrusted->addFilter(boost::bind(&LLPanelRegionExperiences::FilterExisting, this, _1)); + + std::string url = region->getCapability("AgentExperiences"); + mOwned->getParent()->setVisible(!url.empty() && region && region->canManageEstate()); + + if(!url.empty()) + { + LLHTTPClient::get(url, new LLRegionExperienceResponder(boost::bind(&LLPanelRegionExperiences::ownedCallback, + getDerivedHandle<LLPanelRegionExperiences>(), _1))); + + getChild<LLButton>("btn_buy")->setCommitCallback(boost::bind(&LLPanelRegionExperiences::sendPurchaseRequest, this)); + } + + url = region->getCapability("RegionExperiences"); + if (!url.empty()) + { + LLHTTPClient::get(url, new LLRegionExperienceResponder(boost::bind(&LLPanelRegionExperiences::infoCallback, + getDerivedHandle<LLPanelRegionExperiences>(), _1))); + } + return LLPanelRegionInfo::refreshFromRegion(region); +} + +LLSD LLPanelRegionExperiences::addIds(LLPanelExperienceListEditor* panel) +{ + LLSD ids; + const uuid_list_t& id_list = panel->getExperienceIds(); + for(uuid_list_t::const_iterator it = id_list.begin(); it != id_list.end(); ++it) + { + ids.append(*it); + } + return ids; +} + + +BOOL LLPanelRegionExperiences::sendUpdate() +{ + LLViewerRegion* region = gAgent.getRegion(); + std::string url = region->getCapability("RegionExperiences"); + if (!url.empty()) + { + LLSD content; + + content["allowed"]=addIds(mAllowed); + content["blocked"]=addIds(mBlocked); + content["trusted"]=addIds(mTrusted); + + LLHTTPClient::post(url, content, new LLRegionExperienceResponder(boost::bind(&LLPanelRegionExperiences::infoCallback, + getDerivedHandle<LLPanelRegionExperiences>(), _1))); + } + + return TRUE; +} + +void LLPanelRegionExperiences::listChanged() +{ + onChangeAnything(); +} + +void LLPanelRegionExperiences::setOwnedExperiences( const LLSD& experiences ) +{ + mOwned->setExperienceList(experiences); +} + +void LLPanelRegionExperiences::sendPurchaseRequest() const +{ + LLViewerRegion* region = gAgent.getRegion(); + std::string url = region->getCapability("AgentExperiences"); + if(!url.empty()) + { + LLSD content; + + LLHTTPClient::post(url, content, new LLRegionExperienceResponder(boost::bind(&LLPanelRegionExperiences::ownedCallback, + getDerivedHandle<LLPanelRegionExperiences>(), _1))); + } +} |