PageRenderTime 634ms CodeModel.GetById 30ms RepoModel.GetById 21ms app.codeStats 1ms

/indra/newview/llfloaterregioninfo.cpp

https://bitbucket.org/lindenlab/viewer-beta/
C++ | 2052 lines | 1498 code | 304 blank | 250 comment | 180 complexity | e9530b9eb7491f4ac8fa146f9239f1c9 MD5 | raw file
Possible License(s): LGPL-2.1
  1. /**
  2. * @file llfloaterregioninfo.cpp
  3. * @author Aaron Brashears
  4. * @brief Implementation of the region info and controls floater and panels.
  5. *
  6. * $LicenseInfo:firstyear=2004&license=viewerlgpl$
  7. * Second Life Viewer Source Code
  8. * Copyright (C) 2010, Linden Research, Inc.
  9. *
  10. * This library is free software; you can redistribute it and/or
  11. * modify it under the terms of the GNU Lesser General Public
  12. * License as published by the Free Software Foundation;
  13. * version 2.1 of the License only.
  14. *
  15. * This library is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  18. * Lesser General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU Lesser General Public
  21. * License along with this library; if not, write to the Free Software
  22. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  23. *
  24. * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
  25. * $/LicenseInfo$
  26. */
  27. #include "llviewerprecompiledheaders.h"
  28. #include "llfloaterregioninfo.h"
  29. #include <algorithm>
  30. #include <functional>
  31. #include "lldir.h"
  32. #include "lldispatcher.h"
  33. #include "llglheaders.h"
  34. #include "llregionflags.h"
  35. #include "llstl.h"
  36. #include "llvfile.h"
  37. #include "llxfermanager.h"
  38. #include "indra_constants.h"
  39. #include "message.h"
  40. #include "llloadingindicator.h"
  41. #include "llradiogroup.h"
  42. #include "llsd.h"
  43. #include "llsdserialize.h"
  44. #include "llagent.h"
  45. #include "llappviewer.h"
  46. #include "llavatarname.h"
  47. #include "llfloateravatarpicker.h"
  48. #include "llbutton.h"
  49. #include "llcheckboxctrl.h"
  50. #include "llcombobox.h"
  51. #include "lldaycyclemanager.h"
  52. #include "llenvmanager.h"
  53. #include "llestateinfomodel.h"
  54. #include "llfilepicker.h"
  55. #include "llfloatergodtools.h" // for send_sim_wide_deletes()
  56. #include "llfloatertopobjects.h" // added to fix SL-32336
  57. #include "llfloatergroups.h"
  58. #include "llfloaterreg.h"
  59. #include "llfloaterregiondebugconsole.h"
  60. #include "llfloatertelehub.h"
  61. #include "llinventorymodel.h"
  62. #include "lllineeditor.h"
  63. #include "llnamelistctrl.h"
  64. #include "llnotifications.h"
  65. #include "llnotificationsutil.h"
  66. #include "llregioninfomodel.h"
  67. #include "llscrolllistitem.h"
  68. #include "llsliderctrl.h"
  69. #include "llslurl.h"
  70. #include "llspinctrl.h"
  71. #include "lltabcontainer.h"
  72. #include "lltextbox.h"
  73. #include "llinventory.h"
  74. #include "lltexturectrl.h"
  75. #include "lltrans.h"
  76. #include "llviewercontrol.h"
  77. #include "lluictrlfactory.h"
  78. #include "llviewerinventory.h"
  79. #include "llviewertexture.h"
  80. #include "llviewertexturelist.h"
  81. #include "llviewerregion.h"
  82. #include "llviewerstats.h"
  83. #include "llviewertexteditor.h"
  84. #include "llviewerwindow.h"
  85. #include "llvlcomposition.h"
  86. #include "llwaterparammanager.h"
  87. #include "lltrans.h"
  88. #include "llagentui.h"
  89. #include "llmeshrepository.h"
  90. const S32 TERRAIN_TEXTURE_COUNT = 4;
  91. const S32 CORNER_COUNT = 4;
  92. #define TMP_DISABLE_WLES // STORM-1180
  93. ///----------------------------------------------------------------------------
  94. /// Local class declaration
  95. ///----------------------------------------------------------------------------
  96. class LLDispatchEstateUpdateInfo : public LLDispatchHandler
  97. {
  98. public:
  99. LLDispatchEstateUpdateInfo() {}
  100. virtual ~LLDispatchEstateUpdateInfo() {}
  101. virtual bool operator()(
  102. const LLDispatcher* dispatcher,
  103. const std::string& key,
  104. const LLUUID& invoice,
  105. const sparam_t& strings);
  106. };
  107. class LLDispatchSetEstateAccess : public LLDispatchHandler
  108. {
  109. public:
  110. LLDispatchSetEstateAccess() {}
  111. virtual ~LLDispatchSetEstateAccess() {}
  112. virtual bool operator()(
  113. const LLDispatcher* dispatcher,
  114. const std::string& key,
  115. const LLUUID& invoice,
  116. const sparam_t& strings);
  117. };
  118. /*
  119. void unpack_request_params(
  120. LLMessageSystem* msg,
  121. LLDispatcher::sparam_t& strings,
  122. LLDispatcher::iparam_t& integers)
  123. {
  124. char str_buf[MAX_STRING];
  125. S32 str_count = msg->getNumberOfBlocksFast(_PREHASH_StringData);
  126. S32 i;
  127. for (i = 0; i < str_count; ++i)
  128. {
  129. // we treat the SParam as binary data (since it might be an
  130. // LLUUID in compressed form which may have embedded \0's,)
  131. str_buf[0] = '\0';
  132. S32 data_size = msg->getSizeFast(_PREHASH_StringData, i, _PREHASH_SParam);
  133. if (data_size >= 0)
  134. {
  135. msg->getBinaryDataFast(_PREHASH_StringData, _PREHASH_SParam,
  136. str_buf, data_size, i, MAX_STRING - 1);
  137. strings.push_back(std::string(str_buf, data_size));
  138. }
  139. }
  140. U32 int_buf;
  141. S32 int_count = msg->getNumberOfBlocksFast(_PREHASH_IntegerData);
  142. for (i = 0; i < int_count; ++i)
  143. {
  144. msg->getU32("IntegerData", "IParam", int_buf, i);
  145. integers.push_back(int_buf);
  146. }
  147. }
  148. */
  149. bool estate_dispatch_initialized = false;
  150. ///----------------------------------------------------------------------------
  151. /// LLFloaterRegionInfo
  152. ///----------------------------------------------------------------------------
  153. //S32 LLFloaterRegionInfo::sRequestSerial = 0;
  154. LLUUID LLFloaterRegionInfo::sRequestInvoice;
  155. LLFloaterRegionInfo::LLFloaterRegionInfo(const LLSD& seed)
  156. : LLFloater(seed)
  157. {}
  158. BOOL LLFloaterRegionInfo::postBuild()
  159. {
  160. mTab = getChild<LLTabContainer>("region_panels");
  161. mTab->setCommitCallback(boost::bind(&LLFloaterRegionInfo::onTabSelected, this, _2));
  162. // contruct the panels
  163. LLPanelRegionInfo* panel;
  164. panel = new LLPanelEstateInfo;
  165. mInfoPanels.push_back(panel);
  166. panel->buildFromFile("panel_region_estate.xml");
  167. mTab->addTabPanel(LLTabContainer::TabPanelParams().panel(panel).select_tab(true));
  168. panel = new LLPanelEstateCovenant;
  169. mInfoPanels.push_back(panel);
  170. panel->buildFromFile("panel_region_covenant.xml");
  171. mTab->addTabPanel(panel);
  172. panel = new LLPanelRegionGeneralInfo;
  173. mInfoPanels.push_back(panel);
  174. panel->getCommitCallbackRegistrar().add("RegionInfo.ManageTelehub", boost::bind(&LLPanelRegionInfo::onClickManageTelehub, panel));
  175. panel->buildFromFile("panel_region_general.xml");
  176. mTab->addTabPanel(panel);
  177. panel = new LLPanelRegionTerrainInfo;
  178. mInfoPanels.push_back(panel);
  179. panel->buildFromFile("panel_region_terrain.xml");
  180. mTab->addTabPanel(panel);
  181. panel = new LLPanelEnvironmentInfo;
  182. mInfoPanels.push_back(panel);
  183. panel->buildFromFile("panel_region_environment.xml");
  184. mTab->addTabPanel(panel);
  185. panel = new LLPanelRegionDebugInfo;
  186. mInfoPanels.push_back(panel);
  187. panel->buildFromFile("panel_region_debug.xml");
  188. mTab->addTabPanel(panel);
  189. gMessageSystem->setHandlerFunc(
  190. "EstateOwnerMessage",
  191. &processEstateOwnerRequest);
  192. // Request region info when agent region changes.
  193. LLEnvManagerNew::instance().setRegionChangeCallback(boost::bind(&LLFloaterRegionInfo::requestRegionInfo, this));
  194. return TRUE;
  195. }
  196. LLFloaterRegionInfo::~LLFloaterRegionInfo()
  197. {}
  198. void LLFloaterRegionInfo::onOpen(const LLSD& key)
  199. {
  200. refreshFromRegion(gAgent.getRegion());
  201. requestRegionInfo();
  202. requestMeshRezInfo();
  203. }
  204. // static
  205. void LLFloaterRegionInfo::requestRegionInfo()
  206. {
  207. LLTabContainer* tab = getChild<LLTabContainer>("region_panels");
  208. tab->getChild<LLPanel>("General")->setCtrlsEnabled(FALSE);
  209. tab->getChild<LLPanel>("Debug")->setCtrlsEnabled(FALSE);
  210. tab->getChild<LLPanel>("Terrain")->setCtrlsEnabled(FALSE);
  211. tab->getChild<LLPanel>("Estate")->setCtrlsEnabled(FALSE);
  212. // Must allow anyone to request the RegionInfo data
  213. // so non-owners/non-gods can see the values.
  214. // Therefore can't use an EstateOwnerMessage JC
  215. LLMessageSystem* msg = gMessageSystem;
  216. msg->newMessage("RequestRegionInfo");
  217. msg->nextBlock("AgentData");
  218. msg->addUUID("AgentID", gAgent.getID());
  219. msg->addUUID("SessionID", gAgent.getSessionID());
  220. gAgent.sendReliableMessage();
  221. }
  222. // static
  223. void LLFloaterRegionInfo::processEstateOwnerRequest(LLMessageSystem* msg,void**)
  224. {
  225. static LLDispatcher dispatch;
  226. LLFloaterRegionInfo* floater = LLFloaterReg::getTypedInstance<LLFloaterRegionInfo>("region_info");
  227. if(!floater)
  228. {
  229. return;
  230. }
  231. if (!estate_dispatch_initialized)
  232. {
  233. LLPanelEstateInfo::initDispatch(dispatch);
  234. }
  235. LLTabContainer* tab = floater->getChild<LLTabContainer>("region_panels");
  236. LLPanelEstateInfo* panel = (LLPanelEstateInfo*)tab->getChild<LLPanel>("Estate");
  237. // unpack the message
  238. std::string request;
  239. LLUUID invoice;
  240. LLDispatcher::sparam_t strings;
  241. LLDispatcher::unpackMessage(msg, request, invoice, strings);
  242. if(invoice != getLastInvoice())
  243. {
  244. llwarns << "Mismatched Estate message: " << request << llendl;
  245. return;
  246. }
  247. //dispatch the message
  248. dispatch.dispatch(request, invoice, strings);
  249. LLViewerRegion* region = gAgent.getRegion();
  250. panel->updateControls(region);
  251. }
  252. // static
  253. void LLFloaterRegionInfo::processRegionInfo(LLMessageSystem* msg)
  254. {
  255. LLPanel* panel;
  256. LLFloaterRegionInfo* floater = LLFloaterReg::getTypedInstance<LLFloaterRegionInfo>("region_info");
  257. if(!floater)
  258. {
  259. return;
  260. }
  261. // We need to re-request environment setting here,
  262. // otherwise after we apply (send) updated region settings we won't get them back,
  263. // so our environment won't be updated.
  264. // This is also the way to know about externally changed region environment.
  265. LLEnvManagerNew::instance().requestRegionSettings();
  266. LLTabContainer* tab = floater->getChild<LLTabContainer>("region_panels");
  267. LLViewerRegion* region = gAgent.getRegion();
  268. BOOL allow_modify = gAgent.isGodlike() || (region && region->canManageEstate());
  269. // *TODO: Replace parsing msg with accessing the region info model.
  270. LLRegionInfoModel& region_info = LLRegionInfoModel::instance();
  271. // extract message
  272. std::string sim_name;
  273. std::string sim_type = LLTrans::getString("land_type_unknown");
  274. U32 region_flags;
  275. U8 agent_limit;
  276. F32 object_bonus_factor;
  277. U8 sim_access;
  278. F32 water_height;
  279. F32 terrain_raise_limit;
  280. F32 terrain_lower_limit;
  281. BOOL use_estate_sun;
  282. F32 sun_hour;
  283. msg->getString("RegionInfo", "SimName", sim_name);
  284. msg->getU32("RegionInfo", "RegionFlags", region_flags);
  285. msg->getU8("RegionInfo", "MaxAgents", agent_limit);
  286. msg->getF32("RegionInfo", "ObjectBonusFactor", object_bonus_factor);
  287. msg->getU8("RegionInfo", "SimAccess", sim_access);
  288. msg->getF32Fast(_PREHASH_RegionInfo, _PREHASH_WaterHeight, water_height);
  289. msg->getF32Fast(_PREHASH_RegionInfo, _PREHASH_TerrainRaiseLimit, terrain_raise_limit);
  290. msg->getF32Fast(_PREHASH_RegionInfo, _PREHASH_TerrainLowerLimit, terrain_lower_limit);
  291. msg->getBOOL("RegionInfo", "UseEstateSun", use_estate_sun);
  292. // actually the "last set" sun hour, not the current sun hour. JC
  293. msg->getF32("RegionInfo", "SunHour", sun_hour);
  294. // the only reasonable way to decide if we actually have any data is to
  295. // check to see if any of these fields have nonzero sizes
  296. if (msg->getSize("RegionInfo2", "ProductSKU") > 0 ||
  297. msg->getSize("RegionInfo2", "ProductName") > 0)
  298. {
  299. msg->getString("RegionInfo2", "ProductName", sim_type);
  300. LLTrans::findString(sim_type, sim_type); // try localizing sim product name
  301. }
  302. // GENERAL PANEL
  303. panel = tab->getChild<LLPanel>("General");
  304. panel->getChild<LLUICtrl>("region_text")->setValue(LLSD(sim_name));
  305. panel->getChild<LLUICtrl>("region_type")->setValue(LLSD(sim_type));
  306. panel->getChild<LLUICtrl>("version_channel_text")->setValue(gLastVersionChannel);
  307. panel->getChild<LLUICtrl>("block_terraform_check")->setValue((region_flags & REGION_FLAGS_BLOCK_TERRAFORM) ? TRUE : FALSE );
  308. panel->getChild<LLUICtrl>("block_fly_check")->setValue((region_flags & REGION_FLAGS_BLOCK_FLY) ? TRUE : FALSE );
  309. panel->getChild<LLUICtrl>("allow_damage_check")->setValue((region_flags & REGION_FLAGS_ALLOW_DAMAGE) ? TRUE : FALSE );
  310. panel->getChild<LLUICtrl>("restrict_pushobject")->setValue((region_flags & REGION_FLAGS_RESTRICT_PUSHOBJECT) ? TRUE : FALSE );
  311. panel->getChild<LLUICtrl>("allow_land_resell_check")->setValue((region_flags & REGION_FLAGS_BLOCK_LAND_RESELL) ? FALSE : TRUE );
  312. panel->getChild<LLUICtrl>("allow_parcel_changes_check")->setValue((region_flags & REGION_FLAGS_ALLOW_PARCEL_CHANGES) ? TRUE : FALSE );
  313. panel->getChild<LLUICtrl>("block_parcel_search_check")->setValue((region_flags & REGION_FLAGS_BLOCK_PARCEL_SEARCH) ? TRUE : FALSE );
  314. panel->getChild<LLUICtrl>("agent_limit_spin")->setValue(LLSD((F32)agent_limit) );
  315. panel->getChild<LLUICtrl>("object_bonus_spin")->setValue(LLSD(object_bonus_factor) );
  316. panel->getChild<LLUICtrl>("access_combo")->setValue(LLSD(sim_access) );
  317. // detect teen grid for maturity
  318. U32 parent_estate_id;
  319. msg->getU32("RegionInfo", "ParentEstateID", parent_estate_id);
  320. BOOL teen_grid = (parent_estate_id == 5); // *TODO add field to estate table and test that
  321. panel->getChildView("access_combo")->setEnabled(gAgent.isGodlike() || (region && region->canManageEstate() && !teen_grid));
  322. panel->setCtrlsEnabled(allow_modify);
  323. // DEBUG PANEL
  324. panel = tab->getChild<LLPanel>("Debug");
  325. panel->getChild<LLUICtrl>("region_text")->setValue(LLSD(sim_name) );
  326. panel->getChild<LLUICtrl>("disable_scripts_check")->setValue(LLSD((BOOL)(region_flags & REGION_FLAGS_SKIP_SCRIPTS)) );
  327. panel->getChild<LLUICtrl>("disable_collisions_check")->setValue(LLSD((BOOL)(region_flags & REGION_FLAGS_SKIP_COLLISIONS)) );
  328. panel->getChild<LLUICtrl>("disable_physics_check")->setValue(LLSD((BOOL)(region_flags & REGION_FLAGS_SKIP_PHYSICS)) );
  329. panel->setCtrlsEnabled(allow_modify);
  330. // TERRAIN PANEL
  331. panel = tab->getChild<LLPanel>("Terrain");
  332. panel->getChild<LLUICtrl>("region_text")->setValue(LLSD(sim_name));
  333. panel->getChild<LLUICtrl>("water_height_spin")->setValue(region_info.mWaterHeight);
  334. panel->getChild<LLUICtrl>("terrain_raise_spin")->setValue(region_info.mTerrainRaiseLimit);
  335. panel->getChild<LLUICtrl>("terrain_lower_spin")->setValue(region_info.mTerrainLowerLimit);
  336. panel->setCtrlsEnabled(allow_modify);
  337. floater->refreshFromRegion( gAgent.getRegion() );
  338. }
  339. // static
  340. LLPanelEstateInfo* LLFloaterRegionInfo::getPanelEstate()
  341. {
  342. LLFloaterRegionInfo* floater = LLFloaterReg::getTypedInstance<LLFloaterRegionInfo>("region_info");
  343. if (!floater) return NULL;
  344. LLTabContainer* tab = floater->getChild<LLTabContainer>("region_panels");
  345. LLPanelEstateInfo* panel = (LLPanelEstateInfo*)tab->getChild<LLPanel>("Estate");
  346. return panel;
  347. }
  348. // static
  349. LLPanelEstateCovenant* LLFloaterRegionInfo::getPanelCovenant()
  350. {
  351. LLFloaterRegionInfo* floater = LLFloaterReg::getTypedInstance<LLFloaterRegionInfo>("region_info");
  352. if (!floater) return NULL;
  353. LLTabContainer* tab = floater->getChild<LLTabContainer>("region_panels");
  354. LLPanelEstateCovenant* panel = (LLPanelEstateCovenant*)tab->getChild<LLPanel>("Covenant");
  355. return panel;
  356. }
  357. // static
  358. LLPanelRegionTerrainInfo* LLFloaterRegionInfo::getPanelRegionTerrain()
  359. {
  360. LLFloaterRegionInfo* floater = LLFloaterReg::getTypedInstance<LLFloaterRegionInfo>("region_info");
  361. if (!floater)
  362. {
  363. llassert(floater);
  364. return NULL;
  365. }
  366. LLTabContainer* tab_container = floater->getChild<LLTabContainer>("region_panels");
  367. LLPanelRegionTerrainInfo* panel =
  368. dynamic_cast<LLPanelRegionTerrainInfo*>(tab_container->getChild<LLPanel>("Terrain"));
  369. llassert(panel);
  370. return panel;
  371. }
  372. void LLFloaterRegionInfo::onTabSelected(const LLSD& param)
  373. {
  374. LLPanel* active_panel = getChild<LLPanel>(param.asString());
  375. active_panel->onOpen(LLSD());
  376. }
  377. void LLFloaterRegionInfo::refreshFromRegion(LLViewerRegion* region)
  378. {
  379. if (!region)
  380. {
  381. return;
  382. }
  383. // call refresh from region on all panels
  384. std::for_each(
  385. mInfoPanels.begin(),
  386. mInfoPanels.end(),
  387. llbind2nd(
  388. #if LL_WINDOWS
  389. std::mem_fun1(&LLPanelRegionInfo::refreshFromRegion),
  390. #else
  391. std::mem_fun(&LLPanelRegionInfo::refreshFromRegion),
  392. #endif
  393. region));
  394. }
  395. // public
  396. void LLFloaterRegionInfo::refresh()
  397. {
  398. for(info_panels_t::iterator iter = mInfoPanels.begin();
  399. iter != mInfoPanels.end(); ++iter)
  400. {
  401. (*iter)->refresh();
  402. }
  403. }
  404. ///----------------------------------------------------------------------------
  405. /// Local class implementation
  406. ///----------------------------------------------------------------------------
  407. //
  408. // LLPanelRegionInfo
  409. //
  410. LLPanelRegionInfo::LLPanelRegionInfo()
  411. : LLPanel()
  412. {
  413. }
  414. void LLPanelRegionInfo::onBtnSet()
  415. {
  416. if (sendUpdate())
  417. {
  418. disableButton("apply_btn");
  419. }
  420. }
  421. void LLPanelRegionInfo::onChangeChildCtrl(LLUICtrl* ctrl)
  422. {
  423. updateChild(ctrl); // virtual function
  424. }
  425. // Enables the "set" button if it is not already enabled
  426. void LLPanelRegionInfo::onChangeAnything()
  427. {
  428. enableButton("apply_btn");
  429. refresh();
  430. }
  431. // static
  432. // Enables set button on change to line editor
  433. void LLPanelRegionInfo::onChangeText(LLLineEditor* caller, void* user_data)
  434. {
  435. LLPanelRegionInfo* panel = dynamic_cast<LLPanelRegionInfo*>(caller->getParent());
  436. if(panel)
  437. {
  438. panel->enableButton("apply_btn");
  439. panel->refresh();
  440. }
  441. }
  442. // virtual
  443. BOOL LLPanelRegionInfo::postBuild()
  444. {
  445. // If the panel has an Apply button, set a callback for it.
  446. LLUICtrl* apply_btn = findChild<LLUICtrl>("apply_btn");
  447. if (apply_btn)
  448. {
  449. apply_btn->setCommitCallback(boost::bind(&LLPanelRegionInfo::onBtnSet, this));
  450. }
  451. refresh();
  452. return TRUE;
  453. }
  454. // virtual
  455. void LLPanelRegionInfo::updateChild(LLUICtrl* child_ctr)
  456. {
  457. }
  458. // virtual
  459. bool LLPanelRegionInfo::refreshFromRegion(LLViewerRegion* region)
  460. {
  461. if (region) mHost = region->getHost();
  462. return true;
  463. }
  464. void LLPanelRegionInfo::sendEstateOwnerMessage(
  465. LLMessageSystem* msg,
  466. const std::string& request,
  467. const LLUUID& invoice,
  468. const strings_t& strings)
  469. {
  470. llinfos << "Sending estate request '" << request << "'" << llendl;
  471. msg->newMessage("EstateOwnerMessage");
  472. msg->nextBlockFast(_PREHASH_AgentData);
  473. msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
  474. msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
  475. msg->addUUIDFast(_PREHASH_TransactionID, LLUUID::null); //not used
  476. msg->nextBlock("MethodData");
  477. msg->addString("Method", request);
  478. msg->addUUID("Invoice", invoice);
  479. if(strings.empty())
  480. {
  481. msg->nextBlock("ParamList");
  482. msg->addString("Parameter", NULL);
  483. }
  484. else
  485. {
  486. strings_t::const_iterator it = strings.begin();
  487. strings_t::const_iterator end = strings.end();
  488. for(; it != end; ++it)
  489. {
  490. msg->nextBlock("ParamList");
  491. msg->addString("Parameter", *it);
  492. }
  493. }
  494. msg->sendReliable(mHost);
  495. }
  496. void LLPanelRegionInfo::enableButton(const std::string& btn_name, BOOL enable)
  497. {
  498. LLView* button = findChildView(btn_name);
  499. if (button) button->setEnabled(enable);
  500. }
  501. void LLPanelRegionInfo::disableButton(const std::string& btn_name)
  502. {
  503. LLView* button = findChildView(btn_name);
  504. if (button) button->setEnabled(FALSE);
  505. }
  506. void LLPanelRegionInfo::initCtrl(const std::string& name)
  507. {
  508. getChild<LLUICtrl>(name)->setCommitCallback(boost::bind(&LLPanelRegionInfo::onChangeAnything, this));
  509. }
  510. void LLPanelRegionInfo::onClickManageTelehub()
  511. {
  512. LLFloaterReg::hideInstance("region_info");
  513. LLFloaterReg::showInstance("telehubs");
  514. }
  515. /////////////////////////////////////////////////////////////////////////////
  516. // LLPanelRegionGeneralInfo
  517. //
  518. bool LLPanelRegionGeneralInfo::refreshFromRegion(LLViewerRegion* region)
  519. {
  520. BOOL allow_modify = gAgent.isGodlike() || (region && region->canManageEstate());
  521. setCtrlsEnabled(allow_modify);
  522. getChildView("apply_btn")->setEnabled(FALSE);
  523. getChildView("access_text")->setEnabled(allow_modify);
  524. // getChildView("access_combo")->setEnabled(allow_modify);
  525. // now set in processRegionInfo for teen grid detection
  526. getChildView("kick_btn")->setEnabled(allow_modify);
  527. getChildView("kick_all_btn")->setEnabled(allow_modify);
  528. getChildView("im_btn")->setEnabled(allow_modify);
  529. getChildView("manage_telehub_btn")->setEnabled(allow_modify);
  530. // Data gets filled in by processRegionInfo
  531. return LLPanelRegionInfo::refreshFromRegion(region);
  532. }
  533. BOOL LLPanelRegionGeneralInfo::postBuild()
  534. {
  535. // Enable the "Apply" button if something is changed. JC
  536. initCtrl("block_terraform_check");
  537. initCtrl("block_fly_check");
  538. initCtrl("allow_damage_check");
  539. initCtrl("allow_land_resell_check");
  540. initCtrl("allow_parcel_changes_check");
  541. initCtrl("agent_limit_spin");
  542. initCtrl("object_bonus_spin");
  543. initCtrl("access_combo");
  544. initCtrl("restrict_pushobject");
  545. initCtrl("block_parcel_search_check");
  546. childSetAction("kick_btn", boost::bind(&LLPanelRegionGeneralInfo::onClickKick, this));
  547. childSetAction("kick_all_btn", onClickKickAll, this);
  548. childSetAction("im_btn", onClickMessage, this);
  549. // childSetAction("manage_telehub_btn", onClickManageTelehub, this);
  550. return LLPanelRegionInfo::postBuild();
  551. }
  552. void LLPanelRegionGeneralInfo::onClickKick()
  553. {
  554. llinfos << "LLPanelRegionGeneralInfo::onClickKick" << llendl;
  555. // this depends on the grandparent view being a floater
  556. // in order to set up floater dependency
  557. LLFloater* parent_floater = gFloaterView->getParentFloater(this);
  558. LLFloater* child_floater = LLFloaterAvatarPicker::show(boost::bind(&LLPanelRegionGeneralInfo::onKickCommit, this, _1), FALSE, TRUE);
  559. parent_floater->addDependentFloater(child_floater);
  560. }
  561. void LLPanelRegionGeneralInfo::onKickCommit(const uuid_vec_t& ids)
  562. {
  563. if (ids.empty()) return;
  564. if(ids[0].notNull())
  565. {
  566. strings_t strings;
  567. // [0] = our agent id
  568. // [1] = target agent id
  569. std::string buffer;
  570. gAgent.getID().toString(buffer);
  571. strings.push_back(buffer);
  572. ids[0].toString(buffer);
  573. strings.push_back(strings_t::value_type(buffer));
  574. LLUUID invoice(LLFloaterRegionInfo::getLastInvoice());
  575. sendEstateOwnerMessage(gMessageSystem, "teleporthomeuser", invoice, strings);
  576. }
  577. }
  578. // static
  579. void LLPanelRegionGeneralInfo::onClickKickAll(void* userdata)
  580. {
  581. llinfos << "LLPanelRegionGeneralInfo::onClickKickAll" << llendl;
  582. LLNotificationsUtil::add("KickUsersFromRegion",
  583. LLSD(),
  584. LLSD(),
  585. boost::bind(&LLPanelRegionGeneralInfo::onKickAllCommit, (LLPanelRegionGeneralInfo*)userdata, _1, _2));
  586. }
  587. bool LLPanelRegionGeneralInfo::onKickAllCommit(const LLSD& notification, const LLSD& response)
  588. {
  589. S32 option = LLNotificationsUtil::getSelectedOption(notification, response);
  590. if (option == 0)
  591. {
  592. strings_t strings;
  593. // [0] = our agent id
  594. std::string buffer;
  595. gAgent.getID().toString(buffer);
  596. strings.push_back(buffer);
  597. LLUUID invoice(LLFloaterRegionInfo::getLastInvoice());
  598. // historical message name
  599. sendEstateOwnerMessage(gMessageSystem, "teleporthomeallusers", invoice, strings);
  600. }
  601. return false;
  602. }
  603. // static
  604. void LLPanelRegionGeneralInfo::onClickMessage(void* userdata)
  605. {
  606. llinfos << "LLPanelRegionGeneralInfo::onClickMessage" << llendl;
  607. LLNotificationsUtil::add("MessageRegion",
  608. LLSD(),
  609. LLSD(),
  610. boost::bind(&LLPanelRegionGeneralInfo::onMessageCommit, (LLPanelRegionGeneralInfo*)userdata, _1, _2));
  611. }
  612. // static
  613. bool LLPanelRegionGeneralInfo::onMessageCommit(const LLSD& notification, const LLSD& response)
  614. {
  615. if(LLNotificationsUtil::getSelectedOption(notification, response) != 0) return false;
  616. std::string text = response["message"].asString();
  617. if (text.empty()) return false;
  618. llinfos << "Message to everyone: " << text << llendl;
  619. strings_t strings;
  620. // [0] grid_x, unused here
  621. // [1] grid_y, unused here
  622. // [2] agent_id of sender
  623. // [3] sender name
  624. // [4] message
  625. strings.push_back("-1");
  626. strings.push_back("-1");
  627. std::string buffer;
  628. gAgent.getID().toString(buffer);
  629. strings.push_back(buffer);
  630. std::string name;
  631. LLAgentUI::buildFullname(name);
  632. strings.push_back(strings_t::value_type(name));
  633. strings.push_back(strings_t::value_type(text));
  634. LLUUID invoice(LLFloaterRegionInfo::getLastInvoice());
  635. sendEstateOwnerMessage(gMessageSystem, "simulatormessage", invoice, strings);
  636. return false;
  637. }
  638. class ConsoleRequestResponder : public LLHTTPClient::Responder
  639. {
  640. public:
  641. /*virtual*/
  642. void error(U32 status, const std::string& reason)
  643. {
  644. llwarns << "requesting mesh_rez_enabled failed" << llendl;
  645. }
  646. };
  647. // called if this request times out.
  648. class ConsoleUpdateResponder : public LLHTTPClient::Responder
  649. {
  650. public:
  651. /* virtual */
  652. void error(U32 status, const std::string& reason)
  653. {
  654. llwarns << "Updating mesh enabled region setting failed" << llendl;
  655. }
  656. };
  657. void LLFloaterRegionInfo::requestMeshRezInfo()
  658. {
  659. std::string sim_console_url = gAgent.getRegion()->getCapability("SimConsoleAsync");
  660. if (!sim_console_url.empty())
  661. {
  662. std::string request_str = "get mesh_rez_enabled";
  663. LLHTTPClient::post(
  664. sim_console_url,
  665. LLSD(request_str),
  666. new ConsoleRequestResponder);
  667. }
  668. }
  669. // setregioninfo
  670. // strings[0] = 'Y' - block terraform, 'N' - not
  671. // strings[1] = 'Y' - block fly, 'N' - not
  672. // strings[2] = 'Y' - allow damage, 'N' - not
  673. // strings[3] = 'Y' - allow land sale, 'N' - not
  674. // strings[4] = agent limit
  675. // strings[5] = object bonus
  676. // strings[6] = sim access (0 = unknown, 13 = PG, 21 = Mature, 42 = Adult)
  677. // strings[7] = restrict pushobject
  678. // strings[8] = 'Y' - allow parcel subdivide, 'N' - not
  679. // strings[9] = 'Y' - block parcel search, 'N' - allow
  680. BOOL LLPanelRegionGeneralInfo::sendUpdate()
  681. {
  682. llinfos << "LLPanelRegionGeneralInfo::sendUpdate()" << llendl;
  683. // First try using a Cap. If that fails use the old method.
  684. LLSD body;
  685. std::string url = gAgent.getRegion()->getCapability("DispatchRegionInfo");
  686. if (!url.empty())
  687. {
  688. body["block_terraform"] = getChild<LLUICtrl>("block_terraform_check")->getValue();
  689. body["block_fly"] = getChild<LLUICtrl>("block_fly_check")->getValue();
  690. body["allow_damage"] = getChild<LLUICtrl>("allow_damage_check")->getValue();
  691. body["allow_land_resell"] = getChild<LLUICtrl>("allow_land_resell_check")->getValue();
  692. body["agent_limit"] = getChild<LLUICtrl>("agent_limit_spin")->getValue();
  693. body["prim_bonus"] = getChild<LLUICtrl>("object_bonus_spin")->getValue();
  694. body["sim_access"] = getChild<LLUICtrl>("access_combo")->getValue();
  695. body["restrict_pushobject"] = getChild<LLUICtrl>("restrict_pushobject")->getValue();
  696. body["allow_parcel_changes"] = getChild<LLUICtrl>("allow_parcel_changes_check")->getValue();
  697. body["block_parcel_search"] = getChild<LLUICtrl>("block_parcel_search_check")->getValue();
  698. LLHTTPClient::post(url, body, new LLHTTPClient::Responder());
  699. }
  700. else
  701. {
  702. strings_t strings;
  703. std::string buffer;
  704. buffer = llformat("%s", (getChild<LLUICtrl>("block_terraform_check")->getValue().asBoolean() ? "Y" : "N"));
  705. strings.push_back(strings_t::value_type(buffer));
  706. buffer = llformat("%s", (getChild<LLUICtrl>("block_fly_check")->getValue().asBoolean() ? "Y" : "N"));
  707. strings.push_back(strings_t::value_type(buffer));
  708. buffer = llformat("%s", (getChild<LLUICtrl>("allow_damage_check")->getValue().asBoolean() ? "Y" : "N"));
  709. strings.push_back(strings_t::value_type(buffer));
  710. buffer = llformat("%s", (getChild<LLUICtrl>("allow_land_resell_check")->getValue().asBoolean() ? "Y" : "N"));
  711. strings.push_back(strings_t::value_type(buffer));
  712. F32 value = (F32)getChild<LLUICtrl>("agent_limit_spin")->getValue().asReal();
  713. buffer = llformat("%f", value);
  714. strings.push_back(strings_t::value_type(buffer));
  715. value = (F32)getChild<LLUICtrl>("object_bonus_spin")->getValue().asReal();
  716. buffer = llformat("%f", value);
  717. strings.push_back(strings_t::value_type(buffer));
  718. buffer = llformat("%d", getChild<LLUICtrl>("access_combo")->getValue().asInteger());
  719. strings.push_back(strings_t::value_type(buffer));
  720. buffer = llformat("%s", (getChild<LLUICtrl>("restrict_pushobject")->getValue().asBoolean() ? "Y" : "N"));
  721. strings.push_back(strings_t::value_type(buffer));
  722. buffer = llformat("%s", (getChild<LLUICtrl>("allow_parcel_changes_check")->getValue().asBoolean() ? "Y" : "N"));
  723. strings.push_back(strings_t::value_type(buffer));
  724. LLUUID invoice(LLFloaterRegionInfo::getLastInvoice());
  725. sendEstateOwnerMessage(gMessageSystem, "setregioninfo", invoice, strings);
  726. }
  727. // if we changed access levels, tell user about it
  728. LLViewerRegion* region = gAgent.getRegion();
  729. if (region && (getChild<LLUICtrl>("access_combo")->getValue().asInteger() != region->getSimAccess()) )
  730. {
  731. LLNotificationsUtil::add("RegionMaturityChange");
  732. }
  733. return TRUE;
  734. }
  735. /////////////////////////////////////////////////////////////////////////////
  736. // LLPanelRegionDebugInfo
  737. /////////////////////////////////////////////////////////////////////////////
  738. BOOL LLPanelRegionDebugInfo::postBuild()
  739. {
  740. LLPanelRegionInfo::postBuild();
  741. initCtrl("disable_scripts_check");
  742. initCtrl("disable_collisions_check");
  743. initCtrl("disable_physics_check");
  744. childSetAction("choose_avatar_btn", boost::bind(&LLPanelRegionDebugInfo::onClickChooseAvatar, this));
  745. childSetAction("return_btn", onClickReturn, this);
  746. childSetAction("top_colliders_btn", onClickTopColliders, this);
  747. childSetAction("top_scripts_btn", onClickTopScripts, this);
  748. childSetAction("restart_btn", onClickRestart, this);
  749. childSetAction("cancel_restart_btn", onClickCancelRestart, this);
  750. return TRUE;
  751. }
  752. // virtual
  753. bool LLPanelRegionDebugInfo::refreshFromRegion(LLViewerRegion* region)
  754. {
  755. BOOL allow_modify = gAgent.isGodlike() || (region && region->canManageEstate());
  756. setCtrlsEnabled(allow_modify);
  757. getChildView("apply_btn")->setEnabled(FALSE);
  758. getChildView("target_avatar_name")->setEnabled(FALSE);
  759. getChildView("choose_avatar_btn")->setEnabled(allow_modify);
  760. getChildView("return_scripts")->setEnabled(allow_modify && !mTargetAvatar.isNull());
  761. getChildView("return_other_land")->setEnabled(allow_modify && !mTargetAvatar.isNull());
  762. getChildView("return_estate_wide")->setEnabled(allow_modify && !mTargetAvatar.isNull());
  763. getChildView("return_btn")->setEnabled(allow_modify && !mTargetAvatar.isNull());
  764. getChildView("top_colliders_btn")->setEnabled(allow_modify);
  765. getChildView("top_scripts_btn")->setEnabled(allow_modify);
  766. getChildView("restart_btn")->setEnabled(allow_modify);
  767. getChildView("cancel_restart_btn")->setEnabled(allow_modify);
  768. return LLPanelRegionInfo::refreshFromRegion(region);
  769. }
  770. // virtual
  771. BOOL LLPanelRegionDebugInfo::sendUpdate()
  772. {
  773. llinfos << "LLPanelRegionDebugInfo::sendUpdate" << llendl;
  774. strings_t strings;
  775. std::string buffer;
  776. buffer = llformat("%s", (getChild<LLUICtrl>("disable_scripts_check")->getValue().asBoolean() ? "Y" : "N"));
  777. strings.push_back(buffer);
  778. buffer = llformat("%s", (getChild<LLUICtrl>("disable_collisions_check")->getValue().asBoolean() ? "Y" : "N"));
  779. strings.push_back(buffer);
  780. buffer = llformat("%s", (getChild<LLUICtrl>("disable_physics_check")->getValue().asBoolean() ? "Y" : "N"));
  781. strings.push_back(buffer);
  782. LLUUID invoice(LLFloaterRegionInfo::getLastInvoice());
  783. sendEstateOwnerMessage(gMessageSystem, "setregiondebug", invoice, strings);
  784. return TRUE;
  785. }
  786. void LLPanelRegionDebugInfo::onClickChooseAvatar()
  787. {
  788. LLFloaterAvatarPicker::show(boost::bind(&LLPanelRegionDebugInfo::callbackAvatarID, this, _1, _2), FALSE, TRUE);
  789. }
  790. void LLPanelRegionDebugInfo::callbackAvatarID(const uuid_vec_t& ids, const std::vector<LLAvatarName> names)
  791. {
  792. if (ids.empty() || names.empty()) return;
  793. mTargetAvatar = ids[0];
  794. getChild<LLUICtrl>("target_avatar_name")->setValue(LLSD(names[0].getCompleteName()));
  795. refreshFromRegion( gAgent.getRegion() );
  796. }
  797. // static
  798. void LLPanelRegionDebugInfo::onClickReturn(void* data)
  799. {
  800. LLPanelRegionDebugInfo* panelp = (LLPanelRegionDebugInfo*) data;
  801. if (panelp->mTargetAvatar.isNull()) return;
  802. LLSD args;
  803. args["USER_NAME"] = panelp->getChild<LLUICtrl>("target_avatar_name")->getValue().asString();
  804. LLSD payload;
  805. payload["avatar_id"] = panelp->mTargetAvatar;
  806. U32 flags = SWD_ALWAYS_RETURN_OBJECTS;
  807. if (panelp->getChild<LLUICtrl>("return_scripts")->getValue().asBoolean())
  808. {
  809. flags |= SWD_SCRIPTED_ONLY;
  810. }
  811. if (panelp->getChild<LLUICtrl>("return_other_land")->getValue().asBoolean())
  812. {
  813. flags |= SWD_OTHERS_LAND_ONLY;
  814. }
  815. payload["flags"] = int(flags);
  816. payload["return_estate_wide"] = panelp->getChild<LLUICtrl>("return_estate_wide")->getValue().asBoolean();
  817. LLNotificationsUtil::add("EstateObjectReturn", args, payload,
  818. boost::bind(&LLPanelRegionDebugInfo::callbackReturn, panelp, _1, _2));
  819. }
  820. bool LLPanelRegionDebugInfo::callbackReturn(const LLSD& notification, const LLSD& response)
  821. {
  822. S32 option = LLNotificationsUtil::getSelectedOption(notification, response);
  823. if (option != 0) return false;
  824. LLUUID target_avatar = notification["payload"]["avatar_id"].asUUID();
  825. if (!target_avatar.isNull())
  826. {
  827. U32 flags = notification["payload"]["flags"].asInteger();
  828. bool return_estate_wide = notification["payload"]["return_estate_wide"];
  829. if (return_estate_wide)
  830. {
  831. // send as estate message - routed by spaceserver to all regions in estate
  832. strings_t strings;
  833. strings.push_back(llformat("%d", flags));
  834. strings.push_back(target_avatar.asString());
  835. LLUUID invoice(LLFloaterRegionInfo::getLastInvoice());
  836. sendEstateOwnerMessage(gMessageSystem, "estateobjectreturn", invoice, strings);
  837. }
  838. else
  839. {
  840. // send to this simulator only
  841. send_sim_wide_deletes(target_avatar, flags);
  842. }
  843. }
  844. return false;
  845. }
  846. // static
  847. void LLPanelRegionDebugInfo::onClickTopColliders(void* data)
  848. {
  849. LLPanelRegionDebugInfo* self = (LLPanelRegionDebugInfo*)data;
  850. strings_t strings;
  851. strings.push_back("1"); // one physics step
  852. LLUUID invoice(LLFloaterRegionInfo::getLastInvoice());
  853. LLFloaterTopObjects* instance = LLFloaterReg::getTypedInstance<LLFloaterTopObjects>("top_objects");
  854. if(!instance) return;
  855. LLFloaterReg::showInstance("top_objects");
  856. instance->clearList();
  857. self->sendEstateOwnerMessage(gMessageSystem, "colliders", invoice, strings);
  858. }
  859. // static
  860. void LLPanelRegionDebugInfo::onClickTopScripts(void* data)
  861. {
  862. LLPanelRegionDebugInfo* self = (LLPanelRegionDebugInfo*)data;
  863. strings_t strings;
  864. strings.push_back("6"); // top 5 scripts
  865. LLUUID invoice(LLFloaterRegionInfo::getLastInvoice());
  866. LLFloaterTopObjects* instance = LLFloaterReg::getTypedInstance<LLFloaterTopObjects>("top_objects");
  867. if(!instance) return;
  868. LLFloaterReg::showInstance("top_objects");
  869. instance->clearList();
  870. self->sendEstateOwnerMessage(gMessageSystem, "scripts", invoice, strings);
  871. }
  872. // static
  873. void LLPanelRegionDebugInfo::onClickRestart(void* data)
  874. {
  875. LLNotificationsUtil::add("ConfirmRestart", LLSD(), LLSD(),
  876. boost::bind(&LLPanelRegionDebugInfo::callbackRestart, (LLPanelRegionDebugInfo*)data, _1, _2));
  877. }
  878. bool LLPanelRegionDebugInfo::callbackRestart(const LLSD& notification, const LLSD& response)
  879. {
  880. S32 option = LLNotificationsUtil::getSelectedOption(notification, response);
  881. if (option != 0) return false;
  882. strings_t strings;
  883. strings.push_back("120");
  884. LLUUID invoice(LLFloaterRegionInfo::getLastInvoice());
  885. sendEstateOwnerMessage(gMessageSystem, "restart", invoice, strings);
  886. return false;
  887. }
  888. // static
  889. void LLPanelRegionDebugInfo::onClickCancelRestart(void* data)
  890. {
  891. LLPanelRegionDebugInfo* self = (LLPanelRegionDebugInfo*)data;
  892. strings_t strings;
  893. strings.push_back("-1");
  894. LLUUID invoice(LLFloaterRegionInfo::getLastInvoice());
  895. self->sendEstateOwnerMessage(gMessageSystem, "restart", invoice, strings);
  896. }
  897. BOOL LLPanelRegionTerrainInfo::validateTextureSizes()
  898. {
  899. for(S32 i = 0; i < TERRAIN_TEXTURE_COUNT; ++i)
  900. {
  901. std::string buffer;
  902. buffer = llformat("texture_detail_%d", i);
  903. LLTextureCtrl* texture_ctrl = getChild<LLTextureCtrl>(buffer);
  904. if (!texture_ctrl) continue;
  905. LLUUID image_asset_id = texture_ctrl->getImageAssetID();
  906. LLViewerTexture* img = LLViewerTextureManager::getFetchedTexture(image_asset_id);
  907. S32 components = img->getComponents();
  908. // Must ask for highest resolution version's width. JC
  909. S32 width = img->getFullWidth();
  910. S32 height = img->getFullHeight();
  911. //llinfos << "texture detail " << i << " is " << width << "x" << height << "x" << components << llendl;
  912. if (components != 3)
  913. {
  914. LLSD args;
  915. args["TEXTURE_NUM"] = i+1;
  916. args["TEXTURE_BIT_DEPTH"] = llformat("%d",components * 8);
  917. LLNotificationsUtil::add("InvalidTerrainBitDepth", args);
  918. return FALSE;
  919. }
  920. if (width > 512 || height > 512)
  921. {
  922. LLSD args;
  923. args["TEXTURE_NUM"] = i+1;
  924. args["TEXTURE_SIZE_X"] = width;
  925. args["TEXTURE_SIZE_Y"] = height;
  926. LLNotificationsUtil::add("InvalidTerrainSize", args);
  927. return FALSE;
  928. }
  929. }
  930. return TRUE;
  931. }
  932. /////////////////////////////////////////////////////////////////////////////
  933. // LLPanelRegionTerrainInfo
  934. /////////////////////////////////////////////////////////////////////////////
  935. // Initialize statics
  936. BOOL LLPanelRegionTerrainInfo::postBuild()
  937. {
  938. LLPanelRegionInfo::postBuild();
  939. initCtrl("water_height_spin");
  940. initCtrl("terrain_raise_spin");
  941. initCtrl("terrain_lower_spin");
  942. std::string buffer;
  943. for(S32 i = 0; i < TERRAIN_TEXTURE_COUNT; ++i)
  944. {
  945. buffer = llformat("texture_detail_%d", i);
  946. initCtrl(buffer);
  947. }
  948. for(S32 i = 0; i < CORNER_COUNT; ++i)
  949. {
  950. buffer = llformat("height_start_spin_%d", i);
  951. initCtrl(buffer);
  952. buffer = llformat("height_range_spin_%d", i);
  953. initCtrl(buffer);
  954. }
  955. childSetAction("download_raw_btn", onClickDownloadRaw, this);
  956. childSetAction("upload_raw_btn", onClickUploadRaw, this);
  957. childSetAction("bake_terrain_btn", onClickBakeTerrain, this);
  958. return LLPanelRegionInfo::postBuild();
  959. }
  960. // virtual
  961. bool LLPanelRegionTerrainInfo::refreshFromRegion(LLViewerRegion* region)
  962. {
  963. BOOL owner_or_god = gAgent.isGodlike()
  964. || (region && (region->getOwner() == gAgent.getID()));
  965. BOOL owner_or_god_or_manager = owner_or_god
  966. || (region && region->isEstateManager());
  967. setCtrlsEnabled(owner_or_god_or_manager);
  968. getChildView("apply_btn")->setEnabled(FALSE);
  969. if (region)
  970. {
  971. getChild<LLUICtrl>("region_text")->setValue(LLSD(region->getName()));
  972. LLVLComposition* compp = region->getComposition();
  973. LLTextureCtrl* texture_ctrl;
  974. std::string buffer;
  975. for(S32 i = 0; i < TERRAIN_TEXTURE_COUNT; ++i)
  976. {
  977. buffer = llformat("texture_detail_%d", i);
  978. texture_ctrl = getChild<LLTextureCtrl>(buffer);
  979. if(texture_ctrl)
  980. {
  981. lldebugs << "Detail Texture " << i << ": "
  982. << compp->getDetailTextureID(i) << llendl;
  983. LLUUID tmp_id(compp->getDetailTextureID(i));
  984. texture_ctrl->setImageAssetID(tmp_id);
  985. }
  986. }
  987. for(S32 i = 0; i < CORNER_COUNT; ++i)
  988. {
  989. buffer = llformat("height_start_spin_%d", i);
  990. getChild<LLUICtrl>(buffer)->setValue(LLSD(compp->getStartHeight(i)));
  991. buffer = llformat("height_range_spin_%d", i);
  992. getChild<LLUICtrl>(buffer)->setValue(LLSD(compp->getHeightRange(i)));
  993. }
  994. }
  995. else
  996. {
  997. lldebugs << "no region set" << llendl;
  998. getChild<LLUICtrl>("region_text")->setValue(LLSD(""));
  999. }
  1000. getChildView("download_raw_btn")->setEnabled(owner_or_god);
  1001. getChildView("upload_raw_btn")->setEnabled(owner_or_god);
  1002. getChildView("bake_terrain_btn")->setEnabled(owner_or_god);
  1003. return LLPanelRegionInfo::refreshFromRegion(region);
  1004. }
  1005. // virtual
  1006. BOOL LLPanelRegionTerrainInfo::sendUpdate()
  1007. {
  1008. llinfos << "LLPanelRegionTerrainInfo::sendUpdate" << llendl;
  1009. std::string buffer;
  1010. strings_t strings;
  1011. LLUUID invoice(LLFloaterRegionInfo::getLastInvoice());
  1012. // update the model
  1013. LLRegionInfoModel& region_info = LLRegionInfoModel::instance();
  1014. region_info.mWaterHeight = (F32) getChild<LLUICtrl>("water_height_spin")->getValue().asReal();
  1015. region_info.mTerrainRaiseLimit = (F32) getChild<LLUICtrl>("terrain_raise_spin")->getValue().asReal();
  1016. region_info.mTerrainLowerLimit = (F32) getChild<LLUICtrl>("terrain_lower_spin")->getValue().asReal();
  1017. // and sync the region with it
  1018. region_info.sendRegionTerrain(invoice);
  1019. // =======================================
  1020. // Assemble and send texturedetail message
  1021. // Make sure user hasn't chosen wacky textures.
  1022. if (!validateTextureSizes())
  1023. {
  1024. return FALSE;
  1025. }
  1026. LLTextureCtrl* texture_ctrl;
  1027. std::string id_str;
  1028. LLMessageSystem* msg = gMessageSystem;
  1029. for(S32 i = 0; i < TERRAIN_TEXTURE_COUNT; ++i)
  1030. {
  1031. buffer = llformat("texture_detail_%d", i);
  1032. texture_ctrl = getChild<LLTextureCtrl>(buffer);
  1033. if(texture_ctrl)
  1034. {
  1035. LLUUID tmp_id(texture_ctrl->getImageAssetID());
  1036. tmp_id.toString(id_str);
  1037. buffer = llformat("%d %s", i, id_str.c_str());
  1038. strings.push_back(buffer);
  1039. }
  1040. }
  1041. sendEstateOwnerMessage(msg, "texturedetail", invoice, strings);
  1042. strings.clear();
  1043. // ========================================
  1044. // Assemble and send textureheights message
  1045. for(S32 i = 0; i < CORNER_COUNT; ++i)
  1046. {
  1047. buffer = llformat("height_start_spin_%d", i);
  1048. std::string buffer2 = llformat("height_range_spin_%d", i);
  1049. std::string buffer3 = llformat("%d %f %f", i, (F32)getChild<LLUICtrl>(buffer)->getValue().asReal(), (F32)getChild<LLUICtrl>(buffer2)->getValue().asReal());
  1050. strings.push_back(buffer3);
  1051. }
  1052. sendEstateOwnerMessage(msg, "textureheights", invoice, strings);
  1053. strings.clear();
  1054. // ========================================
  1055. // Send texturecommit message
  1056. sendEstateOwnerMessage(msg, "texturecommit", invoice, strings);
  1057. return TRUE;
  1058. }
  1059. // static
  1060. void LLPanelRegionTerrainInfo::onClickDownloadRaw(void* data)
  1061. {
  1062. LLFilePicker& picker = LLFilePicker::instance();
  1063. if (!picker.getSaveFile(LLFilePicker::FFSAVE_RAW, "terrain.raw"))
  1064. {
  1065. llwarns << "No file" << llendl;
  1066. return;
  1067. }
  1068. std::string filepath = picker.getFirstFile();
  1069. gXferManager->expectFileForRequest(filepath);
  1070. LLPanelRegionTerrainInfo* self = (LLPanelRegionTerrainInfo*)data;
  1071. strings_t strings;
  1072. strings.push_back("download filename");
  1073. strings.push_back(filepath);
  1074. LLUUID invoice(LLFloaterRegionInfo::getLastInvoice());
  1075. self->sendEstateOwnerMessage(gMessageSystem, "terrain", invoice, strings);
  1076. }
  1077. // static
  1078. void LLPanelRegionTerrainInfo::onClickUploadRaw(void* data)
  1079. {
  1080. LLFilePicker& picker = LLFilePicker::instance();
  1081. if (!picker.getOpenFile(LLFilePicker::FFLOAD_RAW))
  1082. {
  1083. llwarns << "No file" << llendl;
  1084. return;
  1085. }
  1086. std::string filepath = picker.getFirstFile();
  1087. gXferManager->expectFileForTransfer(filepath);
  1088. LLPanelRegionTerrainInfo* self = (LLPanelRegionTerrainInfo*)data;
  1089. strings_t strings;
  1090. strings.push_back("upload filename");
  1091. strings.push_back(filepath);
  1092. LLUUID invoice(LLFloaterRegionInfo::getLastInvoice());
  1093. self->sendEstateOwnerMessage(gMessageSystem, "terrain", invoice, strings);
  1094. LLNotificationsUtil::add("RawUploadStarted");
  1095. }
  1096. // static
  1097. void LLPanelRegionTerrainInfo::onClickBakeTerrain(void* data)
  1098. {
  1099. LLNotificationsUtil::add("ConfirmBakeTerrain", LLSD(), LLSD(), boost::bind(&LLPanelRegionTerrainInfo::callbackBakeTerrain, (LLPanelRegionTerrainInfo*)data, _1, _2));
  1100. }
  1101. bool LLPanelRegionTerrainInfo::callbackBakeTerrain(const LLSD& notification, const LLSD& response)
  1102. {
  1103. S32 option = LLNotificationsUtil::getSelectedOption(notification, response);
  1104. if (option != 0) return false;
  1105. strings_t strings;
  1106. strings.push_back("bake");
  1107. LLUUID invoice(LLFloaterRegionInfo::getLastInvoice());
  1108. sendEstateOwnerMessage(gMessageSystem, "terrain", invoice, strings);
  1109. return false;
  1110. }
  1111. /////////////////////////////////////////////////////////////////////////////
  1112. // LLPanelEstateInfo
  1113. //
  1114. LLPanelEstateInfo::LLPanelEstateInfo()
  1115. : LLPanelRegionInfo(),
  1116. mEstateID(0) // invalid
  1117. {
  1118. LLEstateInfoModel& estate_info = LLEstateInfoModel::instance();
  1119. estate_info.setCommitCallback(boost::bind(&LLPanelEstateInfo::refreshFromEstate, this));
  1120. estate_info.setUpdateCallback(boost::bind(&LLPanelEstateInfo::refreshFromEstate, this));
  1121. }
  1122. // static
  1123. void LLPanelEstateInfo::initDispatch(LLDispatcher& dispatch)
  1124. {
  1125. std::string name;
  1126. // name.assign("setowner");
  1127. // static LLDispatchSetEstateOwner set_owner;
  1128. // dispatch.addHandler(name, &set_owner);
  1129. name.assign("estateupdateinfo");
  1130. static LLDispatchEstateUpdateInfo estate_update_info;
  1131. dispatch.addHandler(name, &estate_update_info);
  1132. name.assign("setaccess");
  1133. static LLDispatchSetEstateAccess set_access;
  1134. dispatch.addHandler(name, &set_access);
  1135. estate_dispatch_initialized = true;
  1136. }
  1137. //---------------------------------------------------------------------------
  1138. // Add/Remove estate access button callbacks
  1139. //---------------------------------------------------------------------------
  1140. void LLPanelEstateInfo::onClickAddAllowedAgent()
  1141. {
  1142. LLCtrlListInterface *list = childGetListInterface("allowed_avatar_name_list");
  1143. if (!list) return;
  1144. if (list->getItemCount() >= ESTATE_MAX_ACCESS_IDS)
  1145. {
  1146. //args
  1147. LLSD args;
  1148. args["MAX_AGENTS"] = llformat("%d",ESTATE_MAX_ACCESS_IDS);
  1149. LLNotificationsUtil::add("MaxAllowedAgentOnRegion", args);
  1150. return;
  1151. }
  1152. accessAddCore(ESTATE_ACCESS_ALLOWED_AGENT_ADD, "EstateAllowedAgentAdd");
  1153. }
  1154. void LLPanelEstateInfo::onClickRemoveAllowedAgent()
  1155. {
  1156. accessRemoveCore(ESTATE_ACCESS_ALLOWED_AGENT_REMOVE, "EstateAllowedAgentRemove", "allowed_avatar_name_list");
  1157. }
  1158. void LLPanelEstateInfo::onClickAddAllowedGroup()
  1159. {
  1160. LLCtrlListInterface *list = childGetListInterface("allowed_group_name_list");
  1161. if (!list) return;
  1162. if (list->getItemCount() >= ESTATE_MAX_ACCESS_IDS)
  1163. {
  1164. LLSD args;
  1165. args["MAX_GROUPS"] = llformat("%d",ESTATE_MAX_ACCESS_IDS);
  1166. LLNotificationsUtil::add("MaxAllowedGroupsOnRegion", args);
  1167. return;
  1168. }
  1169. LLNotification::Params params("ChangeLindenAccess");
  1170. params.functor.function(boost::bind(&LLPanelEstateInfo::addAllowedGroup, this, _1, _2));
  1171. if (isLindenEstate())
  1172. {
  1173. LLNotifications::instance().add(params);
  1174. }
  1175. else
  1176. {
  1177. LLNotifications::instance().forceResponse(params, 0);
  1178. }
  1179. }
  1180. bool LLPanelEstateInfo::addAllowedGroup(const LLSD& notification, const LLSD& response)
  1181. {
  1182. S32 option = LLNotificationsUtil::getSelectedOption(notification, response);
  1183. if (option != 0) return false;
  1184. LLFloater* parent_floater = gFloaterView->getParentFloater(this);
  1185. LLFloaterGroupPicker* widget = LLFloaterReg::showTypedInstance<LLFloaterGroupPicker>("group_picker", LLSD(gAgent.getID()));
  1186. if (widget)
  1187. {
  1188. widget->removeNoneOption();
  1189. widget->setSelectGroupCallback(boost::bind(&LLPanelEstateInfo::addAllowedGroup2, this, _1));
  1190. if (parent_floater)
  1191. {
  1192. LLRect new_rect = gFloaterView->findNeighboringPosition(parent_floater, widget);
  1193. widget->setOrigin(new_rect.mLeft, new_rect.mBottom);
  1194. parent_floater->addDependentFloater(widget);
  1195. }
  1196. }
  1197. return false;
  1198. }
  1199. void LLPanelEstateInfo::onClickRemoveAllowedGroup()
  1200. {
  1201. accessRemoveCore(ESTATE_ACCESS_ALLOWED_GROUP_REMOVE, "EstateAllowedGroupRemove", "allowed_group_name_list");
  1202. }
  1203. void LLPanelEstateInfo::onClickAddBannedAgent()
  1204. {
  1205. LLCtrlListInterface *list = childGetListInterface("banned_avatar_name_list");
  1206. if (!list) return;
  1207. if (list->getItemCount() >= ESTATE_MAX_ACCESS_IDS)
  1208. {
  1209. LLSD args;
  1210. args["MAX_BANNED"] = llformat("%d",ESTATE_MAX_ACCESS_IDS);
  1211. LLNotificationsUtil::add("MaxBannedAgentsOnRegion", args);
  1212. return;
  1213. }
  1214. accessAddCore(ESTATE_ACCESS_BANNED_AGENT_ADD, "EstateBannedAgentAdd");
  1215. }
  1216. void LLPanelEstateInfo::onClickRemoveBannedAgent()
  1217. {
  1218. accessRemoveCore(ESTATE_ACCESS_BANNED_AGENT_REMOVE, "EstateBannedAgentRemove", "banned_avatar_name_list");
  1219. }
  1220. // static
  1221. void LLPanelEstateInfo::onClickAddEstateManager()
  1222. {
  1223. LLCtrlListInterface *list = childGetListInterface("estate_manager_name_list");
  1224. if (!list) return;
  1225. if (list->getItemCount() >= ESTATE_MAX_MANAGERS)
  1226. { // Tell user they can't add more managers
  1227. LLSD args;
  1228. args["MAX_MANAGER"] = llformat("%d",ESTATE_MAX_MANAGERS);
  1229. LLNotificationsUtil::add("MaxManagersOnRegion", args);
  1230. }
  1231. else
  1232. { // Go pick managers to add
  1233. accessAddCore(ESTATE_ACCESS_MANAGER_ADD, "EstateManagerAdd");
  1234. }
  1235. }
  1236. // static
  1237. void LLPanelEstateInfo::onClickRemoveEstateManager()
  1238. {
  1239. accessRemoveCore(ESTATE_ACCESS_MANAGER_REMOVE, "EstateManagerRemove", "estate_manager_name_list");
  1240. }
  1241. //---------------------------------------------------------------------------
  1242. // Kick from estate methods
  1243. //---------------------------------------------------------------------------
  1244. void LLPanelEstateInfo::onClickKickUser()
  1245. {
  1246. // this depends on the grandparent view being a floater
  1247. // in order to set up floater dependency
  1248. LLFloater* parent_floater = gFloaterView->getParentFloater(this);
  1249. LLFloater* child_floater = LLFloaterAvatarPicker::show(boost::bind(&LLPanelEstateInfo::onKickUserCommit, this, _1), FALSE, TRUE);
  1250. parent_floater->addDependentFloater(child_floater);
  1251. }
  1252. void LLPanelEstateInfo::onKickUserCommit(const uuid_vec_t& ids)
  1253. {
  1254. if (ids.empty()) return;
  1255. //Bring up a confirmation dialog
  1256. LLSD args;
  1257. args["EVIL_USER"] = LLSLURL("agent", ids[0], "completename").getSLURLString();
  1258. LLSD payload;
  1259. payload["agent_id"] = ids[0];
  1260. LLNotificationsUtil::add("EstateKickUser", args, payload, boost::bind(&LLPanelEstateInfo::kickUserConfirm, this, _1, _2));
  1261. }
  1262. bool LLPanelEstateInfo::kickUserConfirm(const LLSD& notification, const LLSD& response)
  1263. {
  1264. S32 option = LLNotificationsUtil::getSelectedOption(notification, response);
  1265. switch(option)
  1266. {
  1267. case 0:
  1268. {
  1269. //Kick User
  1270. strings_t strings;
  1271. strings.push_back(notification["payload"]["agent_id"].asString());
  1272. sendEstateOwnerMessage(gMessageSystem, "kickestate", LLFloaterRegionInfo::getLastInvoice(), strings);
  1273. break;
  1274. }
  1275. default:
  1276. break;
  1277. }
  1278. return false;
  1279. }
  1280. //---------------------------------------------------------------------------
  1281. // Core Add/Remove estate access methods
  1282. // TODO: INTERNATIONAL: don't build message text here;
  1283. // instead, create multiple translatable messages and choose
  1284. // one based on the status.
  1285. //---------------------------------------------------------------------------
  1286. std::string all_estates_text()
  1287. {
  1288. LLPanelEstateInfo* panel = LLFloaterRegionInfo::getPanelEstate();
  1289. if (!panel) return "(" + LLTrans::getString("RegionInfoError") + ")";
  1290. LLStringUtil::format_map_t args;
  1291. std::string owner = panel->getOwnerName();
  1292. LLViewerRegion* region = gAgent.getRegion();
  1293. if (gAgent.isGodlike())
  1294. {
  1295. args["[OWNER]"] = owner.c_str();
  1296. return LLTrans::getString("RegionInfoAllEstatesOwnedBy", args);
  1297. }
  1298. else if (region && region->getOwner() == gAgent.getID())
  1299. {
  1300. return LLTrans::getString("RegionInfoAllEstatesYouOwn");
  1301. }
  1302. else if (region && region->isEstateManager())
  1303. {
  1304. args["[OWNER]"] = owner.c_str();
  1305. return LLTrans::getString("RegionInfoAllEstatesYouManage", args);
  1306. }
  1307. else
  1308. {
  1309. return "(" + LLTrans::getString("RegionInfoError") + ")";
  1310. }
  1311. }
  1312. // static
  1313. bool LLPanelEstateInfo::isLindenEstate()
  1314. {
  1315. U32 estate_id = LLEstateInfoModel::instance().getID();
  1316. return (estate_id <= ESTATE_LAST_LINDEN);
  1317. }
  1318. struct LLEstateAccessChangeInfo
  1319. {
  1320. LLEstateAccessChangeInfo(const LLSD& sd)
  1321. {
  1322. mDialogName = sd["dialog_name"].asString();
  1323. mOperationFlag = (U32)sd["operation"].asInteger();
  1324. LLSD::array_const_iterator end_it = sd["allowed_ids"].endArray();
  1325. for (LLSD::array_const_iterator id_it = sd["allowed_ids"].beginArray();
  1326. id_it != end_it;
  1327. ++id_it)
  1328. {
  1329. mAgentOrGroupIDs.push_back(id_it->asUUID());
  1330. }
  1331. }
  1332. const LLSD asLLSD() const
  1333. {
  1334. LLSD sd;
  1335. sd["name"] = mDialogName;
  1336. sd["operation"] = (S32)mOperationFlag;
  1337. for (uuid_vec_t::const_iterator it = mAgentOrGroupIDs.begin();
  1338. it != mAgentOrGroupIDs.end();
  1339. ++it)
  1340. {
  1341. sd["allowed_ids"].append(*it);
  1342. }
  1343. return sd;
  1344. }
  1345. U32 mOperationFlag; // ESTATE_ACCESS_BANNED_AGENT_ADD, _REMOVE, etc.
  1346. std::string mDialogName;
  1347. uuid_vec_t mAgentOrGroupIDs; // List of agent IDs to apply to this change
  1348. };
  1349. // Special case callback for groups, since it has different callback format than names
  1350. void LLPanelEstateInfo::addAllowedGroup2(LLUUID id)
  1351. {
  1352. LLSD payload;
  1353. payload["operation"] = (S32)ESTATE_ACCESS_ALLOWED_GROUP_ADD;
  1354. payload["dialog_name"] = "EstateAllowedGroupAdd";
  1355. payload["allowed_ids"].append(id);
  1356. LLSD args;
  1357. args["ALL_ESTATES"] = all_estates_text();
  1358. LLNotification::Params params("EstateAllowedGroupAdd");
  1359. params.payload(payload)
  1360. .substitutions(args)
  1361. .functor.function(accessCoreConfirm);
  1362. if (isLindenEstate())
  1363. {
  1364. LLNotifications::instance().forceResponse(params, 0);
  1365. }
  1366. else
  1367. {
  1368. LLNotifications::instance().add(params);
  1369. }
  1370. }
  1371. // static
  1372. void LLPanelEstateInfo::accessAddCore(U32 operation_flag, const std::string& dialog_name)
  1373. {
  1374. LLSD payload;
  1375. payload["operation"] = (S32)operation_flag;
  1376. payload["dialog_name"] = dialog_name;
  1377. // agent id filled in after avatar picker
  1378. LLNotification::Params params("ChangeLindenAccess");
  1379. params.payload(payload)
  1380. .functor.function(accessAddCore2);
  1381. if (isLindenEstate())
  1382. {
  1383. LLNotifications::instance().add(params);
  1384. }
  1385. else
  1386. {
  1387. // same as clicking "OK"
  1388. LLNotifications::instance().forceResponse(params, 0);
  1389. }
  1390. }
  1391. // static
  1392. bool LLPanelEstateInfo::accessAddCore2(const LLSD& notification, const LLSD& response)
  1393. {
  1394. S32 option = LLNotificationsUtil::getSelectedOption(notification, response);
  1395. if (option != 0)
  1396. {
  1397. // abort change
  1398. return false;
  1399. }
  1400. LLEstateAccessChangeInfo* change_info = new LLEstateAccessChangeInfo(notification["payload"]);
  1401. // avatar picker yes multi-select, yes close-on-select
  1402. LLFloaterAvatarPicker::show(boost::bind(&LLPanelEstateInfo::accessAddCore3, _1, (void*)change_info), TRUE, TRUE);
  1403. return false;
  1404. }
  1405. // static
  1406. void LLPanelEstateInfo::accessAddCore3(const uuid_vec_t& ids, void* data)
  1407. {
  1408. LLEstateAccessChangeInfo* change_info = (LLEstateAccessChangeInfo*)data;
  1409. if (!change_info) return;
  1410. if (ids.empty())
  1411. {
  1412. // User didn't select a name.
  1413. delete change_info;
  1414. change_info = NULL;
  1415. return;
  1416. }
  1417. // User did select a name.
  1418. change_info->mAgentOrGroupIDs = ids;
  1419. // Can't put estate owner on ban list
  1420. LLPanelEstateInfo* panel = LLFloaterRegionInfo::getPanelEstate();
  1421. if (!panel) return;
  1422. LLViewerRegion* region = gAgent.getRegion();
  1423. if (!region) return;
  1424. if (change_info->mOperationFlag & ESTATE_ACCESS_ALLOWED_AGENT_ADD)
  1425. {
  1426. LLCtrlListInterface *list = panel->childGetListInterface("allowed_avatar_name_list");
  1427. int currentCount = (list ? list->getItemCount() : 0);
  1428. if (ids.size() + currentCount > ESTATE_MAX_ACCESS_IDS)
  1429. {
  1430. LLSD args;
  1431. args["NUM_ADDED"] = llformat("%d",ids.size());
  1432. args["MAX_AGENTS"] = llformat("%d",ESTATE_MAX_ACCESS_IDS);
  1433. args["LIST_TYPE"] = "Allowed Residents";
  1434. args["NUM_EXCESS"] = llformat("%d",(ids.size()+currentCount)-ESTATE_MAX_ACCESS_IDS);
  1435. LLNotificationsUtil::add("MaxAgentOnRegionBatch", args);
  1436. delete change_info;
  1437. return;
  1438. }
  1439. }
  1440. if (change_info->mOperationFlag & ESTATE_ACCESS_BANNED_AGENT_ADD)
  1441. {
  1442. LLCtrlListInterface *list = panel->childGetListInterface("banned_avatar_name_list");
  1443. int currentCount = (list ? list->getItemCount() : 0);
  1444. if (ids.size() + currentCount > ESTATE_MAX_ACCESS_IDS)
  1445. {
  1446. LLSD args;
  1447. args["NUM_ADDED"] = llformat("%d",ids.size());
  1448. args["MAX_AGENTS"] = llformat("%d",ESTATE_MAX_ACCESS_IDS);
  1449. args["LIST_TYPE"] = "Banned Residents";
  1450. args["NUM_EXCESS"] = llformat("%d",(ids.size()+currentCount)-ESTATE_MAX_ACCESS_IDS);
  1451. LLNotificationsUtil::add("MaxAgentOnRegionBatch", args);
  1452. delete change_info;
  1453. return;
  1454. }
  1455. }
  1456. LLSD args;
  1457. args["ALL_ESTATES"] = all_estates_text();
  1458. LLNotification::Params params(change_info->mDialogName);
  1459. params.substitutions(args)
  1460. .payload(change_info->asLLSD())
  1461. .functor.function(accessCoreConfirm);
  1462. if (isLindenEstate())
  1463. {
  1464. // just apply to this estate
  1465. LLNotifications::instance().forceResponse(params, 0);
  1466. }
  1467. else
  1468. {
  1469. // ask if this estate or all estates with this owner
  1470. LLNotifications::instance().add(params);
  1471. }
  1472. }
  1473. // static
  1474. void LLPanelEstateInfo::accessRemoveCore(U32 operation_flag, const std::string& dialog_name, const std::string& list_ctrl_name)
  1475. {
  1476. LLPanelEstateInfo* panel = LLFloaterRegionInfo::getPanelEstate();
  1477. if (!panel) return;
  1478. LLNameListCtrl* name_list = panel->getChild<LLNameListCtrl>(list_ctrl_name);
  1479. if (!name_list) return;
  1480. std::vector<LLScrollListItem*> list_vector = name_list->getAllSelected();
  1481. if (list_vector.size() == 0)
  1482. return;
  1483. LLSD payload;
  1484. payload["operation"] = (S32)operation_flag;
  1485. payload["dialog_name"] = dialog_name;
  1486. for (std::vector<LLScrollListItem*>::const_iterator iter = list_vector.begin();
  1487. iter != list_vector.end();
  1488. iter++)
  1489. {
  1490. LLScrollListItem *item = (*iter);
  1491. payload["allowed_ids"].append(item->getUUID());
  1492. }
  1493. LLNotification::Params params("ChangeLindenAccess");
  1494. params.payload(payload)
  1495. .functor.function(accessRemoveCore2);
  1496. if (isLindenEstate())
  1497. {
  1498. // warn on change linden estate
  1499. LLNotifications::instance().add(params);
  1500. }
  1501. else
  1502. {
  1503. // just proceed, as if clicking OK
  1504. LLNotifications::instance().forceResponse(params, 0);
  1505. }
  1506. }
  1507. // static
  1508. bool LLPanelEstateInfo::accessRemoveCore2(const LLSD& notification, const LLSD& response)
  1509. {
  1510. S32 option = LLNotificationsUtil::getSelectedOption(notification, response);
  1511. if (option != 0)
  1512. {
  1513. // abort
  1514. return false;
  1515. }
  1516. // If Linden estate, can only apply to "this" estate, not all estates
  1517. // owned by NULL.
  1518. if (isLindenEstate())
  1519. {
  1520. accessCoreConfirm(notification, response);
  1521. }
  1522. else
  1523. {
  1524. LLSD args;
  1525. args["ALL_ESTATES"] = all_estates_text();
  1526. LLNotificationsUtil::add(notification["payload"]["dialog_name"],
  1527. args,
  1528. notification["payload"],
  1529. accessCoreConfirm);
  1530. }
  1531. return false;
  1532. }
  1533. // Used for both access add and remove operations, depending on the mOperationFlag
  1534. // passed in (ESTATE_ACCESS_BANNED_AGENT_ADD, ESTATE_ACCESS_ALLOWED_AGENT_REMOVE, etc.)
  1535. // static
  1536. bool LLPanelEstateInfo::accessCoreConfirm(const LLSD& notification, const LLSD& response)
  1537. {
  1538. S32 option = LLNotificationsUtil::getSelectedOption(notification, response);
  1539. const U32 originalFlags = (U32)notification["payload"]["operation"].asInteger();
  1540. LLViewerRegion* region = gAgent.getRegion();
  1541. LLSD::array_const_iterator end_it = notification["payload"]["allowed_ids"].endArray();
  1542. for (LLSD::array_const_iterator iter = notification["payload"]["allowed_ids"].beginArray();
  1543. iter != end_it;
  1544. iter++)
  1545. {
  1546. U32 flags = originalFlags;
  1547. if (iter + 1 != end_it)
  1548. flags |= ESTATE_ACCESS_NO_REPLY;
  1549. const LLUUID id = iter->asUUID();
  1550. if (((U32)notification["payload"]["operation"].asInteger() & ESTATE_ACCESS_BANNED_AGENT_ADD)
  1551. && region && (region->getOwner() == id))
  1552. {
  1553. LLNotificationsUtil::add("OwnerCanNotBeDenied");
  1554. break;
  1555. }
  1556. switch(option)
  1557. {
  1558. case 0:
  1559. // This estate
  1560. sendEstateAccessDelta(flags, id);
  1561. break;
  1562. case 1:
  1563. {
  1564. // All estates, either than I own or manage for this owner.
  1565. // This will be verified on simulator. JC
  1566. if (!region) break;
  1567. if (region->getOwner() == gAgent.getID()
  1568. || gAgent.isGodlike())
  1569. {
  1570. flags |= ESTATE_ACCESS_APPLY_TO_ALL_ESTATES;
  1571. sendEstateAccessDelta(flags, id);
  1572. }
  1573. else if (region->isEstateManager())
  1574. {
  1575. flags |= ESTATE_ACCESS_APPLY_TO_MANAGED_ESTATES;
  1576. sendEstateAccessDelta(flags, id);
  1577. }
  1578. break;
  1579. }
  1580. case 2:
  1581. default:
  1582. break;
  1583. }
  1584. }
  1585. return false;
  1586. }
  1587. // key = "estateaccessdelta"
  1588. // str(estate_id) will be added to front of list by forward_EstateOwnerRequest_to_dataserver
  1589. // str[0] = str(agent_id) requesting the change
  1590. // str[1] = str(flags) (ESTATE_ACCESS_DELTA_*)
  1591. // str[2] = str(agent_id) to add or remove
  1592. // static
  1593. void LLPanelEstateInfo::sendEstateAccessDelta(U32 flags, const LLUUID& agent_or_group_id)
  1594. {
  1595. LLMessageSystem* msg = gMessageSystem;
  1596. msg->newMessage("EstateOwnerMessage");
  1597. msg->nextBlockFast(_PREHASH_AgentData);
  1598. msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
  1599. msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
  1600. msg->addUUIDFast(_PREHASH_TransactionID, LLUUID::null); //not used
  1601. msg->nextBlock("MethodData");
  1602. msg->addString("Method", "estateaccessdelta");
  1603. msg->addUUID("Invoice", LLFloaterRegionInfo::getLastInvoice());
  1604. std::string buf;
  1605. gAgent.getID().toString(buf);
  1606. msg->nextBlock("ParamList");
  1607. msg->addString("Parameter", buf);
  1608. buf = llformat("%u", flags);
  1609. msg->nextBlock("ParamList");
  1610. msg->addString("Parameter", buf);
  1611. agent_or_group_id.toString(buf);
  1612. msg->nextBlock("ParamList");
  1613. msg->addString("Parameter", buf);
  1614. LLPanelEstateInfo* panel = LLFloaterRegionInfo::getPanelEstate();
  1615. if (flags & (ESTATE_ACCESS_ALLOWED_AGENT_ADD | ESTATE_ACCESS_ALLOWED_AGENT_REMOVE |
  1616. ESTATE_ACCESS_BANNED_AGENT_ADD | ESTATE_ACCESS_BANNED_AGENT_REMOVE))
  1617. {
  1618. panel->clearAccessLists();
  1619. }
  1620. gAgent.sendReliableMessage();
  1621. }
  1622. void LLPanelEstateInfo::updateControls(LLViewerRegion* region)
  1623. {
  1624. BOOL god = gAgent.isGodlike();
  1625. BOOL owner = (region && (region->getOwner() == gAgent.getID()));
  1626. BOOL manager = (region && region->isEstateManager());
  1627. setCtrlsEnabled(god || owner || manager);
  1628. getChildView("add_allowed_avatar_btn")->setEnabled(god || owner || manager);
  1629. getChildView("remove_allowed_avatar_btn")->setEnabled(god || owner || manager);
  1630. getChildView("add_allowed_group_btn")->setEnabled(god || owner || manager);
  1631. getChildView("remove_allowed_group_btn")->setEnabled(god || owner || manager);
  1632. // Can't ban people from mainland, orientation islands, etc. because this
  1633. // creates much network traffic and server load.
  1634. // Disable their accounts in CSR tool instead.
  1635. bool linden_estate = isLindenEstate();
  1636. bool enable_ban = (god || owner || manager) && !linden_estate;
  1637. getChildView("add_banned_avatar_btn")->setEnabled(enable_ban);
  1638. getChildView("remove_banned_avatar_btn")->setEnabled(enable_ban);
  1639. getChildView("message_estate_btn")->setEnabled(god || owner || manager);
  1640. getChildView("kick_user_from_estate_btn")->setEnabled(god || owner || manager);
  1641. // estate managers can't add estate managers
  1642. getChildView("add_estate_manager_btn")->setEnabled(god || owner);
  1643. getChildView("remove_estate_manager_btn")->setEnabled(god || owner);
  1644. getChildView("estate_manager_name_list")->setEnabled(god || owner);
  1645. refresh();
  1646. }
  1647. bool LLPanelEstateInfo::refreshFromRegion(LLViewerRegion* region)
  1648. {
  1649. updateControls(region);
  1650. // let the parent class handle the general data collection.
  1651. bool rv = LLPanelRegionInfo::refreshFromRegion(region);
  1652. // We want estate info. To make sure it works across region
  1653. // boundaries and multiple packets, we add a serial number to the
  1654. // integers and track against that on update.
  1655. strings_t strings;
  1656. //integers_t integers;
  1657. //LLFloaterRegionInfo::incrementSerial();
  1658. LLFloaterRegionInfo::nextInvoice();
  1659. LLUUID invoice(LLFloaterRegionInfo::getLastInvoice());
  1660. //integers.push_back(LLFloaterRegionInfo::());::getPanelEstate();
  1661. LLPanelEstateInfo* panel = LLFloaterRegionInfo::getPanelEstate();
  1662. panel->clearAccessLists();
  1663. sendEstateOwnerMessage(gMessageSystem, "getinfo", invoice, strings);
  1664. refresh();
  1665. return rv;
  1666. }
  1667. void LLPanelEstateInfo::updateChild(LLUICtrl* child_ctrl)
  1668. {
  1669. if (checkRemovalButton(child_ctrl->getName()))
  1670. {
  1671. // do nothing
  1672. }
  1673. }
  1674. bool LLPanelEstateInfo::estateUpdate(LLMessageSystem* msg)
  1675. {
  1676. llinfos << "LLPanelEstateInfo::estateUpdate()" << llendl;
  1677. return false;
  1678. }
  1679. BOOL LLPanelEstateInfo::postBuild()
  1680. {
  1681. // set up the callbacks for the generic controls
  1682. initCtrl("externally_visible_check");
  1683. initCtrl("allow_direct_teleport");
  1684. initCtrl("limit_payment");
  1685. initCtrl("limit_age_verified");
  1686. initCtrl("voice_chat_check");
  1687. getChild<LLUICtrl>("allowed_avatar_name_list")->setCommitCallback(boost::bind(&LLPanelEstateInfo::onChangeChildCtrl, this, _1));
  1688. LLNameListCtrl *avatar_name_list = getChild<LLNameListCtrl>("allowed_avatar_name_list");
  1689. if (avatar_name_list)
  1690. {
  1691. avatar_name_list->setCommitOnSelectionChange(TRUE);
  1692. avatar_name_list->setMaxItemCount(ESTATE_MAX_ACCESS_IDS);
  1693. }
  1694. childSetAction("add_allowed_avatar_btn", boost::bind(&LLPanelEstateInfo::onClickAddAllowedAgent, this));
  1695. childSetAction("remove_allowed_avatar_btn", boost::bind(&LLPanelEstateInfo::onClickRemoveAllowedAgent, this));
  1696. getChild<LLUICtrl>("allowed_group_name_list")->setCommitCallback(boost::bind(&LLPanelEstateInfo::onChangeChildCtrl, this, _1));
  1697. LLNameListCtrl* group_name_list = getChild<LLNameListCtrl>("allowed_group_name_list");
  1698. if (group_name_list)
  1699. {
  1700. group_name_list->setCommitOnSelectionChange(TRUE);
  1701. group_name_list->setMaxItemCount(ESTATE_MAX_ACCESS_IDS);
  1702. }
  1703. getChild<LLUICtrl>("add_allowed_group_btn")->setCommitCallback(boost::bind(&LLPanelEstateInfo::onClickAddAllowedGroup, this));
  1704. childSetAction("remove_allowed_group_btn", boost::bind(&LLPanelEstateInfo::onClickRemoveAllowedGroup, this));
  1705. getChild<LLUICtrl>("banned_avatar_name_list")->setCommitCallback(boost::bind(&LLPanelEstateInfo::onChangeChildCtrl, this, _1));
  1706. LLNameListCtrl* banned_name_list = getChild<LLNameListCtrl>("banned_avatar_name_list");
  1707. if (banned_name_list)
  1708. {
  1709. banned_name_list->setCommitOnSelectionChange(TRUE);
  1710. banned_name_list->setMaxItemCount(ESTATE_MAX_ACCESS_IDS);
  1711. }
  1712. childSetAction("add_banned_avatar_btn", boost::bind(&LLPanelEstateInfo::onClickAddBannedAgent, this));
  1713. childSetAction("remove_banned_avatar_btn", boost::bind(&LLPanelEstateInfo::onClickRemoveBannedAgent, this));
  1714. getChild<LLUICtrl>("estate_manager_name_list")->setCommitCallback(boost::bind(&LLPanelEstateInfo::onChangeChildCtrl, this, _1));
  1715. LLNameListCtrl* manager_name_list = getChild<LLNameListCtrl>("estate_manager_name_list");
  1716. if (manager_name_list)
  1717. {
  1718. manager_name_list->setCommitOnSelectionChange(TRUE);
  1719. manager_name_list->setMaxItemCount(ESTATE_MAX_MANAGERS * 4); // Allow extras for dupe issue
  1720. }
  1721. childSetAction("add_estate_manager_btn", boost::bind(&LLPanelEstateInfo::onClickAddEstateManager, this));
  1722. childSetAction("remove_estate_manager_btn", boost::bind(&LLPanelEstateInfo::onClickRemoveEstateManager, this));
  1723. childSetAction("message_estate_btn", boost::bind(&LLPanelEstateInfo::onClickMessageEstate, this));
  1724. childSetAction("kick_user_from_estate_btn", boost::bind(&LLPanelEstateInfo::onClickKickUser, this));
  1725. return LLPanelRegionInfo::postBuild();
  1726. }
  1727. void LLPanelEstateInfo::refresh()
  1728. {
  1729. // Disable access restriction controls if they make no sense.
  1730. bool public_access = getChild<LLUICtrl>("externally_visible_check")->getValue().asBoolean();
  1731. getChildView("Only Allow")->setEnabled(public_access);
  1732. getChildView("limit_payment")->setEnabled(public_access);
  1733. getChildView("limit_age_verified")->setEnabled(public_access);
  1734. // if this is set to false, then the limit fields are meaningless and should be turned off
  1735. if (public_access == false)
  1736. {
  1737. getChild<LLUICtrl>("limit_payment")->setValue(false);
  1738. getChild<LLUICtrl>("limit_age_verified")->setValue(false);
  1739. }
  1740. }
  1741. void LLPanelEstateInfo::refreshFromEstate()
  1742. {
  1743. const LLEstateInfoModel& estate_info = LLEstateInfoModel::instance();
  1744. getChild<LLUICtrl>("estate_name")->setValue(estate_info.getName());
  1745. setOwnerName(LLSLURL("agent", estate_info.getOwnerID(), "inspect").getSLURLString());
  1746. getChild<LLUICtrl>("externally_visible_check")->setValue(estate_info.getIsExternallyVisible());
  1747. getChild<LLUICtrl>("voice_chat_check")->setValue(estate_i