BunchOfCapsModule.cs 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. /*
  2. * Copyright (c) Contributors, http://opensimulator.org/
  3. * See CONTRIBUTORS.TXT for a full list of copyright holders.
  4. *
  5. * Redistribution and use in source and binary forms, with or without
  6. * modification, are permitted provided that the following conditions are met:
  7. * * Redistributions of source code must retain the above copyright
  8. * notice, this list of conditions and the following disclaimer.
  9. * * Redistributions in binary form must reproduce the above copyright
  10. * notice, this list of conditions and the following disclaimer in the
  11. * documentation and/or other materials provided with the distribution.
  12. * * Neither the name of the OpenSimulator Project nor the
  13. * names of its contributors may be used to endorse or promote products
  14. * derived from this software without specific prior written permission.
  15. *
  16. * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
  17. * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  18. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  19. * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
  20. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  21. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  22. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  23. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  24. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  25. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  26. */
  27. using System;
  28. using log4net;
  29. using Nini.Config;
  30. using OpenMetaverse;
  31. using Mono.Addins;
  32. using OpenSim.Framework;
  33. using OpenSim.Region.Framework;
  34. using OpenSim.Region.Framework.Interfaces;
  35. using OpenSim.Region.Framework.Scenes;
  36. using Caps = OpenSim.Framework.Capabilities.Caps;
  37. [assembly: Addin("LindenCaps", OpenSim.VersionInfo.VersionNumber)]
  38. [assembly: AddinDependency("OpenSim.Region.Framework", OpenSim.VersionInfo.VersionNumber)]
  39. namespace OpenSim.Region.ClientStack.Linden
  40. {
  41. public class BunchOfCapsConfigOptions
  42. {
  43. public ModelCost ModelCost;
  44. public bool persistBakedTextures = false;
  45. public bool enableModelUploadTextureToInventory = true; // place uploaded textures also in inventory
  46. // may not be visible till relog
  47. public bool enableFreeTestUpload = false; // allows "TEST-" prefix hack
  48. public bool ForceFreeTestUpload = false; // forces all uploads to be test
  49. public bool RestrictFreeTestUploadPerms = false; // reduces also the permitions. Needs a creator defined!!
  50. public int levelUpload = 0;
  51. public bool AllowCapHomeLocation = true;
  52. public bool AllowCapGroupMemberData = true;
  53. public bool AllowCapLandResources = true;
  54. public bool AllowCapAttachmentResources = true;
  55. public UUID testAssetsCreatorID = UUID.Zero;
  56. }
  57. [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "BunchOfCapsModule")]
  58. public class BunchOfCapsModule : INonSharedRegionModule
  59. {
  60. //private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
  61. private Scene m_Scene;
  62. private BunchOfCapsConfigOptions ConfigOptions = new();
  63. #region INonSharedRegionModule
  64. public string Name { get { return "BunchOfCapsModule"; } }
  65. public Type ReplaceableInterface { get { return null; } }
  66. public void Initialise(IConfigSource source)
  67. {
  68. }
  69. public void Close() { }
  70. public void AddRegion(Scene scene)
  71. {
  72. m_Scene = scene;
  73. }
  74. public void RemoveRegion(Scene scene)
  75. {
  76. }
  77. public void RegionLoaded(Scene scene)
  78. {
  79. ConfigOptions.ModelCost = new ModelCost(m_Scene);
  80. IConfigSource config = m_Scene.Config;
  81. if (config is not null)
  82. {
  83. IConfig sconfig = config.Configs["Startup"];
  84. if (sconfig is not null)
  85. ConfigOptions.levelUpload = sconfig.GetInt("LevelUpload", 0);
  86. if (ConfigOptions.levelUpload == 0)
  87. {
  88. IConfig pconfig = config.Configs["Permissions"];
  89. if (pconfig is not null)
  90. ConfigOptions.levelUpload = pconfig.GetInt("LevelUpload", 0);
  91. }
  92. IConfig appearanceConfig = config.Configs["Appearance"];
  93. if (appearanceConfig is not null)
  94. {
  95. ConfigOptions.persistBakedTextures = appearanceConfig.GetBoolean("PersistBakedTextures", ConfigOptions.persistBakedTextures);
  96. }
  97. // economy for model upload
  98. IConfig EconomyConfig = config.Configs["Economy"];
  99. if (EconomyConfig is not null)
  100. {
  101. ConfigOptions.ModelCost.Econfig(EconomyConfig);
  102. ConfigOptions.enableModelUploadTextureToInventory =
  103. EconomyConfig.GetBoolean("MeshModelAllowTextureToInventory", ConfigOptions.enableModelUploadTextureToInventory);
  104. ConfigOptions.RestrictFreeTestUploadPerms =
  105. EconomyConfig.GetBoolean("m_RestrictFreeTestUploadPerms", ConfigOptions.RestrictFreeTestUploadPerms);
  106. ConfigOptions.enableFreeTestUpload = EconomyConfig.GetBoolean("AllowFreeTestUpload", ConfigOptions.enableFreeTestUpload);
  107. ConfigOptions.ForceFreeTestUpload =
  108. EconomyConfig.GetBoolean("ForceFreeTestUpload", ConfigOptions.ForceFreeTestUpload);
  109. string testcreator = EconomyConfig.GetString("TestAssetsCreatorID", "");
  110. if (!string.IsNullOrEmpty(testcreator))
  111. {
  112. if (UUID.TryParse(testcreator, out UUID id))
  113. ConfigOptions.testAssetsCreatorID = id;
  114. }
  115. }
  116. IConfig CapsConfig = config.Configs["ClientStack.LindenCaps"];
  117. if (CapsConfig is not null)
  118. {
  119. string homeLocationUrl = CapsConfig.GetString("Cap_HomeLocation", "localhost");
  120. ConfigOptions.AllowCapHomeLocation = !string.IsNullOrEmpty(homeLocationUrl);
  121. string GroupMemberDataUrl = CapsConfig.GetString("Cap_GroupMemberData", "localhost");
  122. ConfigOptions.AllowCapGroupMemberData = !string.IsNullOrEmpty(GroupMemberDataUrl);
  123. string LandResourcesUrl = CapsConfig.GetString("Cap_LandResources", "localhost");
  124. ConfigOptions.AllowCapLandResources = !string.IsNullOrEmpty(LandResourcesUrl);
  125. string AttachmentResourcesUrl = CapsConfig.GetString("Cap_AttachmentResources", "localhost");
  126. ConfigOptions.AllowCapAttachmentResources = !string.IsNullOrEmpty(AttachmentResourcesUrl);
  127. }
  128. m_Scene.EventManager.OnRegisterCaps += OnRegisterCaps;
  129. }
  130. }
  131. public void PostInitialise() { }
  132. #endregion
  133. private void OnRegisterCaps(UUID agentID, Caps caps)
  134. {
  135. _ = new BunchOfCaps(m_Scene, agentID, caps, ConfigOptions);
  136. }
  137. }
  138. }