llfloaterregioninfo.cpp

Go to the documentation of this file.
00001 
00033 #include "llviewerprecompiledheaders.h"
00034 #include "llfloaterregioninfo.h"
00035 
00036 #include <algorithm>
00037 #include <functional>
00038 
00039 #include "llcachename.h"
00040 #include "lldir.h"
00041 #include "lldispatcher.h"
00042 #include "llglheaders.h"
00043 #include "llregionflags.h"
00044 #include "llstl.h"
00045 #include "indra_constants.h"
00046 #include "message.h"
00047 
00048 #include "llagent.h"
00049 #include "llalertdialog.h"
00050 #include "llfloateravatarpicker.h"
00051 #include "llbutton.h" 
00052 #include "llcheckboxctrl.h"
00053 #include "llcombobox.h"
00054 #include "llfilepicker.h"
00055 #include "llfloatergodtools.h"  // for send_sim_wide_deletes()
00056 #include "llfloatertopobjects.h" // added to fix SL-32336
00057 #include "llfloatergroups.h"
00058 #include "llfloatertelehub.h"
00059 #include "lllineeditor.h"
00060 #include "llalertdialog.h"
00061 #include "llnamelistctrl.h"
00062 #include "llsliderctrl.h"
00063 #include "llspinctrl.h"
00064 #include "lltabcontainer.h"
00065 #include "lltextbox.h"
00066 #include "llinventory.h"
00067 #include "lltexturectrl.h"
00068 #include "llviewercontrol.h"
00069 #include "llvieweruictrlfactory.h"
00070 #include "llviewerimage.h"
00071 #include "llviewerimagelist.h"
00072 #include "llviewerregion.h"
00073 #include "llviewerstats.h"
00074 #include "llviewertexteditor.h"
00075 #include "llviewerwindow.h"
00076 #include "llvlcomposition.h"
00077 
00078 const S32 TERRAIN_TEXTURE_COUNT = 4;
00079 const S32 CORNER_COUNT = 4;
00080 
00081 
00085 
00086 /*
00087 class LLDispatchSetEstateOwner : public LLDispatchHandler
00088 {
00089 public:
00090         LLDispatchSetEstateOwner() {}
00091         virtual ~LLDispatchSetEstateOwner() {}
00092         virtual bool operator()(
00093                 const LLDispatcher* dispatcher,
00094                 const std::string& key,
00095                 const sparam_t& strings,
00096                 const iparam_t& integers);
00097 };
00098 */
00099 
00100 class LLDispatchEstateUpdateInfo : public LLDispatchHandler
00101 {
00102 public:
00103         LLDispatchEstateUpdateInfo() {}
00104         virtual ~LLDispatchEstateUpdateInfo() {}
00105         virtual bool operator()(
00106                 const LLDispatcher* dispatcher,
00107                 const std::string& key,
00108                 const LLUUID& invoice,
00109                 const sparam_t& strings);
00110 };
00111 
00112 class LLDispatchSetEstateAccess : public LLDispatchHandler
00113 {
00114 public:
00115         LLDispatchSetEstateAccess() {}
00116         virtual ~LLDispatchSetEstateAccess() {}
00117         virtual bool operator()(
00118                 const LLDispatcher* dispatcher,
00119                 const std::string& key,
00120                 const LLUUID& invoice,
00121                 const sparam_t& strings);
00122 };
00123 
00124 
00125 /*
00126 void unpack_request_params(
00127         LLMessageSystem* msg,
00128         LLDispatcher::sparam_t& strings,
00129         LLDispatcher::iparam_t& integers)
00130 {
00131         char str_buf[MAX_STRING];
00132         S32 str_count = msg->getNumberOfBlocksFast(_PREHASH_StringData);
00133         S32 i;
00134         for (i = 0; i < str_count; ++i)
00135         {
00136                 // we treat the SParam as binary data (since it might be an 
00137                 // LLUUID in compressed form which may have embedded \0's,)
00138                 str_buf[0] = '\0';
00139                 S32 data_size = msg->getSizeFast(_PREHASH_StringData, i, _PREHASH_SParam);
00140                 msg->getBinaryDataFast(_PREHASH_StringData, _PREHASH_SParam,
00141                                                            str_buf, data_size, i, MAX_STRING - 1);
00142                 strings.push_back(std::string(str_buf, data_size));
00143         }
00144 
00145         U32 int_buf;
00146         S32 int_count = msg->getNumberOfBlocksFast(_PREHASH_IntegerData);
00147         for (i = 0; i < int_count; ++i)
00148         {
00149                 msg->getU32("IntegerData", "IParam", int_buf, i);
00150                 integers.push_back(int_buf);
00151         }
00152 }
00153 */
00154 
00155 
00156 
00157 bool estate_dispatch_initialized = false;
00158 
00159 
00163 
00164 LLFloaterRegionInfo* LLFloaterRegionInfo::sInstance = NULL;
00165 //S32 LLFloaterRegionInfo::sRequestSerial = 0;
00166 LLUUID LLFloaterRegionInfo::sRequestInvoice;
00167 
00168 LLFloaterRegionInfo::LLFloaterRegionInfo(const LLRect& rect) :
00169         LLFloater("regioninfo", rect, "Region/Estate")
00170 {
00171         LLRect tr(0, rect.getHeight() - LLFLOATER_HEADER_SIZE, rect.getWidth(), 0);
00172         mTab = new LLTabContainer("tab", tr, LLTabContainer::TOP, NULL,NULL,"");
00173         mTab->setBorderVisible(FALSE);
00174         addChild(mTab);
00175 
00176         // contruct the panels
00177         LLPanel* panel;
00178         panel = new LLPanelRegionGeneralInfo;
00179         mInfoPanels.push_back((LLPanelRegionInfo*)panel);
00180         gUICtrlFactory->buildPanel(panel, "panel_region_general.xml");
00181         mTab->addTabPanel(panel, panel->getLabel(), TRUE);
00182 
00183         panel = new LLPanelRegionDebugInfo;
00184         mInfoPanels.push_back((LLPanelRegionInfo*)panel);
00185         gUICtrlFactory->buildPanel(panel, "panel_region_debug.xml");
00186         mTab->addTabPanel(panel, panel->getLabel(), FALSE);
00187 
00188         panel = new LLPanelRegionTextureInfo;
00189         mInfoPanels.push_back((LLPanelRegionInfo*)panel);
00190         gUICtrlFactory->buildPanel(panel, "panel_region_texture.xml");
00191         mTab->addTabPanel(panel, panel->getLabel(), FALSE);
00192 
00193         panel = new LLPanelRegionTerrainInfo;
00194         mInfoPanels.push_back((LLPanelRegionInfo*)panel);
00195         gUICtrlFactory->buildPanel(panel, "panel_region_terrain.xml");
00196         mTab->addTabPanel(panel, panel->getLabel(), FALSE);
00197 
00198         panel = new LLPanelEstateInfo;
00199         mInfoPanels.push_back((LLPanelRegionInfo*)panel);
00200         gUICtrlFactory->buildPanel(panel, "panel_region_estate.xml");
00201         mTab->addTabPanel(panel, panel->getLabel(), FALSE);
00202 
00203         panel = new LLPanelEstateCovenant;
00204         mInfoPanels.push_back((LLPanelRegionInfo*)panel);
00205         gUICtrlFactory->buildPanel(panel, "panel_region_covenant.xml");
00206         mTab->addTabPanel(panel, panel->getLabel(), FALSE);
00207 
00208 }
00209 
00210 LLFloaterRegionInfo::~LLFloaterRegionInfo()
00211 {
00212         sInstance = NULL;
00213 }
00214 
00215 // static
00216 void LLFloaterRegionInfo::show(LLViewerRegion* region)
00217 {
00218         if (!sInstance)
00219         {
00220                 LLRect rect = gSavedSettings.getRect("FloaterRegionInfo");
00221                 S32 left, top;
00222                 gFloaterView->getNewFloaterPosition(&left, &top);
00223                 rect.translate(left,top);
00224                 sInstance = new LLFloaterRegionInfo(rect);
00225                 gMessageSystem->setHandlerFunc(
00226                         "EstateOwnerMessage", 
00227                         &processEstateOwnerRequest);
00228         }
00229         sInstance->open();              /* Flawfinder: ignore*/
00230         sInstance->refreshFromRegion(region);
00231 
00232         // Must allow anyone to request the RegionInfo data
00233         // so non-owners/non-gods can see the values. 
00234         // Therefore can't use an EstateOwnerMessage JC
00235         LLMessageSystem* msg = gMessageSystem;
00236         msg->newMessage("RequestRegionInfo");
00237         msg->nextBlock("AgentData");
00238         msg->addUUID("AgentID", gAgent.getID());
00239         msg->addUUID("SessionID", gAgent.getSessionID());
00240         gAgent.sendReliableMessage();
00241 
00242 }
00243 
00244 // static
00245 void LLFloaterRegionInfo::show(void*)
00246 {
00247         show(gAgent.getRegion());
00248 }
00249 
00250 // static
00251 LLFloaterRegionInfo* LLFloaterRegionInfo::getInstance()
00252 {
00253         return sInstance;
00254 }
00255 
00256 // static
00257 void LLFloaterRegionInfo::processEstateOwnerRequest(LLMessageSystem* msg,void**)
00258 {
00259         static LLDispatcher dispatch;
00260         if(!sInstance) return;
00261 
00262         if (!estate_dispatch_initialized)
00263         {
00264                 LLPanelEstateInfo::initDispatch(dispatch);
00265         }
00266 
00267         LLTabContainerCommon* tab = LLUICtrlFactory::getTabContainerByName(sInstance, "tab");
00268         if (!tab) return;
00269 
00270         LLPanelEstateInfo* panel = (LLPanelEstateInfo*)LLUICtrlFactory::getPanelByName(tab, "Estate");
00271         if (!panel) return;
00272 
00273         // unpack the message
00274         std::string request;
00275         LLUUID invoice;
00276         LLDispatcher::sparam_t strings;
00277         LLDispatcher::unpackMessage(msg, request, invoice, strings);
00278         if(invoice != getLastInvoice())
00279         {
00280                 llwarns << "Mismatched Estate message: " << request.c_str() << llendl;
00281                 return;
00282         }
00283 
00284         //dispatch the message
00285         dispatch.dispatch(request, invoice, strings);
00286 }
00287 
00288 
00289 // static
00290 void LLFloaterRegionInfo::processRegionInfo(LLMessageSystem* msg)
00291 {
00292         LLPanel* panel;
00293 
00294         llinfos << "LLFloaterRegionInfo::processRegionInfo" << llendl;
00295         if(!sInstance) return;
00296         LLTabContainerCommon* tab = LLUICtrlFactory::getTabContainerByName(sInstance, "tab");
00297         if(!tab) return;
00298 
00299         // extract message
00300         char sim_name[MAX_STRING];              /* Flawfinder: ignore*/
00301         U32 region_flags;
00302         U8 agent_limit;
00303         F32 object_bonus_factor;
00304         U8 sim_access;
00305         F32 water_height;
00306         F32 terrain_raise_limit;
00307         F32 terrain_lower_limit;
00308         BOOL use_estate_sun;
00309         F32 sun_hour;
00310         msg->getString("RegionInfo", "SimName", MAX_STRING, sim_name);
00311         msg->getU32("RegionInfo", "RegionFlags", region_flags);
00312         msg->getU8("RegionInfo", "MaxAgents", agent_limit);
00313         msg->getF32("RegionInfo", "ObjectBonusFactor", object_bonus_factor);
00314         msg->getU8("RegionInfo", "SimAccess", sim_access);
00315         msg->getF32Fast(_PREHASH_RegionInfo, _PREHASH_WaterHeight, water_height);
00316         msg->getF32Fast(_PREHASH_RegionInfo, _PREHASH_TerrainRaiseLimit, terrain_raise_limit);
00317         msg->getF32Fast(_PREHASH_RegionInfo, _PREHASH_TerrainLowerLimit, terrain_lower_limit);
00318         msg->getBOOL("RegionInfo", "UseEstateSun", use_estate_sun);
00319         // actually the "last set" sun hour, not the current sun hour. JC
00320         msg->getF32("RegionInfo", "SunHour", sun_hour);
00321 
00322         // GENERAL PANEL
00323         panel = LLUICtrlFactory::getPanelByName(tab, "General");
00324         if(!panel) return;
00325         panel->childSetValue("region_text", LLSD(sim_name));
00326 
00327         panel->childSetValue("block_terraform_check", (region_flags & REGION_FLAGS_BLOCK_TERRAFORM) ? TRUE : FALSE );
00328         panel->childSetValue("block_fly_check", (region_flags & REGION_FLAGS_BLOCK_FLY) ? TRUE : FALSE );
00329         panel->childSetValue("allow_damage_check", (region_flags & REGION_FLAGS_ALLOW_DAMAGE) ? TRUE : FALSE );
00330         panel->childSetValue("restrict_pushobject", (region_flags & REGION_FLAGS_RESTRICT_PUSHOBJECT) ? TRUE : FALSE );
00331         panel->childSetValue("allow_land_resell_check", (region_flags & REGION_FLAGS_BLOCK_LAND_RESELL) ? FALSE : TRUE );
00332         panel->childSetValue("allow_parcel_changes_check", (region_flags & REGION_FLAGS_ALLOW_PARCEL_CHANGES) ? TRUE : FALSE );
00333         panel->childSetValue("block_parcel_search_check", (region_flags & REGION_FLAGS_BLOCK_PARCEL_SEARCH) ? TRUE : FALSE );
00334         panel->childSetValue("agent_limit_spin", LLSD((F32)agent_limit) );
00335         panel->childSetValue("object_bonus_spin", LLSD(object_bonus_factor) );
00336         panel->childSetValue("access_combo", LLSD(LLViewerRegion::accessToString(sim_access)) );
00337 
00338 
00339         // detect teen grid for maturity
00340         LLViewerRegion* region = gAgent.getRegion();
00341 
00342         U32 parent_estate_id;
00343         msg->getU32("RegionInfo", "ParentEstateID", parent_estate_id);
00344         BOOL teen_grid = (parent_estate_id == 5);  // *TODO add field to estate table and test that
00345         panel->childSetEnabled("access_combo", gAgent.isGodlike() || (region && region->canManageEstate() && !teen_grid));
00346         
00347 
00348         // DEBUG PANEL
00349         panel = LLUICtrlFactory::getPanelByName(tab, "Debug");
00350         if(!panel) return;
00351 
00352         panel->childSetValue("region_text", LLSD(sim_name) );
00353         panel->childSetValue("disable_scripts_check", LLSD((BOOL)(region_flags & REGION_FLAGS_SKIP_SCRIPTS)) );
00354         panel->childSetValue("disable_collisions_check", LLSD((BOOL)(region_flags & REGION_FLAGS_SKIP_COLLISIONS)) );
00355         panel->childSetValue("disable_physics_check", LLSD((BOOL)(region_flags & REGION_FLAGS_SKIP_PHYSICS)) );
00356 
00357         // TERRAIN PANEL
00358         panel = LLUICtrlFactory::getPanelByName(tab, "Terrain");
00359         if(!panel) return;
00360 
00361         panel->childSetValue("region_text", LLSD(sim_name));
00362         panel->childSetValue("water_height_spin", LLSD(water_height));
00363         panel->childSetValue("terrain_raise_spin", LLSD(terrain_raise_limit));
00364         panel->childSetValue("terrain_lower_spin", LLSD(terrain_lower_limit));
00365         panel->childSetValue("use_estate_sun_check", LLSD(use_estate_sun));
00366 
00367         BOOL allow_modify = gAgent.isGodlike() || (region && region->canManageEstate());
00368         panel->childSetValue("fixed_sun_check", LLSD((BOOL)(region_flags & REGION_FLAGS_SUN_FIXED)));
00369         panel->childSetEnabled("fixed_sun_check", allow_modify && !use_estate_sun);
00370         panel->childSetValue("sun_hour_slider", LLSD(sun_hour));
00371         panel->childSetEnabled("sun_hour_slider", allow_modify && !use_estate_sun);
00372 }
00373 
00374 // static
00375 LLPanelEstateInfo* LLFloaterRegionInfo::getPanelEstate()
00376 {
00377         LLFloaterRegionInfo* floater = LLFloaterRegionInfo::getInstance();
00378         if (!floater) return NULL;
00379         LLTabContainerCommon* tab = LLUICtrlFactory::getTabContainerByName(floater, "tab");
00380         if (!tab) return NULL;
00381         LLPanelEstateInfo* panel = (LLPanelEstateInfo*)LLUICtrlFactory::getPanelByName(tab,"Estate");
00382         return panel;
00383 }
00384 
00385 // static
00386 LLPanelEstateCovenant* LLFloaterRegionInfo::getPanelCovenant()
00387 {
00388         LLFloaterRegionInfo* floater = LLFloaterRegionInfo::getInstance();
00389         if (!floater) return NULL;
00390         LLTabContainerCommon* tab = LLUICtrlFactory::getTabContainerByName(floater, "tab");
00391         if (!tab) return NULL;
00392         LLPanelEstateCovenant* panel = (LLPanelEstateCovenant*)LLUICtrlFactory::getPanelByName(tab, "Covenant");
00393         return panel;
00394 }
00395 
00396 void LLFloaterRegionInfo::refreshFromRegion(LLViewerRegion* region)
00397 {
00398         // call refresh from region on all panels
00399         std::for_each(
00400                 mInfoPanels.begin(),
00401                 mInfoPanels.end(),
00402                 llbind2nd(
00403 #if LL_WINDOWS
00404                         std::mem_fun1(&LLPanelRegionInfo::refreshFromRegion),
00405 #else
00406                         std::mem_fun(&LLPanelRegionInfo::refreshFromRegion),
00407 #endif
00408                         region));
00409 }
00410 
00411 
00412 
00416 
00417 //
00418 // LLPanelRegionInfo
00419 //
00420 
00421 // static
00422 void LLPanelRegionInfo::onBtnSet(void* user_data)
00423 {
00424         LLPanelRegionInfo* panel = (LLPanelRegionInfo*)user_data;
00425         if(!panel) return;
00426         if (panel->sendUpdate())
00427         {
00428                 panel->disableButton("apply_btn");
00429         }
00430 }
00431 
00432 //static 
00433 void LLPanelRegionInfo::onChangeChildCtrl(LLUICtrl* ctrl, void* user_data)
00434 {
00435         if (ctrl)
00436         {
00437                 LLPanelRegionInfo* panel = (LLPanelRegionInfo*) ctrl->getParent();
00438                 panel->updateChild(ctrl);
00439         }
00440 }
00441 
00442 // static
00443 // Enables the "set" button if it is not already enabled
00444 void LLPanelRegionInfo::onChangeAnything(LLUICtrl* ctrl, void* user_data)
00445 {
00446         LLPanelRegionInfo* panel = (LLPanelRegionInfo*)user_data;
00447         if(panel)
00448         {
00449                 panel->enableButton("apply_btn");
00450         }
00451 }
00452 
00453 // virtual
00454 BOOL LLPanelRegionInfo::postBuild()
00455 {
00456         childSetAction("apply_btn", onBtnSet, this);
00457         childDisable("apply_btn");
00458         return TRUE;
00459 }
00460 
00461 // virtual 
00462 void LLPanelRegionInfo::updateChild(LLUICtrl* child_ctr)
00463 {
00464 }
00465 
00466 // virtual
00467 bool LLPanelRegionInfo::refreshFromRegion(LLViewerRegion* region)
00468 {
00469         if (region) mHost = region->getHost();
00470         return true;
00471 }
00472 
00473 void LLPanelRegionInfo::sendEstateOwnerMessage(
00474         LLMessageSystem* msg,
00475         const char* request,
00476         const LLUUID& invoice,
00477         const strings_t& strings)
00478 {
00479         llinfos << "Sending estate request '" << request << "'" << llendl;
00480         msg->newMessage("EstateOwnerMessage");
00481         msg->nextBlockFast(_PREHASH_AgentData);
00482         msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
00483         msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
00484         msg->addUUIDFast(_PREHASH_TransactionID, LLUUID::null); //not used
00485         msg->nextBlock("MethodData");
00486         msg->addString("Method", request);
00487         msg->addUUID("Invoice", invoice);
00488         if(strings.empty())
00489         {
00490                 msg->nextBlock("ParamList");
00491                 msg->addString("Parameter", NULL);
00492         }
00493         else
00494         {
00495                 strings_t::const_iterator it = strings.begin();
00496                 strings_t::const_iterator end = strings.end();
00497                 for(; it != end; ++it)
00498                 {
00499                         msg->nextBlock("ParamList");
00500                         msg->addString("Parameter", (*it).c_str());
00501                 }
00502         }
00503         msg->sendReliable(mHost);
00504 }
00505 
00506 void LLPanelRegionInfo::enableButton(const char* btn_name, BOOL enable)
00507 {
00508         childSetEnabled(btn_name, enable);
00509 }
00510 
00511 void LLPanelRegionInfo::disableButton(const char* btn_name)
00512 {
00513         childDisable(btn_name);
00514 }
00515 
00516 void LLPanelRegionInfo::initCtrl(const char* name)
00517 {
00518         childSetCommitCallback(name, onChangeAnything, this);
00519 }
00520 
00521 void LLPanelRegionInfo::initHelpBtn(const char* name, const char* xml_alert)
00522 {
00523         childSetAction(name, onClickHelp, (void*)xml_alert);
00524 }
00525 
00526 // static
00527 void LLPanelRegionInfo::onClickHelp(void* data)
00528 {
00529         const char* xml_alert = (const char*)data;
00530         gViewerWindow->alertXml(xml_alert);
00531 }
00532 
00534 // LLPanelRegionGeneralInfo
00535 //
00536 bool LLPanelRegionGeneralInfo::refreshFromRegion(LLViewerRegion* region)
00537 {
00538         BOOL allow_modify = gAgent.isGodlike() || (region && region->canManageEstate());
00539         setCtrlsEnabled(allow_modify);
00540         childDisable("apply_btn");
00541         childSetEnabled("access_text", allow_modify);
00542         // childSetEnabled("access_combo", allow_modify);
00543         // now set in processRegionInfo for teen grid detection
00544         childSetEnabled("kick_btn", allow_modify);
00545         childSetEnabled("kick_all_btn", allow_modify);
00546         childSetEnabled("im_btn", allow_modify);
00547         childSetEnabled("manage_telehub_btn", allow_modify);
00548 
00549         // Data gets filled in by processRegionInfo
00550 
00551         return LLPanelRegionInfo::refreshFromRegion(region);
00552 }
00553 
00554 BOOL LLPanelRegionGeneralInfo::postBuild()
00555 {
00556         // Enable the "Apply" button if something is changed. JC
00557         initCtrl("block_terraform_check");
00558         initCtrl("block_fly_check");
00559         initCtrl("allow_damage_check");
00560     initCtrl("allow_land_resell_check");
00561         initCtrl("allow_parcel_changes_check");
00562         initCtrl("agent_limit_spin");
00563         initCtrl("object_bonus_spin");
00564         initCtrl("access_combo");
00565         initCtrl("restrict_pushobject");
00566         initCtrl("block_parcel_search_check");
00567 
00568         initHelpBtn("terraform_help",           "HelpRegionBlockTerraform");
00569         initHelpBtn("fly_help",                         "HelpRegionBlockFly");
00570         initHelpBtn("damage_help",                      "HelpRegionAllowDamage");
00571         initHelpBtn("agent_limit_help",         "HelpRegionAgentLimit");
00572         initHelpBtn("object_bonus_help",        "HelpRegionObjectBonus");
00573         initHelpBtn("access_help",                      "HelpRegionMaturity");
00574         initHelpBtn("restrict_pushobject_help",         "HelpRegionRestrictPushObject");
00575         initHelpBtn("land_resell_help", "HelpRegionLandResell");
00576         initHelpBtn("parcel_changes_help", "HelpParcelChanges");
00577         initHelpBtn("parcel_search_help", "HelpRegionSearch");
00578 
00579         childSetAction("kick_btn", onClickKick, this);
00580         childSetAction("kick_all_btn", onClickKickAll, this);
00581         childSetAction("im_btn", onClickMessage, this);
00582         childSetAction("manage_telehub_btn", onClickManageTelehub, this);
00583 
00584         return LLPanelRegionInfo::postBuild();
00585 }
00586 
00587 // static
00588 void LLPanelRegionGeneralInfo::onClickKick(void* userdata)
00589 {
00590         llinfos << "LLPanelRegionGeneralInfo::onClickKick" << llendl;
00591         LLPanelRegionGeneralInfo* panelp = (LLPanelRegionGeneralInfo*)userdata;
00592 
00593         // this depends on the grandparent view being a floater
00594         // in order to set up floater dependency
00595         LLFloater* parent_floater = gFloaterView->getParentFloater(panelp);
00596         LLFloater* child_floater = LLFloaterAvatarPicker::show(onKickCommit, userdata, FALSE, TRUE);
00597         parent_floater->addDependentFloater(child_floater);
00598 }
00599 
00600 // static
00601 void LLPanelRegionGeneralInfo::onKickCommit(const std::vector<std::string>& names, const std::vector<LLUUID>& ids, void* userdata)
00602 {
00603         if (names.empty() || ids.empty()) return;
00604         if(ids[0].notNull())
00605         {
00606                 LLPanelRegionGeneralInfo* self = (LLPanelRegionGeneralInfo*)userdata;
00607                 if(!self) return;
00608                 strings_t strings;
00609                 // [0] = our agent id
00610                 // [1] = target agent id
00611                 char buffer[MAX_STRING];                /* Flawfinder: ignore*/
00612                 gAgent.getID().toString(buffer);
00613                 strings.push_back(buffer);
00614 
00615                 ids[0].toString(buffer);
00616                 strings.push_back(strings_t::value_type(buffer));
00617 
00618                 LLUUID invoice(LLFloaterRegionInfo::getLastInvoice());
00619                 self->sendEstateOwnerMessage(gMessageSystem, "teleporthomeuser", invoice, strings);
00620         }
00621 }
00622 
00623 // static
00624 void LLPanelRegionGeneralInfo::onClickKickAll(void* userdata)
00625 {
00626         llinfos << "LLPanelRegionGeneralInfo::onClickKickAll" << llendl;
00627         gViewerWindow->alertXml("KickUsersFromRegion", onKickAllCommit, userdata);
00628 }
00629 
00630 // static
00631 void LLPanelRegionGeneralInfo::onKickAllCommit(S32 option, void* userdata)
00632 {
00633         if (option == 0)
00634         {
00635                 LLPanelRegionGeneralInfo* self = (LLPanelRegionGeneralInfo*)userdata;
00636                 if(!self) return;
00637                 strings_t strings;
00638                 // [0] = our agent id
00639                 char buffer[MAX_STRING];                /* Flawfinder: ignore*/
00640                 gAgent.getID().toString(buffer);
00641                 strings.push_back(buffer);
00642 
00643                 LLUUID invoice(LLFloaterRegionInfo::getLastInvoice());
00644                 // historical message name
00645                 self->sendEstateOwnerMessage(gMessageSystem, "teleporthomeallusers", invoice, strings);
00646         }
00647 }
00648 
00649 // static
00650 void LLPanelRegionGeneralInfo::onClickMessage(void* userdata)
00651 {
00652         llinfos << "LLPanelRegionGeneralInfo::onClickMessage" << llendl;
00653         gViewerWindow->alertXmlEditText("MessageRegion", LLString::format_map_t(),
00654                                                                         NULL, NULL,
00655                                                                         onMessageCommit, userdata);
00656 }
00657 
00658 // static
00659 void LLPanelRegionGeneralInfo::onMessageCommit(S32 option, const LLString& text, void* userdata)
00660 {
00661         if(option != 0) return;
00662         if(text.empty()) return;
00663         LLPanelRegionGeneralInfo* self = (LLPanelRegionGeneralInfo*)userdata;
00664         if(!self) return;
00665         llinfos << "Message to everyone: " << text << llendl;
00666         strings_t strings;
00667         // [0] grid_x, unused here
00668         // [1] grid_y, unused here
00669         // [2] agent_id of sender
00670         // [3] sender name
00671         // [4] message
00672         strings.push_back("-1");
00673         strings.push_back("-1");
00674         char buffer[MAX_STRING];                /* Flawfinder: ignore*/
00675         gAgent.getID().toString(buffer);
00676         strings.push_back(buffer);
00677         std::string name;
00678         gAgent.buildFullname(name);
00679         strings.push_back(strings_t::value_type(name));
00680         strings.push_back(strings_t::value_type(text));
00681         LLUUID invoice(LLFloaterRegionInfo::getLastInvoice());
00682         self->sendEstateOwnerMessage(gMessageSystem, "simulatormessage", invoice, strings);
00683 }
00684 
00685 // static
00686 void LLPanelRegionGeneralInfo::onClickManageTelehub(void* data)
00687 {
00688         LLFloaterRegionInfo::getInstance()->close();
00689 
00690         LLFloaterTelehub::show();
00691 }
00692 
00693 // setregioninfo
00694 // strings[0] = 'Y' - block terraform, 'N' - not
00695 // strings[1] = 'Y' - block fly, 'N' - not
00696 // strings[2] = 'Y' - allow damage, 'N' - not
00697 // strings[3] = 'Y' - allow land sale, 'N' - not
00698 // strings[4] = agent limit
00699 // strings[5] = object bonus
00700 // strings[6] = sim access (0 = unknown, 13 = PG, 21 = Mature)
00701 // strings[7] = restrict pushobject
00702 // strings[8] = 'Y' - allow parcel subdivide, 'N' - not
00703 // strings[9] = 'Y' - block parcel search, 'N' - allow
00704 BOOL LLPanelRegionGeneralInfo::sendUpdate()
00705 {
00706         llinfos << "LLPanelRegionGeneralInfo::sendUpdate()" << llendl;
00707 
00708         // First try using a Cap.  If that fails use the old method.
00709         LLSD body;
00710         std::string url = gAgent.getRegion()->getCapability("DispatchRegionInfo");
00711         if (!url.empty())
00712         {
00713                 body["block_terraform"] = childGetValue("block_terraform_check");
00714                 body["block_fly"] = childGetValue("block_fly_check");
00715                 body["allow_damage"] = childGetValue("allow_damage_check");
00716                 body["allow_land_resell"] = childGetValue("allow_land_resell_check");
00717                 body["agent_limit"] = childGetValue("agent_limit_spin");
00718                 body["prim_bonus"] = childGetValue("object_bonus_spin");
00719                 body["sim_access"] = LLViewerRegion::stringToAccess(childGetValue("access_combo").asString().c_str());
00720                 body["restrict_pushobject"] = childGetValue("restrict_pushobject");
00721                 body["allow_parcel_changes"] = childGetValue("allow_parcel_changes_check");
00722                 body["block_parcel_search"] = childGetValue("block_parcel_search_check");
00723 
00724                 LLHTTPClient::post(url, body, new LLHTTPClient::Responder());
00725         }
00726         else
00727         {
00728                 strings_t strings;
00729                 char buffer[MAX_STRING];                /* Flawfinder: ignore*/
00730 
00731                 snprintf(buffer, MAX_STRING, "%s", (childGetValue("block_terraform_check").asBoolean() ? "Y" : "N"));                   /* Flawfinder: ignore */
00732                 strings.push_back(strings_t::value_type(buffer));
00733 
00734                 snprintf(buffer, MAX_STRING, "%s", (childGetValue("block_fly_check").asBoolean() ? "Y" : "N"));                 /* Flawfinder: ignore */
00735                 strings.push_back(strings_t::value_type(buffer));
00736 
00737                 snprintf(buffer, MAX_STRING, "%s", (childGetValue("allow_damage_check").asBoolean() ? "Y" : "N"));                      /* Flawfinder: ignore */
00738                 strings.push_back(strings_t::value_type(buffer));
00739 
00740                 snprintf(buffer, MAX_STRING, "%s", (childGetValue("allow_land_resell_check").asBoolean() ? "Y" : "N"));                 /* Flawfinder: ignore */
00741                 strings.push_back(strings_t::value_type(buffer));
00742 
00743                 F32 value = (F32)childGetValue("agent_limit_spin").asReal();
00744                 snprintf(buffer, MAX_STRING, "%f", value);                      /* Flawfinder: ignore */
00745                 strings.push_back(strings_t::value_type(buffer));
00746 
00747                 value = (F32)childGetValue("object_bonus_spin").asReal();
00748                 snprintf(buffer, MAX_STRING, "%f", value);                      /* Flawfinder: ignore */
00749                 strings.push_back(strings_t::value_type(buffer));
00750 
00751                 U8 access = LLViewerRegion::stringToAccess(childGetValue("access_combo").asString().c_str());
00752                 snprintf(buffer, MAX_STRING, "%d", (S32)access);                        /* Flawfinder: ignore */
00753                 strings.push_back(strings_t::value_type(buffer));
00754 
00755                 snprintf(buffer, MAX_STRING, "%s", (childGetValue("restrict_pushobject").asBoolean() ? "Y" : "N"));                     /* Flawfinder: ignore */
00756                 strings.push_back(strings_t::value_type(buffer));
00757 
00758                 snprintf(buffer, MAX_STRING, "%s", (childGetValue("allow_parcel_changes_check").asBoolean() ? "Y" : "N"));                      /* Flawfinder: ignore */
00759                 strings.push_back(strings_t::value_type(buffer));
00760 
00761                 LLUUID invoice(LLFloaterRegionInfo::getLastInvoice());
00762                 sendEstateOwnerMessage(gMessageSystem, "setregioninfo", invoice, strings);
00763 
00764                 LLViewerRegion* region = gAgent.getRegion();
00765                 if (region
00766                         && access != region->getSimAccess() )           /* Flawfinder: ignore */
00767                 {
00768                         gViewerWindow->alertXml("RegionMaturityChange");
00769                 }
00770         }
00771 
00772 
00773         //integers_t integers;
00774 
00775 
00776         return TRUE;
00777 }
00778 
00780 // LLPanelRegionDebugInfo
00782 BOOL LLPanelRegionDebugInfo::postBuild()
00783 {
00784         LLPanelRegionInfo::postBuild();
00785         initCtrl("disable_scripts_check");
00786         initCtrl("disable_collisions_check");
00787         initCtrl("disable_physics_check");
00788 
00789         initHelpBtn("disable_scripts_help",             "HelpRegionDisableScripts");
00790         initHelpBtn("disable_collisions_help",  "HelpRegionDisableCollisions");
00791         initHelpBtn("disable_physics_help",             "HelpRegionDisablePhysics");
00792         initHelpBtn("top_colliders_help",               "HelpRegionTopColliders");
00793         initHelpBtn("top_scripts_help",                 "HelpRegionTopScripts");
00794         initHelpBtn("restart_help",                             "HelpRegionRestart");
00795 
00796         childSetAction("choose_avatar_btn", onClickChooseAvatar, this);
00797         childSetAction("return_scripted_other_land_btn", onClickReturnScriptedOtherLand, this);
00798         childSetAction("return_scripted_all_btn", onClickReturnScriptedAll, this);
00799         childSetAction("top_colliders_btn", onClickTopColliders, this);
00800         childSetAction("top_scripts_btn", onClickTopScripts, this);
00801         childSetAction("restart_btn", onClickRestart, this);
00802         childSetAction("cancel_restart_btn", onClickCancelRestart, this);
00803 
00804         return TRUE;
00805 }
00806 
00807 // virtual
00808 bool LLPanelRegionDebugInfo::refreshFromRegion(LLViewerRegion* region)
00809 {
00810         BOOL allow_modify = gAgent.isGodlike() || (region && region->canManageEstate());
00811         setCtrlsEnabled(allow_modify);
00812         childDisable("apply_btn");
00813 
00814         childSetEnabled("choose_avatar_btn", allow_modify);
00815         childSetEnabled("return_scripted_other_land_btn", allow_modify && !mTargetAvatar.isNull());
00816         childSetEnabled("return_scripted_all_btn", allow_modify && !mTargetAvatar.isNull());
00817         childSetEnabled("top_colliders_btn", allow_modify);
00818         childSetEnabled("top_scripts_btn", allow_modify);
00819         childSetEnabled("restart_btn", allow_modify);
00820         childSetEnabled("cancel_restart_btn", allow_modify);
00821 
00822         return LLPanelRegionInfo::refreshFromRegion(region);
00823 }
00824 
00825 // virtual
00826 BOOL LLPanelRegionDebugInfo::sendUpdate()
00827 {
00828         llinfos << "LLPanelRegionDebugInfo::sendUpdate" << llendl;
00829         strings_t strings;
00830         char buffer[MAX_STRING];                /* Flawfinder: ignore */
00831 
00832         snprintf(buffer, MAX_STRING, "%s", (childGetValue("disable_scripts_check").asBoolean() ? "Y" : "N"));                   /* Flawfinder: ignore */
00833         strings.push_back(buffer);
00834 
00835         snprintf(buffer, MAX_STRING, "%s", (childGetValue("disable_collisions_check").asBoolean() ? "Y" : "N"));                        /* Flawfinder: ignore */
00836         strings.push_back(buffer);
00837 
00838         snprintf(buffer, MAX_STRING, "%s", (childGetValue("disable_physics_check").asBoolean() ? "Y" : "N"));                   /* Flawfinder: ignore */
00839         strings.push_back(buffer);
00840 
00841         LLUUID invoice(LLFloaterRegionInfo::getLastInvoice());
00842         sendEstateOwnerMessage(gMessageSystem, "setregiondebug", invoice, strings);
00843         return TRUE;
00844 }
00845 
00846 void LLPanelRegionDebugInfo::onClickChooseAvatar(void* data)
00847 {
00848         LLFloaterAvatarPicker::show(callbackAvatarID, data, FALSE, TRUE);
00849 }
00850 
00851 // static
00852 void LLPanelRegionDebugInfo::callbackAvatarID(const std::vector<std::string>& names, const std::vector<LLUUID>& ids, void* data)
00853 {
00854         LLPanelRegionDebugInfo* self = (LLPanelRegionDebugInfo*) data;
00855         if (ids.empty() || names.empty()) return;
00856         self->mTargetAvatar = ids[0];
00857         self->childSetValue("target_avatar_name", LLSD(names[0]));
00858         self->refreshFromRegion( gAgent.getRegion() );
00859 }
00860 
00861 // static
00862 void LLPanelRegionDebugInfo::onClickReturnScriptedOtherLand(void* data)
00863 {
00864         LLPanelRegionDebugInfo* panelp = (LLPanelRegionDebugInfo*) data;
00865         if (panelp->mTargetAvatar.isNull()) return;
00866 
00867         LLString::format_map_t args;
00868         args["[USER_NAME]"] = panelp->childGetValue("target_avatar_name").asString();
00869         gViewerWindow->alertXml("ReturnScriptedOnOthersLand", args, callbackReturnScriptedOtherLand, data);
00870 }
00871 
00872 // static
00873 void LLPanelRegionDebugInfo::callbackReturnScriptedOtherLand( S32 option, void* userdata )
00874 {
00875         if (option != 0) return;
00876 
00877         LLPanelRegionDebugInfo* self = (LLPanelRegionDebugInfo*) userdata;
00878         if (!self->mTargetAvatar.isNull())
00879         {
00880                 U32 flags = 0;
00881                 flags = flags | SWD_OTHERS_LAND_ONLY;
00882                 flags = flags | SWD_ALWAYS_RETURN_OBJECTS;
00883                 flags |= SWD_SCRIPTED_ONLY;
00884 
00885                 send_sim_wide_deletes(self->mTargetAvatar, flags);
00886         }
00887 }
00888 
00889 // static
00890 void LLPanelRegionDebugInfo::onClickReturnScriptedAll(void* data)
00891 {
00892         LLPanelRegionDebugInfo* panelp = (LLPanelRegionDebugInfo*) data;
00893         if (panelp->mTargetAvatar.isNull()) return;
00894         
00895         
00896         LLString::format_map_t args;
00897         args["[USER_NAME]"] = panelp->childGetValue("target_avatar_name").asString();
00898         gViewerWindow->alertXml("ReturnScriptedOnAllLand", args, callbackReturnScriptedAll, data);
00899 }
00900 
00901 // static
00902 void LLPanelRegionDebugInfo::callbackReturnScriptedAll( S32 option, void* userdata )
00903 {
00904         if (option != 0) return;
00905 
00906         LLPanelRegionDebugInfo* self = (LLPanelRegionDebugInfo*) userdata;
00907         if (!self->mTargetAvatar.isNull())
00908         {
00909                 U32 flags = 0;
00910                 flags |= SWD_ALWAYS_RETURN_OBJECTS;
00911                 flags |= SWD_SCRIPTED_ONLY;
00912 
00913                 send_sim_wide_deletes(self->mTargetAvatar, flags);
00914         }
00915 }
00916 
00917 // static
00918 void LLPanelRegionDebugInfo::onClickTopColliders(void* data)
00919 {
00920         LLPanelRegionDebugInfo* self = (LLPanelRegionDebugInfo*)data;
00921         strings_t strings;
00922         strings.push_back("1"); // one physics step
00923         LLUUID invoice(LLFloaterRegionInfo::getLastInvoice());
00924         LLFloaterTopObjects::show();
00925         LLFloaterTopObjects::clearList();
00926         self->sendEstateOwnerMessage(gMessageSystem, "colliders", invoice, strings);
00927 }
00928 
00929 // static
00930 void LLPanelRegionDebugInfo::onClickTopScripts(void* data)
00931 {
00932         LLPanelRegionDebugInfo* self = (LLPanelRegionDebugInfo*)data;
00933         strings_t strings;
00934         strings.push_back("6"); // top 5 scripts
00935         LLUUID invoice(LLFloaterRegionInfo::getLastInvoice());
00936         LLFloaterTopObjects::show();
00937         LLFloaterTopObjects::clearList();
00938         self->sendEstateOwnerMessage(gMessageSystem, "scripts", invoice, strings);
00939 }
00940 
00941 // static
00942 void LLPanelRegionDebugInfo::onClickRestart(void* data)
00943 {
00944         gViewerWindow->alertXml("ConfirmRestart", callbackRestart, data);
00945 }
00946 
00947 // static
00948 void LLPanelRegionDebugInfo::callbackRestart(S32 option, void* data)
00949 {
00950         if (option != 0) return;
00951 
00952         LLPanelRegionDebugInfo* self = (LLPanelRegionDebugInfo*)data;
00953         strings_t strings;
00954         strings.push_back("120");
00955         LLUUID invoice(LLFloaterRegionInfo::getLastInvoice());
00956         self->sendEstateOwnerMessage(gMessageSystem, "restart", invoice, strings);
00957 }
00958 
00959 // static
00960 void LLPanelRegionDebugInfo::onClickCancelRestart(void* data)
00961 {
00962         LLPanelRegionDebugInfo* self = (LLPanelRegionDebugInfo*)data;
00963         strings_t strings;
00964         strings.push_back("-1");
00965         LLUUID invoice(LLFloaterRegionInfo::getLastInvoice());
00966         self->sendEstateOwnerMessage(gMessageSystem, "restart", invoice, strings);
00967 }
00968 
00969 
00971 // LLPanelRegionTextureInfo
00972 //
00973 LLPanelRegionTextureInfo::LLPanelRegionTextureInfo() : LLPanelRegionInfo()
00974 {
00975         // nothing.
00976 }
00977 
00978 bool LLPanelRegionTextureInfo::refreshFromRegion(LLViewerRegion* region)
00979 {
00980         BOOL allow_modify = gAgent.isGodlike() || (region && region->canManageEstate());
00981         setCtrlsEnabled(allow_modify);
00982         childDisable("apply_btn");
00983 
00984         if (region)
00985         {
00986                 childSetValue("region_text", LLSD(region->getName()));
00987         }
00988         else
00989         {
00990                 childSetValue("region_text", LLSD(""));
00991         }
00992 
00993         if (!region) return LLPanelRegionInfo::refreshFromRegion(region);
00994 
00995         LLVLComposition* compp = region->getComposition();
00996         LLTextureCtrl* texture_ctrl;
00997         char buffer[MAX_STRING];                /* Flawfinder: ignore */
00998         for(S32 i = 0; i < TERRAIN_TEXTURE_COUNT; ++i)
00999         {
01000                 snprintf(buffer, MAX_STRING, "texture_detail_%d", i);                   /* Flawfinder: ignore */
01001                 texture_ctrl = LLViewerUICtrlFactory::getTexturePickerByName(this, buffer);
01002                 if(texture_ctrl)
01003                 {
01004                         lldebugs << "Detail Texture " << i << ": "
01005                                          << compp->getDetailTextureID(i) << llendl;
01006                         LLUUID tmp_id(compp->getDetailTextureID(i));
01007                         texture_ctrl->setImageAssetID(tmp_id);
01008                 }
01009         }
01010 
01011         for(S32 i = 0; i < CORNER_COUNT; ++i)
01012     {
01013                 snprintf(buffer, MAX_STRING, "height_start_spin_%d", i);                        /* Flawfinder: ignore */
01014                 childSetValue(buffer, LLSD(compp->getStartHeight(i)));
01015                 snprintf(buffer, MAX_STRING, "height_range_spin_%d", i);                /* Flawfinder: ignore */
01016                 childSetValue(buffer, LLSD(compp->getHeightRange(i)));
01017         }
01018 
01019         // Call the parent for common book-keeping
01020         return LLPanelRegionInfo::refreshFromRegion(region);
01021 }
01022 
01023 
01024 BOOL LLPanelRegionTextureInfo::postBuild()
01025 {
01026         LLPanelRegionInfo::postBuild();
01027         char buffer[MAX_STRING];                /* Flawfinder: ignore */
01028         for(S32 i = 0; i < TERRAIN_TEXTURE_COUNT; ++i)
01029         {
01030                 snprintf(buffer, MAX_STRING, "texture_detail_%d", i);                   /* Flawfinder: ignore */
01031                 initCtrl(buffer);
01032         }
01033 
01034         for(S32 i = 0; i < CORNER_COUNT; ++i)
01035         {
01036                 snprintf(buffer, MAX_STRING, "height_start_spin_%d", i);                        /* Flawfinder: ignore */
01037                 initCtrl(buffer);
01038                 snprintf(buffer, MAX_STRING, "height_range_spin_%d", i);                        /* Flawfinder: ignore */
01039                 initCtrl(buffer);
01040         }
01041 
01042 //      LLButton* btn = new LLButton("dump", LLRect(0, 20, 100, 0), "", onClickDump, this);
01043 //      btn->setFollows(FOLLOWS_TOP|FOLLOWS_LEFT);
01044 //      addChild(btn);
01045 
01046         return LLPanelRegionInfo::postBuild();
01047 }
01048 
01049 void LLPanelRegionTextureInfo::draw()
01050 {
01051         if(getVisible())
01052         {
01053                 LLPanel::draw();
01054         }
01055 }
01056 
01057 BOOL LLPanelRegionTextureInfo::sendUpdate()
01058 {
01059         llinfos << "LLPanelRegionTextureInfo::sendUpdate()" << llendl;
01060 
01061         // Make sure user hasn't chosen wacky textures.
01062         if (!validateTextureSizes())
01063         {
01064                 return FALSE;
01065         }
01066 
01067         LLTextureCtrl* texture_ctrl;
01068         char buffer[MAX_STRING];                /* Flawfinder: ignore */
01069         char buffer2[MAX_STRING];               /* Flawfinder: ignore */
01070         char id_str[UUID_STR_LENGTH];   /* Flawfinder: ignore */
01071         LLMessageSystem* msg = gMessageSystem;
01072         strings_t strings;
01073 
01074         LLUUID invoice(LLFloaterRegionInfo::getLastInvoice());
01075         
01076         for(S32 i = 0; i < TERRAIN_TEXTURE_COUNT; ++i)
01077         {
01078                 snprintf(buffer, MAX_STRING, "texture_detail_%d", i);                   /* Flawfinder: ignore */
01079                 texture_ctrl = LLViewerUICtrlFactory::getTexturePickerByName(this, buffer);
01080                 if(texture_ctrl)
01081                 {
01082                         LLUUID tmp_id(texture_ctrl->getImageAssetID());
01083                         tmp_id.toString(id_str);
01084                         snprintf(buffer, MAX_STRING, "%d %s", i, id_str);                       /* Flawfinder: ignore */
01085                         strings.push_back(strings_t::value_type(buffer));
01086                 }
01087         }
01088         sendEstateOwnerMessage(msg, "texturedetail", invoice, strings);
01089         strings.clear();
01090         for(S32 i = 0; i < CORNER_COUNT; ++i)
01091         {
01092                 snprintf(buffer, MAX_STRING, "height_start_spin_%d", i);                        /* Flawfinder: ignore */
01093                 snprintf(buffer2, MAX_STRING, "height_range_spin_%d", i);                       /* Flawfinder: ignore */
01094                 snprintf(buffer, MAX_STRING, "%d %f %f", i, (F32)childGetValue(buffer).asReal(), (F32)childGetValue(buffer2).asReal());                 /* Flawfinder: ignore */
01095                 strings.push_back(strings_t::value_type(buffer));
01096         }
01097         sendEstateOwnerMessage(msg, "textureheights", invoice, strings);
01098         strings.clear();
01099         sendEstateOwnerMessage(msg, "texturecommit", invoice, strings);
01100         return TRUE;
01101 }
01102 
01103 BOOL LLPanelRegionTextureInfo::validateTextureSizes()
01104 {
01105         for(S32 i = 0; i < TERRAIN_TEXTURE_COUNT; ++i)
01106         {
01107                 char buffer[MAX_STRING];                /* Flawfinder: ignore */
01108                 snprintf(buffer, MAX_STRING, "texture_detail_%d", i);                   /* Flawfinder: ignore */
01109                 LLTextureCtrl* texture_ctrl = LLViewerUICtrlFactory::getTexturePickerByName(this, buffer);
01110                 if (!texture_ctrl) continue;
01111 
01112                 LLUUID image_asset_id = texture_ctrl->getImageAssetID();
01113                 LLViewerImage* img = gImageList.getImage(image_asset_id);
01114                 S32 components = img->getComponents();
01115                 // Must ask for highest resolution version's width. JC
01116                 S32 width = img->getWidth(0);
01117                 S32 height = img->getHeight(0);
01118 
01119                 //llinfos << "texture detail " << i << " is " << width << "x" << height << "x" << components << llendl;
01120 
01121                 if (components != 3)
01122                 {
01123                         LLString::format_map_t args;
01124                         args["[TEXTURE_NUM]"] = llformat("%d",i+1);
01125                         args["[TEXTURE_BIT_DEPTH]"] = llformat("%d",components * 8);
01126                         gViewerWindow->alertXml("InvalidTerrainBitDepth", args);
01127                         return FALSE;
01128                 }
01129 
01130                 if (width > 512 || height > 512)
01131                 {
01132 
01133                         LLString::format_map_t args;
01134                         args["[TEXTURE_NUM]"] = i+1;
01135                         args["[TEXTURE_SIZE_X]"] = llformat("%d",width);
01136                         args["[TEXTURE_SIZE_Y]"] = llformat("%d",height);
01137                         gViewerWindow->alertXml("InvalidTerrainSize", args);
01138                         return FALSE;
01139                         
01140                 }
01141         }
01142 
01143         return TRUE;
01144 }
01145 
01146 
01147 // static
01148 void LLPanelRegionTextureInfo::onClickDump(void* data)
01149 {
01150         llinfos << "LLPanelRegionTextureInfo::onClickDump()" << llendl;
01151 }
01152 
01153 
01155 // LLPanelRegionTerrainInfo
01157 BOOL LLPanelRegionTerrainInfo::postBuild()
01158 {
01159         LLPanelRegionInfo::postBuild();
01160 
01161         initHelpBtn("water_height_help",        "HelpRegionWaterHeight");
01162         initHelpBtn("terrain_raise_help",       "HelpRegionTerrainRaise");
01163         initHelpBtn("terrain_lower_help",       "HelpRegionTerrainLower");
01164         initHelpBtn("upload_raw_help",          "HelpRegionUploadRaw");
01165         initHelpBtn("download_raw_help",        "HelpRegionDownloadRaw");
01166         initHelpBtn("use_estate_sun_help",      "HelpRegionUseEstateSun");
01167         initHelpBtn("fixed_sun_help",           "HelpRegionFixedSun");
01168         initHelpBtn("bake_terrain_help",        "HelpRegionBakeTerrain");
01169 
01170         initCtrl("water_height_spin");
01171         initCtrl("terrain_raise_spin");
01172         initCtrl("terrain_lower_spin");
01173 
01174         initCtrl("fixed_sun_check");
01175         childSetCommitCallback("fixed_sun_check", onChangeFixedSun, this);
01176         childSetCommitCallback("use_estate_sun_check", onChangeUseEstateTime, this);
01177         childSetCommitCallback("sun_hour_slider", onChangeSunHour, this);
01178 
01179         childSetAction("download_raw_btn", onClickDownloadRaw, this);
01180         childSetAction("upload_raw_btn", onClickUploadRaw, this);
01181         childSetAction("bake_terrain_btn", onClickBakeTerrain, this);
01182 
01183         return TRUE;
01184 }
01185 
01186 // virtual
01187 bool LLPanelRegionTerrainInfo::refreshFromRegion(LLViewerRegion* region)
01188 {
01189         llinfos << "LLPanelRegionTerrainInfo::refreshFromRegion" << llendl;
01190 
01191         BOOL owner_or_god = gAgent.isGodlike() 
01192                                                 || (region && (region->getOwner() == gAgent.getID()));
01193         BOOL owner_or_god_or_manager = owner_or_god
01194                                                 || (region && region->isEstateManager());
01195         setCtrlsEnabled(owner_or_god_or_manager);
01196         childDisable("apply_btn");
01197 
01198         childSetEnabled("download_raw_btn", owner_or_god);
01199         childSetEnabled("upload_raw_btn", owner_or_god);
01200         childSetEnabled("bake_terrain_btn", owner_or_god);
01201 
01202         return LLPanelRegionInfo::refreshFromRegion(region);
01203 }
01204 
01205 // virtual
01206 BOOL LLPanelRegionTerrainInfo::sendUpdate()
01207 {
01208         llinfos << "LLPanelRegionTerrainInfo::sendUpdate" << llendl;
01209         char buffer[MAX_STRING];                /* Flawfinder: ignore */
01210         strings_t strings;
01211         LLUUID invoice(LLFloaterRegionInfo::getLastInvoice());
01212 
01213         snprintf(buffer, MAX_STRING, "%f", (F32)childGetValue("water_height_spin").asReal());                   /* Flawfinder: ignore */
01214         strings.push_back(buffer);
01215         snprintf(buffer, MAX_STRING, "%f", (F32)childGetValue("terrain_raise_spin").asReal());                  /* Flawfinder: ignore */
01216         strings.push_back(buffer);
01217         snprintf(buffer, MAX_STRING, "%f", (F32)childGetValue("terrain_lower_spin").asReal());                  /* Flawfinder: ignore */
01218         strings.push_back(buffer);
01219         snprintf(buffer, MAX_STRING, "%s", (childGetValue("use_estate_sun_check").asBoolean() ? "Y" : "N"));                    /* Flawfinder: ignore */
01220         strings.push_back(buffer);
01221         snprintf(buffer, MAX_STRING, "%s", (childGetValue("fixed_sun_check").asBoolean() ? "Y" : "N"));                 /* Flawfinder: ignore */
01222         strings.push_back(buffer);
01223         snprintf(buffer, MAX_STRING, "%f", (F32)childGetValue("sun_hour_slider").asReal() );                    /* Flawfinder: ignore */
01224         strings.push_back(buffer);
01225 
01226         // Grab estate information in case the user decided to set the
01227         // region back to estate time. JC
01228         LLFloaterRegionInfo* floater = LLFloaterRegionInfo::getInstance();
01229         if (!floater) return true;
01230 
01231         LLTabContainerCommon* tab = LLUICtrlFactory::getTabContainerByName(floater, "tab");
01232         if (!tab) return true;
01233 
01234         LLPanelEstateInfo* panel = (LLPanelEstateInfo*)LLUICtrlFactory::getPanelByName(tab, "Estate");
01235         if (!panel) return true;
01236 
01237         BOOL estate_global_time = panel->getGlobalTime();
01238         BOOL estate_fixed_sun = panel->getFixedSun();
01239         F32 estate_sun_hour;
01240         if (estate_global_time)
01241         {
01242                 estate_sun_hour = 0.f;
01243         }
01244         else
01245         {
01246                 estate_sun_hour = panel->getSunHour();
01247         }
01248 
01249         snprintf(buffer, MAX_STRING, "%s", (estate_global_time ? "Y" : "N") );                  /* Flawfinder: ignore */
01250         strings.push_back(buffer);
01251         snprintf(buffer, MAX_STRING, "%s", (estate_fixed_sun ? "Y" : "N") );                    /* Flawfinder: ignore */
01252         strings.push_back(buffer);
01253         snprintf(buffer, MAX_STRING, "%f", estate_sun_hour);                    /* Flawfinder: ignore */
01254         strings.push_back(buffer);
01255 
01256         sendEstateOwnerMessage(gMessageSystem, "setregionterrain", invoice, strings);
01257         return TRUE;
01258 }
01259 
01260 // static 
01261 void LLPanelRegionTerrainInfo::onChangeUseEstateTime(LLUICtrl* ctrl, void* user_data)
01262 {
01263         LLPanelRegionTerrainInfo* panel = (LLPanelRegionTerrainInfo*) user_data;
01264         if (!panel) return;
01265         BOOL use_estate_sun = panel->childGetValue("use_estate_sun_check").asBoolean();
01266         panel->childSetEnabled("fixed_sun_check", !use_estate_sun);
01267         panel->childSetEnabled("sun_hour_slider", !use_estate_sun);
01268         if (use_estate_sun)
01269         {
01270                 panel->childSetValue("fixed_sun_check", LLSD(FALSE));
01271                 panel->childSetValue("sun_hour_slider", LLSD(0.f));
01272         }
01273         panel->childEnable("apply_btn");
01274 }
01275 
01276 // static 
01277 void LLPanelRegionTerrainInfo::onChangeFixedSun(LLUICtrl* ctrl, void* user_data)
01278 {
01279         LLPanelRegionTerrainInfo* panel = (LLPanelRegionTerrainInfo*) user_data;
01280         if (!panel) return;
01281         // Just enable the apply button.  We let the sun-hour slider be enabled
01282         // for both fixed-sun and non-fixed-sun. JC
01283         panel->childEnable("apply_btn");
01284 }
01285 
01286 // static 
01287 void LLPanelRegionTerrainInfo::onChangeSunHour(LLUICtrl* ctrl, void*)
01288 {
01289         // can't use userdata to get panel, slider uses it internally
01290         LLPanelRegionTerrainInfo* panel = (LLPanelRegionTerrainInfo*) ctrl->getParent();
01291         if (!panel) return;
01292         panel->childEnable("apply_btn");
01293 }
01294 
01295 // static
01296 void LLPanelRegionTerrainInfo::onClickDownloadRaw(void* data)
01297 {
01298         LLFilePicker& picker = LLFilePicker::instance();
01299         if (!picker.getSaveFile(LLFilePicker::FFSAVE_RAW, "terrain.raw"))
01300         {
01301                 llwarns << "No file" << llendl;
01302                 return;
01303         }
01304         LLString filepath = picker.getFirstFile();
01305 
01306         LLPanelRegionTerrainInfo* self = (LLPanelRegionTerrainInfo*)data;
01307         strings_t strings;
01308         strings.push_back("download filename");
01309         strings.push_back(filepath);
01310         LLUUID invoice(LLFloaterRegionInfo::getLastInvoice());
01311         self->sendEstateOwnerMessage(gMessageSystem, "terrain", invoice, strings);
01312 }
01313 
01314 // static
01315 void LLPanelRegionTerrainInfo::onClickUploadRaw(void* data)
01316 {
01317         LLFilePicker& picker = LLFilePicker::instance();
01318         if (!picker.getOpenFile(LLFilePicker::FFLOAD_RAW))
01319         {
01320                 llwarns << "No file" << llendl;
01321                 return;
01322         }
01323         LLString filepath = picker.getFirstFile();
01324 
01325         LLPanelRegionTerrainInfo* self = (LLPanelRegionTerrainInfo*)data;
01326         strings_t strings;
01327         strings.push_back("upload filename");
01328         strings.push_back(filepath);
01329         LLUUID invoice(LLFloaterRegionInfo::getLastInvoice());
01330         self->sendEstateOwnerMessage(gMessageSystem, "terrain", invoice, strings);
01331 
01332         gViewerWindow->alertXml("RawUploadStarted");
01333 }
01334 
01335 // static
01336 void LLPanelRegionTerrainInfo::onClickBakeTerrain(void* data)
01337 {
01338         gViewerWindow->alertXml("ConfirmBakeTerrain", 
01339                                                          callbackBakeTerrain, data);
01340 }
01341 
01342 // static
01343 void LLPanelRegionTerrainInfo::callbackBakeTerrain(S32 option, void* data)
01344 {
01345         if (option != 0) return;
01346 
01347         LLPanelRegionTerrainInfo* self = (LLPanelRegionTerrainInfo*)data;
01348         strings_t strings;
01349         strings.push_back("bake");
01350         LLUUID invoice(LLFloaterRegionInfo::getLastInvoice());
01351         self->sendEstateOwnerMessage(gMessageSystem, "terrain", invoice, strings);
01352 }
01353 
01355 // LLPanelEstateInfo
01356 //
01357 
01358 LLPanelEstateInfo::LLPanelEstateInfo() 
01359 :       LLPanelRegionInfo(),
01360         mEstateID(0)    // invalid
01361 {
01362 }
01363 
01364 // static
01365 void LLPanelEstateInfo::initDispatch(LLDispatcher& dispatch)
01366 {
01367         std::string name;
01368 
01369 //      name.assign("setowner");
01370 //      static LLDispatchSetEstateOwner set_owner;
01371 //      dispatch.addHandler(name, &set_owner);
01372 
01373         name.assign("estateupdateinfo");
01374         static LLDispatchEstateUpdateInfo estate_update_info;
01375         dispatch.addHandler(name, &estate_update_info);
01376 
01377         name.assign("setaccess");
01378         static LLDispatchSetEstateAccess set_access;
01379         dispatch.addHandler(name, &set_access);
01380 
01381         estate_dispatch_initialized = true;
01382 }
01383 
01384 // static
01385 // Disables the sun-hour slider and the use fixed time check if the use global time is check
01386 void LLPanelEstateInfo::onChangeUseGlobalTime(LLUICtrl* ctrl, void* user_data)
01387 {
01388         LLPanelEstateInfo* panel = (LLPanelEstateInfo*) user_data;
01389         if (panel)
01390         {
01391                 bool enabled = !panel->childGetValue("use_global_time_check").asBoolean();
01392                 panel->childSetEnabled("sun_hour_slider", enabled);
01393                 panel->childSetEnabled("fixed_sun_check", enabled);
01394                 panel->childSetValue("fixed_sun_check", LLSD(FALSE));
01395                 panel->enableButton("apply_btn");
01396         }
01397 }
01398 
01399 // Enables the sun-hour slider if the fixed-sun checkbox is set
01400 void LLPanelEstateInfo::onChangeFixedSun(LLUICtrl* ctrl, void* user_data)
01401 {
01402         LLPanelEstateInfo* panel = (LLPanelEstateInfo*) user_data;
01403         if (panel)
01404         {
01405                 bool enabled = !panel->childGetValue("fixed_sun_check").asBoolean();
01406                 panel->childSetEnabled("use_global_time_check", enabled);
01407                 panel->childSetValue("use_global_time_check", LLSD(FALSE));
01408                 panel->enableButton("apply_btn");
01409         }
01410 }
01411 
01412 //---------------------------------------------------------------------------
01413 // Add/Remove estate access button callbacks
01414 //---------------------------------------------------------------------------
01415 
01416 // static
01417 void LLPanelEstateInfo::onClickAddAllowedAgent(void* user_data)
01418 {
01419         LLPanelEstateInfo* self = (LLPanelEstateInfo*)user_data;
01420         LLCtrlListInterface *list = self->childGetListInterface("allowed_avatar_name_list");
01421         if (!list) return;
01422         if (list->getItemCount() >= ESTATE_MAX_ACCESS_IDS)
01423         {
01424                 //args
01425 
01426                 LLString::format_map_t args;
01427                 args["[MAX_AGENTS]"] = llformat("%d",ESTATE_MAX_ACCESS_IDS);
01428                 gViewerWindow->alertXml("MaxAllowedAgentOnRegion", args);
01429                 return;
01430         }
01431         accessAddCore(ESTATE_ACCESS_ALLOWED_AGENT_ADD, "EstateAllowedAgentAdd");
01432 }
01433 
01434 // static
01435 void LLPanelEstateInfo::onClickRemoveAllowedAgent(void* user_data)
01436 {
01437         accessRemoveCore(ESTATE_ACCESS_ALLOWED_AGENT_REMOVE, "EstateAllowedAgentRemove", "allowed_avatar_name_list");
01438 }
01439 
01440 // static
01441 void LLPanelEstateInfo::onClickAddAllowedGroup(void* user_data)
01442 {
01443         LLPanelEstateInfo* self = (LLPanelEstateInfo*)user_data;
01444         LLCtrlListInterface *list = self->childGetListInterface("allowed_group_name_list");
01445         if (!list) return;
01446         if (list->getItemCount() >= ESTATE_MAX_ACCESS_IDS)
01447         {
01448                 LLString::format_map_t args;
01449                 args["[MAX_GROUPS]"] = llformat("%d",ESTATE_MAX_ACCESS_IDS);
01450                 gViewerWindow->alertXml("MaxAllowedGroupsOnRegion", args);
01451                 return;
01452         }
01453         if (isLindenEstate())
01454         {
01455                 gViewerWindow->alertXml("ChangeLindenAccess", addAllowedGroup, user_data);
01456         }
01457         else
01458         {
01459                 addAllowedGroup(0, user_data);
01460         }
01461 }
01462 
01463 // static
01464 void LLPanelEstateInfo::addAllowedGroup(S32 option, void* user_data)
01465 {
01466         if (option != 0) return;
01467 
01468         LLPanelEstateInfo* panelp = (LLPanelEstateInfo*)user_data;
01469 
01470         LLFloater* parent_floater = gFloaterView->getParentFloater(panelp);
01471 
01472         LLFloaterGroupPicker* widget;
01473         widget = LLFloaterGroupPicker::showInstance(LLSD(gAgent.getID()));
01474         if (widget)
01475         {
01476                 widget->setSelectCallback(addAllowedGroup2, user_data);
01477                 if (parent_floater)
01478                 {
01479                         LLRect new_rect = gFloaterView->findNeighboringPosition(parent_floater, widget);
01480                         widget->setOrigin(new_rect.mLeft, new_rect.mBottom);
01481                         parent_floater->addDependentFloater(widget);
01482                 }
01483         }
01484 }
01485 
01486 // static
01487 void LLPanelEstateInfo::onClickRemoveAllowedGroup(void* user_data)
01488 {
01489         accessRemoveCore(ESTATE_ACCESS_ALLOWED_GROUP_REMOVE, "EstateAllowedGroupRemove", "allowed_group_name_list");
01490 }
01491 
01492 // static
01493 void LLPanelEstateInfo::onClickAddBannedAgent(void* user_data)
01494 {
01495         LLPanelEstateInfo* self = (LLPanelEstateInfo*)user_data;
01496         LLCtrlListInterface *list = self->childGetListInterface("banned_avatar_name_list");
01497         if (!list) return;
01498         if (list->getItemCount() >= ESTATE_MAX_ACCESS_IDS)
01499         {
01500                 LLString::format_map_t args;
01501                 args["[MAX_BANNED]"] = llformat("%d",ESTATE_MAX_ACCESS_IDS);
01502                 gViewerWindow->alertXml("MaxBannedAgentsOnRegion", args);
01503                 return;
01504         }
01505         accessAddCore(ESTATE_ACCESS_BANNED_AGENT_ADD, "EstateBannedAgentAdd");
01506 }
01507 
01508 // static
01509 void LLPanelEstateInfo::onClickRemoveBannedAgent(void* user_data)
01510 {
01511         accessRemoveCore(ESTATE_ACCESS_BANNED_AGENT_REMOVE, "EstateBannedAgentRemove", "banned_avatar_name_list");
01512 }
01513 
01514 // static
01515 void LLPanelEstateInfo::onClickAddEstateManager(void* user_data)
01516 {
01517         LLPanelEstateInfo* self = (LLPanelEstateInfo*)user_data;
01518         LLCtrlListInterface *list = self->childGetListInterface("estate_manager_name_list");
01519         if (!list) return;
01520         if (list->getItemCount() >= ESTATE_MAX_MANAGERS)
01521         {       // Tell user they can't add more managers
01522                 LLString::format_map_t args;
01523                 args["[MAX_MANAGER]"] = llformat("%d",ESTATE_MAX_MANAGERS);
01524                 gViewerWindow->alertXml("MaxManagersOnRegion", args);
01525         }
01526         else
01527         {       // Go pick managers to add
01528                 accessAddCore(ESTATE_ACCESS_MANAGER_ADD, "EstateManagerAdd");
01529         }
01530 }
01531 
01532 // static
01533 void LLPanelEstateInfo::onClickRemoveEstateManager(void* user_data)
01534 {
01535         accessRemoveCore(ESTATE_ACCESS_MANAGER_REMOVE, "EstateManagerRemove", "estate_manager_name_list");
01536 }
01537 
01538 //---------------------------------------------------------------------------
01539 // Kick from estate methods
01540 //---------------------------------------------------------------------------
01541 struct LLKickFromEstateInfo
01542 {
01543         LLPanelEstateInfo *mEstatePanelp;
01544         LLString    mDialogName;
01545         LLUUID      mAgentID;
01546 };
01547 
01548 void LLPanelEstateInfo::onClickKickUser(void *user_data)
01549 {
01550         LLPanelEstateInfo* panelp = (LLPanelEstateInfo*)user_data;
01551 
01552         // this depends on the grandparent view being a floater
01553         // in order to set up floater dependency
01554         LLFloater* parent_floater = gFloaterView->getParentFloater(panelp);
01555         LLFloater* child_floater = LLFloaterAvatarPicker::show(LLPanelEstateInfo::onKickUserCommit, user_data, FALSE, TRUE);
01556         parent_floater->addDependentFloater(child_floater);
01557 }
01558 
01559 void LLPanelEstateInfo::onKickUserCommit(const std::vector<std::string>& names, const std::vector<LLUUID>& ids, void* userdata)
01560 {
01561         if (names.empty() || ids.empty()) return;
01562         
01563         //check to make sure there is one valid user and id
01564         if( (ids[0].isNull()) ||
01565                 (names[0].length() == 0) )
01566         {
01567                 return;
01568         }
01569 
01570         LLPanelEstateInfo* self = (LLPanelEstateInfo*)userdata;
01571         if(!self) return;
01572 
01573         //keep track of what user they want to kick and other misc info
01574         LLKickFromEstateInfo *kick_info = new LLKickFromEstateInfo();
01575         kick_info->mEstatePanelp = self;
01576         kick_info->mDialogName  = "EstateKickUser";
01577         kick_info->mAgentID     = ids[0];
01578 
01579         //Bring up a confirmation dialog
01580         LLString::format_map_t args;
01581         args["[EVIL_USER]"] = names[0];
01582         gViewerWindow->alertXml(kick_info->mDialogName, args, LLPanelEstateInfo::kickUserConfirm, (void*)kick_info);
01583 
01584 }
01585 
01586 void LLPanelEstateInfo::kickUserConfirm(S32 option, void* userdata)
01587 {
01588         //extract the callback parameter
01589         LLKickFromEstateInfo *kick_info = (LLKickFromEstateInfo*) userdata;
01590         if (!kick_info) return;
01591 
01592         LLUUID invoice(LLFloaterRegionInfo::getLastInvoice());
01593         strings_t strings;
01594         char buffer[MAX_STRING];                /* Flawfinder: ignore*/
01595 
01596         switch(option)
01597         {
01598         case 0:
01599                 //Kick User
01600                 kick_info->mAgentID.toString(buffer);
01601                 strings.push_back(strings_t::value_type(buffer));
01602 
01603                 kick_info->mEstatePanelp->sendEstateOwnerMessage(gMessageSystem, "kickestate", invoice, strings);
01604                 break;
01605         default:
01606                 break;
01607         }
01608 
01609         delete kick_info;
01610         kick_info = NULL;
01611 }
01612 
01613 //---------------------------------------------------------------------------
01614 // Core Add/Remove estate access methods
01615 //---------------------------------------------------------------------------
01616 std::string all_estates_text()
01617 {
01618         LLPanelEstateInfo* panel = LLFloaterRegionInfo::getPanelEstate();
01619         if (!panel) return "(error)";
01620 
01621         std::string owner = panel->getOwnerName();
01622 
01623         LLViewerRegion* region = gAgent.getRegion();
01624         if (gAgent.isGodlike())
01625         {
01626                 return llformat("all estates\nowned by %s", owner.c_str());
01627         }
01628         else if (region && region->getOwner() == gAgent.getID())
01629         {
01630                 return "all estates you own";
01631         }
01632         else if (region && region->isEstateManager())
01633         {
01634                 return llformat("all estates that\nyou manage for %s", owner.c_str());
01635         }
01636         else
01637         {
01638                 return "(error)";
01639         }
01640 }
01641 
01642 // static
01643 bool LLPanelEstateInfo::isLindenEstate()
01644 {
01645         LLPanelEstateInfo* panel = LLFloaterRegionInfo::getPanelEstate();
01646         if (!panel) return false;
01647 
01648         U32 estate_id = panel->getEstateID();
01649         return (estate_id <= ESTATE_LAST_LINDEN);
01650 }
01651 
01652 struct LLEstateAccessChangeInfo
01653 {
01654         U32 mOperationFlag;     // ESTATE_ACCESS_BANNED_AGENT_ADD, _REMOVE, etc.
01655         LLString mDialogName;
01656         LLUUID mAgentOrGroupID;
01657 };
01658 
01659 // Special case callback for groups, since it has different callback format than names
01660 // static
01661 void LLPanelEstateInfo::addAllowedGroup2(LLUUID id, void* user_data)
01662 {
01663         LLEstateAccessChangeInfo* change_info = new LLEstateAccessChangeInfo;
01664         change_info->mOperationFlag = ESTATE_ACCESS_ALLOWED_GROUP_ADD;
01665         change_info->mDialogName = "EstateAllowedGroupAdd";
01666         change_info->mAgentOrGroupID = id;
01667 
01668         if (isLindenEstate())
01669         {
01670                 accessCoreConfirm(0, (void*)change_info);
01671         }
01672         else
01673         {
01674                 LLString::format_map_t args;
01675                 args["[ALL_ESTATES]"] = all_estates_text();
01676                 gViewerWindow->alertXml(change_info->mDialogName, args, accessCoreConfirm, (void*)change_info);
01677         }
01678 }
01679 
01680 // static
01681 void LLPanelEstateInfo::accessAddCore(U32 operation_flag, const char* dialog_name)
01682 {
01683         LLEstateAccessChangeInfo* change_info = new LLEstateAccessChangeInfo;
01684         change_info->mOperationFlag = operation_flag;
01685         change_info->mDialogName = dialog_name;
01686         // agent id filled in after avatar picker
01687 
01688         if (isLindenEstate())
01689         {
01690                 gViewerWindow->alertXml("ChangeLindenAccess", accessAddCore2, change_info);
01691         }
01692         else
01693         {
01694                 // same as clicking "OK"
01695                 accessAddCore2(0, change_info);
01696         }
01697 }
01698 
01699 // static
01700 void LLPanelEstateInfo::accessAddCore2(S32 option, void* data)
01701 {
01702         LLEstateAccessChangeInfo* change_info = (LLEstateAccessChangeInfo*)data;
01703         if (option != 0)
01704         {
01705                 // abort change
01706                 delete change_info;
01707                 change_info = NULL;
01708                 return;
01709         }
01710 
01711         // avatar picker no multi-select, yes close-on-select
01712         LLFloaterAvatarPicker::show(accessAddCore3, (void*)change_info, FALSE, TRUE);
01713 }
01714 
01715 // static
01716 void LLPanelEstateInfo::accessAddCore3(const std::vector<std::string>& names, const std::vector<LLUUID>& ids, void* data)
01717 {
01718         LLEstateAccessChangeInfo* change_info = (LLEstateAccessChangeInfo*)data;
01719         if (!change_info) return;
01720         if (ids.empty()) 
01721         {
01722                 // User didn't select a name.
01723                 delete change_info;
01724                 change_info = NULL;
01725                 return;
01726         }
01727         // User did select a name.
01728         change_info->mAgentOrGroupID = ids[0];
01729 
01730         // Can't put estate owner on ban list
01731         LLPanelEstateInfo* panel = LLFloaterRegionInfo::getPanelEstate();
01732         if (!panel) return;
01733         LLViewerRegion* region = gAgent.getRegion();
01734         if (!region) return;
01735 
01736         if ((change_info->mOperationFlag & ESTATE_ACCESS_BANNED_AGENT_ADD)
01737                 && (region->getOwner() == change_info->mAgentOrGroupID))
01738         {
01739                 gViewerWindow->alertXml("OwnerCanNotBeDenied");
01740                 delete change_info;
01741                 change_info = NULL;
01742                 return;
01743         }
01744 
01745         if (isLindenEstate())
01746         {
01747                 // just apply to this estate
01748                 accessCoreConfirm(0, (void*)change_info);
01749         }
01750         else
01751         {
01752                 // ask if this estate or all estates with this owner
01753                 LLString::format_map_t args;
01754                 args["[ALL_ESTATES]"] = all_estates_text();
01755                 gViewerWindow->alertXml(change_info->mDialogName, args, accessCoreConfirm, (void*)change_info);
01756         }
01757 }
01758 
01759 // static
01760 void LLPanelEstateInfo::accessRemoveCore(U32 operation_flag, const char* dialog_name, const char* list_ctrl_name)
01761 {
01762         LLPanelEstateInfo* panel = LLFloaterRegionInfo::getPanelEstate();
01763         if (!panel) return;
01764         LLNameListCtrl* name_list = LLViewerUICtrlFactory::getNameListByName(panel, list_ctrl_name);
01765         if (!name_list) return;
01766         LLScrollListItem* item = name_list->getFirstSelected();
01767         if (!item) return;
01768         LLUUID agent_id = item->getUUID();
01769 
01770         LLEstateAccessChangeInfo* change_info = new LLEstateAccessChangeInfo;
01771         change_info->mAgentOrGroupID = agent_id;
01772         change_info->mOperationFlag = operation_flag;
01773         change_info->mDialogName = dialog_name;
01774 
01775         if (isLindenEstate())
01776         {
01777                 // warn on change linden estate
01778                 gViewerWindow->alertXml("ChangeLindenAccess", 
01779                                                            accessRemoveCore2,
01780                                                            (void*)change_info);
01781         }
01782         else
01783         {
01784                 // just proceed, as if clicking OK
01785                 accessRemoveCore2(0, (void*)change_info);
01786         }
01787 }
01788 
01789 // static
01790 void LLPanelEstateInfo::accessRemoveCore2(S32 option, void* data)
01791 {
01792         LLEstateAccessChangeInfo* change_info = (LLEstateAccessChangeInfo*)data;
01793         if (option != 0)
01794         {
01795                 // abort
01796                 delete change_info;
01797                 change_info = NULL;
01798                 return;
01799         }
01800 
01801         // If Linden estate, can only apply to "this" estate, not all estates
01802         // owned by NULL.
01803         if (isLindenEstate())
01804         {
01805                 accessCoreConfirm(0, (void*)change_info);
01806         }
01807         else
01808         {
01809                 LLString::format_map_t args;
01810                 args["[ALL_ESTATES]"] = all_estates_text();
01811                 gViewerWindow->alertXml(change_info->mDialogName, 
01812                                                            args, 
01813                                                            accessCoreConfirm, 
01814                                                            (void*)change_info);
01815         }
01816 }
01817 
01818 // Used for both access add and remove operations, depending on the mOperationFlag
01819 // passed in (ESTATE_ACCESS_BANNED_AGENT_ADD, ESTATE_ACCESS_ALLOWED_AGENT_REMOVE, etc.)
01820 // static
01821 void LLPanelEstateInfo::accessCoreConfirm(S32 option, void* data)
01822 {
01823         LLEstateAccessChangeInfo* change_info = (LLEstateAccessChangeInfo*)data;
01824         U32 flags = change_info->mOperationFlag;
01825         switch(option)
01826         {
01827         case 0:
01828                 // This estate
01829                 sendEstateAccessDelta(flags, change_info->mAgentOrGroupID);
01830                 break;
01831         case 1:
01832                 {
01833                         // All estates, either than I own or manage for this owner.  
01834                         // This will be verified on simulator. JC
01835                         LLViewerRegion* region = gAgent.getRegion();
01836                         if (!region) break;
01837                         if (region->getOwner() == gAgent.getID()
01838                                 || gAgent.isGodlike())
01839                         {
01840                                 flags |= ESTATE_ACCESS_APPLY_TO_ALL_ESTATES;
01841                                 sendEstateAccessDelta(flags, change_info->mAgentOrGroupID);
01842                         }
01843                         else if (region->isEstateManager())
01844                         {
01845                                 flags |= ESTATE_ACCESS_APPLY_TO_MANAGED_ESTATES;
01846                                 sendEstateAccessDelta(flags, change_info->mAgentOrGroupID);
01847                         }
01848                         break;
01849                 }
01850         case 2:
01851         default:
01852                 break;
01853         }
01854         delete change_info;
01855         change_info = NULL;
01856 }
01857 
01858 // key = "estateaccessdelta"
01859 // str(estate_id) will be added to front of list by forward_EstateOwnerRequest_to_dataserver
01860 // str[0] = str(agent_id) requesting the change
01861 // str[1] = str(flags) (ESTATE_ACCESS_DELTA_*)
01862 // str[2] = str(agent_id) to add or remove
01863 // static
01864 void LLPanelEstateInfo::sendEstateAccessDelta(U32 flags, const LLUUID& agent_or_group_id)
01865 {
01866         LLMessageSystem* msg = gMessageSystem;
01867         msg->newMessage("EstateOwnerMessage");
01868         msg->nextBlockFast(_PREHASH_AgentData);
01869         msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
01870         msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
01871         msg->addUUIDFast(_PREHASH_TransactionID, LLUUID::null); //not used
01872 
01873         msg->nextBlock("MethodData");
01874         msg->addString("Method", "estateaccessdelta");
01875         msg->addUUID("Invoice", LLFloaterRegionInfo::getLastInvoice());
01876 
01877         char buf[MAX_STRING];           /* Flawfinder: ignore*/
01878         gAgent.getID().toString(buf);
01879         msg->nextBlock("ParamList");
01880         msg->addString("Parameter", buf);
01881 
01882         snprintf(buf, MAX_STRING, "%u", flags);                 /* Flawfinder: ignore */
01883         msg->nextBlock("ParamList");
01884         msg->addString("Parameter", buf);
01885 
01886         agent_or_group_id.toString(buf);
01887         msg->nextBlock("ParamList");
01888         msg->addString("Parameter", buf);
01889 
01890 
01891         LLPanelEstateInfo* panel = LLFloaterRegionInfo::getPanelEstate();
01892 
01893         if (flags & (ESTATE_ACCESS_ALLOWED_AGENT_ADD | ESTATE_ACCESS_ALLOWED_AGENT_REMOVE |
01894                          ESTATE_ACCESS_BANNED_AGENT_ADD | ESTATE_ACCESS_BANNED_AGENT_REMOVE))
01895         {
01896                 
01897                 panel->clearAccessLists();
01898         }
01899 
01900         gAgent.sendReliableMessage();
01901 }
01902 
01903 
01904 bool LLPanelEstateInfo::refreshFromRegion(LLViewerRegion* region)
01905 {
01906         BOOL god = gAgent.isGodlike();
01907         BOOL owner = (region && (region->getOwner() == gAgent.getID()));
01908         BOOL manager = (region && region->isEstateManager());
01909         setCtrlsEnabled(god || owner || manager);
01910         childDisable("apply_btn");
01911         childSetEnabled("add_allowed_avatar_btn",               god || owner || manager);
01912         childSetEnabled("remove_allowed_avatar_btn",    god || owner || manager);
01913         childSetEnabled("add_allowed_group_btn",                god || owner || manager);
01914         childSetEnabled("remove_allowed_group_btn",             god || owner || manager);
01915         childSetEnabled("add_banned_avatar_btn",                god || owner || manager);
01916         childSetEnabled("remove_banned_avatar_btn",             god || owner || manager);
01917         childSetEnabled("message_estate_btn",                   god || owner || manager);
01918         childSetEnabled("kick_user_from_estate_btn",    god || owner || manager);
01919 
01920         // estate managers can't add estate managers
01921         childSetEnabled("add_estate_manager_btn",               god || owner);
01922         childSetEnabled("remove_estate_manager_btn",    god || owner);
01923         childSetEnabled("estate_manager_name_list",             god || owner);
01924 
01925         // let the parent class handle the general data collection. 
01926         bool rv = LLPanelRegionInfo::refreshFromRegion(region);
01927 
01928         // We want estate info. To make sure it works across region
01929         // boundaries and multiple packets, we add a serial number to the
01930         // integers and track against that on update.
01931         strings_t strings;
01932         //integers_t integers;
01933         //LLFloaterRegionInfo::incrementSerial();
01934         LLFloaterRegionInfo::nextInvoice();
01935         LLUUID invoice(LLFloaterRegionInfo::getLastInvoice());
01936         //integers.push_back(LLFloaterRegionInfo::());::getPanelEstate();
01937 
01938         
01939         LLPanelEstateInfo* panel = LLFloaterRegionInfo::getPanelEstate();
01940         panel->clearAccessLists();
01941         
01942 
01943         sendEstateOwnerMessage(gMessageSystem, "getinfo", invoice, strings);
01944 
01945         
01946 
01947 
01948         return rv;
01949 }
01950 
01951 void LLPanelEstateInfo::updateChild(LLUICtrl* child_ctrl)
01952 {
01953         if (checkRemovalButton(child_ctrl->getName()))
01954         {
01955                 // do nothing
01956         }
01957         else if (checkSunHourSlider(child_ctrl))
01958         {
01959                 // do nothing
01960         }
01961 }
01962 
01963 bool LLPanelEstateInfo::estateUpdate(LLMessageSystem* msg)
01964 {
01965         llinfos << "LLPanelEstateInfo::estateUpdate()" << llendl;
01966         return false;
01967 }
01968 
01969 
01970 BOOL LLPanelEstateInfo::postBuild()
01971 {
01972         // set up the callbacks for the generic controls
01973         initCtrl("externally_visible_check");
01974         initCtrl("use_global_time_check");
01975         initCtrl("fixed_sun_check");
01976         initCtrl("allow_direct_teleport");
01977         initCtrl("deny_anonymous");
01978         initCtrl("deny_identified");
01979         initCtrl("deny_transacted");
01980         initCtrl("voice_chat_check");
01981 
01982         initHelpBtn("estate_manager_help",                      "HelpEstateEstateManager");
01983         initHelpBtn("use_global_time_help",                     "HelpEstateUseGlobalTime");
01984         initHelpBtn("fixed_sun_help",                           "HelpEstateFixedSun");
01985         initHelpBtn("externally_visible_help",          "HelpEstateExternallyVisible");
01986         initHelpBtn("allow_direct_teleport_help",       "HelpEstateAllowDirectTeleport");
01987         initHelpBtn("allow_resident_help",                      "HelpEstateAllowResident");
01988         initHelpBtn("allow_group_help",                         "HelpEstateAllowGroup");
01989         initHelpBtn("ban_resident_help",                        "HelpEstateBanResident");
01990         initHelpBtn("voice_chat_help", "HelpEstateVoiceChat");
01991 
01992         // set up the use global time checkbox
01993         childSetCommitCallback("use_global_time_check", onChangeUseGlobalTime, this);
01994         childSetCommitCallback("fixed_sun_check", onChangeFixedSun, this);
01995         childSetCommitCallback("sun_hour_slider", onChangeChildCtrl, this);
01996 
01997         childSetCommitCallback("allowed_avatar_name_list", onChangeChildCtrl, this);
01998         LLNameListCtrl *avatar_name_list = LLViewerUICtrlFactory::getNameListByName(this, "allowed_avatar_name_list");
01999         if (avatar_name_list)
02000         {
02001                 avatar_name_list->setCommitOnSelectionChange(TRUE);
02002                 avatar_name_list->setMaxItemCount(ESTATE_MAX_ACCESS_IDS);
02003         }
02004 
02005         childSetAction("add_allowed_avatar_btn", onClickAddAllowedAgent, this);
02006         childSetAction("remove_allowed_avatar_btn", onClickRemoveAllowedAgent, this);
02007 
02008         childSetCommitCallback("allowed_group_name_list", onChangeChildCtrl, this);
02009         LLNameListCtrl* group_name_list = LLViewerUICtrlFactory::getNameListByName(this, "allowed_group_name_list");
02010         if (group_name_list)
02011         {
02012                 group_name_list->setCommitOnSelectionChange(TRUE);
02013                 group_name_list->setMaxItemCount(ESTATE_MAX_ACCESS_IDS);
02014         }
02015 
02016         childSetAction("add_allowed_group_btn", onClickAddAllowedGroup, this);
02017         childSetAction("remove_allowed_group_btn", onClickRemoveAllowedGroup, this);
02018 
02019         childSetCommitCallback("banned_avatar_name_list", onChangeChildCtrl, this);
02020         LLNameListCtrl* banned_name_list = LLViewerUICtrlFactory::getNameListByName(this, "banned_avatar_name_list");
02021         if (banned_name_list)
02022         {
02023                 banned_name_list->setCommitOnSelectionChange(TRUE);
02024                 banned_name_list->setMaxItemCount(ESTATE_MAX_ACCESS_IDS);
02025         }
02026 
02027         childSetAction("add_banned_avatar_btn", onClickAddBannedAgent, this);
02028         childSetAction("remove_banned_avatar_btn", onClickRemoveBannedAgent, this);
02029 
02030         childSetCommitCallback("estate_manager_name_list", onChangeChildCtrl, this);
02031         LLNameListCtrl* manager_name_list = LLViewerUICtrlFactory::getNameListByName(this, "estate_manager_name_list");
02032         if (manager_name_list)
02033         {
02034                 manager_name_list->setCommitOnSelectionChange(TRUE);
02035                 manager_name_list->setMaxItemCount(ESTATE_MAX_MANAGERS * 4);    // Allow extras for dupe issue
02036         }
02037 
02038         childSetAction("add_estate_manager_btn", onClickAddEstateManager, this);
02039         childSetAction("remove_estate_manager_btn", onClickRemoveEstateManager, this);
02040         childSetAction("message_estate_btn", onClickMessageEstate, this);
02041         childSetAction("kick_user_from_estate_btn", onClickKickUser, this);
02042 
02043         return LLPanelRegionInfo::postBuild();
02044 }
02045 
02046 
02047 BOOL LLPanelEstateInfo::sendUpdate()
02048 {
02049         llinfos << "LLPanelEsateInfo::sendUpdate()" << llendl;
02050 
02051         if (getEstateID() <= ESTATE_LAST_LINDEN)
02052         {
02053                 // trying to change reserved estate, warn
02054                 gViewerWindow->alertXml("ChangeLindenEstate",
02055                                                            callbackChangeLindenEstate,
02056                                                            this);
02057         }
02058         else
02059         {
02060                 // for normal estates, just make the change
02061                 callbackChangeLindenEstate(0, this);
02062         }
02063         return TRUE;
02064 }
02065 
02066 // static
02067 void LLPanelEstateInfo::callbackChangeLindenEstate(S32 option, void* data)
02068 {
02069         LLPanelEstateInfo* self = (LLPanelEstateInfo*)data;
02070         switch(option)
02071         {
02072         case 0:
02073                 // send the update
02074                 LLFloaterRegionInfo::nextInvoice();
02075                 self->commitEstateInfo();
02076                 break;
02077         case 1:
02078         default:
02079                 // do nothing
02080                 break;
02081         }
02082 }
02083 
02084 
02085 /*
02086 // Request = "getowner"
02087 // SParam[0] = "" (empty string)
02088 // IParam[0] = serial
02089 void LLPanelEstateInfo::getEstateOwner()
02090 {
02091         // TODO -- disable the panel
02092         // and call this function whenever we cross a region boundary
02093         // re-enable when owner matches, and get new estate info
02094         LLMessageSystem* msg = gMessageSystem;
02095         msg->newMessageFast(_PREHASH_EstateOwnerRequest);
02096         msg->nextBlockFast(_PREHASH_AgentData);
02097         msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
02098 
02099         msg->nextBlockFast(_PREHASH_RequestData);
02100         msg->addStringFast(_PREHASH_Request, "getowner");
02101 
02102         // we send an empty string so that the variable block is not empty
02103         msg->nextBlockFast(_PREHASH_StringData);
02104         msg->addStringFast(_PREHASH_SParam, "");
02105 
02106         msg->nextBlockFast(_PREHASH_IntegerData);
02107         msg->addS32Fast(_PREHASH_IParam, LLFloaterRegionInfo::getSerial());
02108 
02109         gAgent.sendMessage();
02110 }
02111 */
02112 
02113 // key = "estatechangeinfo"
02114 // strings[0] = str(estate_id) (added by simulator before relay - not here)
02115 // strings[1] = estate_name
02116 // strings[2] = str(estate_flags)
02117 // strings[3] = str((S32)(sun_hour * 1024.f))
02118 void LLPanelEstateInfo::commitEstateInfo()
02119 {
02120         LLMessageSystem* msg = gMessageSystem;
02121         msg->newMessage("EstateOwnerMessage");
02122         msg->nextBlockFast(_PREHASH_AgentData);
02123         msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
02124         msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
02125         msg->addUUIDFast(_PREHASH_TransactionID, LLUUID::null); //not used
02126 
02127         msg->nextBlock("MethodData");
02128         msg->addString("Method", "estatechangeinfo");
02129         msg->addUUID("Invoice", LLFloaterRegionInfo::getLastInvoice());
02130 
02131         msg->nextBlock("ParamList");
02132         msg->addString("Parameter", getEstateName());
02133 
02134         char buf[MAX_STRING];           /* Flawfinder: ignore*/
02135         snprintf(buf, MAX_STRING, "%u", computeEstateFlags());                  /* Flawfinder: ignore */
02136         msg->nextBlock("ParamList");
02137         msg->addString("Parameter", buf);
02138 
02139         F32 sun_hour = getSunHour();
02140         if (childGetValue("use_global_time_check").asBoolean())
02141         {
02142                 sun_hour = 0.f; // 0 = global time
02143         }
02144 
02145         snprintf(buf, MAX_STRING, "%d", (S32)(sun_hour*1024.0f));       /* Flawfinder: ignore */
02146         msg->nextBlock("ParamList");
02147         msg->addString("Parameter", buf);
02148 
02149         gAgent.sendMessage();
02150 }
02151 
02152 void LLPanelEstateInfo::setEstateFlags(U32 flags)
02153 {
02154         childSetValue("externally_visible_check", LLSD(flags & REGION_FLAGS_EXTERNALLY_VISIBLE ? TRUE : FALSE) );
02155         childSetValue("fixed_sun_check", LLSD(flags & REGION_FLAGS_SUN_FIXED ? TRUE : FALSE) );
02156         childSetValue(
02157                 "voice_chat_check",
02158                 LLSD(flags & REGION_FLAGS_ALLOW_VOICE ? TRUE : FALSE));
02159         childSetValue("allow_direct_teleport", LLSD(flags & REGION_FLAGS_ALLOW_DIRECT_TELEPORT ? TRUE : FALSE) );
02160         childSetValue("deny_anonymous", LLSD(flags & REGION_FLAGS_DENY_ANONYMOUS ? TRUE : FALSE) );
02161         childSetValue("deny_identified", LLSD(flags & REGION_FLAGS_DENY_IDENTIFIED ? TRUE : FALSE) );
02162         childSetValue("deny_transacted", LLSD(flags & REGION_FLAGS_DENY_TRANSACTED ? TRUE : FALSE) );
02163         childSetVisible("abuse_email_text", flags & REGION_FLAGS_ABUSE_EMAIL_TO_ESTATE_OWNER);
02164 }
02165 
02166 U32 LLPanelEstateInfo::computeEstateFlags()
02167 {
02168         U32 flags = 0;
02169 
02170         if (childGetValue("externally_visible_check").asBoolean())
02171         {
02172                 flags |= REGION_FLAGS_EXTERNALLY_VISIBLE;
02173         }
02174 
02175         if ( childGetValue("voice_chat_check").asBoolean() )
02176         {
02177                 flags |= REGION_FLAGS_ALLOW_VOICE;
02178         }
02179         
02180         if (childGetValue("allow_direct_teleport").asBoolean())
02181         {
02182                 flags |= REGION_FLAGS_ALLOW_DIRECT_TELEPORT;
02183         }
02184 
02185         if (childGetValue("fixed_sun_check").asBoolean())
02186         {
02187                 flags |= REGION_FLAGS_SUN_FIXED;
02188         }
02189         
02190         if (childGetValue("deny_anonymous").asBoolean())
02191         {
02192                 flags |= REGION_FLAGS_DENY_ANONYMOUS;
02193         }
02194         
02195         if (childGetValue("deny_identified").asBoolean())
02196         {
02197                 flags |= REGION_FLAGS_DENY_IDENTIFIED;
02198         }
02199 
02200         if (childGetValue("deny_transacted").asBoolean())
02201         {
02202                 flags |= REGION_FLAGS_DENY_TRANSACTED;
02203         }
02204         
02205         return flags;
02206 }
02207 
02208 BOOL LLPanelEstateInfo::getGlobalTime()
02209 {
02210         return childGetValue("use_global_time_check").asBoolean();
02211 }
02212 
02213 void LLPanelEstateInfo::setGlobalTime(bool b)
02214 {
02215         childSetValue("use_global_time_check", LLSD(b));
02216         childSetEnabled("fixed_sun_check", LLSD(!b));
02217         childSetEnabled("sun_hour_slider", LLSD(!b));
02218         if (b)
02219         {
02220                 childSetValue("sun_hour_slider", LLSD(0.f));
02221         }
02222 }
02223 
02224 
02225 BOOL LLPanelEstateInfo::getFixedSun()
02226 {
02227         return childGetValue("fixed_sun_check").asBoolean();
02228 }
02229 
02230 void LLPanelEstateInfo::setSunHour(F32 sun_hour)
02231 {
02232         if(sun_hour < 6.0f)
02233         {
02234                 sun_hour = 24.0f + sun_hour;
02235         }
02236         childSetValue("sun_hour_slider", LLSD(sun_hour));
02237 }
02238 
02239 F32 LLPanelEstateInfo::getSunHour()
02240 {
02241         if (childIsEnabled("sun_hour_slider"))
02242         {
02243                 return (F32)childGetValue("sun_hour_slider").asReal();
02244         }
02245         return 0.f;
02246 }
02247 
02248 const std::string LLPanelEstateInfo::getEstateName() const
02249 {
02250         return childGetValue("estate_name").asString();
02251 }
02252 
02253 void LLPanelEstateInfo::setEstateName(const std::string& name)
02254 {
02255         childSetValue("estate_name", LLSD(name));
02256 }
02257 
02258 const std::string LLPanelEstateInfo::getOwnerName() const
02259 {
02260         return childGetValue("estate_owner").asString();
02261 }
02262 
02263 void LLPanelEstateInfo::setOwnerName(const std::string& name)
02264 {
02265         childSetValue("estate_owner", LLSD(name));
02266 }
02267 
02268 void LLPanelEstateInfo::setAccessAllowedEnabled(bool enable_agent,
02269                                                                                                 bool enable_group,
02270                                                                                                 bool enable_ban)
02271 {
02272         childSetEnabled("allow_resident_label", enable_agent);
02273         childSetEnabled("allowed_avatar_name_list", enable_agent);
02274         childSetVisible("allowed_avatar_name_list", enable_agent);
02275         childSetEnabled("add_allowed_avatar_btn", enable_agent);
02276         childSetEnabled("remove_allowed_avatar_btn", enable_agent);
02277 
02278         // Groups
02279         childSetEnabled("allow_group_label", enable_group);
02280         childSetEnabled("allowed_group_name_list", enable_group);
02281         childSetVisible("allowed_group_name_list", enable_group);
02282         childSetEnabled("add_allowed_group_btn", enable_group);
02283         childSetEnabled("remove_allowed_group_btn", enable_group);
02284 
02285         // Ban
02286         childSetEnabled("ban_resident_label", enable_ban);
02287         childSetEnabled("banned_avatar_name_list", enable_ban);
02288         childSetVisible("banned_avatar_name_list", enable_ban);
02289         childSetEnabled("add_banned_avatar_btn", enable_ban);
02290         childSetEnabled("remove_banned_avatar_btn", enable_ban);
02291 
02292         // Update removal buttons if needed
02293         if (enable_agent)
02294         {
02295                 checkRemovalButton("allowed_avatar_name_list");
02296         }
02297 
02298         if (enable_group)
02299         {
02300                 checkRemovalButton("allowed_group_name_list");
02301         }
02302 
02303         if (enable_ban)
02304         {
02305                 checkRemovalButton("banned_avatar_name_list");
02306         }
02307 }
02308 
02309 // static
02310 void LLPanelEstateInfo::callbackCacheName(
02311         const LLUUID& id,
02312         const char* first,
02313         const char* last,
02314         BOOL is_group,
02315         void*)
02316 {
02317         LLPanelEstateInfo* self = LLFloaterRegionInfo::getPanelEstate();
02318         if (!self) return;
02319 
02320         std::string name;
02321         
02322         if (id.isNull())
02323         {
02324                 name = "(none)";
02325         }
02326         else
02327         {
02328                 name = first;
02329                 name += " ";
02330                 name += last;
02331         }
02332 
02333         self->setOwnerName(name);
02334 }
02335 
02336 void LLPanelEstateInfo::clearAccessLists() 
02337 {
02338         LLNameListCtrl* name_list = LLViewerUICtrlFactory::getNameListByName(this, "allowed_avatar_name_list");
02339         if (name_list)
02340         {
02341                 name_list->deleteAllItems();
02342         }
02343 
02344         name_list = LLViewerUICtrlFactory::getNameListByName(this, "banned_avatar_name_list");
02345         if (name_list)
02346         {
02347                 name_list->deleteAllItems();
02348         }
02349 }
02350 
02351 // enables/disables the "remove" button for the various allow/ban lists
02352 BOOL LLPanelEstateInfo::checkRemovalButton(std::string name)
02353 {
02354         std::string btn_name = "";
02355         if (name == "allowed_avatar_name_list")
02356         {
02357                 btn_name = "remove_allowed_avatar_btn";
02358         }
02359         else if (name == "allowed_group_name_list")
02360         {
02361                 btn_name = "remove_allowed_group_btn";
02362         }
02363         else if (name == "banned_avatar_name_list")
02364         {
02365                 btn_name = "remove_banned_avatar_btn";
02366         }
02367         else if (name == "estate_manager_name_list")
02368         {
02369                 btn_name = "remove_estate_manager_btn";
02370         }
02371 
02372         // enable the remove button if something is selected
02373         LLNameListCtrl* name_list = LLViewerUICtrlFactory::getNameListByName(this, name);
02374         childSetEnabled(btn_name.c_str(), name_list && name_list->getFirstSelected() ? TRUE : FALSE);
02375 
02376         return (btn_name != "");
02377 }
02378 
02379 BOOL LLPanelEstateInfo::checkSunHourSlider(LLUICtrl* child_ctrl)
02380 {
02381         BOOL found_child_ctrl = FALSE;
02382         if (child_ctrl->getName() == "sun_hour_slider")
02383         {
02384                 enableButton("apply_btn");
02385                 found_child_ctrl = TRUE;
02386         }
02387         return found_child_ctrl;
02388 }
02389 
02390 // static
02391 void LLPanelEstateInfo::onClickMessageEstate(void* userdata)
02392 {
02393         llinfos << "LLPanelEstateInfo::onClickMessageEstate" << llendl;
02394         gViewerWindow->alertXmlEditText("MessageEstate", LLString::format_map_t(),
02395                                                                         NULL, NULL,
02396                                                                         onMessageCommit, userdata);
02397 }
02398 
02399 // static
02400 void LLPanelEstateInfo::onMessageCommit(S32 option, const LLString& text, void* userdata)
02401 {
02402         if(option != 0) return;
02403         if(text.empty()) return;
02404         LLPanelEstateInfo* self = (LLPanelEstateInfo*)userdata;
02405         if(!self) return;
02406         llinfos << "Message to everyone: " << text << llendl;
02407         strings_t strings;
02408         //integers_t integers;
02409         std::string name;
02410         gAgent.buildFullname(name);
02411         strings.push_back(strings_t::value_type(name));
02412         strings.push_back(strings_t::value_type(text));
02413         LLUUID invoice(LLFloaterRegionInfo::getLastInvoice());
02414         self->sendEstateOwnerMessage(gMessageSystem, "instantmessage", invoice, strings);
02415 }
02416 
02417 LLPanelEstateCovenant::LLPanelEstateCovenant()
02418 : mCovenantID(LLUUID::null)
02419 {
02420 }
02421 
02422 // virtual 
02423 bool LLPanelEstateCovenant::refreshFromRegion(LLViewerRegion* region)
02424 {
02425         LLTextBox* region_name = (LLTextBox*)getChildByName("region_name_text");
02426         if (region_name)
02427         {
02428                 region_name->setText(region->getName());
02429         }
02430 
02431         LLTextBox* resellable_clause = (LLTextBox*)getChildByName("resellable_clause");
02432         if (resellable_clause)
02433         {
02434                 if (region->getRegionFlags() & REGION_FLAGS_BLOCK_LAND_RESELL)
02435                 {
02436                         resellable_clause->setText(childGetText("can_not_resell"));
02437                 }
02438                 else
02439                 {
02440                         resellable_clause->setText(childGetText("can_resell"));
02441                 }
02442         }
02443         
02444         LLTextBox* changeable_clause = (LLTextBox*)getChildByName("changeable_clause");
02445         if (changeable_clause)
02446         {
02447                 if (region->getRegionFlags() & REGION_FLAGS_ALLOW_PARCEL_CHANGES)
02448                 {
02449                         changeable_clause->setText(childGetText("can_change"));
02450                 }
02451                 else
02452                 {
02453                         changeable_clause->setText(childGetText("can_not_change"));
02454                 }
02455         }
02456 
02457         // let the parent class handle the general data collection. 
02458         bool rv = LLPanelRegionInfo::refreshFromRegion(region);
02459         LLMessageSystem *msg = gMessageSystem;
02460         msg->newMessage("EstateCovenantRequest");
02461         msg->nextBlockFast(_PREHASH_AgentData);
02462         msg->addUUIDFast(_PREHASH_AgentID,      gAgent.getID());
02463         msg->addUUIDFast(_PREHASH_SessionID,gAgent.getSessionID());
02464         msg->sendReliable(region->getHost());
02465         return rv;
02466 }
02467 
02468 // virtual 
02469 bool LLPanelEstateCovenant::estateUpdate(LLMessageSystem* msg)
02470 {
02471         llinfos << "LLPanelEstateCovenant::estateUpdate()" << llendl;
02472         return true;
02473 }
02474         
02475 // virtual 
02476 BOOL LLPanelEstateCovenant::postBuild()
02477 {
02478         initHelpBtn("covenant_help",            "HelpEstateCovenant");
02479         mEstateNameText = (LLTextBox*)getChildByName("estate_name_text");
02480         mEstateOwnerText = (LLTextBox*)getChildByName("estate_owner_text");
02481         mLastModifiedText = (LLTextBox*)getChildByName("covenant_timestamp_text");
02482         mEditor = (LLViewerTextEditor*)getChildByName("covenant_editor");
02483         if (mEditor) mEditor->setHandleEditKeysDirectly(TRUE);
02484         LLButton* reset_button = (LLButton*)getChildByName("reset_covenant");
02485         reset_button->setEnabled(gAgent.canManageEstate());
02486         reset_button->setClickedCallback(LLPanelEstateCovenant::resetCovenantID, NULL);
02487 
02488         return LLPanelRegionInfo::postBuild();
02489 }
02490 
02491 // virtual 
02492 void LLPanelEstateCovenant::updateChild(LLUICtrl* child_ctrl)
02493 {
02494 }
02495 
02496 // virtual
02497 BOOL LLPanelEstateCovenant::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop,
02498                                                                   EDragAndDropType cargo_type,
02499                                                                   void* cargo_data,
02500                                                                   EAcceptance* accept,
02501                                                                   LLString& tooltip_msg)
02502 {
02503         LLInventoryItem* item = (LLInventoryItem*)cargo_data;
02504 
02505         if (!gAgent.canManageEstate())
02506         {
02507                 *accept = ACCEPT_NO;
02508                 return TRUE;
02509         }
02510 
02511         switch(cargo_type)
02512         {
02513         case DAD_NOTECARD:
02514                 *accept = ACCEPT_YES_COPY_SINGLE;
02515                 if (item && drop)
02516                 {
02517                         gViewerWindow->alertXml("EstateChangeCovenant",
02518                                                                         LLPanelEstateCovenant::confirmChangeCovenantCallback,
02519                                                                         item);
02520                 }
02521                 break;
02522         default:
02523                 *accept = ACCEPT_NO;
02524                 break;
02525         }
02526 
02527         return TRUE;
02528 } 
02529 
02530 // static 
02531 void LLPanelEstateCovenant::confirmChangeCovenantCallback(S32 option, void* userdata)
02532 {
02533         LLInventoryItem* item = (LLInventoryItem*)userdata;
02534         LLPanelEstateCovenant* self = LLFloaterRegionInfo::getPanelCovenant();
02535 
02536         if (!item || !self) return;
02537 
02538         switch(option)
02539         {
02540         case 0:
02541                 self->loadInvItem(item);
02542                 break;
02543         default:
02544                 break;
02545         }
02546 }
02547 
02548 // static
02549 void LLPanelEstateCovenant::resetCovenantID(void* userdata)
02550 {
02551         gViewerWindow->alertXml("EstateChangeCovenant",
02552                                                         LLPanelEstateCovenant::confirmResetCovenantCallback,
02553                                                         NULL);
02554 }
02555 
02556 // static
02557 void LLPanelEstateCovenant::confirmResetCovenantCallback(S32 option, void* userdata)
02558 {
02559         LLPanelEstateCovenant* self = LLFloaterRegionInfo::getPanelCovenant();
02560         if (!self) return;
02561 
02562         switch(option)
02563         {
02564         case 0:         
02565                 self->loadInvItem(NULL);
02566                 break;
02567         default:
02568                 break;
02569         }
02570 }
02571 
02572 void LLPanelEstateCovenant::loadInvItem(LLInventoryItem *itemp)
02573 {
02574         const BOOL high_priority = TRUE;        
02575         if (itemp)
02576         {
02577                 gAssetStorage->getInvItemAsset(gAgent.getRegionHost(),
02578                                                                         gAgent.getID(),
02579                                                                         gAgent.getSessionID(),
02580                                                                         itemp->getPermissions().getOwner(),
02581                                                                         LLUUID::null,
02582                                                                         itemp->getUUID(),
02583                                                                         itemp->getAssetUUID(),
02584                                                                         itemp->getType(),
02585                                     onLoadComplete,
02586                                                                         (void*)this,
02587                                                                         high_priority);
02588                 mAssetStatus = ASSET_LOADING;
02589         }
02590         else
02591         {
02592                 mAssetStatus = ASSET_LOADED;
02593                 setCovenantTextEditor("There is no Covenant provided for this Estate.");
02594                 sendChangeCovenantID(LLUUID::null);
02595         }
02596 }
02597 
02598 // static
02599 void LLPanelEstateCovenant::onLoadComplete(LLVFS *vfs,
02600                                                                            const LLUUID& asset_uuid,
02601                                                                            LLAssetType::EType type,
02602                                                                            void* user_data, S32 status, LLExtStat ext_status)
02603 {
02604         llinfos << "LLPanelEstateCovenant::onLoadComplete()" << llendl;
02605         LLPanelEstateCovenant* panelp = (LLPanelEstateCovenant*)user_data;
02606         if( panelp )
02607         {
02608                 if(0 == status)
02609                 {
02610                         LLVFile file(vfs, asset_uuid, type, LLVFile::READ);
02611 
02612                         S32 file_length = file.getSize();
02613 
02614                         char* buffer = new char[file_length+1];
02615                         if (buffer == NULL)
02616                         {
02617                                 llerrs << "Memory Allocation Failed" << llendl;
02618                                 return;
02619                         }
02620 
02621                         file.read((U8*)buffer, file_length);            /* Flawfinder: ignore */
02622                         // put a EOS at the end
02623                         buffer[file_length] = 0;
02624 
02625                         if( (file_length > 19) && !strncmp( buffer, "Linden text version", 19 ) )
02626                         {
02627                                 if( !panelp->mEditor->importBuffer( buffer ) )
02628                                 {
02629                                         llwarns << "Problem importing estate covenant." << llendl;
02630                                         gViewerWindow->alertXml("ProblemImportingEstateCovenant");
02631                                 }
02632                                 else
02633                                 {
02634                                         panelp->sendChangeCovenantID(asset_uuid);       
02635                                 }
02636                         }
02637                         else
02638                         {
02639                                 // Version 0 (just text, doesn't include version number)
02640                                 panelp->sendChangeCovenantID(asset_uuid);
02641                         }
02642                         delete[] buffer;
02643                 }
02644                 else
02645                 {
02646                         if( gViewerStats )
02647                         {
02648                                 gViewerStats->incStat( LLViewerStats::ST_DOWNLOAD_FAILED );
02649                         }
02650 
02651                         if( LL_ERR_ASSET_REQUEST_NOT_IN_DATABASE == status ||
02652                                 LL_ERR_FILE_EMPTY == status)
02653                         {
02654                                 gViewerWindow->alertXml("MissingNotecardAssetID");
02655                         }
02656                         else if (LL_ERR_INSUFFICIENT_PERMISSIONS == status)
02657                         {
02658                                 gViewerWindow->alertXml("NotAllowedToViewNotecard");
02659                         }
02660                         else
02661                         {
02662                                 gViewerWindow->alertXml("UnableToLoadNotecard");
02663                         }
02664 
02665                         llwarns << "Problem loading notecard: " << status << llendl;
02666                 }
02667                 panelp->mAssetStatus = ASSET_LOADED;
02668                 panelp->setCovenantID(asset_uuid);
02669         }
02670 }
02671 
02672 // key = "estatechangecovenantid"
02673 // strings[0] = str(estate_id) (added by simulator before relay - not here)
02674 // strings[1] = str(covenant_id)
02675 void LLPanelEstateCovenant::sendChangeCovenantID(const LLUUID &asset_id)
02676 {
02677         if (asset_id != getCovenantID())
02678         {
02679         setCovenantID(asset_id);
02680 
02681                 LLMessageSystem* msg = gMessageSystem;
02682                 msg->newMessage("EstateOwnerMessage");
02683                 msg->nextBlockFast(_PREHASH_AgentData);
02684                 msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
02685                 msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
02686                 msg->addUUIDFast(_PREHASH_TransactionID, LLUUID::null); //not used
02687 
02688                 msg->nextBlock("MethodData");
02689                 msg->addString("Method", "estatechangecovenantid");
02690                 msg->addUUID("Invoice", LLFloaterRegionInfo::getLastInvoice());
02691 
02692                 msg->nextBlock("ParamList");
02693                 msg->addString("Parameter", getCovenantID().asString());
02694                 gAgent.sendReliableMessage();
02695         }
02696 }
02697 
02698 // virtual 
02699 BOOL LLPanelEstateCovenant::sendUpdate()
02700 {
02701         return TRUE;
02702 }
02703 
02704 const std::string& LLPanelEstateCovenant::getEstateName() const
02705 {
02706         return mEstateNameText->getText();
02707 }
02708 
02709 void LLPanelEstateCovenant::setEstateName(const std::string& name)
02710 {
02711         mEstateNameText->setText(name);
02712 }
02713 
02714 // static
02715 void LLPanelEstateCovenant::updateCovenantText(const std::string& string, const LLUUID& asset_id)
02716 {
02717         LLPanelEstateCovenant* panelp = LLFloaterRegionInfo::getPanelCovenant();
02718         if( panelp )
02719         {
02720                 panelp->mEditor->setText(string);
02721                 panelp->setCovenantID(asset_id);
02722         }
02723 }
02724 
02725 // static
02726 void LLPanelEstateCovenant::updateEstateName(const std::string& name)
02727 {
02728         LLPanelEstateCovenant* panelp = LLFloaterRegionInfo::getPanelCovenant();
02729         if( panelp )
02730         {
02731                 panelp->mEstateNameText->setText(name);
02732         }
02733 }
02734 
02735 // static
02736 void LLPanelEstateCovenant::updateLastModified(const std::string& text)
02737 {
02738         LLPanelEstateCovenant* panelp = LLFloaterRegionInfo::getPanelCovenant();
02739         if( panelp )
02740         {
02741                 panelp->mLastModifiedText->setText(text);
02742         }
02743 }
02744 
02745 // static
02746 void LLPanelEstateCovenant::updateEstateOwnerName(const std::string& name)
02747 {
02748         LLPanelEstateCovenant* panelp = LLFloaterRegionInfo::getPanelCovenant();
02749         if( panelp )
02750         {
02751                 panelp->mEstateOwnerText->setText(name);
02752         }
02753 }
02754 
02755 const std::string& LLPanelEstateCovenant::getOwnerName() const
02756 {
02757         return mEstateOwnerText->getText();
02758 }
02759 
02760 void LLPanelEstateCovenant::setOwnerName(const std::string& name)
02761 {
02762         mEstateOwnerText->setText(name);
02763 }
02764 
02765 void LLPanelEstateCovenant::setCovenantTextEditor(const std::string& text)
02766 {
02767         mEditor->setText(text);
02768 }
02769 
02770 /*
02771 // AgentData = agent_id
02772 // RequestData = "setowner"
02773 // StringData[0] = compressed owner id
02774 // IntegerData[0] = serial
02775 bool LLDispatchSetEstateOwner::operator()(
02776                 const LLDispatcher* dispatcher,
02777                 const std::string& key,
02778                 const sparam_t& strings,
02779                 const iparam_t& integers)
02780 {
02781         LLFloaterRegionInfo* floater = LLFloaterRegionInfo::getInstance();
02782         if (!floater) return true;
02783 
02784         LLTabContainer* tab = (LLTabContainer*)(floater->getChildByName("tab"));
02785         if (!tab) return true;
02786 
02787         LLPanelEstateInfo* panel = (LLPanelEstateInfo*)(tab->getChildByName("Estate"));
02788         if (!panel) return true;
02789 
02790         // TODO -- check owner, and disable floater if owner
02791         // does not match
02792 
02793         return true;
02794 }
02795 */
02796 
02797 // key = "estateupdateinfo"
02798 // strings[0] = estate name
02799 // strings[1] = str(owner_id)
02800 // strings[2] = str(estate_id)
02801 // strings[3] = str(estate_flags)
02802 // strings[4] = str((S32)(sun_hour * 1024))
02803 // strings[5] = str(parent_estate_id)
02804 // strings[6] = str(covenant_id)
02805 // strings[7] = str(covenant_timestamp)
02806 // strings[8] = str(send_to_agent_only)
02807 bool LLDispatchEstateUpdateInfo::operator()(
02808                 const LLDispatcher* dispatcher,
02809                 const std::string& key,
02810                 const LLUUID& invoice,
02811                 const sparam_t& strings)
02812 {
02813         LLPanelEstateInfo* panel = LLFloaterRegionInfo::getPanelEstate();
02814         if (!panel) return true;
02815 
02816         // NOTE: LLDispatcher extracts strings with an extra \0 at the
02817         // end.  If we pass the std::string direct to the UI/renderer
02818         // it draws with a weird character at the end of the string.
02819         std::string estate_name = strings[0].c_str();
02820         panel->setEstateName(estate_name);
02821 
02822 
02823         LLViewerRegion* regionp = gAgent.getRegion();
02824 
02825         LLUUID owner_id(strings[1].c_str());
02826         regionp->setOwner(owner_id);
02827         // Update estate owner name in UI
02828         const BOOL is_group = FALSE;
02829         gCacheName->get(owner_id, is_group, LLPanelEstateInfo::callbackCacheName);
02830 
02831         U32 estate_id = strtoul(strings[2].c_str(), NULL, 10);
02832         panel->setEstateID(estate_id);
02833 
02834         U32 flags = strtoul(strings[3].c_str(), NULL, 10);
02835         panel->setEstateFlags(flags);
02836 
02837         F32 sun_hour = ((F32)(strtod(strings[4].c_str(), NULL)))/1024.0f;
02838         if(sun_hour == 0 && (flags & REGION_FLAGS_SUN_FIXED ? FALSE : TRUE))
02839         {
02840                 panel->setGlobalTime(TRUE);
02841         } 
02842         else
02843         {
02844                 panel->setGlobalTime(FALSE);
02845                 panel->setSunHour(sun_hour);
02846         }
02847 
02848         bool visible_from_mainland = (bool)(flags & REGION_FLAGS_EXTERNALLY_VISIBLE);
02849         bool god = gAgent.isGodlike();
02850         bool linden_estate = (estate_id <= ESTATE_LAST_LINDEN);
02851 
02852         // If visible from mainland, disable the access allowed
02853         // UI, as anyone can teleport there.
02854         // However, gods need to be able to edit the access list for
02855         // linden estates, regardless of visibility, to allow object
02856         // and L$ transfers.
02857         bool enable_agent = (!visible_from_mainland || (god && linden_estate));
02858         bool enable_group = enable_agent;
02859         bool enable_ban = !linden_estate;
02860         panel->setAccessAllowedEnabled(enable_agent, enable_group, enable_ban);
02861 
02862         return true;
02863 }
02864 
02865 
02866 // key = "setaccess"
02867 // strings[0] = str(estate_id)
02868 // strings[1] = str(packed_access_lists)
02869 // strings[2] = str(num allowed agent ids)
02870 // strings[3] = str(num allowed group ids)
02871 // strings[4] = str(num banned agent ids)
02872 // strings[5] = str(num estate manager agent ids)
02873 // strings[6] = bin(uuid)
02874 // strings[7] = bin(uuid)
02875 // strings[8] = bin(uuid)
02876 // ...
02877 bool LLDispatchSetEstateAccess::operator()(
02878                 const LLDispatcher* dispatcher,
02879                 const std::string& key,
02880                 const LLUUID& invoice,
02881                 const sparam_t& strings)
02882 {
02883         LLPanelEstateInfo* panel = LLFloaterRegionInfo::getPanelEstate();
02884         if (!panel) return true;
02885 
02886         S32 index = 1;  // skip estate_id
02887         U32 access_flags = strtoul(strings[index++].c_str(), NULL,10);
02888         S32 num_allowed_agents = strtol(strings[index++].c_str(), NULL, 10);
02889         S32 num_allowed_groups = strtol(strings[index++].c_str(), NULL, 10);
02890         S32 num_banned_agents = strtol(strings[index++].c_str(), NULL, 10);
02891         S32 num_estate_managers = strtol(strings[index++].c_str(), NULL, 10);
02892 
02893         // sanity ckecks
02894         if (num_allowed_agents > 0
02895                 && !(access_flags & ESTATE_ACCESS_ALLOWED_AGENTS))
02896         {
02897                 llwarns << "non-zero count for allowed agents, but no corresponding flag" << llendl;
02898         }
02899         if (num_allowed_groups > 0
02900                 && !(access_flags & ESTATE_ACCESS_ALLOWED_GROUPS))
02901         {
02902                 llwarns << "non-zero count for allowed groups, but no corresponding flag" << llendl;
02903         }
02904         if (num_banned_agents > 0
02905                 && !(access_flags & ESTATE_ACCESS_BANNED_AGENTS))
02906         {
02907                 llwarns << "non-zero count for banned agents, but no corresponding flag" << llendl;
02908         }
02909         if (num_estate_managers > 0
02910                 && !(access_flags & ESTATE_ACCESS_MANAGERS))
02911         {
02912                 llwarns << "non-zero count for managers, but no corresponding flag" << llendl;
02913         }
02914 
02915         // grab the UUID's out of the string fields
02916         if (access_flags & ESTATE_ACCESS_ALLOWED_AGENTS)
02917         {
02918                 LLNameListCtrl* allowed_agent_name_list;
02919                 allowed_agent_name_list = LLViewerUICtrlFactory::getNameListByName(panel, "allowed_avatar_name_list");
02920 
02921                 int totalAllowedAgents = num_allowed_agents;
02922                 
02923                 if (allowed_agent_name_list) 
02924                 {
02925                         totalAllowedAgents += allowed_agent_name_list->getItemCount();
02926                 }
02927 
02928                 std::string msg = llformat("Allowed residents: (%d, max %d)",
02929                                                                         totalAllowedAgents,
02930                                                                         ESTATE_MAX_ACCESS_IDS);
02931                 panel->childSetValue("allow_resident_label", LLSD(msg));
02932 
02933                 if (allowed_agent_name_list)
02934                 {
02935                         //allowed_agent_name_list->deleteAllItems();
02936                         for (S32 i = 0; i < num_allowed_agents && i < ESTATE_MAX_ACCESS_IDS; i++)
02937                         {
02938                                 LLUUID id;
02939                                 memcpy(id.mData, strings[index++].data(), UUID_BYTES);          /* Flawfinder: ignore */
02940                                 allowed_agent_name_list->addNameItem(id);
02941                         }
02942                         panel->childSetEnabled("remove_allowed_avatar_btn", allowed_agent_name_list->getFirstSelected() ? TRUE : FALSE);
02943                         allowed_agent_name_list->sortByColumn(0, TRUE);
02944                 }
02945         }
02946 
02947         if (access_flags & ESTATE_ACCESS_ALLOWED_GROUPS)
02948         {
02949                 LLNameListCtrl* allowed_group_name_list;
02950                 allowed_group_name_list = LLViewerUICtrlFactory::getNameListByName(panel, "allowed_group_name_list");
02951 
02952                 std::string msg = llformat("Allowed groups: (%d, max %d)",
02953                                                                         num_allowed_groups,
02954                                                                         (S32) ESTATE_MAX_GROUP_IDS);
02955                 panel->childSetValue("allow_group_label", LLSD(msg));
02956 
02957                 if (allowed_group_name_list)
02958                 {
02959                         allowed_group_name_list->deleteAllItems();
02960                         for (S32 i = 0; i < num_allowed_groups && i < ESTATE_MAX_GROUP_IDS; i++)
02961                         {
02962                                 LLUUID id;
02963                                 memcpy(id.mData, strings[index++].data(), UUID_BYTES);          /* Flawfinder: ignore */
02964                                 allowed_group_name_list->addGroupNameItem(id);
02965                         }
02966                         panel->childSetEnabled("remove_allowed_group_btn", allowed_group_name_list->getFirstSelected() ? TRUE : FALSE);
02967                         allowed_group_name_list->sortByColumn(0, TRUE);
02968                 }
02969         }
02970 
02971         if (access_flags & ESTATE_ACCESS_BANNED_AGENTS)
02972         {
02973                 LLNameListCtrl* banned_agent_name_list;
02974                 banned_agent_name_list = LLViewerUICtrlFactory::getNameListByName(panel, "banned_avatar_name_list");
02975 
02976                 int totalBannedAgents = num_banned_agents;
02977                 
02978                 if (banned_agent_name_list) 
02979                 {
02980                         totalBannedAgents += banned_agent_name_list->getItemCount();
02981                 }
02982 
02983 
02984                 std::string msg = llformat("Banned residents: (%d, max %d)",
02985                                                                         totalBannedAgents,
02986                                                                         ESTATE_MAX_ACCESS_IDS);
02987                 panel->childSetValue("ban_resident_label", LLSD(msg));
02988 
02989                 if (banned_agent_name_list)
02990                 {
02991                         //banned_agent_name_list->deleteAllItems();
02992                         for (S32 i = 0; i < num_banned_agents && i < ESTATE_MAX_ACCESS_IDS; i++)
02993                         {
02994                                 LLUUID id;
02995                                 memcpy(id.mData, strings[index++].data(), UUID_BYTES);          /* Flawfinder: ignore */
02996                                 banned_agent_name_list->addNameItem(id);
02997                         }
02998                         panel->childSetEnabled("remove_banned_avatar_btn", banned_agent_name_list->getFirstSelected() ? TRUE : FALSE);
02999                         banned_agent_name_list->sortByColumn(0, TRUE);
03000                 }
03001         }
03002 
03003         if (access_flags & ESTATE_ACCESS_MANAGERS)
03004         {
03005                 std::string msg = llformat("Estate Managers: (%d, max %d)",
03006                                                                         num_estate_managers,
03007                                                                         ESTATE_MAX_MANAGERS);
03008                 panel->childSetValue("estate_manager_label", LLSD(msg));
03009 
03010                 LLNameListCtrl* estate_manager_name_list =
03011                         LLViewerUICtrlFactory::getNameListByName(panel, "estate_manager_name_list");
03012                 if (estate_manager_name_list)
03013                 {       
03014                         estate_manager_name_list->deleteAllItems();             // Clear existing entries
03015 
03016                         // There should be only ESTATE_MAX_MANAGERS people in the list, but if the database gets more (SL-46107) don't 
03017                         // truncate the list unless it's really big.  Go ahead and show the extras so the user doesn't get confused, 
03018                         // and they can still remove them.
03019                         for (S32 i = 0; i < num_estate_managers && i < (ESTATE_MAX_MANAGERS * 4); i++)
03020                         {
03021                                 LLUUID id;
03022                                 memcpy(id.mData, strings[index++].data(), UUID_BYTES);          /* Flawfinder: ignore */
03023                                 estate_manager_name_list->addNameItem(id);
03024                         }
03025                         panel->childSetEnabled("remove_estate_manager_btn", estate_manager_name_list->getFirstSelected() ? TRUE : FALSE);
03026                         estate_manager_name_list->sortByColumn(0, TRUE);
03027                 }
03028         }
03029 
03030         return true;
03031 }

Generated on Thu Jul 1 06:08:35 2010 for Second Life Viewer by  doxygen 1.4.7