llfloaterregioninfo.h 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649
  1. /**
  2. * @file llfloaterregioninfo.h
  3. * @author Aaron Brashears
  4. * @brief Declaration 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. #ifndef LL_LLFLOATERREGIONINFO_H
  35. #define LL_LLFLOATERREGIONINFO_H
  36. #include "llextendedstatus.h"
  37. #include "hbfileselector.h"
  38. #include "llhost.h"
  39. #include "llregionflags.h"
  40. class LLButton;
  41. class LLDispatcher;
  42. class LLInventoryItem;
  43. class LLMessageSystem;
  44. class LLNameListCtrl;
  45. class LLPanelExperienceListEditor;
  46. class HBPanelLandEnvironment;
  47. class LLRadioGroup;
  48. class LLTabContainer;
  49. class LLTextBox;
  50. class LLTextureCtrl;
  51. class LLViewerRegion;
  52. class LLViewerTextEditor;
  53. class LLVLComposition;
  54. /////////////////////////////////////////////////////////////////////////////
  55. // Purely static class (a singleton in LL's viewer, but LL coders love to
  56. // complicate and slow down things for no reason)... It is used to store data
  57. // for the last estate info request and its member variables are filled up by
  58. // LLDispatchEstateUpdateInfo::operator(). HB
  59. class LLEstateInfoModel
  60. {
  61. LLEstateInfoModel() = delete;
  62. ~LLEstateInfoModel() = delete;
  63. public:
  64. LL_INLINE static bool getUseFixedSun()
  65. {
  66. return (sEstateFlags & REGION_FLAGS_SUN_FIXED) != 0;
  67. }
  68. LL_INLINE static bool getAllowEnvironmentOverride()
  69. {
  70. return (sEstateFlags & REGION_FLAGS_ALLOW_ENVIRONMENT_OVERRIDE) != 0;
  71. }
  72. LL_INLINE static void setAllowEnvironmentOverride(bool b)
  73. {
  74. setFlag(REGION_FLAGS_ALLOW_ENVIRONMENT_OVERRIDE, b);
  75. }
  76. LL_INLINE static bool getDenyScriptedAgents()
  77. {
  78. return (sEstateFlags & REGION_FLAGS_DENY_BOTS) != 0;
  79. }
  80. LL_INLINE static void setDenyScriptedAgents(bool b)
  81. {
  82. setFlag(REGION_FLAGS_DENY_BOTS, b);
  83. }
  84. LL_INLINE static void setFlag(U64 flag, bool b)
  85. {
  86. if (b)
  87. {
  88. sEstateFlags |= flag;
  89. }
  90. else
  91. {
  92. sEstateFlags &= ~flag;
  93. }
  94. }
  95. public:
  96. static U64 sEstateFlags;
  97. static U32 sEstateId;
  98. static F32 sSunHour;
  99. static std::string sEstateName;
  100. static LLUUID sOwnerId;
  101. };
  102. /////////////////////////////////////////////////////////////////////////////
  103. // Base class for all region information panels.
  104. /////////////////////////////////////////////////////////////////////////////
  105. class LLPanelRegionInfo : public LLPanel
  106. {
  107. protected:
  108. LOG_CLASS(LLPanelRegionInfo);
  109. public:
  110. LLPanelRegionInfo();
  111. virtual bool refreshFromRegion(LLViewerRegion* region);
  112. virtual bool estateUpdate(LLMessageSystem* msg) { return true; }
  113. bool postBuild() override;
  114. void enableApplyBtn(bool enable = true);
  115. void disableApplyBtn();
  116. protected:
  117. void initCtrl(const char* name);
  118. void initHelpBtn(const char*, const std::string& xml_alert);
  119. static void onBtnSet(void* user_data);
  120. static void onChangeAnything(LLUICtrl* ctrl, void* user_data);
  121. // Callback for all help buttons, data is name of XML alert to show.
  122. static void onClickHelp(void* data);
  123. // Returns true if update sent and apply button should be disabled.
  124. virtual bool sendUpdate() { return true; }
  125. typedef std::vector<std::string> strings_t;
  126. void sendEstateOwnerMessage(const std::string& request,
  127. const strings_t& strings);
  128. protected:
  129. LLVLComposition* mComposition;
  130. LLButton* mApplyBtn;
  131. LLHost mHost;
  132. bool mOwner;
  133. bool mCanManage;
  134. bool mEstateManager;
  135. };
  136. /////////////////////////////////////////////////////////////////////////////
  137. // Actual panels start here
  138. /////////////////////////////////////////////////////////////////////////////
  139. class LLPanelRegionGeneralInfo final : public LLPanelRegionInfo
  140. {
  141. protected:
  142. LOG_CLASS(LLPanelRegionGeneralInfo);
  143. public:
  144. bool refreshFromRegion(LLViewerRegion* region) override;
  145. bool postBuild() override;
  146. private:
  147. bool sendUpdate() override;
  148. static void onClickKick(void* userdata);
  149. static void onKickCommit(const std::vector<std::string>& names,
  150. const std::vector<LLUUID>& ids, void* userdata);
  151. static void onClickKickAll(void* userdata);
  152. bool onKickAllCommit(const LLSD& notification, const LLSD& response);
  153. static void onClickMessage(void* userdata);
  154. bool onMessageCommit(const LLSD& notification, const LLSD& response);
  155. static void onClickManageTelehub(void* data);
  156. };
  157. class LLPanelRegionDebugInfo final : public LLPanelRegionInfo
  158. {
  159. protected:
  160. LOG_CLASS(LLPanelRegionDebugInfo);
  161. public:
  162. bool postBuild() override;
  163. bool refreshFromRegion(LLViewerRegion* region) override;
  164. private:
  165. bool sendUpdate() override;
  166. static void onClickChooseAvatar(void*);
  167. static void callbackAvatarID(const std::vector<std::string>& names,
  168. const std::vector<LLUUID>& ids, void* data);
  169. static void onClickReturn(void *);
  170. bool callbackReturn(const LLSD& notification, const LLSD& response);
  171. static void onClickTopColliders(void*);
  172. static void onClickTopScripts(void*);
  173. static void onClickRestart(void* data);
  174. bool callbackRestart(const LLSD& notification, const LLSD& response);
  175. static void onClickCancelRestart(void* data);
  176. private:
  177. LLUUID mTargetAvatar;
  178. };
  179. class LLPanelRegionTextureInfo final : public LLPanelRegionInfo
  180. {
  181. protected:
  182. LOG_CLASS(LLPanelRegionTextureInfo);
  183. public:
  184. LLPanelRegionTextureInfo() = default;
  185. ~LLPanelRegionTextureInfo() override;
  186. // LLPanelRegionInfo override
  187. bool refreshFromRegion(LLViewerRegion* region) override;
  188. private:
  189. // LLPanel overrides
  190. bool postBuild() override;
  191. void draw() override;
  192. // LLPanelRegionInfo override
  193. bool sendUpdate() override;
  194. void clearMaterialPreview(const LLUUID& mat_id);
  195. bool validateTextureSizes() const;
  196. bool validateMaterials() const;
  197. static void onTerrainTypeCommit(LLUICtrl*, void* userdata);
  198. static void onMatPreviewClicked(void* userdata);
  199. static void onSelectInventoryMat(const std::vector<std::string>&,
  200. const uuid_vec_t& ids, void* userdata,
  201. bool);
  202. private:
  203. LLRadioGroup* mTerrainTypeCtrl;
  204. // Note: 4 = LLTerrain::ASSET_COUNT (avoids #including llvlcomposition.h)
  205. LLTextureCtrl* mTexPickers[4];
  206. LLView* mMatBorders[4];
  207. LLTextBox* mMatClickTexts[4];
  208. LLRect mThumbnailRect[4];
  209. LLUUID mMatAssetIds[4];
  210. enum EMatStatus : U32
  211. {
  212. NEEDS_PBR_MODE = 1,
  213. NEEDS_PROBES,
  214. NO_PBR_MAT,
  215. LOADING_PBR_MAT,
  216. FAILED_PBR_MAT,
  217. NTR,
  218. STATUS_COUNT
  219. };
  220. std::string mStatusStrings[STATUS_COUNT];
  221. };
  222. class LLPanelRegionTerrainInfo final : public LLPanelRegionInfo
  223. {
  224. protected:
  225. LOG_CLASS(LLPanelRegionTerrainInfo);
  226. public:
  227. // LLPanelRegionInfo override
  228. bool refreshFromRegion(LLViewerRegion* region) override;
  229. private:
  230. // LLPanel overrides
  231. bool postBuild() override;
  232. // LLPanelRegionInfo override
  233. bool sendUpdate() override;
  234. bool callbackBakeTerrain(const LLSD& notification, const LLSD& response);
  235. static void onChangeUseEstateTime(LLUICtrl* ctrl, void* user_data);
  236. static void onChangeFixedSun(LLUICtrl* ctrl, void* user_data);
  237. static void onChangeSunHour(LLUICtrl* ctrl, void*);
  238. static void downloadRawCallback(HBFileSelector::ESaveFilter filter,
  239. std::string& filepath, void* data);
  240. static void uploadRawCallback(HBFileSelector::ELoadFilter filter,
  241. std::string& filepath, void* data);
  242. static void onClickDownloadRaw(void*);
  243. static void onClickUploadRaw(void*);
  244. static void onClickBakeTerrain(void*);
  245. };
  246. class LLPanelEstateInfo final : public LLPanelRegionInfo
  247. {
  248. friend class HBPanelLandEnvironment;
  249. protected:
  250. LOG_CLASS(LLPanelEstateInfo);
  251. public:
  252. static void initDispatch(LLDispatcher& dispatch);
  253. bool kickUserConfirm(const LLSD& notification, const LLSD& response);
  254. bool onMessageCommit(const LLSD& notification, const LLSD& response);
  255. LLPanelEstateInfo();
  256. void updateControls();
  257. bool refreshFromRegion(LLViewerRegion* region) override;
  258. bool estateUpdate(LLMessageSystem* msg) override;
  259. bool postBuild() override;
  260. void refresh() override;
  261. U32 computeEstateFlags();
  262. void setEstateFlags(U32 flags);
  263. bool getGlobalTime();
  264. void setGlobalTime(bool b);
  265. bool getFixedSun();
  266. F32 getSunHour();
  267. void setSunHour(F32 sun_hour);
  268. const std::string getEstateName() const;
  269. void setEstateName(const std::string& name);
  270. LL_INLINE U32 getEstateID() const { return mEstateID; }
  271. LL_INLINE void setEstateID(U32 estate_id) { mEstateID = estate_id; }
  272. static bool isLindenEstate();
  273. const std::string getOwnerName() const;
  274. void setOwnerName(const std::string& name);
  275. static void updateEstateOwnerName(const std::string& name);
  276. static void updateEstateName(const std::string& name);
  277. // This must have the same function signature as llmessage/llcachename.h
  278. // LLCacheNameCallback
  279. static void callbackCacheName(const LLUUID& id,
  280. const std::string& full_name, bool is_group);
  281. protected:
  282. bool sendUpdate() override;
  283. private:
  284. // Confirmation dialog callback
  285. bool callbackChangeLindenEstate(const LLSD& notification,
  286. const LLSD& response);
  287. void commitEstateInfoDataserver();
  288. bool commitEstateInfoCaps();
  289. void commitEstateInfoCapsCoro(const std::string& url);
  290. void commitEstateAccess();
  291. void commitEstateManagers();
  292. bool checkSunHourSlider(LLUICtrl* child_ctrl);
  293. static void updateChild(LLUICtrl* ctrl, void* user_data);
  294. static void onKickUserCommit(const std::vector<std::string>& names,
  295. const std::vector<LLUUID>& ids,
  296. void* userdata);
  297. static void onClickMessageEstate(void* data);
  298. static void onChangeFixedSun(LLUICtrl* ctrl, void* user_data);
  299. static void onChangeUseGlobalTime(LLUICtrl* ctrl, void* user_data);
  300. static void onClickKickUser(void* userdata);
  301. private:
  302. U32 mEstateID;
  303. };
  304. class LLPanelEstateAccess final : public LLPanelRegionInfo
  305. {
  306. protected:
  307. LOG_CLASS(LLPanelEstateAccess);
  308. public:
  309. LLPanelEstateAccess();
  310. bool postBuild() override;
  311. bool refreshFromRegion(LLViewerRegion* region) override;
  312. void updateControls();
  313. void updateLists();
  314. LL_INLINE void setPendingUpdate(bool pending) { mPendingUpdate = pending; }
  315. LL_INLINE bool getPendingUpdate() { return mPendingUpdate; }
  316. // If visible from mainland, allowed agent and allowed groups are ignored,
  317. // so must disable UI.
  318. void setAccessAllowedEnabled(bool enable_agent, bool enable_group,
  319. bool enable_ban);
  320. static std::string allEstatesText();
  321. private:
  322. bool checkRemovalButton(std::string name);
  323. static void onTabChanged(void* user_data, bool);
  324. static void updateChild(LLUICtrl* ctrl, void* user_data);
  325. static void onClickAddAllowedAgent(void* user_data);
  326. static void onClickRemoveAllowedAgent(void* user_data);
  327. static void onClickAddAllowedGroup(void* user_data);
  328. static void onClickRemoveAllowedGroup(void* user_data);
  329. static void onClickAddBannedAgent(void* user_data);
  330. static void onClickRemoveBannedAgent(void* user_data);
  331. static void onClickAddEstateManager(void* user_data);
  332. static void onClickRemoveEstateManager(void* user_data);
  333. #if 0 // *TODO: implement (backport from LL's viewer-release)
  334. static void onClickCopyAllowedList(void* user_data);
  335. static void onClickCopyAllowedGroupList(void* user_data);
  336. static void onClickCopyBannedList(void* user_data);
  337. static void onAllowedSearchEdit(const std::string& search_string,
  338. void* user_data);
  339. static void onAllowedGroupsSearchEdit(const std::string& search_string,
  340. void* user_data);
  341. static void onBannedSearchEdit(const std::string& search_string,
  342. void* user_data);
  343. void searchAgent(LLNameListCtrl* list, const std::string& search_string);
  344. void copyListToClipboard(std::string list_name);
  345. #endif
  346. // Core methods for all above add/remove button clicks
  347. static void accessAddCore(U32 operation_flag);
  348. static bool accessAddCore2(const LLSD& notification, const LLSD& response);
  349. static void accessAddCore3(const std::vector<std::string>& names,
  350. const std::vector<LLUUID>& ids, void* data);
  351. static void accessRemoveCore(U32 operation_flag);
  352. static bool accessRemoveCore2(const LLSD& notification,
  353. const LLSD& response);
  354. static void addAllowedGroup2(LLUUID id, void* data);
  355. // Used for both add and remove operations
  356. static bool accessCoreConfirm(const LLSD& notification,
  357. const LLSD& response);
  358. // Send the actual EstateOwnerRequest "estateaccessdelta" message
  359. static void sendEstateAccessDelta(U32 flags, const LLUUID& agent_id);
  360. // Group picker callback is different: cannot use core methods above
  361. bool addAllowedGroup(const LLSD& notification, const LLSD& response);
  362. void addAllowedGroup2(LLUUID id);
  363. static void requestEstateGetAccessCoro(const std::string& url);
  364. public:
  365. LLNameListCtrl* mEstateManagers;
  366. LLNameListCtrl* mAllowedGroups;
  367. LLNameListCtrl* mAllowedAvatars;
  368. LLNameListCtrl* mBannedAvatars;
  369. private:
  370. LLTabContainer* mTabContainer;
  371. bool mPendingUpdate;
  372. bool mCtrlsEnabled;
  373. static S32 sLastActiveTab;
  374. };
  375. class LLPanelEstateCovenant final : public LLPanelRegionInfo
  376. {
  377. protected:
  378. LOG_CLASS(LLPanelEstateCovenant);
  379. bool sendUpdate() override;
  380. public:
  381. LLPanelEstateCovenant();
  382. bool postBuild() override;
  383. bool refreshFromRegion(LLViewerRegion* region) override;
  384. bool estateUpdate(LLMessageSystem* msg) override;
  385. // LLView overrides
  386. bool handleDragAndDrop(S32 x, S32 y, MASK mask, bool drop,
  387. EDragAndDropType cargo_type,
  388. void* cargo_data, EAcceptance* accept,
  389. std::string& tooltip_msg) override;
  390. void sendChangeCovenantID(const LLUUID& asset_id);
  391. void loadInvItem(LLInventoryItem* itemp);
  392. // Accessor functions
  393. static void updateCovenantText(const std::string& string, const LLUUID& asset_id);
  394. static void updateEstateName(const std::string& name);
  395. static void updateLastModified(const std::string& text);
  396. static void updateEstateOwnerName(const std::string& name);
  397. LL_INLINE const LLUUID& getCovenantID() const { return mCovenantID; }
  398. LL_INLINE void setCovenantID(const LLUUID& id) { mCovenantID = id; }
  399. const std::string& getEstateName() const;
  400. void setEstateName(const std::string& name);
  401. const std::string& getOwnerName() const;
  402. void setOwnerName(const std::string& name);
  403. void setCovenantTextEditor(const std::string& text);
  404. typedef enum e_asset_status
  405. {
  406. ASSET_ERROR,
  407. ASSET_UNLOADED,
  408. ASSET_LOADING,
  409. ASSET_LOADED
  410. } EAssetStatus;
  411. private:
  412. static void onLoadComplete(const LLUUID& asset_uuid,
  413. LLAssetType::EType type, void* user_data,
  414. S32 status, LLExtStat);
  415. static bool confirmChangeCovenantCallback(const LLSD& notification,
  416. const LLSD& response);
  417. static void resetCovenantID(void* userdata);
  418. static bool confirmResetCovenantCallback(const LLSD& notification,
  419. const LLSD& response);
  420. private:
  421. LLTextBox* mEstateNameText;
  422. LLTextBox* mEstateOwnerText;
  423. LLTextBox* mLastModifiedText;
  424. // CovenantID from sim
  425. LLUUID mCovenantID;
  426. LLViewerTextEditor* mEditor;
  427. EAssetStatus mAssetStatus;
  428. };
  429. class LLPanelRegionExperiences final : public LLPanelRegionInfo
  430. {
  431. protected:
  432. LOG_CLASS(LLPanelRegionExperiences);
  433. public:
  434. LLPanelRegionExperiences();
  435. bool postBuild() override;
  436. bool sendUpdate() override;
  437. static bool experienceCoreConfirm(const LLSD& notification,
  438. const LLSD& response);
  439. static void sendEstateExperienceDelta(U32 flags,
  440. const LLUUID& agent_id);
  441. static void infoCallback(LLHandle<LLPanelRegionExperiences> handle,
  442. const LLSD& content);
  443. bool refreshFromRegion(LLViewerRegion* region) override;
  444. void sendPurchaseRequest()const;
  445. void processResponse(const LLSD& content);
  446. private:
  447. static void* createAllowedExperiencesPanel(void* data);
  448. static void* createTrustedExperiencesPanel(void* data);
  449. static void* createBlockedExperiencesPanel(void* data);
  450. static LLSD addIds(LLPanelExperienceListEditor* panel);
  451. void refreshRegionExperiences();
  452. static const std::string& regionCapabilityQuery(LLViewerRegion* region,
  453. const char* cap);
  454. void setupList(LLPanelExperienceListEditor* panel,
  455. const std::string& control_name,
  456. U32 add_id, U32 remove_id);
  457. void itemChanged(U32 event_type, const LLUUID& id);
  458. private:
  459. LLPanelExperienceListEditor* mTrusted;
  460. LLPanelExperienceListEditor* mAllowed;
  461. LLPanelExperienceListEditor* mBlocked;
  462. LLUUID mDefaultExperience;
  463. };
  464. /////////////////////////////////////////////////////////////////////////////
  465. // Floater class proper
  466. /////////////////////////////////////////////////////////////////////////////
  467. class LLFloaterRegionInfo final
  468. : public LLFloater,
  469. public LLFloaterSingleton<LLFloaterRegionInfo>
  470. {
  471. friend class LLUISingleton<LLFloaterRegionInfo, VisibilityPolicy<LLFloater> >;
  472. protected:
  473. LOG_CLASS(LLFloaterRegionInfo);
  474. public:
  475. ~LLFloaterRegionInfo() override;
  476. void onOpen() override;
  477. bool postBuild() override;
  478. static void processEstateOwnerRequest(LLMessageSystem* msg, void**);
  479. // Processes received region info when the floater exists.
  480. static void updateFromRegionInfo();
  481. LL_INLINE static const LLUUID& getLastInvoice() { return sRequestInvoice; }
  482. LL_INLINE static void nextInvoice() { sRequestInvoice.generate(); }
  483. static LLPanelRegionGeneralInfo* getPanelGeneral();
  484. static LLPanelRegionDebugInfo* getPanelDebug();
  485. static LLPanelEstateInfo* getPanelEstate();
  486. static LLPanelEstateAccess* getPanelAccess();
  487. static LLPanelEstateCovenant* getPanelCovenant();
  488. static LLPanelRegionTerrainInfo* getPanelTerrain();
  489. static LLPanelRegionExperiences* getPanelExperiences();
  490. static HBPanelLandEnvironment* getPanelEnvironment();
  491. void refresh() override;
  492. static void requestRegionInfo();
  493. protected:
  494. LLFloaterRegionInfo(const LLSD& seed);
  495. void refreshFromRegion(LLViewerRegion* region);
  496. private:
  497. LLTabContainer* mTabs;
  498. HBPanelLandEnvironment* mPanelEnvironment;
  499. typedef std::vector<LLPanelRegionInfo*> info_panels_t;
  500. info_panels_t mInfoPanels;
  501. static LLUUID sRequestInvoice;
  502. static S32 sLastTab;
  503. };
  504. #endif