summaryrefslogtreecommitdiff
path: root/indra/newview/llfloaterregioninfo.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llfloaterregioninfo.cpp')
-rwxr-xr-xindra/newview/llfloaterregioninfo.cpp232
1 files changed, 232 insertions, 0 deletions
diff --git a/indra/newview/llfloaterregioninfo.cpp b/indra/newview/llfloaterregioninfo.cpp
index 73c0963a1d..2522b7bf18 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;
@@ -126,6 +131,18 @@ public:
const sparam_t& strings);
};
+class LLDispatchSetEstateExperience : public LLDispatchHandler
+{
+public:
+ virtual bool operator()(
+ const LLDispatcher* dispatcher,
+ const std::string& key,
+ const LLUUID& invoice,
+ const sparam_t& strings);
+
+ LLSD getIDs( sparam_t::const_iterator it, sparam_t::const_iterator end, S32 count );
+};
+
/*
void unpack_request_params(
@@ -215,6 +232,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);
@@ -444,6 +469,16 @@ LLPanelRegionTerrainInfo* LLFloaterRegionInfo::getPanelRegionTerrain()
return panel;
}
+LLPanelRegionExperiences* LLFloaterRegionInfo::getPanelExperiences()
+{
+ LLFloaterRegionInfo* floater = LLFloaterReg::getTypedInstance<LLFloaterRegionInfo>("region_info");
+ if (!floater) return NULL;
+ LLTabContainer* tab = floater->getChild<LLTabContainer>("region_panels");
+ return (LLPanelRegionExperiences*)tab->getChild<LLPanel>("Experiences");
+}
+
+
+
void LLFloaterRegionInfo::onTabSelected(const LLSD& param)
{
LLPanel* active_panel = getChild<LLPanel>(param.asString());
@@ -1363,6 +1398,11 @@ void LLPanelEstateInfo::initDispatch(LLDispatcher& dispatch)
static LLDispatchSetEstateAccess set_access;
dispatch.addHandler(name, &set_access);
+
+ name.assign("setexperience");
+ static LLDispatchSetEstateExperience set_experience;
+ dispatch.addHandler(name, &set_experience);
+
estate_dispatch_initialized = true;
}
@@ -2873,6 +2913,56 @@ bool LLDispatchSetEstateAccess::operator()(
return true;
}
+LLSD LLDispatchSetEstateExperience::getIDs( sparam_t::const_iterator it, sparam_t::const_iterator end, S32 count )
+{
+ LLSD idList = LLSD::emptyArray();
+ LLUUID id;
+ while(count--> 0)
+ {
+ memcpy(id.mData, (*(it++)).data(), UUID_BYTES);
+ idList.append(id);
+ }
+ return idList;
+}
+
+// key = "setexperience"
+// strings[0] = str(estate_id)
+// strings[1] = str(send_to_agent_only)
+// strings[2] = str(num blocked)
+// strings[3] = str(num trusted)
+// strings[4] = str(num allowed)
+// strings[8] = bin(uuid) ...
+// ...
+bool LLDispatchSetEstateExperience::operator()(
+ const LLDispatcher* dispatcher,
+ const std::string& key,
+ const LLUUID& invoice,
+ const sparam_t& strings)
+{
+ LLPanelRegionExperiences* panel = LLFloaterRegionInfo::getPanelExperiences();
+ if (!panel) return true;
+
+ sparam_t::const_iterator it = strings.begin();
+ ++it; // U32 estate_id = strtol((*it).c_str(), NULL, 10);
+ ++it; // U32 send_to_agent_only = strtoul((*(++it)).c_str(), NULL, 10);
+
+ LLUUID id;
+ S32 num_blocked = strtol((*(it++)).c_str(), NULL, 10);
+ S32 num_trusted = strtol((*(it++)).c_str(), NULL, 10);
+ S32 num_allowed = strtol((*(it++)).c_str(), NULL, 10);
+
+ LLSD ids = LLSD::emptyMap()
+ .with("blocked", getIDs(it, strings.end(), num_blocked))
+ .with("trusted", getIDs(it + (num_blocked), strings.end(), num_trusted))
+ .with("allowed", getIDs(it + (num_blocked+num_trusted), strings.end(), num_allowed));
+
+ panel->processResponse(ids);
+
+ return true;
+}
+
+
+
LLPanelEnvironmentInfo::LLPanelEnvironmentInfo()
: mEnableEditing(false),
mRegionSettingsRadioGroup(NULL),
@@ -3464,3 +3554,145 @@ void LLPanelEnvironmentInfo::onRegionSettingsApplied(bool ok)
LLEnvManagerNew::instance().requestRegionSettings();
}
}
+
+BOOL LLPanelRegionExperiences::postBuild()
+{
+ mAllowed = setupList("panel_allowed");
+ mTrusted = setupList("panel_trusted");
+ mBlocked = setupList("panel_blocked");
+
+ mAllowed->setAddedCallback( boost::bind(&LLPanelRegionExperiences::itemChanged, this, ESTATE_EXPERIENCE_ALLOWED_ADD, _1));
+ mAllowed->setRemovedCallback( boost::bind(&LLPanelRegionExperiences::itemChanged, this, ESTATE_EXPERIENCE_ALLOWED_REMOVE, _1));
+ mBlocked->setAddedCallback( boost::bind(&LLPanelRegionExperiences::itemChanged, this, ESTATE_EXPERIENCE_BLOCKED_ADD, _1));
+ mBlocked->setRemovedCallback( boost::bind(&LLPanelRegionExperiences::itemChanged, this, ESTATE_EXPERIENCE_BLOCKED_REMOVE, _1));
+ mTrusted->setAddedCallback( boost::bind(&LLPanelRegionExperiences::itemChanged, this, ESTATE_EXPERIENCE_TRUSTED_ADD, _1));
+ mTrusted->setRemovedCallback( boost::bind(&LLPanelRegionExperiences::itemChanged, this, ESTATE_EXPERIENCE_TRUSTED_REMOVE, _1));
+
+ 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;
+}
+
+
+void LLPanelRegionExperiences::processResponse( const LLSD& content )
+{
+ mAllowed->setExperienceIds(content["allowed"]);
+ mBlocked->setExperienceIds(content["blocked"]);
+ mTrusted->setExperienceIds(content["trusted"]);
+}
+
+
+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);
+ }
+}
+
+
+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));
+
+ 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));
+
+ mTrusted->loading();
+ mTrusted->setReadonly(!allow_modify);
+
+ std::string 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::itemChanged( U32 event_type, const LLUUID& id )
+{
+ strings_t str(3, std::string());
+ gAgent.getID().toString(str[0]);
+ str[1] = llformat("%u", event_type);
+ id.toString(str[2]);
+
+ sendEstateOwnerMessage(gMessageSystem, "estateexperiencedelta", LLFloaterRegionInfo::getLastInvoice(), str);
+ onChangeAnything();
+}