aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llfloaterregioninfo.cpp
diff options
context:
space:
mode:
authorRevolutionSmythe2010-10-20 16:31:09 -0500
committerMcCabe Maxsted2010-11-01 16:58:02 -0700
commitaf6877fbfe94e80948c559cf77f008049f8168dc (patch)
tree4fe687aaec6a1b964a0e989d3c03c143b4ab07f6 /linden/indra/newview/llfloaterregioninfo.cpp
parentMerge remote branch 'thickbrick/weekly' into weekly (diff)
downloadmeta-impy-af6877fbfe94e80948c559cf77f008049f8168dc.zip
meta-impy-af6877fbfe94e80948c559cf77f008049f8168dc.tar.gz
meta-impy-af6877fbfe94e80948c559cf77f008049f8168dc.tar.bz2
meta-impy-af6877fbfe94e80948c559cf77f008049f8168dc.tar.xz
Finishes the OpenRegionSettings module, adds a new panel to Region/Estate for OpenRegionSettings, adds the new CAPS based WindLight Settings module, cleans up a few UI parts, and rebuilds the ToS window to support OpenSim regions better.
Diffstat (limited to 'linden/indra/newview/llfloaterregioninfo.cpp')
-rw-r--r--linden/indra/newview/llfloaterregioninfo.cpp6734
1 files changed, 3436 insertions, 3298 deletions
diff --git a/linden/indra/newview/llfloaterregioninfo.cpp b/linden/indra/newview/llfloaterregioninfo.cpp
index deee0f6..c7f1c38 100644
--- a/linden/indra/newview/llfloaterregioninfo.cpp
+++ b/linden/indra/newview/llfloaterregioninfo.cpp
@@ -1,3298 +1,3436 @@
1/** 1/**
2 * @file llfloaterregioninfo.cpp 2 * @file llfloaterregioninfo.cpp
3 * @author Aaron Brashears 3 * @author Aaron Brashears
4 * @brief Implementation of the region info and controls floater and panels. 4 * @brief Implementation of the region info and controls floater and panels.
5 * 5 *
6 * $LicenseInfo:firstyear=2004&license=viewergpl$ 6 * $LicenseInfo:firstyear=2004&license=viewergpl$
7 * 7 *
8 * Copyright (c) 2004-2009, Linden Research, Inc. 8 * Copyright (c) 2004-2009, Linden Research, Inc.
9 * 9 *
10 * Second Life Viewer Source Code 10 * Second Life Viewer Source Code
11 * The source code in this file ("Source Code") is provided by Linden Lab 11 * The source code in this file ("Source Code") is provided by Linden Lab
12 * to you under the terms of the GNU General Public License, version 2.0 12 * to you under the terms of the GNU General Public License, version 2.0
13 * ("GPL"), unless you have obtained a separate licensing agreement 13 * ("GPL"), unless you have obtained a separate licensing agreement
14 * ("Other License"), formally executed by you and Linden Lab. Terms of 14 * ("Other License"), formally executed by you and Linden Lab. Terms of
15 * the GPL can be found in doc/GPL-license.txt in this distribution, or 15 * the GPL can be found in doc/GPL-license.txt in this distribution, or
16 * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 16 * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
17 * 17 *
18 * There are special exceptions to the terms and conditions of the GPL as 18 * There are special exceptions to the terms and conditions of the GPL as
19 * it is applied to this Source Code. View the full text of the exception 19 * it is applied to this Source Code. View the full text of the exception
20 * in the file doc/FLOSS-exception.txt in this software distribution, or 20 * in the file doc/FLOSS-exception.txt in this software distribution, or
21 * online at 21 * online at
22 * http://secondlifegrid.net/programs/open_source/licensing/flossexception 22 * http://secondlifegrid.net/programs/open_source/licensing/flossexception
23 * 23 *
24 * By copying, modifying or distributing this software, you acknowledge 24 * By copying, modifying or distributing this software, you acknowledge
25 * that you have read and understood your obligations described above, 25 * that you have read and understood your obligations described above,
26 * and agree to abide by those obligations. 26 * and agree to abide by those obligations.
27 * 27 *
28 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO 28 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
29 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, 29 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
30 * COMPLETENESS OR PERFORMANCE. 30 * COMPLETENESS OR PERFORMANCE.
31 * $/LicenseInfo$ 31 * $/LicenseInfo$
32 */ 32 */
33 33
34#include "llviewerprecompiledheaders.h" 34#include "llviewerprecompiledheaders.h"
35#include "llfloaterregioninfo.h" 35#include "llfloaterregioninfo.h"
36 36
37#include <algorithm> 37#include <algorithm>
38#include <functional> 38#include <functional>
39 39
40#include "llcachename.h" 40#include "llcachename.h"
41#include "lldir.h" 41#include "lldir.h"
42#include "lldispatcher.h" 42#include "lldispatcher.h"
43#include "llglheaders.h" 43#include "llglheaders.h"
44#include "llregionflags.h" 44#include "llregionflags.h"
45#include "llstl.h" 45#include "llstl.h"
46#include "indra_constants.h" 46#include "indra_constants.h"
47#include "message.h" 47#include "message.h"
48 48
49#include "llagent.h" 49#include "llagent.h"
50#include "llalertdialog.h" 50#include "llalertdialog.h"
51#include "llappviewer.h" 51#include "llappviewer.h"
52#include "llfloateravatarpicker.h" 52#include "llfloateravatarpicker.h"
53#include "llbutton.h" 53#include "llbutton.h"
54#include "llcheckboxctrl.h" 54#include "llcheckboxctrl.h"
55#include "llcombobox.h" 55#include "llcombobox.h"
56#include "llfilepicker.h" 56#include "llfilepicker.h"
57#include "llfloaterdaycycle.h" 57#include "llfloaterdaycycle.h"
58#include "llfloatergodtools.h" // for send_sim_wide_deletes() 58#include "llfloatergodtools.h" // for send_sim_wide_deletes()
59#include "llfloatertopobjects.h" // added to fix SL-32336 59#include "llfloatertopobjects.h" // added to fix SL-32336
60#include "llfloatergroups.h" 60#include "llfloatergroups.h"
61#include "llfloatertelehub.h" 61#include "llfloatertelehub.h"
62#include "llfloaterwindlight.h" 62#include "llfloaterwindlight.h"
63#include "llinventorymodel.h" 63#include "llinventorymodel.h"
64#include "lllineeditor.h" 64#include "lllineeditor.h"
65#include "llalertdialog.h" 65#include "llalertdialog.h"
66#include "llnamelistctrl.h" 66#include "llnamelistctrl.h"
67#include "llsliderctrl.h" 67#include "llsliderctrl.h"
68#include "llspinctrl.h" 68#include "llspinctrl.h"
69#include "lltabcontainer.h" 69#include "lltabcontainer.h"
70#include "lltextbox.h" 70#include "lltextbox.h"
71#include "llinventory.h" 71#include "llinventory.h"
72#include "lltexturectrl.h" 72#include "lltexturectrl.h"
73#include "lltrans.h" 73#include "lltrans.h"
74#include "llviewercontrol.h" 74#include "llviewercontrol.h"
75#include "lluictrlfactory.h" 75#include "lluictrlfactory.h"
76#include "llviewerimage.h" 76#include "llviewerimage.h"
77#include "llviewerimagelist.h" 77#include "llviewerimagelist.h"
78#include "llviewerregion.h" 78#include "llviewerregion.h"
79#include "llviewerstats.h" 79#include "llviewerstats.h"
80#include "llviewertexteditor.h" 80#include "llviewertexteditor.h"
81#include "llviewerwindow.h" 81#include "llviewerwindow.h"
82#include "llvlcomposition.h" 82#include "llvlcomposition.h"
83 83#include "hippoLimits.h"
84// [RLVa:KB] 84
85#include "rlvhandler.h" 85// [RLVa:KB]
86// [/RLVa:KB] 86#include "rlvhandler.h"
87 87// [/RLVa:KB]
88#define ELAR_ENABLED 0 // Enable when server support is implemented 88
89 89#define ELAR_ENABLED 0 // Enable when server support is implemented
90const S32 TERRAIN_TEXTURE_COUNT = 4; 90
91const S32 CORNER_COUNT = 4; 91const S32 TERRAIN_TEXTURE_COUNT = 4;
92 92const S32 CORNER_COUNT = 4;
93///---------------------------------------------------------------------------- 93
94/// Local class declaration 94///----------------------------------------------------------------------------
95///---------------------------------------------------------------------------- 95/// Local class declaration
96 96///----------------------------------------------------------------------------
97class LLDispatchEstateUpdateInfo : public LLDispatchHandler 97
98{ 98class LLDispatchEstateUpdateInfo : public LLDispatchHandler
99public: 99{
100 LLDispatchEstateUpdateInfo() {} 100public:
101 virtual ~LLDispatchEstateUpdateInfo() {} 101 LLDispatchEstateUpdateInfo() {}
102 virtual bool operator()( 102 virtual ~LLDispatchEstateUpdateInfo() {}
103 const LLDispatcher* dispatcher, 103 virtual bool operator()(
104 const std::string& key, 104 const LLDispatcher* dispatcher,
105 const LLUUID& invoice, 105 const std::string& key,
106 const sparam_t& strings); 106 const LLUUID& invoice,
107}; 107 const sparam_t& strings);
108 108};
109class LLDispatchSetEstateAccess : public LLDispatchHandler 109
110{ 110class LLDispatchSetEstateAccess : public LLDispatchHandler
111public: 111{
112 LLDispatchSetEstateAccess() {} 112public:
113 virtual ~LLDispatchSetEstateAccess() {} 113 LLDispatchSetEstateAccess() {}
114 virtual bool operator()( 114 virtual ~LLDispatchSetEstateAccess() {}
115 const LLDispatcher* dispatcher, 115 virtual bool operator()(
116 const std::string& key, 116 const LLDispatcher* dispatcher,
117 const LLUUID& invoice, 117 const std::string& key,
118 const sparam_t& strings); 118 const LLUUID& invoice,
119}; 119 const sparam_t& strings);
120 120};
121 121
122/* 122
123void unpack_request_params( 123/*
124 LLMessageSystem* msg, 124void unpack_request_params(
125 LLDispatcher::sparam_t& strings, 125 LLMessageSystem* msg,
126 LLDispatcher::iparam_t& integers) 126 LLDispatcher::sparam_t& strings,
127{ 127 LLDispatcher::iparam_t& integers)
128 char str_buf[MAX_STRING]; 128{
129 S32 str_count = msg->getNumberOfBlocksFast(_PREHASH_StringData); 129 char str_buf[MAX_STRING];
130 S32 i; 130 S32 str_count = msg->getNumberOfBlocksFast(_PREHASH_StringData);
131 for (i = 0; i < str_count; ++i) 131 S32 i;
132 { 132 for (i = 0; i < str_count; ++i)
133 // we treat the SParam as binary data (since it might be an 133 {
134 // LLUUID in compressed form which may have embedded \0's,) 134 // we treat the SParam as binary data (since it might be an
135 str_buf[0] = '\0'; 135 // LLUUID in compressed form which may have embedded \0's,)
136 S32 data_size = msg->getSizeFast(_PREHASH_StringData, i, _PREHASH_SParam); 136 str_buf[0] = '\0';
137 if (data_size >= 0) 137 S32 data_size = msg->getSizeFast(_PREHASH_StringData, i, _PREHASH_SParam);
138 { 138 if (data_size >= 0)
139 msg->getBinaryDataFast(_PREHASH_StringData, _PREHASH_SParam, 139 {
140 str_buf, data_size, i, MAX_STRING - 1); 140 msg->getBinaryDataFast(_PREHASH_StringData, _PREHASH_SParam,
141 strings.push_back(std::string(str_buf, data_size)); 141 str_buf, data_size, i, MAX_STRING - 1);
142 } 142 strings.push_back(std::string(str_buf, data_size));
143 } 143 }
144 144 }
145 U32 int_buf; 145
146 S32 int_count = msg->getNumberOfBlocksFast(_PREHASH_IntegerData); 146 U32 int_buf;
147 for (i = 0; i < int_count; ++i) 147 S32 int_count = msg->getNumberOfBlocksFast(_PREHASH_IntegerData);
148 { 148 for (i = 0; i < int_count; ++i)
149 msg->getU32("IntegerData", "IParam", int_buf, i); 149 {
150 integers.push_back(int_buf); 150 msg->getU32("IntegerData", "IParam", int_buf, i);
151 } 151 integers.push_back(int_buf);
152} 152 }
153*/ 153}
154 154*/
155 155
156 156
157bool estate_dispatch_initialized = false; 157
158 158bool estate_dispatch_initialized = false;
159 159
160///---------------------------------------------------------------------------- 160
161/// LLFloaterRegionInfo 161///----------------------------------------------------------------------------
162///---------------------------------------------------------------------------- 162/// LLFloaterRegionInfo
163 163///----------------------------------------------------------------------------
164//S32 LLFloaterRegionInfo::sRequestSerial = 0; 164
165LLUUID LLFloaterRegionInfo::sRequestInvoice; 165//S32 LLFloaterRegionInfo::sRequestSerial = 0;
166 166LLUUID LLFloaterRegionInfo::sRequestInvoice;
167LLFloaterRegionInfo::LLFloaterRegionInfo(const LLSD& seed) 167
168{ 168LLFloaterRegionInfo::LLFloaterRegionInfo(const LLSD& seed)
169 LLUICtrlFactory::getInstance()->buildFloater(this, "floater_region_info.xml", NULL, FALSE); 169{
170} 170 LLUICtrlFactory::getInstance()->buildFloater(this, "floater_region_info.xml", NULL, FALSE);
171 171}
172BOOL LLFloaterRegionInfo::postBuild() 172
173{ 173BOOL LLFloaterRegionInfo::postBuild()
174 mTab = getChild<LLTabContainer>("region_panels"); 174{
175 175 mTab = getChild<LLTabContainer>("region_panels");
176 // contruct the panels 176
177 LLPanelRegionInfo* panel; 177 // contruct the panels
178 panel = new LLPanelRegionGeneralInfo; 178 LLPanelRegionInfo* panel;
179 mInfoPanels.push_back(panel); 179
180 LLUICtrlFactory::getInstance()->buildPanel(panel, "panel_region_general.xml"); 180 panel = new LLPanelRegionGeneralInfo;
181 mTab->addTabPanel(panel, panel->getLabel(), TRUE); 181 mInfoPanels.push_back(panel);
182 182 LLUICtrlFactory::getInstance()->buildPanel(panel, "panel_region_general.xml");
183 panel = new LLPanelRegionDebugInfo; 183 mTab->addTabPanel(panel, panel->getLabel(), TRUE);
184 mInfoPanels.push_back(panel); 184
185 LLUICtrlFactory::getInstance()->buildPanel(panel, "panel_region_debug.xml"); 185 panel = new LLPanelRegionOpenSettingsInfo;
186 mTab->addTabPanel(panel, panel->getLabel(), FALSE); 186 mInfoPanels.push_back(panel);
187 187 LLUICtrlFactory::getInstance()->buildPanel(panel, "panel_region_open_region_settings.xml");
188 panel = new LLPanelRegionTextureInfo; 188 mTab->addTabPanel(panel, panel->getLabel(), FALSE);
189 mInfoPanels.push_back(panel); 189
190 LLUICtrlFactory::getInstance()->buildPanel(panel, "panel_region_texture.xml"); 190 panel = new LLPanelRegionDebugInfo;
191 mTab->addTabPanel(panel, panel->getLabel(), FALSE); 191 mInfoPanels.push_back(panel);
192 192 LLUICtrlFactory::getInstance()->buildPanel(panel, "panel_region_debug.xml");
193 panel = new LLPanelRegionTerrainInfo; 193 mTab->addTabPanel(panel, panel->getLabel(), FALSE);
194 mInfoPanels.push_back(panel); 194
195 LLUICtrlFactory::getInstance()->buildPanel(panel, "panel_region_terrain.xml"); 195 panel = new LLPanelRegionTextureInfo;
196 mTab->addTabPanel(panel, panel->getLabel(), FALSE); 196 mInfoPanels.push_back(panel);
197 197 LLUICtrlFactory::getInstance()->buildPanel(panel, "panel_region_texture.xml");
198 panel = new LLPanelEstateInfo; 198 mTab->addTabPanel(panel, panel->getLabel(), FALSE);
199 mInfoPanels.push_back(panel); 199
200 LLUICtrlFactory::getInstance()->buildPanel(panel, "panel_region_estate.xml"); 200 panel = new LLPanelRegionTerrainInfo;
201 mTab->addTabPanel(panel, panel->getLabel(), FALSE); 201 mInfoPanels.push_back(panel);
202 202 LLUICtrlFactory::getInstance()->buildPanel(panel, "panel_region_terrain.xml");
203 panel = new LLPanelEstateCovenant; 203 mTab->addTabPanel(panel, panel->getLabel(), FALSE);
204 mInfoPanels.push_back(panel); 204
205 LLUICtrlFactory::getInstance()->buildPanel(panel, "panel_region_covenant.xml"); 205 panel = new LLPanelEstateInfo;
206 mTab->addTabPanel(panel, panel->getLabel(), FALSE); 206 mInfoPanels.push_back(panel);
207 207 LLUICtrlFactory::getInstance()->buildPanel(panel, "panel_region_estate.xml");
208 gMessageSystem->setHandlerFunc( 208 mTab->addTabPanel(panel, panel->getLabel(), FALSE);
209 "EstateOwnerMessage", 209
210 &processEstateOwnerRequest); 210 panel = new LLPanelEstateCovenant;
211 211 mInfoPanels.push_back(panel);
212 return TRUE; 212 LLUICtrlFactory::getInstance()->buildPanel(panel, "panel_region_covenant.xml");
213} 213 mTab->addTabPanel(panel, panel->getLabel(), FALSE);
214 214
215LLFloaterRegionInfo::~LLFloaterRegionInfo() 215 gMessageSystem->setHandlerFunc(
216{ 216 "EstateOwnerMessage",
217} 217 &processEstateOwnerRequest);
218 218
219void LLFloaterRegionInfo::onOpen() 219 return TRUE;
220{ 220}
221 LLRect rect = gSavedSettings.getRect("FloaterRegionInfo"); 221
222 S32 left, top; 222LLFloaterRegionInfo::~LLFloaterRegionInfo()
223 gFloaterView->getNewFloaterPosition(&left, &top); 223{
224 rect.translate(left,top); 224}
225 225
226 refreshFromRegion(gAgent.getRegion()); 226void LLFloaterRegionInfo::onOpen()
227 requestRegionInfo(); 227{
228 LLFloater::onOpen(); 228 LLRect rect = gSavedSettings.getRect("FloaterRegionInfo");
229} 229 S32 left, top;
230 230 gFloaterView->getNewFloaterPosition(&left, &top);
231// static 231 rect.translate(left,top);
232void LLFloaterRegionInfo::requestRegionInfo() 232
233{ 233 refreshFromRegion(gAgent.getRegion());
234 LLTabContainer* tab = findInstance()->getChild<LLTabContainer>("region_panels"); 234 requestRegionInfo();
235 235 LLFloater::onOpen();
236 tab->getChild<LLPanel>("General")->setCtrlsEnabled(FALSE); 236}
237 tab->getChild<LLPanel>("Debug")->setCtrlsEnabled(FALSE); 237
238 tab->getChild<LLPanel>("Terrain")->setCtrlsEnabled(FALSE); 238// static
239 tab->getChild<LLPanel>("Estate")->setCtrlsEnabled(FALSE); 239void LLFloaterRegionInfo::requestRegionInfo()
240 240{
241 // Must allow anyone to request the RegionInfo data 241 LLTabContainer* tab = findInstance()->getChild<LLTabContainer>("region_panels");
242 // so non-owners/non-gods can see the values. 242
243 // Therefore can't use an EstateOwnerMessage JC 243 tab->getChild<LLPanel>("General")->setCtrlsEnabled(FALSE);
244 LLMessageSystem* msg = gMessageSystem; 244 tab->getChild<LLPanel>("Debug")->setCtrlsEnabled(FALSE);
245 msg->newMessage("RequestRegionInfo"); 245 tab->getChild<LLPanel>("Terrain")->setCtrlsEnabled(FALSE);
246 msg->nextBlock("AgentData"); 246 tab->getChild<LLPanel>("Estate")->setCtrlsEnabled(FALSE);
247 msg->addUUID("AgentID", gAgent.getID()); 247 tab->getChild<LLPanel>("RegionSettings")->setCtrlsEnabled(FALSE);
248 msg->addUUID("SessionID", gAgent.getSessionID()); 248
249 gAgent.sendReliableMessage(); 249 // Must allow anyone to request the RegionInfo data
250} 250 // so non-owners/non-gods can see the values.
251 251 // Therefore can't use an EstateOwnerMessage JC
252// static 252 LLMessageSystem* msg = gMessageSystem;
253void LLFloaterRegionInfo::processEstateOwnerRequest(LLMessageSystem* msg,void**) 253 msg->newMessage("RequestRegionInfo");
254{ 254 msg->nextBlock("AgentData");
255 static LLDispatcher dispatch; 255 msg->addUUID("AgentID", gAgent.getID());
256 if(!findInstance()) 256 msg->addUUID("SessionID", gAgent.getSessionID());
257 { 257 gAgent.sendReliableMessage();
258 return; 258}
259 } 259
260 260// static
261 if (!estate_dispatch_initialized) 261void LLFloaterRegionInfo::processEstateOwnerRequest(LLMessageSystem* msg,void**)
262 { 262{
263 LLPanelEstateInfo::initDispatch(dispatch); 263 static LLDispatcher dispatch;
264 } 264 if(!findInstance())
265 265 {
266 LLTabContainer* tab = findInstance()->getChild<LLTabContainer>("region_panels"); 266 return;
267 LLPanelEstateInfo* panel = (LLPanelEstateInfo*)tab->getChild<LLPanel>("Estate"); 267 }
268 268
269 // unpack the message 269 if (!estate_dispatch_initialized)
270 std::string request; 270 {
271 LLUUID invoice; 271 LLPanelEstateInfo::initDispatch(dispatch);
272 LLDispatcher::sparam_t strings; 272 }
273 LLDispatcher::unpackMessage(msg, request, invoice, strings); 273
274 if(invoice != getLastInvoice()) 274 LLTabContainer* tab = findInstance()->getChild<LLTabContainer>("region_panels");
275 { 275 LLPanelEstateInfo* panel = (LLPanelEstateInfo*)tab->getChild<LLPanel>("Estate");
276 llwarns << "Mismatched Estate message: " << request << llendl; 276
277 return; 277 // unpack the message
278 } 278 std::string request;
279 279 LLUUID invoice;
280 //dispatch the message 280 LLDispatcher::sparam_t strings;
281 dispatch.dispatch(request, invoice, strings); 281 LLDispatcher::unpackMessage(msg, request, invoice, strings);
282 282 if(invoice != getLastInvoice())
283 LLViewerRegion* region = gAgent.getRegion(); 283 {
284 panel->updateControls(region); 284 llwarns << "Mismatched Estate message: " << request << llendl;
285} 285 return;
286 286 }
287 287
288// static 288 //dispatch the message
289void LLFloaterRegionInfo::processRegionInfo(LLMessageSystem* msg) 289 dispatch.dispatch(request, invoice, strings);
290{ 290
291 LLPanel* panel; 291 LLViewerRegion* region = gAgent.getRegion();
292 292 panel->updateControls(region);
293 llinfos << "LLFloaterRegionInfo::processRegionInfo" << llendl; 293}
294 if(!findInstance()) 294
295 { 295
296 return; 296// static
297 } 297void LLFloaterRegionInfo::processRegionInfo(LLMessageSystem* msg)
298 298{
299 LLTabContainer* tab = findInstance()->getChild<LLTabContainer>("region_panels"); 299 LLPanel* panel;
300 300
301 LLViewerRegion* region = gAgent.getRegion(); 301 llinfos << "LLFloaterRegionInfo::processRegionInfo" << llendl;
302 BOOL allow_modify = gAgent.isGodlike() || (region && region->canManageEstate()); 302 if(!findInstance())
303 303 {
304 // extract message 304 return;
305 std::string sim_name; 305 }
306 std::string sim_type = LLTrans::getString("land_type_unknown"); 306
307 U32 region_flags; 307 LLTabContainer* tab = findInstance()->getChild<LLTabContainer>("region_panels");
308 U8 agent_limit; 308
309 F32 object_bonus_factor; 309 LLViewerRegion* region = gAgent.getRegion();
310 U8 sim_access; 310 BOOL allow_modify = gAgent.isGodlike() || (region && region->canManageEstate());
311 F32 water_height; 311
312 F32 terrain_raise_limit; 312 // extract message
313 F32 terrain_lower_limit; 313 std::string sim_name;
314 BOOL use_estate_sun; 314 std::string sim_type = LLTrans::getString("land_type_unknown");
315 F32 sun_hour; 315 U32 region_flags;
316 msg->getString("RegionInfo", "SimName", sim_name); 316 U8 agent_limit;
317 msg->getU32("RegionInfo", "RegionFlags", region_flags); 317 F32 object_bonus_factor;
318 msg->getU8("RegionInfo", "MaxAgents", agent_limit); 318 U8 sim_access;
319 msg->getF32("RegionInfo", "ObjectBonusFactor", object_bonus_factor); 319 F32 water_height;
320 msg->getU8("RegionInfo", "SimAccess", sim_access); 320 F32 terrain_raise_limit;
321 msg->getF32Fast(_PREHASH_RegionInfo, _PREHASH_WaterHeight, water_height); 321 F32 terrain_lower_limit;
322 msg->getF32Fast(_PREHASH_RegionInfo, _PREHASH_TerrainRaiseLimit, terrain_raise_limit); 322 BOOL use_estate_sun;
323 msg->getF32Fast(_PREHASH_RegionInfo, _PREHASH_TerrainLowerLimit, terrain_lower_limit); 323 F32 sun_hour;
324 msg->getBOOL("RegionInfo", "UseEstateSun", use_estate_sun); 324 msg->getString("RegionInfo", "SimName", sim_name);
325 // actually the "last set" sun hour, not the current sun hour. JC 325 msg->getU32("RegionInfo", "RegionFlags", region_flags);
326 msg->getF32("RegionInfo", "SunHour", sun_hour); 326 msg->getU8("RegionInfo", "MaxAgents", agent_limit);
327 // the only reasonable way to decide if we actually have any data is to 327 msg->getF32("RegionInfo", "ObjectBonusFactor", object_bonus_factor);
328 // check to see if any of these fields have nonzero sizes 328 msg->getU8("RegionInfo", "SimAccess", sim_access);
329 if (msg->getSize("RegionInfo2", "ProductSKU") > 0 || 329 msg->getF32Fast(_PREHASH_RegionInfo, _PREHASH_WaterHeight, water_height);
330 msg->getSize("RegionInfo2", "ProductName") > 0) 330 msg->getF32Fast(_PREHASH_RegionInfo, _PREHASH_TerrainRaiseLimit, terrain_raise_limit);
331 { 331 msg->getF32Fast(_PREHASH_RegionInfo, _PREHASH_TerrainLowerLimit, terrain_lower_limit);
332 msg->getString("RegionInfo2", "ProductName", sim_type); 332 msg->getBOOL("RegionInfo", "UseEstateSun", use_estate_sun);
333 } 333 // actually the "last set" sun hour, not the current sun hour. JC
334 334 msg->getF32("RegionInfo", "SunHour", sun_hour);
335 // GENERAL PANEL 335 // the only reasonable way to decide if we actually have any data is to
336 panel = tab->getChild<LLPanel>("General"); 336 // check to see if any of these fields have nonzero sizes
337 panel->childSetValue("region_text", LLSD(sim_name)); 337 if (msg->getSize("RegionInfo2", "ProductSKU") > 0 ||
338 panel->childSetValue("region_type", LLSD(sim_type)); 338 msg->getSize("RegionInfo2", "ProductName") > 0)
339 panel->childSetValue("version_channel_text", gLastVersionChannel); 339 {
340 340 msg->getString("RegionInfo2", "ProductName", sim_type);
341 panel->childSetValue("block_terraform_check", (region_flags & REGION_FLAGS_BLOCK_TERRAFORM) ? TRUE : FALSE ); 341 }
342 panel->childSetValue("block_fly_check", (region_flags & REGION_FLAGS_BLOCK_FLY) ? TRUE : FALSE ); 342
343 panel->childSetValue("allow_damage_check", (region_flags & REGION_FLAGS_ALLOW_DAMAGE) ? TRUE : FALSE ); 343 // GENERAL PANEL
344 panel->childSetValue("restrict_pushobject", (region_flags & REGION_FLAGS_RESTRICT_PUSHOBJECT) ? TRUE : FALSE ); 344 panel = tab->getChild<LLPanel>("General");
345 panel->childSetValue("allow_land_resell_check", (region_flags & REGION_FLAGS_BLOCK_LAND_RESELL) ? FALSE : TRUE ); 345 panel->childSetValue("region_text", LLSD(sim_name));
346 panel->childSetValue("allow_parcel_changes_check", (region_flags & REGION_FLAGS_ALLOW_PARCEL_CHANGES) ? TRUE : FALSE ); 346 panel->childSetValue("region_type", LLSD(sim_type));
347 panel->childSetValue("block_parcel_search_check", (region_flags & REGION_FLAGS_BLOCK_PARCEL_SEARCH) ? TRUE : FALSE ); 347 panel->childSetValue("version_channel_text", gLastVersionChannel);
348 panel->childSetValue("agent_limit_spin", LLSD((F32)agent_limit) ); 348
349 panel->childSetValue("object_bonus_spin", LLSD(object_bonus_factor) ); 349 panel->childSetValue("block_terraform_check", (region_flags & REGION_FLAGS_BLOCK_TERRAFORM) ? TRUE : FALSE );
350 panel->childSetValue("access_combo", LLSD(sim_access) ); 350 panel->childSetValue("block_fly_check", (region_flags & REGION_FLAGS_BLOCK_FLY) ? TRUE : FALSE );
351 351 panel->childSetValue("allow_damage_check", (region_flags & REGION_FLAGS_ALLOW_DAMAGE) ? TRUE : FALSE );
352 352 panel->childSetValue("restrict_pushobject", (region_flags & REGION_FLAGS_RESTRICT_PUSHOBJECT) ? TRUE : FALSE );
353 // detect teen grid for maturity 353 panel->childSetValue("allow_land_resell_check", (region_flags & REGION_FLAGS_BLOCK_LAND_RESELL) ? FALSE : TRUE );
354 354 panel->childSetValue("allow_parcel_changes_check", (region_flags & REGION_FLAGS_ALLOW_PARCEL_CHANGES) ? TRUE : FALSE );
355 U32 parent_estate_id; 355 panel->childSetValue("block_parcel_search_check", (region_flags & REGION_FLAGS_BLOCK_PARCEL_SEARCH) ? TRUE : FALSE );
356 msg->getU32("RegionInfo", "ParentEstateID", parent_estate_id); 356 panel->childSetValue("agent_limit_spin", LLSD((F32)agent_limit) );
357 BOOL teen_grid = (parent_estate_id == 5); // *TODO add field to estate table and test that 357 panel->childSetValue("object_bonus_spin", LLSD(object_bonus_factor) );
358 panel->childSetEnabled("access_combo", gAgent.isGodlike() || (region && region->canManageEstate() && !teen_grid)); 358 panel->childSetValue("access_combo", LLSD(sim_access) );
359 panel->setCtrlsEnabled(allow_modify); 359
360 360
361 361 // detect teen grid for maturity
362 // DEBUG PANEL 362
363 panel = tab->getChild<LLPanel>("Debug"); 363 U32 parent_estate_id;
364 364 msg->getU32("RegionInfo", "ParentEstateID", parent_estate_id);
365 panel->childSetValue("region_text", LLSD(sim_name) ); 365 BOOL teen_grid = (parent_estate_id == 5); // *TODO add field to estate table and test that
366 panel->childSetValue("disable_scripts_check", LLSD((BOOL)(region_flags & REGION_FLAGS_SKIP_SCRIPTS)) ); 366 panel->childSetEnabled("access_combo", gAgent.isGodlike() || (region && region->canManageEstate() && !teen_grid));
367 panel->childSetValue("disable_collisions_check", LLSD((BOOL)(region_flags & REGION_FLAGS_SKIP_COLLISIONS)) ); 367 panel->setCtrlsEnabled(allow_modify);
368 panel->childSetValue("disable_physics_check", LLSD((BOOL)(region_flags & REGION_FLAGS_SKIP_PHYSICS)) ); 368
369 panel->setCtrlsEnabled(allow_modify); 369 // RegionSettings PANEL
370 370 panel = tab->getChild<LLPanel>("RegionSettings");
371 // TERRAIN PANEL 371 panel->setCtrlsEnabled(allow_modify);
372 panel = tab->getChild<LLPanel>("Terrain"); 372
373 373 // DEBUG PANEL
374 panel->childSetValue("region_text", LLSD(sim_name)); 374 panel = tab->getChild<LLPanel>("Debug");
375 panel->childSetValue("water_height_spin", LLSD(water_height)); 375
376 panel->childSetValue("terrain_raise_spin", LLSD(terrain_raise_limit)); 376 panel->childSetValue("region_text", LLSD(sim_name) );
377 panel->childSetValue("terrain_lower_spin", LLSD(terrain_lower_limit)); 377 panel->childSetValue("disable_scripts_check", LLSD((BOOL)(region_flags & REGION_FLAGS_SKIP_SCRIPTS)) );
378 panel->childSetValue("use_estate_sun_check", LLSD(use_estate_sun)); 378 panel->childSetValue("disable_collisions_check", LLSD((BOOL)(region_flags & REGION_FLAGS_SKIP_COLLISIONS)) );
379 379 panel->childSetValue("disable_physics_check", LLSD((BOOL)(region_flags & REGION_FLAGS_SKIP_PHYSICS)) );
380 panel->childSetValue("fixed_sun_check", LLSD((BOOL)(region_flags & REGION_FLAGS_SUN_FIXED))); 380 panel->setCtrlsEnabled(allow_modify);
381 panel->childSetEnabled("fixed_sun_check", allow_modify && !use_estate_sun); 381
382 panel->childSetValue("sun_hour_slider", LLSD(sun_hour)); 382 // TERRAIN PANEL
383 panel->childSetEnabled("sun_hour_slider", allow_modify && !use_estate_sun); 383 panel = tab->getChild<LLPanel>("Terrain");
384 panel->setCtrlsEnabled(allow_modify); 384
385 385 panel->childSetValue("region_text", LLSD(sim_name));
386 getInstance()->refreshFromRegion( gAgent.getRegion() ); 386 panel->childSetValue("water_height_spin", LLSD(water_height));
387} 387 panel->childSetValue("terrain_raise_spin", LLSD(terrain_raise_limit));
388 388 panel->childSetValue("terrain_lower_spin", LLSD(terrain_lower_limit));
389// static 389 panel->childSetValue("use_estate_sun_check", LLSD(use_estate_sun));
390LLPanelEstateInfo* LLFloaterRegionInfo::getPanelEstate() 390
391{ 391 panel->childSetValue("fixed_sun_check", LLSD((BOOL)(region_flags & REGION_FLAGS_SUN_FIXED)));
392 LLFloaterRegionInfo* floater = LLFloaterRegionInfo::getInstance(); 392 panel->childSetEnabled("fixed_sun_check", allow_modify && !use_estate_sun);
393 if (!floater) return NULL; 393 panel->childSetValue("sun_hour_slider", LLSD(sun_hour));
394 LLTabContainer* tab = floater->getChild<LLTabContainer>("region_panels"); 394 panel->childSetEnabled("sun_hour_slider", allow_modify && !use_estate_sun);
395 LLPanelEstateInfo* panel = (LLPanelEstateInfo*)tab->getChild<LLPanel>("Estate"); 395 panel->setCtrlsEnabled(allow_modify);
396 return panel; 396
397} 397 getInstance()->refreshFromRegion( gAgent.getRegion() );
398 398}
399// static 399
400LLPanelEstateCovenant* LLFloaterRegionInfo::getPanelCovenant() 400// static
401{ 401LLPanelEstateInfo* LLFloaterRegionInfo::getPanelEstate()
402 LLFloaterRegionInfo* floater = LLFloaterRegionInfo::getInstance(); 402{
403 if (!floater) return NULL; 403 LLFloaterRegionInfo* floater = LLFloaterRegionInfo::getInstance();
404 LLTabContainer* tab = floater->getChild<LLTabContainer>("region_panels"); 404 if (!floater) return NULL;
405 LLPanelEstateCovenant* panel = (LLPanelEstateCovenant*)tab->getChild<LLPanel>("Covenant"); 405 LLTabContainer* tab = floater->getChild<LLTabContainer>("region_panels");
406 return panel; 406 LLPanelEstateInfo* panel = (LLPanelEstateInfo*)tab->getChild<LLPanel>("Estate");
407} 407 return panel;
408 408}
409void LLFloaterRegionInfo::refreshFromRegion(LLViewerRegion* region) 409
410{ 410// static
411 // call refresh from region on all panels 411LLPanelEstateCovenant* LLFloaterRegionInfo::getPanelCovenant()
412 std::for_each( 412{
413 mInfoPanels.begin(), 413 LLFloaterRegionInfo* floater = LLFloaterRegionInfo::getInstance();
414 mInfoPanels.end(), 414 if (!floater) return NULL;
415 llbind2nd( 415 LLTabContainer* tab = floater->getChild<LLTabContainer>("region_panels");
416#if LL_WINDOWS 416 LLPanelEstateCovenant* panel = (LLPanelEstateCovenant*)tab->getChild<LLPanel>("Covenant");
417 std::mem_fun1(&LLPanelRegionInfo::refreshFromRegion), 417 return panel;
418#else 418}
419 std::mem_fun(&LLPanelRegionInfo::refreshFromRegion), 419
420#endif 420// static
421 region)); 421LLPanelRegionOpenSettingsInfo* LLFloaterRegionInfo::getPanelOpenSettings()
422} 422{
423 423 LLFloaterRegionInfo* floater = LLFloaterRegionInfo::getInstance();
424// public 424 if (!floater) return NULL;
425void LLFloaterRegionInfo::refresh() 425 LLTabContainer* tab = floater->getChild<LLTabContainer>("region_panels");
426{ 426 LLPanelRegionOpenSettingsInfo* panel;
427 for(info_panels_t::iterator iter = mInfoPanels.begin(); 427 panel = (LLPanelRegionOpenSettingsInfo*)tab->getChild<LLPanel>("RegionSettings");
428 iter != mInfoPanels.end(); ++iter) 428 return panel;
429 { 429}
430 (*iter)->refresh(); 430
431 } 431void LLFloaterRegionInfo::refreshFromRegion(LLViewerRegion* region)
432} 432{
433 433 // call refresh from region on all panels
434 434 std::for_each(
435///---------------------------------------------------------------------------- 435 mInfoPanels.begin(),
436/// Local class implementation 436 mInfoPanels.end(),
437///---------------------------------------------------------------------------- 437 llbind2nd(
438 438#if LL_WINDOWS
439// 439 std::mem_fun1(&LLPanelRegionInfo::refreshFromRegion),
440// LLPanelRegionInfo 440#else
441// 441 std::mem_fun(&LLPanelRegionInfo::refreshFromRegion),
442 442#endif
443// static 443 region));
444void LLPanelRegionInfo::onBtnSet(void* user_data) 444}
445{ 445
446 LLPanelRegionInfo* panel = (LLPanelRegionInfo*)user_data; 446// public
447 if(!panel) return; 447void LLFloaterRegionInfo::refresh()
448 if (panel->sendUpdate()) 448{
449 { 449 for(info_panels_t::iterator iter = mInfoPanels.begin();
450 panel->disableButton("apply_btn"); 450 iter != mInfoPanels.end(); ++iter)
451 } 451 {
452} 452 (*iter)->refresh();
453 453 }
454//static 454}
455void LLPanelRegionInfo::onChangeChildCtrl(LLUICtrl* ctrl, void* user_data) 455
456{ 456
457 if (ctrl) 457///----------------------------------------------------------------------------
458 { 458/// Local class implementation
459 LLPanelRegionInfo* panel = (LLPanelRegionInfo*) ctrl->getParent(); 459///----------------------------------------------------------------------------
460 panel->updateChild(ctrl); 460
461 } 461//
462} 462// LLPanelRegionInfo
463 463//
464// static 464
465// Enables the "set" button if it is not already enabled 465// static
466void LLPanelRegionInfo::onChangeAnything(LLUICtrl* ctrl, void* user_data) 466void LLPanelRegionInfo::onBtnSet(void* user_data)
467{ 467{
468 LLPanelRegionInfo* panel = (LLPanelRegionInfo*)user_data; 468 LLPanelRegionInfo* panel = (LLPanelRegionInfo*)user_data;
469 if(panel) 469 if(!panel) return;
470 { 470 if (panel->sendUpdate())
471 panel->enableButton("apply_btn"); 471 {
472 panel->refresh(); 472 panel->disableButton("apply_btn");
473 } 473 }
474} 474}
475 475
476// static 476//static
477// Enables set button on change to line editor 477void LLPanelRegionInfo::onChangeChildCtrl(LLUICtrl* ctrl, void* user_data)
478void LLPanelRegionInfo::onChangeText(LLLineEditor* caller, void* user_data) 478{
479{ 479 if (ctrl)
480 // reuse the previous method 480 {
481 onChangeAnything(0, user_data); 481 LLPanelRegionInfo* panel = (LLPanelRegionInfo*) ctrl->getParent();
482} 482 panel->updateChild(ctrl);
483 483 }
484 484}
485// virtual 485
486BOOL LLPanelRegionInfo::postBuild() 486// static
487{ 487// Enables the "set" button if it is not already enabled
488 childSetAction("apply_btn", onBtnSet, this); 488void LLPanelRegionInfo::onChangeAnything(LLUICtrl* ctrl, void* user_data)
489 childDisable("apply_btn"); 489{
490 refresh(); 490 LLPanelRegionInfo* panel = (LLPanelRegionInfo*)user_data;
491 return TRUE; 491 if(panel)
492} 492 {
493 493 panel->enableButton("apply_btn");
494// virtual 494 panel->refresh();
495void LLPanelRegionInfo::updateChild(LLUICtrl* child_ctr) 495 }
496{ 496}
497} 497
498 498// static
499// virtual 499// Enables set button on change to line editor
500bool LLPanelRegionInfo::refreshFromRegion(LLViewerRegion* region) 500void LLPanelRegionInfo::onChangeText(LLLineEditor* caller, void* user_data)
501{ 501{
502 if (region) mHost = region->getHost(); 502 // reuse the previous method
503 return true; 503 onChangeAnything(0, user_data);
504} 504}
505 505
506void LLPanelRegionInfo::sendEstateOwnerMessage( 506
507 LLMessageSystem* msg, 507// virtual
508 const std::string& request, 508BOOL LLPanelRegionInfo::postBuild()
509 const LLUUID& invoice, 509{
510 const strings_t& strings) 510 childSetAction("apply_btn", onBtnSet, this);
511{ 511 childDisable("apply_btn");
512 llinfos << "Sending estate request '" << request << "'" << llendl; 512 refresh();
513 msg->newMessage("EstateOwnerMessage"); 513 return TRUE;
514 msg->nextBlockFast(_PREHASH_AgentData); 514}
515 msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); 515
516 msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); 516// virtual
517 msg->addUUIDFast(_PREHASH_TransactionID, LLUUID::null); //not used 517void LLPanelRegionInfo::updateChild(LLUICtrl* child_ctr)
518 msg->nextBlock("MethodData"); 518{
519 msg->addString("Method", request); 519}
520 msg->addUUID("Invoice", invoice); 520
521 if(strings.empty()) 521// virtual
522 { 522bool LLPanelRegionInfo::refreshFromRegion(LLViewerRegion* region)
523 msg->nextBlock("ParamList"); 523{
524 msg->addString("Parameter", NULL); 524 if (region) mHost = region->getHost();
525 } 525 return true;
526 else 526}
527 { 527
528 strings_t::const_iterator it = strings.begin(); 528void LLPanelRegionInfo::sendEstateOwnerMessage(
529 strings_t::const_iterator end = strings.end(); 529 LLMessageSystem* msg,
530 for(; it != end; ++it) 530 const std::string& request,
531 { 531 const LLUUID& invoice,
532 msg->nextBlock("ParamList"); 532 const strings_t& strings)
533 msg->addString("Parameter", *it); 533{
534 } 534 llinfos << "Sending estate request '" << request << "'" << llendl;
535 } 535 msg->newMessage("EstateOwnerMessage");
536 msg->sendReliable(mHost); 536 msg->nextBlockFast(_PREHASH_AgentData);
537} 537 msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
538 538 msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
539void LLPanelRegionInfo::enableButton(const std::string& btn_name, BOOL enable) 539 msg->addUUIDFast(_PREHASH_TransactionID, LLUUID::null); //not used
540{ 540 msg->nextBlock("MethodData");
541 childSetEnabled(btn_name, enable); 541 msg->addString("Method", request);
542} 542 msg->addUUID("Invoice", invoice);
543 543 if(strings.empty())
544void LLPanelRegionInfo::disableButton(const std::string& btn_name) 544 {
545{ 545 msg->nextBlock("ParamList");
546 childDisable(btn_name); 546 msg->addString("Parameter", NULL);
547} 547 }
548 548 else
549void LLPanelRegionInfo::initCtrl(const std::string& name) 549 {
550{ 550 strings_t::const_iterator it = strings.begin();
551 childSetCommitCallback(name, onChangeAnything, this); 551 strings_t::const_iterator end = strings.end();
552} 552 for(; it != end; ++it)
553 553 {
554void LLPanelRegionInfo::initHelpBtn(const std::string& name, const std::string& xml_alert) 554 msg->nextBlock("ParamList");
555{ 555 msg->addString("Parameter", *it);
556 childSetAction(name, onClickHelp, new std::string(xml_alert)); 556 }
557} 557 }
558 558 msg->sendReliable(mHost);
559// static 559}
560void LLPanelRegionInfo::onClickHelp(void* data) 560
561{ 561void LLPanelRegionInfo::enableButton(const std::string& btn_name, BOOL enable)
562 std::string* xml_alert = (std::string*)data; 562{
563 LLNotifications::instance().add(*xml_alert); 563 childSetEnabled(btn_name, enable);
564} 564}
565 565
566///////////////////////////////////////////////////////////////////////////// 566void LLPanelRegionInfo::disableButton(const std::string& btn_name)
567// LLPanelRegionGeneralInfo 567{
568// 568 childDisable(btn_name);
569bool LLPanelRegionGeneralInfo::refreshFromRegion(LLViewerRegion* region) 569}
570{ 570
571 BOOL allow_modify = gAgent.isGodlike() || (region && region->canManageEstate()); 571void LLPanelRegionInfo::initCtrl(const std::string& name)
572 setCtrlsEnabled(allow_modify); 572{
573 childDisable("apply_btn"); 573 childSetCommitCallback(name, onChangeAnything, this);
574 childSetEnabled("access_text", allow_modify); 574}
575 // childSetEnabled("access_combo", allow_modify); 575
576 // now set in processRegionInfo for teen grid detection 576void LLPanelRegionInfo::initHelpBtn(const std::string& name, const std::string& xml_alert)
577 childSetEnabled("kick_btn", allow_modify); 577{
578 childSetEnabled("kick_all_btn", allow_modify); 578 childSetAction(name, onClickHelp, new std::string(xml_alert));
579 childSetEnabled("im_btn", allow_modify); 579}
580 childSetEnabled("manage_telehub_btn", allow_modify); 580
581 581// static
582 // Data gets filled in by processRegionInfo 582void LLPanelRegionInfo::onClickHelp(void* data)
583 583{
584 return LLPanelRegionInfo::refreshFromRegion(region); 584 std::string* xml_alert = (std::string*)data;
585} 585 LLNotifications::instance().add(*xml_alert);
586 586}
587BOOL LLPanelRegionGeneralInfo::postBuild() 587
588{ 588/////////////////////////////////////////////////////////////////////////////
589 // Enable the "Apply" button if something is changed. JC 589// LLPanelRegionGeneralInfo
590 initCtrl("block_terraform_check"); 590//
591 initCtrl("block_fly_check"); 591bool LLPanelRegionGeneralInfo::refreshFromRegion(LLViewerRegion* region)
592 initCtrl("allow_damage_check"); 592{
593 initCtrl("allow_land_resell_check"); 593 BOOL allow_modify = gAgent.isGodlike() || (region && region->canManageEstate());
594 initCtrl("allow_parcel_changes_check"); 594 setCtrlsEnabled(allow_modify);
595 initCtrl("agent_limit_spin"); 595 childDisable("apply_btn");
596 initCtrl("object_bonus_spin"); 596 childSetEnabled("access_text", allow_modify);
597 initCtrl("access_combo"); 597 // childSetEnabled("access_combo", allow_modify);
598 initCtrl("restrict_pushobject"); 598 // now set in processRegionInfo for teen grid detection
599 initCtrl("block_parcel_search_check"); 599 childSetEnabled("kick_btn", allow_modify);
600 600 childSetEnabled("kick_all_btn", allow_modify);
601 initHelpBtn("terraform_help", "HelpRegionBlockTerraform"); 601 childSetEnabled("im_btn", allow_modify);
602 initHelpBtn("fly_help", "HelpRegionBlockFly"); 602 childSetEnabled("manage_telehub_btn", allow_modify);
603 initHelpBtn("damage_help", "HelpRegionAllowDamage"); 603
604 initHelpBtn("agent_limit_help", "HelpRegionAgentLimit"); 604 // Data gets filled in by processRegionInfo
605 initHelpBtn("object_bonus_help", "HelpRegionObjectBonus"); 605
606 initHelpBtn("access_help", "HelpRegionMaturity"); 606 return LLPanelRegionInfo::refreshFromRegion(region);
607 initHelpBtn("restrict_pushobject_help", "HelpRegionRestrictPushObject"); 607}
608 initHelpBtn("land_resell_help", "HelpRegionLandResell"); 608
609 initHelpBtn("parcel_changes_help", "HelpParcelChanges"); 609BOOL LLPanelRegionGeneralInfo::postBuild()
610 initHelpBtn("parcel_search_help", "HelpRegionSearch"); 610{
611 611 // Enable the "Apply" button if something is changed. JC
612 childSetAction("kick_btn", onClickKick, this); 612 initCtrl("block_terraform_check");
613 childSetAction("kick_all_btn", onClickKickAll, this); 613 initCtrl("block_fly_check");
614 childSetAction("im_btn", onClickMessage, this); 614 initCtrl("allow_damage_check");
615 childSetAction("manage_telehub_btn", onClickManageTelehub, this); 615 initCtrl("allow_land_resell_check");
616 616 initCtrl("allow_parcel_changes_check");
617 return LLPanelRegionInfo::postBuild(); 617 initCtrl("agent_limit_spin");
618} 618 initCtrl("object_bonus_spin");
619 619 initCtrl("access_combo");
620// static 620 initCtrl("restrict_pushobject");
621void LLPanelRegionGeneralInfo::onClickKick(void* userdata) 621 initCtrl("block_parcel_search_check");
622{ 622 initCtrl("minimum_agent_age");
623 llinfos << "LLPanelRegionGeneralInfo::onClickKick" << llendl; 623
624 LLPanelRegionGeneralInfo* panelp = (LLPanelRegionGeneralInfo*)userdata; 624 initHelpBtn("terraform_help", "HelpRegionBlockTerraform");
625 625 initHelpBtn("fly_help", "HelpRegionBlockFly");
626 // this depends on the grandparent view being a floater 626 initHelpBtn("damage_help", "HelpRegionAllowDamage");
627 // in order to set up floater dependency 627 initHelpBtn("agent_limit_help", "HelpRegionAgentLimit");
628 LLFloater* parent_floater = gFloaterView->getParentFloater(panelp); 628 initHelpBtn("object_bonus_help", "HelpRegionObjectBonus");
629 LLFloater* child_floater = LLFloaterAvatarPicker::show(onKickCommit, userdata, FALSE, TRUE); 629 initHelpBtn("access_help", "HelpRegionMaturity");
630 parent_floater->addDependentFloater(child_floater); 630 initHelpBtn("restrict_pushobject_help", "HelpRegionRestrictPushObject");
631} 631 initHelpBtn("land_resell_help", "HelpRegionLandResell");
632 632 initHelpBtn("parcel_changes_help", "HelpParcelChanges");
633// static 633 initHelpBtn("parcel_search_help", "HelpRegionSearch");
634void LLPanelRegionGeneralInfo::onKickCommit(const std::vector<std::string>& names, const std::vector<LLUUID>& ids, void* userdata) 634
635{ 635 childSetAction("kick_btn", onClickKick, this);
636 if (names.empty() || ids.empty()) return; 636 childSetAction("kick_all_btn", onClickKickAll, this);
637 if(ids[0].notNull()) 637 childSetAction("im_btn", onClickMessage, this);
638 { 638 childSetAction("manage_telehub_btn", onClickManageTelehub, this);
639 LLPanelRegionGeneralInfo* self = (LLPanelRegionGeneralInfo*)userdata; 639
640 if(!self) return; 640 return LLPanelRegionInfo::postBuild();
641 strings_t strings; 641}
642 // [0] = our agent id 642
643 // [1] = target agent id 643// static
644 std::string buffer; 644void LLPanelRegionGeneralInfo::onClickKick(void* userdata)
645 gAgent.getID().toString(buffer); 645{
646 strings.push_back(buffer); 646 llinfos << "LLPanelRegionGeneralInfo::onClickKick" << llendl;
647 647 LLPanelRegionGeneralInfo* panelp = (LLPanelRegionGeneralInfo*)userdata;
648 ids[0].toString(buffer); 648
649 strings.push_back(strings_t::value_type(buffer)); 649 // this depends on the grandparent view being a floater
650 650 // in order to set up floater dependency
651 LLUUID invoice(LLFloaterRegionInfo::getLastInvoice()); 651 LLFloater* parent_floater = gFloaterView->getParentFloater(panelp);
652 self->sendEstateOwnerMessage(gMessageSystem, "teleporthomeuser", invoice, strings); 652 LLFloater* child_floater = LLFloaterAvatarPicker::show(onKickCommit, userdata, FALSE, TRUE);
653 } 653 parent_floater->addDependentFloater(child_floater);
654} 654}
655 655
656// static 656// static
657void LLPanelRegionGeneralInfo::onClickKickAll(void* userdata) 657void LLPanelRegionGeneralInfo::onKickCommit(const std::vector<std::string>& names, const std::vector<LLUUID>& ids, void* userdata)
658{ 658{
659 llinfos << "LLPanelRegionGeneralInfo::onClickKickAll" << llendl; 659 if (names.empty() || ids.empty()) return;
660 LLNotifications::instance().add("KickUsersFromRegion", 660 if(ids[0].notNull())
661 LLSD(), 661 {
662 LLSD(), 662 LLPanelRegionGeneralInfo* self = (LLPanelRegionGeneralInfo*)userdata;
663 boost::bind(&LLPanelRegionGeneralInfo::onKickAllCommit, (LLPanelRegionGeneralInfo*)userdata, _1, _2)); 663 if(!self) return;
664} 664 strings_t strings;
665 665 // [0] = our agent id
666bool LLPanelRegionGeneralInfo::onKickAllCommit(const LLSD& notification, const LLSD& response) 666 // [1] = target agent id
667{ 667 std::string buffer;
668 S32 option = LLNotification::getSelectedOption(notification, response); 668 gAgent.getID().toString(buffer);
669 if (option == 0) 669 strings.push_back(buffer);
670 { 670
671 strings_t strings; 671 ids[0].toString(buffer);
672 // [0] = our agent id 672 strings.push_back(strings_t::value_type(buffer));
673 std::string buffer; 673
674 gAgent.getID().toString(buffer); 674 LLUUID invoice(LLFloaterRegionInfo::getLastInvoice());
675 strings.push_back(buffer); 675 self->sendEstateOwnerMessage(gMessageSystem, "teleporthomeuser", invoice, strings);
676 676 }
677 LLUUID invoice(LLFloaterRegionInfo::getLastInvoice()); 677}
678 // historical message name 678
679 sendEstateOwnerMessage(gMessageSystem, "teleporthomeallusers", invoice, strings); 679// static
680 } 680void LLPanelRegionGeneralInfo::onClickKickAll(void* userdata)
681 return false; 681{
682} 682 llinfos << "LLPanelRegionGeneralInfo::onClickKickAll" << llendl;
683 683 LLNotifications::instance().add("KickUsersFromRegion",
684// static 684 LLSD(),
685void LLPanelRegionGeneralInfo::onClickMessage(void* userdata) 685 LLSD(),
686{ 686 boost::bind(&LLPanelRegionGeneralInfo::onKickAllCommit, (LLPanelRegionGeneralInfo*)userdata, _1, _2));
687 llinfos << "LLPanelRegionGeneralInfo::onClickMessage" << llendl; 687}
688 LLNotifications::instance().add("MessageRegion", 688
689 LLSD(), 689bool LLPanelRegionGeneralInfo::onKickAllCommit(const LLSD& notification, const LLSD& response)
690 LLSD(), 690{
691 boost::bind(&LLPanelRegionGeneralInfo::onMessageCommit, (LLPanelRegionGeneralInfo*)userdata, _1, _2)); 691 S32 option = LLNotification::getSelectedOption(notification, response);
692} 692 if (option == 0)
693 693 {
694// static 694 strings_t strings;
695bool LLPanelRegionGeneralInfo::onMessageCommit(const LLSD& notification, const LLSD& response) 695 // [0] = our agent id
696{ 696 std::string buffer;
697 if(LLNotification::getSelectedOption(notification, response) != 0) return false; 697 gAgent.getID().toString(buffer);
698 698 strings.push_back(buffer);
699 std::string text = response["message"].asString(); 699
700 if (text.empty()) return false; 700 LLUUID invoice(LLFloaterRegionInfo::getLastInvoice());
701 701 // historical message name
702 llinfos << "Message to everyone: " << text << llendl; 702 sendEstateOwnerMessage(gMessageSystem, "teleporthomeallusers", invoice, strings);
703 strings_t strings; 703 }
704 // [0] grid_x, unused here 704 return false;
705 // [1] grid_y, unused here 705}
706 // [2] agent_id of sender 706
707 // [3] sender name 707// static
708 // [4] message 708void LLPanelRegionGeneralInfo::onClickMessage(void* userdata)
709 strings.push_back("-1"); 709{
710 strings.push_back("-1"); 710 llinfos << "LLPanelRegionGeneralInfo::onClickMessage" << llendl;
711 std::string buffer; 711 LLNotifications::instance().add("MessageRegion",
712 gAgent.getID().toString(buffer); 712 LLSD(),
713 strings.push_back(buffer); 713 LLSD(),
714 std::string name; 714 boost::bind(&LLPanelRegionGeneralInfo::onMessageCommit, (LLPanelRegionGeneralInfo*)userdata, _1, _2));
715 gAgent.buildFullname(name); 715}
716 strings.push_back(strings_t::value_type(name)); 716
717 strings.push_back(strings_t::value_type(text)); 717// static
718 LLUUID invoice(LLFloaterRegionInfo::getLastInvoice()); 718bool LLPanelRegionGeneralInfo::onMessageCommit(const LLSD& notification, const LLSD& response)
719 sendEstateOwnerMessage(gMessageSystem, "simulatormessage", invoice, strings); 719{
720 return false; 720 if(LLNotification::getSelectedOption(notification, response) != 0) return false;
721} 721
722 722 std::string text = response["message"].asString();
723// static 723 if (text.empty()) return false;
724void LLPanelRegionGeneralInfo::onClickManageTelehub(void* data) 724
725{ 725 llinfos << "Message to everyone: " << text << llendl;
726 LLFloaterRegionInfo::getInstance()->close(); 726 strings_t strings;
727 727 // [0] grid_x, unused here
728 LLFloaterTelehub::show(); 728 // [1] grid_y, unused here
729} 729 // [2] agent_id of sender
730 730 // [3] sender name
731// setregioninfo 731 // [4] message
732// strings[0] = 'Y' - block terraform, 'N' - not 732 strings.push_back("-1");
733// strings[1] = 'Y' - block fly, 'N' - not 733 strings.push_back("-1");
734// strings[2] = 'Y' - allow damage, 'N' - not 734 std::string buffer;
735// strings[3] = 'Y' - allow land sale, 'N' - not 735 gAgent.getID().toString(buffer);
736// strings[4] = agent limit 736 strings.push_back(buffer);
737// strings[5] = object bonus 737 std::string name;
738// strings[6] = sim access (0 = unknown, 13 = PG, 21 = Mature, 42 = Adult) 738 gAgent.buildFullname(name);
739// strings[7] = restrict pushobject 739 strings.push_back(strings_t::value_type(name));
740// strings[8] = 'Y' - allow parcel subdivide, 'N' - not 740 strings.push_back(strings_t::value_type(text));
741// strings[9] = 'Y' - block parcel search, 'N' - allow 741 LLUUID invoice(LLFloaterRegionInfo::getLastInvoice());
742BOOL LLPanelRegionGeneralInfo::sendUpdate() 742 sendEstateOwnerMessage(gMessageSystem, "simulatormessage", invoice, strings);
743{ 743 return false;
744 llinfos << "LLPanelRegionGeneralInfo::sendUpdate()" << llendl; 744}
745 745
746 // First try using a Cap. If that fails use the old method. 746// static
747 LLSD body; 747void LLPanelRegionGeneralInfo::onClickManageTelehub(void* data)
748 std::string url = gAgent.getRegion()->getCapability("DispatchRegionInfo"); 748{
749 if (!url.empty()) 749 LLFloaterRegionInfo::getInstance()->close();
750 { 750
751 body["block_terraform"] = childGetValue("block_terraform_check"); 751 LLFloaterTelehub::show();
752 body["block_fly"] = childGetValue("block_fly_check"); 752}
753 body["allow_damage"] = childGetValue("allow_damage_check"); 753
754 body["allow_land_resell"] = childGetValue("allow_land_resell_check"); 754// setregioninfo
755 body["agent_limit"] = childGetValue("agent_limit_spin"); 755// strings[0] = 'Y' - block terraform, 'N' - not
756 body["prim_bonus"] = childGetValue("object_bonus_spin"); 756// strings[1] = 'Y' - block fly, 'N' - not
757 body["sim_access"] = childGetValue("access_combo"); 757// strings[2] = 'Y' - allow damage, 'N' - not
758 body["restrict_pushobject"] = childGetValue("restrict_pushobject"); 758// strings[3] = 'Y' - allow land sale, 'N' - not
759 body["allow_parcel_changes"] = childGetValue("allow_parcel_changes_check"); 759// strings[4] = agent limit
760 body["block_parcel_search"] = childGetValue("block_parcel_search_check"); 760// strings[5] = object bonus
761 761// strings[6] = sim access (0 = unknown, 13 = PG, 21 = Mature, 42 = Adult)
762 LLHTTPClient::post(url, body, new LLHTTPClient::Responder()); 762// strings[7] = restrict pushobject
763 } 763// strings[8] = 'Y' - allow parcel subdivide, 'N' - not
764 else 764// strings[9] = 'Y' - block parcel search, 'N' - allow
765 { 765BOOL LLPanelRegionGeneralInfo::sendUpdate()
766 strings_t strings; 766{
767 std::string buffer; 767 llinfos << "LLPanelRegionGeneralInfo::sendUpdate()" << llendl;
768 768
769 buffer = llformat("%s", (childGetValue("block_terraform_check").asBoolean() ? "Y" : "N")); 769 // First try using a Cap. If that fails use the old method.
770 strings.push_back(strings_t::value_type(buffer)); 770 LLSD body;
771 771 std::string url = gAgent.getRegion()->getCapability("DispatchRegionInfo");
772 buffer = llformat("%s", (childGetValue("block_fly_check").asBoolean() ? "Y" : "N")); 772 if (!url.empty())
773 strings.push_back(strings_t::value_type(buffer)); 773 {
774 774 body["block_terraform"] = childGetValue("block_terraform_check");
775 buffer = llformat("%s", (childGetValue("allow_damage_check").asBoolean() ? "Y" : "N")); 775 body["block_fly"] = childGetValue("block_fly_check");
776 strings.push_back(strings_t::value_type(buffer)); 776 body["allow_damage"] = childGetValue("allow_damage_check");
777 777 body["allow_land_resell"] = childGetValue("allow_land_resell_check");
778 buffer = llformat("%s", (childGetValue("allow_land_resell_check").asBoolean() ? "Y" : "N")); 778 body["agent_limit"] = childGetValue("agent_limit_spin");
779 strings.push_back(strings_t::value_type(buffer)); 779 body["prim_bonus"] = childGetValue("object_bonus_spin");
780 780 body["sim_access"] = childGetValue("access_combo");
781 F32 value = (F32)childGetValue("agent_limit_spin").asReal(); 781 body["restrict_pushobject"] = childGetValue("restrict_pushobject");
782 buffer = llformat("%f", value); 782 body["allow_parcel_changes"] = childGetValue("allow_parcel_changes_check");
783 strings.push_back(strings_t::value_type(buffer)); 783 body["block_parcel_search"] = childGetValue("block_parcel_search_check");
784 784 body["minimum_agent_age"] = childGetValue("minimum_agent_age");
785 value = (F32)childGetValue("object_bonus_spin").asReal(); 785
786 buffer = llformat("%f", value); 786 LLHTTPClient::post(url, body, new LLHTTPClient::Responder());
787 strings.push_back(strings_t::value_type(buffer)); 787 }
788 788 else
789 buffer = llformat("%d", childGetValue("access_combo").asInteger()); 789 {
790 strings.push_back(strings_t::value_type(buffer)); 790 strings_t strings;
791 791 std::string buffer;
792 buffer = llformat("%s", (childGetValue("restrict_pushobject").asBoolean() ? "Y" : "N")); 792
793 strings.push_back(strings_t::value_type(buffer)); 793 buffer = llformat("%s", (childGetValue("block_terraform_check").asBoolean() ? "Y" : "N"));
794 794 strings.push_back(strings_t::value_type(buffer));
795 buffer = llformat("%s", (childGetValue("allow_parcel_changes_check").asBoolean() ? "Y" : "N")); 795
796 strings.push_back(strings_t::value_type(buffer)); 796 buffer = llformat("%s", (childGetValue("block_fly_check").asBoolean() ? "Y" : "N"));
797 797 strings.push_back(strings_t::value_type(buffer));
798 LLUUID invoice(LLFloaterRegionInfo::getLastInvoice()); 798
799 sendEstateOwnerMessage(gMessageSystem, "setregioninfo", invoice, strings); 799 buffer = llformat("%s", (childGetValue("allow_damage_check").asBoolean() ? "Y" : "N"));
800 } 800 strings.push_back(strings_t::value_type(buffer));
801 801
802 // if we changed access levels, tell user about it 802 buffer = llformat("%s", (childGetValue("allow_land_resell_check").asBoolean() ? "Y" : "N"));
803 LLViewerRegion* region = gAgent.getRegion(); 803 strings.push_back(strings_t::value_type(buffer));
804 if (region && (childGetValue("access_combo").asInteger() != region->getSimAccess()) ) 804
805 { 805 F32 value = (F32)childGetValue("agent_limit_spin").asReal();
806 LLNotifications::instance().add("RegionMaturityChange"); 806 buffer = llformat("%f", value);
807 } 807 strings.push_back(strings_t::value_type(buffer));
808 808
809 return TRUE; 809 value = (F32)childGetValue("object_bonus_spin").asReal();
810} 810 buffer = llformat("%f", value);
811 811 strings.push_back(strings_t::value_type(buffer));
812///////////////////////////////////////////////////////////////////////////// 812
813// LLPanelRegionDebugInfo 813 buffer = llformat("%d", childGetValue("access_combo").asInteger());
814///////////////////////////////////////////////////////////////////////////// 814 strings.push_back(strings_t::value_type(buffer));
815BOOL LLPanelRegionDebugInfo::postBuild() 815
816{ 816 buffer = llformat("%s", (childGetValue("restrict_pushobject").asBoolean() ? "Y" : "N"));
817 LLPanelRegionInfo::postBuild(); 817 strings.push_back(strings_t::value_type(buffer));
818 initCtrl("disable_scripts_check"); 818
819 initCtrl("disable_collisions_check"); 819 buffer = llformat("%s", (childGetValue("allow_parcel_changes_check").asBoolean() ? "Y" : "N"));
820 initCtrl("disable_physics_check"); 820 strings.push_back(strings_t::value_type(buffer));
821 821
822 initHelpBtn("disable_scripts_help", "HelpRegionDisableScripts"); 822 LLUUID invoice(LLFloaterRegionInfo::getLastInvoice());
823 initHelpBtn("disable_collisions_help", "HelpRegionDisableCollisions"); 823 sendEstateOwnerMessage(gMessageSystem, "setregioninfo", invoice, strings);
824 initHelpBtn("disable_physics_help", "HelpRegionDisablePhysics"); 824 }
825 initHelpBtn("top_colliders_help", "HelpRegionTopColliders"); 825
826 initHelpBtn("top_scripts_help", "HelpRegionTopScripts"); 826 // if we changed access levels, tell user about it
827 initHelpBtn("restart_help", "HelpRegionRestart"); 827 LLViewerRegion* region = gAgent.getRegion();
828 828 if (region && (childGetValue("access_combo").asInteger() != region->getSimAccess()) )
829 childSetAction("choose_avatar_btn", onClickChooseAvatar, this); 829 {
830 childSetAction("return_btn", onClickReturn, this); 830 LLNotifications::instance().add("RegionMaturityChange");
831 childSetAction("top_colliders_btn", onClickTopColliders, this); 831 }
832 childSetAction("top_scripts_btn", onClickTopScripts, this); 832
833 childSetAction("restart_btn", onClickRestart, this); 833 return TRUE;
834 childSetAction("cancel_restart_btn", onClickCancelRestart, this); 834}
835 835
836 return TRUE; 836/////////////////////////////////////////////////////////////////////////////
837} 837// LLPanelRegionOpenSettingsInfo
838 838//
839// virtual 839bool LLPanelRegionOpenSettingsInfo::refreshFromRegion(LLViewerRegion* region)
840bool LLPanelRegionDebugInfo::refreshFromRegion(LLViewerRegion* region) 840{
841{ 841 // Data gets filled in by hippo manager
842 BOOL allow_modify = gAgent.isGodlike() || (region && region->canManageEstate()); 842 BOOL allow_modify = gAgent.isGodlike() || (region && region->canManageEstate());
843 setCtrlsEnabled(allow_modify); 843
844 childDisable("apply_btn"); 844 childSetValue("draw_distance", gAgent.mDrawDistance);
845 childDisable("target_avatar_name"); 845 childSetValue("force_draw_distance", gAgent.mLockedDrawDistance);
846 846 childSetValue("allow_minimap", LLSD(gHippoLimits->mAllowMinimap));
847 childSetEnabled("choose_avatar_btn", allow_modify); 847 childSetValue("allow_physical_prims", (gHippoLimits->mAllowPhysicalPrims == 1 ? TRUE : FALSE));
848 childSetEnabled("return_scripts", allow_modify && !mTargetAvatar.isNull()); 848 childSetValue("max_drag_distance", LLSD(gHippoLimits->mMaxDragDistance));
849 childSetEnabled("return_other_land", allow_modify && !mTargetAvatar.isNull()); 849 childSetValue("min_hole_size", LLSD(gHippoLimits->mMinHoleSize));
850 childSetEnabled("return_estate_wide", allow_modify && !mTargetAvatar.isNull()); 850 childSetValue("max_hollow_size", LLSD(gHippoLimits->mMaxHollow));
851 childSetEnabled("return_btn", allow_modify && !mTargetAvatar.isNull()); 851 childSetValue("max_inventory_items_transfer", LLSD(gHippoLimits->mMaxInventoryItemsTransfer));
852 childSetEnabled("top_colliders_btn", allow_modify); 852 childSetValue("max_link_count", LLSD(gHippoLimits->mMaxLinkedPrims));
853 childSetEnabled("top_scripts_btn", allow_modify); 853 childSetValue("max_link_count_phys", LLSD(gHippoLimits->mMaxPhysLinkedPrims));
854 childSetEnabled("restart_btn", allow_modify); 854 childSetValue("max_phys_prim_scale", LLSD(gHippoLimits->mMaxPrimScale));//Todo:Fix
855 childSetEnabled("cancel_restart_btn", allow_modify); 855 childSetValue("max_prim_scale", LLSD(gHippoLimits->mMaxPrimScale));
856 856 childSetValue("min_prim_scale", LLSD(gHippoLimits->mMinPrimScale));
857 return LLPanelRegionInfo::refreshFromRegion(region); 857 childSetValue("render_water", LLSD(gHippoLimits->mRenderWater));
858} 858 childSetValue("show_tags", LLSD(gHippoLimits->mRenderName));
859 859 childSetValue("max_groups", LLSD(gHippoLimits->mMaxAgentGroups));
860// virtual 860 childSetValue("allow_parcel_windlight", LLSD(gHippoLimits->mAllowParcelWindLight));
861BOOL LLPanelRegionDebugInfo::sendUpdate() 861 childSetValue("enable_teen_mode", LLSD(gHippoLimits->mEnableTeenMode));
862{ 862 childSetValue("enforce_max_build", LLSD(gHippoLimits->mEnforceMaxBuild));
863 llinfos << "LLPanelRegionDebugInfo::sendUpdate" << llendl; 863
864 strings_t strings; 864 setCtrlsEnabled(allow_modify);
865 std::string buffer; 865
866 866 return LLPanelRegionInfo::refreshFromRegion(region);
867 buffer = llformat("%s", (childGetValue("disable_scripts_check").asBoolean() ? "Y" : "N")); 867}
868 strings.push_back(buffer); 868
869 869BOOL LLPanelRegionOpenSettingsInfo::postBuild()
870 buffer = llformat("%s", (childGetValue("disable_collisions_check").asBoolean() ? "Y" : "N")); 870{
871 strings.push_back(buffer); 871 // Enable the "Apply" button if something is changed. JC
872 872 initCtrl("draw_distance");
873 buffer = llformat("%s", (childGetValue("disable_physics_check").asBoolean() ? "Y" : "N")); 873 initCtrl("force_draw_distance");
874 strings.push_back(buffer); 874 initCtrl("max_drag_distance");
875 875 initCtrl("max_prim_scale");
876 LLUUID invoice(LLFloaterRegionInfo::getLastInvoice()); 876 initCtrl("min_prim_scale");
877 sendEstateOwnerMessage(gMessageSystem, "setregiondebug", invoice, strings); 877 initCtrl("max_phys_prim_scale");
878 return TRUE; 878 initCtrl("max_hollow_size");
879} 879 initCtrl("min_hole_size");
880 880 initCtrl("max_link_count");
881void LLPanelRegionDebugInfo::onClickChooseAvatar(void* data) 881 initCtrl("max_link_count_phys");
882{ 882 initCtrl("max_inventory_items_transfer");
883 LLFloaterAvatarPicker::show(callbackAvatarID, data, FALSE, TRUE); 883 initCtrl("max_groups");
884} 884 initCtrl("render_water");
885 885 initCtrl("allow_minimap");
886// static 886 initCtrl("allow_physical_prims");
887void LLPanelRegionDebugInfo::callbackAvatarID(const std::vector<std::string>& names, const std::vector<LLUUID>& ids, void* data) 887 initCtrl("enable_teen_mode");
888{ 888 initCtrl("show_tags");
889 LLPanelRegionDebugInfo* self = (LLPanelRegionDebugInfo*) data; 889 initCtrl("allow_parcel_windlight");
890 if (ids.empty() || names.empty()) return; 890
891 self->mTargetAvatar = ids[0]; 891 initHelpBtn("force_draw_distance_help", "HelpForceDrawDistance");
892 self->childSetValue("target_avatar_name", LLSD(names[0])); 892 initHelpBtn("max_inventory_items_transfer_help", "HelpMaxInventoryItemsTransfer");
893 self->refreshFromRegion( gAgent.getRegion() ); 893 initHelpBtn("max_groups_help", "HelpMaxGroups");
894} 894 initHelpBtn("render_water_help", "HelpRenderWater");
895 895 initHelpBtn("allow_minimap_help", "HelpAllowMinimap");
896// static 896 initHelpBtn("allow_physical_prims_help", "HelpAllowPhysicalPrims");
897void LLPanelRegionDebugInfo::onClickReturn(void* data) 897 initHelpBtn("enable_teen_mode_help", "HelpEnableTeenMode");
898{ 898 initHelpBtn("show_tags_help", "HelpShowTags");
899 LLPanelRegionDebugInfo* panelp = (LLPanelRegionDebugInfo*) data; 899 initHelpBtn("allow_parcel_windlight_help", "HelpAllowParcelWindLight");
900 if (panelp->mTargetAvatar.isNull()) return; 900
901 901 childSetAction("apply_ors_btn", sendUpdate, this);
902 LLSD args; 902
903 args["USER_NAME"] = panelp->childGetValue("target_avatar_name").asString(); 903 refreshFromRegion(gAgent.getRegion());
904 LLSD payload; 904
905 payload["avatar_id"] = panelp->mTargetAvatar; 905 return LLPanelRegionInfo::postBuild();
906 906}
907 U32 flags = SWD_ALWAYS_RETURN_OBJECTS; 907
908 908// setregioninfo
909 if (panelp->childGetValue("return_scripts").asBoolean()) 909// strings[0] = 'Y' - block terraform, 'N' - not
910 { 910// strings[1] = 'Y' - block fly, 'N' - not
911 flags |= SWD_SCRIPTED_ONLY; 911// strings[2] = 'Y' - allow damage, 'N' - not
912 } 912// strings[3] = 'Y' - allow land sale, 'N' - not
913 913// strings[4] = agent limit
914 if (panelp->childGetValue("return_other_land").asBoolean()) 914// strings[5] = object bonus
915 { 915// strings[6] = sim access (0 = unknown, 13 = PG, 21 = Mature, 42 = Adult)
916 flags |= SWD_OTHERS_LAND_ONLY; 916// strings[7] = restrict pushobject
917 } 917// strings[8] = 'Y' - allow parcel subdivide, 'N' - not
918 payload["flags"] = int(flags); 918// strings[9] = 'Y' - block parcel search, 'N' - allow
919 payload["return_estate_wide"] = panelp->childGetValue("return_estate_wide").asBoolean(); 919void LLPanelRegionOpenSettingsInfo::sendUpdate(void* userdata)
920 LLNotifications::instance().add("EstateObjectReturn", args, payload, 920{
921 boost::bind(&LLPanelRegionDebugInfo::callbackReturn, panelp, _1, _2)); 921 LLPanelRegionOpenSettingsInfo* self;
922} 922 self = (LLPanelRegionOpenSettingsInfo*)userdata;
923 923
924bool LLPanelRegionDebugInfo::callbackReturn(const LLSD& notification, const LLSD& response) 924 llinfos << "LLPanelRegionOpenSettingsInfo::sendUpdate()" << llendl;
925{ 925
926 S32 option = LLNotification::getSelectedOption(notification, response); 926 LLSD body;
927 if (option != 0) return false; 927 std::string url = gAgent.getRegion()->getCapability("DispatchOpenRegionSettings");
928 928 if (!url.empty())
929 LLUUID target_avatar = notification["payload"]["avatar_id"].asUUID(); 929 {
930 if (!target_avatar.isNull()) 930 body["draw_distance"] = self->childGetValue("draw_distance");
931 { 931 body["force_draw_distance"] = self->childGetValue("force_draw_distance");
932 U32 flags = notification["payload"]["flags"].asInteger(); 932 body["allow_minimap"] = self->childGetValue("allow_minimap");
933 bool return_estate_wide = notification["payload"]["return_estate_wide"]; 933 body["allow_physical_prims"] = self->childGetValue("allow_physical_prims");
934 if (return_estate_wide) 934 body["max_drag_distance"] = self->childGetValue("max_drag_distance");
935 { 935 body["min_hole_size"] = self->childGetValue("min_hole_size");
936 // send as estate message - routed by spaceserver to all regions in estate 936 body["max_hollow_size"] = self->childGetValue("max_hollow_size");
937 strings_t strings; 937 body["max_inventory_items_transfer"] = self->childGetValue("max_inventory_items_transfer");
938 strings.push_back(llformat("%d", flags)); 938 body["max_link_count"] = self->childGetValue("max_link_count");
939 strings.push_back(target_avatar.asString()); 939 body["max_link_count_phys"] = self->childGetValue("max_link_count_phys");
940 940 body["max_phys_prim_scale"] = self->childGetValue("max_phys_prim_scale");
941 LLUUID invoice(LLFloaterRegionInfo::getLastInvoice()); 941 body["max_prim_scale"] = self->childGetValue("max_prim_scale");
942 942 body["min_prim_scale"] = self->childGetValue("min_prim_scale");
943 sendEstateOwnerMessage(gMessageSystem, "estateobjectreturn", invoice, strings); 943 body["render_water"] = self->childGetValue("render_water");
944 } 944 body["show_tags"] = self->childGetValue("show_tags");
945 else 945 body["max_groups"] = self->childGetValue("max_groups");
946 { 946 body["allow_parcel_windlight"] = self->childGetValue("allow_parcel_windlight");
947 // send to this simulator only 947 body["enable_teen_mode"] = self->childGetValue("enable_teen_mode");
948 send_sim_wide_deletes(target_avatar, flags); 948 body["enforce_max_build"] = self->childGetValue("enforce_max_build");
949 } 949
950 } 950 LLHTTPClient::post(url, body, new LLHTTPClient::Responder());
951 return false; 951 }
952} 952}
953 953
954 954/////////////////////////////////////////////////////////////////////////////
955// static 955// LLPanelRegionDebugInfo
956void LLPanelRegionDebugInfo::onClickTopColliders(void* data) 956/////////////////////////////////////////////////////////////////////////////
957{ 957BOOL LLPanelRegionDebugInfo::postBuild()
958 LLPanelRegionDebugInfo* self = (LLPanelRegionDebugInfo*)data; 958{
959 strings_t strings; 959 LLPanelRegionInfo::postBuild();
960 strings.push_back("1"); // one physics step 960 initCtrl("disable_scripts_check");
961 LLUUID invoice(LLFloaterRegionInfo::getLastInvoice()); 961 initCtrl("disable_collisions_check");
962 LLFloaterTopObjects::show(); 962 initCtrl("disable_physics_check");
963 LLFloaterTopObjects::clearList(); 963
964 self->sendEstateOwnerMessage(gMessageSystem, "colliders", invoice, strings); 964 initHelpBtn("disable_scripts_help", "HelpRegionDisableScripts");
965} 965 initHelpBtn("disable_collisions_help", "HelpRegionDisableCollisions");
966 966 initHelpBtn("disable_physics_help", "HelpRegionDisablePhysics");
967// static 967 initHelpBtn("top_colliders_help", "HelpRegionTopColliders");
968void LLPanelRegionDebugInfo::onClickTopScripts(void* data) 968 initHelpBtn("top_scripts_help", "HelpRegionTopScripts");
969{ 969 initHelpBtn("restart_help", "HelpRegionRestart");
970 LLPanelRegionDebugInfo* self = (LLPanelRegionDebugInfo*)data; 970 initHelpBtn("minimum_agent_age_help", "HelpRegionMinimumAge");
971 strings_t strings; 971
972 strings.push_back("6"); // top 5 scripts 972
973 LLUUID invoice(LLFloaterRegionInfo::getLastInvoice()); 973 childSetAction("choose_avatar_btn", onClickChooseAvatar, this);
974 LLFloaterTopObjects::show(); 974 childSetAction("return_btn", onClickReturn, this);
975 LLFloaterTopObjects::clearList(); 975 childSetAction("top_colliders_btn", onClickTopColliders, this);
976 self->sendEstateOwnerMessage(gMessageSystem, "scripts", invoice, strings); 976 childSetAction("top_scripts_btn", onClickTopScripts, this);
977} 977 childSetAction("restart_btn", onClickRestart, this);
978 978 childSetAction("cancel_restart_btn", onClickCancelRestart, this);
979// static 979
980void LLPanelRegionDebugInfo::onClickRestart(void* data) 980 return TRUE;
981{ 981}
982 LLNotifications::instance().add("ConfirmRestart", LLSD(), LLSD(), 982
983 boost::bind(&LLPanelRegionDebugInfo::callbackRestart, (LLPanelRegionDebugInfo*)data, _1, _2)); 983// virtual
984} 984bool LLPanelRegionDebugInfo::refreshFromRegion(LLViewerRegion* region)
985 985{
986bool LLPanelRegionDebugInfo::callbackRestart(const LLSD& notification, const LLSD& response) 986 BOOL allow_modify = gAgent.isGodlike() || (region && region->canManageEstate());
987{ 987 setCtrlsEnabled(allow_modify);
988 S32 option = LLNotification::getSelectedOption(notification, response); 988 childDisable("apply_btn");
989 if (option != 0) return false; 989 childDisable("target_avatar_name");
990 990
991 strings_t strings; 991 childSetEnabled("choose_avatar_btn", allow_modify);
992 strings.push_back("120"); 992 childSetEnabled("return_scripts", allow_modify && !mTargetAvatar.isNull());
993 LLUUID invoice(LLFloaterRegionInfo::getLastInvoice()); 993 childSetEnabled("return_other_land", allow_modify && !mTargetAvatar.isNull());
994 sendEstateOwnerMessage(gMessageSystem, "restart", invoice, strings); 994 childSetEnabled("return_estate_wide", allow_modify && !mTargetAvatar.isNull());
995 return false; 995 childSetEnabled("return_btn", allow_modify && !mTargetAvatar.isNull());
996} 996 childSetEnabled("top_colliders_btn", allow_modify);
997 997 childSetEnabled("top_scripts_btn", allow_modify);
998// static 998 childSetEnabled("restart_btn", allow_modify);
999void LLPanelRegionDebugInfo::onClickCancelRestart(void* data) 999 childSetEnabled("cancel_restart_btn", allow_modify);
1000{ 1000
1001 LLPanelRegionDebugInfo* self = (LLPanelRegionDebugInfo*)data; 1001 return LLPanelRegionInfo::refreshFromRegion(region);
1002 strings_t strings; 1002}
1003 strings.push_back("-1"); 1003
1004 LLUUID invoice(LLFloaterRegionInfo::getLastInvoice()); 1004// virtual
1005 self->sendEstateOwnerMessage(gMessageSystem, "restart", invoice, strings); 1005BOOL LLPanelRegionDebugInfo::sendUpdate()
1006} 1006{
1007 1007 llinfos << "LLPanelRegionDebugInfo::sendUpdate" << llendl;
1008 1008 strings_t strings;
1009///////////////////////////////////////////////////////////////////////////// 1009 std::string buffer;
1010// LLPanelRegionTextureInfo 1010
1011// 1011 buffer = llformat("%s", (childGetValue("disable_scripts_check").asBoolean() ? "Y" : "N"));
1012LLPanelRegionTextureInfo::LLPanelRegionTextureInfo() : LLPanelRegionInfo() 1012 strings.push_back(buffer);
1013{ 1013
1014 // nothing. 1014 buffer = llformat("%s", (childGetValue("disable_collisions_check").asBoolean() ? "Y" : "N"));
1015} 1015 strings.push_back(buffer);
1016 1016
1017bool LLPanelRegionTextureInfo::refreshFromRegion(LLViewerRegion* region) 1017 buffer = llformat("%s", (childGetValue("disable_physics_check").asBoolean() ? "Y" : "N"));
1018{ 1018 strings.push_back(buffer);
1019 BOOL allow_modify = gAgent.isGodlike() || (region && region->canManageEstate()); 1019
1020 setCtrlsEnabled(allow_modify); 1020 LLUUID invoice(LLFloaterRegionInfo::getLastInvoice());
1021 childDisable("apply_btn"); 1021 sendEstateOwnerMessage(gMessageSystem, "setregiondebug", invoice, strings);
1022 1022 return TRUE;
1023 if (region) 1023}
1024 { 1024
1025 childSetValue("region_text", LLSD(region->getName())); 1025void LLPanelRegionDebugInfo::onClickChooseAvatar(void* data)
1026 } 1026{
1027 else 1027 LLFloaterAvatarPicker::show(callbackAvatarID, data, FALSE, TRUE);
1028 { 1028}
1029 childSetValue("region_text", LLSD("")); 1029
1030 } 1030// static
1031 1031void LLPanelRegionDebugInfo::callbackAvatarID(const std::vector<std::string>& names, const std::vector<LLUUID>& ids, void* data)
1032 if (!region) return LLPanelRegionInfo::refreshFromRegion(region); 1032{
1033 1033 LLPanelRegionDebugInfo* self = (LLPanelRegionDebugInfo*) data;
1034 LLVLComposition* compp = region->getComposition(); 1034 if (ids.empty() || names.empty()) return;
1035 LLTextureCtrl* texture_ctrl; 1035 self->mTargetAvatar = ids[0];
1036 std::string buffer; 1036 self->childSetValue("target_avatar_name", LLSD(names[0]));
1037 for(S32 i = 0; i < TERRAIN_TEXTURE_COUNT; ++i) 1037 self->refreshFromRegion( gAgent.getRegion() );
1038 { 1038}
1039 buffer = llformat("texture_detail_%d", i); 1039
1040 texture_ctrl = getChild<LLTextureCtrl>(buffer); 1040// static
1041 if(texture_ctrl) 1041void LLPanelRegionDebugInfo::onClickReturn(void* data)
1042 { 1042{
1043 lldebugs << "Detail Texture " << i << ": " 1043 LLPanelRegionDebugInfo* panelp = (LLPanelRegionDebugInfo*) data;
1044 << compp->getDetailTextureID(i) << llendl; 1044 if (panelp->mTargetAvatar.isNull()) return;
1045 LLUUID tmp_id(compp->getDetailTextureID(i)); 1045
1046 texture_ctrl->setImageAssetID(tmp_id); 1046 LLSD args;
1047 } 1047 args["USER_NAME"] = panelp->childGetValue("target_avatar_name").asString();
1048 } 1048 LLSD payload;
1049 1049 payload["avatar_id"] = panelp->mTargetAvatar;
1050 for(S32 i = 0; i < CORNER_COUNT; ++i) 1050
1051 { 1051 U32 flags = SWD_ALWAYS_RETURN_OBJECTS;
1052 buffer = llformat("height_start_spin_%d", i); 1052
1053 childSetValue(buffer, LLSD(compp->getStartHeight(i))); 1053 if (panelp->childGetValue("return_scripts").asBoolean())
1054 buffer = llformat("height_range_spin_%d", i); 1054 {
1055 childSetValue(buffer, LLSD(compp->getHeightRange(i))); 1055 flags |= SWD_SCRIPTED_ONLY;
1056 } 1056 }
1057 1057
1058 // Call the parent for common book-keeping 1058 if (panelp->childGetValue("return_other_land").asBoolean())
1059 return LLPanelRegionInfo::refreshFromRegion(region); 1059 {
1060} 1060 flags |= SWD_OTHERS_LAND_ONLY;
1061 1061 }
1062 1062 payload["flags"] = int(flags);
1063BOOL LLPanelRegionTextureInfo::postBuild() 1063 payload["return_estate_wide"] = panelp->childGetValue("return_estate_wide").asBoolean();
1064{ 1064 LLNotifications::instance().add("EstateObjectReturn", args, payload,
1065 LLPanelRegionInfo::postBuild(); 1065 boost::bind(&LLPanelRegionDebugInfo::callbackReturn, panelp, _1, _2));
1066 std::string buffer; 1066}
1067 for(S32 i = 0; i < TERRAIN_TEXTURE_COUNT; ++i) 1067
1068 { 1068bool LLPanelRegionDebugInfo::callbackReturn(const LLSD& notification, const LLSD& response)
1069 buffer = llformat("texture_detail_%d", i); 1069{
1070 initCtrl(buffer); 1070 S32 option = LLNotification::getSelectedOption(notification, response);
1071 } 1071 if (option != 0) return false;
1072 1072
1073 for(S32 i = 0; i < CORNER_COUNT; ++i) 1073 LLUUID target_avatar = notification["payload"]["avatar_id"].asUUID();
1074 { 1074 if (!target_avatar.isNull())
1075 buffer = llformat("height_start_spin_%d", i); 1075 {
1076 initCtrl(buffer); 1076 U32 flags = notification["payload"]["flags"].asInteger();
1077 buffer = llformat("height_range_spin_%d", i); 1077 bool return_estate_wide = notification["payload"]["return_estate_wide"];
1078 initCtrl(buffer); 1078 if (return_estate_wide)
1079 } 1079 {
1080 1080 // send as estate message - routed by spaceserver to all regions in estate
1081// LLButton* btn = new LLButton("dump", LLRect(0, 20, 100, 0), "", onClickDump, this); 1081 strings_t strings;
1082// btn->setFollows(FOLLOWS_TOP|FOLLOWS_LEFT); 1082 strings.push_back(llformat("%d", flags));
1083// addChild(btn); 1083 strings.push_back(target_avatar.asString());
1084 1084
1085 return LLPanelRegionInfo::postBuild(); 1085 LLUUID invoice(LLFloaterRegionInfo::getLastInvoice());
1086} 1086
1087 1087 sendEstateOwnerMessage(gMessageSystem, "estateobjectreturn", invoice, strings);
1088BOOL LLPanelRegionTextureInfo::sendUpdate() 1088 }
1089{ 1089 else
1090 llinfos << "LLPanelRegionTextureInfo::sendUpdate()" << llendl; 1090 {
1091 1091 // send to this simulator only
1092 // Make sure user hasn't chosen wacky textures. 1092 send_sim_wide_deletes(target_avatar, flags);
1093 if (!validateTextureSizes()) 1093 }
1094 { 1094 }
1095 return FALSE; 1095 return false;
1096 } 1096}
1097 1097
1098 LLTextureCtrl* texture_ctrl; 1098
1099 std::string buffer; 1099// static
1100 std::string id_str; 1100void LLPanelRegionDebugInfo::onClickTopColliders(void* data)
1101 LLMessageSystem* msg = gMessageSystem; 1101{
1102 strings_t strings; 1102 LLPanelRegionDebugInfo* self = (LLPanelRegionDebugInfo*)data;
1103 1103 strings_t strings;
1104 LLUUID invoice(LLFloaterRegionInfo::getLastInvoice()); 1104 strings.push_back("1"); // one physics step
1105 1105 LLUUID invoice(LLFloaterRegionInfo::getLastInvoice());
1106 for(S32 i = 0; i < TERRAIN_TEXTURE_COUNT; ++i) 1106 LLFloaterTopObjects::show();
1107 { 1107 LLFloaterTopObjects::clearList();
1108 buffer = llformat("texture_detail_%d", i); 1108 self->sendEstateOwnerMessage(gMessageSystem, "colliders", invoice, strings);
1109 texture_ctrl = getChild<LLTextureCtrl>(buffer); 1109}
1110 if(texture_ctrl) 1110
1111 { 1111// static
1112 LLUUID tmp_id(texture_ctrl->getImageAssetID()); 1112void LLPanelRegionDebugInfo::onClickTopScripts(void* data)
1113 tmp_id.toString(id_str); 1113{
1114 buffer = llformat("%d %s", i, id_str.c_str()); 1114 LLPanelRegionDebugInfo* self = (LLPanelRegionDebugInfo*)data;
1115 strings.push_back(buffer); 1115 strings_t strings;
1116 } 1116 strings.push_back("6"); // top 5 scripts
1117 } 1117 LLUUID invoice(LLFloaterRegionInfo::getLastInvoice());
1118 sendEstateOwnerMessage(msg, "texturedetail", invoice, strings); 1118 LLFloaterTopObjects::show();
1119 strings.clear(); 1119 LLFloaterTopObjects::clearList();
1120 for(S32 i = 0; i < CORNER_COUNT; ++i) 1120 self->sendEstateOwnerMessage(gMessageSystem, "scripts", invoice, strings);
1121 { 1121}
1122 buffer = llformat("height_start_spin_%d", i); 1122
1123 std::string buffer2 = llformat("height_range_spin_%d", i); 1123// static
1124 std::string buffer3 = llformat("%d %f %f", i, (F32)childGetValue(buffer).asReal(), (F32)childGetValue(buffer2).asReal()); 1124void LLPanelRegionDebugInfo::onClickRestart(void* data)
1125 strings.push_back(buffer3); 1125{
1126 } 1126 LLNotifications::instance().add("ConfirmRestart", LLSD(), LLSD(),
1127 sendEstateOwnerMessage(msg, "textureheights", invoice, strings); 1127 boost::bind(&LLPanelRegionDebugInfo::callbackRestart, (LLPanelRegionDebugInfo*)data, _1, _2));
1128 strings.clear(); 1128}
1129 sendEstateOwnerMessage(msg, "texturecommit", invoice, strings); 1129
1130 return TRUE; 1130bool LLPanelRegionDebugInfo::callbackRestart(const LLSD& notification, const LLSD& response)
1131} 1131{
1132 1132 S32 option = LLNotification::getSelectedOption(notification, response);
1133BOOL LLPanelRegionTextureInfo::validateTextureSizes() 1133 if (option != 0) return false;
1134{ 1134
1135 for(S32 i = 0; i < TERRAIN_TEXTURE_COUNT; ++i) 1135 strings_t strings;
1136 { 1136 strings.push_back("120");
1137 std::string buffer; 1137 LLUUID invoice(LLFloaterRegionInfo::getLastInvoice());
1138 buffer = llformat("texture_detail_%d", i); 1138 sendEstateOwnerMessage(gMessageSystem, "restart", invoice, strings);
1139 LLTextureCtrl* texture_ctrl = getChild<LLTextureCtrl>(buffer); 1139 return false;
1140 if (!texture_ctrl) continue; 1140}
1141 1141
1142 LLUUID image_asset_id = texture_ctrl->getImageAssetID(); 1142// static
1143 LLViewerImage* img = gImageList.getImage(image_asset_id); 1143void LLPanelRegionDebugInfo::onClickCancelRestart(void* data)
1144 S32 components = img->getComponents(); 1144{
1145 // Must ask for highest resolution version's width. JC 1145 LLPanelRegionDebugInfo* self = (LLPanelRegionDebugInfo*)data;
1146 S32 width = img->getWidth(0); 1146 strings_t strings;
1147 S32 height = img->getHeight(0); 1147 strings.push_back("-1");
1148 1148 LLUUID invoice(LLFloaterRegionInfo::getLastInvoice());
1149 //llinfos << "texture detail " << i << " is " << width << "x" << height << "x" << components << llendl; 1149 self->sendEstateOwnerMessage(gMessageSystem, "restart", invoice, strings);
1150 1150}
1151 if (components != 3) 1151
1152 { 1152
1153 LLSD args; 1153/////////////////////////////////////////////////////////////////////////////
1154 args["TEXTURE_NUM"] = i+1; 1154// LLPanelRegionTextureInfo
1155 args["TEXTURE_BIT_DEPTH"] = llformat("%d",components * 8); 1155//
1156 LLNotifications::instance().add("InvalidTerrainBitDepth", args); 1156LLPanelRegionTextureInfo::LLPanelRegionTextureInfo() : LLPanelRegionInfo()
1157 return FALSE; 1157{
1158 } 1158 // nothing.
1159 1159}
1160 if (width > 512 || height > 512) 1160
1161 { 1161bool LLPanelRegionTextureInfo::refreshFromRegion(LLViewerRegion* region)
1162 1162{
1163 LLSD args; 1163 BOOL allow_modify = gAgent.isGodlike() || (region && region->canManageEstate());
1164 args["TEXTURE_NUM"] = i+1; 1164 setCtrlsEnabled(allow_modify);
1165 args["TEXTURE_SIZE_X"] = width; 1165 childDisable("apply_btn");
1166 args["TEXTURE_SIZE_Y"] = height; 1166
1167 LLNotifications::instance().add("InvalidTerrainSize", args); 1167 if (region)
1168 return FALSE; 1168 {
1169 1169 childSetValue("region_text", LLSD(region->getName()));
1170 } 1170 }
1171 } 1171 else
1172 1172 {
1173 return TRUE; 1173 childSetValue("region_text", LLSD(""));
1174} 1174 }
1175 1175
1176 1176 if (!region) return LLPanelRegionInfo::refreshFromRegion(region);
1177// static 1177
1178void LLPanelRegionTextureInfo::onClickDump(void* data) 1178 LLVLComposition* compp = region->getComposition();
1179{ 1179 LLTextureCtrl* texture_ctrl;
1180 llinfos << "LLPanelRegionTextureInfo::onClickDump()" << llendl; 1180 std::string buffer;
1181} 1181 for(S32 i = 0; i < TERRAIN_TEXTURE_COUNT; ++i)
1182 1182 {
1183 1183 buffer = llformat("texture_detail_%d", i);
1184///////////////////////////////////////////////////////////////////////////// 1184 texture_ctrl = getChild<LLTextureCtrl>(buffer);
1185// LLPanelRegionTerrainInfo 1185 if(texture_ctrl)
1186///////////////////////////////////////////////////////////////////////////// 1186 {
1187BOOL LLPanelRegionTerrainInfo::postBuild() 1187 lldebugs << "Detail Texture " << i << ": "
1188{ 1188 << compp->getDetailTextureID(i) << llendl;
1189 LLPanelRegionInfo::postBuild(); 1189 LLUUID tmp_id(compp->getDetailTextureID(i));
1190 1190 texture_ctrl->setImageAssetID(tmp_id);
1191 initHelpBtn("water_height_help", "HelpRegionWaterHeight"); 1191 }
1192 initHelpBtn("terrain_raise_help", "HelpRegionTerrainRaise"); 1192 }
1193 initHelpBtn("terrain_lower_help", "HelpRegionTerrainLower"); 1193
1194 initHelpBtn("upload_raw_help", "HelpRegionUploadRaw"); 1194 for(S32 i = 0; i < CORNER_COUNT; ++i)
1195 initHelpBtn("download_raw_help", "HelpRegionDownloadRaw"); 1195 {
1196 initHelpBtn("use_estate_sun_help", "HelpRegionUseEstateSun"); 1196 buffer = llformat("height_start_spin_%d", i);
1197 initHelpBtn("fixed_sun_help", "HelpRegionFixedSun"); 1197 childSetValue(buffer, LLSD(compp->getStartHeight(i)));
1198 initHelpBtn("bake_terrain_help", "HelpRegionBakeTerrain"); 1198 buffer = llformat("height_range_spin_%d", i);
1199 1199 childSetValue(buffer, LLSD(compp->getHeightRange(i)));
1200 initCtrl("water_height_spin"); 1200 }
1201 initCtrl("terrain_raise_spin"); 1201
1202 initCtrl("terrain_lower_spin"); 1202 // Call the parent for common book-keeping
1203 1203 return LLPanelRegionInfo::refreshFromRegion(region);
1204 initCtrl("fixed_sun_check"); 1204}
1205 childSetCommitCallback("fixed_sun_check", onChangeFixedSun, this); 1205
1206 childSetCommitCallback("use_estate_sun_check", onChangeUseEstateTime, this); 1206
1207 childSetCommitCallback("sun_hour_slider", onChangeSunHour, this); 1207BOOL LLPanelRegionTextureInfo::postBuild()
1208 1208{
1209 childSetAction("download_raw_btn", onClickDownloadRaw, this); 1209 LLPanelRegionInfo::postBuild();
1210 childSetAction("upload_raw_btn", onClickUploadRaw, this); 1210 std::string buffer;
1211 childSetAction("bake_terrain_btn", onClickBakeTerrain, this); 1211 for(S32 i = 0; i < TERRAIN_TEXTURE_COUNT; ++i)
1212 1212 {
1213 return TRUE; 1213 buffer = llformat("texture_detail_%d", i);
1214} 1214 initCtrl(buffer);
1215 1215 }
1216// virtual 1216
1217bool LLPanelRegionTerrainInfo::refreshFromRegion(LLViewerRegion* region) 1217 for(S32 i = 0; i < CORNER_COUNT; ++i)
1218{ 1218 {
1219 llinfos << "LLPanelRegionTerrainInfo::refreshFromRegion" << llendl; 1219 buffer = llformat("height_start_spin_%d", i);
1220 1220 initCtrl(buffer);
1221 BOOL owner_or_god = gAgent.isGodlike() 1221 buffer = llformat("height_range_spin_%d", i);
1222 || (region && (region->getOwner() == gAgent.getID())); 1222 initCtrl(buffer);
1223 BOOL owner_or_god_or_manager = owner_or_god 1223 }
1224 || (region && region->isEstateManager()); 1224
1225 setCtrlsEnabled(owner_or_god_or_manager); 1225// LLButton* btn = new LLButton("dump", LLRect(0, 20, 100, 0), "", onClickDump, this);
1226 childDisable("apply_btn"); 1226// btn->setFollows(FOLLOWS_TOP|FOLLOWS_LEFT);
1227 1227// addChild(btn);
1228 childSetEnabled("download_raw_btn", owner_or_god); 1228
1229 childSetEnabled("upload_raw_btn", owner_or_god); 1229 return LLPanelRegionInfo::postBuild();
1230 childSetEnabled("bake_terrain_btn", owner_or_god); 1230}
1231 1231
1232 return LLPanelRegionInfo::refreshFromRegion(region); 1232BOOL LLPanelRegionTextureInfo::sendUpdate()
1233} 1233{
1234 1234 llinfos << "LLPanelRegionTextureInfo::sendUpdate()" << llendl;
1235// virtual 1235
1236BOOL LLPanelRegionTerrainInfo::sendUpdate() 1236 // Make sure user hasn't chosen wacky textures.
1237{ 1237 if (!validateTextureSizes())
1238 llinfos << "LLPanelRegionTerrainInfo::sendUpdate" << llendl; 1238 {
1239 std::string buffer; 1239 return FALSE;
1240 strings_t strings; 1240 }
1241 LLUUID invoice(LLFloaterRegionInfo::getLastInvoice()); 1241
1242 1242 LLTextureCtrl* texture_ctrl;
1243 buffer = llformat("%f", (F32)childGetValue("water_height_spin").asReal()); 1243 std::string buffer;
1244 strings.push_back(buffer); 1244 std::string id_str;
1245 buffer = llformat("%f", (F32)childGetValue("terrain_raise_spin").asReal()); 1245 LLMessageSystem* msg = gMessageSystem;
1246 strings.push_back(buffer); 1246 strings_t strings;
1247 buffer = llformat("%f", (F32)childGetValue("terrain_lower_spin").asReal()); 1247
1248 strings.push_back(buffer); 1248 LLUUID invoice(LLFloaterRegionInfo::getLastInvoice());
1249 buffer = llformat("%s", (childGetValue("use_estate_sun_check").asBoolean() ? "Y" : "N")); 1249
1250 strings.push_back(buffer); 1250 for(S32 i = 0; i < TERRAIN_TEXTURE_COUNT; ++i)
1251 buffer = llformat("%s", (childGetValue("fixed_sun_check").asBoolean() ? "Y" : "N")); 1251 {
1252 strings.push_back(buffer); 1252 buffer = llformat("texture_detail_%d", i);
1253 buffer = llformat("%f", (F32)childGetValue("sun_hour_slider").asReal() ); 1253 texture_ctrl = getChild<LLTextureCtrl>(buffer);
1254 strings.push_back(buffer); 1254 if(texture_ctrl)
1255 1255 {
1256 // Grab estate information in case the user decided to set the 1256 LLUUID tmp_id(texture_ctrl->getImageAssetID());
1257 // region back to estate time. JC 1257 tmp_id.toString(id_str);
1258 LLFloaterRegionInfo* floater = LLFloaterRegionInfo::getInstance(); 1258 buffer = llformat("%d %s", i, id_str.c_str());
1259 if (!floater) return true; 1259 strings.push_back(buffer);
1260 1260 }
1261 LLTabContainer* tab = floater->getChild<LLTabContainer>("region_panels"); 1261 }
1262 if (!tab) return true; 1262 sendEstateOwnerMessage(msg, "texturedetail", invoice, strings);
1263 1263 strings.clear();
1264 LLPanelEstateInfo* panel = (LLPanelEstateInfo*)tab->getChild<LLPanel>("Estate"); 1264 for(S32 i = 0; i < CORNER_COUNT; ++i)
1265 if (!panel) return true; 1265 {
1266 1266 buffer = llformat("height_start_spin_%d", i);
1267 BOOL estate_global_time = panel->getGlobalTime(); 1267 std::string buffer2 = llformat("height_range_spin_%d", i);
1268 BOOL estate_fixed_sun = panel->getFixedSun(); 1268 std::string buffer3 = llformat("%d %f %f", i, (F32)childGetValue(buffer).asReal(), (F32)childGetValue(buffer2).asReal());
1269 F32 estate_sun_hour; 1269 strings.push_back(buffer3);
1270 if (estate_global_time) 1270 }
1271 { 1271 sendEstateOwnerMessage(msg, "textureheights", invoice, strings);
1272 estate_sun_hour = 0.f; 1272 strings.clear();
1273 } 1273 sendEstateOwnerMessage(msg, "texturecommit", invoice, strings);
1274 else 1274 return TRUE;
1275 { 1275}
1276 estate_sun_hour = panel->getSunHour(); 1276
1277 } 1277BOOL LLPanelRegionTextureInfo::validateTextureSizes()
1278 1278{
1279 buffer = llformat("%s", (estate_global_time ? "Y" : "N") ); 1279 for(S32 i = 0; i < TERRAIN_TEXTURE_COUNT; ++i)
1280 strings.push_back(buffer); 1280 {
1281 buffer = llformat("%s", (estate_fixed_sun ? "Y" : "N") ); 1281 std::string buffer;
1282 strings.push_back(buffer); 1282 buffer = llformat("texture_detail_%d", i);
1283 buffer = llformat("%f", estate_sun_hour); 1283 LLTextureCtrl* texture_ctrl = getChild<LLTextureCtrl>(buffer);
1284 strings.push_back(buffer); 1284 if (!texture_ctrl) continue;
1285 1285
1286 sendEstateOwnerMessage(gMessageSystem, "setregionterrain", invoice, strings); 1286 LLUUID image_asset_id = texture_ctrl->getImageAssetID();
1287 return TRUE; 1287 LLViewerImage* img = gImageList.getImage(image_asset_id);
1288} 1288 S32 components = img->getComponents();
1289 1289 // Must ask for highest resolution version's width. JC
1290// static 1290 S32 width = img->getWidth(0);
1291void LLPanelRegionTerrainInfo::onChangeUseEstateTime(LLUICtrl* ctrl, void* user_data) 1291 S32 height = img->getHeight(0);
1292{ 1292
1293 LLPanelRegionTerrainInfo* panel = (LLPanelRegionTerrainInfo*) user_data; 1293 //llinfos << "texture detail " << i << " is " << width << "x" << height << "x" << components << llendl;
1294 if (!panel) return; 1294
1295 BOOL use_estate_sun = panel->childGetValue("use_estate_sun_check").asBoolean(); 1295 if (components != 3)
1296 panel->childSetEnabled("fixed_sun_check", !use_estate_sun); 1296 {
1297 panel->childSetEnabled("sun_hour_slider", !use_estate_sun); 1297 LLSD args;
1298 if (use_estate_sun) 1298 args["TEXTURE_NUM"] = i+1;
1299 { 1299 args["TEXTURE_BIT_DEPTH"] = llformat("%d",components * 8);
1300 panel->childSetValue("fixed_sun_check", LLSD(FALSE)); 1300 LLNotifications::instance().add("InvalidTerrainBitDepth", args);
1301 panel->childSetValue("sun_hour_slider", LLSD(0.f)); 1301 return FALSE;
1302 } 1302 }
1303 panel->childEnable("apply_btn"); 1303
1304} 1304 if (width > 512 || height > 512)
1305 1305 {
1306// static 1306
1307void LLPanelRegionTerrainInfo::onChangeFixedSun(LLUICtrl* ctrl, void* user_data) 1307 LLSD args;
1308{ 1308 args["TEXTURE_NUM"] = i+1;
1309 LLPanelRegionTerrainInfo* panel = (LLPanelRegionTerrainInfo*) user_data; 1309 args["TEXTURE_SIZE_X"] = width;
1310 if (!panel) return; 1310 args["TEXTURE_SIZE_Y"] = height;
1311 // Just enable the apply button. We let the sun-hour slider be enabled 1311 LLNotifications::instance().add("InvalidTerrainSize", args);
1312 // for both fixed-sun and non-fixed-sun. JC 1312 return FALSE;
1313 panel->childEnable("apply_btn"); 1313
1314} 1314 }
1315 1315 }
1316// static 1316
1317void LLPanelRegionTerrainInfo::onChangeSunHour(LLUICtrl* ctrl, void*) 1317 return TRUE;
1318{ 1318}
1319 // can't use userdata to get panel, slider uses it internally 1319
1320 LLPanelRegionTerrainInfo* panel = (LLPanelRegionTerrainInfo*) ctrl->getParent(); 1320
1321 if (!panel) return; 1321// static
1322 panel->childEnable("apply_btn"); 1322void LLPanelRegionTextureInfo::onClickDump(void* data)
1323} 1323{
1324 1324 llinfos << "LLPanelRegionTextureInfo::onClickDump()" << llendl;
1325// static 1325}
1326void LLPanelRegionTerrainInfo::onClickDownloadRaw(void* data) 1326
1327{ 1327
1328 LLFilePicker& picker = LLFilePicker::instance(); 1328/////////////////////////////////////////////////////////////////////////////
1329 if (!picker.getSaveFile(LLFilePicker::FFSAVE_RAW, "terrain.raw")) 1329// LLPanelRegionTerrainInfo
1330 { 1330/////////////////////////////////////////////////////////////////////////////
1331 llwarns << "No file" << llendl; 1331BOOL LLPanelRegionTerrainInfo::postBuild()
1332 return; 1332{
1333 } 1333 LLPanelRegionInfo::postBuild();
1334 std::string filepath = picker.getFirstFile(); 1334
1335 gXferManager->expectFileForRequest(filepath); 1335 initHelpBtn("water_height_help", "HelpRegionWaterHeight");
1336 1336 initHelpBtn("terrain_raise_help", "HelpRegionTerrainRaise");
1337 LLPanelRegionTerrainInfo* self = (LLPanelRegionTerrainInfo*)data; 1337 initHelpBtn("terrain_lower_help", "HelpRegionTerrainLower");
1338 strings_t strings; 1338 initHelpBtn("upload_raw_help", "HelpRegionUploadRaw");
1339 strings.push_back("download filename"); 1339 initHelpBtn("download_raw_help", "HelpRegionDownloadRaw");
1340 strings.push_back(filepath); 1340 initHelpBtn("use_estate_sun_help", "HelpRegionUseEstateSun");
1341 LLUUID invoice(LLFloaterRegionInfo::getLastInvoice()); 1341 initHelpBtn("fixed_sun_help", "HelpRegionFixedSun");
1342 self->sendEstateOwnerMessage(gMessageSystem, "terrain", invoice, strings); 1342 initHelpBtn("bake_terrain_help", "HelpRegionBakeTerrain");
1343} 1343
1344 1344 initCtrl("water_height_spin");
1345// static 1345 initCtrl("terrain_raise_spin");
1346void LLPanelRegionTerrainInfo::onClickUploadRaw(void* data) 1346 initCtrl("terrain_lower_spin");
1347{ 1347
1348 LLFilePicker& picker = LLFilePicker::instance(); 1348 initCtrl("fixed_sun_check");
1349 if (!picker.getOpenFile(LLFilePicker::FFLOAD_RAW)) 1349 childSetCommitCallback("fixed_sun_check", onChangeFixedSun, this);
1350 { 1350 childSetCommitCallback("use_estate_sun_check", onChangeUseEstateTime, this);
1351 llwarns << "No file" << llendl; 1351 childSetCommitCallback("sun_hour_slider", onChangeSunHour, this);
1352 return; 1352
1353 } 1353 childSetAction("download_raw_btn", onClickDownloadRaw, this);
1354 std::string filepath = picker.getFirstFile(); 1354 childSetAction("upload_raw_btn", onClickUploadRaw, this);
1355 gXferManager->expectFileForTransfer(filepath); 1355 childSetAction("bake_terrain_btn", onClickBakeTerrain, this);
1356 1356
1357 LLPanelRegionTerrainInfo* self = (LLPanelRegionTerrainInfo*)data; 1357 return TRUE;
1358 strings_t strings; 1358}
1359 strings.push_back("upload filename"); 1359
1360 strings.push_back(filepath); 1360// virtual
1361 LLUUID invoice(LLFloaterRegionInfo::getLastInvoice()); 1361bool LLPanelRegionTerrainInfo::refreshFromRegion(LLViewerRegion* region)
1362 self->sendEstateOwnerMessage(gMessageSystem, "terrain", invoice, strings); 1362{
1363 1363 llinfos << "LLPanelRegionTerrainInfo::refreshFromRegion" << llendl;
1364 LLNotifications::instance().add("RawUploadStarted"); 1364
1365} 1365 BOOL owner_or_god = gAgent.isGodlike()
1366 1366 || (region && (region->getOwner() == gAgent.getID()));
1367// static 1367 BOOL owner_or_god_or_manager = owner_or_god
1368void LLPanelRegionTerrainInfo::onClickBakeTerrain(void* data) 1368 || (region && region->isEstateManager());
1369{ 1369 setCtrlsEnabled(owner_or_god_or_manager);
1370 LLNotifications::instance().add( 1370 childDisable("apply_btn");
1371 LLNotification::Params("ConfirmBakeTerrain") 1371
1372 .functor(boost::bind(&LLPanelRegionTerrainInfo::callbackBakeTerrain, (LLPanelRegionTerrainInfo*)data, _1, _2))); 1372 childSetEnabled("download_raw_btn", owner_or_god);
1373} 1373 childSetEnabled("upload_raw_btn", owner_or_god);
1374 1374 childSetEnabled("bake_terrain_btn", owner_or_god);
1375bool LLPanelRegionTerrainInfo::callbackBakeTerrain(const LLSD& notification, const LLSD& response) 1375
1376{ 1376 return LLPanelRegionInfo::refreshFromRegion(region);
1377 S32 option = LLNotification::getSelectedOption(notification, response); 1377}
1378 if (option != 0) return false; 1378
1379 1379// virtual
1380 strings_t strings; 1380BOOL LLPanelRegionTerrainInfo::sendUpdate()
1381 strings.push_back("bake"); 1381{
1382 LLUUID invoice(LLFloaterRegionInfo::getLastInvoice()); 1382 llinfos << "LLPanelRegionTerrainInfo::sendUpdate" << llendl;
1383 sendEstateOwnerMessage(gMessageSystem, "terrain", invoice, strings); 1383 std::string buffer;
1384 return false; 1384 strings_t strings;
1385} 1385 LLUUID invoice(LLFloaterRegionInfo::getLastInvoice());
1386 1386
1387///////////////////////////////////////////////////////////////////////////// 1387 buffer = llformat("%f", (F32)childGetValue("water_height_spin").asReal());
1388// LLPanelEstateInfo 1388 strings.push_back(buffer);
1389// 1389 buffer = llformat("%f", (F32)childGetValue("terrain_raise_spin").asReal());
1390 1390 strings.push_back(buffer);
1391LLPanelEstateInfo::LLPanelEstateInfo() 1391 buffer = llformat("%f", (F32)childGetValue("terrain_lower_spin").asReal());
1392: LLPanelRegionInfo(), 1392 strings.push_back(buffer);
1393 mEstateID(0) // invalid 1393 buffer = llformat("%s", (childGetValue("use_estate_sun_check").asBoolean() ? "Y" : "N"));
1394{ 1394 strings.push_back(buffer);
1395} 1395 buffer = llformat("%s", (childGetValue("fixed_sun_check").asBoolean() ? "Y" : "N"));
1396 1396 strings.push_back(buffer);
1397// static 1397 buffer = llformat("%f", (F32)childGetValue("sun_hour_slider").asReal() );
1398void LLPanelEstateInfo::initDispatch(LLDispatcher& dispatch) 1398 strings.push_back(buffer);
1399{ 1399
1400 std::string name; 1400 // Grab estate information in case the user decided to set the
1401 1401 // region back to estate time. JC
1402// name.assign("setowner"); 1402 LLFloaterRegionInfo* floater = LLFloaterRegionInfo::getInstance();
1403// static LLDispatchSetEstateOwner set_owner; 1403 if (!floater) return true;
1404// dispatch.addHandler(name, &set_owner); 1404
1405 1405 LLTabContainer* tab = floater->getChild<LLTabContainer>("region_panels");
1406 name.assign("estateupdateinfo"); 1406 if (!tab) return true;
1407 static LLDispatchEstateUpdateInfo estate_update_info; 1407
1408 dispatch.addHandler(name, &estate_update_info); 1408 LLPanelEstateInfo* panel = (LLPanelEstateInfo*)tab->getChild<LLPanel>("Estate");
1409 1409 if (!panel) return true;
1410 name.assign("setaccess"); 1410
1411 static LLDispatchSetEstateAccess set_access; 1411 BOOL estate_global_time = panel->getGlobalTime();
1412 dispatch.addHandler(name, &set_access); 1412 BOOL estate_fixed_sun = panel->getFixedSun();
1413 1413 F32 estate_sun_hour;
1414 estate_dispatch_initialized = true; 1414 if (estate_global_time)
1415} 1415 {
1416 1416 estate_sun_hour = 0.f;
1417// static 1417 }
1418// Disables the sun-hour slider and the use fixed time check if the use global time is check 1418 else
1419void LLPanelEstateInfo::onChangeUseGlobalTime(LLUICtrl* ctrl, void* user_data) 1419 {
1420{ 1420 estate_sun_hour = panel->getSunHour();
1421 LLPanelEstateInfo* panel = (LLPanelEstateInfo*) user_data; 1421 }
1422 if (panel) 1422
1423 { 1423 buffer = llformat("%s", (estate_global_time ? "Y" : "N") );
1424 bool enabled = !panel->childGetValue("use_global_time_check").asBoolean(); 1424 strings.push_back(buffer);
1425 panel->childSetEnabled("sun_hour_slider", enabled); 1425 buffer = llformat("%s", (estate_fixed_sun ? "Y" : "N") );
1426 panel->childSetEnabled("fixed_sun_check", enabled); 1426 strings.push_back(buffer);
1427 panel->childSetValue("fixed_sun_check", LLSD(FALSE)); 1427 buffer = llformat("%f", estate_sun_hour);
1428 panel->enableButton("apply_btn"); 1428 strings.push_back(buffer);
1429 } 1429
1430} 1430 sendEstateOwnerMessage(gMessageSystem, "setregionterrain", invoice, strings);
1431 1431 return TRUE;
1432// Enables the sun-hour slider if the fixed-sun checkbox is set 1432}
1433void LLPanelEstateInfo::onChangeFixedSun(LLUICtrl* ctrl, void* user_data) 1433
1434{ 1434// static
1435 LLPanelEstateInfo* panel = (LLPanelEstateInfo*) user_data; 1435void LLPanelRegionTerrainInfo::onChangeUseEstateTime(LLUICtrl* ctrl, void* user_data)
1436 if (panel) 1436{
1437 { 1437 LLPanelRegionTerrainInfo* panel = (LLPanelRegionTerrainInfo*) user_data;
1438 bool enabled = !panel->childGetValue("fixed_sun_check").asBoolean(); 1438 if (!panel) return;
1439 panel->childSetEnabled("use_global_time_check", enabled); 1439 BOOL use_estate_sun = panel->childGetValue("use_estate_sun_check").asBoolean();
1440 panel->childSetValue("use_global_time_check", LLSD(FALSE)); 1440 panel->childSetEnabled("fixed_sun_check", !use_estate_sun);
1441 panel->enableButton("apply_btn"); 1441 panel->childSetEnabled("sun_hour_slider", !use_estate_sun);
1442 } 1442 if (use_estate_sun)
1443} 1443 {
1444 1444 panel->childSetValue("fixed_sun_check", LLSD(FALSE));
1445 1445 panel->childSetValue("sun_hour_slider", LLSD(0.f));
1446 1446 }
1447 1447 panel->childEnable("apply_btn");
1448//--------------------------------------------------------------------------- 1448}
1449// Add/Remove estate access button callbacks 1449
1450//--------------------------------------------------------------------------- 1450// static
1451void LLPanelEstateInfo::onClickEditSky(void* user_data) 1451void LLPanelRegionTerrainInfo::onChangeFixedSun(LLUICtrl* ctrl, void* user_data)
1452{ 1452{
1453 LLFloaterWindLight::show(); 1453 LLPanelRegionTerrainInfo* panel = (LLPanelRegionTerrainInfo*) user_data;
1454} 1454 if (!panel) return;
1455 1455 // Just enable the apply button. We let the sun-hour slider be enabled
1456void LLPanelEstateInfo::onClickEditDayCycle(void* user_data) 1456 // for both fixed-sun and non-fixed-sun. JC
1457{ 1457 panel->childEnable("apply_btn");
1458 LLFloaterDayCycle::show(); 1458}
1459} 1459
1460 1460// static
1461// static 1461void LLPanelRegionTerrainInfo::onChangeSunHour(LLUICtrl* ctrl, void*)
1462void LLPanelEstateInfo::onClickAddAllowedAgent(void* user_data) 1462{
1463{ 1463 // can't use userdata to get panel, slider uses it internally
1464 LLPanelEstateInfo* self = (LLPanelEstateInfo*)user_data; 1464 LLPanelRegionTerrainInfo* panel = (LLPanelRegionTerrainInfo*) ctrl->getParent();
1465 LLCtrlListInterface *list = self->childGetListInterface("allowed_avatar_name_list"); 1465 if (!panel) return;
1466 if (!list) return; 1466 panel->childEnable("apply_btn");
1467 if (list->getItemCount() >= ESTATE_MAX_ACCESS_IDS) 1467}
1468 { 1468
1469 //args 1469// static
1470 1470void LLPanelRegionTerrainInfo::onClickDownloadRaw(void* data)
1471 LLSD args; 1471{
1472 args["MAX_AGENTS"] = llformat("%d",ESTATE_MAX_ACCESS_IDS); 1472 LLFilePicker& picker = LLFilePicker::instance();
1473 LLNotifications::instance().add("MaxAllowedAgentOnRegion", args); 1473 if (!picker.getSaveFile(LLFilePicker::FFSAVE_RAW, "terrain.raw"))
1474 return; 1474 {
1475 } 1475 llwarns << "No file" << llendl;
1476 accessAddCore(ESTATE_ACCESS_ALLOWED_AGENT_ADD, "EstateAllowedAgentAdd"); 1476 return;
1477} 1477 }
1478 1478 std::string filepath = picker.getFirstFile();
1479// static 1479 gXferManager->expectFileForRequest(filepath);
1480void LLPanelEstateInfo::onClickRemoveAllowedAgent(void* user_data) 1480
1481{ 1481 LLPanelRegionTerrainInfo* self = (LLPanelRegionTerrainInfo*)data;
1482 accessRemoveCore(ESTATE_ACCESS_ALLOWED_AGENT_REMOVE, "EstateAllowedAgentRemove", "allowed_avatar_name_list"); 1482 strings_t strings;
1483} 1483 strings.push_back("download filename");
1484 1484 strings.push_back(filepath);
1485// static 1485 LLUUID invoice(LLFloaterRegionInfo::getLastInvoice());
1486void LLPanelEstateInfo::onClickAddAllowedGroup(void* user_data) 1486 self->sendEstateOwnerMessage(gMessageSystem, "terrain", invoice, strings);
1487{ 1487}
1488 LLPanelEstateInfo* self = (LLPanelEstateInfo*)user_data; 1488
1489 LLCtrlListInterface *list = self->childGetListInterface("allowed_group_name_list"); 1489// static
1490 if (!list) return; 1490void LLPanelRegionTerrainInfo::onClickUploadRaw(void* data)
1491 if (list->getItemCount() >= ESTATE_MAX_ACCESS_IDS) 1491{
1492 { 1492 LLFilePicker& picker = LLFilePicker::instance();
1493 LLSD args; 1493 if (!picker.getOpenFile(LLFilePicker::FFLOAD_RAW))
1494 args["MAX_GROUPS"] = llformat("%d",ESTATE_MAX_ACCESS_IDS); 1494 {
1495 LLNotifications::instance().add("MaxAllowedGroupsOnRegion", args); 1495 llwarns << "No file" << llendl;
1496 return; 1496 return;
1497 } 1497 }
1498 1498 std::string filepath = picker.getFirstFile();
1499 LLNotification::Params params("ChangeLindenAccess"); 1499 gXferManager->expectFileForTransfer(filepath);
1500 params.functor(boost::bind(&LLPanelEstateInfo::addAllowedGroup, self, _1, _2)); 1500
1501 if (isLindenEstate()) 1501 LLPanelRegionTerrainInfo* self = (LLPanelRegionTerrainInfo*)data;
1502 { 1502 strings_t strings;
1503 LLNotifications::instance().add(params); 1503 strings.push_back("upload filename");
1504 } 1504 strings.push_back(filepath);
1505 else 1505 LLUUID invoice(LLFloaterRegionInfo::getLastInvoice());
1506 { 1506 self->sendEstateOwnerMessage(gMessageSystem, "terrain", invoice, strings);
1507 LLNotifications::instance().forceResponse(params, 0); 1507
1508 } 1508 LLNotifications::instance().add("RawUploadStarted");
1509} 1509}
1510 1510
1511bool LLPanelEstateInfo::addAllowedGroup(const LLSD& notification, const LLSD& response) 1511// static
1512{ 1512void LLPanelRegionTerrainInfo::onClickBakeTerrain(void* data)
1513 S32 option = LLNotification::getSelectedOption(notification, response); 1513{
1514 if (option != 0) return false; 1514 LLNotifications::instance().add(
1515 1515 LLNotification::Params("ConfirmBakeTerrain")
1516 LLFloater* parent_floater = gFloaterView->getParentFloater(this); 1516 .functor(boost::bind(&LLPanelRegionTerrainInfo::callbackBakeTerrain, (LLPanelRegionTerrainInfo*)data, _1, _2)));
1517 1517}
1518 LLFloaterGroupPicker* widget; 1518
1519 widget = LLFloaterGroupPicker::showInstance(LLSD(gAgent.getID())); 1519bool LLPanelRegionTerrainInfo::callbackBakeTerrain(const LLSD& notification, const LLSD& response)
1520 if (widget) 1520{
1521 { 1521 S32 option = LLNotification::getSelectedOption(notification, response);
1522 widget->setSelectCallback(addAllowedGroup2, NULL); 1522 if (option != 0) return false;
1523 if (parent_floater) 1523
1524 { 1524 strings_t strings;
1525 LLRect new_rect = gFloaterView->findNeighboringPosition(parent_floater, widget); 1525 strings.push_back("bake");
1526 widget->setOrigin(new_rect.mLeft, new_rect.mBottom); 1526 LLUUID invoice(LLFloaterRegionInfo::getLastInvoice());
1527 parent_floater->addDependentFloater(widget); 1527 sendEstateOwnerMessage(gMessageSystem, "terrain", invoice, strings);
1528 } 1528 return false;
1529 } 1529}
1530 1530
1531 return false; 1531/////////////////////////////////////////////////////////////////////////////
1532} 1532// LLPanelEstateInfo
1533 1533//
1534// static 1534
1535void LLPanelEstateInfo::onClickRemoveAllowedGroup(void* user_data) 1535LLPanelEstateInfo::LLPanelEstateInfo()
1536{ 1536: LLPanelRegionInfo(),
1537 accessRemoveCore(ESTATE_ACCESS_ALLOWED_GROUP_REMOVE, "EstateAllowedGroupRemove", "allowed_group_name_list"); 1537 mEstateID(0) // invalid
1538} 1538{
1539 1539}
1540// static 1540
1541void LLPanelEstateInfo::onClickAddBannedAgent(void* user_data) 1541// static
1542{ 1542void LLPanelEstateInfo::initDispatch(LLDispatcher& dispatch)
1543 LLPanelEstateInfo* self = (LLPanelEstateInfo*)user_data; 1543{
1544 LLCtrlListInterface *list = self->childGetListInterface("banned_avatar_name_list"); 1544 std::string name;
1545 if (!list) return; 1545
1546 if (list->getItemCount() >= ESTATE_MAX_ACCESS_IDS) 1546// name.assign("setowner");
1547 { 1547// static LLDispatchSetEstateOwner set_owner;
1548 LLSD args; 1548// dispatch.addHandler(name, &set_owner);
1549 args["MAX_BANNED"] = llformat("%d",ESTATE_MAX_ACCESS_IDS); 1549
1550 LLNotifications::instance().add("MaxBannedAgentsOnRegion", args); 1550 name.assign("estateupdateinfo");
1551 return; 1551 static LLDispatchEstateUpdateInfo estate_update_info;
1552 } 1552 dispatch.addHandler(name, &estate_update_info);
1553 accessAddCore(ESTATE_ACCESS_BANNED_AGENT_ADD, "EstateBannedAgentAdd"); 1553
1554} 1554 name.assign("setaccess");
1555 1555 static LLDispatchSetEstateAccess set_access;
1556// static 1556 dispatch.addHandler(name, &set_access);
1557void LLPanelEstateInfo::onClickRemoveBannedAgent(void* user_data) 1557
1558{ 1558 estate_dispatch_initialized = true;
1559 accessRemoveCore(ESTATE_ACCESS_BANNED_AGENT_REMOVE, "EstateBannedAgentRemove", "banned_avatar_name_list"); 1559}
1560} 1560
1561 1561// static
1562// static 1562// Disables the sun-hour slider and the use fixed time check if the use global time is check
1563void LLPanelEstateInfo::onClickAddEstateManager(void* user_data) 1563void LLPanelEstateInfo::onChangeUseGlobalTime(LLUICtrl* ctrl, void* user_data)
1564{ 1564{
1565 LLPanelEstateInfo* self = (LLPanelEstateInfo*)user_data; 1565 LLPanelEstateInfo* panel = (LLPanelEstateInfo*) user_data;
1566 LLCtrlListInterface *list = self->childGetListInterface("estate_manager_name_list"); 1566 if (panel)
1567 if (!list) return; 1567 {
1568 if (list->getItemCount() >= ESTATE_MAX_MANAGERS) 1568 bool enabled = !panel->childGetValue("use_global_time_check").asBoolean();
1569 { // Tell user they can't add more managers 1569 panel->childSetEnabled("sun_hour_slider", enabled);
1570 LLSD args; 1570 panel->childSetEnabled("fixed_sun_check", enabled);
1571 args["MAX_MANAGER"] = llformat("%d",ESTATE_MAX_MANAGERS); 1571 panel->childSetValue("fixed_sun_check", LLSD(FALSE));
1572 LLNotifications::instance().add("MaxManagersOnRegion", args); 1572 panel->enableButton("apply_btn");
1573 } 1573 }
1574 else 1574}
1575 { // Go pick managers to add 1575
1576 accessAddCore(ESTATE_ACCESS_MANAGER_ADD, "EstateManagerAdd"); 1576// Enables the sun-hour slider if the fixed-sun checkbox is set
1577 } 1577void LLPanelEstateInfo::onChangeFixedSun(LLUICtrl* ctrl, void* user_data)
1578} 1578{
1579 1579 LLPanelEstateInfo* panel = (LLPanelEstateInfo*) user_data;
1580// static 1580 if (panel)
1581void LLPanelEstateInfo::onClickRemoveEstateManager(void* user_data) 1581 {
1582{ 1582 bool enabled = !panel->childGetValue("fixed_sun_check").asBoolean();
1583 accessRemoveCore(ESTATE_ACCESS_MANAGER_REMOVE, "EstateManagerRemove", "estate_manager_name_list"); 1583 panel->childSetEnabled("use_global_time_check", enabled);
1584} 1584 panel->childSetValue("use_global_time_check", LLSD(FALSE));
1585 1585 panel->enableButton("apply_btn");
1586//--------------------------------------------------------------------------- 1586 }
1587// Kick from estate methods 1587}
1588//--------------------------------------------------------------------------- 1588
1589struct LLKickFromEstateInfo 1589
1590{ 1590
1591 LLPanelEstateInfo *mEstatePanelp; 1591
1592 LLUUID mAgentID; 1592//---------------------------------------------------------------------------
1593}; 1593// Add/Remove estate access button callbacks
1594 1594//---------------------------------------------------------------------------
1595void LLPanelEstateInfo::onClickKickUser(void *user_data) 1595void LLPanelEstateInfo::onClickEditSky(void* user_data)
1596{ 1596{
1597 LLPanelEstateInfo* panelp = (LLPanelEstateInfo*)user_data; 1597 LLFloaterWindLight::show();
1598 1598}
1599 // this depends on the grandparent view being a floater 1599
1600 // in order to set up floater dependency 1600void LLPanelEstateInfo::onClickEditDayCycle(void* user_data)
1601 LLFloater* parent_floater = gFloaterView->getParentFloater(panelp); 1601{
1602 LLFloater* child_floater = LLFloaterAvatarPicker::show(LLPanelEstateInfo::onKickUserCommit, user_data, FALSE, TRUE); 1602 LLFloaterDayCycle::show();
1603 parent_floater->addDependentFloater(child_floater); 1603}
1604} 1604
1605 1605// static
1606void LLPanelEstateInfo::onKickUserCommit(const std::vector<std::string>& names, const std::vector<LLUUID>& ids, void* userdata) 1606void LLPanelEstateInfo::onClickAddAllowedAgent(void* user_data)
1607{ 1607{
1608 if (names.empty() || ids.empty()) return; 1608 LLPanelEstateInfo* self = (LLPanelEstateInfo*)user_data;
1609 1609 LLCtrlListInterface *list = self->childGetListInterface("allowed_avatar_name_list");
1610 //check to make sure there is one valid user and id 1610 if (!list) return;
1611 if( (ids[0].isNull()) || 1611 if (list->getItemCount() >= ESTATE_MAX_ACCESS_IDS)
1612 (names[0].length() == 0) ) 1612 {
1613 { 1613 //args
1614 return; 1614
1615 } 1615 LLSD args;
1616 1616 args["MAX_AGENTS"] = llformat("%d",ESTATE_MAX_ACCESS_IDS);
1617 LLPanelEstateInfo* self = (LLPanelEstateInfo*)userdata; 1617 LLNotifications::instance().add("MaxAllowedAgentOnRegion", args);
1618 if(!self) return; 1618 return;
1619 1619 }
1620 //keep track of what user they want to kick and other misc info 1620 accessAddCore(ESTATE_ACCESS_ALLOWED_AGENT_ADD, "EstateAllowedAgentAdd");
1621 LLKickFromEstateInfo *kick_info = new LLKickFromEstateInfo(); 1621}
1622 kick_info->mEstatePanelp = self; 1622
1623 kick_info->mAgentID = ids[0]; 1623// static
1624 1624void LLPanelEstateInfo::onClickRemoveAllowedAgent(void* user_data)
1625 //Bring up a confirmation dialog 1625{
1626 LLSD args; 1626 accessRemoveCore(ESTATE_ACCESS_ALLOWED_AGENT_REMOVE, "EstateAllowedAgentRemove", "allowed_avatar_name_list");
1627 args["EVIL_USER"] = names[0]; 1627}
1628 LLSD payload; 1628
1629 payload["agent_id"] = ids[0]; 1629// static
1630 LLNotifications::instance().add("EstateKickUser", args, payload, boost::bind(&LLPanelEstateInfo::kickUserConfirm, self, _1, _2)); 1630void LLPanelEstateInfo::onClickAddAllowedGroup(void* user_data)
1631 1631{
1632} 1632 LLPanelEstateInfo* self = (LLPanelEstateInfo*)user_data;
1633 1633 LLCtrlListInterface *list = self->childGetListInterface("allowed_group_name_list");
1634bool LLPanelEstateInfo::kickUserConfirm(const LLSD& notification, const LLSD& response) 1634 if (!list) return;
1635{ 1635 if (list->getItemCount() >= ESTATE_MAX_ACCESS_IDS)
1636 S32 option = LLNotification::getSelectedOption(notification, response); 1636 {
1637 switch(option) 1637 LLSD args;
1638 { 1638 args["MAX_GROUPS"] = llformat("%d",ESTATE_MAX_ACCESS_IDS);
1639 case 0: 1639 LLNotifications::instance().add("MaxAllowedGroupsOnRegion", args);
1640 { 1640 return;
1641 //Kick User 1641 }
1642 strings_t strings; 1642
1643 strings.push_back(notification["payload"]["agent_id"].asString()); 1643 LLNotification::Params params("ChangeLindenAccess");
1644 1644 params.functor(boost::bind(&LLPanelEstateInfo::addAllowedGroup, self, _1, _2));
1645 sendEstateOwnerMessage(gMessageSystem, "kickestate", LLFloaterRegionInfo::getLastInvoice(), strings); 1645 if (isLindenEstate())
1646 break; 1646 {
1647 } 1647 LLNotifications::instance().add(params);
1648 default: 1648 }
1649 break; 1649 else
1650 } 1650 {
1651 return false; 1651 LLNotifications::instance().forceResponse(params, 0);
1652} 1652 }
1653 1653}
1654//--------------------------------------------------------------------------- 1654
1655// Core Add/Remove estate access methods 1655bool LLPanelEstateInfo::addAllowedGroup(const LLSD& notification, const LLSD& response)
1656// TODO: INTERNATIONAL: don't build message text here; 1656{
1657// instead, create multiple translatable messages and choose 1657 S32 option = LLNotification::getSelectedOption(notification, response);
1658// one based on the status. 1658 if (option != 0) return false;
1659//--------------------------------------------------------------------------- 1659
1660std::string all_estates_text() 1660 LLFloater* parent_floater = gFloaterView->getParentFloater(this);
1661{ 1661
1662 LLPanelEstateInfo* panel = LLFloaterRegionInfo::getPanelEstate(); 1662 LLFloaterGroupPicker* widget;
1663 if (!panel) return "(error)"; 1663 widget = LLFloaterGroupPicker::showInstance(LLSD(gAgent.getID()));
1664 1664 if (widget)
1665 std::string owner = panel->getOwnerName(); 1665 {
1666 1666 widget->setSelectCallback(addAllowedGroup2, NULL);
1667 LLViewerRegion* region = gAgent.getRegion(); 1667 if (parent_floater)
1668 if (gAgent.isGodlike()) 1668 {
1669 { 1669 LLRect new_rect = gFloaterView->findNeighboringPosition(parent_floater, widget);
1670 return llformat("all estates\nowned by %s", owner.c_str()); 1670 widget->setOrigin(new_rect.mLeft, new_rect.mBottom);
1671 } 1671 parent_floater->addDependentFloater(widget);
1672 else if (region && region->getOwner() == gAgent.getID()) 1672 }
1673 { 1673 }
1674 return "all estates you own"; 1674
1675 } 1675 return false;
1676 else if (region && region->isEstateManager()) 1676}
1677 { 1677
1678 return llformat("all estates that\nyou manage for %s", owner.c_str()); 1678// static
1679 } 1679void LLPanelEstateInfo::onClickRemoveAllowedGroup(void* user_data)
1680 else 1680{
1681 { 1681 accessRemoveCore(ESTATE_ACCESS_ALLOWED_GROUP_REMOVE, "EstateAllowedGroupRemove", "allowed_group_name_list");
1682 return "(error)"; 1682}
1683 } 1683
1684} 1684// static
1685 1685void LLPanelEstateInfo::onClickAddBannedAgent(void* user_data)
1686// static 1686{
1687bool LLPanelEstateInfo::isLindenEstate() 1687 LLPanelEstateInfo* self = (LLPanelEstateInfo*)user_data;
1688{ 1688 LLCtrlListInterface *list = self->childGetListInterface("banned_avatar_name_list");
1689 LLPanelEstateInfo* panel = LLFloaterRegionInfo::getPanelEstate(); 1689 if (!list) return;
1690 if (!panel) return false; 1690 if (list->getItemCount() >= ESTATE_MAX_ACCESS_IDS)
1691 1691 {
1692 U32 estate_id = panel->getEstateID(); 1692 LLSD args;
1693 return (estate_id <= ESTATE_LAST_LINDEN); 1693 args["MAX_BANNED"] = llformat("%d",ESTATE_MAX_ACCESS_IDS);
1694} 1694 LLNotifications::instance().add("MaxBannedAgentsOnRegion", args);
1695 1695 return;
1696typedef std::vector<LLUUID> AgentOrGroupIDsVector; 1696 }
1697struct LLEstateAccessChangeInfo 1697 accessAddCore(ESTATE_ACCESS_BANNED_AGENT_ADD, "EstateBannedAgentAdd");
1698{ 1698}
1699 LLEstateAccessChangeInfo(const LLSD& sd) 1699
1700 { 1700// static
1701 mDialogName = sd["dialog_name"].asString(); 1701void LLPanelEstateInfo::onClickRemoveBannedAgent(void* user_data)
1702 mOperationFlag = (U32)sd["operation"].asInteger(); 1702{
1703 LLSD::array_const_iterator end_it = sd["allowed_ids"].endArray(); 1703 accessRemoveCore(ESTATE_ACCESS_BANNED_AGENT_REMOVE, "EstateBannedAgentRemove", "banned_avatar_name_list");
1704 for (LLSD::array_const_iterator id_it = sd["allowed_ids"].beginArray(); 1704}
1705 id_it != end_it; 1705
1706 ++id_it) 1706// static
1707 { 1707void LLPanelEstateInfo::onClickAddEstateManager(void* user_data)
1708 mAgentOrGroupIDs.push_back(id_it->asUUID()); 1708{
1709 } 1709 LLPanelEstateInfo* self = (LLPanelEstateInfo*)user_data;
1710 } 1710 LLCtrlListInterface *list = self->childGetListInterface("estate_manager_name_list");
1711 1711 if (!list) return;
1712 const LLSD asLLSD() const 1712 if (list->getItemCount() >= ESTATE_MAX_MANAGERS)
1713 { 1713 { // Tell user they can't add more managers
1714 LLSD sd; 1714 LLSD args;
1715 sd["name"] = mDialogName; 1715 args["MAX_MANAGER"] = llformat("%d",ESTATE_MAX_MANAGERS);
1716 sd["operation"] = (S32)mOperationFlag; 1716 LLNotifications::instance().add("MaxManagersOnRegion", args);
1717 for (AgentOrGroupIDsVector::const_iterator it = mAgentOrGroupIDs.begin(); 1717 }
1718 it != mAgentOrGroupIDs.end(); 1718 else
1719 ++it) 1719 { // Go pick managers to add
1720 { 1720 accessAddCore(ESTATE_ACCESS_MANAGER_ADD, "EstateManagerAdd");
1721 sd["allowed_ids"].append(*it); 1721 }
1722 } 1722}
1723 return sd; 1723
1724 } 1724// static
1725 1725void LLPanelEstateInfo::onClickRemoveEstateManager(void* user_data)
1726 U32 mOperationFlag; // ESTATE_ACCESS_BANNED_AGENT_ADD, _REMOVE, etc. 1726{
1727 std::string mDialogName; 1727 accessRemoveCore(ESTATE_ACCESS_MANAGER_REMOVE, "EstateManagerRemove", "estate_manager_name_list");
1728 AgentOrGroupIDsVector mAgentOrGroupIDs; // List of agent IDs to apply to this change 1728}
1729}; 1729
1730 1730//---------------------------------------------------------------------------
1731// Special case callback for groups, since it has different callback format than names 1731// Kick from estate methods
1732// static 1732//---------------------------------------------------------------------------
1733void LLPanelEstateInfo::addAllowedGroup2(LLUUID id, void* user_data) 1733struct LLKickFromEstateInfo
1734{ 1734{
1735 LLSD payload; 1735 LLPanelEstateInfo *mEstatePanelp;
1736 payload["operation"] = (S32)ESTATE_ACCESS_ALLOWED_GROUP_ADD; 1736 LLUUID mAgentID;
1737 payload["dialog_name"] = "EstateAllowedGroupAdd"; 1737};
1738 payload["allowed_ids"].append(id); 1738
1739 1739void LLPanelEstateInfo::onClickKickUser(void *user_data)
1740 LLSD args; 1740{
1741 args["ALL_ESTATES"] = all_estates_text(); 1741 LLPanelEstateInfo* panelp = (LLPanelEstateInfo*)user_data;
1742 1742
1743 LLNotification::Params params("EstateAllowedGroupAdd"); 1743 // this depends on the grandparent view being a floater
1744 params.payload(payload) 1744 // in order to set up floater dependency
1745 .substitutions(args) 1745 LLFloater* parent_floater = gFloaterView->getParentFloater(panelp);
1746 .functor(accessCoreConfirm); 1746 LLFloater* child_floater = LLFloaterAvatarPicker::show(LLPanelEstateInfo::onKickUserCommit, user_data, FALSE, TRUE);
1747 if (isLindenEstate()) 1747 parent_floater->addDependentFloater(child_floater);
1748 { 1748}
1749 LLNotifications::instance().forceResponse(params, 0); 1749
1750 } 1750void LLPanelEstateInfo::onKickUserCommit(const std::vector<std::string>& names, const std::vector<LLUUID>& ids, void* userdata)
1751 else 1751{
1752 { 1752 if (names.empty() || ids.empty()) return;
1753 LLNotifications::instance().add(params); 1753
1754 } 1754 //check to make sure there is one valid user and id
1755} 1755 if( (ids[0].isNull()) ||
1756 1756 (names[0].length() == 0) )
1757// static 1757 {
1758void LLPanelEstateInfo::accessAddCore(U32 operation_flag, const std::string& dialog_name) 1758 return;
1759{ 1759 }
1760 LLSD payload; 1760
1761 payload["operation"] = (S32)operation_flag; 1761 LLPanelEstateInfo* self = (LLPanelEstateInfo*)userdata;
1762 payload["dialog_name"] = dialog_name; 1762 if(!self) return;
1763 // agent id filled in after avatar picker 1763
1764 1764 //keep track of what user they want to kick and other misc info
1765 LLNotification::Params params("ChangeLindenAccess"); 1765 LLKickFromEstateInfo *kick_info = new LLKickFromEstateInfo();
1766 params.payload(payload) 1766 kick_info->mEstatePanelp = self;
1767 .functor(accessAddCore2); 1767 kick_info->mAgentID = ids[0];
1768 1768
1769 if (isLindenEstate()) 1769 //Bring up a confirmation dialog
1770 { 1770 LLSD args;
1771 LLNotifications::instance().add(params); 1771 args["EVIL_USER"] = names[0];
1772 } 1772 LLSD payload;
1773 else 1773 payload["agent_id"] = ids[0];
1774 { 1774 LLNotifications::instance().add("EstateKickUser", args, payload, boost::bind(&LLPanelEstateInfo::kickUserConfirm, self, _1, _2));
1775 // same as clicking "OK" 1775
1776 LLNotifications::instance().forceResponse(params, 0); 1776}
1777 } 1777
1778} 1778bool LLPanelEstateInfo::kickUserConfirm(const LLSD& notification, const LLSD& response)
1779 1779{
1780// static 1780 S32 option = LLNotification::getSelectedOption(notification, response);
1781bool LLPanelEstateInfo::accessAddCore2(const LLSD& notification, const LLSD& response) 1781 switch(option)
1782{ 1782 {
1783 S32 option = LLNotification::getSelectedOption(notification, response); 1783 case 0:
1784 if (option != 0) 1784 {
1785 { 1785 //Kick User
1786 // abort change 1786 strings_t strings;
1787 return false; 1787 strings.push_back(notification["payload"]["agent_id"].asString());
1788 } 1788
1789 1789 sendEstateOwnerMessage(gMessageSystem, "kickestate", LLFloaterRegionInfo::getLastInvoice(), strings);
1790 LLEstateAccessChangeInfo* change_info = new LLEstateAccessChangeInfo(notification["payload"]); 1790 break;
1791 // avatar picker yes multi-select, yes close-on-select 1791 }
1792 LLFloaterAvatarPicker::show(accessAddCore3, (void*)change_info, TRUE, TRUE); 1792 default:
1793 return false; 1793 break;
1794} 1794 }
1795 1795 return false;
1796// static 1796}
1797void LLPanelEstateInfo::accessAddCore3(const std::vector<std::string>& names, const std::vector<LLUUID>& ids, void* data) 1797
1798{ 1798//---------------------------------------------------------------------------
1799 LLEstateAccessChangeInfo* change_info = (LLEstateAccessChangeInfo*)data; 1799// Core Add/Remove estate access methods
1800 if (!change_info) return; 1800// TODO: INTERNATIONAL: don't build message text here;
1801 if (ids.empty()) 1801// instead, create multiple translatable messages and choose
1802 { 1802// one based on the status.
1803 // User didn't select a name. 1803//---------------------------------------------------------------------------
1804 delete change_info; 1804std::string all_estates_text()
1805 change_info = NULL; 1805{
1806 return; 1806 LLPanelEstateInfo* panel = LLFloaterRegionInfo::getPanelEstate();
1807 } 1807 if (!panel) return "(error)";
1808 // User did select a name. 1808
1809 change_info->mAgentOrGroupIDs = ids; 1809 std::string owner = panel->getOwnerName();
1810 // Can't put estate owner on ban list 1810
1811 LLPanelEstateInfo* panel = LLFloaterRegionInfo::getPanelEstate(); 1811 LLViewerRegion* region = gAgent.getRegion();
1812 if (!panel) return; 1812 if (gAgent.isGodlike())
1813 LLViewerRegion* region = gAgent.getRegion(); 1813 {
1814 if (!region) return; 1814 return llformat("all estates\nowned by %s", owner.c_str());
1815 1815 }
1816 if (change_info->mOperationFlag & ESTATE_ACCESS_ALLOWED_AGENT_ADD) 1816 else if (region && region->getOwner() == gAgent.getID())
1817 { 1817 {
1818 LLCtrlListInterface *list = panel->childGetListInterface("allowed_avatar_name_list"); 1818 return "all estates you own";
1819 int currentCount = (list ? list->getItemCount() : 0); 1819 }
1820 if (ids.size() + currentCount > ESTATE_MAX_ACCESS_IDS) 1820 else if (region && region->isEstateManager())
1821 { 1821 {
1822 LLSD args; 1822 return llformat("all estates that\nyou manage for %s", owner.c_str());
1823 args["NUM_ADDED"] = llformat("%d",ids.size()); 1823 }
1824 args["MAX_AGENTS"] = llformat("%d",ESTATE_MAX_ACCESS_IDS); 1824 else
1825 args["LIST_TYPE"] = "Allowed Residents"; 1825 {
1826 args["NUM_EXCESS"] = llformat("%d",(ids.size()+currentCount)-ESTATE_MAX_ACCESS_IDS); 1826 return "(error)";
1827 LLNotifications::instance().add("MaxAgentOnRegionBatch", args); 1827 }
1828 delete change_info; 1828}
1829 return; 1829
1830 } 1830// static
1831 } 1831bool LLPanelEstateInfo::isLindenEstate()
1832 if (change_info->mOperationFlag & ESTATE_ACCESS_BANNED_AGENT_ADD) 1832{
1833 { 1833 LLPanelEstateInfo* panel = LLFloaterRegionInfo::getPanelEstate();
1834 LLCtrlListInterface *list = panel->childGetListInterface("banned_avatar_name_list"); 1834 if (!panel) return false;
1835 int currentCount = (list ? list->getItemCount() : 0); 1835
1836 if (ids.size() + currentCount > ESTATE_MAX_ACCESS_IDS) 1836 U32 estate_id = panel->getEstateID();
1837 { 1837 return (estate_id <= ESTATE_LAST_LINDEN);
1838 LLSD args; 1838}
1839 args["NUM_ADDED"] = llformat("%d",ids.size()); 1839
1840 args["MAX_AGENTS"] = llformat("%d",ESTATE_MAX_ACCESS_IDS); 1840typedef std::vector<LLUUID> AgentOrGroupIDsVector;
1841 args["LIST_TYPE"] = "Banned Residents"; 1841struct LLEstateAccessChangeInfo
1842 args["NUM_EXCESS"] = llformat("%d",(ids.size()+currentCount)-ESTATE_MAX_ACCESS_IDS); 1842{
1843 LLNotifications::instance().add("MaxAgentOnRegionBatch", args); 1843 LLEstateAccessChangeInfo(const LLSD& sd)
1844 delete change_info; 1844 {
1845 return; 1845 mDialogName = sd["dialog_name"].asString();
1846 } 1846 mOperationFlag = (U32)sd["operation"].asInteger();
1847 } 1847 LLSD::array_const_iterator end_it = sd["allowed_ids"].endArray();
1848 1848 for (LLSD::array_const_iterator id_it = sd["allowed_ids"].beginArray();
1849 LLSD args; 1849 id_it != end_it;
1850 args["ALL_ESTATES"] = all_estates_text(); 1850 ++id_it)
1851 1851 {
1852 LLNotification::Params params(change_info->mDialogName); 1852 mAgentOrGroupIDs.push_back(id_it->asUUID());
1853 params.substitutions(args) 1853 }
1854 .payload(change_info->asLLSD()) 1854 }
1855 .functor(accessCoreConfirm); 1855
1856 1856 const LLSD asLLSD() const
1857 if (isLindenEstate()) 1857 {
1858 { 1858 LLSD sd;
1859 // just apply to this estate 1859 sd["name"] = mDialogName;
1860 LLNotifications::instance().forceResponse(params, 0); 1860 sd["operation"] = (S32)mOperationFlag;
1861 } 1861 for (AgentOrGroupIDsVector::const_iterator it = mAgentOrGroupIDs.begin();
1862 else 1862 it != mAgentOrGroupIDs.end();
1863 { 1863 ++it)
1864 // ask if this estate or all estates with this owner 1864 {
1865 LLNotifications::instance().add(params); 1865 sd["allowed_ids"].append(*it);
1866 } 1866 }
1867} 1867 return sd;
1868 1868 }
1869// static 1869
1870void LLPanelEstateInfo::accessRemoveCore(U32 operation_flag, const std::string& dialog_name, const std::string& list_ctrl_name) 1870 U32 mOperationFlag; // ESTATE_ACCESS_BANNED_AGENT_ADD, _REMOVE, etc.
1871{ 1871 std::string mDialogName;
1872 LLPanelEstateInfo* panel = LLFloaterRegionInfo::getPanelEstate(); 1872 AgentOrGroupIDsVector mAgentOrGroupIDs; // List of agent IDs to apply to this change
1873 if (!panel) return; 1873};
1874 LLNameListCtrl* name_list = panel->getChild<LLNameListCtrl>(list_ctrl_name); 1874
1875 if (!name_list) return; 1875// Special case callback for groups, since it has different callback format than names
1876 1876// static
1877 std::vector<LLScrollListItem*> list_vector = name_list->getAllSelected(); 1877void LLPanelEstateInfo::addAllowedGroup2(LLUUID id, void* user_data)
1878 if (list_vector.size() == 0) 1878{
1879 return; 1879 LLSD payload;
1880 1880 payload["operation"] = (S32)ESTATE_ACCESS_ALLOWED_GROUP_ADD;
1881 LLSD payload; 1881 payload["dialog_name"] = "EstateAllowedGroupAdd";
1882 payload["operation"] = (S32)operation_flag; 1882 payload["allowed_ids"].append(id);
1883 payload["dialog_name"] = dialog_name; 1883
1884 1884 LLSD args;
1885 for (std::vector<LLScrollListItem*>::const_iterator iter = list_vector.begin(); 1885 args["ALL_ESTATES"] = all_estates_text();
1886 iter != list_vector.end(); 1886
1887 iter++) 1887 LLNotification::Params params("EstateAllowedGroupAdd");
1888 { 1888 params.payload(payload)
1889 LLScrollListItem *item = (*iter); 1889 .substitutions(args)
1890 payload["allowed_ids"].append(item->getUUID()); 1890 .functor(accessCoreConfirm);
1891 } 1891 if (isLindenEstate())
1892 1892 {
1893 LLNotification::Params params("ChangeLindenAccess"); 1893 LLNotifications::instance().forceResponse(params, 0);
1894 params.payload(payload) 1894 }
1895 .functor(accessRemoveCore2); 1895 else
1896 1896 {
1897 if (isLindenEstate()) 1897 LLNotifications::instance().add(params);
1898 { 1898 }
1899 // warn on change linden estate 1899}
1900 LLNotifications::instance().add(params); 1900
1901 } 1901// static
1902 else 1902void LLPanelEstateInfo::accessAddCore(U32 operation_flag, const std::string& dialog_name)
1903 { 1903{
1904 // just proceed, as if clicking OK 1904 LLSD payload;
1905 LLNotifications::instance().forceResponse(params, 0); 1905 payload["operation"] = (S32)operation_flag;
1906 } 1906 payload["dialog_name"] = dialog_name;
1907} 1907 // agent id filled in after avatar picker
1908 1908
1909// static 1909 LLNotification::Params params("ChangeLindenAccess");
1910bool LLPanelEstateInfo::accessRemoveCore2(const LLSD& notification, const LLSD& response) 1910 params.payload(payload)
1911{ 1911 .functor(accessAddCore2);
1912 S32 option = LLNotification::getSelectedOption(notification, response); 1912
1913 if (option != 0) 1913 if (isLindenEstate())
1914 { 1914 {
1915 // abort 1915 LLNotifications::instance().add(params);
1916 return false; 1916 }
1917 } 1917 else
1918 1918 {
1919 // If Linden estate, can only apply to "this" estate, not all estates 1919 // same as clicking "OK"
1920 // owned by NULL. 1920 LLNotifications::instance().forceResponse(params, 0);
1921 if (isLindenEstate()) 1921 }
1922 { 1922}
1923 accessCoreConfirm(notification, response); 1923
1924 } 1924// static
1925 else 1925bool LLPanelEstateInfo::accessAddCore2(const LLSD& notification, const LLSD& response)
1926 { 1926{
1927 LLSD args; 1927 S32 option = LLNotification::getSelectedOption(notification, response);
1928 args["ALL_ESTATES"] = all_estates_text(); 1928 if (option != 0)
1929 LLNotifications::instance().add(notification["payload"]["dialog_name"], 1929 {
1930 args, 1930 // abort change
1931 notification["payload"], 1931 return false;
1932 accessCoreConfirm); 1932 }
1933 } 1933
1934 return false; 1934 LLEstateAccessChangeInfo* change_info = new LLEstateAccessChangeInfo(notification["payload"]);
1935} 1935 // avatar picker yes multi-select, yes close-on-select
1936 1936 LLFloaterAvatarPicker::show(accessAddCore3, (void*)change_info, TRUE, TRUE);
1937// Used for both access add and remove operations, depending on the mOperationFlag 1937 return false;
1938// passed in (ESTATE_ACCESS_BANNED_AGENT_ADD, ESTATE_ACCESS_ALLOWED_AGENT_REMOVE, etc.) 1938}
1939// static 1939
1940bool LLPanelEstateInfo::accessCoreConfirm(const LLSD& notification, const LLSD& response) 1940// static
1941{ 1941void LLPanelEstateInfo::accessAddCore3(const std::vector<std::string>& names, const std::vector<LLUUID>& ids, void* data)
1942 S32 option = LLNotification::getSelectedOption(notification, response); 1942{
1943 const U32 originalFlags = (U32)notification["payload"]["operation"].asInteger(); 1943 LLEstateAccessChangeInfo* change_info = (LLEstateAccessChangeInfo*)data;
1944 1944 if (!change_info) return;
1945 LLViewerRegion* region = gAgent.getRegion(); 1945 if (ids.empty())
1946 1946 {
1947 LLSD::array_const_iterator end_it = notification["payload"]["allowed_ids"].endArray(); 1947 // User didn't select a name.
1948 1948 delete change_info;
1949 for (LLSD::array_const_iterator iter = notification["payload"]["allowed_ids"].beginArray(); 1949 change_info = NULL;
1950 iter != end_it; 1950 return;
1951 iter++) 1951 }
1952 { 1952 // User did select a name.
1953 U32 flags = originalFlags; 1953 change_info->mAgentOrGroupIDs = ids;
1954 if (iter + 1 != end_it) 1954 // Can't put estate owner on ban list
1955 flags |= ESTATE_ACCESS_NO_REPLY; 1955 LLPanelEstateInfo* panel = LLFloaterRegionInfo::getPanelEstate();
1956 1956 if (!panel) return;
1957 const LLUUID id = iter->asUUID(); 1957 LLViewerRegion* region = gAgent.getRegion();
1958 if (((U32)notification["payload"]["operation"].asInteger() & ESTATE_ACCESS_BANNED_AGENT_ADD) 1958 if (!region) return;
1959 && region && (region->getOwner() == id)) 1959
1960 { 1960 if (change_info->mOperationFlag & ESTATE_ACCESS_ALLOWED_AGENT_ADD)
1961 LLNotifications::instance().add("OwnerCanNotBeDenied"); 1961 {
1962 break; 1962 LLCtrlListInterface *list = panel->childGetListInterface("allowed_avatar_name_list");
1963 } 1963 int currentCount = (list ? list->getItemCount() : 0);
1964 switch(option) 1964 if (ids.size() + currentCount > ESTATE_MAX_ACCESS_IDS)
1965 { 1965 {
1966 case 0: 1966 LLSD args;
1967 // This estate 1967 args["NUM_ADDED"] = llformat("%d",ids.size());
1968 sendEstateAccessDelta(flags, id); 1968 args["MAX_AGENTS"] = llformat("%d",ESTATE_MAX_ACCESS_IDS);
1969 break; 1969 args["LIST_TYPE"] = "Allowed Residents";
1970 case 1: 1970 args["NUM_EXCESS"] = llformat("%d",(ids.size()+currentCount)-ESTATE_MAX_ACCESS_IDS);
1971 { 1971 LLNotifications::instance().add("MaxAgentOnRegionBatch", args);
1972 // All estates, either than I own or manage for this owner. 1972 delete change_info;
1973 // This will be verified on simulator. JC 1973 return;
1974 if (!region) break; 1974 }
1975 if (region->getOwner() == gAgent.getID() 1975 }
1976 || gAgent.isGodlike()) 1976 if (change_info->mOperationFlag & ESTATE_ACCESS_BANNED_AGENT_ADD)
1977 { 1977 {
1978 flags |= ESTATE_ACCESS_APPLY_TO_ALL_ESTATES; 1978 LLCtrlListInterface *list = panel->childGetListInterface("banned_avatar_name_list");
1979 sendEstateAccessDelta(flags, id); 1979 int currentCount = (list ? list->getItemCount() : 0);
1980 } 1980 if (ids.size() + currentCount > ESTATE_MAX_ACCESS_IDS)
1981 else if (region->isEstateManager()) 1981 {
1982 { 1982 LLSD args;
1983 flags |= ESTATE_ACCESS_APPLY_TO_MANAGED_ESTATES; 1983 args["NUM_ADDED"] = llformat("%d",ids.size());
1984 sendEstateAccessDelta(flags, id); 1984 args["MAX_AGENTS"] = llformat("%d",ESTATE_MAX_ACCESS_IDS);
1985 } 1985 args["LIST_TYPE"] = "Banned Residents";
1986 break; 1986 args["NUM_EXCESS"] = llformat("%d",(ids.size()+currentCount)-ESTATE_MAX_ACCESS_IDS);
1987 } 1987 LLNotifications::instance().add("MaxAgentOnRegionBatch", args);
1988 case 2: 1988 delete change_info;
1989 default: 1989 return;
1990 break; 1990 }
1991 } 1991 }
1992 } 1992
1993 return false; 1993 LLSD args;
1994} 1994 args["ALL_ESTATES"] = all_estates_text();
1995 1995
1996// key = "estateaccessdelta" 1996 LLNotification::Params params(change_info->mDialogName);
1997// str(estate_id) will be added to front of list by forward_EstateOwnerRequest_to_dataserver 1997 params.substitutions(args)
1998// str[0] = str(agent_id) requesting the change 1998 .payload(change_info->asLLSD())
1999// str[1] = str(flags) (ESTATE_ACCESS_DELTA_*) 1999 .functor(accessCoreConfirm);
2000// str[2] = str(agent_id) to add or remove 2000
2001// static 2001 if (isLindenEstate())
2002void LLPanelEstateInfo::sendEstateAccessDelta(U32 flags, const LLUUID& agent_or_group_id) 2002 {
2003{ 2003 // just apply to this estate
2004 LLMessageSystem* msg = gMessageSystem; 2004 LLNotifications::instance().forceResponse(params, 0);
2005 msg->newMessage("EstateOwnerMessage"); 2005 }
2006 msg->nextBlockFast(_PREHASH_AgentData); 2006 else
2007 msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); 2007 {
2008 msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); 2008 // ask if this estate or all estates with this owner
2009 msg->addUUIDFast(_PREHASH_TransactionID, LLUUID::null); //not used 2009 LLNotifications::instance().add(params);
2010 2010 }
2011 msg->nextBlock("MethodData"); 2011}
2012 msg->addString("Method", "estateaccessdelta"); 2012
2013 msg->addUUID("Invoice", LLFloaterRegionInfo::getLastInvoice()); 2013// static
2014 2014void LLPanelEstateInfo::accessRemoveCore(U32 operation_flag, const std::string& dialog_name, const std::string& list_ctrl_name)
2015 std::string buf; 2015{
2016 gAgent.getID().toString(buf); 2016 LLPanelEstateInfo* panel = LLFloaterRegionInfo::getPanelEstate();
2017 msg->nextBlock("ParamList"); 2017 if (!panel) return;
2018 msg->addString("Parameter", buf); 2018 LLNameListCtrl* name_list = panel->getChild<LLNameListCtrl>(list_ctrl_name);
2019 2019 if (!name_list) return;
2020 buf = llformat("%u", flags); 2020
2021 msg->nextBlock("ParamList"); 2021 std::vector<LLScrollListItem*> list_vector = name_list->getAllSelected();
2022 msg->addString("Parameter", buf); 2022 if (list_vector.size() == 0)
2023 2023 return;
2024 agent_or_group_id.toString(buf); 2024
2025 msg->nextBlock("ParamList"); 2025 LLSD payload;
2026 msg->addString("Parameter", buf); 2026 payload["operation"] = (S32)operation_flag;
2027 2027 payload["dialog_name"] = dialog_name;
2028 2028
2029 LLPanelEstateInfo* panel = LLFloaterRegionInfo::getPanelEstate(); 2029 for (std::vector<LLScrollListItem*>::const_iterator iter = list_vector.begin();
2030 2030 iter != list_vector.end();
2031 if (flags & (ESTATE_ACCESS_ALLOWED_AGENT_ADD | ESTATE_ACCESS_ALLOWED_AGENT_REMOVE | 2031 iter++)
2032 ESTATE_ACCESS_BANNED_AGENT_ADD | ESTATE_ACCESS_BANNED_AGENT_REMOVE)) 2032 {
2033 { 2033 LLScrollListItem *item = (*iter);
2034 2034 payload["allowed_ids"].append(item->getUUID());
2035 panel->clearAccessLists(); 2035 }
2036 } 2036
2037 2037 LLNotification::Params params("ChangeLindenAccess");
2038 gAgent.sendReliableMessage(); 2038 params.payload(payload)
2039} 2039 .functor(accessRemoveCore2);
2040 2040
2041void LLPanelEstateInfo::updateControls(LLViewerRegion* region) 2041 if (isLindenEstate())
2042{ 2042 {
2043 BOOL god = gAgent.isGodlike(); 2043 // warn on change linden estate
2044 BOOL owner = (region && (region->getOwner() == gAgent.getID())); 2044 LLNotifications::instance().add(params);
2045 BOOL manager = (region && region->isEstateManager()); 2045 }
2046 setCtrlsEnabled(god || owner || manager); 2046 else
2047 2047 {
2048 childDisable("apply_btn"); 2048 // just proceed, as if clicking OK
2049 childSetEnabled("add_allowed_avatar_btn", god || owner || manager); 2049 LLNotifications::instance().forceResponse(params, 0);
2050 childSetEnabled("remove_allowed_avatar_btn", god || owner || manager); 2050 }
2051 childSetEnabled("add_allowed_group_btn", god || owner || manager); 2051}
2052 childSetEnabled("remove_allowed_group_btn", god || owner || manager); 2052
2053 childSetEnabled("add_banned_avatar_btn", god || owner || manager); 2053// static
2054 childSetEnabled("remove_banned_avatar_btn", god || owner || manager); 2054bool LLPanelEstateInfo::accessRemoveCore2(const LLSD& notification, const LLSD& response)
2055 childSetEnabled("message_estate_btn", god || owner || manager); 2055{
2056 childSetEnabled("kick_user_from_estate_btn", god || owner || manager); 2056 S32 option = LLNotification::getSelectedOption(notification, response);
2057#if ELAR_ENABLED 2057 if (option != 0)
2058 childSetEnabled("abuse_email_address", god || owner || manager); 2058 {
2059#else 2059 // abort
2060 childSetEnabled("abuse_email_address", false); 2060 return false;
2061#endif 2061 }
2062 2062
2063 // estate managers can't add estate managers 2063 // If Linden estate, can only apply to "this" estate, not all estates
2064 childSetEnabled("add_estate_manager_btn", god || owner); 2064 // owned by NULL.
2065 childSetEnabled("remove_estate_manager_btn", god || owner); 2065 if (isLindenEstate())
2066 childSetEnabled("estate_manager_name_list", god || owner); 2066 {
2067} 2067 accessCoreConfirm(notification, response);
2068 2068 }
2069bool LLPanelEstateInfo::refreshFromRegion(LLViewerRegion* region) 2069 else
2070{ 2070 {
2071 updateControls(region); 2071 LLSD args;
2072 2072 args["ALL_ESTATES"] = all_estates_text();
2073 // let the parent class handle the general data collection. 2073 LLNotifications::instance().add(notification["payload"]["dialog_name"],
2074 bool rv = LLPanelRegionInfo::refreshFromRegion(region); 2074 args,
2075 2075 notification["payload"],
2076 // We want estate info. To make sure it works across region 2076 accessCoreConfirm);
2077 // boundaries and multiple packets, we add a serial number to the 2077 }
2078 // integers and track against that on update. 2078 return false;
2079 strings_t strings; 2079}
2080 //integers_t integers; 2080
2081 //LLFloaterRegionInfo::incrementSerial(); 2081// Used for both access add and remove operations, depending on the mOperationFlag
2082 LLFloaterRegionInfo::nextInvoice(); 2082// passed in (ESTATE_ACCESS_BANNED_AGENT_ADD, ESTATE_ACCESS_ALLOWED_AGENT_REMOVE, etc.)
2083 LLUUID invoice(LLFloaterRegionInfo::getLastInvoice()); 2083// static
2084 //integers.push_back(LLFloaterRegionInfo::());::getPanelEstate(); 2084bool LLPanelEstateInfo::accessCoreConfirm(const LLSD& notification, const LLSD& response)
2085 2085{
2086 2086 S32 option = LLNotification::getSelectedOption(notification, response);
2087 LLPanelEstateInfo* panel = LLFloaterRegionInfo::getPanelEstate(); 2087 const U32 originalFlags = (U32)notification["payload"]["operation"].asInteger();
2088 panel->clearAccessLists(); 2088
2089 2089 LLViewerRegion* region = gAgent.getRegion();
2090 2090
2091 sendEstateOwnerMessage(gMessageSystem, "getinfo", invoice, strings); 2091 LLSD::array_const_iterator end_it = notification["payload"]["allowed_ids"].endArray();
2092 2092
2093 refresh(); 2093 for (LLSD::array_const_iterator iter = notification["payload"]["allowed_ids"].beginArray();
2094 2094 iter != end_it;
2095 return rv; 2095 iter++)
2096} 2096 {
2097 2097 U32 flags = originalFlags;
2098void LLPanelEstateInfo::updateChild(LLUICtrl* child_ctrl) 2098 if (iter + 1 != end_it)
2099{ 2099 flags |= ESTATE_ACCESS_NO_REPLY;
2100 if (checkRemovalButton(child_ctrl->getName())) 2100
2101 { 2101 const LLUUID id = iter->asUUID();
2102 // do nothing 2102 if (((U32)notification["payload"]["operation"].asInteger() & ESTATE_ACCESS_BANNED_AGENT_ADD)
2103 } 2103 && region && (region->getOwner() == id))
2104 else if (checkSunHourSlider(child_ctrl)) 2104 {
2105 { 2105 LLNotifications::instance().add("OwnerCanNotBeDenied");
2106 // do nothing 2106 break;
2107 } 2107 }
2108} 2108 switch(option)
2109 2109 {
2110bool LLPanelEstateInfo::estateUpdate(LLMessageSystem* msg) 2110 case 0:
2111{ 2111 // This estate
2112 llinfos << "LLPanelEstateInfo::estateUpdate()" << llendl; 2112 sendEstateAccessDelta(flags, id);
2113 return false; 2113 break;
2114} 2114 case 1:
2115 2115 {
2116 2116 // All estates, either than I own or manage for this owner.
2117BOOL LLPanelEstateInfo::postBuild() 2117 // This will be verified on simulator. JC
2118{ 2118 if (!region) break;
2119 // set up the callbacks for the generic controls 2119 if (region->getOwner() == gAgent.getID()
2120 initCtrl("externally_visible_check"); 2120 || gAgent.isGodlike())
2121 initCtrl("use_global_time_check"); 2121 {
2122 initCtrl("fixed_sun_check"); 2122 flags |= ESTATE_ACCESS_APPLY_TO_ALL_ESTATES;
2123 initCtrl("allow_direct_teleport"); 2123 sendEstateAccessDelta(flags, id);
2124 initCtrl("limit_payment"); 2124 }
2125 initCtrl("limit_age_verified"); 2125 else if (region->isEstateManager())
2126 initCtrl("voice_chat_check"); 2126 {
2127 childSetCommitCallback("abuse_email_address", onChangeAnything, this); 2127 flags |= ESTATE_ACCESS_APPLY_TO_MANAGED_ESTATES;
2128 childSetKeystrokeCallback("abuse_email_address", onChangeText, this); 2128 sendEstateAccessDelta(flags, id);
2129 2129 }
2130 initHelpBtn("estate_manager_help", "HelpEstateEstateManager"); 2130 break;
2131 initHelpBtn("use_global_time_help", "HelpEstateUseGlobalTime"); 2131 }
2132 initHelpBtn("fixed_sun_help", "HelpEstateFixedSun"); 2132 case 2:
2133 initHelpBtn("WLEditSkyHelp", "HelpEditSky"); 2133 default:
2134 initHelpBtn("WLEditDayCycleHelp", "HelpEditDayCycle"); 2134 break;
2135 2135 }
2136 initHelpBtn("externally_visible_help", "HelpEstateExternallyVisible"); 2136 }
2137 initHelpBtn("allow_direct_teleport_help", "HelpEstateAllowDirectTeleport"); 2137 return false;
2138 initHelpBtn("allow_resident_help", "HelpEstateAllowResident"); 2138}
2139 initHelpBtn("allow_group_help", "HelpEstateAllowGroup"); 2139
2140 initHelpBtn("ban_resident_help", "HelpEstateBanResident"); 2140// key = "estateaccessdelta"
2141 initHelpBtn("abuse_email_address_help", "HelpEstateAbuseEmailAddress"); 2141// str(estate_id) will be added to front of list by forward_EstateOwnerRequest_to_dataserver
2142 initHelpBtn("voice_chat_help", "HelpEstateVoiceChat"); 2142// str[0] = str(agent_id) requesting the change
2143 2143// str[1] = str(flags) (ESTATE_ACCESS_DELTA_*)
2144 // set up the use global time checkbox 2144// str[2] = str(agent_id) to add or remove
2145 childSetCommitCallback("use_global_time_check", onChangeUseGlobalTime, this); 2145// static
2146 childSetCommitCallback("fixed_sun_check", onChangeFixedSun, this); 2146void LLPanelEstateInfo::sendEstateAccessDelta(U32 flags, const LLUUID& agent_or_group_id)
2147 childSetCommitCallback("sun_hour_slider", onChangeChildCtrl, this); 2147{
2148 2148 LLMessageSystem* msg = gMessageSystem;
2149 childSetCommitCallback("allowed_avatar_name_list", onChangeChildCtrl, this); 2149 msg->newMessage("EstateOwnerMessage");
2150 LLNameListCtrl *avatar_name_list = getChild<LLNameListCtrl>("allowed_avatar_name_list"); 2150 msg->nextBlockFast(_PREHASH_AgentData);
2151 if (avatar_name_list) 2151 msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
2152 { 2152 msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
2153 avatar_name_list->setCommitOnSelectionChange(TRUE); 2153 msg->addUUIDFast(_PREHASH_TransactionID, LLUUID::null); //not used
2154 avatar_name_list->setMaxItemCount(ESTATE_MAX_ACCESS_IDS); 2154
2155 } 2155 msg->nextBlock("MethodData");
2156 2156 msg->addString("Method", "estateaccessdelta");
2157 childSetAction("add_allowed_avatar_btn", onClickAddAllowedAgent, this); 2157 msg->addUUID("Invoice", LLFloaterRegionInfo::getLastInvoice());
2158 childSetAction("remove_allowed_avatar_btn", onClickRemoveAllowedAgent, this); 2158
2159 2159 std::string buf;
2160 childSetCommitCallback("allowed_group_name_list", onChangeChildCtrl, this); 2160 gAgent.getID().toString(buf);
2161 LLNameListCtrl* group_name_list = getChild<LLNameListCtrl>("allowed_group_name_list"); 2161 msg->nextBlock("ParamList");
2162 if (group_name_list) 2162 msg->addString("Parameter", buf);
2163 { 2163
2164 group_name_list->setCommitOnSelectionChange(TRUE); 2164 buf = llformat("%u", flags);
2165 group_name_list->setMaxItemCount(ESTATE_MAX_ACCESS_IDS); 2165 msg->nextBlock("ParamList");
2166 } 2166 msg->addString("Parameter", buf);
2167 2167
2168 childSetAction("add_allowed_group_btn", onClickAddAllowedGroup, this); 2168 agent_or_group_id.toString(buf);
2169 childSetAction("remove_allowed_group_btn", onClickRemoveAllowedGroup, this); 2169 msg->nextBlock("ParamList");
2170 2170 msg->addString("Parameter", buf);
2171 childSetCommitCallback("banned_avatar_name_list", onChangeChildCtrl, this); 2171
2172 LLNameListCtrl* banned_name_list = getChild<LLNameListCtrl>("banned_avatar_name_list"); 2172
2173 if (banned_name_list) 2173 LLPanelEstateInfo* panel = LLFloaterRegionInfo::getPanelEstate();
2174 { 2174
2175 banned_name_list->setCommitOnSelectionChange(TRUE); 2175 if (flags & (ESTATE_ACCESS_ALLOWED_AGENT_ADD | ESTATE_ACCESS_ALLOWED_AGENT_REMOVE |
2176 banned_name_list->setMaxItemCount(ESTATE_MAX_ACCESS_IDS); 2176 ESTATE_ACCESS_BANNED_AGENT_ADD | ESTATE_ACCESS_BANNED_AGENT_REMOVE))
2177 } 2177 {
2178 2178
2179 childSetAction("add_banned_avatar_btn", onClickAddBannedAgent, this); 2179 panel->clearAccessLists();
2180 childSetAction("remove_banned_avatar_btn", onClickRemoveBannedAgent, this); 2180 }
2181 2181
2182 childSetCommitCallback("estate_manager_name_list", onChangeChildCtrl, this); 2182 gAgent.sendReliableMessage();
2183 LLNameListCtrl* manager_name_list = getChild<LLNameListCtrl>("estate_manager_name_list"); 2183}
2184 if (manager_name_list) 2184
2185 { 2185void LLPanelEstateInfo::updateControls(LLViewerRegion* region)
2186 manager_name_list->setCommitOnSelectionChange(TRUE); 2186{
2187 manager_name_list->setMaxItemCount(ESTATE_MAX_MANAGERS * 4); // Allow extras for dupe issue 2187 BOOL god = gAgent.isGodlike();
2188 } 2188 BOOL owner = (region && (region->getOwner() == gAgent.getID()));
2189 2189 BOOL manager = (region && region->isEstateManager());
2190 childSetAction("add_estate_manager_btn", onClickAddEstateManager, this); 2190 setCtrlsEnabled(god || owner || manager);
2191 childSetAction("remove_estate_manager_btn", onClickRemoveEstateManager, this); 2191
2192 childSetAction("message_estate_btn", onClickMessageEstate, this); 2192 childDisable("apply_btn");
2193 childSetAction("kick_user_from_estate_btn", onClickKickUser, this); 2193 childSetEnabled("add_allowed_avatar_btn", god || owner || manager);
2194 2194 childSetEnabled("remove_allowed_avatar_btn", god || owner || manager);
2195 childSetAction("WLEditSky", onClickEditSky, this); 2195 childSetEnabled("add_allowed_group_btn", god || owner || manager);
2196 childSetAction("WLEditDayCycle", onClickEditDayCycle, this); 2196 childSetEnabled("remove_allowed_group_btn", god || owner || manager);
2197 2197 childSetEnabled("add_banned_avatar_btn", god || owner || manager);
2198 return LLPanelRegionInfo::postBuild(); 2198 childSetEnabled("remove_banned_avatar_btn", god || owner || manager);
2199} 2199 childSetEnabled("message_estate_btn", god || owner || manager);
2200 2200 childSetEnabled("kick_user_from_estate_btn", god || owner || manager);
2201void LLPanelEstateInfo::refresh() 2201 childSetEnabled("abuse_email_address", god || owner || manager);
2202{ 2202
2203 bool public_access = childGetValue("externally_visible_check").asBoolean(); 2203 // estate managers can't add estate managers
2204 childSetEnabled("Only Allow", public_access); 2204 childSetEnabled("add_estate_manager_btn", god || owner);
2205 childSetEnabled("limit_payment", public_access); 2205 childSetEnabled("remove_estate_manager_btn", god || owner);
2206 childSetEnabled("limit_age_verified", public_access); 2206 childSetEnabled("estate_manager_name_list", god || owner);
2207 // if this is set to false, then the limit fields are meaningless and should be turned off 2207}
2208 if (public_access == false) 2208
2209 { 2209bool LLPanelEstateInfo::refreshFromRegion(LLViewerRegion* region)
2210 childSetValue("limit_payment", false); 2210{
2211 childSetValue("limit_age_verified", false); 2211 updateControls(region);
2212 } 2212
2213} 2213 // let the parent class handle the general data collection.
2214 2214 bool rv = LLPanelRegionInfo::refreshFromRegion(region);
2215BOOL LLPanelEstateInfo::sendUpdate() 2215
2216{ 2216 // We want estate info. To make sure it works across region
2217 llinfos << "LLPanelEsateInfo::sendUpdate()" << llendl; 2217 // boundaries and multiple packets, we add a serial number to the
2218 2218 // integers and track against that on update.
2219 LLNotification::Params params("ChangeLindenEstate"); 2219 strings_t strings;
2220 params.functor(boost::bind(&LLPanelEstateInfo::callbackChangeLindenEstate, this, _1, _2)); 2220 //integers_t integers;
2221 2221 //LLFloaterRegionInfo::incrementSerial();
2222 if (getEstateID() <= ESTATE_LAST_LINDEN) 2222 LLFloaterRegionInfo::nextInvoice();
2223 { 2223 LLUUID invoice(LLFloaterRegionInfo::getLastInvoice());
2224 // trying to change reserved estate, warn 2224 //integers.push_back(LLFloaterRegionInfo::());::getPanelEstate();
2225 LLNotifications::instance().add(params); 2225
2226 } 2226
2227 else 2227 LLPanelEstateInfo* panel = LLFloaterRegionInfo::getPanelEstate();
2228 { 2228 panel->clearAccessLists();
2229 // for normal estates, just make the change 2229
2230 LLNotifications::instance().forceResponse(params, 0); 2230
2231 } 2231 sendEstateOwnerMessage(gMessageSystem, "getinfo", invoice, strings);
2232 return TRUE; 2232
2233} 2233 refresh();
2234 2234
2235bool LLPanelEstateInfo::callbackChangeLindenEstate(const LLSD& notification, const LLSD& response) 2235 return rv;
2236{ 2236}
2237 S32 option = LLNotification::getSelectedOption(notification, response); 2237
2238 switch(option) 2238void LLPanelEstateInfo::updateChild(LLUICtrl* child_ctrl)
2239 { 2239{
2240 case 0: 2240 if (checkRemovalButton(child_ctrl->getName()))
2241 // send the update 2241 {
2242 if (!commitEstateInfoCaps()) 2242 // do nothing
2243 { 2243 }
2244 // the caps method failed, try the old way 2244 else if (checkSunHourSlider(child_ctrl))
2245 LLFloaterRegionInfo::nextInvoice(); 2245 {
2246 commitEstateInfoDataserver(); 2246 // do nothing
2247 } 2247 }
2248 // we don't want to do this because we'll get it automatically from the sim 2248}
2249 // after the spaceserver processes it 2249
2250// else 2250bool LLPanelEstateInfo::estateUpdate(LLMessageSystem* msg)
2251// { 2251{
2252// // caps method does not automatically send this info 2252 llinfos << "LLPanelEstateInfo::estateUpdate()" << llendl;
2253// LLFloaterRegionInfo::requestRegionInfo(); 2253 return false;
2254// } 2254}
2255 break; 2255
2256 case 1: 2256
2257 default: 2257BOOL LLPanelEstateInfo::postBuild()
2258 // do nothing 2258{
2259 break; 2259 // set up the callbacks for the generic controls
2260 } 2260 initCtrl("externally_visible_check");
2261 return false; 2261 initCtrl("use_global_time_check");
2262} 2262 initCtrl("fixed_sun_check");
2263 2263 initCtrl("allow_direct_teleport");
2264 2264 initCtrl("limit_payment");
2265/* 2265 initCtrl("limit_age_verified");
2266// Request = "getowner" 2266 initCtrl("voice_chat_check");
2267// SParam[0] = "" (empty string) 2267 childSetCommitCallback("abuse_email_address", onChangeAnything, this);
2268// IParam[0] = serial 2268 childSetKeystrokeCallback("abuse_email_address", onChangeText, this);
2269void LLPanelEstateInfo::getEstateOwner() 2269
2270{ 2270 initHelpBtn("estate_manager_help", "HelpEstateEstateManager");
2271 // TODO -- disable the panel 2271 initHelpBtn("use_global_time_help", "HelpEstateUseGlobalTime");
2272 // and call this function whenever we cross a region boundary 2272 initHelpBtn("fixed_sun_help", "HelpEstateFixedSun");
2273 // re-enable when owner matches, and get new estate info 2273 initHelpBtn("WLEditSkyHelp", "HelpEditSky");
2274 LLMessageSystem* msg = gMessageSystem; 2274 initHelpBtn("WLEditDayCycleHelp", "HelpEditDayCycle");
2275 msg->newMessageFast(_PREHASH_EstateOwnerRequest); 2275
2276 msg->nextBlockFast(_PREHASH_AgentData); 2276 initHelpBtn("externally_visible_help", "HelpEstateExternallyVisible");
2277 msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); 2277 initHelpBtn("allow_direct_teleport_help", "HelpEstateAllowDirectTeleport");
2278 2278 initHelpBtn("allow_resident_help", "HelpEstateAllowResident");
2279 msg->nextBlockFast(_PREHASH_RequestData); 2279 initHelpBtn("allow_group_help", "HelpEstateAllowGroup");
2280 msg->addStringFast(_PREHASH_Request, "getowner"); 2280 initHelpBtn("ban_resident_help", "HelpEstateBanResident");
2281 2281 initHelpBtn("abuse_email_address_help", "HelpEstateAbuseEmailAddress");
2282 // we send an empty string so that the variable block is not empty 2282 initHelpBtn("voice_chat_help", "HelpEstateVoiceChat");
2283 msg->nextBlockFast(_PREHASH_StringData); 2283
2284 msg->addStringFast(_PREHASH_SParam, ""); 2284 // set up the use global time checkbox
2285 2285 childSetCommitCallback("use_global_time_check", onChangeUseGlobalTime, this);
2286 msg->nextBlockFast(_PREHASH_IntegerData); 2286 childSetCommitCallback("fixed_sun_check", onChangeFixedSun, this);
2287 msg->addS32Fast(_PREHASH_IParam, LLFloaterRegionInfo::getSerial()); 2287 childSetCommitCallback("sun_hour_slider", onChangeChildCtrl, this);
2288 2288
2289 gAgent.sendMessage(); 2289 childSetCommitCallback("allowed_avatar_name_list", onChangeChildCtrl, this);
2290} 2290 LLNameListCtrl *avatar_name_list = getChild<LLNameListCtrl>("allowed_avatar_name_list");
2291*/ 2291 if (avatar_name_list)
2292 2292 {
2293class LLEstateChangeInfoResponder : public LLHTTPClient::Responder 2293 avatar_name_list->setCommitOnSelectionChange(TRUE);
2294{ 2294 avatar_name_list->setMaxItemCount(ESTATE_MAX_ACCESS_IDS);
2295public: 2295 }
2296 LLEstateChangeInfoResponder(void* userdata) : mpPanel((LLPanelEstateInfo*)userdata) {}; 2296
2297 2297 childSetAction("add_allowed_avatar_btn", onClickAddAllowedAgent, this);
2298 // if we get a normal response, handle it here 2298 childSetAction("remove_allowed_avatar_btn", onClickRemoveAllowedAgent, this);
2299 virtual void result(const LLSD& content) 2299
2300 { 2300 childSetCommitCallback("allowed_group_name_list", onChangeChildCtrl, this);
2301 // refresh the panel from the database 2301 LLNameListCtrl* group_name_list = getChild<LLNameListCtrl>("allowed_group_name_list");
2302 mpPanel->refresh(); 2302 if (group_name_list)
2303 } 2303 {
2304 2304 group_name_list->setCommitOnSelectionChange(TRUE);
2305 // if we get an error response 2305 group_name_list->setMaxItemCount(ESTATE_MAX_ACCESS_IDS);
2306 virtual void error(U32 status, const std::string& reason) 2306 }
2307 { 2307
2308 llinfos << "LLEstateChangeInfoResponder::error " 2308 childSetAction("add_allowed_group_btn", onClickAddAllowedGroup, this);
2309 << status << ": " << reason << llendl; 2309 childSetAction("remove_allowed_group_btn", onClickRemoveAllowedGroup, this);
2310 } 2310
2311private: 2311 childSetCommitCallback("banned_avatar_name_list", onChangeChildCtrl, this);
2312 LLPanelEstateInfo* mpPanel; 2312 LLNameListCtrl* banned_name_list = getChild<LLNameListCtrl>("banned_avatar_name_list");
2313}; 2313 if (banned_name_list)
2314 2314 {
2315// tries to send estate info using a cap; returns true if it succeeded 2315 banned_name_list->setCommitOnSelectionChange(TRUE);
2316bool LLPanelEstateInfo::commitEstateInfoCaps() 2316 banned_name_list->setMaxItemCount(ESTATE_MAX_ACCESS_IDS);
2317{ 2317 }
2318 std::string url = gAgent.getRegion()->getCapability("EstateChangeInfo"); 2318
2319 2319 childSetAction("add_banned_avatar_btn", onClickAddBannedAgent, this);
2320 if (url.empty()) 2320 childSetAction("remove_banned_avatar_btn", onClickRemoveBannedAgent, this);
2321 { 2321
2322 // whoops, couldn't find the cap, so bail out 2322 childSetCommitCallback("estate_manager_name_list", onChangeChildCtrl, this);
2323 return false; 2323 LLNameListCtrl* manager_name_list = getChild<LLNameListCtrl>("estate_manager_name_list");
2324 } 2324 if (manager_name_list)
2325 2325 {
2326 LLSD body; 2326 manager_name_list->setCommitOnSelectionChange(TRUE);
2327 body["estate_name"] = getEstateName(); 2327 manager_name_list->setMaxItemCount(ESTATE_MAX_MANAGERS * 4); // Allow extras for dupe issue
2328 2328 }
2329 body["is_externally_visible"] = childGetValue("externally_visible_check").asBoolean(); 2329
2330 body["allow_direct_teleport"] = childGetValue("allow_direct_teleport").asBoolean(); 2330 childSetAction("add_estate_manager_btn", onClickAddEstateManager, this);
2331 body["is_sun_fixed" ] = childGetValue("fixed_sun_check").asBoolean(); 2331 childSetAction("remove_estate_manager_btn", onClickRemoveEstateManager, this);
2332 body["deny_anonymous" ] = childGetValue("limit_payment").asBoolean(); 2332 childSetAction("message_estate_btn", onClickMessageEstate, this);
2333 body["deny_age_unverified" ] = childGetValue("limit_age_verified").asBoolean(); 2333 childSetAction("kick_user_from_estate_btn", onClickKickUser, this);
2334 body["allow_voice_chat" ] = childGetValue("voice_chat_check").asBoolean(); 2334
2335 body["invoice" ] = LLFloaterRegionInfo::getLastInvoice(); 2335 childSetAction("WLEditSky", onClickEditSky, this);
2336 2336 childSetAction("WLEditDayCycle", onClickEditDayCycle, this);
2337 // block fly is in estate database but not in estate UI, so we're not supporting it 2337
2338 //body["block_fly" ] = childGetValue("").asBoolean(); 2338 return LLPanelRegionInfo::postBuild();
2339 2339}
2340 F32 sun_hour = getSunHour(); 2340
2341 if (childGetValue("use_global_time_check").asBoolean()) 2341void LLPanelEstateInfo::refresh()
2342 { 2342{
2343 sun_hour = 0.f; // 0 = global time 2343 bool public_access = childGetValue("externally_visible_check").asBoolean();
2344 } 2344 childSetEnabled("Only Allow", public_access);
2345 body["sun_hour"] = sun_hour; 2345 childSetEnabled("limit_payment", public_access);
2346 2346 childSetEnabled("limit_age_verified", public_access);
2347 body["owner_abuse_email"] = childGetValue("abuse_email_address").asString(); 2347 // if this is set to false, then the limit fields are meaningless and should be turned off
2348 2348 if (public_access == false)
2349 // we use a responder so that we can re-get the data after committing to the database 2349 {
2350 LLHTTPClient::post(url, body, new LLEstateChangeInfoResponder((void*)this)); 2350 childSetValue("limit_payment", false);
2351 return true; 2351 childSetValue("limit_age_verified", false);
2352} 2352 }
2353 2353}
2354/* This is the old way of doing things, is deprecated, and should be 2354
2355 deleted when the dataserver model can be removed */ 2355BOOL LLPanelEstateInfo::sendUpdate()
2356// key = "estatechangeinfo" 2356{
2357// strings[0] = str(estate_id) (added by simulator before relay - not here) 2357 llinfos << "LLPanelEsateInfo::sendUpdate()" << llendl;
2358// strings[1] = estate_name 2358
2359// strings[2] = str(estate_flags) 2359 LLNotification::Params params("ChangeLindenEstate");
2360// strings[3] = str((S32)(sun_hour * 1024.f)) 2360 params.functor(boost::bind(&LLPanelEstateInfo::callbackChangeLindenEstate, this, _1, _2));
2361void LLPanelEstateInfo::commitEstateInfoDataserver() 2361
2362{ 2362 if (getEstateID() <= ESTATE_LAST_LINDEN)
2363 LLMessageSystem* msg = gMessageSystem; 2363 {
2364 msg->newMessage("EstateOwnerMessage"); 2364 // trying to change reserved estate, warn
2365 msg->nextBlockFast(_PREHASH_AgentData); 2365 LLNotifications::instance().add(params);
2366 msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); 2366 }
2367 msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); 2367 else
2368 msg->addUUIDFast(_PREHASH_TransactionID, LLUUID::null); //not used 2368 {
2369 2369 // for normal estates, just make the change
2370 msg->nextBlock("MethodData"); 2370 LLNotifications::instance().forceResponse(params, 0);
2371 msg->addString("Method", "estatechangeinfo"); 2371 }
2372 msg->addUUID("Invoice", LLFloaterRegionInfo::getLastInvoice()); 2372 return TRUE;
2373 2373}
2374 msg->nextBlock("ParamList"); 2374
2375 msg->addString("Parameter", getEstateName()); 2375bool LLPanelEstateInfo::callbackChangeLindenEstate(const LLSD& notification, const LLSD& response)
2376 2376{
2377 std::string buffer; 2377 S32 option = LLNotification::getSelectedOption(notification, response);
2378 buffer = llformat("%u", computeEstateFlags()); 2378 switch(option)
2379 msg->nextBlock("ParamList"); 2379 {
2380 msg->addString("Parameter", buffer); 2380 case 0:
2381 2381 // send the update
2382 F32 sun_hour = getSunHour(); 2382 if (!commitEstateInfoCaps())
2383 if (childGetValue("use_global_time_check").asBoolean()) 2383 {
2384 { 2384 // the caps method failed, try the old way
2385 sun_hour = 0.f; // 0 = global time 2385 LLFloaterRegionInfo::nextInvoice();
2386 } 2386 commitEstateInfoDataserver();
2387 2387 }
2388 buffer = llformat("%d", (S32)(sun_hour*1024.0f)); 2388 // we don't want to do this because we'll get it automatically from the sim
2389 msg->nextBlock("ParamList"); 2389 // after the spaceserver processes it
2390 msg->addString("Parameter", buffer); 2390// else
2391 2391// {
2392 gAgent.sendMessage(); 2392// // caps method does not automatically send this info
2393} 2393// LLFloaterRegionInfo::requestRegionInfo();
2394 2394// }
2395void LLPanelEstateInfo::setEstateFlags(U32 flags) 2395 break;
2396{ 2396 case 1:
2397 childSetValue("externally_visible_check", LLSD(flags & REGION_FLAGS_EXTERNALLY_VISIBLE ? TRUE : FALSE) ); 2397 default:
2398 childSetValue("fixed_sun_check", LLSD(flags & REGION_FLAGS_SUN_FIXED ? TRUE : FALSE) ); 2398 // do nothing
2399 childSetValue( 2399 break;
2400 "voice_chat_check", 2400 }
2401 LLSD(flags & REGION_FLAGS_ALLOW_VOICE ? TRUE : FALSE)); 2401 return false;
2402 childSetValue("allow_direct_teleport", LLSD(flags & REGION_FLAGS_ALLOW_DIRECT_TELEPORT ? TRUE : FALSE) ); 2402}
2403 childSetValue("limit_payment", LLSD(flags & REGION_FLAGS_DENY_ANONYMOUS ? TRUE : FALSE) ); 2403
2404 childSetValue("limit_age_verified", LLSD(flags & REGION_FLAGS_DENY_AGEUNVERIFIED ? TRUE : FALSE) ); 2404
2405 2405/*
2406 refresh(); 2406// Request = "getowner"
2407} 2407// SParam[0] = "" (empty string)
2408 2408// IParam[0] = serial
2409U32 LLPanelEstateInfo::computeEstateFlags() 2409void LLPanelEstateInfo::getEstateOwner()
2410{ 2410{
2411 U32 flags = 0; 2411 // TODO -- disable the panel
2412 2412 // and call this function whenever we cross a region boundary
2413 if (childGetValue("externally_visible_check").asBoolean()) 2413 // re-enable when owner matches, and get new estate info
2414 { 2414 LLMessageSystem* msg = gMessageSystem;
2415 flags |= REGION_FLAGS_EXTERNALLY_VISIBLE; 2415 msg->newMessageFast(_PREHASH_EstateOwnerRequest);
2416 } 2416 msg->nextBlockFast(_PREHASH_AgentData);
2417 2417 msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
2418 if ( childGetValue("voice_chat_check").asBoolean() ) 2418
2419 { 2419 msg->nextBlockFast(_PREHASH_RequestData);
2420 flags |= REGION_FLAGS_ALLOW_VOICE; 2420 msg->addStringFast(_PREHASH_Request, "getowner");
2421 } 2421
2422 2422 // we send an empty string so that the variable block is not empty
2423 if (childGetValue("allow_direct_teleport").asBoolean()) 2423 msg->nextBlockFast(_PREHASH_StringData);
2424 { 2424 msg->addStringFast(_PREHASH_SParam, "");
2425 flags |= REGION_FLAGS_ALLOW_DIRECT_TELEPORT; 2425
2426 } 2426 msg->nextBlockFast(_PREHASH_IntegerData);
2427 2427 msg->addS32Fast(_PREHASH_IParam, LLFloaterRegionInfo::getSerial());
2428 if (childGetValue("fixed_sun_check").asBoolean()) 2428
2429 { 2429 gAgent.sendMessage();
2430 flags |= REGION_FLAGS_SUN_FIXED; 2430}
2431 } 2431*/
2432 2432
2433 if (childGetValue("limit_payment").asBoolean()) 2433class LLEstateChangeInfoResponder : public LLHTTPClient::Responder
2434 { 2434{
2435 flags |= REGION_FLAGS_DENY_ANONYMOUS; 2435public:
2436 } 2436 LLEstateChangeInfoResponder(void* userdata) : mpPanel((LLPanelEstateInfo*)userdata) {};
2437 2437
2438 if (childGetValue("limit_age_verified").asBoolean()) 2438 // if we get a normal response, handle it here
2439 { 2439 virtual void result(const LLSD& content)
2440 flags |= REGION_FLAGS_DENY_AGEUNVERIFIED; 2440 {
2441 } 2441 // refresh the panel from the database
2442 2442 mpPanel->refresh();
2443 2443 }
2444 return flags; 2444
2445} 2445 // if we get an error response
2446 2446 virtual void error(U32 status, const std::string& reason)
2447BOOL LLPanelEstateInfo::getGlobalTime() 2447 {
2448{ 2448 llinfos << "LLEstateChangeInfoResponder::error "
2449 return childGetValue("use_global_time_check").asBoolean(); 2449 << status << ": " << reason << llendl;
2450} 2450 }
2451 2451private:
2452void LLPanelEstateInfo::setGlobalTime(bool b) 2452 LLPanelEstateInfo* mpPanel;
2453{ 2453};
2454 childSetValue("use_global_time_check", LLSD(b)); 2454
2455 childSetEnabled("fixed_sun_check", LLSD(!b)); 2455// tries to send estate info using a cap; returns true if it succeeded
2456 childSetEnabled("sun_hour_slider", LLSD(!b)); 2456bool LLPanelEstateInfo::commitEstateInfoCaps()
2457 if (b) 2457{
2458 { 2458 std::string url = gAgent.getRegion()->getCapability("EstateChangeInfo");
2459 childSetValue("sun_hour_slider", LLSD(0.f)); 2459
2460 } 2460 if (url.empty())
2461} 2461 {
2462 2462 // whoops, couldn't find the cap, so bail out
2463 2463 return false;
2464BOOL LLPanelEstateInfo::getFixedSun() 2464 }
2465{ 2465
2466 return childGetValue("fixed_sun_check").asBoolean(); 2466 LLSD body;
2467} 2467 body["estate_name"] = getEstateName();
2468 2468
2469void LLPanelEstateInfo::setSunHour(F32 sun_hour) 2469 body["is_externally_visible"] = childGetValue("externally_visible_check").asBoolean();
2470{ 2470 body["allow_direct_teleport"] = childGetValue("allow_direct_teleport").asBoolean();
2471 if(sun_hour < 6.0f) 2471 body["is_sun_fixed" ] = childGetValue("fixed_sun_check").asBoolean();
2472 { 2472 body["deny_anonymous" ] = childGetValue("limit_payment").asBoolean();
2473 sun_hour = 24.0f + sun_hour; 2473 body["deny_age_unverified" ] = childGetValue("limit_age_verified").asBoolean();
2474 } 2474 body["allow_voice_chat" ] = childGetValue("voice_chat_check").asBoolean();
2475 childSetValue("sun_hour_slider", LLSD(sun_hour)); 2475 body["invoice" ] = LLFloaterRegionInfo::getLastInvoice();
2476} 2476
2477 2477 // block fly is in estate database but not in estate UI, so we're not supporting it
2478F32 LLPanelEstateInfo::getSunHour() 2478 //body["block_fly" ] = childGetValue("").asBoolean();
2479{ 2479
2480 if (childIsEnabled("sun_hour_slider")) 2480 F32 sun_hour = getSunHour();
2481 { 2481 if (childGetValue("use_global_time_check").asBoolean())
2482 return (F32)childGetValue("sun_hour_slider").asReal(); 2482 {
2483 } 2483 sun_hour = 0.f; // 0 = global time
2484 return 0.f; 2484 }
2485} 2485 body["sun_hour"] = sun_hour;
2486 2486
2487const std::string LLPanelEstateInfo::getEstateName() const 2487 body["owner_abuse_email"] = childGetValue("abuse_email_address").asString();
2488{ 2488
2489 return childGetValue("estate_name").asString(); 2489 // we use a responder so that we can re-get the data after committing to the database
2490} 2490 LLHTTPClient::post(url, body, new LLEstateChangeInfoResponder((void*)this));
2491 2491 return true;
2492void LLPanelEstateInfo::setEstateName(const std::string& name) 2492}
2493{ 2493
2494 childSetValue("estate_name", LLSD(name)); 2494/* This is the old way of doing things, is deprecated, and should be
2495} 2495 deleted when the dataserver model can be removed */
2496 2496// key = "estatechangeinfo"
2497const std::string LLPanelEstateInfo::getOwnerName() const 2497// strings[0] = str(estate_id) (added by simulator before relay - not here)
2498{ 2498// strings[1] = estate_name
2499 return childGetValue("estate_owner").asString(); 2499// strings[2] = str(estate_flags)
2500} 2500// strings[3] = str((S32)(sun_hour * 1024.f))
2501 2501void LLPanelEstateInfo::commitEstateInfoDataserver()
2502void LLPanelEstateInfo::setOwnerName(const std::string& name) 2502{
2503{ 2503 LLMessageSystem* msg = gMessageSystem;
2504 childSetValue("estate_owner", LLSD(name)); 2504 msg->newMessage("EstateOwnerMessage");
2505} 2505 msg->nextBlockFast(_PREHASH_AgentData);
2506 2506 msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
2507const std::string LLPanelEstateInfo::getAbuseEmailAddress() const 2507 msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
2508{ 2508 msg->addUUIDFast(_PREHASH_TransactionID, LLUUID::null); //not used
2509 return childGetValue("abuse_email_address").asString(); 2509
2510} 2510 msg->nextBlock("MethodData");
2511 2511 msg->addString("Method", "estatechangeinfo");
2512void LLPanelEstateInfo::setAbuseEmailAddress(const std::string& address) 2512 msg->addUUID("Invoice", LLFloaterRegionInfo::getLastInvoice());
2513{ 2513
2514 childSetValue("abuse_email_address", LLSD(address)); 2514 msg->nextBlock("ParamList");
2515} 2515 msg->addString("Parameter", getEstateName());
2516 2516
2517void LLPanelEstateInfo::setAccessAllowedEnabled(bool enable_agent, 2517 std::string buffer;
2518 bool enable_group, 2518 buffer = llformat("%u", computeEstateFlags());
2519 bool enable_ban) 2519 msg->nextBlock("ParamList");
2520{ 2520 msg->addString("Parameter", buffer);
2521 childSetEnabled("allow_resident_label", enable_agent); 2521
2522 childSetEnabled("allowed_avatar_name_list", enable_agent); 2522 F32 sun_hour = getSunHour();
2523 childSetVisible("allowed_avatar_name_list", enable_agent); 2523 if (childGetValue("use_global_time_check").asBoolean())
2524 childSetEnabled("add_allowed_avatar_btn", enable_agent); 2524 {
2525 childSetEnabled("remove_allowed_avatar_btn", enable_agent); 2525 sun_hour = 0.f; // 0 = global time
2526 2526 }
2527 // Groups 2527
2528 childSetEnabled("allow_group_label", enable_group); 2528 buffer = llformat("%d", (S32)(sun_hour*1024.0f));
2529 childSetEnabled("allowed_group_name_list", enable_group); 2529 msg->nextBlock("ParamList");
2530 childSetVisible("allowed_group_name_list", enable_group); 2530 msg->addString("Parameter", buffer);
2531 childSetEnabled("add_allowed_group_btn", enable_group); 2531
2532 childSetEnabled("remove_allowed_group_btn", enable_group); 2532 gAgent.sendMessage();
2533 2533}
2534 // Ban 2534
2535 childSetEnabled("ban_resident_label", enable_ban); 2535void LLPanelEstateInfo::setEstateFlags(U32 flags)
2536 childSetEnabled("banned_avatar_name_list", enable_ban); 2536{
2537 childSetVisible("banned_avatar_name_list", enable_ban); 2537 childSetValue("externally_visible_check", LLSD(flags & REGION_FLAGS_EXTERNALLY_VISIBLE ? TRUE : FALSE) );
2538 childSetEnabled("add_banned_avatar_btn", enable_ban); 2538 childSetValue("fixed_sun_check", LLSD(flags & REGION_FLAGS_SUN_FIXED ? TRUE : FALSE) );
2539 childSetEnabled("remove_banned_avatar_btn", enable_ban); 2539 childSetValue(
2540 2540 "voice_chat_check",
2541 // Update removal buttons if needed 2541 LLSD(flags & REGION_FLAGS_ALLOW_VOICE ? TRUE : FALSE));
2542 if (enable_agent) 2542 childSetValue("allow_direct_teleport", LLSD(flags & REGION_FLAGS_ALLOW_DIRECT_TELEPORT ? TRUE : FALSE) );
2543 { 2543 childSetValue("limit_payment", LLSD(flags & REGION_FLAGS_DENY_ANONYMOUS ? TRUE : FALSE) );
2544 checkRemovalButton("allowed_avatar_name_list"); 2544 childSetValue("limit_age_verified", LLSD(flags & REGION_FLAGS_DENY_AGEUNVERIFIED ? TRUE : FALSE) );
2545 } 2545
2546 2546 refresh();
2547 if (enable_group) 2547}
2548 { 2548
2549 checkRemovalButton("allowed_group_name_list"); 2549U32 LLPanelEstateInfo::computeEstateFlags()
2550 } 2550{
2551 2551 U32 flags = 0;
2552 if (enable_ban) 2552
2553 { 2553 if (childGetValue("externally_visible_check").asBoolean())
2554 checkRemovalButton("banned_avatar_name_list"); 2554 {
2555 } 2555 flags |= REGION_FLAGS_EXTERNALLY_VISIBLE;
2556} 2556 }
2557 2557
2558// static 2558 if ( childGetValue("voice_chat_check").asBoolean() )
2559void LLPanelEstateInfo::callbackCacheName( 2559 {
2560 const LLUUID& id, 2560 flags |= REGION_FLAGS_ALLOW_VOICE;
2561 const std::string& first, 2561 }
2562 const std::string& last, 2562
2563 BOOL is_group, 2563 if (childGetValue("allow_direct_teleport").asBoolean())
2564 void*) 2564 {
2565{ 2565 flags |= REGION_FLAGS_ALLOW_DIRECT_TELEPORT;
2566 LLPanelEstateInfo* self = LLFloaterRegionInfo::getPanelEstate(); 2566 }
2567 if (!self) return; 2567
2568 2568 if (childGetValue("fixed_sun_check").asBoolean())
2569 std::string name; 2569 {
2570 2570 flags |= REGION_FLAGS_SUN_FIXED;
2571 if (id.isNull()) 2571 }
2572 { 2572
2573 name = "(none)"; 2573 if (childGetValue("limit_payment").asBoolean())
2574 } 2574 {
2575 else 2575 flags |= REGION_FLAGS_DENY_ANONYMOUS;
2576 { 2576 }
2577 name = first + " " + last; 2577
2578 } 2578 if (childGetValue("limit_age_verified").asBoolean())
2579 2579 {
2580 self->setOwnerName(name); 2580 flags |= REGION_FLAGS_DENY_AGEUNVERIFIED;
2581} 2581 }
2582 2582
2583void LLPanelEstateInfo::clearAccessLists() 2583
2584{ 2584 return flags;
2585 LLNameListCtrl* name_list = getChild<LLNameListCtrl>("allowed_avatar_name_list"); 2585}
2586 if (name_list) 2586
2587 { 2587BOOL LLPanelEstateInfo::getGlobalTime()
2588 name_list->deleteAllItems(); 2588{
2589 } 2589 return childGetValue("use_global_time_check").asBoolean();
2590 2590}
2591 name_list = getChild<LLNameListCtrl>("banned_avatar_name_list"); 2591
2592 if (name_list) 2592void LLPanelEstateInfo::setGlobalTime(bool b)
2593 { 2593{
2594 name_list->deleteAllItems(); 2594 childSetValue("use_global_time_check", LLSD(b));
2595 } 2595 childSetEnabled("fixed_sun_check", LLSD(!b));
2596} 2596 childSetEnabled("sun_hour_slider", LLSD(!b));
2597 2597 if (b)
2598// enables/disables the "remove" button for the various allow/ban lists 2598 {
2599BOOL LLPanelEstateInfo::checkRemovalButton(std::string name) 2599 childSetValue("sun_hour_slider", LLSD(0.f));
2600{ 2600 }
2601 std::string btn_name = ""; 2601}
2602 if (name == "allowed_avatar_name_list") 2602
2603 { 2603
2604 btn_name = "remove_allowed_avatar_btn"; 2604BOOL LLPanelEstateInfo::getFixedSun()
2605 } 2605{
2606 else if (name == "allowed_group_name_list") 2606 return childGetValue("fixed_sun_check").asBoolean();
2607 { 2607}
2608 btn_name = "remove_allowed_group_btn"; 2608
2609 } 2609void LLPanelEstateInfo::setSunHour(F32 sun_hour)
2610 else if (name == "banned_avatar_name_list") 2610{
2611 { 2611 if(sun_hour < 6.0f)
2612 btn_name = "remove_banned_avatar_btn"; 2612 {
2613 } 2613 sun_hour = 24.0f + sun_hour;
2614 else if (name == "estate_manager_name_list") 2614 }
2615 { 2615 childSetValue("sun_hour_slider", LLSD(sun_hour));
2616 //ONLY OWNER CAN ADD /DELET ESTATE MANAGER 2616}
2617 LLViewerRegion* region = gAgent.getRegion(); 2617
2618 if (region && (region->getOwner() == gAgent.getID())) 2618F32 LLPanelEstateInfo::getSunHour()
2619 { 2619{
2620 btn_name = "remove_estate_manager_btn"; 2620 if (childIsEnabled("sun_hour_slider"))
2621 } 2621 {
2622 } 2622 return (F32)childGetValue("sun_hour_slider").asReal();
2623 2623 }
2624 // enable the remove button if something is selected 2624 return 0.f;
2625 LLNameListCtrl* name_list = getChild<LLNameListCtrl>(name); 2625}
2626 childSetEnabled(btn_name, name_list && name_list->getFirstSelected() ? TRUE : FALSE); 2626
2627 2627const std::string LLPanelEstateInfo::getEstateName() const
2628 return (btn_name != ""); 2628{
2629} 2629 return childGetValue("estate_name").asString();
2630 2630}
2631BOOL LLPanelEstateInfo::checkSunHourSlider(LLUICtrl* child_ctrl) 2631
2632{ 2632void LLPanelEstateInfo::setEstateName(const std::string& name)
2633 BOOL found_child_ctrl = FALSE; 2633{
2634 if (child_ctrl->getName() == "sun_hour_slider") 2634 childSetValue("estate_name", LLSD(name));
2635 { 2635}
2636 enableButton("apply_btn"); 2636
2637 found_child_ctrl = TRUE; 2637const std::string LLPanelEstateInfo::getOwnerName() const
2638 } 2638{
2639 return found_child_ctrl; 2639 return childGetValue("estate_owner").asString();
2640} 2640}
2641 2641
2642// static 2642void LLPanelEstateInfo::setOwnerName(const std::string& name)
2643void LLPanelEstateInfo::onClickMessageEstate(void* userdata) 2643{
2644{ 2644 childSetValue("estate_owner", LLSD(name));
2645 llinfos << "LLPanelEstateInfo::onClickMessageEstate" << llendl; 2645}
2646 LLNotifications::instance().add("MessageEstate", LLSD(), LLSD(), boost::bind(&LLPanelEstateInfo::onMessageCommit, (LLPanelEstateInfo*)userdata, _1, _2)); 2646
2647} 2647const std::string LLPanelEstateInfo::getAbuseEmailAddress() const
2648 2648{
2649bool LLPanelEstateInfo::onMessageCommit(const LLSD& notification, const LLSD& response) 2649 return childGetValue("abuse_email_address").asString();
2650{ 2650}
2651 S32 option = LLNotification::getSelectedOption(notification, response); 2651
2652 std::string text = response["message"].asString(); 2652void LLPanelEstateInfo::setAbuseEmailAddress(const std::string& address)
2653 if(option != 0) return false; 2653{
2654 if(text.empty()) return false; 2654 childSetValue("abuse_email_address", LLSD(address));
2655 llinfos << "Message to everyone: " << text << llendl; 2655}
2656 strings_t strings; 2656
2657 //integers_t integers; 2657void LLPanelEstateInfo::setAccessAllowedEnabled(bool enable_agent,
2658 std::string name; 2658 bool enable_group,
2659 gAgent.buildFullname(name); 2659 bool enable_ban)
2660 strings.push_back(strings_t::value_type(name)); 2660{
2661 strings.push_back(strings_t::value_type(text)); 2661 childSetEnabled("allow_resident_label", enable_agent);
2662 LLUUID invoice(LLFloaterRegionInfo::getLastInvoice()); 2662 childSetEnabled("allowed_avatar_name_list", enable_agent);
2663 sendEstateOwnerMessage(gMessageSystem, "instantmessage", invoice, strings); 2663 childSetVisible("allowed_avatar_name_list", enable_agent);
2664 return false; 2664 childSetEnabled("add_allowed_avatar_btn", enable_agent);
2665} 2665 childSetEnabled("remove_allowed_avatar_btn", enable_agent);
2666 2666
2667LLPanelEstateCovenant::LLPanelEstateCovenant() 2667 // Groups
2668: mCovenantID(LLUUID::null) 2668 childSetEnabled("allow_group_label", enable_group);
2669{ 2669 childSetEnabled("allowed_group_name_list", enable_group);
2670} 2670 childSetVisible("allowed_group_name_list", enable_group);
2671 2671 childSetEnabled("add_allowed_group_btn", enable_group);
2672// virtual 2672 childSetEnabled("remove_allowed_group_btn", enable_group);
2673bool LLPanelEstateCovenant::refreshFromRegion(LLViewerRegion* region) 2673
2674{ 2674 // Ban
2675 LLTextBox* region_name = getChild<LLTextBox>("region_name_text"); 2675 childSetEnabled("ban_resident_label", enable_ban);
2676 if (region_name) 2676 childSetEnabled("banned_avatar_name_list", enable_ban);
2677 { 2677 childSetVisible("banned_avatar_name_list", enable_ban);
2678 region_name->setText(region->getName()); 2678 childSetEnabled("add_banned_avatar_btn", enable_ban);
2679 } 2679 childSetEnabled("remove_banned_avatar_btn", enable_ban);
2680 2680
2681 LLTextBox* resellable_clause = getChild<LLTextBox>("resellable_clause"); 2681 // Update removal buttons if needed
2682 if (resellable_clause) 2682 if (enable_agent)
2683 { 2683 {
2684 if (region->getRegionFlags() & REGION_FLAGS_BLOCK_LAND_RESELL) 2684 checkRemovalButton("allowed_avatar_name_list");
2685 { 2685 }
2686 resellable_clause->setText(getString("can_not_resell")); 2686
2687 } 2687 if (enable_group)
2688 else 2688 {
2689 { 2689 checkRemovalButton("allowed_group_name_list");
2690 resellable_clause->setText(getString("can_resell")); 2690 }
2691 } 2691
2692 } 2692 if (enable_ban)
2693 2693 {
2694 LLTextBox* changeable_clause = getChild<LLTextBox>("changeable_clause"); 2694 checkRemovalButton("banned_avatar_name_list");
2695 if (changeable_clause) 2695 }
2696 { 2696}
2697 if (region->getRegionFlags() & REGION_FLAGS_ALLOW_PARCEL_CHANGES) 2697
2698 { 2698// static
2699 changeable_clause->setText(getString("can_change")); 2699void LLPanelEstateInfo::callbackCacheName(
2700 } 2700 const LLUUID& id,
2701 else 2701 const std::string& first,
2702 { 2702 const std::string& last,
2703 changeable_clause->setText(getString("can_not_change")); 2703 BOOL is_group,
2704 } 2704 void*)
2705 } 2705{
2706 2706 LLPanelEstateInfo* self = LLFloaterRegionInfo::getPanelEstate();
2707 LLTextBox* region_maturity = getChild<LLTextBox>("region_maturity_text"); 2707 if (!self) return;
2708 if (region_maturity) 2708
2709 { 2709 std::string name;
2710 region_maturity->setText(region->getSimAccessString()); 2710
2711 } 2711 if (id.isNull())
2712 2712 {
2713 LLTextBox* region_landtype = getChild<LLTextBox>("region_landtype_text"); 2713 name = "(none)";
2714 if (region_landtype) 2714 }
2715 { 2715 else
2716 region_landtype->setText(region->getSimProductName()); 2716 {
2717 } 2717 name = first + " " + last;
2718 2718 }
2719 2719
2720 // let the parent class handle the general data collection. 2720 self->setOwnerName(name);
2721 bool rv = LLPanelRegionInfo::refreshFromRegion(region); 2721}
2722 LLMessageSystem *msg = gMessageSystem; 2722
2723 msg->newMessage("EstateCovenantRequest"); 2723void LLPanelEstateInfo::clearAccessLists()
2724 msg->nextBlockFast(_PREHASH_AgentData); 2724{
2725 msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); 2725 LLNameListCtrl* name_list = getChild<LLNameListCtrl>("allowed_avatar_name_list");
2726 msg->addUUIDFast(_PREHASH_SessionID,gAgent.getSessionID()); 2726 if (name_list)
2727 msg->sendReliable(region->getHost()); 2727 {
2728 return rv; 2728 name_list->deleteAllItems();
2729} 2729 }
2730 2730
2731// virtual 2731 name_list = getChild<LLNameListCtrl>("banned_avatar_name_list");
2732bool LLPanelEstateCovenant::estateUpdate(LLMessageSystem* msg) 2732 if (name_list)
2733{ 2733 {
2734 llinfos << "LLPanelEstateCovenant::estateUpdate()" << llendl; 2734 name_list->deleteAllItems();
2735 return true; 2735 }
2736} 2736}
2737 2737
2738// virtual 2738// enables/disables the "remove" button for the various allow/ban lists
2739BOOL LLPanelEstateCovenant::postBuild() 2739BOOL LLPanelEstateInfo::checkRemovalButton(std::string name)
2740{ 2740{
2741 initHelpBtn("covenant_help", "HelpEstateCovenant"); 2741 std::string btn_name = "";
2742 mEstateNameText = getChild<LLTextBox>("estate_name_text"); 2742 if (name == "allowed_avatar_name_list")
2743 mEstateOwnerText = getChild<LLTextBox>("estate_owner_text"); 2743 {
2744 mLastModifiedText = getChild<LLTextBox>("covenant_timestamp_text"); 2744 btn_name = "remove_allowed_avatar_btn";
2745 mEditor = getChild<LLViewerTextEditor>("covenant_editor"); 2745 }
2746 if (mEditor) mEditor->setHandleEditKeysDirectly(TRUE); 2746 else if (name == "allowed_group_name_list")
2747 LLButton* reset_button = getChild<LLButton>("reset_covenant"); 2747 {
2748 reset_button->setEnabled(gAgent.canManageEstate()); 2748 btn_name = "remove_allowed_group_btn";
2749 reset_button->setClickedCallback(LLPanelEstateCovenant::resetCovenantID, NULL); 2749 }
2750 2750 else if (name == "banned_avatar_name_list")
2751 return LLPanelRegionInfo::postBuild(); 2751 {
2752} 2752 btn_name = "remove_banned_avatar_btn";
2753 2753 }
2754// virtual 2754 else if (name == "estate_manager_name_list")
2755void LLPanelEstateCovenant::updateChild(LLUICtrl* child_ctrl) 2755 {
2756{ 2756 //ONLY OWNER CAN ADD /DELET ESTATE MANAGER
2757} 2757 LLViewerRegion* region = gAgent.getRegion();
2758 2758 if (region && (region->getOwner() == gAgent.getID()))
2759// virtual 2759 {
2760BOOL LLPanelEstateCovenant::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, 2760 btn_name = "remove_estate_manager_btn";
2761 EDragAndDropType cargo_type, 2761 }
2762 void* cargo_data, 2762 }
2763 EAcceptance* accept, 2763
2764 std::string& tooltip_msg) 2764 // enable the remove button if something is selected
2765{ 2765 LLNameListCtrl* name_list = getChild<LLNameListCtrl>(name);
2766 LLInventoryItem* item = (LLInventoryItem*)cargo_data; 2766 childSetEnabled(btn_name, name_list && name_list->getFirstSelected() ? TRUE : FALSE);
2767 2767
2768 if (!gAgent.canManageEstate()) 2768 return (btn_name != "");
2769 { 2769}
2770 *accept = ACCEPT_NO; 2770
2771 return TRUE; 2771BOOL LLPanelEstateInfo::checkSunHourSlider(LLUICtrl* child_ctrl)
2772 } 2772{
2773 2773 BOOL found_child_ctrl = FALSE;
2774 switch(cargo_type) 2774 if (child_ctrl->getName() == "sun_hour_slider")
2775 { 2775 {
2776 case DAD_NOTECARD: 2776 enableButton("apply_btn");
2777 *accept = ACCEPT_YES_COPY_SINGLE; 2777 found_child_ctrl = TRUE;
2778 if (item && drop) 2778 }
2779 { 2779 return found_child_ctrl;
2780 LLSD payload; 2780}
2781 payload["item_id"] = item->getUUID(); 2781
2782 LLNotifications::instance().add("EstateChangeCovenant", LLSD(), payload, 2782// static
2783 LLPanelEstateCovenant::confirmChangeCovenantCallback); 2783void LLPanelEstateInfo::onClickMessageEstate(void* userdata)
2784 } 2784{
2785 break; 2785 llinfos << "LLPanelEstateInfo::onClickMessageEstate" << llendl;
2786 default: 2786 LLNotifications::instance().add("MessageEstate", LLSD(), LLSD(), boost::bind(&LLPanelEstateInfo::onMessageCommit, (LLPanelEstateInfo*)userdata, _1, _2));
2787 *accept = ACCEPT_NO; 2787}
2788 break; 2788
2789 } 2789bool LLPanelEstateInfo::onMessageCommit(const LLSD& notification, const LLSD& response)
2790 2790{
2791 return TRUE; 2791 S32 option = LLNotification::getSelectedOption(notification, response);
2792} 2792 std::string text = response["message"].asString();
2793 2793 if(option != 0) return false;
2794// static 2794 if(text.empty()) return false;
2795bool LLPanelEstateCovenant::confirmChangeCovenantCallback(const LLSD& notification, const LLSD& response) 2795 llinfos << "Message to everyone: " << text << llendl;
2796{ 2796 strings_t strings;
2797 S32 option = LLNotification::getSelectedOption(notification, response); 2797 //integers_t integers;
2798 LLInventoryItem* item = gInventory.getItem(notification["payload"]["item_id"].asUUID()); 2798 std::string name;
2799 LLPanelEstateCovenant* self = LLFloaterRegionInfo::getPanelCovenant(); 2799 gAgent.buildFullname(name);
2800 2800 strings.push_back(strings_t::value_type(name));
2801 if (!item || !self) return false; 2801 strings.push_back(strings_t::value_type(text));
2802 2802 LLUUID invoice(LLFloaterRegionInfo::getLastInvoice());
2803 switch(option) 2803 sendEstateOwnerMessage(gMessageSystem, "instantmessage", invoice, strings);
2804 { 2804 return false;
2805 case 0: 2805}
2806 self->loadInvItem(item); 2806
2807 break; 2807LLPanelEstateCovenant::LLPanelEstateCovenant()
2808 default: 2808: mCovenantID(LLUUID::null)
2809 break; 2809{
2810 } 2810}
2811 return false; 2811
2812} 2812// virtual
2813 2813bool LLPanelEstateCovenant::refreshFromRegion(LLViewerRegion* region)
2814// static 2814{
2815void LLPanelEstateCovenant::resetCovenantID(void* userdata) 2815 LLTextBox* region_name = getChild<LLTextBox>("region_name_text");
2816{ 2816 if (region_name)
2817 LLNotifications::instance().add("EstateChangeCovenant", LLSD(), LLSD(), confirmResetCovenantCallback); 2817 {
2818} 2818 region_name->setText(region->getName());
2819 2819 }
2820// static 2820
2821bool LLPanelEstateCovenant::confirmResetCovenantCallback(const LLSD& notification, const LLSD& response) 2821 LLTextBox* resellable_clause = getChild<LLTextBox>("resellable_clause");
2822{ 2822 if (resellable_clause)
2823 LLPanelEstateCovenant* self = LLFloaterRegionInfo::getPanelCovenant(); 2823 {
2824 if (!self) return false; 2824 if (region->getRegionFlags() & REGION_FLAGS_BLOCK_LAND_RESELL)
2825 2825 {
2826 S32 option = LLNotification::getSelectedOption(notification, response); 2826 resellable_clause->setText(getString("can_not_resell"));
2827 switch(option) 2827 }
2828 { 2828 else
2829 case 0: 2829 {
2830 self->loadInvItem(NULL); 2830 resellable_clause->setText(getString("can_resell"));
2831 break; 2831 }
2832 default: 2832 }
2833 break; 2833
2834 } 2834 LLTextBox* changeable_clause = getChild<LLTextBox>("changeable_clause");
2835 return false; 2835 if (changeable_clause)
2836} 2836 {
2837 2837 if (region->getRegionFlags() & REGION_FLAGS_ALLOW_PARCEL_CHANGES)
2838void LLPanelEstateCovenant::loadInvItem(LLInventoryItem *itemp) 2838 {
2839{ 2839 changeable_clause->setText(getString("can_change"));
2840 const BOOL high_priority = TRUE; 2840 }
2841 if (itemp) 2841 else
2842 { 2842 {
2843 gAssetStorage->getInvItemAsset(gAgent.getRegionHost(), 2843 changeable_clause->setText(getString("can_not_change"));
2844 gAgent.getID(), 2844 }
2845 gAgent.getSessionID(), 2845 }
2846 itemp->getPermissions().getOwner(), 2846
2847 LLUUID::null, 2847 LLTextBox* region_maturity = getChild<LLTextBox>("region_maturity_text");
2848 itemp->getUUID(), 2848 if (region_maturity)
2849 itemp->getAssetUUID(), 2849 {
2850 itemp->getType(), 2850 region_maturity->setText(region->getSimAccessString());
2851 onLoadComplete, 2851 }
2852 (void*)this, 2852
2853 high_priority); 2853 LLTextBox* region_landtype = getChild<LLTextBox>("region_landtype_text");
2854 mAssetStatus = ASSET_LOADING; 2854 if (region_landtype)
2855 } 2855 {
2856 else 2856 region_landtype->setText(region->getSimProductName());
2857 { 2857 }
2858 mAssetStatus = ASSET_LOADED; 2858
2859 setCovenantTextEditor("There is no Covenant provided for this Estate."); 2859
2860 sendChangeCovenantID(LLUUID::null); 2860 // let the parent class handle the general data collection.
2861 } 2861 bool rv = LLPanelRegionInfo::refreshFromRegion(region);
2862} 2862 LLMessageSystem *msg = gMessageSystem;
2863 2863 msg->newMessage("EstateCovenantRequest");
2864// static 2864 msg->nextBlockFast(_PREHASH_AgentData);
2865void LLPanelEstateCovenant::onLoadComplete(LLVFS *vfs, 2865 msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
2866 const LLUUID& asset_uuid, 2866 msg->addUUIDFast(_PREHASH_SessionID,gAgent.getSessionID());
2867 LLAssetType::EType type, 2867 msg->sendReliable(region->getHost());
2868 void* user_data, S32 status, LLExtStat ext_status) 2868 return rv;
2869{ 2869}
2870 llinfos << "LLPanelEstateCovenant::onLoadComplete()" << llendl; 2870
2871 LLPanelEstateCovenant* panelp = (LLPanelEstateCovenant*)user_data; 2871// virtual
2872 if( panelp ) 2872bool LLPanelEstateCovenant::estateUpdate(LLMessageSystem* msg)
2873 { 2873{
2874 if(0 == status) 2874 llinfos << "LLPanelEstateCovenant::estateUpdate()" << llendl;
2875 { 2875 return true;
2876 LLVFile file(vfs, asset_uuid, type, LLVFile::READ); 2876}
2877 2877
2878 S32 file_length = file.getSize(); 2878// virtual
2879 2879BOOL LLPanelEstateCovenant::postBuild()
2880 char* buffer = new char[file_length+1]; 2880{
2881 if (buffer == NULL) 2881 initHelpBtn("covenant_help", "HelpEstateCovenant");
2882 { 2882 mEstateNameText = getChild<LLTextBox>("estate_name_text");
2883 llerrs << "Memory Allocation Failed" << llendl; 2883 mEstateOwnerText = getChild<LLTextBox>("estate_owner_text");
2884 return; 2884 mLastModifiedText = getChild<LLTextBox>("covenant_timestamp_text");
2885 } 2885 mEditor = getChild<LLViewerTextEditor>("covenant_editor");
2886 2886 if (mEditor) mEditor->setHandleEditKeysDirectly(TRUE);
2887 file.read((U8*)buffer, file_length); /* Flawfinder: ignore */ 2887 LLButton* reset_button = getChild<LLButton>("reset_covenant");
2888 // put a EOS at the end 2888 reset_button->setEnabled(gAgent.canManageEstate());
2889 buffer[file_length] = 0; 2889 reset_button->setClickedCallback(LLPanelEstateCovenant::resetCovenantID, NULL);
2890 2890
2891 if( (file_length > 19) && !strncmp( buffer, "Linden text version", 19 ) ) 2891 return LLPanelRegionInfo::postBuild();
2892 { 2892}
2893 if( !panelp->mEditor->importBuffer( buffer, file_length+1 ) ) 2893
2894 { 2894// virtual
2895 llwarns << "Problem importing estate covenant." << llendl; 2895void LLPanelEstateCovenant::updateChild(LLUICtrl* child_ctrl)
2896 LLNotifications::instance().add("ProblemImportingEstateCovenant"); 2896{
2897 } 2897}
2898 else 2898
2899 { 2899// virtual
2900 panelp->sendChangeCovenantID(asset_uuid); 2900BOOL LLPanelEstateCovenant::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop,
2901 } 2901 EDragAndDropType cargo_type,
2902 } 2902 void* cargo_data,
2903 else 2903 EAcceptance* accept,
2904 { 2904 std::string& tooltip_msg)
2905 // Version 0 (just text, doesn't include version number) 2905{
2906 panelp->sendChangeCovenantID(asset_uuid); 2906 LLInventoryItem* item = (LLInventoryItem*)cargo_data;
2907 } 2907
2908 delete[] buffer; 2908 if (!gAgent.canManageEstate())
2909 } 2909 {
2910 else 2910 *accept = ACCEPT_NO;
2911 { 2911 return TRUE;
2912 LLViewerStats::getInstance()->incStat( LLViewerStats::ST_DOWNLOAD_FAILED ); 2912 }
2913 2913
2914 if( LL_ERR_ASSET_REQUEST_NOT_IN_DATABASE == status || 2914 switch(cargo_type)
2915 LL_ERR_FILE_EMPTY == status) 2915 {
2916 { 2916 case DAD_NOTECARD:
2917 LLNotifications::instance().add("MissingNotecardAssetID"); 2917 *accept = ACCEPT_YES_COPY_SINGLE;
2918 } 2918 if (item && drop)
2919 else if (LL_ERR_INSUFFICIENT_PERMISSIONS == status) 2919 {
2920 { 2920 LLSD payload;
2921 LLNotifications::instance().add("NotAllowedToViewNotecard"); 2921 payload["item_id"] = item->getUUID();
2922 } 2922 LLNotifications::instance().add("EstateChangeCovenant", LLSD(), payload,
2923 else 2923 LLPanelEstateCovenant::confirmChangeCovenantCallback);
2924 { 2924 }
2925 LLNotifications::instance().add("UnableToLoadNotecardAsset"); 2925 break;
2926 } 2926 default:
2927 2927 *accept = ACCEPT_NO;
2928 llwarns << "Problem loading notecard: " << status << llendl; 2928 break;
2929 } 2929 }
2930 panelp->mAssetStatus = ASSET_LOADED; 2930
2931 panelp->setCovenantID(asset_uuid); 2931 return TRUE;
2932 } 2932}
2933} 2933
2934 2934// static
2935// key = "estatechangecovenantid" 2935bool LLPanelEstateCovenant::confirmChangeCovenantCallback(const LLSD& notification, const LLSD& response)
2936// strings[0] = str(estate_id) (added by simulator before relay - not here) 2936{
2937// strings[1] = str(covenant_id) 2937 S32 option = LLNotification::getSelectedOption(notification, response);
2938void LLPanelEstateCovenant::sendChangeCovenantID(const LLUUID &asset_id) 2938 LLInventoryItem* item = gInventory.getItem(notification["payload"]["item_id"].asUUID());
2939{ 2939 LLPanelEstateCovenant* self = LLFloaterRegionInfo::getPanelCovenant();
2940 if (asset_id != getCovenantID()) 2940
2941 { 2941 if (!item || !self) return false;
2942 setCovenantID(asset_id); 2942
2943 2943 switch(option)
2944 LLMessageSystem* msg = gMessageSystem; 2944 {
2945 msg->newMessage("EstateOwnerMessage"); 2945 case 0:
2946 msg->nextBlockFast(_PREHASH_AgentData); 2946 self->loadInvItem(item);
2947 msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); 2947 break;
2948 msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); 2948 default:
2949 msg->addUUIDFast(_PREHASH_TransactionID, LLUUID::null); //not used 2949 break;
2950 2950 }
2951 msg->nextBlock("MethodData"); 2951 return false;
2952 msg->addString("Method", "estatechangecovenantid"); 2952}
2953 msg->addUUID("Invoice", LLFloaterRegionInfo::getLastInvoice()); 2953
2954 2954// static
2955 msg->nextBlock("ParamList"); 2955void LLPanelEstateCovenant::resetCovenantID(void* userdata)
2956 msg->addString("Parameter", getCovenantID().asString()); 2956{
2957 gAgent.sendReliableMessage(); 2957 LLNotifications::instance().add("EstateChangeCovenant", LLSD(), LLSD(), confirmResetCovenantCallback);
2958 } 2958}
2959} 2959
2960 2960// static
2961// virtual 2961bool LLPanelEstateCovenant::confirmResetCovenantCallback(const LLSD& notification, const LLSD& response)
2962BOOL LLPanelEstateCovenant::sendUpdate() 2962{
2963{ 2963 LLPanelEstateCovenant* self = LLFloaterRegionInfo::getPanelCovenant();
2964 return TRUE; 2964 if (!self) return false;
2965} 2965
2966 2966 S32 option = LLNotification::getSelectedOption(notification, response);
2967const std::string& LLPanelEstateCovenant::getEstateName() const 2967 switch(option)
2968{ 2968 {
2969 return mEstateNameText->getText(); 2969 case 0:
2970} 2970 self->loadInvItem(NULL);
2971 2971 break;
2972void LLPanelEstateCovenant::setEstateName(const std::string& name) 2972 default:
2973{ 2973 break;
2974 mEstateNameText->setText(name); 2974 }
2975} 2975 return false;
2976 2976}
2977// static 2977
2978void LLPanelEstateCovenant::updateCovenantText(const std::string& string, const LLUUID& asset_id) 2978void LLPanelEstateCovenant::loadInvItem(LLInventoryItem *itemp)
2979{ 2979{
2980 LLPanelEstateCovenant* panelp = LLFloaterRegionInfo::getPanelCovenant(); 2980 const BOOL high_priority = TRUE;
2981 if( panelp ) 2981 if (itemp)
2982 { 2982 {
2983 panelp->mEditor->setText(string); 2983 gAssetStorage->getInvItemAsset(gAgent.getRegionHost(),
2984 panelp->setCovenantID(asset_id); 2984 gAgent.getID(),
2985 } 2985 gAgent.getSessionID(),
2986} 2986 itemp->getPermissions().getOwner(),
2987 2987 LLUUID::null,
2988// static 2988 itemp->getUUID(),
2989void LLPanelEstateCovenant::updateEstateName(const std::string& name) 2989 itemp->getAssetUUID(),
2990{ 2990 itemp->getType(),
2991 LLPanelEstateCovenant* panelp = LLFloaterRegionInfo::getPanelCovenant(); 2991 onLoadComplete,
2992 if( panelp ) 2992 (void*)this,
2993 { 2993 high_priority);
2994 panelp->mEstateNameText->setText(name); 2994 mAssetStatus = ASSET_LOADING;
2995 } 2995 }
2996} 2996 else
2997 2997 {
2998// static 2998 mAssetStatus = ASSET_LOADED;
2999void LLPanelEstateCovenant::updateLastModified(const std::string& text) 2999 setCovenantTextEditor("There is no Covenant provided for this Estate.");
3000{ 3000 sendChangeCovenantID(LLUUID::null);
3001 LLPanelEstateCovenant* panelp = LLFloaterRegionInfo::getPanelCovenant(); 3001 }
3002 if( panelp ) 3002}
3003 { 3003
3004 panelp->mLastModifiedText->setText(text); 3004// static
3005 } 3005void LLPanelEstateCovenant::onLoadComplete(LLVFS *vfs,
3006} 3006 const LLUUID& asset_uuid,
3007 3007 LLAssetType::EType type,
3008// static 3008 void* user_data, S32 status, LLExtStat ext_status)
3009void LLPanelEstateCovenant::updateEstateOwnerName(const std::string& name) 3009{
3010{ 3010 llinfos << "LLPanelEstateCovenant::onLoadComplete()" << llendl;
3011 LLPanelEstateCovenant* panelp = LLFloaterRegionInfo::getPanelCovenant(); 3011 LLPanelEstateCovenant* panelp = (LLPanelEstateCovenant*)user_data;
3012 if( panelp ) 3012 if( panelp )
3013 { 3013 {
3014 panelp->mEstateOwnerText->setText(name); 3014 if(0 == status)
3015 } 3015 {
3016} 3016 LLVFile file(vfs, asset_uuid, type, LLVFile::READ);
3017 3017
3018const std::string& LLPanelEstateCovenant::getOwnerName() const 3018 S32 file_length = file.getSize();
3019{ 3019
3020 return mEstateOwnerText->getText(); 3020 char* buffer = new char[file_length+1];
3021} 3021 if (buffer == NULL)
3022 3022 {
3023void LLPanelEstateCovenant::setOwnerName(const std::string& name) 3023 llerrs << "Memory Allocation Failed" << llendl;
3024{ 3024 return;
3025 mEstateOwnerText->setText(name); 3025 }
3026} 3026
3027 3027 file.read((U8*)buffer, file_length); /* Flawfinder: ignore */
3028void LLPanelEstateCovenant::setCovenantTextEditor(const std::string& text) 3028 // put a EOS at the end
3029{ 3029 buffer[file_length] = 0;
3030 mEditor->setText(text); 3030
3031} 3031 if( (file_length > 19) && !strncmp( buffer, "Linden text version", 19 ) )
3032 3032 {
3033// key = "estateupdateinfo" 3033 if( !panelp->mEditor->importBuffer( buffer, file_length+1 ) )
3034// strings[0] = estate name 3034 {
3035// strings[1] = str(owner_id) 3035 llwarns << "Problem importing estate covenant." << llendl;
3036// strings[2] = str(estate_id) 3036 LLNotifications::instance().add("ProblemImportingEstateCovenant");
3037// strings[3] = str(estate_flags) 3037 }
3038// strings[4] = str((S32)(sun_hour * 1024)) 3038 else
3039// strings[5] = str(parent_estate_id) 3039 {
3040// strings[6] = str(covenant_id) 3040 panelp->sendChangeCovenantID(asset_uuid);
3041// strings[7] = str(covenant_timestamp) 3041 }
3042// strings[8] = str(send_to_agent_only) 3042 }
3043// strings[9] = str(abuse_email_addr) 3043 else
3044bool LLDispatchEstateUpdateInfo::operator()( 3044 {
3045 const LLDispatcher* dispatcher, 3045 // Version 0 (just text, doesn't include version number)
3046 const std::string& key, 3046 panelp->sendChangeCovenantID(asset_uuid);
3047 const LLUUID& invoice, 3047 }
3048 const sparam_t& strings) 3048 delete[] buffer;
3049{ 3049 }
3050 LLPanelEstateInfo* panel = LLFloaterRegionInfo::getPanelEstate(); 3050 else
3051 if (!panel) return true; 3051 {
3052 3052 LLViewerStats::getInstance()->incStat( LLViewerStats::ST_DOWNLOAD_FAILED );
3053 // NOTE: LLDispatcher extracts strings with an extra \0 at the 3053
3054 // end. If we pass the std::string direct to the UI/renderer 3054 if( LL_ERR_ASSET_REQUEST_NOT_IN_DATABASE == status ||
3055 // it draws with a weird character at the end of the string. 3055 LL_ERR_FILE_EMPTY == status)
3056 std::string estate_name = strings[0].c_str(); // preserve c_str() call! 3056 {
3057 panel->setEstateName(estate_name); 3057 LLNotifications::instance().add("MissingNotecardAssetID");
3058 3058 }
3059#if ELAR_ENABLED 3059 else if (LL_ERR_INSUFFICIENT_PERMISSIONS == status)
3060 if (strings.size() > 9) 3060 {
3061 { 3061 LLNotifications::instance().add("NotAllowedToViewNotecard");
3062 std::string abuse_email = strings[9].c_str(); // preserve c_str() call! 3062 }
3063 panel->setAbuseEmailAddress(abuse_email); 3063 else
3064 } 3064 {
3065 else 3065 LLNotifications::instance().add("UnableToLoadNotecardAsset");
3066#endif 3066 }
3067 { 3067
3068 panel->setAbuseEmailAddress(panel->getString("email_unsupported")); 3068 llwarns << "Problem loading notecard: " << status << llendl;
3069 } 3069 }
3070 3070 panelp->mAssetStatus = ASSET_LOADED;
3071 LLViewerRegion* regionp = gAgent.getRegion(); 3071 panelp->setCovenantID(asset_uuid);
3072 3072 }
3073 LLUUID owner_id(strings[1]); 3073}
3074 regionp->setOwner(owner_id); 3074
3075 // Update estate owner name in UI 3075// key = "estatechangecovenantid"
3076 const BOOL is_group = FALSE; 3076// strings[0] = str(estate_id) (added by simulator before relay - not here)
3077 gCacheName->get(owner_id, is_group, LLPanelEstateInfo::callbackCacheName); 3077// strings[1] = str(covenant_id)
3078 3078void LLPanelEstateCovenant::sendChangeCovenantID(const LLUUID &asset_id)
3079 U32 estate_id = strtoul(strings[2].c_str(), NULL, 10); 3079{
3080 panel->setEstateID(estate_id); 3080 if (asset_id != getCovenantID())
3081 3081 {
3082 U32 flags = strtoul(strings[3].c_str(), NULL, 10); 3082 setCovenantID(asset_id);
3083 panel->setEstateFlags(flags); 3083
3084 3084 LLMessageSystem* msg = gMessageSystem;
3085 F32 sun_hour = ((F32)(strtod(strings[4].c_str(), NULL)))/1024.0f; 3085 msg->newMessage("EstateOwnerMessage");
3086 if(sun_hour == 0 && (flags & REGION_FLAGS_SUN_FIXED ? FALSE : TRUE)) 3086 msg->nextBlockFast(_PREHASH_AgentData);
3087 { 3087 msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
3088 panel->setGlobalTime(TRUE); 3088 msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
3089 } 3089 msg->addUUIDFast(_PREHASH_TransactionID, LLUUID::null); //not used
3090 else 3090
3091 { 3091 msg->nextBlock("MethodData");
3092 panel->setGlobalTime(FALSE); 3092 msg->addString("Method", "estatechangecovenantid");
3093 panel->setSunHour(sun_hour); 3093 msg->addUUID("Invoice", LLFloaterRegionInfo::getLastInvoice());
3094 } 3094
3095 3095 msg->nextBlock("ParamList");
3096 bool visible_from_mainland = (bool)(flags & REGION_FLAGS_EXTERNALLY_VISIBLE); 3096 msg->addString("Parameter", getCovenantID().asString());
3097 bool god = gAgent.isGodlike(); 3097 gAgent.sendReliableMessage();
3098 bool linden_estate = (estate_id <= ESTATE_LAST_LINDEN); 3098 }
3099 3099}
3100 // If visible from mainland, disable the access allowed 3100
3101 // UI, as anyone can teleport there. 3101// virtual
3102 // However, gods need to be able to edit the access list for 3102BOOL LLPanelEstateCovenant::sendUpdate()
3103 // linden estates, regardless of visibility, to allow object 3103{
3104 // and L$ transfers. 3104 return TRUE;
3105 bool enable_agent = (!visible_from_mainland || (god && linden_estate)); 3105}
3106 bool enable_group = enable_agent; 3106
3107 bool enable_ban = !linden_estate; 3107const std::string& LLPanelEstateCovenant::getEstateName() const
3108 panel->setAccessAllowedEnabled(enable_agent, enable_group, enable_ban); 3108{
3109 3109 return mEstateNameText->getText();
3110 return true; 3110}
3111} 3111
3112 3112void LLPanelEstateCovenant::setEstateName(const std::string& name)
3113 3113{
3114// key = "setaccess" 3114 mEstateNameText->setText(name);
3115// strings[0] = str(estate_id) 3115}
3116// strings[1] = str(packed_access_lists) 3116
3117// strings[2] = str(num allowed agent ids) 3117// static
3118// strings[3] = str(num allowed group ids) 3118void LLPanelEstateCovenant::updateCovenantText(const std::string& string, const LLUUID& asset_id)
3119// strings[4] = str(num banned agent ids) 3119{
3120// strings[5] = str(num estate manager agent ids) 3120 LLPanelEstateCovenant* panelp = LLFloaterRegionInfo::getPanelCovenant();
3121// strings[6] = bin(uuid) 3121 if( panelp )
3122// strings[7] = bin(uuid) 3122 {
3123// strings[8] = bin(uuid) 3123 panelp->mEditor->setText(string);
3124// ... 3124 panelp->setCovenantID(asset_id);
3125bool LLDispatchSetEstateAccess::operator()( 3125 }
3126 const LLDispatcher* dispatcher, 3126}
3127 const std::string& key, 3127
3128 const LLUUID& invoice, 3128// static
3129 const sparam_t& strings) 3129void LLPanelEstateCovenant::updateEstateName(const std::string& name)
3130{ 3130{
3131 LLPanelEstateInfo* panel = LLFloaterRegionInfo::getPanelEstate(); 3131 LLPanelEstateCovenant* panelp = LLFloaterRegionInfo::getPanelCovenant();
3132 if (!panel) return true; 3132 if( panelp )
3133 3133 {
3134 S32 index = 1; // skip estate_id 3134 panelp->mEstateNameText->setText(name);
3135 U32 access_flags = strtoul(strings[index++].c_str(), NULL,10); 3135 }
3136 S32 num_allowed_agents = strtol(strings[index++].c_str(), NULL, 10); 3136}
3137 S32 num_allowed_groups = strtol(strings[index++].c_str(), NULL, 10); 3137
3138 S32 num_banned_agents = strtol(strings[index++].c_str(), NULL, 10); 3138// static
3139 S32 num_estate_managers = strtol(strings[index++].c_str(), NULL, 10); 3139void LLPanelEstateCovenant::updateLastModified(const std::string& text)
3140 3140{
3141 // sanity ckecks 3141 LLPanelEstateCovenant* panelp = LLFloaterRegionInfo::getPanelCovenant();
3142 if (num_allowed_agents > 0 3142 if( panelp )
3143 && !(access_flags & ESTATE_ACCESS_ALLOWED_AGENTS)) 3143 {
3144 { 3144 panelp->mLastModifiedText->setText(text);
3145 llwarns << "non-zero count for allowed agents, but no corresponding flag" << llendl; 3145 }
3146 } 3146}
3147 if (num_allowed_groups > 0 3147
3148 && !(access_flags & ESTATE_ACCESS_ALLOWED_GROUPS)) 3148// static
3149 { 3149void LLPanelEstateCovenant::updateEstateOwnerName(const std::string& name)
3150 llwarns << "non-zero count for allowed groups, but no corresponding flag" << llendl; 3150{
3151 } 3151 LLPanelEstateCovenant* panelp = LLFloaterRegionInfo::getPanelCovenant();
3152 if (num_banned_agents > 0 3152 if( panelp )
3153 && !(access_flags & ESTATE_ACCESS_BANNED_AGENTS)) 3153 {
3154 { 3154 panelp->mEstateOwnerText->setText(name);
3155 llwarns << "non-zero count for banned agents, but no corresponding flag" << llendl; 3155 }
3156 } 3156}
3157 if (num_estate_managers > 0 3157
3158 && !(access_flags & ESTATE_ACCESS_MANAGERS)) 3158const std::string& LLPanelEstateCovenant::getOwnerName() const
3159 { 3159{
3160 llwarns << "non-zero count for managers, but no corresponding flag" << llendl; 3160 return mEstateOwnerText->getText();
3161 } 3161}
3162 3162
3163 // grab the UUID's out of the string fields 3163void LLPanelEstateCovenant::setOwnerName(const std::string& name)
3164 if (access_flags & ESTATE_ACCESS_ALLOWED_AGENTS) 3164{
3165 { 3165 mEstateOwnerText->setText(name);
3166 LLNameListCtrl* allowed_agent_name_list; 3166}
3167 allowed_agent_name_list = panel->getChild<LLNameListCtrl>("allowed_avatar_name_list"); 3167
3168 3168void LLPanelEstateCovenant::setCovenantTextEditor(const std::string& text)
3169 int totalAllowedAgents = num_allowed_agents; 3169{
3170 3170 mEditor->setText(text);
3171 if (allowed_agent_name_list) 3171}
3172 { 3172
3173 totalAllowedAgents += allowed_agent_name_list->getItemCount(); 3173// key = "estateupdateinfo"
3174 } 3174// strings[0] = estate name
3175 3175// strings[1] = str(owner_id)
3176 std::string msg = llformat("Allowed residents: (%d, max %d)", 3176// strings[2] = str(estate_id)
3177 totalAllowedAgents, 3177// strings[3] = str(estate_flags)
3178 ESTATE_MAX_ACCESS_IDS); 3178// strings[4] = str((S32)(sun_hour * 1024))
3179 panel->childSetValue("allow_resident_label", LLSD(msg)); 3179// strings[5] = str(parent_estate_id)
3180 3180// strings[6] = str(covenant_id)
3181 if (allowed_agent_name_list) 3181// strings[7] = str(covenant_timestamp)
3182 { 3182// strings[8] = str(send_to_agent_only)
3183 //allowed_agent_name_list->deleteAllItems(); 3183// strings[9] = str(abuse_email_addr)
3184 for (S32 i = 0; i < num_allowed_agents && i < ESTATE_MAX_ACCESS_IDS; i++) 3184bool LLDispatchEstateUpdateInfo::operator()(
3185 { 3185 const LLDispatcher* dispatcher,
3186 LLUUID id; 3186 const std::string& key,
3187 memcpy(id.mData, strings[index++].data(), UUID_BYTES); /* Flawfinder: ignore */ 3187 const LLUUID& invoice,
3188 allowed_agent_name_list->addNameItem(id); 3188 const sparam_t& strings)
3189 } 3189{
3190 panel->childSetEnabled("remove_allowed_avatar_btn", allowed_agent_name_list->getFirstSelected() ? TRUE : FALSE); 3190 LLPanelEstateInfo* panel = LLFloaterRegionInfo::getPanelEstate();
3191 allowed_agent_name_list->sortByColumnIndex(0, TRUE); 3191 if (!panel) return true;
3192 } 3192
3193 } 3193 // NOTE: LLDispatcher extracts strings with an extra \0 at the
3194 3194 // end. If we pass the std::string direct to the UI/renderer
3195 if (access_flags & ESTATE_ACCESS_ALLOWED_GROUPS) 3195 // it draws with a weird character at the end of the string.
3196 { 3196 std::string estate_name = strings[0].c_str(); // preserve c_str() call!
3197 LLNameListCtrl* allowed_group_name_list; 3197 panel->setEstateName(estate_name);
3198 allowed_group_name_list = panel->getChild<LLNameListCtrl>("allowed_group_name_list"); 3198
3199 3199 if (strings.size() > 3)
3200 std::string msg = llformat("Allowed groups: (%d, max %d)", 3200 {
3201 num_allowed_groups, 3201 std::string abuse_email = strings[9].c_str(); // preserve c_str() call!
3202 (S32) ESTATE_MAX_GROUP_IDS); 3202 panel->setAbuseEmailAddress(abuse_email);
3203 panel->childSetValue("allow_group_label", LLSD(msg)); 3203 }
3204 3204 else
3205 if (allowed_group_name_list) 3205 {
3206 { 3206 panel->setAbuseEmailAddress(panel->getString("email_unsupported"));
3207 allowed_group_name_list->deleteAllItems(); 3207 }
3208 for (S32 i = 0; i < num_allowed_groups && i < ESTATE_MAX_GROUP_IDS; i++) 3208
3209 { 3209 LLViewerRegion* regionp = gAgent.getRegion();
3210 LLUUID id; 3210
3211 memcpy(id.mData, strings[index++].data(), UUID_BYTES); /* Flawfinder: ignore */ 3211 LLUUID owner_id(strings[1]);
3212 allowed_group_name_list->addGroupNameItem(id); 3212 regionp->setOwner(owner_id);
3213 } 3213 // Update estate owner name in UI
3214 panel->childSetEnabled("remove_allowed_group_btn", allowed_group_name_list->getFirstSelected() ? TRUE : FALSE); 3214 const BOOL is_group = FALSE;
3215 allowed_group_name_list->sortByColumnIndex(0, TRUE); 3215 gCacheName->get(owner_id, is_group, LLPanelEstateInfo::callbackCacheName);
3216 } 3216
3217 } 3217 U32 estate_id = strtoul(strings[2].c_str(), NULL, 10);
3218 3218 panel->setEstateID(estate_id);
3219 if (access_flags & ESTATE_ACCESS_BANNED_AGENTS) 3219
3220 { 3220 U32 flags = strtoul(strings[3].c_str(), NULL, 10);
3221 LLNameListCtrl* banned_agent_name_list; 3221 panel->setEstateFlags(flags);
3222 banned_agent_name_list = panel->getChild<LLNameListCtrl>("banned_avatar_name_list"); 3222
3223 3223 F32 sun_hour = ((F32)(strtod(strings[4].c_str(), NULL)))/1024.0f;
3224 int totalBannedAgents = num_banned_agents; 3224 if(sun_hour == 0 && (flags & REGION_FLAGS_SUN_FIXED ? FALSE : TRUE))
3225 3225 {
3226 if (banned_agent_name_list) 3226 panel->setGlobalTime(TRUE);
3227 { 3227 }
3228 totalBannedAgents += banned_agent_name_list->getItemCount(); 3228 else
3229 } 3229 {
3230 3230 panel->setGlobalTime(FALSE);
3231 3231 panel->setSunHour(sun_hour);
3232 std::string msg = llformat("Banned residents: (%d, max %d)", 3232 }
3233 totalBannedAgents, 3233
3234 ESTATE_MAX_ACCESS_IDS); 3234 bool visible_from_mainland = (bool)(flags & REGION_FLAGS_EXTERNALLY_VISIBLE);
3235 panel->childSetValue("ban_resident_label", LLSD(msg)); 3235 bool god = gAgent.isGodlike();
3236 3236 bool linden_estate = (estate_id <= ESTATE_LAST_LINDEN);
3237 if (banned_agent_name_list) 3237
3238 { 3238 // If visible from mainland, disable the access allowed
3239 //banned_agent_name_list->deleteAllItems(); 3239 // UI, as anyone can teleport there.
3240 for (S32 i = 0; i < num_banned_agents && i < ESTATE_MAX_ACCESS_IDS; i++) 3240 // However, gods need to be able to edit the access list for
3241 { 3241 // linden estates, regardless of visibility, to allow object
3242 LLUUID id; 3242 // and L$ transfers.
3243 memcpy(id.mData, strings[index++].data(), UUID_BYTES); /* Flawfinder: ignore */ 3243 bool enable_agent = (!visible_from_mainland || (god && linden_estate));
3244 banned_agent_name_list->addNameItem(id); 3244 bool enable_group = enable_agent;
3245 } 3245 bool enable_ban = !linden_estate;
3246 panel->childSetEnabled("remove_banned_avatar_btn", banned_agent_name_list->getFirstSelected() ? TRUE : FALSE); 3246 panel->setAccessAllowedEnabled(enable_agent, enable_group, enable_ban);
3247 banned_agent_name_list->sortByColumnIndex(0, TRUE); 3247
3248 } 3248 return true;
3249 } 3249}
3250 3250
3251 if (access_flags & ESTATE_ACCESS_MANAGERS) 3251
3252 { 3252// key = "setaccess"
3253 std::string msg = llformat("Estate Managers: (%d, max %d)", 3253// strings[0] = str(estate_id)
3254 num_estate_managers, 3254// strings[1] = str(packed_access_lists)
3255 ESTATE_MAX_MANAGERS); 3255// strings[2] = str(num allowed agent ids)
3256 panel->childSetValue("estate_manager_label", LLSD(msg)); 3256// strings[3] = str(num allowed group ids)
3257 3257// strings[4] = str(num banned agent ids)
3258 LLNameListCtrl* estate_manager_name_list = 3258// strings[5] = str(num estate manager agent ids)
3259 panel->getChild<LLNameListCtrl>("estate_manager_name_list"); 3259// strings[6] = bin(uuid)
3260 if (estate_manager_name_list) 3260// strings[7] = bin(uuid)
3261 { 3261// strings[8] = bin(uuid)
3262 estate_manager_name_list->deleteAllItems(); // Clear existing entries 3262// ...
3263 3263bool LLDispatchSetEstateAccess::operator()(
3264 // There should be only ESTATE_MAX_MANAGERS people in the list, but if the database gets more (SL-46107) don't 3264 const LLDispatcher* dispatcher,
3265 // truncate the list unless it's really big. Go ahead and show the extras so the user doesn't get confused, 3265 const std::string& key,
3266 // and they can still remove them. 3266 const LLUUID& invoice,
3267 for (S32 i = 0; i < num_estate_managers && i < (ESTATE_MAX_MANAGERS * 4); i++) 3267 const sparam_t& strings)
3268 { 3268{
3269 LLUUID id; 3269 LLPanelEstateInfo* panel = LLFloaterRegionInfo::getPanelEstate();
3270 memcpy(id.mData, strings[index++].data(), UUID_BYTES); /* Flawfinder: ignore */ 3270 if (!panel) return true;
3271 estate_manager_name_list->addNameItem(id); 3271
3272 } 3272 S32 index = 1; // skip estate_id
3273 panel->childSetEnabled("remove_estate_manager_btn", estate_manager_name_list->getFirstSelected() ? TRUE : FALSE); 3273 U32 access_flags = strtoul(strings[index++].c_str(), NULL,10);
3274 estate_manager_name_list->sortByColumnIndex(0, TRUE); 3274 S32 num_allowed_agents = strtol(strings[index++].c_str(), NULL, 10);
3275 } 3275 S32 num_allowed_groups = strtol(strings[index++].c_str(), NULL, 10);
3276 } 3276 S32 num_banned_agents = strtol(strings[index++].c_str(), NULL, 10);
3277 3277 S32 num_estate_managers = strtol(strings[index++].c_str(), NULL, 10);
3278 return true; 3278
3279} 3279 // sanity ckecks
3280 3280 if (num_allowed_agents > 0
3281// [RLVa:KB] - Checked: 2009-07-04 (RLVa-1.0.0a) 3281 && !(access_flags & ESTATE_ACCESS_ALLOWED_AGENTS))
3282void LLFloaterRegionInfo::open() 3282 {
3283{ 3283 llwarns << "non-zero count for allowed agents, but no corresponding flag" << llendl;
3284 // We'll allow access to the estate tools for estate managers (and for the sim owner) 3284 }
3285 if (gRlvHandler.hasBehaviour(RLV_BHVR_SHOWLOC)) 3285 if (num_allowed_groups > 0
3286 { 3286 && !(access_flags & ESTATE_ACCESS_ALLOWED_GROUPS))
3287 LLViewerRegion* pRegion = gAgent.getRegion(); 3287 {
3288 if (!pRegion) 3288 llwarns << "non-zero count for allowed groups, but no corresponding flag" << llendl;
3289 return; 3289 }
3290 3290 if (num_banned_agents > 0
3291 // Should be able to call LLRegion::canManageEstate() but then we can fake god like 3291 && !(access_flags & ESTATE_ACCESS_BANNED_AGENTS))
3292 if ( (!pRegion->isEstateManager()) && (pRegion->getOwner() != gAgent.getID()) ) 3292 {
3293 return; 3293 llwarns << "non-zero count for banned agents, but no corresponding flag" << llendl;
3294 } 3294 }
3295 3295 if (num_estate_managers > 0
3296 LLFloater::open(); 3296 && !(access_flags & ESTATE_ACCESS_MANAGERS))
3297} 3297 {
3298// [/RLVa:KB] 3298 llwarns << "non-zero count for managers, but no corresponding flag" << llendl;
3299 }
3300
3301 // grab the UUID's out of the string fields
3302 if (access_flags & ESTATE_ACCESS_ALLOWED_AGENTS)
3303 {
3304 LLNameListCtrl* allowed_agent_name_list;
3305 allowed_agent_name_list = panel->getChild<LLNameListCtrl>("allowed_avatar_name_list");
3306
3307 int totalAllowedAgents = num_allowed_agents;
3308
3309 if (allowed_agent_name_list)
3310 {
3311 totalAllowedAgents += allowed_agent_name_list->getItemCount();
3312 }
3313
3314 std::string msg = llformat("Allowed residents: (%d, max %d)",
3315 totalAllowedAgents,
3316 ESTATE_MAX_ACCESS_IDS);
3317 panel->childSetValue("allow_resident_label", LLSD(msg));
3318
3319 if (allowed_agent_name_list)
3320 {
3321 //allowed_agent_name_list->deleteAllItems();
3322 for (S32 i = 0; i < num_allowed_agents && i < ESTATE_MAX_ACCESS_IDS; i++)
3323 {
3324 LLUUID id;
3325 memcpy(id.mData, strings[index++].data(), UUID_BYTES); /* Flawfinder: ignore */
3326 allowed_agent_name_list->addNameItem(id);
3327 }
3328 panel->childSetEnabled("remove_allowed_avatar_btn", allowed_agent_name_list->getFirstSelected() ? TRUE : FALSE);
3329 allowed_agent_name_list->sortByColumnIndex(0, TRUE);
3330 }
3331 }
3332
3333 if (access_flags & ESTATE_ACCESS_ALLOWED_GROUPS)
3334 {
3335 LLNameListCtrl* allowed_group_name_list;
3336 allowed_group_name_list = panel->getChild<LLNameListCtrl>("allowed_group_name_list");
3337
3338 std::string msg = llformat("Allowed groups: (%d, max %d)",
3339 num_allowed_groups,
3340 (S32) ESTATE_MAX_GROUP_IDS);
3341 panel->childSetValue("allow_group_label", LLSD(msg));
3342
3343 if (allowed_group_name_list)
3344 {
3345 allowed_group_name_list->deleteAllItems();
3346 for (S32 i = 0; i < num_allowed_groups && i < ESTATE_MAX_GROUP_IDS; i++)
3347 {
3348 LLUUID id;
3349 memcpy(id.mData, strings[index++].data(), UUID_BYTES); /* Flawfinder: ignore */
3350 allowed_group_name_list->addGroupNameItem(id);
3351 }
3352 panel->childSetEnabled("remove_allowed_group_btn", allowed_group_name_list->getFirstSelected() ? TRUE : FALSE);
3353 allowed_group_name_list->sortByColumnIndex(0, TRUE);
3354 }
3355 }
3356
3357 if (access_flags & ESTATE_ACCESS_BANNED_AGENTS)
3358 {
3359 LLNameListCtrl* banned_agent_name_list;
3360 banned_agent_name_list = panel->getChild<LLNameListCtrl>("banned_avatar_name_list");
3361
3362 int totalBannedAgents = num_banned_agents;
3363
3364 if (banned_agent_name_list)
3365 {
3366 totalBannedAgents += banned_agent_name_list->getItemCount();
3367 }
3368
3369
3370 std::string msg = llformat("Banned residents: (%d, max %d)",
3371 totalBannedAgents,
3372 ESTATE_MAX_ACCESS_IDS);
3373 panel->childSetValue("ban_resident_label", LLSD(msg));
3374
3375 if (banned_agent_name_list)
3376 {
3377 //banned_agent_name_list->deleteAllItems();
3378 for (S32 i = 0; i < num_banned_agents && i < ESTATE_MAX_ACCESS_IDS; i++)
3379 {
3380 LLUUID id;
3381 memcpy(id.mData, strings[index++].data(), UUID_BYTES); /* Flawfinder: ignore */
3382 banned_agent_name_list->addNameItem(id);
3383 }
3384 panel->childSetEnabled("remove_banned_avatar_btn", banned_agent_name_list->getFirstSelected() ? TRUE : FALSE);
3385 banned_agent_name_list->sortByColumnIndex(0, TRUE);
3386 }
3387 }
3388
3389 if (access_flags & ESTATE_ACCESS_MANAGERS)
3390 {
3391 std::string msg = llformat("Estate Managers: (%d, max %d)",
3392 num_estate_managers,
3393 ESTATE_MAX_MANAGERS);
3394 panel->childSetValue("estate_manager_label", LLSD(msg));
3395
3396 LLNameListCtrl* estate_manager_name_list =
3397 panel->getChild<LLNameListCtrl>("estate_manager_name_list");
3398 if (estate_manager_name_list)
3399 {
3400 estate_manager_name_list->deleteAllItems(); // Clear existing entries
3401
3402 // There should be only ESTATE_MAX_MANAGERS people in the list, but if the database gets more (SL-46107) don't
3403 // truncate the list unless it's really big. Go ahead and show the extras so the user doesn't get confused,
3404 // and they can still remove them.
3405 for (S32 i = 0; i < num_estate_managers && i < (ESTATE_MAX_MANAGERS * 4); i++)
3406 {
3407 LLUUID id;
3408 memcpy(id.mData, strings[index++].data(), UUID_BYTES); /* Flawfinder: ignore */
3409 estate_manager_name_list->addNameItem(id);
3410 }
3411 panel->childSetEnabled("remove_estate_manager_btn", estate_manager_name_list->getFirstSelected() ? TRUE : FALSE);
3412 estate_manager_name_list->sortByColumnIndex(0, TRUE);
3413 }
3414 }
3415
3416 return true;
3417}
3418
3419// [RLVa:KB] - Checked: 2009-07-04 (RLVa-1.0.0a)
3420void LLFloaterRegionInfo::open()
3421{
3422 // We'll allow access to the estate tools for estate managers (and for the sim owner)
3423 if (gRlvHandler.hasBehaviour(RLV_BHVR_SHOWLOC))
3424 {
3425 LLViewerRegion* pRegion = gAgent.getRegion();
3426 if (!pRegion)
3427 return;
3428
3429 // Should be able to call LLRegion::canManageEstate() but then we can fake god like
3430 if ( (!pRegion->isEstateManager()) && (pRegion->getOwner() != gAgent.getID()) )
3431 return;
3432 }
3433
3434 LLFloater::open();
3435}
3436// [/RLVa:KB]