llfloaterregioninfo.cpp 127 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612
  1. /**
  2. * @file llfloaterregioninfo.cpp
  3. * @author Aaron Brashears
  4. * @brief Implementation of the region info and controls floater and panels.
  5. *
  6. * $LicenseInfo:firstyear=2004&license=viewergpl$
  7. *
  8. * Copyright (c) 2004-2009, Linden Research, Inc.
  9. * Copyright (c) 2009-2024, Henri Beauchamp.
  10. *
  11. * Second Life Viewer Source Code
  12. * The source code in this file ("Source Code") is provided by Linden Lab
  13. * to you under the terms of the GNU General Public License, version 2.0
  14. * ("GPL"), unless you have obtained a separate licensing agreement
  15. * ("Other License"), formally executed by you and Linden Lab. Terms of
  16. * the GPL can be found in doc/GPL-license.txt in this distribution, or
  17. * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  18. *
  19. * There are special exceptions to the terms and conditions of the GPL as
  20. * it is applied to this Source Code. View the full text of the exception
  21. * in the file doc/FLOSS-exception.txt in this software distribution, or
  22. * online at
  23. * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  24. *
  25. * By copying, modifying or distributing this software, you acknowledge
  26. * that you have read and understood your obligations described above,
  27. * and agree to abide by those obligations.
  28. *
  29. * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
  30. * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
  31. * COMPLETENESS OR PERFORMANCE.
  32. * $/LicenseInfo$
  33. */
  34. #include "llviewerprecompiledheaders.h"
  35. #include "llfloaterregioninfo.h"
  36. #include "llalertdialog.h"
  37. #include "llbutton.h"
  38. #include "llcachename.h"
  39. #include "llcheckboxctrl.h"
  40. #include "llcombobox.h"
  41. #include "llcorehttputil.h"
  42. #include "lldir.h"
  43. #include "lldispatcher.h"
  44. #include "llexperiencecache.h"
  45. #include "llfilesystem.h"
  46. #include "llfontgl.h"
  47. #include "llglheaders.h"
  48. #include "llgridmanager.h" // For gIsInSecondLife
  49. #include "llinventory.h"
  50. #include "lllineeditor.h"
  51. #include "llnamelistctrl.h"
  52. #include "llnotifications.h"
  53. #include "llradiogroup.h"
  54. #include "llrenderutils.h" // For gl_draw_scaled_image()
  55. #include "llsliderctrl.h"
  56. #include "llspinctrl.h"
  57. #include "lltabcontainer.h"
  58. #include "lltextbox.h"
  59. #include "lltrans.h"
  60. #include "lluictrlfactory.h"
  61. #include "llxfermanager.h"
  62. #include "llmessage.h"
  63. #include "llagent.h"
  64. #include "llappviewer.h"
  65. #include "llfloateravatarpicker.h"
  66. #include "llfloatergodtools.h" // For send_sim_wide_deletes()
  67. #include "llfloatergroups.h"
  68. #include "hbfloaterinvitemspicker.h"
  69. #include "llfloatertelehub.h"
  70. #include "llfloatertopobjects.h"
  71. #include "llgltfmateriallist.h"
  72. #include "llinventorymodel.h"
  73. #include "llpanelexperiencelisteditor.h"
  74. #include "hbpanellandenvironment.h"
  75. #include "llpipeline.h"
  76. #include "lltexturectrl.h"
  77. #include "llviewercontrol.h"
  78. #include "llviewerregion.h"
  79. #include "llviewerstats.h"
  80. #include "llviewerinventory.h"
  81. #include "llviewertexteditor.h"
  82. #include "llviewertexturelist.h"
  83. #include "llvlcomposition.h"
  84. #define ELAR_ENABLED 0 // Enable when server support is implemented
  85. constexpr U32 CORNER_COUNT = 4;
  86. constexpr U32 MAX_LISTED_NAMES = 100;
  87. bool gEstateDispatchInitialized = false;
  88. std::string LLEstateInfoModel::sEstateName;
  89. LLUUID LLEstateInfoModel::sOwnerId;
  90. U32 LLEstateInfoModel::sEstateId = 0;
  91. U64 LLEstateInfoModel::sEstateFlags = 0;
  92. F32 LLEstateInfoModel::sSunHour = 0.f;
  93. ///----------------------------------------------------------------------------
  94. /// Local classes
  95. ///----------------------------------------------------------------------------
  96. class LLDispatchEstateUpdateInfo final : public LLDispatchHandler
  97. {
  98. public:
  99. LLDispatchEstateUpdateInfo() = default;
  100. bool operator()(const LLDispatcher*, const std::string& key,
  101. const LLUUID& invoice, const sparam_t& strings) override;
  102. };
  103. // key = "estateupdateinfo"
  104. // strings[0] = estate name
  105. // strings[1] = str(owner_id)
  106. // strings[2] = str(estate_id)
  107. // strings[3] = str(estate_flags)
  108. // strings[4] = str((S32)(sun_hour * 1024))
  109. // strings[5] = str(parent_estate_id)
  110. // strings[6] = str(covenant_id)
  111. // strings[7] = str(covenant_timestamp)
  112. // strings[8] = str(send_to_agent_only)
  113. // strings[9] = str(abuse_email_addr)
  114. bool LLDispatchEstateUpdateInfo::operator()(const LLDispatcher*,
  115. const std::string& key,
  116. const LLUUID&,
  117. const sparam_t& strings)
  118. {
  119. // Unconditionnally fill-up the LLEstateInfoModel member variables.
  120. // NOTE: LLDispatcher extracts strings with an extra \0 at the end. If we
  121. // pass the std::string direct to the UI/renderer it draws with a weird
  122. // character at the end of the string. Therefore do preserve the c_str()
  123. // calls !
  124. LLEstateInfoModel::sEstateName = strings[0].c_str();
  125. LLEstateInfoModel::sOwnerId.set(strings[1]);
  126. LLEstateInfoModel::sEstateId = strtoul(strings[2].c_str(), NULL, 10);
  127. U64 flags = strtoul(strings[3].c_str(), NULL, 10);
  128. LLEstateInfoModel::sEstateFlags = flags;
  129. LLEstateInfoModel::sSunHour = F32(strtod(strings[4].c_str(),
  130. NULL)) / 1024.0f;
  131. // Then update the agent region if any (and if none, we got disconnected,
  132. // so give up)
  133. LLViewerRegion* regionp = gAgent.getRegion();
  134. if (!regionp) return true;
  135. regionp->setOwner(LLEstateInfoModel::sOwnerId);
  136. // And finally, update the region info floater if any (else, give-up)
  137. LLPanelEstateInfo* panel = LLFloaterRegionInfo::getPanelEstate();
  138. if (!panel) return true;
  139. panel->setEstateName(LLEstateInfoModel::sEstateName);
  140. // Update estate owner name in UI
  141. if (gCacheNamep)
  142. {
  143. gCacheNamep->get(LLEstateInfoModel::sOwnerId, false,
  144. LLPanelEstateInfo::callbackCacheName);
  145. }
  146. panel->setEstateID(LLEstateInfoModel::sEstateId);
  147. panel->setEstateFlags(flags);
  148. if (LLEstateInfoModel::sSunHour == 0 &&
  149. (flags & REGION_FLAGS_SUN_FIXED) == 0)
  150. {
  151. panel->setGlobalTime(true);
  152. }
  153. else
  154. {
  155. panel->setGlobalTime(false);
  156. panel->setSunHour(LLEstateInfoModel::sSunHour);
  157. }
  158. bool visible_from_mainland = (bool)(flags & REGION_FLAGS_EXTERNALLY_VISIBLE);
  159. bool god = gAgent.isGodlike();
  160. bool linden_estate = LLEstateInfoModel::sEstateId <= ESTATE_LAST_LINDEN;
  161. LLPanelEstateAccess* panel2 = LLFloaterRegionInfo::getPanelAccess();
  162. if (!panel2) return true;
  163. // If visible from mainland, disable the access allowed UI, as anyone can
  164. // teleport there. However, gods need to be able to edit the access list
  165. // for linden estates, regardless of visibility, to allow object and L$
  166. // transfers. In OpenSim, ignore linden estate flag.
  167. bool enable_agent = !visible_from_mainland || (god && linden_estate) ||
  168. !gIsInSecondLife;
  169. bool enable_ban = !linden_estate || !gIsInSecondLife;
  170. panel2->setAccessAllowedEnabled(enable_agent, enable_agent, enable_ban);
  171. panel2->updateControls();
  172. HBPanelLandEnvironment* panel3 =
  173. LLFloaterRegionInfo::getPanelEnvironment();
  174. if (panel3)
  175. {
  176. panel3->refresh();
  177. }
  178. return true;
  179. }
  180. class LLDispatchSetEstateAccess final : public LLDispatchHandler
  181. {
  182. public:
  183. LLDispatchSetEstateAccess() = default;
  184. bool operator()(const LLDispatcher*, const std::string& key,
  185. const LLUUID& invoice, const sparam_t& strings) override;
  186. };
  187. // key = "setaccess"
  188. // strings[0] = str(estate_id)
  189. // strings[1] = str(packed_access_lists)
  190. // strings[2] = str(num allowed agent ids)
  191. // strings[3] = str(num allowed group ids)
  192. // strings[4] = str(num banned agent ids)
  193. // strings[5] = str(num estate manager agent ids)
  194. // strings[6...] = bin(uuid)
  195. bool LLDispatchSetEstateAccess::operator()(const LLDispatcher*,
  196. const std::string& key,
  197. const LLUUID&,
  198. const sparam_t& strings)
  199. {
  200. LLPanelEstateAccess* panel = LLFloaterRegionInfo::getPanelAccess();
  201. if (!panel) return true; // We are since gone !
  202. if (gAgent.hasRegionCapability("EstateAccess"))
  203. {
  204. if (panel->getPendingUpdate())
  205. {
  206. panel->setPendingUpdate(false);
  207. panel->updateLists();
  208. }
  209. return true;
  210. }
  211. // Old, non-capability based code, kept for OpenSIM compatibility
  212. S32 index = 1; // skip estate_id
  213. U32 access_flags = strtoul(strings[index++].c_str(), NULL, 10);
  214. S32 num_allowed_agents = strtol(strings[index++].c_str(), NULL, 10);
  215. S32 num_allowed_groups = strtol(strings[index++].c_str(), NULL, 10);
  216. S32 num_banned_agents = strtol(strings[index++].c_str(), NULL, 10);
  217. S32 num_estate_managers = strtol(strings[index++].c_str(), NULL, 10);
  218. // sanity ckecks
  219. if (num_allowed_agents > 0 &&
  220. !(access_flags & ESTATE_ACCESS_ALLOWED_AGENTS))
  221. {
  222. llwarns << "non-zero count for allowed agents, but no corresponding flag"
  223. << llendl;
  224. }
  225. if (num_allowed_groups > 0 &&
  226. !(access_flags & ESTATE_ACCESS_ALLOWED_GROUPS))
  227. {
  228. llwarns << "non-zero count for allowed groups, but no corresponding flag"
  229. << llendl;
  230. }
  231. if (num_banned_agents > 0 && !(access_flags & ESTATE_ACCESS_BANNED_AGENTS))
  232. {
  233. llwarns << "non-zero count for banned agents, but no corresponding flag"
  234. << llendl;
  235. }
  236. if (num_estate_managers > 0 && !(access_flags & ESTATE_ACCESS_MANAGERS))
  237. {
  238. llwarns << "non-zero count for managers, but no corresponding flag"
  239. << llendl;
  240. }
  241. LLNameListCtrl* name_list;
  242. // Grab the UUIDs out of the string fields
  243. if (access_flags & ESTATE_ACCESS_ALLOWED_AGENTS)
  244. {
  245. name_list = panel->mAllowedAvatars;
  246. S32 total = num_allowed_agents;
  247. if (name_list)
  248. {
  249. total += name_list->getItemCount();
  250. }
  251. std::string msg = llformat("Allowed residents: (%d, max %d)", total,
  252. ESTATE_MAX_ACCESS_IDS);
  253. panel->childSetValue("allow_resident_label", LLSD(msg));
  254. if (name_list)
  255. {
  256. #if 0
  257. name_list->deleteAllItems();
  258. #endif
  259. for (S32 i = 0;
  260. i < num_allowed_agents && i < ESTATE_MAX_ACCESS_IDS; ++i)
  261. {
  262. LLUUID id;
  263. memcpy(id.mData, strings[index++].data(), UUID_BYTES);
  264. name_list->addNameItem(id);
  265. }
  266. panel->childSetEnabled("remove_allowed_avatar_btn",
  267. name_list->getFirstSelected() != NULL);
  268. name_list->sortByName(true);
  269. }
  270. }
  271. if (access_flags & ESTATE_ACCESS_ALLOWED_GROUPS)
  272. {
  273. name_list = panel->mAllowedGroups;
  274. std::string msg = llformat("Allowed groups: (%d, max %d)",
  275. num_allowed_groups,
  276. (S32)ESTATE_MAX_GROUP_IDS);
  277. panel->childSetValue("allow_group_label", LLSD(msg));
  278. if (name_list)
  279. {
  280. name_list->deleteAllItems();
  281. for (S32 i = 0; i < num_allowed_groups && i < ESTATE_MAX_GROUP_IDS;
  282. ++i)
  283. {
  284. LLUUID id;
  285. memcpy(id.mData, strings[index++].data(), UUID_BYTES);
  286. name_list->addGroupNameItem(id);
  287. }
  288. panel->childSetEnabled("remove_allowed_group_btn",
  289. name_list->getFirstSelected() != NULL);
  290. name_list->sortByName(true);
  291. }
  292. }
  293. if (access_flags & ESTATE_ACCESS_BANNED_AGENTS)
  294. {
  295. name_list = panel->mBannedAvatars;
  296. S32 total = num_banned_agents;
  297. if (name_list)
  298. {
  299. total += name_list->getItemCount();
  300. }
  301. std::string msg = llformat("Banned residents: (%d, max %d)", total,
  302. ESTATE_MAX_BANNED_IDS);
  303. panel->childSetValue("ban_resident_label", LLSD(msg));
  304. if (name_list)
  305. {
  306. #if 0
  307. name_list->deleteAllItems();
  308. #endif
  309. std::string na = LLTrans::getString("na");
  310. for (S32 i = 0; i < num_banned_agents && i < ESTATE_MAX_BANNED_IDS;
  311. ++i)
  312. {
  313. LLUUID id;
  314. memcpy(id.mData, strings[index++].data(), UUID_BYTES);
  315. LLSD item;
  316. item["id"] = id;
  317. LLSD& columns = item["columns"];
  318. columns[0]["column"] = "name"; // value is auto-populated
  319. columns[1]["column"] = "last_login_date";
  320. columns[1]["value"] = na;
  321. columns[2]["column"] = "ban_date";
  322. columns[2]["value"] = na;
  323. columns[3]["column"] = "bannedby";
  324. columns[3]["value"] = na;
  325. name_list->addElement(item);
  326. }
  327. panel->childSetEnabled("remove_banned_avatar_btn",
  328. name_list->getFirstSelected() != NULL);
  329. name_list->sortByName(true);
  330. }
  331. }
  332. if (access_flags & ESTATE_ACCESS_MANAGERS)
  333. {
  334. std::string msg = llformat("Estate Managers: (%d, max %d)",
  335. num_estate_managers,
  336. ESTATE_MAX_MANAGERS);
  337. panel->childSetValue("estate_manager_label", LLSD(msg));
  338. name_list = panel->mEstateManagers;
  339. if (name_list)
  340. {
  341. // Clear existing entries
  342. name_list->deleteAllItems();
  343. // There should be only ESTATE_MAX_MANAGERS people in the list,
  344. // but if the database gets more (SL-46107) don't truncate the
  345. // list unless it's really big. Go ahead and show the extras so
  346. // the user doesn't get confused, and they can still remove them.
  347. for (S32 i = 0;
  348. i < num_estate_managers && i < ESTATE_MAX_MANAGERS * 4; ++i)
  349. {
  350. LLUUID id;
  351. memcpy(id.mData, strings[index++].data(), UUID_BYTES);
  352. name_list->addNameItem(id);
  353. }
  354. panel->childSetEnabled("remove_estate_manager_btn",
  355. name_list->getFirstSelected() != NULL);
  356. name_list->sortByName(true);
  357. }
  358. }
  359. return true;
  360. }
  361. class LLEstateAccessChangeInfo
  362. {
  363. public:
  364. LLEstateAccessChangeInfo(const LLSD& sd)
  365. {
  366. mDialogName = sd["dialog_name"].asString();
  367. mOperationFlag = (U32)sd["operation"].asInteger();
  368. for (LLSD::array_const_iterator it = sd["allowed_ids"].beginArray(),
  369. end = sd["allowed_ids"].endArray();
  370. it != end; ++it)
  371. {
  372. mAgentOrGroupIDs.emplace_back(it->asUUID());
  373. }
  374. }
  375. const LLSD asLLSD() const
  376. {
  377. LLSD sd;
  378. sd["name"] = mDialogName;
  379. sd["operation"] = (S32)mOperationFlag;
  380. for (U32 i = 0, count = mAgentOrGroupIDs.size(); i < count; ++i)
  381. {
  382. sd["allowed_ids"].append(mAgentOrGroupIDs[i]);
  383. }
  384. return sd;
  385. }
  386. public:
  387. // ESTATE_ACCESS_BANNED_AGENT_ADD, _REMOVE, etc.
  388. U32 mOperationFlag;
  389. std::string mDialogName;
  390. // List of agent IDs to apply to this change
  391. uuid_vec_t mAgentOrGroupIDs;
  392. };
  393. class LLDispatchSetEstateExperience final : public LLDispatchHandler
  394. {
  395. public:
  396. LLDispatchSetEstateExperience() = default;
  397. bool operator()(const LLDispatcher*, const std::string& key,
  398. const LLUUID& invoice, const sparam_t& strings) override;
  399. static LLSD getIDs(sparam_t::const_iterator it,
  400. sparam_t::const_iterator end, S32 count);
  401. };
  402. //static
  403. LLSD LLDispatchSetEstateExperience::getIDs(sparam_t::const_iterator it,
  404. sparam_t::const_iterator end,
  405. S32 count)
  406. {
  407. LLSD ids = LLSD::emptyArray();
  408. LLUUID id;
  409. while (count-- > 0 && it < end)
  410. {
  411. memcpy(id.mData, (*(it++)).data(), UUID_BYTES);
  412. ids.append(id);
  413. }
  414. return ids;
  415. }
  416. // key = "setexperience"
  417. // strings[0] = str(estate_id)
  418. // strings[1] = str(send_to_agent_only)
  419. // strings[2] = str(num blocked)
  420. // strings[3] = str(num trusted)
  421. // strings[4] = str(num allowed)
  422. // strings[5] = bin(uuid) ...
  423. bool LLDispatchSetEstateExperience::operator()(const LLDispatcher*,
  424. const std::string& key,
  425. const LLUUID&,
  426. const sparam_t& strings)
  427. {
  428. LLPanelRegionExperiences* panelp =
  429. LLFloaterRegionInfo::getPanelExperiences();
  430. if (!panelp)
  431. {
  432. return true;
  433. }
  434. constexpr size_t MIN_SIZE = 5;
  435. if (strings.size() < MIN_SIZE)
  436. {
  437. return true;
  438. }
  439. // Skip 2 parameters
  440. sparam_t::const_iterator it = strings.begin();
  441. ++it; // U32 estate_id = strtol((*it).c_str(), NULL, 10);
  442. ++it; // U32 send_to_agent_only = strtoul((*(++it)).c_str(), NULL, 10);
  443. // Read 3 parameters
  444. S32 blocked = strtol((*(it++)).c_str(), NULL, 10);
  445. S32 trusted = strtol((*(it++)).c_str(), NULL, 10);
  446. S32 allowed = strtol((*(it++)).c_str(), NULL, 10);
  447. LLSD ids = LLSD::emptyMap()
  448. .with("blocked", getIDs(it, strings.end(), blocked))
  449. .with("trusted", getIDs(it + blocked, strings.end(), trusted))
  450. .with("allowed", getIDs(it + blocked + trusted, strings.end(),
  451. allowed));
  452. panelp->processResponse(ids);
  453. return true;
  454. }
  455. ///////////////////////////////////////////////////////////////////////////////
  456. // LLFloaterRegionInfo
  457. ///////////////////////////////////////////////////////////////////////////////
  458. LLUUID LLFloaterRegionInfo::sRequestInvoice;
  459. S32 LLFloaterRegionInfo::sLastTab = 0;
  460. LLFloaterRegionInfo::LLFloaterRegionInfo(const LLSD& seed)
  461. : mPanelEnvironment(NULL)
  462. {
  463. LLUICtrlFactory::getInstance()->buildFloater(this,
  464. "floater_region_info.xml",
  465. NULL, false);
  466. }
  467. bool LLFloaterRegionInfo::postBuild()
  468. {
  469. mTabs = getChild<LLTabContainer>("region_panels");
  470. // Construct the panels
  471. LLPanelRegionInfo* panel = new LLPanelRegionGeneralInfo;
  472. mInfoPanels.push_back(panel);
  473. LLUICtrlFactory::getInstance()->buildPanel(panel,
  474. "panel_region_general.xml");
  475. mTabs->addTabPanel(panel, panel->getLabel(), true);
  476. panel = new LLPanelRegionDebugInfo;
  477. mInfoPanels.push_back(panel);
  478. LLUICtrlFactory::getInstance()->buildPanel(panel,
  479. "panel_region_debug.xml");
  480. mTabs->addTabPanel(panel, panel->getLabel());
  481. panel = new LLPanelRegionTextureInfo;
  482. mInfoPanels.push_back(panel);
  483. LLUICtrlFactory::getInstance()->buildPanel(panel,
  484. "panel_region_texture.xml");
  485. mTabs->addTabPanel(panel, panel->getLabel());
  486. panel = new LLPanelRegionTerrainInfo;
  487. mInfoPanels.push_back(panel);
  488. LLUICtrlFactory::getInstance()->buildPanel(panel,
  489. "panel_region_terrain.xml");
  490. mTabs->addTabPanel(panel, panel->getLabel());
  491. panel = new LLPanelEstateInfo;
  492. mInfoPanels.push_back(panel);
  493. LLUICtrlFactory::getInstance()->buildPanel(panel,
  494. "panel_region_estate.xml");
  495. mTabs->addTabPanel(panel, panel->getLabel());
  496. panel = new LLPanelEstateAccess;
  497. mInfoPanels.push_back(panel);
  498. LLUICtrlFactory::getInstance()->buildPanel(panel,
  499. "panel_region_access.xml");
  500. mTabs->addTabPanel(panel, panel->getLabel());
  501. panel = new LLPanelEstateCovenant;
  502. mInfoPanels.push_back(panel);
  503. LLUICtrlFactory::getInstance()->buildPanel(panel,
  504. "panel_region_covenant.xml");
  505. mTabs->addTabPanel(panel, panel->getLabel());
  506. if (gAgent.hasRegionCapability("RegionExperiences"))
  507. {
  508. panel = new LLPanelRegionExperiences;
  509. mInfoPanels.push_back(panel);
  510. mTabs->addTabPanel(panel, panel->getLabel());
  511. }
  512. // Add the environment tab if needed
  513. if (gAgent.hasInventorySettings())
  514. {
  515. LLViewerRegion* regionp = gAgent.getRegion();
  516. mPanelEnvironment =
  517. new HBPanelLandEnvironment(regionp ? regionp->getHandle() : 0);
  518. mTabs->addTabPanel(mPanelEnvironment, mPanelEnvironment->getLabel());
  519. }
  520. gMessageSystemp->setHandlerFunc(_PREHASH_EstateOwnerMessage,
  521. &processEstateOwnerRequest);
  522. if (sLastTab < mTabs->getTabCount())
  523. {
  524. mTabs->selectTab(sLastTab);
  525. }
  526. else
  527. {
  528. sLastTab = 0;
  529. }
  530. return true;
  531. }
  532. LLFloaterRegionInfo::~LLFloaterRegionInfo()
  533. {
  534. sLastTab = mTabs->getCurrentPanelIndex();
  535. }
  536. void LLFloaterRegionInfo::onOpen()
  537. {
  538. LLRect rect = gSavedSettings.getRect("FloaterRegionInfoRect");
  539. S32 left, top;
  540. gFloaterViewp->getNewFloaterPosition(&left, &top);
  541. rect.translate(left, top);
  542. LLViewerRegion* regionp = gAgent.getRegion();
  543. if (regionp)
  544. {
  545. refreshFromRegion(gAgent.getRegion());
  546. requestRegionInfo();
  547. }
  548. LLFloater::onOpen();
  549. }
  550. //static
  551. void LLFloaterRegionInfo::requestRegionInfo()
  552. {
  553. LLFloaterRegionInfo* self = findInstance();
  554. if (!self) return;
  555. // Disable all but Covenant panels
  556. LLPanel* panel = (LLPanel*)getPanelGeneral();
  557. if (panel)
  558. {
  559. panel->setCtrlsEnabled(false);
  560. }
  561. panel = (LLPanel*)getPanelDebug();
  562. if (panel)
  563. {
  564. panel->setCtrlsEnabled(false);
  565. }
  566. panel = (LLPanel*)getPanelTerrain();
  567. if (panel)
  568. {
  569. panel->setCtrlsEnabled(false);
  570. }
  571. panel = (LLPanel*)getPanelEstate();
  572. if (panel)
  573. {
  574. panel->setCtrlsEnabled(false);
  575. }
  576. panel = (LLPanel*)getPanelAccess();
  577. if (panel)
  578. {
  579. panel->setCtrlsEnabled(false);
  580. }
  581. panel = (LLPanel*)getPanelExperiences();
  582. if (panel)
  583. {
  584. panel->setCtrlsEnabled(false);
  585. }
  586. if (self->mPanelEnvironment)
  587. {
  588. self->mPanelEnvironment->setEnabled(false);
  589. }
  590. // Must allow anyone to request the RegionInfo data so non-owners/non-gods
  591. // can see the values. We therefore cannot use an EstateOwnerMessage. JC
  592. LLMessageSystem* msg = gMessageSystemp;
  593. if (msg) // Paranoia
  594. {
  595. msg->newMessage(_PREHASH_RequestRegionInfo);
  596. msg->nextBlock(_PREHASH_AgentData);
  597. msg->addUUID(_PREHASH_AgentID, gAgentID);
  598. msg->addUUID(_PREHASH_SessionID, gAgentSessionID);
  599. gAgent.sendReliableMessage();
  600. }
  601. }
  602. //static
  603. void LLFloaterRegionInfo::processEstateOwnerRequest(LLMessageSystem* msg,
  604. void**)
  605. {
  606. static LLDispatcher dispatch;
  607. if (!findInstance()) return;
  608. if (!gEstateDispatchInitialized)
  609. {
  610. LLPanelEstateInfo::initDispatch(dispatch);
  611. }
  612. // Unpack the message
  613. std::string request;
  614. LLUUID invoice;
  615. LLDispatcher::sparam_t strings;
  616. LLDispatcher::unpackMessage(msg, request, invoice, strings);
  617. if (invoice != getLastInvoice())
  618. {
  619. LL_DEBUGS("RegionInfo") << "Mismatched estate message: " << request
  620. << " - Invoice: " << invoice << LL_ENDL;
  621. return;
  622. }
  623. // Dispatch the message
  624. dispatch.dispatch(request, invoice, strings);
  625. LLPanelEstateInfo* panelp = getPanelEstate();
  626. if (panelp)
  627. {
  628. panelp->updateControls();
  629. }
  630. }
  631. //static
  632. void LLFloaterRegionInfo::updateFromRegionInfo()
  633. {
  634. LLFloaterRegionInfo* self = findInstance();
  635. if (!self) return;
  636. LLViewerRegion* region = gAgent.getRegion();
  637. if (!region) return;
  638. bool allow_modify = gAgent.isGodlike() || region->canManageEstate();
  639. U64 region_flags = LLRegionInfoModel::sRegionFlags;
  640. // GENERAL PANEL
  641. LLPanel* panel = (LLPanel*)getPanelGeneral();
  642. if (panel)
  643. {
  644. panel->childSetValue("region_text", LLSD(LLRegionInfoModel::sSimName));
  645. panel->childSetValue("region_type", LLSD(LLRegionInfoModel::sSimType));
  646. panel->childSetValue("version_channel_text", gLastVersionChannel);
  647. panel->childSetValue("block_terraform_check",
  648. (region_flags &
  649. REGION_FLAGS_BLOCK_TERRAFORM) != 0);
  650. panel->childSetValue("block_fly_check",
  651. (region_flags & REGION_FLAGS_BLOCK_FLY) != 0);
  652. panel->childSetValue("block_fly_over_check",
  653. (region_flags & REGION_FLAGS_BLOCK_FLYOVER) != 0);
  654. panel->childSetValue("allow_damage_check",
  655. (region_flags & REGION_FLAGS_ALLOW_DAMAGE) != 0);
  656. panel->childSetValue("restrict_pushobject",
  657. (region_flags &
  658. REGION_FLAGS_RESTRICT_PUSHOBJECT) != 0);
  659. panel->childSetValue("allow_land_resell_check",
  660. (region_flags &
  661. REGION_FLAGS_BLOCK_LAND_RESELL) == 0);
  662. panel->childSetValue("allow_parcel_changes_check",
  663. (region_flags &
  664. REGION_FLAGS_ALLOW_PARCEL_CHANGES) != 0);
  665. panel->childSetValue("block_parcel_search_check",
  666. (region_flags &
  667. REGION_FLAGS_BLOCK_PARCEL_SEARCH) != 0);
  668. LLSpinCtrl* spinctrl = panel->getChild<LLSpinCtrl>("agent_limit_spin");
  669. spinctrl->setMaxValue(LLRegionInfoModel::sHardAgentLimit);
  670. spinctrl->setValue(LLSD((F32)LLRegionInfoModel::sAgentLimit));
  671. panel->childSetValue("object_bonus_spin",
  672. LLSD(LLRegionInfoModel::sObjectBonusFactor));
  673. panel->childSetValue("access_combo",
  674. LLSD(LLRegionInfoModel::sSimAccess));
  675. // Detect teen grid for maturity
  676. // *TODO add field to estate table and test that
  677. bool teen_grid = LLRegionInfoModel::sParentEstateID == 5;
  678. panel->childSetEnabled("access_combo",
  679. gAgent.isGodlike() ||
  680. (!teen_grid &&
  681. region && region->canManageEstate()));
  682. panel->setCtrlsEnabled(allow_modify);
  683. }
  684. // DEBUG PANEL
  685. panel = (LLPanel*)getPanelDebug();
  686. if (panel)
  687. {
  688. panel->childSetValue("region_text", LLSD(LLRegionInfoModel::sSimName));
  689. panel->childSetValue("disable_scripts_check",
  690. LLSD((region_flags &
  691. REGION_FLAGS_SKIP_SCRIPTS) != 0));
  692. panel->childSetValue("disable_collisions_check",
  693. LLSD((region_flags &
  694. REGION_FLAGS_SKIP_COLLISIONS) != 0));
  695. panel->childSetValue("disable_physics_check",
  696. LLSD((region_flags &
  697. REGION_FLAGS_SKIP_PHYSICS) != 0));
  698. panel->setCtrlsEnabled(allow_modify);
  699. }
  700. // TERRAIN PANEL
  701. panel = (LLPanel*)getPanelTerrain();
  702. if (panel)
  703. {
  704. panel->childSetValue("region_text", LLSD(LLRegionInfoModel::sSimName));
  705. panel->childSetValue("water_height_spin",
  706. LLSD(LLRegionInfoModel::sWaterHeight));
  707. panel->childSetValue("terrain_raise_spin",
  708. LLSD(LLRegionInfoModel::sTerrainRaiseLimit));
  709. panel->childSetValue("terrain_lower_spin",
  710. LLSD(LLRegionInfoModel::sTerrainLowerLimit));
  711. panel->childSetValue("use_estate_sun_check",
  712. LLSD(LLRegionInfoModel::sUseEstateSun));
  713. panel->childSetValue("fixed_sun_check",
  714. LLSD((region_flags &
  715. REGION_FLAGS_SUN_FIXED) != 0));
  716. panel->childSetEnabled("fixed_sun_check",
  717. allow_modify &&
  718. !LLRegionInfoModel::sUseEstateSun);
  719. panel->childSetValue("sun_hour_slider",
  720. LLSD(LLRegionInfoModel::sSunHour));
  721. panel->childSetEnabled("sun_hour_slider",
  722. allow_modify &&
  723. !LLRegionInfoModel::sUseEstateSun);
  724. panel->setCtrlsEnabled(allow_modify);
  725. }
  726. self->refreshFromRegion(region);
  727. }
  728. //static
  729. LLPanelRegionGeneralInfo* LLFloaterRegionInfo::getPanelGeneral()
  730. {
  731. LLFloaterRegionInfo* self = LLFloaterRegionInfo::findInstance();
  732. if (self)
  733. {
  734. LLPanel* panel = self->mTabs->getChild<LLPanel>("General",
  735. true, false);
  736. return (LLPanelRegionGeneralInfo*)panel;
  737. }
  738. return NULL;
  739. }
  740. //static
  741. LLPanelRegionDebugInfo* LLFloaterRegionInfo::getPanelDebug()
  742. {
  743. LLFloaterRegionInfo* self = LLFloaterRegionInfo::findInstance();
  744. if (self)
  745. {
  746. LLPanel* panel = self->mTabs->getChild<LLPanel>("Debug",
  747. true, false);
  748. return (LLPanelRegionDebugInfo*)panel;
  749. }
  750. return NULL;
  751. }
  752. //static
  753. LLPanelEstateInfo* LLFloaterRegionInfo::getPanelEstate()
  754. {
  755. LLFloaterRegionInfo* self = LLFloaterRegionInfo::findInstance();
  756. if (self)
  757. {
  758. LLPanel* panel = self->mTabs->getChild<LLPanel>("Estate",
  759. true, false);
  760. return (LLPanelEstateInfo*)panel;
  761. }
  762. return NULL;
  763. }
  764. //static
  765. LLPanelEstateAccess* LLFloaterRegionInfo::getPanelAccess()
  766. {
  767. LLFloaterRegionInfo* self = LLFloaterRegionInfo::findInstance();
  768. if (self)
  769. {
  770. LLPanel* panel = self->mTabs->getChild<LLPanel>("Access",
  771. true, false);
  772. return (LLPanelEstateAccess*)panel;
  773. }
  774. return NULL;
  775. }
  776. //static
  777. LLPanelEstateCovenant* LLFloaterRegionInfo::getPanelCovenant()
  778. {
  779. LLFloaterRegionInfo* self = LLFloaterRegionInfo::findInstance();
  780. if (self)
  781. {
  782. LLPanel* panel = self->mTabs->getChild<LLPanel>("Covenant",
  783. true, false);
  784. return (LLPanelEstateCovenant*)panel;
  785. }
  786. return NULL;
  787. }
  788. //static
  789. LLPanelRegionTerrainInfo* LLFloaterRegionInfo::getPanelTerrain()
  790. {
  791. LLFloaterRegionInfo* self = LLFloaterRegionInfo::findInstance();
  792. if (self)
  793. {
  794. LLPanel* panel = self->mTabs->getChild<LLPanel>("Terrain",
  795. true, false);
  796. return (LLPanelRegionTerrainInfo*)panel;
  797. }
  798. return NULL;
  799. }
  800. //static
  801. LLPanelRegionExperiences* LLFloaterRegionInfo::getPanelExperiences()
  802. {
  803. LLFloaterRegionInfo* self = LLFloaterRegionInfo::findInstance();
  804. if (self)
  805. {
  806. LLPanel* panel = self->mTabs->getChild<LLPanel>("Experiences",
  807. true, false);
  808. return (LLPanelRegionExperiences*)panel;
  809. }
  810. return NULL;
  811. }
  812. //static
  813. HBPanelLandEnvironment* LLFloaterRegionInfo::getPanelEnvironment()
  814. {
  815. LLFloaterRegionInfo* self = LLFloaterRegionInfo::findInstance();
  816. return self ? self->mPanelEnvironment : NULL;
  817. }
  818. void LLFloaterRegionInfo::refreshFromRegion(LLViewerRegion* regionp)
  819. {
  820. if (!regionp) return;
  821. // Call refresh from region on all panels
  822. for (S32 i = 0, count = mInfoPanels.size(); i < count; ++i)
  823. {
  824. LLPanelRegionInfo* panelp = mInfoPanels[i];
  825. panelp->refreshFromRegion(regionp);
  826. }
  827. if (mPanelEnvironment)
  828. {
  829. mPanelEnvironment->setRegionHandle(regionp->getHandle());
  830. }
  831. }
  832. void LLFloaterRegionInfo::refresh()
  833. {
  834. for (info_panels_t::iterator iter = mInfoPanels.begin();
  835. iter != mInfoPanels.end(); ++iter)
  836. {
  837. (*iter)->refresh();
  838. }
  839. if (mPanelEnvironment)
  840. {
  841. mPanelEnvironment->refresh();
  842. }
  843. }
  844. ///////////////////////////////////////////////////////////////////////////////
  845. // LLPanelRegionInfo
  846. ///////////////////////////////////////////////////////////////////////////////
  847. LLPanelRegionInfo::LLPanelRegionInfo()
  848. : LLPanel(),
  849. mComposition(NULL),
  850. mApplyBtn(NULL),
  851. mOwner(false),
  852. mCanManage(false),
  853. mEstateManager(false)
  854. {
  855. }
  856. //virtual
  857. bool LLPanelRegionInfo::postBuild()
  858. {
  859. mApplyBtn = getChild<LLButton>("apply_btn", true, false);
  860. if (mApplyBtn)
  861. {
  862. mApplyBtn->setClickedCallback(onBtnSet, this);
  863. mApplyBtn->setEnabled(false);
  864. }
  865. refresh();
  866. return true;
  867. }
  868. //virtual
  869. bool LLPanelRegionInfo::refreshFromRegion(LLViewerRegion* regionp)
  870. {
  871. if (!regionp)
  872. {
  873. mComposition = NULL;
  874. mOwner = mCanManage = mEstateManager = false;
  875. return false;
  876. }
  877. mComposition = regionp->getComposition();
  878. mHost = regionp->getHost();
  879. mOwner = regionp->getOwner() == gAgentID;
  880. mCanManage = regionp->canManageEstate();
  881. mEstateManager = regionp->isEstateManager();
  882. return true;
  883. }
  884. void LLPanelRegionInfo::enableApplyBtn(bool enable)
  885. {
  886. if (mApplyBtn)
  887. {
  888. mApplyBtn->setEnabled(enable);
  889. }
  890. }
  891. void LLPanelRegionInfo::disableApplyBtn()
  892. {
  893. if (mApplyBtn)
  894. {
  895. mApplyBtn->setEnabled(false);
  896. }
  897. }
  898. void LLPanelRegionInfo::initCtrl(const char* name)
  899. {
  900. childSetCommitCallback(name, onChangeAnything, this);
  901. }
  902. void LLPanelRegionInfo::initHelpBtn(const char* name,
  903. const std::string& xml_alert)
  904. {
  905. childSetAction(name, onClickHelp, new std::string(xml_alert));
  906. }
  907. void LLPanelRegionInfo::sendEstateOwnerMessage(const std::string& request,
  908. const strings_t& strings)
  909. {
  910. LLMessageSystem* msg = gMessageSystemp;
  911. if (!msg) return; // Paranoia
  912. llinfos << "Sending estate request '" << request << "' - Invoice: "
  913. << LLFloaterRegionInfo::getLastInvoice() << llendl;
  914. msg->newMessage(_PREHASH_EstateOwnerMessage);
  915. msg->nextBlockFast(_PREHASH_AgentData);
  916. msg->addUUIDFast(_PREHASH_AgentID, gAgentID);
  917. msg->addUUIDFast(_PREHASH_SessionID, gAgentSessionID);
  918. msg->addUUIDFast(_PREHASH_TransactionID, LLUUID::null); // Not used
  919. msg->nextBlock(_PREHASH_MethodData);
  920. msg->addString(_PREHASH_Method, request);
  921. msg->addUUID(_PREHASH_Invoice, LLFloaterRegionInfo::getLastInvoice());
  922. if (strings.empty())
  923. {
  924. msg->nextBlock(_PREHASH_ParamList);
  925. msg->addString(_PREHASH_Parameter, NULL);
  926. }
  927. else
  928. {
  929. strings_t::const_iterator it = strings.begin();
  930. strings_t::const_iterator end = strings.end();
  931. for ( ; it != end; ++it)
  932. {
  933. msg->nextBlock(_PREHASH_ParamList);
  934. msg->addString(_PREHASH_Parameter, *it);
  935. }
  936. }
  937. msg->sendReliable(mHost);
  938. }
  939. //static
  940. void LLPanelRegionInfo::onBtnSet(void* user_data)
  941. {
  942. LLPanelRegionInfo* panel = (LLPanelRegionInfo*)user_data;
  943. if (panel && panel->sendUpdate())
  944. {
  945. panel->disableApplyBtn();
  946. }
  947. }
  948. // Enables the "Apply" button if it is not already enabled
  949. //static
  950. void LLPanelRegionInfo::onChangeAnything(LLUICtrl* ctrl, void* user_data)
  951. {
  952. LLPanelRegionInfo* panel = (LLPanelRegionInfo*)user_data;
  953. if (panel)
  954. {
  955. panel->enableApplyBtn();
  956. panel->refresh();
  957. }
  958. }
  959. //static
  960. void LLPanelRegionInfo::onClickHelp(void* data)
  961. {
  962. std::string* xml_alert = (std::string*)data;
  963. gNotifications.add(*xml_alert);
  964. }
  965. ///////////////////////////////////////////////////////////////////////////////
  966. // LLPanelRegionGeneralInfo
  967. ///////////////////////////////////////////////////////////////////////////////
  968. //virtual
  969. bool LLPanelRegionGeneralInfo::refreshFromRegion(LLViewerRegion* regionp)
  970. {
  971. LLPanelRegionInfo::refreshFromRegion(regionp);
  972. bool allow_modify = mCanManage || gAgent.isGodlike();
  973. setCtrlsEnabled(allow_modify);
  974. disableApplyBtn();
  975. childSetEnabled("access_text", allow_modify);
  976. // childSetEnabled("access_combo", allow_modify);
  977. // now set in processRegionInfo for teen grid detection
  978. childSetEnabled("kick_btn", allow_modify);
  979. childSetEnabled("kick_all_btn", allow_modify);
  980. childSetEnabled("im_btn", allow_modify);
  981. childSetEnabled("manage_telehub_btn", allow_modify);
  982. // Data gets filled in by processRegionInfo
  983. return true;
  984. }
  985. bool LLPanelRegionGeneralInfo::postBuild()
  986. {
  987. // Enable the "Apply" button if something is changed. JC
  988. initCtrl("block_terraform_check");
  989. initCtrl("block_fly_check");
  990. initCtrl("block_fly_over_check");
  991. initCtrl("allow_damage_check");
  992. initCtrl("allow_land_resell_check");
  993. initCtrl("allow_parcel_changes_check");
  994. initCtrl("agent_limit_spin");
  995. initCtrl("object_bonus_spin");
  996. initCtrl("access_combo");
  997. initCtrl("restrict_pushobject");
  998. initCtrl("block_parcel_search_check");
  999. initHelpBtn("terraform_help", "HelpRegionBlockTerraform");
  1000. initHelpBtn("fly_help", "HelpRegionBlockFly");
  1001. initHelpBtn("damage_help", "HelpRegionAllowDamage");
  1002. initHelpBtn("agent_limit_help", "HelpRegionAgentLimit");
  1003. initHelpBtn("object_bonus_help", "HelpRegionObjectBonus");
  1004. initHelpBtn("access_help", "HelpRegionMaturity");
  1005. initHelpBtn("restrict_pushobject_help", "HelpRegionRestrictPushObject");
  1006. initHelpBtn("land_resell_help", "HelpRegionLandResell");
  1007. initHelpBtn("parcel_changes_help", "HelpParcelChanges");
  1008. initHelpBtn("parcel_search_help", "HelpRegionSearch");
  1009. childSetAction("kick_btn", onClickKick, this);
  1010. childSetAction("kick_all_btn", onClickKickAll, this);
  1011. childSetAction("im_btn", onClickMessage, this);
  1012. childSetAction("manage_telehub_btn", onClickManageTelehub, this);
  1013. return LLPanelRegionInfo::postBuild();
  1014. }
  1015. //static
  1016. void LLPanelRegionGeneralInfo::onClickKick(void* userdata)
  1017. {
  1018. LLPanelRegionGeneralInfo* panelp = (LLPanelRegionGeneralInfo*)userdata;
  1019. if (!panelp) return;
  1020. LLFloater* childp = LLFloaterAvatarPicker::show(onKickCommit, userdata,
  1021. false, true);
  1022. if (childp && gFloaterViewp)
  1023. {
  1024. // This depends on the grandparent view being a floater in order to set
  1025. // up floater dependency
  1026. LLFloater* parentp = gFloaterViewp->getParentFloater(panelp);
  1027. if (parentp)
  1028. {
  1029. parentp->addDependentFloater(childp);
  1030. }
  1031. }
  1032. }
  1033. //static
  1034. void LLPanelRegionGeneralInfo::onKickCommit(const std::vector<std::string>& names,
  1035. const uuid_vec_t& ids,
  1036. void* userdata)
  1037. {
  1038. LLPanelRegionGeneralInfo* self = (LLPanelRegionGeneralInfo*)userdata;
  1039. if (self && !names.empty() && !ids.empty() && ids[0].notNull())
  1040. {
  1041. strings_t strings;
  1042. // [0] = our agent id
  1043. // [1] = target agent id
  1044. std::string buffer;
  1045. gAgentID.toString(buffer);
  1046. strings.push_back(buffer);
  1047. ids[0].toString(buffer);
  1048. strings.push_back(strings_t::value_type(buffer));
  1049. self->sendEstateOwnerMessage("teleporthomeuser", strings);
  1050. }
  1051. }
  1052. //static
  1053. void LLPanelRegionGeneralInfo::onClickKickAll(void* userdata)
  1054. {
  1055. gNotifications.add("KickUsersFromRegion", LLSD(), LLSD(),
  1056. boost::bind(&LLPanelRegionGeneralInfo::onKickAllCommit,
  1057. (LLPanelRegionGeneralInfo*)userdata, _1,
  1058. _2));
  1059. }
  1060. bool LLPanelRegionGeneralInfo::onKickAllCommit(const LLSD& notification,
  1061. const LLSD& response)
  1062. {
  1063. if (LLNotification::getSelectedOption(notification, response) == 0)
  1064. {
  1065. strings_t strings;
  1066. // [0] = our agent id
  1067. std::string buffer;
  1068. gAgentID.toString(buffer);
  1069. strings.push_back(buffer);
  1070. // Historical message name
  1071. sendEstateOwnerMessage("teleporthomeallusers", strings);
  1072. }
  1073. return false;
  1074. }
  1075. //static
  1076. void LLPanelRegionGeneralInfo::onClickMessage(void* userdata)
  1077. {
  1078. gNotifications.add("MessageRegion", LLSD(), LLSD(),
  1079. boost::bind(&LLPanelRegionGeneralInfo::onMessageCommit,
  1080. (LLPanelRegionGeneralInfo*)userdata, _1,
  1081. _2));
  1082. }
  1083. //static
  1084. bool LLPanelRegionGeneralInfo::onMessageCommit(const LLSD& notification,
  1085. const LLSD& response)
  1086. {
  1087. if (LLNotification::getSelectedOption(notification, response) != 0)
  1088. {
  1089. return false;
  1090. }
  1091. std::string text = response["message"].asString();
  1092. if (text.empty()) return false;
  1093. llinfos << "Message to everyone: " << text << llendl;
  1094. strings_t strings;
  1095. // [0] grid_x, unused here
  1096. // [1] grid_y, unused here
  1097. // [2] agent_id of sender
  1098. // [3] sender name
  1099. // [4] message
  1100. strings.emplace_back("-1");
  1101. strings.emplace_back("-1");
  1102. std::string buffer;
  1103. gAgentID.toString(buffer);
  1104. strings.emplace_back(buffer);
  1105. std::string name;
  1106. gAgent.buildFullname(name);
  1107. strings.emplace_back(name);
  1108. strings.emplace_back(text);
  1109. sendEstateOwnerMessage("simulatormessage", strings);
  1110. return false;
  1111. }
  1112. //static
  1113. void LLPanelRegionGeneralInfo::onClickManageTelehub(void* data)
  1114. {
  1115. LLFloaterTelehub::showInstance();
  1116. LLFloaterRegionInfo::getInstance()->close();
  1117. }
  1118. #define YESORNO(C) llformat("%s", childGetValue(C).asBoolean() ? "Y" : "N")
  1119. #define ASFLOAT(C) llformat("%f", childGetValue(C).asReal())
  1120. #define ASINTEGER(C) llformat("%d", childGetValue(C).asInteger())
  1121. // setregioninfo
  1122. // strings[0] = 'Y' - block terraform, 'N' - not
  1123. // strings[1] = 'Y' - block fly, 'N' - not
  1124. // strings[2] = 'Y' - allow damage, 'N' - not
  1125. // strings[3] = 'Y' - allow land sale, 'N' - not
  1126. // strings[4] = agent limit
  1127. // strings[5] = object bonus
  1128. // strings[6] = sim access (0 = unknown, 13 = PG, 21 = Mature, 42 = Adult)
  1129. // strings[7] = restrict pushobject
  1130. // strings[8] = 'Y' - allow parcel subdivide, 'N' - not
  1131. // strings[9] = 'Y' - block parcel search, 'N' - allow
  1132. bool LLPanelRegionGeneralInfo::sendUpdate()
  1133. {
  1134. // First try using a Cap. If that fails use the old method.
  1135. LLSD body;
  1136. std::string url = gAgent.getRegionCapability("DispatchRegionInfo");
  1137. if (!url.empty())
  1138. {
  1139. body["block_terraform"] = childGetValue("block_terraform_check");
  1140. body["block_fly"] = childGetValue("block_fly_check");
  1141. body["block_fly_over"] = childGetValue("block_fly_over_check");
  1142. body["allow_damage"] = childGetValue("allow_damage_check");
  1143. body["allow_land_resell"] = childGetValue("allow_land_resell_check");
  1144. body["agent_limit"] = childGetValue("agent_limit_spin");
  1145. body["prim_bonus"] = childGetValue("object_bonus_spin");
  1146. body["sim_access"] = childGetValue("access_combo");
  1147. body["restrict_pushobject"] = childGetValue("restrict_pushobject");
  1148. body["allow_parcel_changes"] =
  1149. childGetValue("allow_parcel_changes_check");
  1150. body["block_parcel_search"] =
  1151. childGetValue("block_parcel_search_check");
  1152. using namespace LLCoreHttpUtil;
  1153. HttpCoroutineAdapter::messageHttpPost(url, body,
  1154. "Region info update posted.",
  1155. "Failure to post region info update.");
  1156. }
  1157. else
  1158. {
  1159. strings_t strings;
  1160. strings.emplace_back(YESORNO("block_terraform_check"));
  1161. strings.emplace_back(YESORNO("block_fly_check"));
  1162. strings.emplace_back(YESORNO("allow_damage_check"));
  1163. strings.emplace_back(YESORNO("allow_land_resell_check"));
  1164. strings.emplace_back(ASFLOAT("agent_limit_spin"));
  1165. strings.emplace_back(ASFLOAT("object_bonus_spin"));
  1166. strings.emplace_back(ASINTEGER("access_combo"));
  1167. strings.emplace_back(YESORNO("restrict_pushobject"));
  1168. strings.emplace_back(YESORNO("allow_parcel_changes_check"));
  1169. sendEstateOwnerMessage("setregioninfo", strings);
  1170. }
  1171. // If we changed access levels, tell user about it
  1172. LLViewerRegion* regionp = gAgent.getRegion();
  1173. if (regionp &&
  1174. childGetValue("access_combo").asInteger() != regionp->getSimAccess())
  1175. {
  1176. gNotifications.add("RegionMaturityChange");
  1177. }
  1178. return true;
  1179. }
  1180. ///////////////////////////////////////////////////////////////////////////////
  1181. // LLPanelRegionDebugInfo
  1182. ///////////////////////////////////////////////////////////////////////////////
  1183. bool LLPanelRegionDebugInfo::postBuild()
  1184. {
  1185. LLPanelRegionInfo::postBuild();
  1186. initCtrl("disable_scripts_check");
  1187. initCtrl("disable_collisions_check");
  1188. initCtrl("disable_physics_check");
  1189. initHelpBtn("disable_scripts_help", "HelpRegionDisableScripts");
  1190. initHelpBtn("disable_collisions_help", "HelpRegionDisableCollisions");
  1191. initHelpBtn("disable_physics_help", "HelpRegionDisablePhysics");
  1192. initHelpBtn("top_colliders_help", "HelpRegionTopColliders");
  1193. initHelpBtn("top_scripts_help", "HelpRegionTopScripts");
  1194. initHelpBtn("restart_help", "HelpRegionRestart");
  1195. childSetAction("choose_avatar_btn", onClickChooseAvatar, this);
  1196. childSetAction("return_btn", onClickReturn, this);
  1197. childSetAction("top_colliders_btn", onClickTopColliders, this);
  1198. childSetAction("top_scripts_btn", onClickTopScripts, this);
  1199. childSetAction("restart_btn", onClickRestart, this);
  1200. childSetAction("cancel_restart_btn", onClickCancelRestart, this);
  1201. return true;
  1202. }
  1203. //virtual
  1204. bool LLPanelRegionDebugInfo::refreshFromRegion(LLViewerRegion* regionp)
  1205. {
  1206. LLPanelRegionInfo::refreshFromRegion(regionp);
  1207. bool allow_modify = mCanManage || gAgent.isGodlike();
  1208. bool got_target_avatar = mTargetAvatar.notNull();
  1209. setCtrlsEnabled(allow_modify);
  1210. disableApplyBtn();
  1211. childDisable("target_avatar_name");
  1212. childSetEnabled("choose_avatar_btn", allow_modify);
  1213. childSetEnabled("return_scripts", allow_modify && got_target_avatar);
  1214. childSetEnabled("return_other_land", allow_modify && got_target_avatar);
  1215. childSetEnabled("return_estate_wide", allow_modify && got_target_avatar);
  1216. childSetEnabled("return_btn", allow_modify && got_target_avatar);
  1217. childSetEnabled("top_colliders_btn", allow_modify);
  1218. childSetEnabled("top_scripts_btn", allow_modify);
  1219. childSetEnabled("restart_btn", allow_modify);
  1220. childSetEnabled("cancel_restart_btn", allow_modify);
  1221. return true;
  1222. }
  1223. //virtual
  1224. bool LLPanelRegionDebugInfo::sendUpdate()
  1225. {
  1226. strings_t strings;
  1227. strings.emplace_back(YESORNO("disable_scripts_check"));
  1228. strings.emplace_back(YESORNO("disable_collisions_check"));
  1229. strings.emplace_back(YESORNO("disable_physics_check"));
  1230. sendEstateOwnerMessage("setregiondebug", strings);
  1231. return true;
  1232. }
  1233. void LLPanelRegionDebugInfo::onClickChooseAvatar(void* data)
  1234. {
  1235. LLFloaterAvatarPicker::show(callbackAvatarID, data, false, true);
  1236. }
  1237. //static
  1238. void LLPanelRegionDebugInfo::callbackAvatarID(const std::vector<std::string>& names,
  1239. const uuid_vec_t& ids,
  1240. void* data)
  1241. {
  1242. LLPanelRegionDebugInfo* self = (LLPanelRegionDebugInfo*)data;
  1243. if (self && !ids.empty() && !names.empty())
  1244. {
  1245. self->mTargetAvatar = ids[0];
  1246. self->childSetValue("target_avatar_name", LLSD(names[0]));
  1247. self->refreshFromRegion(gAgent.getRegion());
  1248. }
  1249. }
  1250. //static
  1251. void LLPanelRegionDebugInfo::onClickReturn(void* data)
  1252. {
  1253. LLPanelRegionDebugInfo* panelp = (LLPanelRegionDebugInfo*)data;
  1254. if (!panelp || panelp->mTargetAvatar.isNull()) return;
  1255. LLSD args;
  1256. args["USER_NAME"] = panelp->childGetValue("target_avatar_name").asString();
  1257. LLSD payload;
  1258. payload["avatar_id"] = panelp->mTargetAvatar;
  1259. U32 flags = SWD_ALWAYS_RETURN_OBJECTS;
  1260. if (panelp->childGetValue("return_scripts").asBoolean())
  1261. {
  1262. flags |= SWD_SCRIPTED_ONLY;
  1263. }
  1264. if (panelp->childGetValue("return_other_land").asBoolean())
  1265. {
  1266. flags |= SWD_OTHERS_LAND_ONLY;
  1267. }
  1268. payload["flags"] = LLSD::Integer(flags);
  1269. payload["return_estate_wide"] =
  1270. panelp->childGetValue("return_estate_wide").asBoolean();
  1271. gNotifications.add("EstateObjectReturn", args, payload,
  1272. boost::bind(&LLPanelRegionDebugInfo::callbackReturn,
  1273. panelp, _1, _2));
  1274. }
  1275. bool LLPanelRegionDebugInfo::callbackReturn(const LLSD& notification,
  1276. const LLSD& response)
  1277. {
  1278. if (LLNotification::getSelectedOption(notification, response))
  1279. {
  1280. return false;
  1281. }
  1282. LLUUID target_avatar = notification["payload"]["avatar_id"].asUUID();
  1283. if (target_avatar.notNull())
  1284. {
  1285. U32 flags = notification["payload"]["flags"].asInteger();
  1286. bool return_estate_wide = notification["payload"]["return_estate_wide"];
  1287. if (return_estate_wide)
  1288. {
  1289. // Send as estate message - routed by spaceserver to all regions in
  1290. // estate
  1291. strings_t strings;
  1292. strings.emplace_back(llformat("%d", flags));
  1293. strings.emplace_back(target_avatar.asString());
  1294. sendEstateOwnerMessage("estateobjectreturn", strings);
  1295. }
  1296. else
  1297. {
  1298. // Send to this simulator only
  1299. send_sim_wide_deletes(target_avatar, flags);
  1300. }
  1301. }
  1302. return false;
  1303. }
  1304. //static
  1305. void LLPanelRegionDebugInfo::onClickTopColliders(void* data)
  1306. {
  1307. LLPanelRegionDebugInfo* self = (LLPanelRegionDebugInfo*)data;
  1308. if (!self) return;
  1309. strings_t strings;
  1310. strings.emplace_back("1"); // one physics step
  1311. LLFloaterTopObjects::showInstance();
  1312. LLFloaterTopObjects::clearList();
  1313. self->sendEstateOwnerMessage("colliders", strings);
  1314. }
  1315. //static
  1316. void LLPanelRegionDebugInfo::onClickTopScripts(void* data)
  1317. {
  1318. LLPanelRegionDebugInfo* self = (LLPanelRegionDebugInfo*)data;
  1319. if (!self) return;
  1320. strings_t strings;
  1321. strings.emplace_back("6"); // top 5 scripts
  1322. LLFloaterTopObjects::showInstance();
  1323. LLFloaterTopObjects::clearList();
  1324. self->sendEstateOwnerMessage("scripts", strings);
  1325. }
  1326. //static
  1327. void LLPanelRegionDebugInfo::onClickRestart(void* data)
  1328. {
  1329. gNotifications.add("ConfirmRestart", LLSD(), LLSD(),
  1330. boost::bind(&LLPanelRegionDebugInfo::callbackRestart,
  1331. (LLPanelRegionDebugInfo*)data, _1, _2));
  1332. }
  1333. bool LLPanelRegionDebugInfo::callbackRestart(const LLSD& notification,
  1334. const LLSD& response)
  1335. {
  1336. if (LLNotification::getSelectedOption(notification, response) == 0)
  1337. {
  1338. strings_t strings;
  1339. strings.emplace_back("120");
  1340. sendEstateOwnerMessage("restart", strings);
  1341. }
  1342. return false;
  1343. }
  1344. //static
  1345. void LLPanelRegionDebugInfo::onClickCancelRestart(void* data)
  1346. {
  1347. LLPanelRegionDebugInfo* self = (LLPanelRegionDebugInfo*)data;
  1348. if (!self) return;
  1349. strings_t strings;
  1350. strings.emplace_back("-1");
  1351. self->sendEstateOwnerMessage("restart", strings);
  1352. }
  1353. ///////////////////////////////////////////////////////////////////////////////
  1354. // LLPanelRegionTextureInfo
  1355. ///////////////////////////////////////////////////////////////////////////////
  1356. //virtual
  1357. LLPanelRegionTextureInfo::~LLPanelRegionTextureInfo()
  1358. {
  1359. for (U32 i = 0; i < LLTerrain::ASSET_COUNT; ++i)
  1360. {
  1361. clearMaterialPreview(mMatAssetIds[i]);
  1362. }
  1363. }
  1364. //virtual
  1365. bool LLPanelRegionTextureInfo::postBuild()
  1366. {
  1367. mTerrainTypeCtrl = getChild<LLRadioGroup>("terrain_type");
  1368. mTerrainTypeCtrl->setCommitCallback(onTerrainTypeCommit);
  1369. mTerrainTypeCtrl->setCallbackUserData(this);
  1370. // For each view border enclosing our future material preview, get the
  1371. // corresponding rectangle and setup a clickable text box in that rectangle
  1372. // to that we can catch the user clicks and open the corresponding material
  1373. // selector. We also store the texture pickers pointers in an array. HB
  1374. std::string buffer;
  1375. for (U32 i = 0; i < LLTerrain::ASSET_COUNT; ++i)
  1376. {
  1377. buffer = llformat("material_detail_%d", i);
  1378. mMatBorders[i] = getChild<LLView>(buffer.c_str());
  1379. LLRect rect = mMatBorders[i]->getRect();
  1380. // Adjust to keep the view border showing while we will draw the
  1381. // thumbnail inside it, over the clickable text box.
  1382. rect.mBottom += 2;
  1383. rect.mTop -= 2;
  1384. rect.mLeft += 2;
  1385. rect.mRight -= 2;
  1386. mMatClickTexts[i] = new LLTextBox(llformat("%d", i), rect, "",
  1387. LLFontGL::getFontSansSerifSmall(),
  1388. true); // Opaque text box
  1389. mMatClickTexts[i]->setColor(LLColor4::white);
  1390. mThumbnailRect[i] = rect;
  1391. // Add it as our child.
  1392. addChild(mMatClickTexts[i]);
  1393. // Add our clicked callback.
  1394. mMatClickTexts[i]->setClickedCallback(onMatPreviewClicked,
  1395. (void*)mMatClickTexts[i]);
  1396. // Keep texture pickers in an array, to avoid calling again getChild()
  1397. // with their name...
  1398. buffer = llformat("texture_detail_%d", i);
  1399. mTexPickers[i] = getChild<LLTextureCtrl>(buffer.c_str());
  1400. }
  1401. mStatusStrings[NEEDS_PBR_MODE] = getString("needs_pbr_text");
  1402. mStatusStrings[NEEDS_PROBES] = getString("needs_probes_text");
  1403. mStatusStrings[NO_PBR_MAT] = getString("no_mat_text");
  1404. mStatusStrings[LOADING_PBR_MAT] = getString("loading_mat_text");
  1405. mStatusStrings[FAILED_PBR_MAT] = getString("failed_mat_text");
  1406. for (U32 i = 0; i < LLTerrain::ASSET_COUNT; ++i)
  1407. {
  1408. buffer = llformat("texture_detail_%d", i);
  1409. initCtrl(buffer.c_str());
  1410. }
  1411. for (U32 i = 0; i < CORNER_COUNT; ++i)
  1412. {
  1413. buffer = llformat("height_start_spin_%d", i);
  1414. initCtrl(buffer.c_str());
  1415. buffer = llformat("height_range_spin_%d", i);
  1416. initCtrl(buffer.c_str());
  1417. }
  1418. return LLPanelRegionInfo::postBuild();
  1419. }
  1420. // This is for now only used to draw the material preview thumbnails, when
  1421. // needed and possible. HB
  1422. //virtual
  1423. void LLPanelRegionTextureInfo::draw()
  1424. {
  1425. if (!mComposition || mTerrainTypeCtrl->getSelectedIndex() == 0)
  1426. {
  1427. // No region set or textures-based terrain: no material preview to
  1428. // render; just draw the UI elements. HB
  1429. LLPanel::draw();
  1430. return;
  1431. }
  1432. U32 status = STATUS_COUNT;
  1433. if (!gUsePBRShaders)
  1434. {
  1435. status = NEEDS_PBR_MODE;
  1436. }
  1437. else if (!LLPipeline::sReflectionProbesEnabled)
  1438. {
  1439. status = NEEDS_PROBES;
  1440. }
  1441. // Update the text in the preview tiles and see if preview are ready. HB
  1442. LLPointer<LLViewerTexture> previews[LLTerrain::ASSET_COUNT];
  1443. for (U32 i = 0; i < LLTerrain::ASSET_COUNT; ++i)
  1444. {
  1445. if (status > NEEDS_PROBES)
  1446. {
  1447. const LLUUID& mat_id = mMatAssetIds[i];
  1448. LLFetchedGLTFMaterial* matp = NULL;
  1449. if (mat_id.notNull())
  1450. {
  1451. matp = gGLTFMaterialList.getMaterial(mat_id);
  1452. }
  1453. if (!matp)
  1454. {
  1455. status = NO_PBR_MAT;
  1456. }
  1457. else if (matp->isFetching())
  1458. {
  1459. status = LOADING_PBR_MAT;
  1460. }
  1461. else if (!matp->isLoaded())
  1462. {
  1463. status = FAILED_PBR_MAT;
  1464. }
  1465. else
  1466. {
  1467. status = NTR;
  1468. // Get the preview for this material.
  1469. previews[i] = matp->getPreview();
  1470. if (previews[i].isNull()) // Preview not ready yet...
  1471. {
  1472. status = LOADING_PBR_MAT;
  1473. }
  1474. }
  1475. }
  1476. mMatClickTexts[i]->setText(mStatusStrings[status]);
  1477. }
  1478. // Draw all UI elements before we would draw the previews(may be). HB
  1479. LLPanel::draw();
  1480. if (status <= NEEDS_PROBES)
  1481. {
  1482. return; // Cannot render material previews, so skip the rest. HB
  1483. }
  1484. // Draw the previews which are ready.
  1485. for (U32 i = 0; i < LLTerrain::ASSET_COUNT; ++i)
  1486. {
  1487. if (previews[i].notNull())
  1488. {
  1489. LLRect rect = mThumbnailRect[i];
  1490. rect.translate(0, 154); // *BUG: why do I need this offset ? O.O
  1491. gl_draw_scaled_image(rect.mLeft, rect.mBottom, rect.getWidth(),
  1492. rect.getHeight(), previews[i]);
  1493. }
  1494. }
  1495. }
  1496. void LLPanelRegionTextureInfo::clearMaterialPreview(const LLUUID& mat_id)
  1497. {
  1498. if (mat_id.isNull())
  1499. {
  1500. return;
  1501. }
  1502. LLFetchedGLTFMaterial* matp = gGLTFMaterialList.getMaterial(mat_id);
  1503. if (matp)
  1504. {
  1505. matp->clearPreview();
  1506. }
  1507. }
  1508. //virtual
  1509. bool LLPanelRegionTextureInfo::refreshFromRegion(LLViewerRegion* regionp)
  1510. {
  1511. LLPanelRegionInfo::refreshFromRegion(regionp);
  1512. bool allow_modify = mCanManage || gAgent.isGodlike();
  1513. setCtrlsEnabled(allow_modify);
  1514. disableApplyBtn();
  1515. if (!mComposition) // No region set !
  1516. {
  1517. childSetValue("region_text", LLSD(""));
  1518. return false;
  1519. }
  1520. childSetValue("region_text", LLSD(regionp->getName()));
  1521. bool is_pbr = mComposition->isPBR();
  1522. mTerrainTypeCtrl->setSelectedIndex(is_pbr ? 1 : 0);
  1523. mTerrainTypeCtrl->setEnabled(regionp->hasPBRTerrain());
  1524. for (U32 i = 0; i < LLTerrain::ASSET_COUNT; ++i)
  1525. {
  1526. mTexPickers[i]->setVisible(!is_pbr);
  1527. mMatBorders[i]->setVisible(is_pbr);
  1528. mMatClickTexts[i]->setVisible(is_pbr);
  1529. const LLUUID& asset_id = mComposition->getDetailAssetID(i);
  1530. if (is_pbr)
  1531. {
  1532. LL_DEBUGS("RegionTexture") << "Detail material " << i << ": "
  1533. << asset_id << LL_ENDL;
  1534. // Clear any old preview.
  1535. clearMaterialPreview(mMatAssetIds[i]);
  1536. // Assign the material.
  1537. mMatAssetIds[i] = asset_id;
  1538. }
  1539. else
  1540. {
  1541. LL_DEBUGS("RegionTexture") << "Detail texture " << i << ": "
  1542. << asset_id << LL_ENDL;
  1543. mTexPickers[i]->setImageAssetID(asset_id);
  1544. }
  1545. }
  1546. std::string buffer;
  1547. for (U32 i = 0; i < CORNER_COUNT; ++i)
  1548. {
  1549. buffer = llformat("height_start_spin_%d", i);
  1550. childSetValue(buffer.c_str(), LLSD(mComposition->getStartHeight(i)));
  1551. buffer = llformat("height_range_spin_%d", i);
  1552. childSetValue(buffer.c_str(), LLSD(mComposition->getHeightRange(i)));
  1553. }
  1554. return true;
  1555. }
  1556. //virtual
  1557. bool LLPanelRegionTextureInfo::sendUpdate()
  1558. {
  1559. bool is_pbr = mTerrainTypeCtrl->getSelectedIndex() == 1;
  1560. // Make sure user has not chosen wacky assets.
  1561. if ((!is_pbr && !validateTextureSizes()) ||
  1562. (is_pbr && !validateMaterials()))
  1563. {
  1564. return false;
  1565. }
  1566. strings_t strings;
  1567. std::string buffer;
  1568. for (U32 i = 0; i < LLTerrain::ASSET_COUNT; ++i)
  1569. {
  1570. if (is_pbr)
  1571. {
  1572. const LLUUID& tex_id = mTexPickers[i]->getImageAssetID();
  1573. tex_id.toString(buffer);
  1574. }
  1575. else
  1576. {
  1577. mMatAssetIds[i].toString(buffer);
  1578. }
  1579. strings.emplace_back(llformat("%d %s", i, buffer.c_str()));
  1580. }
  1581. sendEstateOwnerMessage("texturedetail", strings);
  1582. strings.clear();
  1583. std::string buffer2, buffer3;
  1584. for (U32 i = 0; i < CORNER_COUNT; ++i)
  1585. {
  1586. buffer = llformat("height_start_spin_%d", i);
  1587. buffer2 = llformat("height_range_spin_%d", i);
  1588. buffer3 = llformat("%d %f %f", i,
  1589. (F32)childGetValue(buffer.c_str()).asReal(),
  1590. (F32)childGetValue(buffer2.c_str()).asReal());
  1591. strings.emplace_back(buffer3);
  1592. }
  1593. sendEstateOwnerMessage("textureheights", strings);
  1594. strings.clear();
  1595. sendEstateOwnerMessage("texturecommit", strings);
  1596. return true;
  1597. }
  1598. bool LLPanelRegionTextureInfo::validateTextureSizes() const
  1599. {
  1600. for (U32 i = 0; i < LLTerrain::ASSET_COUNT; ++i)
  1601. {
  1602. const LLUUID& tex_id = mTexPickers[i]->getImageAssetID();
  1603. LLViewerTexture* texp =
  1604. LLViewerTextureManager::getFetchedTexture(tex_id);
  1605. if (!texp) return false;
  1606. S32 components = texp->getComponents();
  1607. if (components != 3)
  1608. {
  1609. LLSD args;
  1610. args["TEXTURE_NUM"] = i + 1;
  1611. args["TEXTURE_BIT_DEPTH"] = llformat("%d", components * 8);
  1612. args["MAX_SIZE"] = gMaxImageSizeDefault;
  1613. gNotifications.add("InvalidTerrainBitDepth", args);
  1614. return false;
  1615. }
  1616. S32 width = texp->getFullWidth();
  1617. S32 height = texp->getFullHeight();
  1618. if (width > gMaxImageSizeDefault || height > gMaxImageSizeDefault)
  1619. {
  1620. LLSD args;
  1621. args["TEXTURE_NUM"] = i + 1;
  1622. args["TEXTURE_SIZE_X"] = width;
  1623. args["TEXTURE_SIZE_Y"] = height;
  1624. args["MAX_SIZE"] = gMaxImageSizeDefault;
  1625. gNotifications.add("InvalidTerrainSize", args);
  1626. return false;
  1627. }
  1628. }
  1629. return true;
  1630. }
  1631. bool LLPanelRegionTextureInfo::validateMaterials() const
  1632. {
  1633. for (U32 i = 0; i < LLTerrain::ASSET_COUNT; ++i)
  1634. {
  1635. const LLUUID mat_id = mMatAssetIds[i];
  1636. const LLFetchedGLTFMaterial* matp =
  1637. gGLTFMaterialList.getMaterial(mat_id);
  1638. if (!matp) return false;
  1639. if (!matp->isLoaded())
  1640. {
  1641. const char* notification =
  1642. matp->isFetching() ? "InvalidTerrainMaterialNotLoaded"
  1643. : "InvalidTerrainMaterialLoadFailed";
  1644. LLSD args;
  1645. args["MATERIAL_NUM"] = i + 1;
  1646. gNotifications.add(notification, args);
  1647. return false;
  1648. }
  1649. if (matp->mDoubleSided)
  1650. {
  1651. LLSD args;
  1652. args["MATERIAL_NUM"] = i + 1;
  1653. gNotifications.add("InvalidTerrainMaterialDoubleSided", args);
  1654. return false;
  1655. }
  1656. if (matp->mAlphaMode != LLGLTFMaterial::ALPHA_MODE_OPAQUE &&
  1657. matp->mAlphaMode != LLGLTFMaterial::ALPHA_MODE_MASK)
  1658. {
  1659. LLSD args;
  1660. args["MATERIAL_NUM"] = i + 1;
  1661. args["MATERIAL_ALPHA_MODE"] = LLSD::String(matp->getAlphaMode());
  1662. gNotifications.add("InvalidTerrainMaterialAlphaMode", args);
  1663. return false;
  1664. }
  1665. }
  1666. return true;
  1667. }
  1668. //static
  1669. void LLPanelRegionTextureInfo::onTerrainTypeCommit(LLUICtrl*, void* userdata)
  1670. {
  1671. LLPanelRegionTextureInfo* self = (LLPanelRegionTextureInfo*)userdata;
  1672. if (!self) return; // Paranoia
  1673. bool is_pbr = self->mTerrainTypeCtrl->getSelectedIndex() == 1;
  1674. for (U32 i = 0; i < LLTerrain::ASSET_COUNT; ++i)
  1675. {
  1676. self->mTexPickers[i]->setVisible(!is_pbr);
  1677. self->mMatBorders[i]->setVisible(is_pbr);
  1678. self->mMatClickTexts[i]->setVisible(is_pbr);
  1679. }
  1680. }
  1681. //static
  1682. void LLPanelRegionTextureInfo::onMatPreviewClicked(void* userdata)
  1683. {
  1684. // Note: userdata is a pointer on the clicked LLTextBox corresponding to
  1685. // the material preview, which parent is LLPanelRegionTextureInfo and which
  1686. // name is equal to the index of the terrain material. HB
  1687. HBFloaterInvItemsPicker* pickerp =
  1688. new HBFloaterInvItemsPicker((LLView*)userdata, onSelectInventoryMat,
  1689. userdata);
  1690. pickerp->setAssetType(LLAssetType::AT_MATERIAL);
  1691. // Terrain materials must be at least copy OK...
  1692. pickerp->setFilterPermMask(PERM_COPY);
  1693. }
  1694. //static
  1695. void LLPanelRegionTextureInfo::onSelectInventoryMat(const std::vector<std::string>&,
  1696. const uuid_vec_t& ids,
  1697. void* userdata, bool)
  1698. {
  1699. if (ids.empty() || ids[0].isNull())
  1700. {
  1701. return; // Nothing to do (was a Cancel, most likely).
  1702. }
  1703. LLViewerInventoryItem* itemp = gInventory.getItem(ids[0]);
  1704. if (!itemp)
  1705. {
  1706. llwarns << "Could not find inventory item " << ids[0] << llendl;
  1707. return;
  1708. }
  1709. LLTextBox* textp = (LLTextBox*)userdata;
  1710. if (!textp) return; // Paranoia
  1711. LLPanelRegionTextureInfo* self =
  1712. (LLPanelRegionTextureInfo*)textp->getParent();
  1713. if (!self) return; // Paranoia
  1714. S32 i = atoi(textp->getName().c_str());
  1715. if (i < 0 || i >= (S32)LLTerrain::ASSET_COUNT)
  1716. {
  1717. llerrs << "Erroneous LLTextBox name (should be equal to the material index): "
  1718. << textp->getName() << llendl;
  1719. }
  1720. // Clear any old preview.
  1721. self->clearMaterialPreview(self->mMatAssetIds[i]);
  1722. // Assign the new material.
  1723. self->mMatAssetIds[i] = itemp->getAssetUUID();
  1724. }
  1725. ///////////////////////////////////////////////////////////////////////////////
  1726. // LLPanelRegionTerrainInfo
  1727. ///////////////////////////////////////////////////////////////////////////////
  1728. bool LLPanelRegionTerrainInfo::postBuild()
  1729. {
  1730. LLPanelRegionInfo::postBuild();
  1731. initHelpBtn("water_height_help", "HelpRegionWaterHeight");
  1732. initHelpBtn("terrain_raise_help", "HelpRegionTerrainRaise");
  1733. initHelpBtn("terrain_lower_help", "HelpRegionTerrainLower");
  1734. initHelpBtn("upload_raw_help", "HelpRegionUploadRaw");
  1735. initHelpBtn("download_raw_help", "HelpRegionDownloadRaw");
  1736. initHelpBtn("use_estate_sun_help", "HelpRegionUseEstateSun");
  1737. initHelpBtn("fixed_sun_help", "HelpRegionFixedSun");
  1738. initHelpBtn("bake_terrain_help", "HelpRegionBakeTerrain");
  1739. initCtrl("water_height_spin");
  1740. initCtrl("terrain_raise_spin");
  1741. initCtrl("terrain_lower_spin");
  1742. initCtrl("fixed_sun_check");
  1743. childSetCommitCallback("fixed_sun_check", onChangeFixedSun, this);
  1744. childSetCommitCallback("use_estate_sun_check", onChangeUseEstateTime, this);
  1745. childSetCommitCallback("sun_hour_slider", onChangeSunHour, this);
  1746. childSetAction("download_raw_btn", onClickDownloadRaw, this);
  1747. childSetAction("upload_raw_btn", onClickUploadRaw, this);
  1748. childSetAction("bake_terrain_btn", onClickBakeTerrain, this);
  1749. return true;
  1750. }
  1751. //virtual
  1752. bool LLPanelRegionTerrainInfo::refreshFromRegion(LLViewerRegion* regionp)
  1753. {
  1754. LLPanelRegionInfo::refreshFromRegion(regionp);
  1755. bool owner_or_god = mOwner || gAgent.isGodlike();
  1756. setCtrlsEnabled(owner_or_god || mEstateManager);
  1757. disableApplyBtn();
  1758. childSetEnabled("download_raw_btn", owner_or_god);
  1759. childSetEnabled("upload_raw_btn", owner_or_god);
  1760. childSetEnabled("bake_terrain_btn", owner_or_god);
  1761. return true;
  1762. }
  1763. //virtual
  1764. bool LLPanelRegionTerrainInfo::sendUpdate()
  1765. {
  1766. strings_t strings;
  1767. LLRegionInfoModel::sWaterHeight =
  1768. childGetValue("water_height_spin").asReal();
  1769. strings.emplace_back(llformat("%f", LLRegionInfoModel::sWaterHeight));
  1770. LLRegionInfoModel::sTerrainRaiseLimit =
  1771. childGetValue("terrain_raise_spin").asReal();
  1772. strings.emplace_back(llformat("%f",
  1773. LLRegionInfoModel::sTerrainRaiseLimit));
  1774. LLRegionInfoModel::sTerrainLowerLimit =
  1775. childGetValue("terrain_lower_spin").asReal();
  1776. strings.emplace_back(llformat("%f", LLRegionInfoModel::sTerrainLowerLimit));
  1777. LLRegionInfoModel::sUseEstateSun =
  1778. childGetValue("use_estate_sun_check").asBoolean();
  1779. strings.emplace_back(llformat("%s",
  1780. LLRegionInfoModel::sUseEstateSun ? "Y"
  1781. : "N"));
  1782. bool fixed_sun = childGetValue("fixed_sun_check").asBoolean();
  1783. LLRegionInfoModel::setUseFixedSun(fixed_sun);
  1784. strings.emplace_back(llformat("%s", fixed_sun ? "Y" : "N"));
  1785. LLRegionInfoModel::sSunHour = childGetValue("sun_hour_slider").asReal();
  1786. strings.emplace_back(llformat("%f", LLRegionInfoModel::sSunHour));
  1787. // Grab estate information in case the user decided to set the region back
  1788. // to estate time. JC
  1789. LLPanelEstateInfo* panel = LLFloaterRegionInfo::getPanelEstate();
  1790. if (!panel) return true;
  1791. bool estate_global_time = panel->getGlobalTime();
  1792. bool estate_fixed_sun = panel->getFixedSun();
  1793. F32 estate_sun_hour;
  1794. if (estate_global_time)
  1795. {
  1796. estate_sun_hour = 0.f;
  1797. }
  1798. else
  1799. {
  1800. estate_sun_hour = panel->getSunHour();
  1801. }
  1802. strings.emplace_back(llformat("%s", estate_global_time ? "Y" : "N"));
  1803. strings.emplace_back(llformat("%s", estate_fixed_sun ? "Y" : "N"));
  1804. strings.emplace_back(llformat("%f", estate_sun_hour));
  1805. sendEstateOwnerMessage("setregionterrain", strings);
  1806. return true;
  1807. }
  1808. //static
  1809. void LLPanelRegionTerrainInfo::onChangeUseEstateTime(LLUICtrl* ctrl,
  1810. void* user_data)
  1811. {
  1812. LLPanelRegionTerrainInfo* panel = (LLPanelRegionTerrainInfo*)user_data;
  1813. if (!panel) return;
  1814. bool use_estate_sun = panel->childGetValue("use_estate_sun_check").asBoolean();
  1815. panel->childSetEnabled("fixed_sun_check", !use_estate_sun);
  1816. panel->childSetEnabled("sun_hour_slider", !use_estate_sun);
  1817. if (use_estate_sun)
  1818. {
  1819. panel->childSetValue("fixed_sun_check", LLSD(false));
  1820. panel->childSetValue("sun_hour_slider", LLSD(0.f));
  1821. }
  1822. panel->enableApplyBtn();
  1823. }
  1824. //static
  1825. void LLPanelRegionTerrainInfo::onChangeFixedSun(LLUICtrl* ctrl, void* data)
  1826. {
  1827. LLPanelRegionTerrainInfo* panel = (LLPanelRegionTerrainInfo*)data;
  1828. if (panel)
  1829. {
  1830. // Just enable the apply button. We let the sun-hour slider be enabled
  1831. // for both fixed-sun and non-fixed-sun. JC
  1832. panel->enableApplyBtn();
  1833. }
  1834. }
  1835. //static
  1836. void LLPanelRegionTerrainInfo::onChangeSunHour(LLUICtrl* ctrl, void*)
  1837. {
  1838. // Cannot use userdata to get panel, slider uses it internally
  1839. LLPanelRegionTerrainInfo* panel = (LLPanelRegionTerrainInfo*)ctrl->getParent();
  1840. if (panel)
  1841. {
  1842. panel->enableApplyBtn();
  1843. }
  1844. }
  1845. //static
  1846. void LLPanelRegionTerrainInfo::downloadRawCallback(HBFileSelector::ESaveFilter filter,
  1847. std::string& filepath,
  1848. void* data)
  1849. {
  1850. LLPanelRegionTerrainInfo* self = LLFloaterRegionInfo::getPanelTerrain();
  1851. if (!self || data != self || !gXferManagerp) return;
  1852. gXferManagerp->expectFileForRequest(filepath);
  1853. strings_t strings;
  1854. strings.emplace_back("download filename");
  1855. strings.emplace_back(filepath);
  1856. self->sendEstateOwnerMessage("terrain", strings);
  1857. }
  1858. //static
  1859. void LLPanelRegionTerrainInfo::onClickDownloadRaw(void* data)
  1860. {
  1861. HBFileSelector::saveFile(HBFileSelector::FFSAVE_RAW, "terrain.raw",
  1862. downloadRawCallback, data);
  1863. }
  1864. //static
  1865. void LLPanelRegionTerrainInfo::uploadRawCallback(HBFileSelector::ELoadFilter filter,
  1866. std::string& filepath,
  1867. void* data)
  1868. {
  1869. LLPanelRegionTerrainInfo* self = LLFloaterRegionInfo::getPanelTerrain();
  1870. if (!self || data != self || !gXferManagerp) return;
  1871. gXferManagerp->expectFileForTransfer(filepath);
  1872. strings_t strings;
  1873. strings.emplace_back("upload filename");
  1874. strings.emplace_back(filepath);
  1875. self->sendEstateOwnerMessage("terrain", strings);
  1876. gNotifications.add("RawUploadStarted");
  1877. }
  1878. //static
  1879. void LLPanelRegionTerrainInfo::onClickUploadRaw(void* data)
  1880. {
  1881. HBFileSelector::loadFile(HBFileSelector::FFLOAD_TERRAIN,
  1882. uploadRawCallback, data);
  1883. }
  1884. //static
  1885. void LLPanelRegionTerrainInfo::onClickBakeTerrain(void* data)
  1886. {
  1887. gNotifications.add(LLNotification::Params("ConfirmBakeTerrain").functor(
  1888. boost::bind(&LLPanelRegionTerrainInfo::callbackBakeTerrain,
  1889. (LLPanelRegionTerrainInfo*)data, _1, _2)));
  1890. }
  1891. bool LLPanelRegionTerrainInfo::callbackBakeTerrain(const LLSD& notification,
  1892. const LLSD& response)
  1893. {
  1894. if (LLNotification::getSelectedOption(notification, response))
  1895. {
  1896. return false;
  1897. }
  1898. strings_t strings;
  1899. strings.emplace_back("bake");
  1900. sendEstateOwnerMessage("terrain", strings);
  1901. return false;
  1902. }
  1903. ///////////////////////////////////////////////////////////////////////////////
  1904. // LLPanelEstateInfo
  1905. ///////////////////////////////////////////////////////////////////////////////
  1906. LLPanelEstateInfo::LLPanelEstateInfo()
  1907. : LLPanelRegionInfo(),
  1908. mEstateID(0) // 0 = invalid
  1909. {
  1910. }
  1911. //virtual
  1912. bool LLPanelEstateInfo::postBuild()
  1913. {
  1914. // Set up the callbacks for the generic controls
  1915. initCtrl("public_access_check");
  1916. initCtrl("use_global_time_check");
  1917. initCtrl("fixed_sun_check");
  1918. initCtrl("allow_direct_teleport");
  1919. initCtrl("limit_payment");
  1920. initCtrl("limit_age_verified");
  1921. initCtrl("voice_chat_check");
  1922. initCtrl("parcel_access_override");
  1923. initCtrl("limit_bots");
  1924. initHelpBtn("use_global_time_help", "HelpEstateUseGlobalTime");
  1925. initHelpBtn("fixed_sun_help", "HelpEstateFixedSun");
  1926. initHelpBtn("public_access_help", "HelpEstatePublicAccess");
  1927. initHelpBtn("allow_direct_teleport_help", "HelpEstateAllowDirectTeleport");
  1928. initHelpBtn("voice_chat_help", "HelpEstateVoiceChat");
  1929. // Set up the use global time checkbox
  1930. childSetCommitCallback("use_global_time_check", onChangeUseGlobalTime,
  1931. this);
  1932. childSetCommitCallback("fixed_sun_check", onChangeFixedSun, this);
  1933. childSetCommitCallback("sun_hour_slider", updateChild, this);
  1934. childSetAction("message_estate_btn", onClickMessageEstate, this);
  1935. childSetAction("kick_user_from_estate_btn", onClickKickUser, this);
  1936. return LLPanelRegionInfo::postBuild();
  1937. }
  1938. //static
  1939. void LLPanelEstateInfo::updateChild(LLUICtrl* ctrlp, void* user_data)
  1940. {
  1941. LLPanelEstateInfo* self = (LLPanelEstateInfo*)user_data;
  1942. if (self && ctrlp)
  1943. {
  1944. self->checkSunHourSlider(ctrlp);
  1945. // Ensure appropriate state of the management ui.
  1946. self->updateControls();
  1947. }
  1948. }
  1949. //virtual
  1950. bool LLPanelEstateInfo::estateUpdate(LLMessageSystem*)
  1951. {
  1952. llinfos << "No operation..." << llendl;
  1953. return false;
  1954. }
  1955. void LLPanelEstateInfo::updateControls()
  1956. {
  1957. bool allow_modify = mOwner || mEstateManager || gAgent.isGodlike();
  1958. setCtrlsEnabled(allow_modify);
  1959. disableApplyBtn();
  1960. childSetEnabled("message_estate_btn", allow_modify);
  1961. childSetEnabled("kick_user_from_estate_btn", allow_modify);
  1962. }
  1963. //virtual
  1964. bool LLPanelEstateInfo::refreshFromRegion(LLViewerRegion* regionp)
  1965. {
  1966. LLPanelRegionInfo::refreshFromRegion(regionp);
  1967. updateControls();
  1968. // We want estate info. To make sure it works across region boundaries and
  1969. // multiple packets, we add a serial number to the integers and track
  1970. // against that on update.
  1971. LLFloaterRegionInfo::nextInvoice();
  1972. strings_t strings;
  1973. sendEstateOwnerMessage("getinfo", strings);
  1974. refresh();
  1975. return true;
  1976. }
  1977. void LLPanelEstateInfo::refresh()
  1978. {
  1979. bool public_access = childGetValue("public_access_check").asBoolean();
  1980. childSetEnabled("Only Allow", public_access);
  1981. childSetEnabled("limit_payment", public_access);
  1982. childSetEnabled("limit_age_verified", public_access);
  1983. childSetEnabled("limit_bots", public_access);
  1984. if (!public_access)
  1985. {
  1986. // If not public access, then the limit fields are meaningless and
  1987. // should be turned off
  1988. childSetValue("limit_payment", false);
  1989. childSetValue("limit_age_verified", false);
  1990. childSetValue("limit_bots", false);
  1991. }
  1992. }
  1993. bool LLPanelEstateInfo::sendUpdate()
  1994. {
  1995. LLNotification::Params params("ChangeLindenEstate");
  1996. params.functor(boost::bind(&LLPanelEstateInfo::callbackChangeLindenEstate,
  1997. this, _1, _2));
  1998. if (getEstateID() <= ESTATE_LAST_LINDEN)
  1999. {
  2000. // Trying to change reserved estate, warn
  2001. gNotifications.add(params);
  2002. }
  2003. else
  2004. {
  2005. // For normal estates, just make the change
  2006. gNotifications.forceResponse(params, 0);
  2007. }
  2008. return true;
  2009. }
  2010. bool LLPanelEstateInfo::callbackChangeLindenEstate(const LLSD& notification,
  2011. const LLSD& response)
  2012. {
  2013. if (LLNotification::getSelectedOption(notification, response) == 0)
  2014. {
  2015. // Send the update
  2016. if (!commitEstateInfoCaps())
  2017. {
  2018. // The caps method failed, try the old way
  2019. LLFloaterRegionInfo::nextInvoice();
  2020. commitEstateInfoDataserver();
  2021. }
  2022. #if 0 // We do not want to do this because we will get it automatically from
  2023. // the sim after the spaceserver processes it
  2024. else
  2025. {
  2026. // Caps method does not automatically send this info
  2027. LLFloaterRegionInfo::requestRegionInfo();
  2028. }
  2029. #endif
  2030. }
  2031. else // Cancelling action
  2032. {
  2033. HBPanelLandEnvironment* panelp =
  2034. LLFloaterRegionInfo::getPanelEnvironment();
  2035. if (panelp)
  2036. {
  2037. // This will (re)set the environment override check to its
  2038. // former (or last) value
  2039. panelp->resetOverride();
  2040. }
  2041. }
  2042. return false;
  2043. }
  2044. #if 0
  2045. // Request = "getowner"
  2046. // SParam[0] = "" (empty string)
  2047. // IParam[0] = serial
  2048. void LLPanelEstateInfo::getEstateOwner()
  2049. {
  2050. // *TODO: disable the panel and call this method whenever we cross a region
  2051. // boundary; re-enable when owner matches, and get new estate info.
  2052. LLMessageSystem* msg = gMessageSystemp;
  2053. msg->newMessageFast(_PREHASH_EstateOwnerRequest);
  2054. msg->nextBlockFast(_PREHASH_AgentData);
  2055. msg->addUUIDFast(_PREHASH_AgentID, gAgentID);
  2056. msg->nextBlockFast(_PREHASH_RequestData);
  2057. msg->addStringFast(_PREHASH_Request, "getowner");
  2058. // We send an empty string so that the variable block is not empty
  2059. msg->nextBlockFast(_PREHASH_StringData);
  2060. msg->addStringFast(_PREHASH_SParam, "");
  2061. msg->nextBlockFast(_PREHASH_IntegerData);
  2062. msg->addS32Fast(_PREHASH_IParam, LLFloaterRegionInfo::getSerial());
  2063. gAgent.sendMessage();
  2064. }
  2065. #endif
  2066. // Tries to send estate info using a cap; returns true if it succeeded
  2067. bool LLPanelEstateInfo::commitEstateInfoCaps()
  2068. {
  2069. std::string url = gAgent.getRegionCapability("EstateChangeInfo");
  2070. if (url.empty())
  2071. {
  2072. // Whoops, could not find the capability, so bail out
  2073. return false;
  2074. }
  2075. gCoros.launch("LLPanelEstateInfo::commitEstateInfoCaps",
  2076. boost::bind(&LLPanelEstateInfo::commitEstateInfoCapsCoro,
  2077. this, url));
  2078. return true;
  2079. }
  2080. void LLPanelEstateInfo::commitEstateInfoCapsCoro(const std::string& url)
  2081. {
  2082. LLSD body;
  2083. body["estate_name"] = getEstateName();
  2084. body["is_externally_visible"] = childGetValue("public_access_check").asBoolean();
  2085. body["allow_direct_teleport"] = childGetValue("allow_direct_teleport").asBoolean();
  2086. body["is_sun_fixed"] = childGetValue("fixed_sun_check").asBoolean();
  2087. body["deny_anonymous"] = childGetValue("limit_payment").asBoolean();
  2088. body["deny_age_unverified"] = childGetValue("limit_age_verified").asBoolean();
  2089. body["block_bots"] = childGetValue("limit_bots").asBoolean();
  2090. body["allow_voice_chat"] = childGetValue("voice_chat_check").asBoolean();
  2091. body["override_public_access"] = childGetValue("override_public_access").asBoolean();
  2092. // For potential EE support in OpenSIM. This is not in LLPanelEstateInfo's
  2093. // UI: it is (re)set by HBPanelLandEnvironment directly in sEstateFlags...
  2094. body["override_environment"] = LLEstateInfoModel::getAllowEnvironmentOverride();
  2095. body["invoice"] = LLFloaterRegionInfo::getLastInvoice();
  2096. #if 0 // Block fly is in estate database but not in estate UI, so we are not
  2097. // supporting it
  2098. body["block_fly"] = childGetValue("").asBoolean();
  2099. #endif
  2100. F32 sun_hour = getSunHour();
  2101. if (childGetValue("use_global_time_check").asBoolean())
  2102. {
  2103. sun_hour = 0.f; // 0 = global time
  2104. }
  2105. body["sun_hour"] = sun_hour;
  2106. LLCoreHttpUtil::HttpCoroutineAdapter adapter("EstateChangeInfo");
  2107. LLSD result = adapter.postAndSuspend(url, body);
  2108. LLCore::HttpStatus status =
  2109. LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(result);
  2110. if (status)
  2111. {
  2112. refresh();
  2113. }
  2114. else
  2115. {
  2116. llwarns << "Failed to commit estate info: " << status.toString()
  2117. << llendl;
  2118. }
  2119. }
  2120. // This is the old way of doing things, is deprecated, and should be deleted
  2121. // when the dataserver model can be removed.
  2122. // key = "estatechangeinfo"
  2123. // strings[0] = str(estate_id) (added by simulator before relay - not here)
  2124. // strings[1] = estate_name
  2125. // strings[2] = str(estate_flags)
  2126. // strings[3] = str((S32)(sun_hour * 1024.f))
  2127. void LLPanelEstateInfo::commitEstateInfoDataserver()
  2128. {
  2129. LLMessageSystem* msg = gMessageSystemp;
  2130. msg->newMessage(_PREHASH_EstateOwnerMessage);
  2131. msg->nextBlockFast(_PREHASH_AgentData);
  2132. msg->addUUIDFast(_PREHASH_AgentID, gAgentID);
  2133. msg->addUUIDFast(_PREHASH_SessionID, gAgentSessionID);
  2134. msg->addUUIDFast(_PREHASH_TransactionID, LLUUID::null); // not used
  2135. msg->nextBlock(_PREHASH_MethodData);
  2136. msg->addString(_PREHASH_Method, "estatechangeinfo");
  2137. msg->addUUID(_PREHASH_Invoice, LLFloaterRegionInfo::getLastInvoice());
  2138. msg->nextBlock(_PREHASH_ParamList);
  2139. msg->addString(_PREHASH_Parameter, getEstateName());
  2140. std::string buffer;
  2141. buffer = llformat("%u", computeEstateFlags());
  2142. msg->nextBlock(_PREHASH_ParamList);
  2143. msg->addString(_PREHASH_Parameter, buffer);
  2144. F32 sun_hour = getSunHour();
  2145. if (childGetValue("use_global_time_check").asBoolean())
  2146. {
  2147. sun_hour = 0.f; // 0 = global time
  2148. }
  2149. buffer = llformat("%d", (S32)(sun_hour * 1024.f));
  2150. msg->nextBlock(_PREHASH_ParamList);
  2151. msg->addString(_PREHASH_Parameter, buffer);
  2152. gAgent.sendMessage();
  2153. }
  2154. void LLPanelEstateInfo::setEstateFlags(U32 flags)
  2155. {
  2156. childSetValue("public_access_check",
  2157. LLSD((flags & REGION_FLAGS_EXTERNALLY_VISIBLE) != 0));
  2158. childSetValue("fixed_sun_check",
  2159. LLSD((flags & REGION_FLAGS_SUN_FIXED) != 0));
  2160. childSetValue("voice_chat_check",
  2161. LLSD((flags & REGION_FLAGS_ALLOW_VOICE) != 0));
  2162. childSetValue("allow_direct_teleport",
  2163. LLSD((flags & REGION_FLAGS_ALLOW_DIRECT_TELEPORT) != 0));
  2164. childSetValue("limit_payment",
  2165. LLSD((flags & REGION_FLAGS_DENY_ANONYMOUS) != 0));
  2166. childSetValue("limit_age_verified",
  2167. LLSD((flags & REGION_FLAGS_DENY_AGEUNVERIFIED) != 0));
  2168. childSetValue("parcel_access_override",
  2169. LLSD((flags & REGION_FLAGS_ALLOW_ACCESS_OVERRIDE) != 0));
  2170. childSetValue("limit_bots", LLSD((flags & REGION_FLAGS_DENY_BOTS) != 0));
  2171. refresh();
  2172. }
  2173. U32 LLPanelEstateInfo::computeEstateFlags()
  2174. {
  2175. U32 flags = 0;
  2176. // This is not in LLPanelEstateInfo's UI: it is (re)set by
  2177. // HBPanelLandEnvironment directly in sEstateFlags...
  2178. if (LLEstateInfoModel::getAllowEnvironmentOverride())
  2179. {
  2180. flags |= REGION_FLAGS_ALLOW_ENVIRONMENT_OVERRIDE;
  2181. }
  2182. if (childGetValue("public_access_check").asBoolean())
  2183. {
  2184. flags |= REGION_FLAGS_EXTERNALLY_VISIBLE;
  2185. }
  2186. if (childGetValue("voice_chat_check").asBoolean())
  2187. {
  2188. flags |= REGION_FLAGS_ALLOW_VOICE;
  2189. }
  2190. if (childGetValue("parcel_access_override").asBoolean())
  2191. {
  2192. flags |= REGION_FLAGS_ALLOW_ACCESS_OVERRIDE;
  2193. }
  2194. if (childGetValue("allow_direct_teleport").asBoolean())
  2195. {
  2196. flags |= REGION_FLAGS_ALLOW_DIRECT_TELEPORT;
  2197. }
  2198. if (childGetValue("fixed_sun_check").asBoolean())
  2199. {
  2200. flags |= REGION_FLAGS_SUN_FIXED;
  2201. }
  2202. if (childGetValue("limit_payment").asBoolean())
  2203. {
  2204. flags |= REGION_FLAGS_DENY_ANONYMOUS;
  2205. }
  2206. if (childGetValue("limit_age_verified").asBoolean())
  2207. {
  2208. flags |= REGION_FLAGS_DENY_AGEUNVERIFIED;
  2209. }
  2210. if (childGetValue("limit_bots").asBoolean())
  2211. {
  2212. flags |= REGION_FLAGS_DENY_BOTS;
  2213. }
  2214. // Store in LLEstateInfoModel
  2215. LLEstateInfoModel::sEstateFlags = flags;
  2216. return flags;
  2217. }
  2218. bool LLPanelEstateInfo::getGlobalTime()
  2219. {
  2220. return childGetValue("use_global_time_check").asBoolean();
  2221. }
  2222. void LLPanelEstateInfo::setGlobalTime(bool b)
  2223. {
  2224. childSetValue("use_global_time_check", LLSD(b));
  2225. childSetEnabled("fixed_sun_check", LLSD(!b));
  2226. childSetEnabled("sun_hour_slider", LLSD(!b));
  2227. if (b)
  2228. {
  2229. childSetValue("sun_hour_slider", LLSD(0.f));
  2230. }
  2231. }
  2232. bool LLPanelEstateInfo::getFixedSun()
  2233. {
  2234. return childGetValue("fixed_sun_check").asBoolean();
  2235. }
  2236. void LLPanelEstateInfo::setSunHour(F32 sun_hour)
  2237. {
  2238. if (sun_hour < 6.f)
  2239. {
  2240. sun_hour = 24.f + sun_hour;
  2241. }
  2242. childSetValue("sun_hour_slider", LLSD(sun_hour));
  2243. }
  2244. F32 LLPanelEstateInfo::getSunHour()
  2245. {
  2246. if (childIsEnabled("sun_hour_slider"))
  2247. {
  2248. return (F32)childGetValue("sun_hour_slider").asReal();
  2249. }
  2250. return 0.f;
  2251. }
  2252. const std::string LLPanelEstateInfo::getEstateName() const
  2253. {
  2254. return childGetValue("estate_name").asString();
  2255. }
  2256. void LLPanelEstateInfo::setEstateName(const std::string& name)
  2257. {
  2258. childSetValue("estate_name", LLSD(name));
  2259. }
  2260. const std::string LLPanelEstateInfo::getOwnerName() const
  2261. {
  2262. return childGetValue("estate_owner").asString();
  2263. }
  2264. void LLPanelEstateInfo::setOwnerName(const std::string& name)
  2265. {
  2266. childSetValue("estate_owner", LLSD(name));
  2267. }
  2268. bool LLPanelEstateInfo::checkSunHourSlider(LLUICtrl* child_ctrl)
  2269. {
  2270. bool found_child_ctrl = false;
  2271. if (child_ctrl->getName() == "sun_hour_slider")
  2272. {
  2273. enableApplyBtn();
  2274. found_child_ctrl = true;
  2275. }
  2276. return found_child_ctrl;
  2277. }
  2278. bool LLPanelEstateInfo::kickUserConfirm(const LLSD& notification,
  2279. const LLSD& response)
  2280. {
  2281. if (LLNotification::getSelectedOption(notification, response) == 0)
  2282. {
  2283. // Kick User
  2284. strings_t strings;
  2285. strings.emplace_back(notification["payload"]["agent_id"].asString());
  2286. sendEstateOwnerMessage("kickestate", strings);
  2287. }
  2288. return false;
  2289. }
  2290. //static
  2291. void LLPanelEstateInfo::onClickMessageEstate(void* userdata)
  2292. {
  2293. gNotifications.add("MessageEstate", LLSD(), LLSD(),
  2294. boost::bind(&LLPanelEstateInfo::onMessageCommit,
  2295. (LLPanelEstateInfo*)userdata, _1, _2));
  2296. }
  2297. //static
  2298. bool LLPanelEstateInfo::onMessageCommit(const LLSD& notification,
  2299. const LLSD& response)
  2300. {
  2301. S32 option = LLNotification::getSelectedOption(notification, response);
  2302. std::string text = response["message"].asString();
  2303. if (option != 0) return false;
  2304. if (text.empty()) return false;
  2305. llinfos << "Message to everyone: " << text << llendl;
  2306. strings_t strings;
  2307. //integers_t integers;
  2308. std::string name;
  2309. gAgent.buildFullname(name);
  2310. strings.emplace_back(strings_t::value_type(name));
  2311. strings.emplace_back(strings_t::value_type(text));
  2312. sendEstateOwnerMessage("instantmessage", strings);
  2313. return false;
  2314. }
  2315. //static
  2316. void LLPanelEstateInfo::initDispatch(LLDispatcher& dispatch)
  2317. {
  2318. std::string name = "estateupdateinfo";
  2319. static LLDispatchEstateUpdateInfo estate_update_info;
  2320. dispatch.addHandler(name, &estate_update_info);
  2321. name = "setaccess";
  2322. static LLDispatchSetEstateAccess set_access;
  2323. dispatch.addHandler(name, &set_access);
  2324. name = "setexperience";
  2325. static LLDispatchSetEstateExperience set_experience;
  2326. dispatch.addHandler(name, &set_experience);
  2327. gEstateDispatchInitialized = true;
  2328. }
  2329. //static
  2330. void LLPanelEstateInfo::callbackCacheName(const LLUUID& id,
  2331. const std::string& full_name,
  2332. bool is_group)
  2333. {
  2334. LLPanelEstateInfo* self = LLFloaterRegionInfo::getPanelEstate();
  2335. if (!self) return;
  2336. std::string name;
  2337. if (id.isNull())
  2338. {
  2339. name = "(none)";
  2340. }
  2341. else
  2342. {
  2343. name = full_name;
  2344. }
  2345. self->setOwnerName(name);
  2346. }
  2347. // Disables the sun-hour slider and the use fixed time check if the use global
  2348. // time is check
  2349. //static
  2350. void LLPanelEstateInfo::onChangeUseGlobalTime(LLUICtrl* ctrl, void* user_data)
  2351. {
  2352. LLPanelEstateInfo* self = (LLPanelEstateInfo*)user_data;
  2353. if (!self) return;
  2354. bool enabled = !self->childGetValue("use_global_time_check").asBoolean();
  2355. self->childSetEnabled("sun_hour_slider", enabled);
  2356. self->childSetEnabled("fixed_sun_check", enabled);
  2357. self->childSetValue("fixed_sun_check", LLSD(false));
  2358. self->enableApplyBtn();
  2359. }
  2360. // Enables the sun-hour slider if the fixed-sun checkbox is set
  2361. //static
  2362. void LLPanelEstateInfo::onChangeFixedSun(LLUICtrl* ctrl, void* user_data)
  2363. {
  2364. LLPanelEstateInfo* self = (LLPanelEstateInfo*) user_data;
  2365. if (!self) return;
  2366. bool enabled = !self->childGetValue("fixed_sun_check").asBoolean();
  2367. self->childSetEnabled("use_global_time_check", enabled);
  2368. self->childSetValue("use_global_time_check", LLSD(false));
  2369. self->enableApplyBtn();
  2370. }
  2371. //static
  2372. void LLPanelEstateInfo::onClickKickUser(void* user_data)
  2373. {
  2374. LLPanelEstateInfo* self = (LLPanelEstateInfo*)user_data;
  2375. if (!self) return;
  2376. LLFloater* picker = LLFloaterAvatarPicker::show(onKickUserCommit,
  2377. user_data, false, true);
  2378. if (picker && gFloaterViewp)
  2379. {
  2380. // This depends on the grandparent view being a floater in order to set
  2381. // up floater dependency
  2382. LLFloater* parentp = gFloaterViewp->getParentFloater(self);
  2383. if (parentp)
  2384. {
  2385. parentp->addDependentFloater(picker);
  2386. }
  2387. }
  2388. }
  2389. struct LLKickFromEstateInfo
  2390. {
  2391. LLPanelEstateInfo* mEstatePanelp;
  2392. LLUUID mAgentID;
  2393. };
  2394. //static
  2395. void LLPanelEstateInfo::onKickUserCommit(const std::vector<std::string>& names,
  2396. const uuid_vec_t& ids,
  2397. void* userdata)
  2398. {
  2399. LLPanelEstateInfo* self = (LLPanelEstateInfo*)userdata;
  2400. if (!self || names.empty() || ids.empty() ||
  2401. // Check to make sure there is one valid user and id
  2402. ids[0].isNull() || names[0].length() == 0)
  2403. {
  2404. return;
  2405. }
  2406. // Keep track of what user they want to kick and other misc info
  2407. LLKickFromEstateInfo* kick_info = new LLKickFromEstateInfo();
  2408. kick_info->mEstatePanelp = self;
  2409. kick_info->mAgentID = ids[0];
  2410. // Bring up a confirmation dialog
  2411. LLSD args;
  2412. args["EVIL_USER"] = names[0];
  2413. LLSD payload;
  2414. payload["agent_id"] = ids[0];
  2415. gNotifications.add("EstateKickUser", args, payload,
  2416. boost::bind(&LLPanelEstateInfo::kickUserConfirm, self,
  2417. _1, _2));
  2418. }
  2419. //static
  2420. bool LLPanelEstateInfo::isLindenEstate()
  2421. {
  2422. LLPanelEstateInfo* self = LLFloaterRegionInfo::getPanelEstate();
  2423. return self && self->getEstateID() <= ESTATE_LAST_LINDEN;
  2424. }
  2425. //static
  2426. void LLPanelEstateInfo::updateEstateOwnerName(const std::string& name)
  2427. {
  2428. LLPanelEstateInfo* self = LLFloaterRegionInfo::getPanelEstate();
  2429. if (self)
  2430. {
  2431. self->setOwnerName(name);
  2432. }
  2433. }
  2434. //static
  2435. void LLPanelEstateInfo::updateEstateName(const std::string& name)
  2436. {
  2437. LLPanelEstateInfo* self = LLFloaterRegionInfo::getPanelEstate();
  2438. if (self)
  2439. {
  2440. self->setEstateName(name);
  2441. }
  2442. }
  2443. ///////////////////////////////////////////////////////////////////////////////
  2444. // LLPanelEstateAccess
  2445. ///////////////////////////////////////////////////////////////////////////////
  2446. //static
  2447. S32 LLPanelEstateAccess::sLastActiveTab = 0;
  2448. LLPanelEstateAccess::LLPanelEstateAccess()
  2449. : LLPanelRegionInfo(),
  2450. mPendingUpdate(false),
  2451. mCtrlsEnabled(false)
  2452. {
  2453. }
  2454. //virtual
  2455. bool LLPanelEstateAccess::postBuild()
  2456. {
  2457. mTabContainer = getChild<LLTabContainer>("access_tabs");
  2458. LLPanel* tab = mTabContainer->getChild<LLPanel>("estate_managers");
  2459. mTabContainer->setTabChangeCallback(tab, onTabChanged);
  2460. mTabContainer->setTabUserData(tab, this);
  2461. tab = mTabContainer->getChild<LLPanel>("allowed_groups");
  2462. mTabContainer->setTabChangeCallback(tab, onTabChanged);
  2463. mTabContainer->setTabUserData(tab, this);
  2464. tab = mTabContainer->getChild<LLPanel>("allowed_resident");
  2465. mTabContainer->setTabChangeCallback(tab, onTabChanged);
  2466. mTabContainer->setTabUserData(tab, this);
  2467. tab = mTabContainer->getChild<LLPanel>("banned_residents");
  2468. mTabContainer->setTabChangeCallback(tab, onTabChanged);
  2469. mTabContainer->setTabUserData(tab, this);
  2470. mTabContainer->selectTab(sLastActiveTab);
  2471. initHelpBtn("estate_manager_help", "HelpEstateEstateManager");
  2472. initHelpBtn("allow_group_help", "HelpEstateAllowGroup");
  2473. initHelpBtn("allow_resident_help", "HelpEstateAllowResident");
  2474. initHelpBtn("ban_resident_help", "HelpEstateBanResident");
  2475. mEstateManagers = getChild<LLNameListCtrl>("estate_manager_name_list");
  2476. mEstateManagers->setCommitCallback(updateChild);
  2477. mEstateManagers->setCallbackUserData(this);
  2478. mEstateManagers->setCommitOnSelectionChange(true);
  2479. // Allow extras for dupe issue
  2480. mEstateManagers->setMaxItemCount(ESTATE_MAX_MANAGERS * 4);
  2481. childSetAction("add_estate_manager_btn", onClickAddEstateManager, this);
  2482. childSetAction("remove_estate_manager_btn", onClickRemoveEstateManager,
  2483. this);
  2484. mAllowedGroups = getChild<LLNameListCtrl>("allowed_group_name_list");
  2485. mAllowedGroups->setCommitCallback(updateChild);
  2486. mAllowedGroups->setCallbackUserData(this);
  2487. mAllowedGroups->setCommitOnSelectionChange(true);
  2488. mAllowedGroups->setMaxItemCount(ESTATE_MAX_ACCESS_IDS);
  2489. childSetAction("add_allowed_group_btn", onClickAddAllowedGroup, this);
  2490. childSetAction("remove_allowed_group_btn", onClickRemoveAllowedGroup,
  2491. this);
  2492. mAllowedAvatars = getChild<LLNameListCtrl>("allowed_avatar_name_list");
  2493. mAllowedAvatars->setCommitCallback(updateChild);
  2494. mAllowedAvatars->setCallbackUserData(this);
  2495. mAllowedAvatars->setCommitOnSelectionChange(true);
  2496. mAllowedAvatars->setMaxItemCount(ESTATE_MAX_ACCESS_IDS);
  2497. childSetAction("add_allowed_avatar_btn", onClickAddAllowedAgent, this);
  2498. childSetAction("remove_allowed_avatar_btn", onClickRemoveAllowedAgent,
  2499. this);
  2500. mBannedAvatars = getChild<LLNameListCtrl>("banned_avatar_name_list");
  2501. mBannedAvatars->setCommitCallback(updateChild);
  2502. mBannedAvatars->setCallbackUserData(this);
  2503. mBannedAvatars->setCommitOnSelectionChange(true);
  2504. mBannedAvatars->setMaxItemCount(ESTATE_MAX_BANNED_IDS);
  2505. childSetAction("add_banned_avatar_btn", onClickAddBannedAgent, this);
  2506. childSetAction("remove_banned_avatar_btn", onClickRemoveBannedAgent, this);
  2507. #if 0 // *TODO: implement (backport from LL's viewer-release)
  2508. childSetCommitCallback("allowed_search_input", onAllowedSearchEdit, this);
  2509. childSetCommitCallback("banned_search_input", onBannedSearchEdit, this);
  2510. childSetCommitCallback("allowed_group_search_input",
  2511. onAllowedGroupsSearchEdit, this);
  2512. childSetAction("copy_allowed_list_btn", onClickCopyAllowedList, this);
  2513. childSetAction("copy_allowed_group_list_btn", onClickCopyAllowedGroupList,
  2514. this);
  2515. childSetAction("copy_banned_list_btn", onClickCopyBannedList, this);
  2516. #endif
  2517. // Note: no apply button, so we do not call LLPanelRegionInfo::postBuild()
  2518. return true;
  2519. }
  2520. //static
  2521. void LLPanelEstateAccess::updateChild(LLUICtrl* ctrlp, void* user_data)
  2522. {
  2523. LLPanelEstateAccess* self = (LLPanelEstateAccess*)user_data;
  2524. if (self && ctrlp)
  2525. {
  2526. self->checkRemovalButton(ctrlp->getName());
  2527. // Ensure appropriate state of the management ui.
  2528. self->updateControls();
  2529. }
  2530. }
  2531. //virtual
  2532. bool LLPanelEstateAccess::refreshFromRegion(LLViewerRegion* regionp)
  2533. {
  2534. LLPanelRegionInfo::refreshFromRegion(regionp);
  2535. LL_DEBUGS("RegionInfo") << "Refreshing from region..." << LL_ENDL;
  2536. updateLists();
  2537. return true;
  2538. }
  2539. void LLPanelEstateAccess::updateLists()
  2540. {
  2541. std::string cap_url = gAgent.getRegionCapability("EstateAccess");
  2542. if (cap_url.empty())
  2543. {
  2544. strings_t strings;
  2545. LLFloaterRegionInfo::nextInvoice();
  2546. sendEstateOwnerMessage("getinfo", strings);
  2547. return;
  2548. }
  2549. // Use the capability
  2550. gCoros.launch("LLPanelEstateAccess::requestEstateGetAccessCoro",
  2551. boost::bind(LLPanelEstateAccess::requestEstateGetAccessCoro,
  2552. cap_url));
  2553. }
  2554. void LLPanelEstateAccess::requestEstateGetAccessCoro(const std::string& url)
  2555. {
  2556. LLCoreHttpUtil::HttpCoroutineAdapter adapter("requestEstateGetAccessoCoro");
  2557. LLSD result = adapter.getAndSuspend(url);
  2558. LLCore::HttpStatus status =
  2559. LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(result);
  2560. LLPanelEstateAccess* self = LLFloaterRegionInfo::getPanelAccess();
  2561. if (!self) return; // We have since been closed...
  2562. LLNameListCtrl* name_list;
  2563. if (result.has("AllowedAgents"))
  2564. {
  2565. name_list = self->mAllowedAvatars;
  2566. const LLSD& allowed = result["AllowedAgents"];
  2567. LLStringUtil::format_map_t args;
  2568. args["[ALLOWEDAGENTS]"] = llformat("%d", allowed.size());
  2569. args["[MAXACCESS]"] = llformat("%d", ESTATE_MAX_ACCESS_IDS);
  2570. std::string msg = self->getString("RegionInfoAllowedResidents", args);
  2571. self->getChild<LLUICtrl>("allow_resident_label")->setValue(LLSD(msg));
  2572. name_list->clearSortOrder();
  2573. name_list->deleteAllItems();
  2574. for (LLSD::array_const_iterator it = allowed.beginArray(),
  2575. end = allowed.endArray();
  2576. it != end; ++it)
  2577. {
  2578. LLUUID id = (*it)["id"].asUUID();
  2579. name_list->addNameItem(id);
  2580. }
  2581. name_list->sortByName(true);
  2582. }
  2583. if (result.has("BannedAgents"))
  2584. {
  2585. name_list = self->mBannedAvatars;
  2586. const LLSD& banned = result["BannedAgents"];
  2587. LLStringUtil::format_map_t args;
  2588. args["[BANNEDAGENTS]"] = llformat("%d", banned.size());
  2589. args["[MAXBANNED]"] = llformat("%d", ESTATE_MAX_BANNED_IDS);
  2590. std::string msg = self->getString("RegionInfoBannedResidents", args);
  2591. self->getChild<LLUICtrl>("ban_resident_label")->setValue(LLSD(msg));
  2592. name_list->clearSortOrder();
  2593. name_list->deleteAllItems();
  2594. std::string fullname;
  2595. std::string na = LLTrans::getString("na");
  2596. for (LLSD::array_const_iterator it = banned.beginArray(),
  2597. end = banned.endArray();
  2598. it != end; ++it)
  2599. {
  2600. LLSD item;
  2601. item["id"] = (*it)["id"].asUUID();
  2602. LLSD& columns = item["columns"];
  2603. columns[0]["column"] = "name"; // value is auto-populated
  2604. columns[1]["column"] = "last_login_date";
  2605. columns[1]["value"] =
  2606. // Cut the seconds
  2607. (*it)["last_login_date"].asString().substr(0, 16);
  2608. std::string ban_date = (*it)["ban_date"].asString();
  2609. columns[2]["column"] = "ban_date";
  2610. // The server returns the "0000-00-00 00:00:00" date in case it
  2611. // does not know it
  2612. columns[2]["value"] = ban_date[0] ? ban_date.substr(0, 16) : na;
  2613. columns[3]["column"] = "bannedby";
  2614. LLUUID banning_id = (*it)["banning_id"].asUUID();
  2615. if (banning_id.isNull())
  2616. {
  2617. columns[3]["value"] = na;
  2618. }
  2619. else if (gCacheNamep &&
  2620. gCacheNamep->getFullName(banning_id, fullname))
  2621. {
  2622. // *TODO: fetch the name if it was not cached
  2623. columns[3]["value"] = fullname;
  2624. }
  2625. name_list->addElement(item);
  2626. }
  2627. name_list->sortByName(true);
  2628. }
  2629. if (result.has("AllowedGroups"))
  2630. {
  2631. name_list = self->mAllowedGroups;
  2632. const LLSD& groups = result["AllowedGroups"];
  2633. LLStringUtil::format_map_t args;
  2634. args["[ALLOWEDGROUPS]"] = llformat("%d", groups.size());
  2635. args["[MAXACCESS]"] = llformat("%d", ESTATE_MAX_GROUP_IDS);
  2636. std::string msg = self->getString("RegionInfoAllowedGroups", args);
  2637. self->getChild<LLUICtrl>("allow_group_label")->setValue(LLSD(msg));
  2638. name_list->clearSortOrder();
  2639. name_list->deleteAllItems();
  2640. for (LLSD::array_const_iterator it = groups.beginArray(),
  2641. end = groups.endArray();
  2642. it != end; ++it)
  2643. {
  2644. LLUUID id = (*it)["id"].asUUID();
  2645. name_list->addGroupNameItem(id);
  2646. }
  2647. name_list->sortByName(true);
  2648. }
  2649. if (result.has("Managers"))
  2650. {
  2651. name_list = self->mEstateManagers;
  2652. const LLSD& managers = result["Managers"];
  2653. LLStringUtil::format_map_t args;
  2654. args["[ESTATEMANAGERS]"] = llformat("%d", managers.size());
  2655. args["[MAXMANAGERS]"] = llformat("%d", ESTATE_MAX_MANAGERS);
  2656. std::string msg = self->getString("RegionInfoEstateManagers", args);
  2657. self->getChild<LLUICtrl>("estate_manager_label")->setValue(LLSD(msg));
  2658. name_list->clearSortOrder();
  2659. name_list->deleteAllItems();
  2660. for (LLSD::array_const_iterator it = managers.beginArray(),
  2661. end = managers.endArray();
  2662. it != end; ++it)
  2663. {
  2664. LLUUID id = (*it)["agent_id"].asUUID();
  2665. name_list->addNameItem(id);
  2666. }
  2667. name_list->sortByName(true);
  2668. }
  2669. self->updateControls();
  2670. }
  2671. //static
  2672. void LLPanelEstateAccess::onTabChanged(void* user_data, bool)
  2673. {
  2674. LLPanelEstateAccess* self = (LLPanelEstateAccess*)user_data;
  2675. if (self)
  2676. {
  2677. sLastActiveTab = self->mTabContainer->getCurrentPanelIndex();
  2678. }
  2679. }
  2680. //static
  2681. void LLPanelEstateAccess::onClickAddAllowedAgent(void* user_data)
  2682. {
  2683. LLPanelEstateAccess* self = (LLPanelEstateAccess*)user_data;
  2684. if (!self) return;
  2685. if (self->mAllowedAvatars->getItemCount() >= ESTATE_MAX_ACCESS_IDS)
  2686. {
  2687. LLSD args;
  2688. args["MAX_AGENTS"] = llformat("%d",ESTATE_MAX_ACCESS_IDS);
  2689. gNotifications.add("MaxAllowedAgentOnRegion", args);
  2690. }
  2691. else
  2692. {
  2693. accessAddCore(ESTATE_ACCESS_ALLOWED_AGENT_ADD);
  2694. }
  2695. }
  2696. //static
  2697. void LLPanelEstateAccess::onClickRemoveAllowedAgent(void* user_data)
  2698. {
  2699. accessRemoveCore(ESTATE_ACCESS_ALLOWED_AGENT_REMOVE);
  2700. }
  2701. //static
  2702. void LLPanelEstateAccess::onClickAddAllowedGroup(void* user_data)
  2703. {
  2704. LLPanelEstateAccess* self = (LLPanelEstateAccess*)user_data;
  2705. if (!self) return;
  2706. if (self->mAllowedGroups->getItemCount() >= ESTATE_MAX_ACCESS_IDS)
  2707. {
  2708. LLSD args;
  2709. args["MAX_GROUPS"] = llformat("%d",ESTATE_MAX_ACCESS_IDS);
  2710. gNotifications.add("MaxAllowedGroupsOnRegion", args);
  2711. return;
  2712. }
  2713. LLNotification::Params params("ChangeLindenAccess");
  2714. params.functor(boost::bind(&LLPanelEstateAccess::addAllowedGroup,
  2715. self, _1, _2));
  2716. if (LLPanelEstateInfo::isLindenEstate())
  2717. {
  2718. gNotifications.add(params);
  2719. }
  2720. else
  2721. {
  2722. gNotifications.forceResponse(params, 0);
  2723. }
  2724. }
  2725. //static
  2726. bool LLPanelEstateAccess::addAllowedGroup(const LLSD& notification,
  2727. const LLSD& response)
  2728. {
  2729. if (LLNotification::getSelectedOption(notification, response))
  2730. {
  2731. return false;
  2732. }
  2733. LLFloaterGroupPicker* picker = LLFloaterGroupPicker::show(addAllowedGroup2,
  2734. NULL);
  2735. LLFloater* parentp = gFloaterViewp->getParentFloater(this);
  2736. if (picker && parentp && gFloaterViewp)
  2737. {
  2738. LLRect new_rect = gFloaterViewp->findNeighboringPosition(parentp,
  2739. picker);
  2740. picker->setOrigin(new_rect.mLeft, new_rect.mBottom);
  2741. parentp->addDependentFloater(picker);
  2742. }
  2743. return false;
  2744. }
  2745. //static
  2746. void LLPanelEstateAccess::onClickRemoveAllowedGroup(void* user_data)
  2747. {
  2748. accessRemoveCore(ESTATE_ACCESS_ALLOWED_GROUP_REMOVE);
  2749. }
  2750. //static
  2751. void LLPanelEstateAccess::onClickAddBannedAgent(void* user_data)
  2752. {
  2753. LLPanelEstateAccess* self = (LLPanelEstateAccess*)user_data;
  2754. if (!self) return;
  2755. if (self->mBannedAvatars->getItemCount() >= ESTATE_MAX_BANNED_IDS)
  2756. {
  2757. LLSD args;
  2758. args["MAX_BANNED"] = llformat("%d",ESTATE_MAX_BANNED_IDS);
  2759. gNotifications.add("MaxBannedAgentsOnRegion", args);
  2760. }
  2761. else
  2762. {
  2763. accessAddCore(ESTATE_ACCESS_BANNED_AGENT_ADD);
  2764. }
  2765. }
  2766. //static
  2767. void LLPanelEstateAccess::onClickRemoveBannedAgent(void* user_data)
  2768. {
  2769. accessRemoveCore(ESTATE_ACCESS_BANNED_AGENT_REMOVE);
  2770. }
  2771. //static
  2772. void LLPanelEstateAccess::onClickAddEstateManager(void* user_data)
  2773. {
  2774. LLPanelEstateAccess* self = (LLPanelEstateAccess*)user_data;
  2775. if (!self) return;
  2776. if (self->mEstateManagers->getItemCount() >= ESTATE_MAX_MANAGERS)
  2777. {
  2778. // Tell user they cannot add more managers
  2779. LLSD args;
  2780. args["MAX_MANAGER"] = llformat("%d", ESTATE_MAX_MANAGERS);
  2781. gNotifications.add("MaxManagersOnRegion", args);
  2782. }
  2783. else
  2784. {
  2785. // Go pick managers to add
  2786. accessAddCore(ESTATE_ACCESS_MANAGER_ADD);
  2787. }
  2788. }
  2789. //static
  2790. void LLPanelEstateAccess::onClickRemoveEstateManager(void* user_data)
  2791. {
  2792. accessRemoveCore(ESTATE_ACCESS_MANAGER_REMOVE);
  2793. }
  2794. //static
  2795. std::string LLPanelEstateAccess::allEstatesText()
  2796. {
  2797. LLPanelEstateAccess* self = LLFloaterRegionInfo::getPanelAccess();
  2798. LLPanelEstateInfo* panel_info = LLFloaterRegionInfo::getPanelEstate();
  2799. LLViewerRegion* region = gAgent.getRegion();
  2800. if (!self || !panel_info || !region)
  2801. {
  2802. return "(error)";
  2803. }
  2804. if (gAgent.isGodlike())
  2805. {
  2806. LLStringUtil::format_map_t args;
  2807. args["[OWNER]"] = panel_info->getOwnerName();
  2808. return self->getString("all_estates_owned_by", args);
  2809. }
  2810. else if (region->getOwner() == gAgentID)
  2811. {
  2812. return self->getString("all_estates_you_own");
  2813. }
  2814. else if (region->isEstateManager())
  2815. {
  2816. LLStringUtil::format_map_t args;
  2817. args["[OWNER]"] = panel_info->getOwnerName();
  2818. return self->getString("all_estates_you_manage_for", args);
  2819. }
  2820. return self->getString("error");
  2821. }
  2822. // Special case callback for groups, since it has different callback format
  2823. // than names
  2824. //static
  2825. void LLPanelEstateAccess::addAllowedGroup2(LLUUID id, void* user_data)
  2826. {
  2827. LLPanelEstateAccess* self = LLFloaterRegionInfo::getPanelAccess();
  2828. if (!self) return;
  2829. LLScrollListItem* item = self->mAllowedGroups->getItemById(id);
  2830. if (item)
  2831. {
  2832. LLSD args;
  2833. args["GROUP"] = item->getColumn(0)->getValue().asString();
  2834. gNotifications.add("GroupIsAlreadyInList", args);
  2835. return;
  2836. }
  2837. LLSD payload;
  2838. payload["operation"] = (S32)ESTATE_ACCESS_ALLOWED_GROUP_ADD;
  2839. payload["dialog_name"] = "EstateAllowedGroupAdd";
  2840. payload["allowed_ids"].append(id);
  2841. LLSD args;
  2842. args["ALL_ESTATES"] = allEstatesText();
  2843. LLNotification::Params params("EstateAllowedGroupAdd");
  2844. params.payload(payload).substitutions(args).functor(accessCoreConfirm);
  2845. if (LLPanelEstateInfo::isLindenEstate())
  2846. {
  2847. gNotifications.forceResponse(params, 0);
  2848. }
  2849. else
  2850. {
  2851. gNotifications.add(params);
  2852. }
  2853. }
  2854. //static
  2855. void LLPanelEstateAccess::accessAddCore(U32 operation_flag)
  2856. {
  2857. std::string dialog_name;
  2858. switch (operation_flag)
  2859. {
  2860. case ESTATE_ACCESS_MANAGER_ADD:
  2861. dialog_name = "EstateManagerAdd";
  2862. break;
  2863. case ESTATE_ACCESS_ALLOWED_AGENT_ADD:
  2864. dialog_name = "EstateAllowedAgentAdd";
  2865. break;
  2866. case ESTATE_ACCESS_BANNED_AGENT_ADD:
  2867. dialog_name = "EstateBannedAgentAdd";
  2868. break;
  2869. default:
  2870. llwarns << "Invalid remove operation requested: " << operation_flag
  2871. << llendl;
  2872. llassert(false);
  2873. return;
  2874. }
  2875. LLSD payload;
  2876. payload["operation"] = (S32)operation_flag;
  2877. payload["dialog_name"] = dialog_name;
  2878. // Avatar id filled in after avatar picker
  2879. LLNotification::Params params("ChangeLindenAccess");
  2880. params.payload(payload).functor(accessAddCore2);
  2881. if (LLPanelEstateInfo::isLindenEstate())
  2882. {
  2883. gNotifications.add(params);
  2884. }
  2885. else
  2886. {
  2887. // Same as clicking "OK"
  2888. gNotifications.forceResponse(params, 0);
  2889. }
  2890. }
  2891. //static
  2892. bool LLPanelEstateAccess::accessAddCore2(const LLSD& notification,
  2893. const LLSD& response)
  2894. {
  2895. if (LLNotification::getSelectedOption(notification, response) == 0)
  2896. {
  2897. LLEstateAccessChangeInfo* change_info =
  2898. new LLEstateAccessChangeInfo(notification["payload"]);
  2899. // Avatar picker yes multi-select, yes close-on-select
  2900. LLFloaterAvatarPicker::show(accessAddCore3, (void*)change_info, true,
  2901. true);
  2902. }
  2903. return false;
  2904. }
  2905. //static
  2906. void LLPanelEstateAccess::accessAddCore3(const std::vector<std::string>& names,
  2907. const uuid_vec_t& ids, void* data)
  2908. {
  2909. LLEstateAccessChangeInfo* change_info = (LLEstateAccessChangeInfo*)data;
  2910. if (!change_info) return;
  2911. LLPanelEstateAccess* self = LLFloaterRegionInfo::getPanelAccess();
  2912. LLViewerRegion* region = gAgent.getRegion();
  2913. if (!self || !region || ids.empty())
  2914. {
  2915. delete change_info;
  2916. return;
  2917. }
  2918. // User did select a name. Note: cannot put estate owner on ban list.
  2919. change_info->mAgentOrGroupIDs = ids;
  2920. if (change_info->mOperationFlag & ESTATE_ACCESS_ALLOWED_AGENT_ADD)
  2921. {
  2922. LLNameListCtrl* name_list = self->mAllowedAvatars;
  2923. S32 list_count = name_list->getItemCount();
  2924. S32 total = ids.size() + list_count;
  2925. if (total > ESTATE_MAX_ACCESS_IDS)
  2926. {
  2927. LLSD args;
  2928. args["NUM_ADDED"] = llformat("%d", ids.size());
  2929. args["MAX_AGENTS"] = llformat("%d", ESTATE_MAX_ACCESS_IDS);
  2930. args["LIST_TYPE"] = "Allowed Residents";
  2931. args["NUM_EXCESS"] = llformat("%d", total - ESTATE_MAX_ACCESS_IDS);
  2932. gNotifications.add("MaxAgentOnRegionBatch", args);
  2933. delete change_info;
  2934. return;
  2935. }
  2936. uuid_vec_t ids_allowed;
  2937. std::string already_allowed, first, last;
  2938. bool single = true;
  2939. for (U32 i = 0, count = ids.size(); i < count; ++i)
  2940. {
  2941. const LLUUID& id = ids[i];
  2942. LLScrollListItem* item = name_list->getItemById(id);
  2943. if (item)
  2944. {
  2945. if (!already_allowed.empty())
  2946. {
  2947. already_allowed += ", ";
  2948. single = false;
  2949. }
  2950. already_allowed += item->getColumn(0)->getValue().asString();
  2951. }
  2952. else
  2953. {
  2954. ids_allowed.emplace_back(id);
  2955. // Used to trigger a name caching request, in anticipation
  2956. // for confirmation dialogs.
  2957. gCacheNamep->getName(id, first, last);
  2958. }
  2959. }
  2960. if (!already_allowed.empty())
  2961. {
  2962. LLSD args;
  2963. args["AGENT"] = already_allowed;
  2964. args["LIST_TYPE"] =
  2965. self->getString("RegionInfoListTypeAllowedAgents");
  2966. std::string dialog = single ? "AgentIsAlreadyInList"
  2967. : "AgentsAreAlreadyInList";
  2968. gNotifications.add(dialog, args);
  2969. if (ids_allowed.empty())
  2970. {
  2971. delete change_info;
  2972. return;
  2973. }
  2974. }
  2975. change_info->mAgentOrGroupIDs = ids_allowed;
  2976. }
  2977. if (change_info->mOperationFlag & ESTATE_ACCESS_BANNED_AGENT_ADD)
  2978. {
  2979. LLNameListCtrl* name_list = self->mBannedAvatars;
  2980. S32 list_count = name_list->getItemCount();
  2981. S32 total = ids.size() + list_count;
  2982. if (total > ESTATE_MAX_BANNED_IDS)
  2983. {
  2984. LLSD args;
  2985. args["NUM_ADDED"] = llformat("%d", ids.size());
  2986. args["MAX_AGENTS"] = llformat("%d", ESTATE_MAX_BANNED_IDS);
  2987. args["LIST_TYPE"] = "Banned Residents";
  2988. args["NUM_EXCESS"] = llformat("%d", total - ESTATE_MAX_BANNED_IDS);
  2989. gNotifications.add("MaxAgentOnRegionBatch", args);
  2990. delete change_info;
  2991. return;
  2992. }
  2993. LLNameListCtrl* em_list = self->mEstateManagers;
  2994. uuid_vec_t ids_banned;
  2995. std::string already_banned, em_ban, first, last;
  2996. bool single = true;
  2997. for (U32 i = 0, count = ids.size(); i < count; ++i)
  2998. {
  2999. const LLUUID& id = ids[i];
  3000. bool can_ban = true;
  3001. LLScrollListItem* em_item = em_list->getItemById(id);
  3002. if (em_item)
  3003. {
  3004. if (!em_ban.empty())
  3005. {
  3006. em_ban += ", ";
  3007. }
  3008. em_ban += em_item->getColumn(0)->getValue().asString();
  3009. can_ban = false;
  3010. }
  3011. LLScrollListItem* item = name_list->getItemById(id);
  3012. if (item)
  3013. {
  3014. if (!already_banned.empty())
  3015. {
  3016. already_banned += ", ";
  3017. single = false;
  3018. }
  3019. already_banned += item->getColumn(0)->getValue().asString();
  3020. can_ban = false;
  3021. }
  3022. if (can_ban)
  3023. {
  3024. ids_banned.emplace_back(id);
  3025. // Used to trigger a name caching request, in anticipation
  3026. // for confirmation dialogs.
  3027. gCacheNamep->getName(id, first, last);
  3028. }
  3029. }
  3030. if (!em_ban.empty())
  3031. {
  3032. LLSD args;
  3033. args["AGENT"] = em_ban;
  3034. gNotifications.add("ProblemBanningEstateManager", args);
  3035. if (ids_banned.empty())
  3036. {
  3037. delete change_info;
  3038. return;
  3039. }
  3040. }
  3041. if (!already_banned.empty())
  3042. {
  3043. LLSD args;
  3044. args["AGENT"] = already_banned;
  3045. args["LIST_TYPE"] =
  3046. self->getString("RegionInfoListTypeBannedAgents");
  3047. std::string dialog = single ? "AgentIsAlreadyInList"
  3048. : "AgentsAreAlreadyInList";
  3049. gNotifications.add(dialog, args);
  3050. if (ids_banned.empty())
  3051. {
  3052. delete change_info;
  3053. return;
  3054. }
  3055. }
  3056. change_info->mAgentOrGroupIDs = ids_banned;
  3057. }
  3058. LLSD args;
  3059. args["ALL_ESTATES"] = allEstatesText();
  3060. LLNotification::Params params(change_info->mDialogName);
  3061. params.substitutions(args).payload(change_info->asLLSD()).functor(accessCoreConfirm);
  3062. if (LLPanelEstateInfo::isLindenEstate())
  3063. {
  3064. // Just apply to this estate
  3065. gNotifications.forceResponse(params, 0);
  3066. }
  3067. else
  3068. {
  3069. // Ask if this estate or all estates with this owner
  3070. gNotifications.add(params);
  3071. }
  3072. }
  3073. //static
  3074. void LLPanelEstateAccess::accessRemoveCore(U32 operation_flag)
  3075. {
  3076. LLPanelEstateAccess* self = LLFloaterRegionInfo::getPanelAccess();
  3077. if (!self) return;
  3078. std::string dialog_name;
  3079. LLNameListCtrl* name_list;
  3080. switch (operation_flag)
  3081. {
  3082. case ESTATE_ACCESS_MANAGER_REMOVE:
  3083. dialog_name = "EstateManagerRemove";
  3084. name_list = self->mEstateManagers;
  3085. break;
  3086. case ESTATE_ACCESS_ALLOWED_GROUP_REMOVE:
  3087. dialog_name = "EstateAllowedGroupRemove";
  3088. name_list = self->mAllowedGroups;
  3089. break;
  3090. case ESTATE_ACCESS_ALLOWED_AGENT_REMOVE:
  3091. dialog_name = "EstateAllowedAgentRemove";
  3092. name_list = self->mAllowedAvatars;
  3093. break;
  3094. case ESTATE_ACCESS_BANNED_AGENT_REMOVE:
  3095. dialog_name = "EstateBannedAgentRemove";
  3096. name_list = self->mBannedAvatars;
  3097. break;
  3098. default:
  3099. llwarns << "Invalid remove operation requested: " << operation_flag
  3100. << llendl;
  3101. llassert(false);
  3102. return;
  3103. }
  3104. std::vector<LLScrollListItem*> list_vector = name_list->getAllSelected();
  3105. if (list_vector.size() == 0)
  3106. {
  3107. return;
  3108. }
  3109. LLSD payload;
  3110. payload["operation"] = (S32)operation_flag;
  3111. payload["dialog_name"] = dialog_name;
  3112. for (U32 i = 0, count = list_vector.size(); i < count; ++i)
  3113. {
  3114. LLScrollListItem* item = list_vector[i];
  3115. if (item) // Paranoia
  3116. {
  3117. payload["allowed_ids"].append(item->getUUID());
  3118. }
  3119. }
  3120. LLNotification::Params params("ChangeLindenAccess");
  3121. params.payload(payload).functor(accessRemoveCore2);
  3122. if (LLPanelEstateInfo::isLindenEstate())
  3123. {
  3124. // Warn on change linden estate
  3125. gNotifications.add(params);
  3126. }
  3127. else
  3128. {
  3129. // Just proceed, as if clicking OK
  3130. gNotifications.forceResponse(params, 0);
  3131. }
  3132. }
  3133. //static
  3134. bool LLPanelEstateAccess::accessRemoveCore2(const LLSD& notification,
  3135. const LLSD& response)
  3136. {
  3137. if (LLNotification::getSelectedOption(notification, response))
  3138. {
  3139. return false;
  3140. }
  3141. // If Linden estate, can only apply to "this" estate, not all estates
  3142. // owned by NULL.
  3143. if (LLPanelEstateInfo::isLindenEstate())
  3144. {
  3145. accessCoreConfirm(notification, response);
  3146. }
  3147. else
  3148. {
  3149. LLSD args;
  3150. args["ALL_ESTATES"] = allEstatesText();
  3151. gNotifications.add(notification["payload"]["dialog_name"], args,
  3152. notification["payload"], accessCoreConfirm);
  3153. }
  3154. return false;
  3155. }
  3156. // Used for both access add and remove operations, depending on the
  3157. // mOperationFlag passed in (ESTATE_ACCESS_BANNED_AGENT_ADD,
  3158. // ESTATE_ACCESS_ALLOWED_AGENT_REMOVE, etc.)
  3159. //static
  3160. bool LLPanelEstateAccess::accessCoreConfirm(const LLSD& notification,
  3161. const LLSD& response)
  3162. {
  3163. LLPanelEstateAccess* self = LLFloaterRegionInfo::getPanelAccess();
  3164. LLViewerRegion* region = gAgent.getRegion();
  3165. if (!self || !region || !gCacheNamep) return false;
  3166. S32 option = LLNotification::getSelectedOption(notification, response);
  3167. if (option == 2) // Cancel button
  3168. {
  3169. return false;
  3170. }
  3171. const LLSD& payload = notification["payload"];
  3172. const U32 orig_flags = (U32)payload["operation"].asInteger();
  3173. U32 flags = orig_flags;
  3174. if (option == 1)
  3175. {
  3176. // All estates, either than I own or manage for this owner; this will
  3177. // be verified on simulator. JC
  3178. if (region->getOwner() == gAgentID || gAgent.isGodlike())
  3179. {
  3180. flags |= ESTATE_ACCESS_APPLY_TO_ALL_ESTATES;
  3181. }
  3182. else if (region->isEstateManager())
  3183. {
  3184. flags |= ESTATE_ACCESS_APPLY_TO_MANAGED_ESTATES;
  3185. }
  3186. }
  3187. std::string names, fullname;
  3188. U32 listed_names = 0;
  3189. const LLSD& allowed_ids = payload["allowed_ids"];
  3190. for (U32 i = 0, count = allowed_ids.size(); i < count; ++i)
  3191. {
  3192. if (i != count - 1)
  3193. {
  3194. flags |= ESTATE_ACCESS_NO_REPLY;
  3195. }
  3196. else
  3197. {
  3198. flags &= ~ESTATE_ACCESS_NO_REPLY;
  3199. }
  3200. const LLUUID id = allowed_ids[i].asUUID();
  3201. if ((orig_flags & ESTATE_ACCESS_BANNED_AGENT_ADD) &&
  3202. region->getOwner() == id)
  3203. {
  3204. gNotifications.add("OwnerCanNotBeDenied");
  3205. break;
  3206. }
  3207. sendEstateAccessDelta(flags, id);
  3208. if ((flags & (ESTATE_ACCESS_ALLOWED_GROUP_ADD |
  3209. ESTATE_ACCESS_ALLOWED_GROUP_REMOVE)) == 0)
  3210. {
  3211. // Fill the name list for confirmation
  3212. if (listed_names < MAX_LISTED_NAMES)
  3213. {
  3214. if (!names.empty())
  3215. {
  3216. names += ", ";
  3217. }
  3218. gCacheNamep->getFullName(id, fullname);
  3219. names += fullname;
  3220. }
  3221. ++listed_names;
  3222. }
  3223. }
  3224. if (listed_names > MAX_LISTED_NAMES)
  3225. {
  3226. LLStringUtil::format_map_t args;
  3227. args["EXTRA_COUNT"] = llformat("%d", listed_names - MAX_LISTED_NAMES);
  3228. names += " " + self->getString("AndNMore", args);
  3229. }
  3230. if (!names.empty())
  3231. {
  3232. // Show the confirmation
  3233. LLSD args;
  3234. args["AGENT"] = names;
  3235. if (flags & (ESTATE_ACCESS_ALLOWED_AGENT_ADD |
  3236. ESTATE_ACCESS_ALLOWED_AGENT_REMOVE))
  3237. {
  3238. args["LIST_TYPE"] =
  3239. self->getString("RegionInfoListTypeAllowedAgents");
  3240. }
  3241. else if (flags & (ESTATE_ACCESS_BANNED_AGENT_ADD |
  3242. ESTATE_ACCESS_BANNED_AGENT_REMOVE))
  3243. {
  3244. args["LIST_TYPE"] =
  3245. self->getString("RegionInfoListTypeBannedAgents");
  3246. }
  3247. if (flags & ESTATE_ACCESS_APPLY_TO_ALL_ESTATES)
  3248. {
  3249. args["ESTATE"] = self->getString("RegionInfoAllEstates");
  3250. }
  3251. else if (flags & ESTATE_ACCESS_APPLY_TO_MANAGED_ESTATES)
  3252. {
  3253. args["ESTATE"] = self->getString("RegionInfoManagedEstates");
  3254. }
  3255. else
  3256. {
  3257. args["ESTATE"] = self->getString("RegionInfoThisEstate");
  3258. }
  3259. std::string dialog;
  3260. if (flags & (ESTATE_ACCESS_ALLOWED_AGENT_ADD |
  3261. ESTATE_ACCESS_BANNED_AGENT_ADD))
  3262. {
  3263. dialog = listed_names == 1 ? "AgentWasAddedToList"
  3264. : "AgentsWereAddedToList";
  3265. }
  3266. else if (flags & (ESTATE_ACCESS_ALLOWED_AGENT_REMOVE |
  3267. ESTATE_ACCESS_BANNED_AGENT_REMOVE))
  3268. {
  3269. dialog = listed_names == 1 ? "AgentWasRemovedFromList"
  3270. : "AgentsWereRemovedFromList";
  3271. }
  3272. if (!dialog.empty())
  3273. {
  3274. gNotifications.add(dialog, args);
  3275. }
  3276. }
  3277. self->setPendingUpdate(true);
  3278. return false;
  3279. }
  3280. // key = "estateaccessdelta"
  3281. // str(estate_id) will be added to front of list by
  3282. // forward_EstateOwnerRequest_to_dataserver
  3283. // str[0] = str(agent_id) requesting the change
  3284. // str[1] = str(flags) (ESTATE_ACCESS_DELTA_*)
  3285. // str[2] = str(agent_id) to add or remove
  3286. //static
  3287. void LLPanelEstateAccess::sendEstateAccessDelta(U32 flags, const LLUUID& id)
  3288. {
  3289. LLMessageSystem* msg = gMessageSystemp;
  3290. if (!msg) return;
  3291. msg->newMessage(_PREHASH_EstateOwnerMessage);
  3292. msg->nextBlockFast(_PREHASH_AgentData);
  3293. msg->addUUIDFast(_PREHASH_AgentID, gAgentID);
  3294. msg->addUUIDFast(_PREHASH_SessionID, gAgentSessionID);
  3295. msg->addUUIDFast(_PREHASH_TransactionID, LLUUID::null); // not used
  3296. msg->nextBlock(_PREHASH_MethodData);
  3297. msg->addString(_PREHASH_Method, "estateaccessdelta");
  3298. msg->addUUID(_PREHASH_Invoice, LLFloaterRegionInfo::getLastInvoice());
  3299. std::string buf;
  3300. gAgentID.toString(buf);
  3301. msg->nextBlock(_PREHASH_ParamList);
  3302. msg->addString(_PREHASH_Parameter, buf);
  3303. buf = llformat("%u", flags);
  3304. msg->nextBlock(_PREHASH_ParamList);
  3305. msg->addString(_PREHASH_Parameter, buf);
  3306. id.toString(buf);
  3307. msg->nextBlock(_PREHASH_ParamList);
  3308. msg->addString(_PREHASH_Parameter, buf);
  3309. gAgent.sendReliableMessage();
  3310. // This was part of the old pre-capability code, so do it when the
  3311. // capability is not in use; the deleteAllItems() are disabled in the
  3312. // LLDispatchSetEstateAccess() code for the capability-less case (likely
  3313. // because we could receive several UDP packets, each contaning a part of
  3314. // the full list), so we need to deleteAllItems() here instead... HB.
  3315. if ((flags & (ESTATE_ACCESS_ALLOWED_AGENT_ADD |
  3316. ESTATE_ACCESS_ALLOWED_AGENT_REMOVE |
  3317. ESTATE_ACCESS_BANNED_AGENT_ADD |
  3318. ESTATE_ACCESS_BANNED_AGENT_REMOVE)) &&
  3319. !gAgent.hasRegionCapability("EstateAccess"))
  3320. {
  3321. LLPanelEstateAccess* self = LLFloaterRegionInfo::getPanelAccess();
  3322. if (self)
  3323. {
  3324. self->mAllowedAvatars->deleteAllItems();
  3325. self->mBannedAvatars->deleteAllItems();
  3326. }
  3327. }
  3328. }
  3329. void LLPanelEstateAccess::updateControls()
  3330. {
  3331. bool god_or_owner = mOwner || gAgent.isGodlike();
  3332. bool can_control = god_or_owner || mEstateManager;
  3333. LL_DEBUGS("RegionInfo") << " - god_or_owner = "
  3334. << (god_or_owner ? "true" : "false")
  3335. << " - can_control = "
  3336. << (can_control ? "true" : "false") << LL_ENDL;
  3337. setCtrlsEnabled(can_control);
  3338. childSetEnabled("add_allowed_group_btn", can_control);
  3339. childSetEnabled("remove_allowed_group_btn",
  3340. can_control && mAllowedGroups->getFirstSelected());
  3341. childSetEnabled("add_allowed_avatar_btn", can_control);
  3342. childSetEnabled("remove_allowed_avatar_btn",
  3343. can_control && mAllowedAvatars->getFirstSelected());
  3344. childSetEnabled("add_banned_avatar_btn", can_control);
  3345. childSetEnabled("remove_banned_avatar_btn",
  3346. can_control && mBannedAvatars->getFirstSelected());
  3347. // Estate managers cannot add estate managers
  3348. childSetEnabled("add_estate_manager_btn", god_or_owner);
  3349. childSetEnabled("remove_estate_manager_btn",
  3350. god_or_owner && mEstateManagers->getFirstSelected());
  3351. childSetEnabled("estate_manager_name_list", god_or_owner);
  3352. if (mCtrlsEnabled != can_control)
  3353. {
  3354. mCtrlsEnabled = can_control;
  3355. // Update the lists on the agent's access level change
  3356. updateLists();
  3357. }
  3358. }
  3359. void LLPanelEstateAccess::setAccessAllowedEnabled(bool enable_agent,
  3360. bool enable_group,
  3361. bool enable_ban)
  3362. {
  3363. LL_DEBUGS("RegionInfo") << "enable_agent = "
  3364. << (enable_agent ? "true" : "false")
  3365. << " - enable_group = "
  3366. << (enable_group ? "true" : "false")
  3367. << " - enable_ban = "
  3368. << (enable_ban ? "true" : "false") << LL_ENDL;
  3369. childSetEnabled("allow_group_label", enable_group);
  3370. childSetEnabled("add_allowed_group_btn", enable_group);
  3371. childSetEnabled("remove_allowed_group_btn", enable_group);
  3372. mAllowedGroups->setEnabled(enable_group);
  3373. childSetEnabled("allow_resident_label", enable_agent);
  3374. childSetEnabled("add_allowed_avatar_btn", enable_agent);
  3375. childSetEnabled("remove_allowed_avatar_btn", enable_agent);
  3376. mAllowedAvatars->setEnabled(enable_agent);
  3377. childSetEnabled("ban_resident_label", enable_ban);
  3378. childSetEnabled("add_banned_avatar_btn", enable_ban);
  3379. childSetEnabled("remove_banned_avatar_btn", enable_ban);
  3380. mBannedAvatars->setEnabled(enable_ban);
  3381. // Update removal buttons if needed
  3382. if (enable_group)
  3383. {
  3384. checkRemovalButton("allowed_group_name_list");
  3385. }
  3386. if (enable_agent)
  3387. {
  3388. checkRemovalButton("allowed_avatar_name_list");
  3389. }
  3390. if (enable_ban)
  3391. {
  3392. checkRemovalButton("banned_avatar_name_list");
  3393. }
  3394. }
  3395. // Enables/disables the "remove" button for the various allow/ban lists
  3396. bool LLPanelEstateAccess::checkRemovalButton(std::string name)
  3397. {
  3398. std::string btn_name;
  3399. if (name == "allowed_avatar_name_list")
  3400. {
  3401. btn_name = "remove_allowed_avatar_btn";
  3402. }
  3403. else if (name == "allowed_group_name_list")
  3404. {
  3405. btn_name = "remove_allowed_group_btn";
  3406. }
  3407. else if (name == "banned_avatar_name_list")
  3408. {
  3409. btn_name = "remove_banned_avatar_btn";
  3410. }
  3411. else if (name == "estate_manager_name_list")
  3412. {
  3413. // ONLY OWNER CAN ADD / DELETE ESTATE MANAGER
  3414. LLViewerRegion* region = gAgent.getRegion();
  3415. if (region && region->getOwner() == gAgentID)
  3416. {
  3417. btn_name = "remove_estate_manager_btn";
  3418. }
  3419. }
  3420. // Enable the remove button if something is selected
  3421. LLNameListCtrl* name_list = getChild<LLNameListCtrl>(name.c_str(),
  3422. true, false);
  3423. if (name_list && !btn_name.empty())
  3424. {
  3425. childSetEnabled(btn_name.c_str(),
  3426. name_list->getFirstSelected() != NULL);
  3427. }
  3428. return !btn_name.empty();
  3429. }
  3430. ///////////////////////////////////////////////////////////////////////////////
  3431. // LLPanelEstateCovenant
  3432. ///////////////////////////////////////////////////////////////////////////////
  3433. LLPanelEstateCovenant::LLPanelEstateCovenant()
  3434. : LLPanelRegionInfo(),
  3435. mCovenantID(LLUUID::null)
  3436. {
  3437. }
  3438. //virtual
  3439. bool LLPanelEstateCovenant::postBuild()
  3440. {
  3441. initHelpBtn("covenant_help", "HelpEstateCovenant");
  3442. mEstateNameText = getChild<LLTextBox>("estate_name_text");
  3443. mEstateOwnerText = getChild<LLTextBox>("estate_owner_text");
  3444. mLastModifiedText = getChild<LLTextBox>("covenant_timestamp_text");
  3445. mEditor = getChild<LLViewerTextEditor>("covenant_editor");
  3446. mEditor->setHandleEditKeysDirectly(true);
  3447. LLButton* reset_button = getChild<LLButton>("reset_covenant");
  3448. reset_button->setEnabled(gAgent.canManageEstate());
  3449. reset_button->setClickedCallback(resetCovenantID, this);
  3450. return LLPanelRegionInfo::postBuild();
  3451. }
  3452. //virtual
  3453. bool LLPanelEstateCovenant::refreshFromRegion(LLViewerRegion* regionp)
  3454. {
  3455. if (!LLPanelRegionInfo::refreshFromRegion(regionp))
  3456. {
  3457. return false;
  3458. }
  3459. LLTextBox* textp = getChild<LLTextBox>("region_name_text", true, false);
  3460. if (textp)
  3461. {
  3462. textp->setText(regionp->getName());
  3463. }
  3464. textp = getChild<LLTextBox>("resellable_clause", true, false);
  3465. if (textp)
  3466. {
  3467. if (regionp->getRegionFlag(REGION_FLAGS_BLOCK_LAND_RESELL))
  3468. {
  3469. textp->setText(getString("can_not_resell"));
  3470. }
  3471. else
  3472. {
  3473. textp->setText(getString("can_resell"));
  3474. }
  3475. }
  3476. textp = getChild<LLTextBox>("changeable_clause", true, false);
  3477. if (textp)
  3478. {
  3479. if (regionp->getRegionFlag(REGION_FLAGS_ALLOW_PARCEL_CHANGES))
  3480. {
  3481. textp->setText(getString("can_change"));
  3482. }
  3483. else
  3484. {
  3485. textp->setText(getString("can_not_change"));
  3486. }
  3487. }
  3488. textp = getChild<LLTextBox>("region_maturity_text", true, false);
  3489. if (textp)
  3490. {
  3491. textp->setText(regionp->getSimAccessString());
  3492. }
  3493. textp = getChild<LLTextBox>("region_landtype_text", true, false);
  3494. if (textp)
  3495. {
  3496. textp->setText(regionp->getSimProductName());
  3497. }
  3498. regionp->sendEstateCovenantRequest();
  3499. return true;
  3500. }
  3501. //virtual
  3502. bool LLPanelEstateCovenant::estateUpdate(LLMessageSystem* msg)
  3503. {
  3504. llinfos << "No operation..." << llendl;
  3505. return true;
  3506. }
  3507. //virtual
  3508. bool LLPanelEstateCovenant::handleDragAndDrop(S32 x, S32 y, MASK mask,
  3509. bool drop,
  3510. EDragAndDropType cargo_type,
  3511. void* cargo_data,
  3512. EAcceptance* accept,
  3513. std::string& tooltip_msg)
  3514. {
  3515. if (!gAgent.canManageEstate())
  3516. {
  3517. *accept = ACCEPT_NO;
  3518. return true;
  3519. }
  3520. if (cargo_type == DAD_NOTECARD)
  3521. {
  3522. *accept = ACCEPT_YES_COPY_SINGLE;
  3523. LLInventoryItem* item = (LLInventoryItem*)cargo_data;
  3524. if (item && drop)
  3525. {
  3526. LLSD payload;
  3527. payload["item_id"] = item->getUUID();
  3528. gNotifications.add("EstateChangeCovenant", LLSD(), payload,
  3529. confirmChangeCovenantCallback);
  3530. }
  3531. }
  3532. else
  3533. {
  3534. *accept = ACCEPT_NO;
  3535. }
  3536. return true;
  3537. }
  3538. //static
  3539. bool LLPanelEstateCovenant::confirmChangeCovenantCallback(const LLSD& notification,
  3540. const LLSD& response)
  3541. {
  3542. S32 option = LLNotification::getSelectedOption(notification, response);
  3543. LLInventoryItem* item = gInventory.getItem(notification["payload"]["item_id"].asUUID());
  3544. LLPanelEstateCovenant* self = LLFloaterRegionInfo::getPanelCovenant();
  3545. if (!item || !self) return false;
  3546. if (option == 0)
  3547. {
  3548. self->loadInvItem(item);
  3549. }
  3550. return false;
  3551. }
  3552. //static
  3553. void LLPanelEstateCovenant::resetCovenantID(void*)
  3554. {
  3555. gNotifications.add("EstateChangeCovenant", LLSD(), LLSD(),
  3556. confirmResetCovenantCallback);
  3557. }
  3558. //static
  3559. bool LLPanelEstateCovenant::confirmResetCovenantCallback(const LLSD& notification,
  3560. const LLSD& response)
  3561. {
  3562. LLPanelEstateCovenant* self = LLFloaterRegionInfo::getPanelCovenant();
  3563. if (!self) return false;
  3564. S32 option = LLNotification::getSelectedOption(notification, response);
  3565. if (option == 0)
  3566. {
  3567. self->loadInvItem(NULL);
  3568. }
  3569. return false;
  3570. }
  3571. void LLPanelEstateCovenant::loadInvItem(LLInventoryItem* itemp)
  3572. {
  3573. if (!gAssetStoragep)
  3574. {
  3575. llwarns << "No valid asset storage. Aborted." << llendl;
  3576. return;
  3577. }
  3578. if (itemp)
  3579. {
  3580. gAssetStoragep->getInvItemAsset(gAgent.getRegionHost(),
  3581. gAgentID, gAgentSessionID,
  3582. itemp->getPermissions().getOwner(),
  3583. LLUUID::null, itemp->getUUID(),
  3584. itemp->getAssetUUID(),
  3585. itemp->getType(), onLoadComplete,
  3586. (void*)this, true); // high priority
  3587. mAssetStatus = ASSET_LOADING;
  3588. }
  3589. else
  3590. {
  3591. mAssetStatus = ASSET_LOADED;
  3592. setCovenantTextEditor("There is no Covenant provided for this Estate.");
  3593. sendChangeCovenantID(LLUUID::null);
  3594. }
  3595. }
  3596. //static
  3597. void LLPanelEstateCovenant::onLoadComplete(const LLUUID& asset_id,
  3598. LLAssetType::EType type,
  3599. void* user_data,
  3600. S32 status, LLExtStat)
  3601. {
  3602. LLPanelEstateCovenant* panelp = (LLPanelEstateCovenant*)user_data;
  3603. if (panelp)
  3604. {
  3605. if (0 == status)
  3606. {
  3607. LLFileSystem file(asset_id);
  3608. S32 file_length = file.getSize();
  3609. char* buffer = new char[file_length+1];
  3610. if (!buffer)
  3611. {
  3612. llerrs << "Memory Allocation Failed" << llendl;
  3613. return;
  3614. }
  3615. file.read((U8*)buffer, file_length);
  3616. // put a EOS at the end
  3617. buffer[file_length] = 0;
  3618. if (file_length > 19 && !strncmp(buffer, "Linden text version", 19))
  3619. {
  3620. if (!panelp->mEditor->importBuffer(buffer, file_length + 1))
  3621. {
  3622. llwarns << "Problem importing estate covenant." << llendl;
  3623. gNotifications.add("ProblemImportingEstateCovenant");
  3624. }
  3625. else
  3626. {
  3627. panelp->sendChangeCovenantID(asset_id);
  3628. }
  3629. }
  3630. else
  3631. {
  3632. // Version 0 (just text, doesn't include version number)
  3633. panelp->sendChangeCovenantID(asset_id);
  3634. }
  3635. delete[] buffer;
  3636. }
  3637. else
  3638. {
  3639. gViewerStats.incStat(LLViewerStats::ST_DOWNLOAD_FAILED);
  3640. if (LL_ERR_ASSET_REQUEST_NOT_IN_DATABASE == status ||
  3641. LL_ERR_FILE_EMPTY == status)
  3642. {
  3643. gNotifications.add("MissingNotecardAssetID");
  3644. }
  3645. else if (LL_ERR_INSUFFICIENT_PERMISSIONS == status)
  3646. {
  3647. gNotifications.add("NotAllowedToViewNotecard");
  3648. }
  3649. else
  3650. {
  3651. gNotifications.add("UnableToLoadNotecardAsset");
  3652. }
  3653. llwarns << "Problem loading notecard: " << status << llendl;
  3654. }
  3655. panelp->mAssetStatus = ASSET_LOADED;
  3656. panelp->setCovenantID(asset_id);
  3657. }
  3658. }
  3659. // key = "estatechangecovenantid"
  3660. // strings[0] = str(estate_id) (added by simulator before relay - not here)
  3661. // strings[1] = str(covenant_id)
  3662. void LLPanelEstateCovenant::sendChangeCovenantID(const LLUUID& asset_id)
  3663. {
  3664. if (asset_id != getCovenantID())
  3665. {
  3666. setCovenantID(asset_id);
  3667. LLMessageSystem* msg = gMessageSystemp;
  3668. msg->newMessage(_PREHASH_EstateOwnerMessage);
  3669. msg->nextBlockFast(_PREHASH_AgentData);
  3670. msg->addUUIDFast(_PREHASH_AgentID, gAgentID);
  3671. msg->addUUIDFast(_PREHASH_SessionID, gAgentSessionID);
  3672. msg->addUUIDFast(_PREHASH_TransactionID, LLUUID::null); // Not used
  3673. msg->nextBlock(_PREHASH_MethodData);
  3674. msg->addString(_PREHASH_Method, "estatechangecovenantid");
  3675. msg->addUUID(_PREHASH_Invoice, LLFloaterRegionInfo::getLastInvoice());
  3676. msg->nextBlock(_PREHASH_ParamList);
  3677. msg->addString(_PREHASH_Parameter, getCovenantID().asString());
  3678. gAgent.sendReliableMessage();
  3679. }
  3680. }
  3681. //virtual
  3682. bool LLPanelEstateCovenant::sendUpdate()
  3683. {
  3684. return true;
  3685. }
  3686. const std::string& LLPanelEstateCovenant::getEstateName() const
  3687. {
  3688. return mEstateNameText->getText();
  3689. }
  3690. void LLPanelEstateCovenant::setEstateName(const std::string& name)
  3691. {
  3692. mEstateNameText->setText(name);
  3693. }
  3694. //static
  3695. void LLPanelEstateCovenant::updateCovenantText(const std::string& string,
  3696. const LLUUID& asset_id)
  3697. {
  3698. LLPanelEstateCovenant* panelp = LLFloaterRegionInfo::getPanelCovenant();
  3699. if (panelp)
  3700. {
  3701. panelp->mEditor->setText(string);
  3702. panelp->setCovenantID(asset_id);
  3703. }
  3704. }
  3705. //static
  3706. void LLPanelEstateCovenant::updateEstateName(const std::string& name)
  3707. {
  3708. LLPanelEstateCovenant* panelp = LLFloaterRegionInfo::getPanelCovenant();
  3709. if (panelp)
  3710. {
  3711. panelp->mEstateNameText->setText(name);
  3712. }
  3713. }
  3714. //static
  3715. void LLPanelEstateCovenant::updateLastModified(const std::string& text)
  3716. {
  3717. LLPanelEstateCovenant* panelp = LLFloaterRegionInfo::getPanelCovenant();
  3718. if (panelp)
  3719. {
  3720. panelp->mLastModifiedText->setText(text);
  3721. }
  3722. }
  3723. //static
  3724. void LLPanelEstateCovenant::updateEstateOwnerName(const std::string& name)
  3725. {
  3726. LLPanelEstateCovenant* panelp = LLFloaterRegionInfo::getPanelCovenant();
  3727. if (panelp)
  3728. {
  3729. panelp->mEstateOwnerText->setText(name);
  3730. }
  3731. }
  3732. const std::string& LLPanelEstateCovenant::getOwnerName() const
  3733. {
  3734. return mEstateOwnerText->getText();
  3735. }
  3736. void LLPanelEstateCovenant::setOwnerName(const std::string& name)
  3737. {
  3738. mEstateOwnerText->setText(name);
  3739. }
  3740. void LLPanelEstateCovenant::setCovenantTextEditor(const std::string& text)
  3741. {
  3742. mEditor->setText(text);
  3743. }
  3744. ///////////////////////////////////////////////////////////////////////////////
  3745. // LLPanelRegionExperiences
  3746. ///////////////////////////////////////////////////////////////////////////////
  3747. // static
  3748. void* LLPanelRegionExperiences::createAllowedExperiencesPanel(void* data)
  3749. {
  3750. LLPanelRegionExperiences* self = (LLPanelRegionExperiences*)data;
  3751. self->mAllowed = new LLPanelExperienceListEditor();
  3752. return self->mAllowed;
  3753. }
  3754. // static
  3755. void* LLPanelRegionExperiences::createTrustedExperiencesPanel(void* data)
  3756. {
  3757. LLPanelRegionExperiences* self = (LLPanelRegionExperiences*)data;
  3758. self->mTrusted = new LLPanelExperienceListEditor();
  3759. return self->mTrusted;
  3760. }
  3761. // static
  3762. void* LLPanelRegionExperiences::createBlockedExperiencesPanel(void* data)
  3763. {
  3764. LLPanelRegionExperiences* self = (LLPanelRegionExperiences*)data;
  3765. self->mBlocked = new LLPanelExperienceListEditor();
  3766. return self->mBlocked;
  3767. }
  3768. LLPanelRegionExperiences::LLPanelRegionExperiences()
  3769. : LLPanelRegionInfo()
  3770. {
  3771. LLCallbackMap::map_t factory_map;
  3772. factory_map["panel_allowed"] = LLCallbackMap(createAllowedExperiencesPanel,
  3773. this);
  3774. factory_map["panel_trusted"] = LLCallbackMap(createTrustedExperiencesPanel,
  3775. this);
  3776. factory_map["panel_blocked"] = LLCallbackMap(createBlockedExperiencesPanel,
  3777. this);
  3778. LLUICtrlFactory::getInstance()->buildPanel(this,
  3779. "panel_region_experiences.xml",
  3780. &factory_map);
  3781. }
  3782. bool LLPanelRegionExperiences::postBuild()
  3783. {
  3784. if (!mAllowed || !mTrusted || !mBlocked) return false;
  3785. setupList(mAllowed, "panel_allowed",
  3786. ESTATE_EXPERIENCE_ALLOWED_ADD, ESTATE_EXPERIENCE_ALLOWED_REMOVE);
  3787. setupList(mTrusted, "panel_trusted",
  3788. ESTATE_EXPERIENCE_TRUSTED_ADD, ESTATE_EXPERIENCE_TRUSTED_REMOVE);
  3789. setupList(mBlocked, "panel_blocked",
  3790. ESTATE_EXPERIENCE_BLOCKED_ADD, ESTATE_EXPERIENCE_BLOCKED_REMOVE);
  3791. getChild<LLPanel>("help_text_layout_panel")->setVisible(true);
  3792. getChild<LLPanel>("trusted_layout_panel")->setVisible(true);
  3793. mTrusted->getChild<LLTextBox>("text_name")->setToolTip(getString("trusted_estate_text"));
  3794. mAllowed->getChild<LLTextBox>("text_name")->setToolTip(getString("allowed_estate_text"));
  3795. mBlocked->getChild<LLTextBox>("text_name")->setToolTip(getString("blocked_estate_text"));
  3796. // Note: no apply button, so we do not call LLPanelRegionInfo::postBuild()
  3797. return true;
  3798. }
  3799. void LLPanelRegionExperiences::setupList(LLPanelExperienceListEditor* panel,
  3800. const std::string& control_name,
  3801. U32 add_id, U32 remove_id)
  3802. {
  3803. if (!panel) return;
  3804. panel->getChild<LLTextBox>("text_name")->setText(panel->getString(control_name));
  3805. panel->setMaxExperienceIDs(ESTATE_MAX_EXPERIENCE_IDS);
  3806. panel->setAddedCallback(boost::bind(&LLPanelRegionExperiences::itemChanged,
  3807. this, add_id, _1));
  3808. panel->setRemovedCallback(boost::bind(&LLPanelRegionExperiences::itemChanged,
  3809. this, remove_id, _1));
  3810. }
  3811. void LLPanelRegionExperiences::processResponse(const LLSD& content)
  3812. {
  3813. if (content.has("default"))
  3814. {
  3815. mDefaultExperience = content["default"].asUUID();
  3816. }
  3817. mAllowed->setExperienceIds(content["allowed"]);
  3818. mBlocked->setExperienceIds(content["blocked"]);
  3819. LLSD trusted = content["trusted"];
  3820. if (mDefaultExperience.notNull())
  3821. {
  3822. mTrusted->setStickyFunction(boost::bind(LLExperienceCache::FilterMatching,
  3823. _1, mDefaultExperience));
  3824. trusted.append(mDefaultExperience);
  3825. }
  3826. mTrusted->setExperienceIds(trusted);
  3827. mAllowed->refreshExperienceCounter();
  3828. mBlocked->refreshExperienceCounter();
  3829. mTrusted->refreshExperienceCounter();
  3830. }
  3831. // Used for both access add and remove operations, depending on the flag passed
  3832. // in (ESTATE_EXPERIENCE_ALLOWED_ADD, ESTATE_EXPERIENCE_ALLOWED_REMOVE, etc.)
  3833. //static
  3834. bool LLPanelRegionExperiences::experienceCoreConfirm(const LLSD& notification,
  3835. const LLSD& response)
  3836. {
  3837. S32 option = LLNotification::getSelectedOption(notification, response);
  3838. const U32 orig_flags = (U32)notification["payload"]["operation"].asInteger();
  3839. LLViewerRegion* region = gAgent.getRegion();
  3840. for (LLSD::array_const_iterator
  3841. iter = notification["payload"]["allowed_ids"].beginArray(),
  3842. end_it = notification["payload"]["allowed_ids"].endArray();
  3843. iter != end_it; ++iter)
  3844. {
  3845. U32 flags = orig_flags;
  3846. if (iter + 1 != end_it)
  3847. {
  3848. flags |= ESTATE_ACCESS_NO_REPLY;
  3849. }
  3850. const LLUUID id = iter->asUUID();
  3851. switch (option)
  3852. {
  3853. case 0:
  3854. // This estate
  3855. sendEstateExperienceDelta(flags, id);
  3856. break;
  3857. case 1:
  3858. {
  3859. // All estates, either than I own or manage for this owner.
  3860. // This will be verified on simulator. JC
  3861. if (!region) break;
  3862. if (region->getOwner() == gAgentID || gAgent.isGodlike())
  3863. {
  3864. flags |= ESTATE_ACCESS_APPLY_TO_ALL_ESTATES;
  3865. sendEstateExperienceDelta(flags, id);
  3866. }
  3867. else if (region->isEstateManager())
  3868. {
  3869. flags |= ESTATE_ACCESS_APPLY_TO_MANAGED_ESTATES;
  3870. sendEstateExperienceDelta(flags, id);
  3871. }
  3872. break;
  3873. }
  3874. default:
  3875. break;
  3876. }
  3877. }
  3878. return false;
  3879. }
  3880. // Send the actual "estateexperiencedelta" message
  3881. void LLPanelRegionExperiences::sendEstateExperienceDelta(U32 flags,
  3882. const LLUUID& experience_id)
  3883. {
  3884. LLPanelRegionExperiences* panel =
  3885. LLFloaterRegionInfo::getPanelExperiences();
  3886. if (panel)
  3887. {
  3888. strings_t str(3, std::string());
  3889. gAgentID.toString(str[0]);
  3890. str[1] = llformat("%u", flags);
  3891. experience_id.toString(str[2]);
  3892. panel->sendEstateOwnerMessage("estateexperiencedelta", str);
  3893. }
  3894. }
  3895. void LLPanelRegionExperiences::infoCallback(LLHandle<LLPanelRegionExperiences> handle,
  3896. const LLSD& content)
  3897. {
  3898. if (handle.isDead()) return;
  3899. LLPanelRegionExperiences* floater = handle.get();
  3900. if (floater)
  3901. {
  3902. floater->processResponse(content);
  3903. }
  3904. }
  3905. //static
  3906. const std::string& LLPanelRegionExperiences::regionCapabilityQuery(LLViewerRegion* region,
  3907. const char* cap)
  3908. {
  3909. return region ? region->getCapability(cap) : LLStringUtil::null;
  3910. }
  3911. //virtual
  3912. bool LLPanelRegionExperiences::refreshFromRegion(LLViewerRegion* regionp)
  3913. {
  3914. if (!LLPanelRegionInfo::refreshFromRegion(regionp))
  3915. {
  3916. return false;
  3917. }
  3918. bool allow_modify = mCanManage || gAgent.isGodlike();
  3919. mAllowed->setDisabled(false);
  3920. mAllowed->setReadonly(!allow_modify);
  3921. mAllowed->loading();
  3922. // Remove grid-wide experiences
  3923. mAllowed->addFilter(boost::bind(LLExperienceCache::FilterWithProperty,
  3924. _1, LLExperienceCache::PROPERTY_GRID));
  3925. // Remove default experience
  3926. mAllowed->addFilter(boost::bind(LLExperienceCache::FilterMatching,
  3927. _1, mDefaultExperience));
  3928. mBlocked->setDisabled(false);
  3929. mBlocked->setReadonly(!allow_modify);
  3930. mBlocked->loading();
  3931. // Only grid-wide experiences
  3932. mBlocked->addFilter(boost::bind(LLExperienceCache::FilterWithoutProperty,
  3933. _1, LLExperienceCache::PROPERTY_GRID));
  3934. // But not privileged ones
  3935. mBlocked->addFilter(boost::bind(LLExperienceCache::FilterWithProperty,
  3936. _1, LLExperienceCache::PROPERTY_PRIVILEGED));
  3937. // Remove default experience
  3938. mBlocked->addFilter(boost::bind(LLExperienceCache::FilterMatching,
  3939. _1, mDefaultExperience));
  3940. mTrusted->setDisabled(false);
  3941. mTrusted->setReadonly(!allow_modify);
  3942. mTrusted->loading();
  3943. LLExperienceCache* exp = LLExperienceCache::getInstance();
  3944. exp->getRegionExperiences(boost::bind(&LLPanelRegionExperiences::regionCapabilityQuery,
  3945. regionp, _1),
  3946. boost::bind(&LLPanelRegionExperiences::infoCallback,
  3947. getDerivedHandle<LLPanelRegionExperiences>(),
  3948. _1));
  3949. return true;
  3950. }
  3951. LLSD LLPanelRegionExperiences::addIds(LLPanelExperienceListEditor* panelp)
  3952. {
  3953. LLSD ids;
  3954. const uuid_list_t& id_list = panelp->getExperienceIds();
  3955. for (uuid_list_t::const_iterator it = id_list.begin(),
  3956. end = id_list.end();
  3957. it != end; ++it)
  3958. {
  3959. ids.append(*it);
  3960. }
  3961. return ids;
  3962. }
  3963. bool LLPanelRegionExperiences::sendUpdate()
  3964. {
  3965. if (!gAgent.hasRegionCapability("RegionExperiences")) return false;
  3966. LLSD content;
  3967. content["allowed"] = addIds(mAllowed);
  3968. content["blocked"] = addIds(mBlocked);
  3969. content["trusted"] = addIds(mTrusted);
  3970. LLExperienceCache* exp = LLExperienceCache::getInstance();
  3971. exp->setRegionExperiences(boost::bind(&LLPanelRegionExperiences::regionCapabilityQuery,
  3972. gAgent.getRegion(), _1), content,
  3973. boost::bind(&LLPanelRegionExperiences::infoCallback,
  3974. getDerivedHandle<LLPanelRegionExperiences>(),
  3975. _1));
  3976. return true;
  3977. }
  3978. void LLPanelRegionExperiences::itemChanged(U32 event_type, const LLUUID& id)
  3979. {
  3980. std::string dialog_name;
  3981. switch (event_type)
  3982. {
  3983. case ESTATE_EXPERIENCE_ALLOWED_ADD:
  3984. dialog_name = "EstateAllowedExperienceAdd";
  3985. break;
  3986. case ESTATE_EXPERIENCE_ALLOWED_REMOVE:
  3987. dialog_name = "EstateAllowedExperienceRemove";
  3988. break;
  3989. case ESTATE_EXPERIENCE_TRUSTED_ADD:
  3990. dialog_name = "EstateTrustedExperienceAdd";
  3991. break;
  3992. case ESTATE_EXPERIENCE_TRUSTED_REMOVE:
  3993. dialog_name = "EstateTrustedExperienceRemove";
  3994. break;
  3995. case ESTATE_EXPERIENCE_BLOCKED_ADD:
  3996. dialog_name = "EstateBlockedExperienceAdd";
  3997. break;
  3998. case ESTATE_EXPERIENCE_BLOCKED_REMOVE:
  3999. dialog_name = "EstateBlockedExperienceRemove";
  4000. break;
  4001. default:
  4002. return;
  4003. }
  4004. LLSD payload;
  4005. payload["operation"] = (S32)event_type;
  4006. payload["dialog_name"] = dialog_name;
  4007. payload["allowed_ids"].append(id);
  4008. LLSD args;
  4009. args["ALL_ESTATES"] = LLPanelEstateAccess::allEstatesText();
  4010. LLNotification::Params p(dialog_name);
  4011. p.substitutions(args).payload(payload)
  4012. .functor(boost::bind(&LLPanelRegionExperiences::experienceCoreConfirm,
  4013. _1, _2));
  4014. if (LLPanelEstateInfo::isLindenEstate())
  4015. {
  4016. gNotifications.forceResponse(p, 0);
  4017. }
  4018. else
  4019. {
  4020. gNotifications.add(p);
  4021. }
  4022. onChangeAnything(NULL, this);
  4023. }