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