EstateSettings.cs 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383
  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 uint m_ParentEstateID = 1;
  53. public uint ParentEstateID
  54. {
  55. get { return m_ParentEstateID; }
  56. set { m_ParentEstateID = value; }
  57. }
  58. private float m_BillableFactor = 0.0f;
  59. public float BillableFactor
  60. {
  61. get { return m_BillableFactor; }
  62. set { m_BillableFactor = value; }
  63. }
  64. private int m_PricePerMeter = 1;
  65. public int PricePerMeter
  66. {
  67. get { return m_PricePerMeter; }
  68. set { m_PricePerMeter = value; }
  69. }
  70. private int m_RedirectGridX = 0;
  71. public int RedirectGridX
  72. {
  73. get { return m_RedirectGridX; }
  74. set { m_RedirectGridX = value; }
  75. }
  76. private int m_RedirectGridY = 0;
  77. public int RedirectGridY
  78. {
  79. get { return m_RedirectGridY; }
  80. set { m_RedirectGridY = value; }
  81. }
  82. // Used by the sim
  83. //
  84. private bool m_UseGlobalTime = true;
  85. public bool UseGlobalTime
  86. {
  87. get { return m_UseGlobalTime; }
  88. set { m_UseGlobalTime = value; }
  89. }
  90. private bool m_FixedSun = false;
  91. public bool FixedSun
  92. {
  93. get { return m_FixedSun; }
  94. set { m_FixedSun = value; }
  95. }
  96. private double m_SunPosition = 0.0;
  97. public double SunPosition
  98. {
  99. get { return m_SunPosition; }
  100. set { m_SunPosition = value; }
  101. }
  102. private bool m_AllowVoice = true;
  103. public bool AllowVoice
  104. {
  105. get { return m_AllowVoice; }
  106. set { m_AllowVoice = value; }
  107. }
  108. private bool m_AllowDirectTeleport = true;
  109. public bool AllowDirectTeleport
  110. {
  111. get { return m_AllowDirectTeleport; }
  112. set { m_AllowDirectTeleport = value; }
  113. }
  114. private bool m_DenyAnonymous = false;
  115. public bool DenyAnonymous
  116. {
  117. get { return m_DenyAnonymous; }
  118. set { m_DenyAnonymous = value; }
  119. }
  120. private bool m_DenyIdentified = false;
  121. public bool DenyIdentified
  122. {
  123. get { return m_DenyIdentified; }
  124. set { m_DenyIdentified = value; }
  125. }
  126. private bool m_DenyTransacted = false;
  127. public bool DenyTransacted
  128. {
  129. get { return m_DenyTransacted; }
  130. set { m_DenyTransacted = value; }
  131. }
  132. private bool m_AbuseEmailToEstateOwner = false;
  133. public bool AbuseEmailToEstateOwner
  134. {
  135. get { return m_AbuseEmailToEstateOwner; }
  136. set { m_AbuseEmailToEstateOwner = value; }
  137. }
  138. private bool m_BlockDwell = false;
  139. public bool BlockDwell
  140. {
  141. get { return m_BlockDwell; }
  142. set { m_BlockDwell = value; }
  143. }
  144. private bool m_EstateSkipScripts = false;
  145. public bool EstateSkipScripts
  146. {
  147. get { return m_EstateSkipScripts; }
  148. set { m_EstateSkipScripts = value; }
  149. }
  150. private bool m_ResetHomeOnTeleport = false;
  151. public bool ResetHomeOnTeleport
  152. {
  153. get { return m_ResetHomeOnTeleport; }
  154. set { m_ResetHomeOnTeleport = value; }
  155. }
  156. private bool m_TaxFree = false;
  157. public bool TaxFree
  158. {
  159. get { return m_TaxFree; }
  160. set { m_TaxFree = value; }
  161. }
  162. private bool m_PublicAccess = true;
  163. public bool PublicAccess
  164. {
  165. get { return m_PublicAccess; }
  166. set { m_PublicAccess = value; }
  167. }
  168. private string m_AbuseEmail = String.Empty;
  169. public string AbuseEmail
  170. {
  171. get { return m_AbuseEmail; }
  172. set { m_AbuseEmail= value; }
  173. }
  174. private UUID m_EstateOwner = UUID.Zero;
  175. public UUID EstateOwner
  176. {
  177. get { return m_EstateOwner; }
  178. set { m_EstateOwner = value; }
  179. }
  180. private bool m_DenyMinors = false;
  181. public bool DenyMinors
  182. {
  183. get { return m_DenyMinors; }
  184. set { m_DenyMinors = value; }
  185. }
  186. // All those lists...
  187. //
  188. private List<UUID> l_EstateManagers = new List<UUID>();
  189. public UUID[] EstateManagers
  190. {
  191. get { return l_EstateManagers.ToArray(); }
  192. set { l_EstateManagers = new List<UUID>(value); }
  193. }
  194. private List<EstateBan> l_EstateBans = new List<EstateBan>();
  195. public EstateBan[] EstateBans
  196. {
  197. get { return l_EstateBans.ToArray(); }
  198. set { l_EstateBans = new List<EstateBan>(value); }
  199. }
  200. private List<UUID> l_EstateAccess = new List<UUID>();
  201. public UUID[] EstateAccess
  202. {
  203. get { return l_EstateAccess.ToArray(); }
  204. set { l_EstateAccess = new List<UUID>(value); }
  205. }
  206. private List<UUID> l_EstateGroups = new List<UUID>();
  207. public UUID[] EstateGroups
  208. {
  209. get { return l_EstateGroups.ToArray(); }
  210. set { l_EstateGroups = new List<UUID>(value); }
  211. }
  212. public EstateSettings()
  213. {
  214. }
  215. public void Save()
  216. {
  217. if (OnSave != null)
  218. OnSave(this);
  219. }
  220. public void AddEstateUser(UUID avatarID)
  221. {
  222. if (avatarID == UUID.Zero)
  223. return;
  224. if (!l_EstateAccess.Contains(avatarID))
  225. l_EstateAccess.Add(avatarID);
  226. }
  227. public void RemoveEstateUser(UUID avatarID)
  228. {
  229. if (l_EstateAccess.Contains(avatarID))
  230. l_EstateAccess.Remove(avatarID);
  231. }
  232. public void AddEstateGroup(UUID avatarID)
  233. {
  234. if (avatarID == UUID.Zero)
  235. return;
  236. if (!l_EstateGroups.Contains(avatarID))
  237. l_EstateGroups.Add(avatarID);
  238. }
  239. public void RemoveEstateGroup(UUID avatarID)
  240. {
  241. if (l_EstateGroups.Contains(avatarID))
  242. l_EstateGroups.Remove(avatarID);
  243. }
  244. public void AddEstateManager(UUID avatarID)
  245. {
  246. if (avatarID == UUID.Zero)
  247. return;
  248. if (!l_EstateManagers.Contains(avatarID))
  249. l_EstateManagers.Add(avatarID);
  250. }
  251. public void RemoveEstateManager(UUID avatarID)
  252. {
  253. if (l_EstateManagers.Contains(avatarID))
  254. l_EstateManagers.Remove(avatarID);
  255. }
  256. public bool IsEstateManager(UUID avatarID)
  257. {
  258. if (IsEstateOwner(avatarID))
  259. return true;
  260. return l_EstateManagers.Contains(avatarID);
  261. }
  262. public bool IsEstateOwner(UUID avatarID)
  263. {
  264. if (avatarID == m_EstateOwner)
  265. return true;
  266. return false;
  267. }
  268. public bool IsBanned(UUID avatarID)
  269. {
  270. foreach (EstateBan ban in l_EstateBans)
  271. if (ban.BannedUserID == avatarID)
  272. return true;
  273. return false;
  274. }
  275. public void AddBan(EstateBan ban)
  276. {
  277. if (ban == null)
  278. return;
  279. if (!IsBanned(ban.BannedUserID))
  280. l_EstateBans.Add(ban);
  281. }
  282. public void ClearBans()
  283. {
  284. l_EstateBans.Clear();
  285. }
  286. public void RemoveBan(UUID avatarID)
  287. {
  288. foreach (EstateBan ban in new List<EstateBan>(l_EstateBans))
  289. if (ban.BannedUserID == avatarID)
  290. l_EstateBans.Remove(ban);
  291. }
  292. public bool HasAccess(UUID user)
  293. {
  294. if (IsEstateManager(user))
  295. return true;
  296. return l_EstateAccess.Contains(user);
  297. }
  298. public bool GroupAccess(UUID groupID)
  299. {
  300. return l_EstateGroups.Contains(groupID);
  301. }
  302. }
  303. }