EstateSettings.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415
  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 System.Collections.Generic;
  29. using System.IO;
  30. using OpenMetaverse;
  31. namespace OpenSim.Framework
  32. {
  33. public class EstateSettings
  34. {
  35. // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
  36. public delegate void SaveDelegate(EstateSettings rs);
  37. public event SaveDelegate OnSave;
  38. // Only the client uses these
  39. //
  40. private uint m_EstateID = 0;
  41. public uint EstateID
  42. {
  43. get { return m_EstateID; }
  44. set { m_EstateID = value; }
  45. }
  46. private string m_EstateName = "My Estate";
  47. public string EstateName
  48. {
  49. get { return m_EstateName; }
  50. set { m_EstateName = value; }
  51. }
  52. private bool m_AllowLandmark = true;
  53. public bool AllowLandmark
  54. {
  55. get { return m_AllowLandmark; }
  56. set { m_AllowLandmark = value; }
  57. }
  58. private bool m_AllowParcelChanges = true;
  59. public bool AllowParcelChanges
  60. {
  61. get { return m_AllowParcelChanges; }
  62. set { m_AllowParcelChanges = value; }
  63. }
  64. private bool m_AllowSetHome = true;
  65. public bool AllowSetHome
  66. {
  67. get { return m_AllowSetHome; }
  68. set { m_AllowSetHome = value; }
  69. }
  70. private uint m_ParentEstateID = 1;
  71. public uint ParentEstateID
  72. {
  73. get { return m_ParentEstateID; }
  74. set { m_ParentEstateID = value; }
  75. }
  76. private float m_BillableFactor = 0.0f;
  77. public float BillableFactor
  78. {
  79. get { return m_BillableFactor; }
  80. set { m_BillableFactor = value; }
  81. }
  82. private int m_PricePerMeter = 1;
  83. public int PricePerMeter
  84. {
  85. get { return m_PricePerMeter; }
  86. set { m_PricePerMeter = value; }
  87. }
  88. private int m_RedirectGridX = 0;
  89. public int RedirectGridX
  90. {
  91. get { return m_RedirectGridX; }
  92. set { m_RedirectGridX = value; }
  93. }
  94. private int m_RedirectGridY = 0;
  95. public int RedirectGridY
  96. {
  97. get { return m_RedirectGridY; }
  98. set { m_RedirectGridY = value; }
  99. }
  100. // Used by the sim
  101. //
  102. private bool m_UseGlobalTime = true;
  103. public bool UseGlobalTime
  104. {
  105. get { return m_UseGlobalTime; }
  106. set { m_UseGlobalTime = value; }
  107. }
  108. private bool m_FixedSun = false;
  109. public bool FixedSun
  110. {
  111. get { return m_FixedSun; }
  112. set { m_FixedSun = value; }
  113. }
  114. private double m_SunPosition = 0.0;
  115. public double SunPosition
  116. {
  117. get { return m_SunPosition; }
  118. set { m_SunPosition = value; }
  119. }
  120. private bool m_AllowVoice = true;
  121. public bool AllowVoice
  122. {
  123. get { return m_AllowVoice; }
  124. set { m_AllowVoice = value; }
  125. }
  126. private bool m_AllowDirectTeleport = true;
  127. public bool AllowDirectTeleport
  128. {
  129. get { return m_AllowDirectTeleport; }
  130. set { m_AllowDirectTeleport = value; }
  131. }
  132. private bool m_DenyAnonymous = false;
  133. public bool DenyAnonymous
  134. {
  135. get { return m_DenyAnonymous; }
  136. set { m_DenyAnonymous = value; }
  137. }
  138. private bool m_DenyIdentified = false;
  139. public bool DenyIdentified
  140. {
  141. get { return m_DenyIdentified; }
  142. set { m_DenyIdentified = value; }
  143. }
  144. private bool m_DenyTransacted = false;
  145. public bool DenyTransacted
  146. {
  147. get { return m_DenyTransacted; }
  148. set { m_DenyTransacted = value; }
  149. }
  150. private bool m_AbuseEmailToEstateOwner = false;
  151. public bool AbuseEmailToEstateOwner
  152. {
  153. get { return m_AbuseEmailToEstateOwner; }
  154. set { m_AbuseEmailToEstateOwner = value; }
  155. }
  156. private bool m_BlockDwell = false;
  157. public bool BlockDwell
  158. {
  159. get { return m_BlockDwell; }
  160. set { m_BlockDwell = value; }
  161. }
  162. private bool m_EstateSkipScripts = false;
  163. public bool EstateSkipScripts
  164. {
  165. get { return m_EstateSkipScripts; }
  166. set { m_EstateSkipScripts = value; }
  167. }
  168. private bool m_ResetHomeOnTeleport = false;
  169. public bool ResetHomeOnTeleport
  170. {
  171. get { return m_ResetHomeOnTeleport; }
  172. set { m_ResetHomeOnTeleport = value; }
  173. }
  174. private bool m_TaxFree = false;
  175. public bool TaxFree
  176. {
  177. get { return m_TaxFree; }
  178. set { m_TaxFree = value; }
  179. }
  180. private bool m_PublicAccess = true;
  181. public bool PublicAccess
  182. {
  183. get { return m_PublicAccess; }
  184. set { m_PublicAccess = value; }
  185. }
  186. private string m_AbuseEmail = String.Empty;
  187. public string AbuseEmail
  188. {
  189. get { return m_AbuseEmail; }
  190. set { m_AbuseEmail= value; }
  191. }
  192. private UUID m_EstateOwner = UUID.Zero;
  193. public UUID EstateOwner
  194. {
  195. get { return m_EstateOwner; }
  196. set { m_EstateOwner = value; }
  197. }
  198. private bool m_DenyMinors = false;
  199. public bool DenyMinors
  200. {
  201. get { return m_DenyMinors; }
  202. set { m_DenyMinors = value; }
  203. }
  204. // All those lists...
  205. //
  206. private List<UUID> l_EstateManagers = new List<UUID>();
  207. public UUID[] EstateManagers
  208. {
  209. get { return l_EstateManagers.ToArray(); }
  210. set { l_EstateManagers = new List<UUID>(value); }
  211. }
  212. private List<EstateBan> l_EstateBans = new List<EstateBan>();
  213. public EstateBan[] EstateBans
  214. {
  215. get { return l_EstateBans.ToArray(); }
  216. set { l_EstateBans = new List<EstateBan>(value); }
  217. }
  218. private List<UUID> l_EstateAccess = new List<UUID>();
  219. public UUID[] EstateAccess
  220. {
  221. get { return l_EstateAccess.ToArray(); }
  222. set { l_EstateAccess = new List<UUID>(value); }
  223. }
  224. private List<UUID> l_EstateGroups = new List<UUID>();
  225. public UUID[] EstateGroups
  226. {
  227. get { return l_EstateGroups.ToArray(); }
  228. set { l_EstateGroups = new List<UUID>(value); }
  229. }
  230. public EstateSettings()
  231. {
  232. }
  233. public void Save()
  234. {
  235. if (OnSave != null)
  236. OnSave(this);
  237. }
  238. public void AddEstateUser(UUID avatarID)
  239. {
  240. if (avatarID == UUID.Zero)
  241. return;
  242. if (!l_EstateAccess.Contains(avatarID))
  243. l_EstateAccess.Add(avatarID);
  244. }
  245. public void RemoveEstateUser(UUID avatarID)
  246. {
  247. if (l_EstateAccess.Contains(avatarID))
  248. l_EstateAccess.Remove(avatarID);
  249. }
  250. public void AddEstateGroup(UUID avatarID)
  251. {
  252. if (avatarID == UUID.Zero)
  253. return;
  254. if (!l_EstateGroups.Contains(avatarID))
  255. l_EstateGroups.Add(avatarID);
  256. }
  257. public void RemoveEstateGroup(UUID avatarID)
  258. {
  259. if (l_EstateGroups.Contains(avatarID))
  260. l_EstateGroups.Remove(avatarID);
  261. }
  262. public void AddEstateManager(UUID avatarID)
  263. {
  264. if (avatarID == UUID.Zero)
  265. return;
  266. if (!l_EstateManagers.Contains(avatarID))
  267. l_EstateManagers.Add(avatarID);
  268. }
  269. public void RemoveEstateManager(UUID avatarID)
  270. {
  271. if (l_EstateManagers.Contains(avatarID))
  272. l_EstateManagers.Remove(avatarID);
  273. }
  274. public bool IsEstateManagerOrOwner(UUID avatarID)
  275. {
  276. if (IsEstateOwner(avatarID))
  277. return true;
  278. return l_EstateManagers.Contains(avatarID);
  279. }
  280. public bool IsEstateOwner(UUID avatarID)
  281. {
  282. if (avatarID == m_EstateOwner)
  283. return true;
  284. return false;
  285. }
  286. public bool IsBanned(UUID avatarID)
  287. {
  288. foreach (EstateBan ban in l_EstateBans)
  289. if (ban.BannedUserID == avatarID)
  290. return true;
  291. return false;
  292. }
  293. public void AddBan(EstateBan ban)
  294. {
  295. if (ban == null)
  296. return;
  297. if (!IsBanned(ban.BannedUserID))
  298. l_EstateBans.Add(ban);
  299. }
  300. public void ClearBans()
  301. {
  302. l_EstateBans.Clear();
  303. }
  304. public void RemoveBan(UUID avatarID)
  305. {
  306. foreach (EstateBan ban in new List<EstateBan>(l_EstateBans))
  307. if (ban.BannedUserID == avatarID)
  308. l_EstateBans.Remove(ban);
  309. }
  310. public bool HasAccess(UUID user)
  311. {
  312. if (IsEstateManagerOrOwner(user))
  313. return true;
  314. return l_EstateAccess.Contains(user);
  315. }
  316. public void SetFromFlags(ulong regionFlags)
  317. {
  318. ResetHomeOnTeleport = ((regionFlags & (ulong)OpenMetaverse.RegionFlags.ResetHomeOnTeleport) == (ulong)OpenMetaverse.RegionFlags.ResetHomeOnTeleport);
  319. BlockDwell = ((regionFlags & (ulong)OpenMetaverse.RegionFlags.BlockDwell) == (ulong)OpenMetaverse.RegionFlags.BlockDwell);
  320. AllowLandmark = ((regionFlags & (ulong)OpenMetaverse.RegionFlags.AllowLandmark) == (ulong)OpenMetaverse.RegionFlags.AllowLandmark);
  321. AllowParcelChanges = ((regionFlags & (ulong)OpenMetaverse.RegionFlags.AllowParcelChanges) == (ulong)OpenMetaverse.RegionFlags.AllowParcelChanges);
  322. AllowSetHome = ((regionFlags & (ulong)OpenMetaverse.RegionFlags.AllowSetHome) == (ulong)OpenMetaverse.RegionFlags.AllowSetHome);
  323. }
  324. public bool GroupAccess(UUID groupID)
  325. {
  326. return l_EstateGroups.Contains(groupID);
  327. }
  328. }
  329. }