diff options
Diffstat (limited to 'indra/newview/llfloaterregioninfo.cpp')
-rw-r--r-- | indra/newview/llfloaterregioninfo.cpp | 1464 |
1 files changed, 398 insertions, 1066 deletions
diff --git a/indra/newview/llfloaterregioninfo.cpp b/indra/newview/llfloaterregioninfo.cpp index a0522c99c2..9f33feb901 100644 --- a/indra/newview/llfloaterregioninfo.cpp +++ b/indra/newview/llfloaterregioninfo.cpp @@ -52,8 +52,6 @@ #include "llbutton.h" #include "llcheckboxctrl.h" #include "llcombobox.h" -#include "lldaycyclemanager.h" -#include "llenvmanager.h" #include "llestateinfomodel.h" #include "llfilepicker.h" #include "llfloatergodtools.h" // for send_sim_wide_deletes() @@ -87,7 +85,6 @@ #include "llviewertexteditor.h" #include "llviewerwindow.h" #include "llvlcomposition.h" -#include "llwaterparammanager.h" #include "lltrans.h" #include "llagentui.h" #include "llmeshrepository.h" @@ -98,6 +95,7 @@ #include "llexperiencecache.h" #include "llpanelexperiences.h" #include "llcorehttputil.h" +#include "llenvironment.h" const S32 TERRAIN_TEXTURE_COUNT = 4; const S32 CORNER_COUNT = 4; @@ -108,43 +106,6 @@ const S32 CORNER_COUNT = 4; /// Local class declaration ///---------------------------------------------------------------------------- -class LLDispatchEstateUpdateInfo : public LLDispatchHandler -{ -public: - LLDispatchEstateUpdateInfo() {} - virtual ~LLDispatchEstateUpdateInfo() {} - virtual bool operator()( - const LLDispatcher* dispatcher, - const std::string& key, - const LLUUID& invoice, - const sparam_t& strings); -}; - -class LLDispatchSetEstateAccess : public LLDispatchHandler -{ -public: - LLDispatchSetEstateAccess() {} - virtual ~LLDispatchSetEstateAccess() {} - virtual bool operator()( - const LLDispatcher* dispatcher, - const std::string& key, - const LLUUID& invoice, - 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( LLMessageSystem* msg, @@ -178,6 +139,40 @@ void unpack_request_params( } */ +class LLPanelRegionEnvironment : public LLPanelEnvironmentInfo +{ +public: + LLPanelRegionEnvironment(); + virtual ~LLPanelRegionEnvironment(); + + virtual void refresh() override; + + virtual bool isRegion() const override { return true; } + virtual LLParcel * getParcel() override { return nullptr; } + virtual bool canEdit() override { return LLEnvironment::instance().canAgentUpdateRegionEnvironment(); } + virtual bool isLargeEnough() override { return true; } // regions are always large enough. + + bool refreshFromRegion(LLViewerRegion* region); + + virtual BOOL postBuild() override; + virtual void onOpen(const LLSD& key) override {}; + + virtual S32 getParcelId() override { return INVALID_PARCEL_ID; } + +protected: + static const U32 DIRTY_FLAG_OVERRIDE; + + virtual void refreshFromSource() override; + + bool confirmUpdateEstateEnvironment(const LLSD& notification, const LLSD& response); + + void onChkAllowOverride(bool value); + +private: + bool mAllowOverrideRestore; + connection_t mCommitConnect; +}; + bool estate_dispatch_initialized = false; @@ -187,12 +182,10 @@ bool estate_dispatch_initialized = false; /// LLFloaterRegionInfo ///---------------------------------------------------------------------------- -//S32 LLFloaterRegionInfo::sRequestSerial = 0; -LLUUID LLFloaterRegionInfo::sRequestInvoice; - - LLFloaterRegionInfo::LLFloaterRegionInfo(const LLSD& seed) - : LLFloater(seed) + : LLFloater(seed), + mEnvironmentPanel(NULL), + mRegionChangedCallback() {} BOOL LLFloaterRegionInfo::postBuild() @@ -223,10 +216,10 @@ BOOL LLFloaterRegionInfo::postBuild() panel->buildFromFile("panel_region_terrain.xml"); mTab->addTabPanel(panel); - panel = new LLPanelEnvironmentInfo; - mInfoPanels.push_back(panel); - panel->buildFromFile("panel_region_environment.xml"); - mTab->addTabPanel(panel); + mEnvironmentPanel = new LLPanelRegionEnvironment; + mEnvironmentPanel->buildFromFile("panel_region_environment.xml"); +// mEnvironmentPanel->configureForRegion(); + mTab->addTabPanel(mEnvironmentPanel); panel = new LLPanelRegionDebugInfo; mInfoPanels.push_back(panel); @@ -245,19 +238,20 @@ BOOL LLFloaterRegionInfo::postBuild() panel->buildFromFile("panel_region_experiences.xml"); mTab->addTabPanel(panel); } - - gMessageSystem->setHandlerFunc( - "EstateOwnerMessage", - &processEstateOwnerRequest); // Request region info when agent region changes. - gAgent.addRegionChangedCallback(boost::bind(&LLFloaterRegionInfo::requestRegionInfo, this)); + mRegionChangedCallback = gAgent.addRegionChangedCallback(boost::bind(&LLFloaterRegionInfo::onRegionChanged, this)); return TRUE; } LLFloaterRegionInfo::~LLFloaterRegionInfo() -{} +{ + if (mRegionChangedCallback.connected()) + { + mRegionChangedCallback.disconnect(); + } +} void LLFloaterRegionInfo::onOpen(const LLSD& key) { @@ -266,20 +260,29 @@ void LLFloaterRegionInfo::onOpen(const LLSD& key) disableTabCtrls(); return; } - refreshFromRegion(gAgent.getRegion()); - requestRegionInfo(); + LLEstateInfoModel::instance().clearRegion(); + requestRegionInfo(); // will cause refreshFromRegion() requestMeshRezInfo(); } -// static -void LLFloaterRegionInfo::requestRegionInfo() +void LLFloaterRegionInfo::onRegionChanged() { - LLTabContainer* tab = getChild<LLTabContainer>("region_panels"); + if (getVisible()) //otherwise onOpen will do request + { + requestRegionInfo(); + } +} - tab->getChild<LLPanel>("General")->setCtrlsEnabled(FALSE); - tab->getChild<LLPanel>("Debug")->setCtrlsEnabled(FALSE); - tab->getChild<LLPanel>("Terrain")->setCtrlsEnabled(FALSE); - tab->getChild<LLPanel>("Estate")->setCtrlsEnabled(FALSE); +void LLFloaterRegionInfo::requestRegionInfo() +{ + LLTabContainer* tab = findChild<LLTabContainer>("region_panels"); + if (tab) + { + tab->getChild<LLPanel>("General")->setCtrlsEnabled(FALSE); + tab->getChild<LLPanel>("Debug")->setCtrlsEnabled(FALSE); + tab->getChild<LLPanel>("Terrain")->setCtrlsEnabled(FALSE); + tab->getChild<LLPanel>("Estate")->setCtrlsEnabled(FALSE); + } // Must allow anyone to request the RegionInfo data // so non-owners/non-gods can see the values. @@ -293,42 +296,6 @@ void LLFloaterRegionInfo::requestRegionInfo() } // static -void LLFloaterRegionInfo::processEstateOwnerRequest(LLMessageSystem* msg,void**) -{ - static LLDispatcher dispatch; - LLFloaterRegionInfo* floater = LLFloaterReg::getTypedInstance<LLFloaterRegionInfo>("region_info"); - if(!floater) - { - return; - } - - if (!estate_dispatch_initialized) - { - LLPanelEstateInfo::initDispatch(dispatch); - } - - LLTabContainer* tab = floater->getChild<LLTabContainer>("region_panels"); - LLPanelEstateInfo* panel = (LLPanelEstateInfo*)tab->getChild<LLPanel>("Estate"); - - // unpack the message - std::string request; - LLUUID invoice; - LLDispatcher::sparam_t strings; - LLDispatcher::unpackMessage(msg, request, invoice, strings); - if(invoice != getLastInvoice()) - { - LL_WARNS() << "Mismatched Estate message: " << request << LL_ENDL; - return; - } - - //dispatch the message - dispatch.dispatch(request, invoice, strings); - - panel->updateControls(gAgent.getRegion()); -} - - -// static void LLFloaterRegionInfo::processRegionInfo(LLMessageSystem* msg) { LLPanel* panel; @@ -337,13 +304,13 @@ void LLFloaterRegionInfo::processRegionInfo(LLMessageSystem* msg) { return; } - +#if 0 // We need to re-request environment setting here, // otherwise after we apply (send) updated region settings we won't get them back, // so our environment won't be updated. // This is also the way to know about externally changed region environment. LLEnvManagerNew::instance().requestRegionSettings(); - +#endif LLTabContainer* tab = floater->getChild<LLTabContainer>("region_panels"); LLViewerRegion* region = gAgent.getRegion(); @@ -450,7 +417,12 @@ void LLFloaterRegionInfo::processRegionInfo(LLMessageSystem* msg) panel->setCtrlsEnabled(allow_modify); - floater->refreshFromRegion( gAgent.getRegion() ); + if (floater->getVisible()) + { + // Note: region info also causes LLRegionInfoModel::instance().update(msg); -> requestRegion(); -> changed message + // we need to know env version here and in update(msg) to know when to request and when not to, when to filter 'changed' + floater->refreshFromRegion(gAgent.getRegion()); + } // else will rerequest on onOpen either way } // static @@ -543,6 +515,7 @@ void LLFloaterRegionInfo::refreshFromRegion(LLViewerRegion* region) std::mem_fun(&LLPanelRegionInfo::refreshFromRegion), #endif region)); + mEnvironmentPanel->refreshFromRegion(region); } // public @@ -553,6 +526,7 @@ void LLFloaterRegionInfo::refresh() { (*iter)->refresh(); } + mEnvironmentPanel->refresh(); } void LLFloaterRegionInfo::enableTopButtons() @@ -635,43 +609,10 @@ void LLPanelRegionInfo::updateChild(LLUICtrl* child_ctr) // virtual bool LLPanelRegionInfo::refreshFromRegion(LLViewerRegion* region) { - if (region) mHost = region->getHost(); + LLEstateInfoModel::instance().setRegion(region); return true; } -void LLPanelRegionInfo::sendEstateOwnerMessage( - LLMessageSystem* msg, - const std::string& request, - const LLUUID& invoice, - const strings_t& strings) -{ - LL_INFOS() << "Sending estate request '" << request << "'" << LL_ENDL; - msg->newMessage("EstateOwnerMessage"); - msg->nextBlockFast(_PREHASH_AgentData); - msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); - msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); - msg->addUUIDFast(_PREHASH_TransactionID, LLUUID::null); //not used - msg->nextBlock("MethodData"); - msg->addString("Method", request); - msg->addUUID("Invoice", invoice); - if(strings.empty()) - { - msg->nextBlock("ParamList"); - msg->addString("Parameter", NULL); - } - else - { - strings_t::const_iterator it = strings.begin(); - strings_t::const_iterator end = strings.end(); - for(; it != end; ++it) - { - msg->nextBlock("ParamList"); - msg->addString("Parameter", *it); - } - } - msg->sendReliable(mHost); -} - void LLPanelRegionInfo::enableButton(const std::string& btn_name, BOOL enable) { LLView* button = findChildView(btn_name); @@ -805,8 +746,7 @@ void LLPanelRegionGeneralInfo::onKickCommit(const uuid_vec_t& ids) ids[0].toString(buffer); strings.push_back(strings_t::value_type(buffer)); - LLUUID invoice(LLFloaterRegionInfo::getLastInvoice()); - sendEstateOwnerMessage(gMessageSystem, "teleporthomeuser", invoice, strings); + LLEstateInfoModel::instance().sendEstateOwnerMessage("teleporthomeuser", strings); } } @@ -831,9 +771,8 @@ bool LLPanelRegionGeneralInfo::onKickAllCommit(const LLSD& notification, const L gAgent.getID().toString(buffer); strings.push_back(buffer); - LLUUID invoice(LLFloaterRegionInfo::getLastInvoice()); // historical message name - sendEstateOwnerMessage(gMessageSystem, "teleporthomeallusers", invoice, strings); + LLEstateInfoModel::instance().sendEstateOwnerMessage("teleporthomeallusers", strings); } return false; } @@ -872,8 +811,7 @@ bool LLPanelRegionGeneralInfo::onMessageCommit(const LLSD& notification, const L LLAgentUI::buildFullname(name); strings.push_back(strings_t::value_type(name)); strings.push_back(strings_t::value_type(text)); - LLUUID invoice(LLFloaterRegionInfo::getLastInvoice()); - sendEstateOwnerMessage(gMessageSystem, "simulatormessage", invoice, strings); + LLEstateInfoModel::instance().sendEstateOwnerMessage("simulatormessage", strings); return false; } @@ -959,8 +897,7 @@ BOOL LLPanelRegionGeneralInfo::sendUpdate() buffer = llformat("%s", (getChild<LLUICtrl>("allow_parcel_changes_check")->getValue().asBoolean() ? "Y" : "N")); strings.push_back(strings_t::value_type(buffer)); - LLUUID invoice(LLFloaterRegionInfo::getLastInvoice()); - sendEstateOwnerMessage(gMessageSystem, "setregioninfo", invoice, strings); + LLEstateInfoModel::instance().sendEstateOwnerMessage("setregioninfo", strings); } // if we changed access levels, tell user about it @@ -1032,8 +969,7 @@ BOOL LLPanelRegionDebugInfo::sendUpdate() buffer = llformat("%s", (getChild<LLUICtrl>("disable_physics_check")->getValue().asBoolean() ? "Y" : "N")); strings.push_back(buffer); - LLUUID invoice(LLFloaterRegionInfo::getLastInvoice()); - sendEstateOwnerMessage(gMessageSystem, "setregiondebug", invoice, strings); + LLEstateInfoModel::instance().sendEstateOwnerMessage("setregiondebug", strings); return TRUE; } @@ -1103,9 +1039,7 @@ bool LLPanelRegionDebugInfo::callbackReturn(const LLSD& notification, const LLSD strings.push_back(llformat("%d", flags)); strings.push_back(target_avatar.asString()); - LLUUID invoice(LLFloaterRegionInfo::getLastInvoice()); - - sendEstateOwnerMessage(gMessageSystem, "estateobjectreturn", invoice, strings); + LLEstateInfoModel::instance().sendEstateOwnerMessage("estateobjectreturn", strings); } else { @@ -1123,7 +1057,6 @@ void LLPanelRegionDebugInfo::onClickTopColliders(void* data) LLPanelRegionDebugInfo* self = (LLPanelRegionDebugInfo*)data; strings_t strings; strings.push_back("1"); // one physics step - LLUUID invoice(LLFloaterRegionInfo::getLastInvoice()); LLFloaterTopObjects* instance = LLFloaterReg::getTypedInstance<LLFloaterTopObjects>("top_objects"); if(!instance) return; LLFloaterReg::showInstance("top_objects"); @@ -1133,7 +1066,7 @@ void LLPanelRegionDebugInfo::onClickTopColliders(void* data) self->getChildView("top_colliders_btn")->setEnabled(false); self->getChildView("top_scripts_btn")->setEnabled(false); - self->sendEstateOwnerMessage(gMessageSystem, "colliders", invoice, strings); + LLEstateInfoModel::instance().sendEstateOwnerMessage("colliders", strings); } // static @@ -1142,7 +1075,6 @@ void LLPanelRegionDebugInfo::onClickTopScripts(void* data) LLPanelRegionDebugInfo* self = (LLPanelRegionDebugInfo*)data; strings_t strings; strings.push_back("6"); // top 5 scripts - LLUUID invoice(LLFloaterRegionInfo::getLastInvoice()); LLFloaterTopObjects* instance = LLFloaterReg::getTypedInstance<LLFloaterTopObjects>("top_objects"); if(!instance) return; LLFloaterReg::showInstance("top_objects"); @@ -1152,7 +1084,7 @@ void LLPanelRegionDebugInfo::onClickTopScripts(void* data) self->getChildView("top_colliders_btn")->setEnabled(false); self->getChildView("top_scripts_btn")->setEnabled(false); - self->sendEstateOwnerMessage(gMessageSystem, "scripts", invoice, strings); + LLEstateInfoModel::instance().sendEstateOwnerMessage("scripts", strings); } // static @@ -1169,19 +1101,16 @@ bool LLPanelRegionDebugInfo::callbackRestart(const LLSD& notification, const LLS strings_t strings; strings.push_back("120"); - LLUUID invoice(LLFloaterRegionInfo::getLastInvoice()); - sendEstateOwnerMessage(gMessageSystem, "restart", invoice, strings); + LLEstateInfoModel::instance().sendEstateOwnerMessage("restart", strings); return false; } // static void LLPanelRegionDebugInfo::onClickCancelRestart(void* data) { - LLPanelRegionDebugInfo* self = (LLPanelRegionDebugInfo*)data; strings_t strings; strings.push_back("-1"); - LLUUID invoice(LLFloaterRegionInfo::getLastInvoice()); - self->sendEstateOwnerMessage(gMessageSystem, "restart", invoice, strings); + LLEstateInfoModel::instance().sendEstateOwnerMessage("restart", strings); } // static @@ -1346,7 +1275,6 @@ BOOL LLPanelRegionTerrainInfo::sendUpdate() LL_INFOS() << "LLPanelRegionTerrainInfo::sendUpdate" << LL_ENDL; std::string buffer; strings_t strings; - LLUUID invoice(LLFloaterRegionInfo::getLastInvoice()); // update the model LLRegionInfoModel& region_info = LLRegionInfoModel::instance(); @@ -1355,7 +1283,7 @@ BOOL LLPanelRegionTerrainInfo::sendUpdate() region_info.mTerrainLowerLimit = (F32) getChild<LLUICtrl>("terrain_lower_spin")->getValue().asReal(); // and sync the region with it - region_info.sendRegionTerrain(invoice); + region_info.sendRegionTerrain(LLEstateInfoModel::instance().getLastInvoice()); // ======================================= // Assemble and send texturedetail message @@ -1383,7 +1311,6 @@ BOOL LLPanelRegionTerrainInfo::sendUpdate() LLTextureCtrl* texture_ctrl; std::string id_str; - LLMessageSystem* msg = gMessageSystem; for(S32 i = 0; i < TERRAIN_TEXTURE_COUNT; ++i) { @@ -1397,7 +1324,7 @@ BOOL LLPanelRegionTerrainInfo::sendUpdate() strings.push_back(buffer); } } - sendEstateOwnerMessage(msg, "texturedetail", invoice, strings); + LLEstateInfoModel::instance().sendEstateOwnerMessage("texturedetail", strings); strings.clear(); // ======================================== @@ -1410,13 +1337,13 @@ BOOL LLPanelRegionTerrainInfo::sendUpdate() std::string buffer3 = llformat("%d %f %f", i, (F32)getChild<LLUICtrl>(buffer)->getValue().asReal(), (F32)getChild<LLUICtrl>(buffer2)->getValue().asReal()); strings.push_back(buffer3); } - sendEstateOwnerMessage(msg, "textureheights", invoice, strings); + LLEstateInfoModel::instance().sendEstateOwnerMessage("textureheights", strings); strings.clear(); // ======================================== // Send texturecommit message - sendEstateOwnerMessage(msg, "texturecommit", invoice, strings); + LLEstateInfoModel::instance().sendEstateOwnerMessage("texturecommit", strings); return TRUE; } @@ -1456,12 +1383,10 @@ void LLPanelRegionTerrainInfo::onClickDownloadRaw(void* data) std::string filepath = picker.getFirstFile(); gXferManager->expectFileForRequest(filepath); - LLPanelRegionTerrainInfo* self = (LLPanelRegionTerrainInfo*)data; strings_t strings; strings.push_back("download filename"); strings.push_back(filepath); - LLUUID invoice(LLFloaterRegionInfo::getLastInvoice()); - self->sendEstateOwnerMessage(gMessageSystem, "terrain", invoice, strings); + LLEstateInfoModel::instance().sendEstateOwnerMessage("terrain", strings); } // static @@ -1476,12 +1401,10 @@ void LLPanelRegionTerrainInfo::onClickUploadRaw(void* data) std::string filepath = picker.getFirstFile(); gXferManager->expectFileForTransfer(filepath); - LLPanelRegionTerrainInfo* self = (LLPanelRegionTerrainInfo*)data; strings_t strings; strings.push_back("upload filename"); strings.push_back(filepath); - LLUUID invoice(LLFloaterRegionInfo::getLastInvoice()); - self->sendEstateOwnerMessage(gMessageSystem, "terrain", invoice, strings); + LLEstateInfoModel::instance().sendEstateOwnerMessage("terrain", strings); LLNotificationsUtil::add("RawUploadStarted"); } @@ -1499,8 +1422,7 @@ bool LLPanelRegionTerrainInfo::callbackBakeTerrain(const LLSD& notification, con strings_t strings; strings.push_back("bake"); - LLUUID invoice(LLFloaterRegionInfo::getLastInvoice()); - sendEstateOwnerMessage(gMessageSystem, "terrain", invoice, strings); + LLEstateInfoModel::instance().sendEstateOwnerMessage("terrain", strings); return false; } @@ -1514,33 +1436,11 @@ LLPanelEstateInfo::LLPanelEstateInfo() mEstateID(0) // invalid { LLEstateInfoModel& estate_info = LLEstateInfoModel::instance(); + estate_info.setCommitCallback(boost::bind(&LLPanelEstateInfo::refreshFromEstate, this)); estate_info.setUpdateCallback(boost::bind(&LLPanelEstateInfo::refreshFromEstate, this)); -} - -// static -void LLPanelEstateInfo::initDispatch(LLDispatcher& dispatch) -{ - std::string name; - -// name.assign("setowner"); -// static LLDispatchSetEstateOwner set_owner; -// dispatch.addHandler(name, &set_owner); - name.assign("estateupdateinfo"); - static LLDispatchEstateUpdateInfo estate_update_info; - dispatch.addHandler(name, &estate_update_info); - - name.assign("setaccess"); - 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; + estate_info.setUpdateAccessCallback(boost::bind(&LLPanelEstateInfo::refreshAccessFromEstate, this, _1)); } //--------------------------------------------------------------------------- @@ -1703,7 +1603,7 @@ bool LLPanelEstateInfo::kickUserConfirm(const LLSD& notification, const LLSD& re strings_t strings; strings.push_back(notification["payload"]["agent_id"].asString()); - sendEstateOwnerMessage(gMessageSystem, "kickestate", LLFloaterRegionInfo::getLastInvoice(), strings); + LLEstateInfoModel::instance().sendEstateOwnerMessage("kickestate", strings); break; } default: @@ -2100,7 +2000,7 @@ void LLPanelEstateInfo::sendEstateAccessDelta(U32 flags, const LLUUID& agent_or_ msg->nextBlock("MethodData"); msg->addString("Method", "estateaccessdelta"); - msg->addUUID("Invoice", LLFloaterRegionInfo::getLastInvoice()); + msg->addUUID("Invoice", LLEstateInfoModel::instance().getLastInvoice()); std::string buf; gAgent.getID().toString(buf); @@ -2203,16 +2103,13 @@ bool LLPanelEstateInfo::refreshFromRegion(LLViewerRegion* region) strings_t strings; //integers_t integers; //LLFloaterRegionInfo::incrementSerial(); - LLFloaterRegionInfo::nextInvoice(); - LLUUID invoice(LLFloaterRegionInfo::getLastInvoice()); //integers.push_back(LLFloaterRegionInfo::());::getPanelEstate(); LLPanelEstateInfo* panel = LLFloaterRegionInfo::getPanelEstate(); panel->clearAccessLists(); - - sendEstateOwnerMessage(gMessageSystem, "getinfo", invoice, strings); + LLEstateInfoModel::instance().setRegion(region); refresh(); @@ -2331,6 +2228,147 @@ void LLPanelEstateInfo::refreshFromEstate() refresh(); } + +void LLPanelEstateInfo::refreshAccessFromEstate(U32 flags) +{ + const LLEstateInfoModel& estate_info = LLEstateInfoModel::instance(); + + // grab the UUID's out of the string fields + if (flags & ESTATE_ACCESS_ALLOWED_AGENTS) + { + LLNameListCtrl *allowed_agent_name_list(getChild<LLNameListCtrl>("allowed_avatar_name_list")); + + const uuid_set_t& allowed_agents(estate_info.getAllowedAgents()); + int totalAllowedAgents = allowed_agents.size(); + + if (allowed_agent_name_list) + { + totalAllowedAgents += allowed_agent_name_list->getItemCount(); + } + + LLStringUtil::format_map_t args; + args["[ALLOWEDAGENTS]"] = llformat("%d", totalAllowedAgents); + args["[MAXACCESS]"] = llformat("%d", ESTATE_MAX_ACCESS_IDS); + std::string msg = LLTrans::getString("RegionInfoAllowedResidents", args); + getChild<LLUICtrl>("allow_resident_label")->setValue(LLSD(msg)); + + if (allowed_agent_name_list) + { + // Don't sort these as we add them, sort them when we are done. + allowed_agent_name_list->clearSortOrder(); + allowed_agent_name_list->deleteAllItems(); + + for (const LLUUID &id : allowed_agents) + { + allowed_agent_name_list->addNameItem(id); + } + allowed_agent_name_list->sortByName(TRUE); + } + } + + if (flags & ESTATE_ACCESS_ALLOWED_GROUPS) + { + LLNameListCtrl* allowed_group_name_list(getChild<LLNameListCtrl>("allowed_group_name_list")); + const uuid_set_t &allowed_groups(estate_info.getAllowedGroups()); + + LLStringUtil::format_map_t args; + args["[ALLOWEDGROUPS]"] = llformat("%d", allowed_groups.size()); + args["[MAXACCESS]"] = llformat("%d", ESTATE_MAX_GROUP_IDS); + std::string msg = LLTrans::getString("RegionInfoAllowedGroups", args); + getChild<LLUICtrl>("allow_group_label")->setValue(LLSD(msg)); + + if (allowed_group_name_list) + { + // Don't sort these as we add them, sort them when we are done. + allowed_group_name_list->clearSortOrder(); + allowed_group_name_list->deleteAllItems(); + + for (const LLUUID &id: allowed_groups) + { + allowed_group_name_list->addGroupNameItem(id); + } + allowed_group_name_list->sortByName(TRUE); + } + } + + if (flags & ESTATE_ACCESS_BANNED_AGENTS) + { + LLNameListCtrl* banned_agent_name_list(getChild<LLNameListCtrl>("banned_avatar_name_list")); + const uuid_set_t &banned_agents(estate_info.getBannedAgents()); + int totalBannedAgents = banned_agents.size(); + + if (banned_agent_name_list) + { + totalBannedAgents += banned_agent_name_list->getItemCount(); + } + + + LLStringUtil::format_map_t args; + args["[BANNEDAGENTS]"] = llformat("%d", totalBannedAgents); + args["[MAXBANNED]"] = llformat("%d", ESTATE_MAX_ACCESS_IDS); + std::string msg = LLTrans::getString("RegionInfoBannedResidents", args); + getChild<LLUICtrl>("ban_resident_label")->setValue(LLSD(msg)); + + if (banned_agent_name_list) + { + // Don't sort these as we add them, sort them when we are done. + banned_agent_name_list->clearSortOrder(); + + for (const LLUUID &id: banned_agents) + { + banned_agent_name_list->addNameItem(id); + } + banned_agent_name_list->sortByName(TRUE); + } + } + + if (flags & ESTATE_ACCESS_MANAGERS) + { + LLNameListCtrl* estate_manager_name_list(getChild<LLNameListCtrl>("estate_manager_name_list")); + const uuid_set_t &estate_mgrs(estate_info.getEstateManagers()); + + LLStringUtil::format_map_t args; + args["[ESTATEMANAGERS]"] = llformat("%d", estate_mgrs.size()); + args["[MAXMANAGERS]"] = llformat("%d", ESTATE_MAX_MANAGERS); + std::string msg = LLTrans::getString("RegionInfoEstateManagers", args); + getChild<LLUICtrl>("estate_manager_label")->setValue(LLSD(msg)); + + if (estate_manager_name_list) + { + // Don't sort these as we add them, sort them when we are done. + estate_manager_name_list->clearSortOrder(); + estate_manager_name_list->deleteAllItems(); // Clear existing entries + + // There should be only ESTATE_MAX_MANAGERS people in the list, but if the database gets more (SL-46107) don't + // truncate the list unless it's really big. Go ahead and show the extras so the user doesn't get confused, + // and they can still remove them. + for (const LLUUID &id : estate_mgrs) + { + estate_manager_name_list->addNameItem(id); + } + estate_manager_name_list->sortByName(TRUE); + } + } + + // Update the buttons which may change based on the list contents but also needs to account for general access features. + updateControls(gAgent.getRegion()); +} + + +namespace +{ + LLSD set_to_llsdarray(const uuid_set_t &values) + { + LLSD result(LLSD::emptyArray()); + + for (const LLUUID &id : values) + { + result.append(id); + } + return result; + } +} + BOOL LLPanelEstateInfo::sendUpdate() { LL_INFOS() << "LLPanelEsateInfo::sendUpdate()" << LL_ENDL; @@ -2368,8 +2406,6 @@ bool LLPanelEstateInfo::callbackChangeLindenEstate(const LLSD& notification, con estate_info.setDenyAgeUnverified(getChild<LLUICtrl>("limit_age_verified")->getValue().asBoolean()); estate_info.setAllowVoiceChat(getChild<LLUICtrl>("voice_chat_check")->getValue().asBoolean()); estate_info.setAllowAccessOverride(getChild<LLUICtrl>("parcel_access_override")->getValue().asBoolean()); - // JIGGLYPUFF - //estate_info.setAllowAccessOverride(getChild<LLUICtrl>("")->getValue().asBoolean()); // send the update to sim estate_info.sendEstateInfo(); } @@ -2465,8 +2501,8 @@ bool LLPanelEstateInfo::onMessageCommit(const LLSD& notification, const LLSD& re LLAgentUI::buildFullname(name); strings.push_back(strings_t::value_type(name)); strings.push_back(strings_t::value_type(text)); - LLUUID invoice(LLFloaterRegionInfo::getLastInvoice()); - sendEstateOwnerMessage(gMessageSystem, "instantmessage", invoice, strings); + + LLEstateInfoModel::instance().sendEstateOwnerMessage("instantmessage", strings); return false; } @@ -2751,7 +2787,7 @@ void LLPanelEstateCovenant::sendChangeCovenantID(const LLUUID &asset_id) msg->nextBlock("MethodData"); msg->addString("Method", "estatechangecovenantid"); - msg->addUUID("Invoice", LLFloaterRegionInfo::getLastInvoice()); + msg->addUUID("Invoice", LLEstateInfoModel::instance().getLastInvoice()); msg->nextBlock("ParamList"); msg->addString("Parameter", getCovenantID().asString()); @@ -2831,859 +2867,6 @@ void LLPanelEstateCovenant::setCovenantTextEditor(const std::string& text) mEditor->setText(text); } -// key = "estateupdateinfo" -// strings[0] = estate name -// strings[1] = str(owner_id) -// strings[2] = str(estate_id) -// strings[3] = str(estate_flags) -// strings[4] = str((S32)(sun_hour * 1024)) -// strings[5] = str(parent_estate_id) -// strings[6] = str(covenant_id) -// strings[7] = str(covenant_timestamp) -// strings[8] = str(send_to_agent_only) -// strings[9] = str(abuse_email_addr) -bool LLDispatchEstateUpdateInfo::operator()( - const LLDispatcher* dispatcher, - const std::string& key, - const LLUUID& invoice, - const sparam_t& strings) -{ - LL_DEBUGS() << "Received estate update" << LL_ENDL; - - // Update estate info model. - // This will call LLPanelEstateInfo::refreshFromEstate(). - // *TODO: Move estate message handling stuff to llestateinfomodel.cpp. - LLEstateInfoModel::instance().update(strings); - - return true; -} - - -// key = "setaccess" -// strings[0] = str(estate_id) -// strings[1] = str(packed_access_lists) -// strings[2] = str(num allowed agent ids) -// strings[3] = str(num allowed group ids) -// strings[4] = str(num banned agent ids) -// strings[5] = str(num estate manager agent ids) -// strings[6] = bin(uuid) -// strings[7] = bin(uuid) -// strings[8] = bin(uuid) -// ... -bool LLDispatchSetEstateAccess::operator()( - const LLDispatcher* dispatcher, - const std::string& key, - const LLUUID& invoice, - const sparam_t& strings) -{ - LLPanelEstateInfo* panel = LLFloaterRegionInfo::getPanelEstate(); - if (!panel) return true; - - S32 index = 1; // skip estate_id - U32 access_flags = strtoul(strings[index++].c_str(), NULL,10); - S32 num_allowed_agents = strtol(strings[index++].c_str(), NULL, 10); - S32 num_allowed_groups = strtol(strings[index++].c_str(), NULL, 10); - S32 num_banned_agents = strtol(strings[index++].c_str(), NULL, 10); - S32 num_estate_managers = strtol(strings[index++].c_str(), NULL, 10); - - // sanity ckecks - if (num_allowed_agents > 0 - && !(access_flags & ESTATE_ACCESS_ALLOWED_AGENTS)) - { - LL_WARNS() << "non-zero count for allowed agents, but no corresponding flag" << LL_ENDL; - } - if (num_allowed_groups > 0 - && !(access_flags & ESTATE_ACCESS_ALLOWED_GROUPS)) - { - LL_WARNS() << "non-zero count for allowed groups, but no corresponding flag" << LL_ENDL; - } - if (num_banned_agents > 0 - && !(access_flags & ESTATE_ACCESS_BANNED_AGENTS)) - { - LL_WARNS() << "non-zero count for banned agents, but no corresponding flag" << LL_ENDL; - } - if (num_estate_managers > 0 - && !(access_flags & ESTATE_ACCESS_MANAGERS)) - { - LL_WARNS() << "non-zero count for managers, but no corresponding flag" << LL_ENDL; - } - - // grab the UUID's out of the string fields - if (access_flags & ESTATE_ACCESS_ALLOWED_AGENTS) - { - LLNameListCtrl* allowed_agent_name_list; - allowed_agent_name_list = panel->getChild<LLNameListCtrl>("allowed_avatar_name_list"); - - int totalAllowedAgents = num_allowed_agents; - - if (allowed_agent_name_list) - { - totalAllowedAgents += allowed_agent_name_list->getItemCount(); - } - - LLStringUtil::format_map_t args; - args["[ALLOWEDAGENTS]"] = llformat ("%d", totalAllowedAgents); - args["[MAXACCESS]"] = llformat ("%d", ESTATE_MAX_ACCESS_IDS); - std::string msg = LLTrans::getString("RegionInfoAllowedResidents", args); - panel->getChild<LLUICtrl>("allow_resident_label")->setValue(LLSD(msg)); - - if (allowed_agent_name_list) - { - // Don't sort these as we add them, sort them when we are done. - allowed_agent_name_list->clearSortOrder(); - for (S32 i = 0; i < num_allowed_agents && i < ESTATE_MAX_ACCESS_IDS; i++) - { - LLUUID id; - memcpy(id.mData, strings[index++].data(), UUID_BYTES); /* Flawfinder: ignore */ - allowed_agent_name_list->addNameItem(id); - } - allowed_agent_name_list->sortByName(TRUE); - } - } - - if (access_flags & ESTATE_ACCESS_ALLOWED_GROUPS) - { - LLNameListCtrl* allowed_group_name_list; - allowed_group_name_list = panel->getChild<LLNameListCtrl>("allowed_group_name_list"); - - LLStringUtil::format_map_t args; - args["[ALLOWEDGROUPS]"] = llformat ("%d", num_allowed_groups); - args["[MAXACCESS]"] = llformat ("%d", ESTATE_MAX_GROUP_IDS); - std::string msg = LLTrans::getString("RegionInfoAllowedGroups", args); - panel->getChild<LLUICtrl>("allow_group_label")->setValue(LLSD(msg)); - - if (allowed_group_name_list) - { - // Don't sort these as we add them, sort them when we are done. - allowed_group_name_list->clearSortOrder(); - allowed_group_name_list->deleteAllItems(); - for (S32 i = 0; i < num_allowed_groups && i < ESTATE_MAX_GROUP_IDS; i++) - { - LLUUID id; - memcpy(id.mData, strings[index++].data(), UUID_BYTES); /* Flawfinder: ignore */ - allowed_group_name_list->addGroupNameItem(id); - } - allowed_group_name_list->sortByName(TRUE); - } - } - - if (access_flags & ESTATE_ACCESS_BANNED_AGENTS) - { - LLNameListCtrl* banned_agent_name_list; - banned_agent_name_list = panel->getChild<LLNameListCtrl>("banned_avatar_name_list"); - - int totalBannedAgents = num_banned_agents; - - if (banned_agent_name_list) - { - totalBannedAgents += banned_agent_name_list->getItemCount(); - } - - - LLStringUtil::format_map_t args; - args["[BANNEDAGENTS]"] = llformat("%d", totalBannedAgents); - args["[MAXBANNED]"] = llformat("%d", ESTATE_MAX_ACCESS_IDS); - std::string msg = LLTrans::getString("RegionInfoBannedResidents", args); - panel->getChild<LLUICtrl>("ban_resident_label")->setValue(LLSD(msg)); - - if (banned_agent_name_list) - { - // Don't sort these as we add them, sort them when we are done. - banned_agent_name_list->clearSortOrder(); - - for (S32 i = 0; i < num_banned_agents && i < ESTATE_MAX_ACCESS_IDS; i++) - { - LLUUID id; - memcpy(id.mData, strings[index++].data(), UUID_BYTES); /* Flawfinder: ignore */ - banned_agent_name_list->addNameItem(id); - } - banned_agent_name_list->sortByName(TRUE); - } - } - - if (access_flags & ESTATE_ACCESS_MANAGERS) - { - LLStringUtil::format_map_t args; - args["[ESTATEMANAGERS]"] = llformat("%d", num_estate_managers); - args["[MAXMANAGERS]"] = llformat("%d", ESTATE_MAX_MANAGERS); - std::string msg = LLTrans::getString("RegionInfoEstateManagers", args); - panel->getChild<LLUICtrl>("estate_manager_label")->setValue(LLSD(msg)); - - LLNameListCtrl* estate_manager_name_list = - panel->getChild<LLNameListCtrl>("estate_manager_name_list"); - if (estate_manager_name_list) - { - // Don't sort these as we add them, sort them when we are done. - estate_manager_name_list->clearSortOrder(); - - estate_manager_name_list->deleteAllItems(); // Clear existing entries - - // There should be only ESTATE_MAX_MANAGERS people in the list, but if the database gets more (SL-46107) don't - // truncate the list unless it's really big. Go ahead and show the extras so the user doesn't get confused, - // and they can still remove them. - for (S32 i = 0; i < num_estate_managers && i < (ESTATE_MAX_MANAGERS * 4); i++) - { - LLUUID id; - memcpy(id.mData, strings[index++].data(), UUID_BYTES); /* Flawfinder: ignore */ - estate_manager_name_list->addNameItem(id); - } - estate_manager_name_list->sortByName(TRUE); - } - } - - // Update the buttons which may change based on the list contents but also needs to account for general access features. - panel->updateControls(gAgent.getRegion()); - - 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), - mDayCycleSettingsRadioGroup(NULL), - mWaterPresetCombo(NULL), - mSkyPresetCombo(NULL), - mDayCyclePresetCombo(NULL) -{ -} - -// virtual -BOOL LLPanelEnvironmentInfo::postBuild() -{ - mRegionSettingsRadioGroup = getChild<LLRadioGroup>("region_settings_radio_group"); - mRegionSettingsRadioGroup->setCommitCallback(boost::bind(&LLPanelEnvironmentInfo::onSwitchRegionSettings, this)); - - mDayCycleSettingsRadioGroup = getChild<LLRadioGroup>("sky_dayc_settings_radio_group"); - mDayCycleSettingsRadioGroup->setCommitCallback(boost::bind(&LLPanelEnvironmentInfo::onSwitchDayCycle, this)); - - mWaterPresetCombo = getChild<LLComboBox>("water_settings_preset_combo"); - mWaterPresetCombo->setCommitCallback(boost::bind(&LLPanelEnvironmentInfo::onSelectWaterPreset, this)); - - mSkyPresetCombo = getChild<LLComboBox>("sky_settings_preset_combo"); - mSkyPresetCombo->setCommitCallback(boost::bind(&LLPanelEnvironmentInfo::onSelectSkyPreset, this)); - - mDayCyclePresetCombo = getChild<LLComboBox>("dayc_settings_preset_combo"); - mDayCyclePresetCombo->setCommitCallback(boost::bind(&LLPanelEnvironmentInfo::onSelectDayCycle, this)); - - childSetCommitCallback("apply_btn", boost::bind(&LLPanelEnvironmentInfo::onBtnApply, this), NULL); - getChild<LLButton>("apply_btn")->setRightMouseDownCallback(boost::bind(&LLEnvManagerNew::dumpUserPrefs, LLEnvManagerNew::getInstance())); - childSetCommitCallback("cancel_btn", boost::bind(&LLPanelEnvironmentInfo::onBtnCancel, this), NULL); - getChild<LLButton>("cancel_btn")->setRightMouseDownCallback(boost::bind(&LLEnvManagerNew::dumpPresets, LLEnvManagerNew::getInstance())); - - LLEnvManagerNew::instance().setRegionSettingsChangeCallback(boost::bind(&LLPanelEnvironmentInfo::onRegionSettingschange, this)); - LLEnvManagerNew::instance().setRegionSettingsAppliedCallback(boost::bind(&LLPanelEnvironmentInfo::onRegionSettingsApplied, this, _1)); - - LLDayCycleManager::instance().setModifyCallback(boost::bind(&LLPanelEnvironmentInfo::populateDayCyclesList, this)); - LLWLParamManager::instance().setPresetListChangeCallback(boost::bind(&LLPanelEnvironmentInfo::populateSkyPresetsList, this)); - LLWaterParamManager::instance().setPresetListChangeCallback(boost::bind(&LLPanelEnvironmentInfo::populateWaterPresetsList, this)); - - return TRUE; -} - -// virtual -void LLPanelEnvironmentInfo::onOpen(const LLSD& key) -{ - LL_DEBUGS("Windlight") << "Panel opened, refreshing" << LL_ENDL; - refresh(); -} - -// virtual -void LLPanelEnvironmentInfo::onVisibilityChange(BOOL new_visibility) -{ - // If hiding (user switched to another tab or closed the floater), - // display user's preferred environment. - if (!new_visibility) - { - LLEnvManagerNew::instance().usePrefs(); - } -} - -// virtual -bool LLPanelEnvironmentInfo::refreshFromRegion(LLViewerRegion* region) -{ - LL_DEBUGS("Windlight") << "Region updated, enabling/disabling controls" << LL_ENDL; - BOOL owner_or_god = gAgent.isGodlike() || (region && (region->getOwner() == gAgent.getID())); - BOOL owner_or_god_or_manager = owner_or_god || (region && region->isEstateManager()); - - // Don't refresh from region settings to avoid flicker after applying new region settings. - mEnableEditing = owner_or_god_or_manager; - setControlsEnabled(mEnableEditing); - - return LLPanelRegionInfo::refreshFromRegion(region); -} - -void LLPanelEnvironmentInfo::refresh() -{ - if(gDisconnected) - { - return; - } - - populateWaterPresetsList(); - populateSkyPresetsList(); - populateDayCyclesList(); - - // Init radio groups. - const LLEnvironmentSettings& settings = LLEnvManagerNew::instance().getRegionSettings(); - const LLSD& dc = settings.getWLDayCycle(); - LLSD::Real first_frame_time = dc.size() > 0 ? dc[0][0].asReal() : 0.0f; - const bool use_fixed_sky = dc.size() == 1 && first_frame_time < 0; - mRegionSettingsRadioGroup->setSelectedIndex(settings.getSkyMap().size() == 0 ? 0 : 1); - mDayCycleSettingsRadioGroup->setSelectedIndex(use_fixed_sky ? 0 : 1); - - setControlsEnabled(mEnableEditing); - - setDirty(false); -} - -void LLPanelEnvironmentInfo::setControlsEnabled(bool enabled) -{ - mRegionSettingsRadioGroup->setEnabled(enabled); - mDayCycleSettingsRadioGroup->setEnabled(enabled); - - mWaterPresetCombo->setEnabled(enabled); - mSkyPresetCombo->setEnabled(enabled); - mDayCyclePresetCombo->setEnabled(enabled); - - getChildView("apply_btn")->setEnabled(enabled); - getChildView("cancel_btn")->setEnabled(enabled); - - if (enabled) - { - // Enable/disable some controls based on currently selected radio buttons. - bool use_defaults = mRegionSettingsRadioGroup->getSelectedIndex() == 0; - getChild<LLView>("user_environment_settings")->setEnabled(!use_defaults); - - bool is_fixed_sky = mDayCycleSettingsRadioGroup->getSelectedIndex() == 0; - mSkyPresetCombo->setEnabled(is_fixed_sky); - mDayCyclePresetCombo->setEnabled(!is_fixed_sky); - } -} - -void LLPanelEnvironmentInfo::setApplyProgress(bool started) -{ - LLLoadingIndicator* indicator = getChild<LLLoadingIndicator>("progress_indicator"); - - indicator->setVisible(started); - - if (started) - { - indicator->start(); - } - else - { - indicator->stop(); - } -} - -void LLPanelEnvironmentInfo::setDirty(bool dirty) -{ - getChildView("apply_btn")->setEnabled(dirty); - getChildView("cancel_btn")->setEnabled(dirty); -} - -void LLPanelEnvironmentInfo::sendRegionSunUpdate() -{ - LLRegionInfoModel& region_info = LLRegionInfoModel::instance(); - - // If the region is being switched to fixed sky, - // change the region's sun hour according to the (fixed) sun position. - // This is needed for llGetSunDirection() LSL function to work properly (STORM-1330). - const LLSD& sky_map = mNewRegionSettings.getSkyMap(); - bool region_use_fixed_sky = sky_map.size() == 1; - if (region_use_fixed_sky) - { - LLWLParamSet param_set; - llassert(sky_map.isMap()); - param_set.setAll(sky_map.beginMap()->second); - F32 sun_angle = param_set.getSunAngle(); - - LL_DEBUGS("WindlightSync") << "Old sun hour: " << region_info.mSunHour << LL_ENDL; - // convert value range from 0..2pi to 6..30 - region_info.mSunHour = fmodf((sun_angle / F_TWO_PI) * 24.f, 24.f) + 6.f; - } - - region_info.setUseFixedSun(region_use_fixed_sky); - region_info.mUseEstateSun = !region_use_fixed_sky; - LL_DEBUGS("WindlightSync") << "Sun hour: " << region_info.mSunHour << LL_ENDL; - - region_info.sendRegionTerrain(LLFloaterRegionInfo::getLastInvoice()); -} - -void LLPanelEnvironmentInfo::fixEstateSun() -{ - // We don't support fixed sun estates anymore and need to fix - // such estates for region day cycle to take effect. - // *NOTE: Assuming that current estate settings have arrived already. - LLEstateInfoModel& estate_info = LLEstateInfoModel::instance(); - if (estate_info.getUseFixedSun()) - { - LL_INFOS() << "Switching estate to global sun" << LL_ENDL; - estate_info.setUseFixedSun(false); - estate_info.sendEstateInfo(); - } -} - -void LLPanelEnvironmentInfo::populateWaterPresetsList() -{ - mWaterPresetCombo->removeall(); - - // If the region already has water params, add them to the list. - const LLEnvironmentSettings& region_settings = LLEnvManagerNew::instance().getRegionSettings(); - if (region_settings.getWaterParams().size() != 0) - { - const std::string& region_name = gAgent.getRegion()->getName(); - mWaterPresetCombo->add(region_name, LLWLParamKey(region_name, LLEnvKey::SCOPE_REGION).toLLSD()); - mWaterPresetCombo->addSeparator(); - } - - std::list<std::string> user_presets, system_presets; - LLWaterParamManager::instance().getPresetNames(user_presets, system_presets); - - // Add local user presets first. - for (std::list<std::string>::const_iterator it = user_presets.begin(); it != user_presets.end(); ++it) - { - mWaterPresetCombo->add(*it, LLWLParamKey(*it, LLEnvKey::SCOPE_LOCAL).toLLSD()); - } - - if (user_presets.size() > 0) - { - mWaterPresetCombo->addSeparator(); - } - - // Add local system presets. - for (std::list<std::string>::const_iterator it = system_presets.begin(); it != system_presets.end(); ++it) - { - mWaterPresetCombo->add(*it, LLWLParamKey(*it, LLEnvKey::SCOPE_LOCAL).toLLSD()); - } - - // There's no way to select current preset because its name is not stored on server. -} - -void LLPanelEnvironmentInfo::populateSkyPresetsList() -{ - mSkyPresetCombo->removeall(); - - LLWLParamManager::preset_name_list_t region_presets; - LLWLParamManager::preset_name_list_t user_presets, sys_presets; - LLWLParamManager::instance().getPresetNames(region_presets, user_presets, sys_presets); - - // Add region presets. - std::string region_name = gAgent.getRegion() ? gAgent.getRegion()->getName() : LLTrans::getString("Unknown"); - for (LLWLParamManager::preset_name_list_t::const_iterator it = region_presets.begin(); it != region_presets.end(); ++it) - { - std::string preset_name = *it; - std::string item_title = preset_name + " (" + region_name + ")"; - mSkyPresetCombo->add(item_title, LLWLParamKey(preset_name, LLEnvKey::SCOPE_REGION).toStringVal()); - } - - if (!region_presets.empty()) - { - mSkyPresetCombo->addSeparator(); - } - - // Add user presets. - for (LLWLParamManager::preset_name_list_t::const_iterator it = user_presets.begin(); it != user_presets.end(); ++it) - { - mSkyPresetCombo->add(*it, LLWLParamKey(*it, LLEnvKey::SCOPE_LOCAL).toStringVal()); - } - - if (!user_presets.empty()) - { - mSkyPresetCombo->addSeparator(); - } - - // Add system presets. - for (LLWLParamManager::preset_name_list_t::const_iterator it = sys_presets.begin(); it != sys_presets.end(); ++it) - { - mSkyPresetCombo->add(*it, LLWLParamKey(*it, LLEnvKey::SCOPE_LOCAL).toStringVal()); - } - - // Select current preset. - LLSD sky_map = LLEnvManagerNew::instance().getRegionSettings().getSkyMap(); - if (sky_map.size() == 1) // if the region is set to fixed sky - { - std::string preset_name = sky_map.beginMap()->first; - mSkyPresetCombo->selectByValue(LLWLParamKey(preset_name, LLEnvKey::SCOPE_REGION).toStringVal()); - } -} - -void LLPanelEnvironmentInfo::populateDayCyclesList() -{ - mDayCyclePresetCombo->removeall(); - - // If the region already has env. settings, add its day cycle to the list. - const LLSD& cur_region_dc = LLEnvManagerNew::instance().getRegionSettings().getWLDayCycle(); - if (cur_region_dc.size() != 0) - { - LLViewerRegion* region = gAgent.getRegion(); - llassert(region != NULL); - - LLWLParamKey key(region->getName(), LLEnvKey::SCOPE_REGION); - mDayCyclePresetCombo->add(region->getName(), key.toStringVal()); - mDayCyclePresetCombo->addSeparator(); - } - - // Add local user day cycles. - LLDayCycleManager::preset_name_list_t user_days, sys_days; - LLDayCycleManager::instance().getPresetNames(user_days, sys_days); - for (LLDayCycleManager::preset_name_list_t::const_iterator it = user_days.begin(); it != user_days.end(); ++it) - { - mDayCyclePresetCombo->add(*it, LLWLParamKey(*it, LLEnvKey::SCOPE_LOCAL).toStringVal()); - } - - if (user_days.size() > 0) - { - mDayCyclePresetCombo->addSeparator(); - } - - // Add local system day cycles. - for (LLDayCycleManager::preset_name_list_t::const_iterator it = sys_days.begin(); it != sys_days.end(); ++it) - { - mDayCyclePresetCombo->add(*it, LLWLParamKey(*it, LLEnvKey::SCOPE_LOCAL).toStringVal()); - } - - // Current day cycle is already selected. -} - -bool LLPanelEnvironmentInfo::getSelectedWaterParams(LLSD& water_params) -{ - LLWLParamKey water_key(mWaterPresetCombo->getSelectedValue()); - - if (water_key.scope == LLEnvKey::SCOPE_REGION) - { - water_params = LLEnvManagerNew::instance().getRegionSettings().getWaterParams(); - } - else - { - LLWaterParamSet param_set; - if (!LLWaterParamManager::instance().getParamSet(water_key.name, param_set)) - { - LL_WARNS() << "Error getting water preset: " << water_key.name << LL_ENDL; - return false; - } - - water_params = param_set.getAll(); - } - - return true; -} - -bool LLPanelEnvironmentInfo::getSelectedSkyParams(LLSD& sky_params, std::string& preset_name) -{ - std::string preset_key(mSkyPresetCombo->getValue().asString()); - LLWLParamKey preset(preset_key); - - // Get the preset sky params. - LLWLParamSet param_set; - if (!LLWLParamManager::instance().getParamSet(preset, param_set)) - { - LL_WARNS() << "Error getting sky params: " << preset.toLLSD() << LL_ENDL; - return false; - } - - sky_params = param_set.getAll(); - preset_name = preset.name; - return true; -} - -bool LLPanelEnvironmentInfo::getSelectedDayCycleParams(LLSD& day_cycle, LLSD& sky_map, short& scope) -{ - std::string preset_key(mDayCyclePresetCombo->getValue().asString()); - LLWLParamKey dc(preset_key); - LL_DEBUGS("Windlight") << "Use day cycle: " << dc.toLLSD() << LL_ENDL; - - if (dc.scope == LLEnvKey::SCOPE_REGION) // current region day cycle - { - const LLEnvironmentSettings& cur_region_settings = LLEnvManagerNew::instance().getRegionSettings(); - day_cycle = cur_region_settings.getWLDayCycle(); - sky_map = cur_region_settings.getSkyMap(); - } - else // a local day cycle - { - if (!LLDayCycleManager::instance().getPreset(dc.name, day_cycle)) - { - LL_WARNS() << "Error getting day cycle " << dc.name << LL_ENDL; - return false; - } - - // Create sky map from the day cycle. - { - LLWLDayCycle tmp_day; - tmp_day.loadDayCycle(day_cycle, dc.scope); - tmp_day.getSkyMap(sky_map); - } - } - - scope = dc.scope; - - return true; -} -void LLPanelEnvironmentInfo::onSwitchRegionSettings() -{ - bool use_defaults = mRegionSettingsRadioGroup->getSelectedIndex() == 0; - getChild<LLView>("user_environment_settings")->setEnabled(!use_defaults); - - if (use_defaults) - { - LLEnvManagerNew::instance().useDefaults(); - } - else - { - onSelectWaterPreset(); - onSwitchDayCycle(); - } - - setDirty(true); -} - -void LLPanelEnvironmentInfo::onSwitchDayCycle() -{ - bool is_fixed_sky = mDayCycleSettingsRadioGroup->getSelectedIndex() == 0; - - mSkyPresetCombo->setEnabled(is_fixed_sky); - mDayCyclePresetCombo->setEnabled(!is_fixed_sky); - - if (is_fixed_sky) - { - onSelectSkyPreset(); - } - else - { - onSelectDayCycle(); - } - - setDirty(true); -} - -void LLPanelEnvironmentInfo::onSelectWaterPreset() -{ - LLSD water_params; - - if (getSelectedWaterParams(water_params)) - { - LLEnvManagerNew::instance().useWaterParams(water_params); - } - - setDirty(true); -} - -void LLPanelEnvironmentInfo::onSelectSkyPreset() -{ - LLSD params; - std::string dummy; - - if (getSelectedSkyParams(params, dummy)) - { - LLEnvManagerNew::instance().useSkyParams(params); - } - - setDirty(true); -} - -void LLPanelEnvironmentInfo::onSelectDayCycle() -{ - LLSD day_cycle; - LLSD sky_map; // unused - short scope; - - if (getSelectedDayCycleParams(day_cycle, sky_map, scope)) - { - LLEnvManagerNew::instance().useDayCycleParams(day_cycle, (LLEnvKey::EScope) scope); - } - - setDirty(true); -} - -void LLPanelEnvironmentInfo::onBtnApply() -{ - const bool use_defaults = mRegionSettingsRadioGroup->getSelectedIndex() == 0; - const bool use_fixed_sky = mDayCycleSettingsRadioGroup->getSelectedIndex() == 0; - - LLSD day_cycle; - LLSD sky_map; - LLSD water_params; - - if (use_defaults) - { - // settings will be empty - LL_DEBUGS("Windlight") << "Defaults" << LL_ENDL; - } - else // use custom region settings - { - if (use_fixed_sky) - { - LL_DEBUGS("Windlight") << "Use fixed sky" << LL_ENDL; - - // Get selected sky params. - LLSD params; - std::string preset_name; - if (!getSelectedSkyParams(params, preset_name)) - { - return; - } - - // Create a day cycle consisting of a single sky preset. - LLSD key(LLSD::emptyArray()); - key.append(-1.0f); // indicate that user preference is actually fixed sky, not a day cycle - key.append(preset_name); - day_cycle.append(key); - - // Create a sky map consisting of only the sky preset. - std::map<LLWLParamKey, LLWLParamSet> refs; - LLWLParamSet param_set; - param_set.setAll(params); - refs[LLWLParamKey(preset_name, LLEnvKey::SCOPE_LOCAL)] = param_set; // scope doesn't matter here - sky_map = LLWLParamManager::createSkyMap(refs); - } - else // use day cycle - { - LL_DEBUGS("Windlight") << "Use day cycle" << LL_ENDL; - - short scope; // unused - if (!getSelectedDayCycleParams(day_cycle, sky_map, scope)) - { - return; - } - - // If it's a special single-preset day cycle meaning using a fixed sky, - // reset the frame time to a non-negative value, - // so that the region setting is displayed in the floater as - // a day cycle, not a preset. (STORM-1289) - if (day_cycle.size() == 1 && day_cycle[0][0].asReal() < 0.0f) - { - LL_DEBUGS("Windlight") << "Fixing negative time" << LL_ENDL; - day_cycle[0][0] = 0.0f; - } - } - - // Get water params. - if (!getSelectedWaterParams(water_params)) - { - // *TODO: show a notification? - return; - } - } - - // Send settings apply request. - LLEnvironmentSettings new_region_settings; - new_region_settings.saveParams(day_cycle, sky_map, water_params, 0.0f); - if (!LLEnvManagerNew::instance().sendRegionSettings(new_region_settings)) - { - LL_WARNS() << "Error applying region environment settings" << LL_ENDL; - return; - } - - // When the settings get applied, we'll also send the region sun position update. - // To determine the sun angle we're going to need the new settings. - mNewRegionSettings = new_region_settings; - - // Start spinning the progress indicator. - setApplyProgress(true); -} - -void LLPanelEnvironmentInfo::onBtnCancel() -{ - // Reload last saved region settings. - refresh(); - - // Apply them. - LLEnvManagerNew& env_mgr = LLEnvManagerNew::instance(); - const LLEnvironmentSettings& cur_settings = env_mgr.getRegionSettings(); - const LLSD& region_day_cycle = cur_settings.getWLDayCycle(); - const LLSD& region_water = cur_settings.getWaterParams(); - env_mgr.useWaterParams(region_water); - env_mgr.useDayCycleParams(region_day_cycle, LLEnvKey::SCOPE_REGION); -} - -void LLPanelEnvironmentInfo::onRegionSettingschange() -{ - LL_DEBUGS("Windlight") << "Region settings changed, refreshing" << LL_ENDL; - refresh(); - - // Stop applying progress indicator (it may be running if it's us who initiated settings update). - setApplyProgress(false); -} - -void LLPanelEnvironmentInfo::onRegionSettingsApplied(bool ok) -{ - // If applying new settings has failed, stop the indicator right away. - // Otherwise it will be stopped when we receive the updated settings from server. - if (ok) - { - // Set the region sun phase/flags according to the chosen new preferences. - // - // If we do this earlier we may get jerky transition from fixed sky to a day cycle (STORM-1481). - // That is caused by the simulator re-sending the region info, which in turn makes us - // re-request and display old region environment settings while the new ones haven't been applied yet. - sendRegionSunUpdate(); - - // Switch estate to not using fixed sun for the region day cycle to work properly (STORM-1506). - fixEstateSun(); - } - else - { - setApplyProgress(false); - - // We need to re-request environment setting here, - // otherwise our subsequent attempts to change region settings will fail with the following error: - // "Unable to update environment settings because the last update your viewer saw was not the same - // as the last update sent from the simulator. Try sending your update again, and if this - // does not work, try leaving and returning to the region." - LLEnvManagerNew::instance().requestRegionSettings(); - } -} - BOOL LLPanelRegionExperiences::postBuild() { mAllowed = setupList("panel_allowed", ESTATE_EXPERIENCE_ALLOWED_ADD, ESTATE_EXPERIENCE_ALLOWED_REMOVE); @@ -3696,6 +2879,8 @@ BOOL LLPanelRegionExperiences::postBuild() getChild<LLTextBox>("allowed_text_help")->setText(getString("allowed_estate_text")); getChild<LLTextBox>("blocked_text_help")->setText(getString("blocked_estate_text")); + LLEstateInfoModel::instance().setUpdateExperienceCallback(boost::bind(&LLPanelRegionExperiences::refreshExperiencesFromEstate, this)); + return LLPanelRegionInfo::postBuild(); } @@ -3739,6 +2924,18 @@ void LLPanelRegionExperiences::processResponse( const LLSD& content ) } +void LLPanelRegionExperiences::refreshExperiencesFromEstate() +{ + const LLEstateInfoModel& estate_info = LLEstateInfoModel::instance(); + + LLSD ids = LLSDMap("blocked", set_to_llsdarray(estate_info.getBlockedExperiences())) + ("trusted", set_to_llsdarray(estate_info.getTrustedExperiences())) + ("allowed", set_to_llsdarray(estate_info.getAllowedExperiences())); + + processResponse(ids); +} + + // Used for both access add and remove operations, depending on the flag // passed in (ESTATE_EXPERIENCE_ALLOWED_ADD, ESTATE_EXPERIENCE_ALLOWED_REMOVE, etc.) // static @@ -3801,11 +2998,7 @@ void LLPanelRegionExperiences::sendEstateExperienceDelta(U32 flags, const LLUUID str[1] = llformat("%u", flags); experience_id.toString(str[2]); - LLPanelRegionExperiences* panel = LLFloaterRegionInfo::getPanelExperiences(); - if (panel) - { - panel->sendEstateOwnerMessage(gMessageSystem, "estateexperiencedelta", LLFloaterRegionInfo::getLastInvoice(), str); - } + LLEstateInfoModel::instance().sendEstateOwnerMessage("estateexperiencedelta", str); } @@ -3942,3 +3135,142 @@ void LLPanelRegionExperiences::itemChanged( U32 event_type, const LLUUID& id ) onChangeAnything(); } + +//========================================================================= +const U32 LLPanelRegionEnvironment::DIRTY_FLAG_OVERRIDE(0x01 << 4); + +LLPanelRegionEnvironment::LLPanelRegionEnvironment(): + LLPanelEnvironmentInfo(), + mAllowOverrideRestore(false) +{ +} + +LLPanelRegionEnvironment::~LLPanelRegionEnvironment() +{ + if (mCommitConnect.connected()) + mCommitConnect.disconnect(); +} + +BOOL LLPanelRegionEnvironment::postBuild() +{ + LLEstateInfoModel& estate_info = LLEstateInfoModel::instance(); + + if (!LLPanelEnvironmentInfo::postBuild()) + return FALSE; + + getChild<LLUICtrl>(BTN_USEDEFAULT)->setLabelArg("[USEDEFAULT]", getString(STR_LABEL_USEDEFAULT)); + getChild<LLUICtrl>(CHK_ALLOWOVERRIDE)->setVisible(TRUE); + getChild<LLUICtrl>(PNL_ENVIRONMENT_ALTITUDES)->setVisible(TRUE); + + getChild<LLUICtrl>(CHK_ALLOWOVERRIDE)->setCommitCallback([this](LLUICtrl *, const LLSD &value){ onChkAllowOverride(value.asBoolean()); }); + + mCommitConnect = estate_info.setCommitCallback(boost::bind(&LLPanelRegionEnvironment::refreshFromEstate, this)); + return TRUE; +} + + +void LLPanelRegionEnvironment::refresh() +{ + if (!mCurrentEnvironment) + { + if (mCurEnvVersion <= INVALID_PARCEL_ENVIRONMENT_VERSION) + { + refreshFromSource(); // will immediately set mCurEnvVersion + } // else - already requesting + return; + } + + LLPanelEnvironmentInfo::refresh(); + + getChild<LLUICtrl>(CHK_ALLOWOVERRIDE)->setValue(mAllowOverride); +} + +bool LLPanelRegionEnvironment::refreshFromRegion(LLViewerRegion* region) +{ + if (!region) + { + setNoSelection(true); + setControlsEnabled(false); + mCurEnvVersion = INVALID_PARCEL_ENVIRONMENT_VERSION; + } + setNoSelection(false); + + if (gAgent.getRegion()->getRegionID() != region->getRegionID()) + { + setCrossRegion(true); + mCurEnvVersion = INVALID_PARCEL_ENVIRONMENT_VERSION; + } + setCrossRegion(false); + + refreshFromSource(); + return true; +} + +void LLPanelRegionEnvironment::refreshFromSource() +{ + LL_DEBUGS("ENVIRONMENT") << "Requesting environment for region, known version " << mCurEnvVersion << LL_ENDL; + LLHandle<LLPanel> that_h = getHandle(); + + if (mCurEnvVersion < UNSET_PARCEL_ENVIRONMENT_VERSION) + { + // to mark as requesting + mCurEnvVersion = UNSET_PARCEL_ENVIRONMENT_VERSION; + } + + LLEnvironment::instance().requestRegion( + [that_h](S32 parcel_id, LLEnvironment::EnvironmentInfo::ptr_t envifo) { _onEnvironmentReceived(that_h, parcel_id, envifo); }); + + setControlsEnabled(false); +} + +bool LLPanelRegionEnvironment::confirmUpdateEstateEnvironment(const LLSD& notification, const LLSD& response) +{ + S32 option = LLNotificationsUtil::getSelectedOption(notification, response); + + switch (option) + { + case 0: + { + LLEstateInfoModel& estate_info = LLEstateInfoModel::instance(); + + // update model + estate_info.setAllowEnvironmentOverride(mAllowOverride); + // send the update to sim + estate_info.sendEstateInfo(); + clearDirtyFlag(DIRTY_FLAG_OVERRIDE); + } + break; + + case 1: + mAllowOverride = mAllowOverrideRestore; + getChild<LLUICtrl>(CHK_ALLOWOVERRIDE)->setValue(mAllowOverride); + break; + default: + break; + } + return false; +} + +void LLPanelRegionEnvironment::onChkAllowOverride(bool value) +{ + setDirtyFlag(DIRTY_FLAG_OVERRIDE); + mAllowOverrideRestore = mAllowOverride; + mAllowOverride = value; + + LLNotification::Params params("ChangeLindenEstate"); + params.functor.function([this](const LLSD& notification, const LLSD& response) { confirmUpdateEstateEnvironment(notification, response); }); + + std::string notification("EstateParcelEnvironmentOverride"); + if (LLPanelEstateInfo::isLindenEstate()) + notification = "ChangeLindenEstate"; + + if (!value || LLPanelEstateInfo::isLindenEstate()) + { // warn if turning off or a Linden Estate + LLNotifications::instance().add(params); + } + else + { + LLNotifications::instance().forceResponse(params, 0); + } + +} |