EstateSettings.cs 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482
  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 OpenSim 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.IO;
  29. using System.Reflection;
  30. using System.Collections.Generic;
  31. using libsecondlife;
  32. using log4net;
  33. namespace OpenSim.Framework
  34. {
  35. public class EstateSettings
  36. {
  37. // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
  38. private ConfigurationMember configMember;
  39. public delegate void SaveDelegate(EstateSettings rs);
  40. public event SaveDelegate OnSave;
  41. // Only the client uses these
  42. //
  43. private uint m_EstateID = 100;
  44. public uint EstateID
  45. {
  46. get { return m_EstateID; }
  47. set { m_EstateID = value; }
  48. }
  49. private string m_EstateName;
  50. public string EstateName
  51. {
  52. get { return m_EstateName; }
  53. set { m_EstateName = value; }
  54. }
  55. private uint m_ParentEstateID = 100;
  56. public uint ParentEstateID
  57. {
  58. get { return m_ParentEstateID; }
  59. set { m_ParentEstateID = value; }
  60. }
  61. private float m_BillableFactor;
  62. public float BillableFactor
  63. {
  64. get { return m_BillableFactor; }
  65. set { m_BillableFactor = value; }
  66. }
  67. private int m_PricePerMeter;
  68. public int PricePerMeter
  69. {
  70. get { return m_PricePerMeter; }
  71. set { m_PricePerMeter = value; }
  72. }
  73. private int m_RedirectGridX;
  74. public int RedirectGridX
  75. {
  76. get { return m_RedirectGridX; }
  77. set { m_RedirectGridX = value; }
  78. }
  79. private int m_RedirectGridY;
  80. public int RedirectGridY
  81. {
  82. get { return m_RedirectGridY; }
  83. set { m_RedirectGridY = value; }
  84. }
  85. // Used by the sim
  86. //
  87. private bool m_UseGlobalTime = true;
  88. public bool UseGlobalTime
  89. {
  90. get { return m_UseGlobalTime; }
  91. set { m_UseGlobalTime = value; }
  92. }
  93. private bool m_FixedSun = false;
  94. public bool FixedSun
  95. {
  96. get { return m_FixedSun; }
  97. set { m_FixedSun = value; }
  98. }
  99. private double m_SunPosition = 0.0;
  100. public double SunPosition
  101. {
  102. get { return m_SunPosition; }
  103. set { m_SunPosition = value; }
  104. }
  105. private bool m_AllowVoice = true;
  106. public bool AllowVoice
  107. {
  108. get { return m_AllowVoice; }
  109. set { m_AllowVoice = value; }
  110. }
  111. private bool m_AllowDirectTeleport = true;
  112. public bool AllowDirectTeleport
  113. {
  114. get { return m_AllowDirectTeleport; }
  115. set { m_AllowDirectTeleport = value; }
  116. }
  117. private bool m_DenyAnonymous = false;
  118. public bool DenyAnonymous
  119. {
  120. get { return m_DenyAnonymous; }
  121. set { m_DenyAnonymous = value; }
  122. }
  123. private bool m_DenyIdentified = false;
  124. public bool DenyIdentified
  125. {
  126. get { return m_DenyIdentified; }
  127. set { m_DenyIdentified = value; }
  128. }
  129. private bool m_DenyTransacted = false;
  130. public bool DenyTransacted
  131. {
  132. get { return m_DenyTransacted; }
  133. set { m_DenyTransacted = value; }
  134. }
  135. private bool m_AbuseEmailToEstateOwner = false;
  136. public bool AbuseEmailToEstateOwner
  137. {
  138. get { return m_AbuseEmailToEstateOwner; }
  139. set { m_AbuseEmailToEstateOwner = value; }
  140. }
  141. private bool m_BlockDwell = false;
  142. public bool BlockDwell
  143. {
  144. get { return m_BlockDwell; }
  145. set { m_BlockDwell = value; }
  146. }
  147. private bool m_EstateSkipScripts = false;
  148. public bool EstateSkipScripts
  149. {
  150. get { return m_EstateSkipScripts; }
  151. set { m_EstateSkipScripts = value; }
  152. }
  153. private bool m_ResetHomeOnTeleport = false;
  154. public bool ResetHomeOnTeleport
  155. {
  156. get { return m_ResetHomeOnTeleport; }
  157. set { m_ResetHomeOnTeleport = value; }
  158. }
  159. private bool m_TaxFree = false;
  160. public bool TaxFree
  161. {
  162. get { return m_TaxFree; }
  163. set { m_TaxFree = value; }
  164. }
  165. private bool m_PublicAccess = true;
  166. public bool PublicAccess
  167. {
  168. get { return m_PublicAccess; }
  169. set { m_PublicAccess = value; }
  170. }
  171. // All those lists...
  172. //
  173. private List<LLUUID> l_EstateManagers = new List<LLUUID>();
  174. public LLUUID[] EstateManagers
  175. {
  176. get { return l_EstateManagers.ToArray(); }
  177. set { l_EstateManagers = new List<LLUUID>(value); }
  178. }
  179. private List<EstateBan> l_EstateBans = new List<EstateBan>();
  180. public EstateBan[] EstateBans
  181. {
  182. get { return l_EstateBans.ToArray(); }
  183. set { l_EstateBans = new List<EstateBan>(value); }
  184. }
  185. private List<LLUUID> l_EstateAccess = new List<LLUUID>();
  186. public LLUUID[] EstateAccess
  187. {
  188. get { return l_EstateAccess.ToArray(); }
  189. set { l_EstateAccess = new List<LLUUID>(value); }
  190. }
  191. private List<LLUUID> l_EstateGroups = new List<LLUUID>();
  192. public LLUUID[] EstateGroups
  193. {
  194. get { return l_EstateGroups.ToArray(); }
  195. set { l_EstateGroups = new List<LLUUID>(value); }
  196. }
  197. public EstateSettings()
  198. {
  199. if (configMember == null)
  200. {
  201. // Load legacy defaults
  202. //
  203. configMember =
  204. new ConfigurationMember(Path.Combine(Util.configDir(),
  205. "estate_settings.xml"), "ESTATE SETTINGS",
  206. loadConfigurationOptions,
  207. handleIncomingConfiguration, true);
  208. l_EstateManagers.Clear();
  209. configMember.performConfigurationRetrieve();
  210. }
  211. }
  212. public void Save()
  213. {
  214. if (OnSave != null)
  215. OnSave(this);
  216. }
  217. public void AddEstateManager(LLUUID avatarID)
  218. {
  219. if (avatarID == LLUUID.Zero)
  220. return;
  221. if (!l_EstateManagers.Contains(avatarID))
  222. l_EstateManagers.Add(avatarID);
  223. }
  224. public void RemoveEstateManager(LLUUID avatarID)
  225. {
  226. if (l_EstateManagers.Contains(avatarID))
  227. l_EstateManagers.Remove(avatarID);
  228. }
  229. public bool IsEstateManager(LLUUID avatarID)
  230. {
  231. return l_EstateManagers.Contains(avatarID);
  232. }
  233. public bool IsBanned(LLUUID avatarID)
  234. {
  235. foreach (EstateBan ban in l_EstateBans)
  236. if (ban.bannedUUID == avatarID)
  237. return true;
  238. return false;
  239. }
  240. public void AddBan(EstateBan ban)
  241. {
  242. if (ban == null)
  243. return;
  244. if (!IsBanned(ban.bannedUUID))
  245. l_EstateBans.Add(ban);
  246. }
  247. public void ClearBans()
  248. {
  249. l_EstateBans.Clear();
  250. }
  251. public void RemoveBan(LLUUID avatarID)
  252. {
  253. foreach (EstateBan ban in new List<EstateBan>(l_EstateBans))
  254. if (ban.bannedUUID == avatarID)
  255. l_EstateBans.Remove(ban);
  256. }
  257. public void loadConfigurationOptions()
  258. {
  259. configMember.addConfigurationOption("billable_factor",
  260. ConfigurationOption.ConfigurationTypes.TYPE_FLOAT,
  261. String.Empty, "0.0", true);
  262. // configMember.addConfigurationOption("estate_id",
  263. // ConfigurationOption.ConfigurationTypes.TYPE_UINT32,
  264. // String.Empty, "100", true);
  265. // configMember.addConfigurationOption("parent_estate_id",
  266. // ConfigurationOption.ConfigurationTypes.TYPE_UINT32,
  267. // String.Empty, "1", true);
  268. configMember.addConfigurationOption("redirect_grid_x",
  269. ConfigurationOption.ConfigurationTypes.TYPE_INT32,
  270. String.Empty, "0", true);
  271. configMember.addConfigurationOption("redirect_grid_y",
  272. ConfigurationOption.ConfigurationTypes.TYPE_INT32,
  273. String.Empty, "0", true);
  274. configMember.addConfigurationOption("price_per_meter",
  275. ConfigurationOption.ConfigurationTypes.TYPE_UINT32,
  276. String.Empty, "1", true);
  277. configMember.addConfigurationOption("estate_name",
  278. ConfigurationOption.ConfigurationTypes.TYPE_STRING,
  279. String.Empty, "My Estate", true);
  280. configMember.addConfigurationOption("estate_manager_0",
  281. ConfigurationOption.ConfigurationTypes.TYPE_LLUUID,
  282. String.Empty, "00000000-0000-0000-0000-000000000000", true);
  283. configMember.addConfigurationOption("estate_manager_1",
  284. ConfigurationOption.ConfigurationTypes.TYPE_LLUUID,
  285. String.Empty, "00000000-0000-0000-0000-000000000000", true);
  286. configMember.addConfigurationOption("estate_manager_2",
  287. ConfigurationOption.ConfigurationTypes.TYPE_LLUUID,
  288. String.Empty, "00000000-0000-0000-0000-000000000000", true);
  289. configMember.addConfigurationOption("estate_manager_3",
  290. ConfigurationOption.ConfigurationTypes.TYPE_LLUUID,
  291. String.Empty, "00000000-0000-0000-0000-000000000000", true);
  292. configMember.addConfigurationOption("estate_manager_4",
  293. ConfigurationOption.ConfigurationTypes.TYPE_LLUUID,
  294. String.Empty, "00000000-0000-0000-0000-000000000000", true);
  295. configMember.addConfigurationOption("estate_manager_5",
  296. ConfigurationOption.ConfigurationTypes.TYPE_LLUUID,
  297. String.Empty, "00000000-0000-0000-0000-000000000000", true);
  298. configMember.addConfigurationOption("estate_manager_6",
  299. ConfigurationOption.ConfigurationTypes.TYPE_LLUUID,
  300. String.Empty, "00000000-0000-0000-0000-000000000000", true);
  301. configMember.addConfigurationOption("estate_manager_7",
  302. ConfigurationOption.ConfigurationTypes.TYPE_LLUUID,
  303. String.Empty, "00000000-0000-0000-0000-000000000000", true);
  304. configMember.addConfigurationOption("estate_manager_8",
  305. ConfigurationOption.ConfigurationTypes.TYPE_LLUUID,
  306. String.Empty, "00000000-0000-0000-0000-000000000000", true);
  307. configMember.addConfigurationOption("estate_manager_9",
  308. ConfigurationOption.ConfigurationTypes.TYPE_LLUUID,
  309. String.Empty, "00000000-0000-0000-0000-000000000000", true);
  310. configMember.addConfigurationOption("region_flags",
  311. ConfigurationOption.ConfigurationTypes.TYPE_UINT32,
  312. String.Empty, "336723974", true);
  313. }
  314. public bool handleIncomingConfiguration(string configuration_key, object configuration_result)
  315. {
  316. switch (configuration_key)
  317. {
  318. case "region_flags":
  319. Simulator.RegionFlags flags = (Simulator.RegionFlags)(uint)configuration_result;
  320. if ((flags & (Simulator.RegionFlags)(1<<29)) != 0)
  321. m_AllowVoice = true;
  322. if ((flags & Simulator.RegionFlags.AllowDirectTeleport) != 0)
  323. m_AllowDirectTeleport = true;
  324. if ((flags & Simulator.RegionFlags.DenyAnonymous) != 0)
  325. m_DenyAnonymous = true;
  326. if ((flags & Simulator.RegionFlags.DenyIdentified) != 0)
  327. m_DenyIdentified = true;
  328. if ((flags & Simulator.RegionFlags.DenyTransacted) != 0)
  329. m_DenyTransacted = true;
  330. if ((flags & Simulator.RegionFlags.AbuseEmailToEstateOwner) != 0)
  331. m_AbuseEmailToEstateOwner = true;
  332. if ((flags & Simulator.RegionFlags.BlockDwell) != 0)
  333. m_BlockDwell = true;
  334. if ((flags & Simulator.RegionFlags.EstateSkipScripts) != 0)
  335. m_EstateSkipScripts = true;
  336. if ((flags & Simulator.RegionFlags.ResetHomeOnTeleport) != 0)
  337. m_ResetHomeOnTeleport = true;
  338. if ((flags & Simulator.RegionFlags.TaxFree) != 0)
  339. m_TaxFree = true;
  340. if ((flags & Simulator.RegionFlags.PublicAllowed) != 0)
  341. m_PublicAccess = true;
  342. break;
  343. case "billable_factor":
  344. m_BillableFactor = (float) configuration_result;
  345. break;
  346. // case "estate_id":
  347. // m_EstateID = (uint) configuration_result;
  348. // break;
  349. // case "parent_estate_id":
  350. // m_ParentEstateID = (uint) configuration_result;
  351. // break;
  352. case "redirect_grid_x":
  353. m_RedirectGridX = (int) configuration_result;
  354. break;
  355. case "redirect_grid_y":
  356. m_RedirectGridY = (int) configuration_result;
  357. break;
  358. case "price_per_meter":
  359. m_PricePerMeter = Convert.ToInt32(configuration_result);
  360. break;
  361. case "estate_name":
  362. m_EstateName = (string) configuration_result;
  363. break;
  364. case "estate_manager_0":
  365. AddEstateManager((LLUUID)configuration_result);
  366. break;
  367. case "estate_manager_1":
  368. AddEstateManager((LLUUID)configuration_result);
  369. break;
  370. case "estate_manager_2":
  371. AddEstateManager((LLUUID)configuration_result);
  372. break;
  373. case "estate_manager_3":
  374. AddEstateManager((LLUUID)configuration_result);
  375. break;
  376. case "estate_manager_4":
  377. AddEstateManager((LLUUID)configuration_result);
  378. break;
  379. case "estate_manager_5":
  380. AddEstateManager((LLUUID)configuration_result);
  381. break;
  382. case "estate_manager_6":
  383. AddEstateManager((LLUUID)configuration_result);
  384. break;
  385. case "estate_manager_7":
  386. AddEstateManager((LLUUID)configuration_result);
  387. break;
  388. case "estate_manager_8":
  389. AddEstateManager((LLUUID)configuration_result);
  390. break;
  391. case "estate_manager_9":
  392. AddEstateManager((LLUUID)configuration_result);
  393. break;
  394. }
  395. return true;
  396. }
  397. }
  398. }