Scene.Permissions.cs 40 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102
  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.Reflection;
  30. using System.Text;
  31. using log4net;
  32. using OpenMetaverse;
  33. using OpenSim.Framework;
  34. using OpenSim.Region.Framework.Interfaces;
  35. namespace OpenSim.Region.Framework.Scenes
  36. {
  37. #region Delegates
  38. public delegate uint GenerateClientFlagsHandler(UUID userID, UUID objectID);
  39. public delegate void SetBypassPermissionsHandler(bool value);
  40. public delegate bool BypassPermissionsHandler();
  41. public delegate bool PropagatePermissionsHandler();
  42. public delegate bool RezObjectHandler(int objectCount, UUID owner, Vector3 objectPosition, Scene scene);
  43. public delegate bool DeleteObjectHandler(UUID objectID, UUID deleter, Scene scene);
  44. public delegate bool TransferObjectHandler(UUID objectID, UUID recipient, Scene scene);
  45. public delegate bool TakeObjectHandler(UUID objectID, UUID stealer, Scene scene);
  46. public delegate bool TakeCopyObjectHandler(UUID objectID, UUID userID, Scene inScene);
  47. public delegate bool DuplicateObjectHandler(int objectCount, UUID objectID, UUID owner, Scene scene, Vector3 objectPosition);
  48. public delegate bool EditObjectHandler(UUID objectID, UUID editorID, Scene scene);
  49. public delegate bool EditObjectInventoryHandler(UUID objectID, UUID editorID, Scene scene);
  50. public delegate bool MoveObjectHandler(UUID objectID, UUID moverID, Scene scene);
  51. public delegate bool ObjectEntryHandler(UUID objectID, bool enteringRegion, Vector3 newPoint, Scene scene);
  52. public delegate bool ReturnObjectsHandler(ILandObject land, UUID user, List<SceneObjectGroup> objects, Scene scene);
  53. public delegate bool InstantMessageHandler(UUID user, UUID target, Scene startScene);
  54. public delegate bool InventoryTransferHandler(UUID user, UUID target, Scene startScene);
  55. public delegate bool ViewScriptHandler(UUID script, UUID objectID, UUID user, Scene scene);
  56. public delegate bool ViewNotecardHandler(UUID script, UUID objectID, UUID user, Scene scene);
  57. public delegate bool EditScriptHandler(UUID script, UUID objectID, UUID user, Scene scene);
  58. public delegate bool EditNotecardHandler(UUID notecard, UUID objectID, UUID user, Scene scene);
  59. public delegate bool RunScriptHandler(UUID script, UUID objectID, UUID user, Scene scene);
  60. public delegate bool CompileScriptHandler(UUID ownerUUID, int scriptType, Scene scene);
  61. public delegate bool StartScriptHandler(UUID script, UUID user, Scene scene);
  62. public delegate bool StopScriptHandler(UUID script, UUID user, Scene scene);
  63. public delegate bool ResetScriptHandler(UUID prim, UUID script, UUID user, Scene scene);
  64. public delegate bool TerraformLandHandler(UUID user, Vector3 position, Scene requestFromScene);
  65. public delegate bool RunConsoleCommandHandler(UUID user, Scene requestFromScene);
  66. public delegate bool IssueEstateCommandHandler(UUID user, Scene requestFromScene, bool ownerCommand);
  67. public delegate bool IsGodHandler(UUID user, Scene requestFromScene);
  68. public delegate bool IsAdministratorHandler(UUID user);
  69. public delegate bool EditParcelHandler(UUID user, ILandObject parcel, Scene scene);
  70. public delegate bool EditParcelPropertiesHandler(UUID user, ILandObject parcel, GroupPowers p, Scene scene);
  71. public delegate bool SellParcelHandler(UUID user, ILandObject parcel, Scene scene);
  72. public delegate bool AbandonParcelHandler(UUID user, ILandObject parcel, Scene scene);
  73. public delegate bool ReclaimParcelHandler(UUID user, ILandObject parcel, Scene scene);
  74. public delegate bool DeedParcelHandler(UUID user, ILandObject parcel, Scene scene);
  75. public delegate bool DeedObjectHandler(UUID user, UUID group, Scene scene);
  76. public delegate bool BuyLandHandler(UUID user, ILandObject parcel, Scene scene);
  77. public delegate bool LinkObjectHandler(UUID user, UUID objectID);
  78. public delegate bool DelinkObjectHandler(UUID user, UUID objectID);
  79. public delegate bool CreateObjectInventoryHandler(int invType, UUID objectID, UUID userID);
  80. public delegate bool CopyObjectInventoryHandler(UUID itemID, UUID objectID, UUID userID);
  81. public delegate bool DeleteObjectInventoryHandler(UUID itemID, UUID objectID, UUID userID);
  82. public delegate bool TransferObjectInventoryHandler(UUID itemID, UUID objectID, UUID userID);
  83. public delegate bool CreateUserInventoryHandler(int invType, UUID userID);
  84. public delegate bool EditUserInventoryHandler(UUID itemID, UUID userID);
  85. public delegate bool CopyUserInventoryHandler(UUID itemID, UUID userID);
  86. public delegate bool DeleteUserInventoryHandler(UUID itemID, UUID userID);
  87. public delegate bool TransferUserInventoryHandler(UUID itemID, UUID userID, UUID recipientID);
  88. public delegate bool TeleportHandler(UUID userID, Scene scene);
  89. public delegate bool ControlPrimMediaHandler(UUID userID, UUID primID, int face);
  90. public delegate bool InteractWithPrimMediaHandler(UUID userID, UUID primID, int face);
  91. #endregion
  92. public class ScenePermissions
  93. {
  94. // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
  95. private Scene m_scene;
  96. public ScenePermissions(Scene scene)
  97. {
  98. m_scene = scene;
  99. }
  100. #region Events
  101. public event GenerateClientFlagsHandler OnGenerateClientFlags;
  102. public event SetBypassPermissionsHandler OnSetBypassPermissions;
  103. public event BypassPermissionsHandler OnBypassPermissions;
  104. public event PropagatePermissionsHandler OnPropagatePermissions;
  105. public event RezObjectHandler OnRezObject;
  106. public event DeleteObjectHandler OnDeleteObject;
  107. public event TransferObjectHandler OnTransferObject;
  108. public event TakeObjectHandler OnTakeObject;
  109. public event TakeCopyObjectHandler OnTakeCopyObject;
  110. public event DuplicateObjectHandler OnDuplicateObject;
  111. public event EditObjectHandler OnEditObject;
  112. public event EditObjectInventoryHandler OnEditObjectInventory;
  113. public event MoveObjectHandler OnMoveObject;
  114. public event ObjectEntryHandler OnObjectEntry;
  115. public event ReturnObjectsHandler OnReturnObjects;
  116. public event InstantMessageHandler OnInstantMessage;
  117. public event InventoryTransferHandler OnInventoryTransfer;
  118. public event ViewScriptHandler OnViewScript;
  119. public event ViewNotecardHandler OnViewNotecard;
  120. public event EditScriptHandler OnEditScript;
  121. public event EditNotecardHandler OnEditNotecard;
  122. public event RunScriptHandler OnRunScript;
  123. public event CompileScriptHandler OnCompileScript;
  124. public event StartScriptHandler OnStartScript;
  125. public event StopScriptHandler OnStopScript;
  126. public event ResetScriptHandler OnResetScript;
  127. public event TerraformLandHandler OnTerraformLand;
  128. public event RunConsoleCommandHandler OnRunConsoleCommand;
  129. public event IssueEstateCommandHandler OnIssueEstateCommand;
  130. public event IsGodHandler OnIsGod;
  131. public event IsAdministratorHandler OnIsAdministrator;
  132. // public event EditParcelHandler OnEditParcel;
  133. public event EditParcelPropertiesHandler OnEditParcelProperties;
  134. public event SellParcelHandler OnSellParcel;
  135. public event AbandonParcelHandler OnAbandonParcel;
  136. public event ReclaimParcelHandler OnReclaimParcel;
  137. public event DeedParcelHandler OnDeedParcel;
  138. public event DeedObjectHandler OnDeedObject;
  139. public event BuyLandHandler OnBuyLand;
  140. public event LinkObjectHandler OnLinkObject;
  141. public event DelinkObjectHandler OnDelinkObject;
  142. public event CreateObjectInventoryHandler OnCreateObjectInventory;
  143. public event CopyObjectInventoryHandler OnCopyObjectInventory;
  144. public event DeleteObjectInventoryHandler OnDeleteObjectInventory;
  145. public event TransferObjectInventoryHandler OnTransferObjectInventory;
  146. public event CreateUserInventoryHandler OnCreateUserInventory;
  147. public event EditUserInventoryHandler OnEditUserInventory;
  148. public event CopyUserInventoryHandler OnCopyUserInventory;
  149. public event DeleteUserInventoryHandler OnDeleteUserInventory;
  150. public event TransferUserInventoryHandler OnTransferUserInventory;
  151. public event TeleportHandler OnTeleport;
  152. public event ControlPrimMediaHandler OnControlPrimMedia;
  153. public event InteractWithPrimMediaHandler OnInteractWithPrimMedia;
  154. #endregion
  155. #region Object Permission Checks
  156. public uint GenerateClientFlags(UUID userID, UUID objectID)
  157. {
  158. // libomv will moan about PrimFlags.ObjectYouOfficer being
  159. // obsolete...
  160. #pragma warning disable 0612
  161. const PrimFlags DEFAULT_FLAGS =
  162. PrimFlags.ObjectModify |
  163. PrimFlags.ObjectCopy |
  164. PrimFlags.ObjectMove |
  165. PrimFlags.ObjectTransfer |
  166. PrimFlags.ObjectYouOwner |
  167. PrimFlags.ObjectAnyOwner |
  168. PrimFlags.ObjectOwnerModify |
  169. PrimFlags.ObjectYouOfficer;
  170. #pragma warning restore 0612
  171. SceneObjectPart part = m_scene.GetSceneObjectPart(objectID);
  172. if (part == null)
  173. return 0;
  174. uint perms = part.GetEffectiveObjectFlags() | (uint)DEFAULT_FLAGS;
  175. GenerateClientFlagsHandler handlerGenerateClientFlags = OnGenerateClientFlags;
  176. if (handlerGenerateClientFlags != null)
  177. {
  178. Delegate[] list = handlerGenerateClientFlags.GetInvocationList();
  179. foreach (GenerateClientFlagsHandler check in list)
  180. {
  181. perms &= check(userID, objectID);
  182. }
  183. }
  184. return perms;
  185. }
  186. public void SetBypassPermissions(bool value)
  187. {
  188. SetBypassPermissionsHandler handler = OnSetBypassPermissions;
  189. if (handler != null)
  190. handler(value);
  191. }
  192. public bool BypassPermissions()
  193. {
  194. BypassPermissionsHandler handler = OnBypassPermissions;
  195. if (handler != null)
  196. {
  197. Delegate[] list = handler.GetInvocationList();
  198. foreach (BypassPermissionsHandler h in list)
  199. {
  200. if (h() == false)
  201. return false;
  202. }
  203. }
  204. return true;
  205. }
  206. public bool PropagatePermissions()
  207. {
  208. PropagatePermissionsHandler handler = OnPropagatePermissions;
  209. if (handler != null)
  210. {
  211. Delegate[] list = handler.GetInvocationList();
  212. foreach (PropagatePermissionsHandler h in list)
  213. {
  214. if (h() == false)
  215. return false;
  216. }
  217. }
  218. return true;
  219. }
  220. #region REZ OBJECT
  221. public bool CanRezObject(int objectCount, UUID owner, Vector3 objectPosition)
  222. {
  223. RezObjectHandler handler = OnRezObject;
  224. if (handler != null)
  225. {
  226. Delegate[] list = handler.GetInvocationList();
  227. foreach (RezObjectHandler h in list)
  228. {
  229. if (h(objectCount, owner,objectPosition, m_scene) == false)
  230. return false;
  231. }
  232. }
  233. return true;
  234. }
  235. #endregion
  236. #region DELETE OBJECT
  237. public bool CanDeleteObject(UUID objectID, UUID deleter)
  238. {
  239. bool result = true;
  240. DeleteObjectHandler handler = OnDeleteObject;
  241. if (handler != null)
  242. {
  243. Delegate[] list = handler.GetInvocationList();
  244. foreach (DeleteObjectHandler h in list)
  245. {
  246. if (h(objectID, deleter, m_scene) == false)
  247. {
  248. result = false;
  249. break;
  250. }
  251. }
  252. }
  253. return result;
  254. }
  255. public bool CanTransferObject(UUID objectID, UUID recipient)
  256. {
  257. bool result = true;
  258. TransferObjectHandler handler = OnTransferObject;
  259. if (handler != null)
  260. {
  261. Delegate[] list = handler.GetInvocationList();
  262. foreach (TransferObjectHandler h in list)
  263. {
  264. if (h(objectID, recipient, m_scene) == false)
  265. {
  266. result = false;
  267. break;
  268. }
  269. }
  270. }
  271. return result;
  272. }
  273. #endregion
  274. #region TAKE OBJECT
  275. public bool CanTakeObject(UUID objectID, UUID AvatarTakingUUID)
  276. {
  277. bool result = true;
  278. TakeObjectHandler handler = OnTakeObject;
  279. if (handler != null)
  280. {
  281. Delegate[] list = handler.GetInvocationList();
  282. foreach (TakeObjectHandler h in list)
  283. {
  284. if (h(objectID, AvatarTakingUUID, m_scene) == false)
  285. {
  286. result = false;
  287. break;
  288. }
  289. }
  290. }
  291. // m_log.DebugFormat(
  292. // "[SCENE PERMISSIONS]: CanTakeObject() fired for object {0}, taker {1}, result {2}",
  293. // objectID, AvatarTakingUUID, result);
  294. return result;
  295. }
  296. #endregion
  297. #region TAKE COPY OBJECT
  298. public bool CanTakeCopyObject(UUID objectID, UUID userID)
  299. {
  300. bool result = true;
  301. TakeCopyObjectHandler handler = OnTakeCopyObject;
  302. if (handler != null)
  303. {
  304. Delegate[] list = handler.GetInvocationList();
  305. foreach (TakeCopyObjectHandler h in list)
  306. {
  307. if (h(objectID, userID, m_scene) == false)
  308. {
  309. result = false;
  310. break;
  311. }
  312. }
  313. }
  314. // m_log.DebugFormat(
  315. // "[SCENE PERMISSIONS]: CanTakeCopyObject() fired for object {0}, user {1}, result {2}",
  316. // objectID, userID, result);
  317. return result;
  318. }
  319. #endregion
  320. #region DUPLICATE OBJECT
  321. public bool CanDuplicateObject(int objectCount, UUID objectID, UUID owner, Vector3 objectPosition)
  322. {
  323. DuplicateObjectHandler handler = OnDuplicateObject;
  324. if (handler != null)
  325. {
  326. Delegate[] list = handler.GetInvocationList();
  327. foreach (DuplicateObjectHandler h in list)
  328. {
  329. if (h(objectCount, objectID, owner, m_scene, objectPosition) == false)
  330. return false;
  331. }
  332. }
  333. return true;
  334. }
  335. #endregion
  336. #region EDIT OBJECT
  337. public bool CanEditObject(UUID objectID, UUID editorID)
  338. {
  339. EditObjectHandler handler = OnEditObject;
  340. if (handler != null)
  341. {
  342. Delegate[] list = handler.GetInvocationList();
  343. foreach (EditObjectHandler h in list)
  344. {
  345. if (h(objectID, editorID, m_scene) == false)
  346. return false;
  347. }
  348. }
  349. return true;
  350. }
  351. public bool CanEditObjectInventory(UUID objectID, UUID editorID)
  352. {
  353. EditObjectInventoryHandler handler = OnEditObjectInventory;
  354. if (handler != null)
  355. {
  356. Delegate[] list = handler.GetInvocationList();
  357. foreach (EditObjectInventoryHandler h in list)
  358. {
  359. if (h(objectID, editorID, m_scene) == false)
  360. return false;
  361. }
  362. }
  363. return true;
  364. }
  365. #endregion
  366. #region MOVE OBJECT
  367. public bool CanMoveObject(UUID objectID, UUID moverID)
  368. {
  369. MoveObjectHandler handler = OnMoveObject;
  370. if (handler != null)
  371. {
  372. Delegate[] list = handler.GetInvocationList();
  373. foreach (MoveObjectHandler h in list)
  374. {
  375. if (h(objectID, moverID, m_scene) == false)
  376. return false;
  377. }
  378. }
  379. return true;
  380. }
  381. #endregion
  382. #region OBJECT ENTRY
  383. public bool CanObjectEntry(UUID objectID, bool enteringRegion, Vector3 newPoint)
  384. {
  385. ObjectEntryHandler handler = OnObjectEntry;
  386. if (handler != null)
  387. {
  388. Delegate[] list = handler.GetInvocationList();
  389. foreach (ObjectEntryHandler h in list)
  390. {
  391. if (h(objectID, enteringRegion, newPoint, m_scene) == false)
  392. return false;
  393. }
  394. }
  395. return true;
  396. }
  397. #endregion
  398. #region RETURN OBJECT
  399. public bool CanReturnObjects(ILandObject land, UUID user, List<SceneObjectGroup> objects)
  400. {
  401. bool result = true;
  402. ReturnObjectsHandler handler = OnReturnObjects;
  403. if (handler != null)
  404. {
  405. Delegate[] list = handler.GetInvocationList();
  406. foreach (ReturnObjectsHandler h in list)
  407. {
  408. if (h(land, user, objects, m_scene) == false)
  409. {
  410. result = false;
  411. break;
  412. }
  413. }
  414. }
  415. // m_log.DebugFormat(
  416. // "[SCENE PERMISSIONS]: CanReturnObjects() fired for user {0} for {1} objects on {2}, result {3}",
  417. // user, objects.Count, land.LandData.Name, result);
  418. return result;
  419. }
  420. #endregion
  421. #region INSTANT MESSAGE
  422. public bool CanInstantMessage(UUID user, UUID target)
  423. {
  424. InstantMessageHandler handler = OnInstantMessage;
  425. if (handler != null)
  426. {
  427. Delegate[] list = handler.GetInvocationList();
  428. foreach (InstantMessageHandler h in list)
  429. {
  430. if (h(user, target, m_scene) == false)
  431. return false;
  432. }
  433. }
  434. return true;
  435. }
  436. #endregion
  437. #region INVENTORY TRANSFER
  438. public bool CanInventoryTransfer(UUID user, UUID target)
  439. {
  440. InventoryTransferHandler handler = OnInventoryTransfer;
  441. if (handler != null)
  442. {
  443. Delegate[] list = handler.GetInvocationList();
  444. foreach (InventoryTransferHandler h in list)
  445. {
  446. if (h(user, target, m_scene) == false)
  447. return false;
  448. }
  449. }
  450. return true;
  451. }
  452. #endregion
  453. #region VIEW SCRIPT
  454. public bool CanViewScript(UUID script, UUID objectID, UUID user)
  455. {
  456. ViewScriptHandler handler = OnViewScript;
  457. if (handler != null)
  458. {
  459. Delegate[] list = handler.GetInvocationList();
  460. foreach (ViewScriptHandler h in list)
  461. {
  462. if (h(script, objectID, user, m_scene) == false)
  463. return false;
  464. }
  465. }
  466. return true;
  467. }
  468. public bool CanViewNotecard(UUID script, UUID objectID, UUID user)
  469. {
  470. ViewNotecardHandler handler = OnViewNotecard;
  471. if (handler != null)
  472. {
  473. Delegate[] list = handler.GetInvocationList();
  474. foreach (ViewNotecardHandler h in list)
  475. {
  476. if (h(script, objectID, user, m_scene) == false)
  477. return false;
  478. }
  479. }
  480. return true;
  481. }
  482. #endregion
  483. #region EDIT SCRIPT
  484. public bool CanEditScript(UUID script, UUID objectID, UUID user)
  485. {
  486. EditScriptHandler handler = OnEditScript;
  487. if (handler != null)
  488. {
  489. Delegate[] list = handler.GetInvocationList();
  490. foreach (EditScriptHandler h in list)
  491. {
  492. if (h(script, objectID, user, m_scene) == false)
  493. return false;
  494. }
  495. }
  496. return true;
  497. }
  498. public bool CanEditNotecard(UUID script, UUID objectID, UUID user)
  499. {
  500. EditNotecardHandler handler = OnEditNotecard;
  501. if (handler != null)
  502. {
  503. Delegate[] list = handler.GetInvocationList();
  504. foreach (EditNotecardHandler h in list)
  505. {
  506. if (h(script, objectID, user, m_scene) == false)
  507. return false;
  508. }
  509. }
  510. return true;
  511. }
  512. #endregion
  513. #region RUN SCRIPT (When Script Placed in Object)
  514. public bool CanRunScript(UUID script, UUID objectID, UUID user)
  515. {
  516. RunScriptHandler handler = OnRunScript;
  517. if (handler != null)
  518. {
  519. Delegate[] list = handler.GetInvocationList();
  520. foreach (RunScriptHandler h in list)
  521. {
  522. if (h(script, objectID, user, m_scene) == false)
  523. return false;
  524. }
  525. }
  526. return true;
  527. }
  528. #endregion
  529. #region COMPILE SCRIPT (When Script needs to get (re)compiled)
  530. public bool CanCompileScript(UUID ownerUUID, int scriptType)
  531. {
  532. CompileScriptHandler handler = OnCompileScript;
  533. if (handler != null)
  534. {
  535. Delegate[] list = handler.GetInvocationList();
  536. foreach (CompileScriptHandler h in list)
  537. {
  538. if (h(ownerUUID, scriptType, m_scene) == false)
  539. return false;
  540. }
  541. }
  542. return true;
  543. }
  544. #endregion
  545. #region START SCRIPT (When Script run box is Checked after placed in object)
  546. public bool CanStartScript(UUID script, UUID user)
  547. {
  548. StartScriptHandler handler = OnStartScript;
  549. if (handler != null)
  550. {
  551. Delegate[] list = handler.GetInvocationList();
  552. foreach (StartScriptHandler h in list)
  553. {
  554. if (h(script, user, m_scene) == false)
  555. return false;
  556. }
  557. }
  558. return true;
  559. }
  560. #endregion
  561. #region STOP SCRIPT (When Script run box is unchecked after placed in object)
  562. public bool CanStopScript(UUID script, UUID user)
  563. {
  564. StopScriptHandler handler = OnStopScript;
  565. if (handler != null)
  566. {
  567. Delegate[] list = handler.GetInvocationList();
  568. foreach (StopScriptHandler h in list)
  569. {
  570. if (h(script, user, m_scene) == false)
  571. return false;
  572. }
  573. }
  574. return true;
  575. }
  576. #endregion
  577. #region RESET SCRIPT
  578. public bool CanResetScript(UUID prim, UUID script, UUID user)
  579. {
  580. ResetScriptHandler handler = OnResetScript;
  581. if (handler != null)
  582. {
  583. Delegate[] list = handler.GetInvocationList();
  584. foreach (ResetScriptHandler h in list)
  585. {
  586. if (h(prim, script, user, m_scene) == false)
  587. return false;
  588. }
  589. }
  590. return true;
  591. }
  592. #endregion
  593. #region TERRAFORM LAND
  594. public bool CanTerraformLand(UUID user, Vector3 pos)
  595. {
  596. TerraformLandHandler handler = OnTerraformLand;
  597. if (handler != null)
  598. {
  599. Delegate[] list = handler.GetInvocationList();
  600. foreach (TerraformLandHandler h in list)
  601. {
  602. if (h(user, pos, m_scene) == false)
  603. return false;
  604. }
  605. }
  606. return true;
  607. }
  608. #endregion
  609. #region RUN CONSOLE COMMAND
  610. public bool CanRunConsoleCommand(UUID user)
  611. {
  612. RunConsoleCommandHandler handler = OnRunConsoleCommand;
  613. if (handler != null)
  614. {
  615. Delegate[] list = handler.GetInvocationList();
  616. foreach (RunConsoleCommandHandler h in list)
  617. {
  618. if (h(user, m_scene) == false)
  619. return false;
  620. }
  621. }
  622. return true;
  623. }
  624. #endregion
  625. #region CAN ISSUE ESTATE COMMAND
  626. public bool CanIssueEstateCommand(UUID user, bool ownerCommand)
  627. {
  628. IssueEstateCommandHandler handler = OnIssueEstateCommand;
  629. if (handler != null)
  630. {
  631. Delegate[] list = handler.GetInvocationList();
  632. foreach (IssueEstateCommandHandler h in list)
  633. {
  634. if (h(user, m_scene, ownerCommand) == false)
  635. return false;
  636. }
  637. }
  638. return true;
  639. }
  640. #endregion
  641. #region CAN BE GODLIKE
  642. public bool IsGod(UUID user)
  643. {
  644. IsGodHandler handler = OnIsGod;
  645. if (handler != null)
  646. {
  647. Delegate[] list = handler.GetInvocationList();
  648. foreach (IsGodHandler h in list)
  649. {
  650. if (h(user, m_scene) == false)
  651. return false;
  652. }
  653. }
  654. return true;
  655. }
  656. public bool IsAdministrator(UUID user)
  657. {
  658. IsAdministratorHandler handler = OnIsAdministrator;
  659. if (handler != null)
  660. {
  661. Delegate[] list = handler.GetInvocationList();
  662. foreach (IsAdministratorHandler h in list)
  663. {
  664. if (h(user) == false)
  665. return false;
  666. }
  667. }
  668. return true;
  669. }
  670. #endregion
  671. #region EDIT PARCEL
  672. public bool CanEditParcelProperties(UUID user, ILandObject parcel, GroupPowers p)
  673. {
  674. EditParcelPropertiesHandler handler = OnEditParcelProperties;
  675. if (handler != null)
  676. {
  677. Delegate[] list = handler.GetInvocationList();
  678. foreach (EditParcelPropertiesHandler h in list)
  679. {
  680. if (h(user, parcel, p, m_scene) == false)
  681. return false;
  682. }
  683. }
  684. return true;
  685. }
  686. #endregion
  687. #region SELL PARCEL
  688. public bool CanSellParcel(UUID user, ILandObject parcel)
  689. {
  690. SellParcelHandler handler = OnSellParcel;
  691. if (handler != null)
  692. {
  693. Delegate[] list = handler.GetInvocationList();
  694. foreach (SellParcelHandler h in list)
  695. {
  696. if (h(user, parcel, m_scene) == false)
  697. return false;
  698. }
  699. }
  700. return true;
  701. }
  702. #endregion
  703. #region ABANDON PARCEL
  704. public bool CanAbandonParcel(UUID user, ILandObject parcel)
  705. {
  706. AbandonParcelHandler handler = OnAbandonParcel;
  707. if (handler != null)
  708. {
  709. Delegate[] list = handler.GetInvocationList();
  710. foreach (AbandonParcelHandler h in list)
  711. {
  712. if (h(user, parcel, m_scene) == false)
  713. return false;
  714. }
  715. }
  716. return true;
  717. }
  718. #endregion
  719. public bool CanReclaimParcel(UUID user, ILandObject parcel)
  720. {
  721. ReclaimParcelHandler handler = OnReclaimParcel;
  722. if (handler != null)
  723. {
  724. Delegate[] list = handler.GetInvocationList();
  725. foreach (ReclaimParcelHandler h in list)
  726. {
  727. if (h(user, parcel, m_scene) == false)
  728. return false;
  729. }
  730. }
  731. return true;
  732. }
  733. public bool CanDeedParcel(UUID user, ILandObject parcel)
  734. {
  735. DeedParcelHandler handler = OnDeedParcel;
  736. if (handler != null)
  737. {
  738. Delegate[] list = handler.GetInvocationList();
  739. foreach (DeedParcelHandler h in list)
  740. {
  741. if (h(user, parcel, m_scene) == false)
  742. return false;
  743. }
  744. }
  745. return true;
  746. }
  747. public bool CanDeedObject(UUID user, UUID group)
  748. {
  749. DeedObjectHandler handler = OnDeedObject;
  750. if (handler != null)
  751. {
  752. Delegate[] list = handler.GetInvocationList();
  753. foreach (DeedObjectHandler h in list)
  754. {
  755. if (h(user, group, m_scene) == false)
  756. return false;
  757. }
  758. }
  759. return true;
  760. }
  761. public bool CanBuyLand(UUID user, ILandObject parcel)
  762. {
  763. BuyLandHandler handler = OnBuyLand;
  764. if (handler != null)
  765. {
  766. Delegate[] list = handler.GetInvocationList();
  767. foreach (BuyLandHandler h in list)
  768. {
  769. if (h(user, parcel, m_scene) == false)
  770. return false;
  771. }
  772. }
  773. return true;
  774. }
  775. public bool CanLinkObject(UUID user, UUID objectID)
  776. {
  777. LinkObjectHandler handler = OnLinkObject;
  778. if (handler != null)
  779. {
  780. Delegate[] list = handler.GetInvocationList();
  781. foreach (LinkObjectHandler h in list)
  782. {
  783. if (h(user, objectID) == false)
  784. return false;
  785. }
  786. }
  787. return true;
  788. }
  789. public bool CanDelinkObject(UUID user, UUID objectID)
  790. {
  791. DelinkObjectHandler handler = OnDelinkObject;
  792. if (handler != null)
  793. {
  794. Delegate[] list = handler.GetInvocationList();
  795. foreach (DelinkObjectHandler h in list)
  796. {
  797. if (h(user, objectID) == false)
  798. return false;
  799. }
  800. }
  801. return true;
  802. }
  803. #endregion
  804. /// Check whether the specified user is allowed to directly create the given inventory type in a prim's
  805. /// inventory (e.g. the New Script button in the 1.21 Linden Lab client).
  806. /// </summary>
  807. /// <param name="invType"></param>
  808. /// <param name="objectID"></param>
  809. /// <param name="userID"></param>
  810. /// <returns></returns>
  811. public bool CanCreateObjectInventory(int invType, UUID objectID, UUID userID)
  812. {
  813. CreateObjectInventoryHandler handler = OnCreateObjectInventory;
  814. if (handler != null)
  815. {
  816. Delegate[] list = handler.GetInvocationList();
  817. foreach (CreateObjectInventoryHandler h in list)
  818. {
  819. if (h(invType, objectID, userID) == false)
  820. return false;
  821. }
  822. }
  823. return true;
  824. }
  825. public bool CanCopyObjectInventory(UUID itemID, UUID objectID, UUID userID)
  826. {
  827. CopyObjectInventoryHandler handler = OnCopyObjectInventory;
  828. if (handler != null)
  829. {
  830. Delegate[] list = handler.GetInvocationList();
  831. foreach (CopyObjectInventoryHandler h in list)
  832. {
  833. if (h(itemID, objectID, userID) == false)
  834. return false;
  835. }
  836. }
  837. return true;
  838. }
  839. public bool CanDeleteObjectInventory(UUID itemID, UUID objectID, UUID userID)
  840. {
  841. DeleteObjectInventoryHandler handler = OnDeleteObjectInventory;
  842. if (handler != null)
  843. {
  844. Delegate[] list = handler.GetInvocationList();
  845. foreach (DeleteObjectInventoryHandler h in list)
  846. {
  847. if (h(itemID, objectID, userID) == false)
  848. return false;
  849. }
  850. }
  851. return true;
  852. }
  853. public bool CanTransferObjectInventory(UUID itemID, UUID objectID, UUID userID)
  854. {
  855. TransferObjectInventoryHandler handler = OnTransferObjectInventory;
  856. if (handler != null)
  857. {
  858. Delegate[] list = handler.GetInvocationList();
  859. foreach (TransferObjectInventoryHandler h in list)
  860. {
  861. if (h(itemID, objectID, userID) == false)
  862. return false;
  863. }
  864. }
  865. return true;
  866. }
  867. /// <summary>
  868. /// Check whether the specified user is allowed to create the given inventory type in their inventory.
  869. /// </summary>
  870. /// <param name="invType"></param>
  871. /// <param name="userID"></param>
  872. /// <returns></returns>
  873. public bool CanCreateUserInventory(int invType, UUID userID)
  874. {
  875. CreateUserInventoryHandler handler = OnCreateUserInventory;
  876. if (handler != null)
  877. {
  878. Delegate[] list = handler.GetInvocationList();
  879. foreach (CreateUserInventoryHandler h in list)
  880. {
  881. if (h(invType, userID) == false)
  882. return false;
  883. }
  884. }
  885. return true;
  886. }
  887. /// <summary>
  888. /// Check whether the specified user is allowed to edit the given inventory item within their own inventory.
  889. /// </summary>
  890. /// <param name="itemID"></param>
  891. /// <param name="userID"></param>
  892. /// <returns></returns>
  893. public bool CanEditUserInventory(UUID itemID, UUID userID)
  894. {
  895. EditUserInventoryHandler handler = OnEditUserInventory;
  896. if (handler != null)
  897. {
  898. Delegate[] list = handler.GetInvocationList();
  899. foreach (EditUserInventoryHandler h in list)
  900. {
  901. if (h(itemID, userID) == false)
  902. return false;
  903. }
  904. }
  905. return true;
  906. }
  907. /// <summary>
  908. /// Check whether the specified user is allowed to copy the given inventory item from their own inventory.
  909. /// </summary>
  910. /// <param name="itemID"></param>
  911. /// <param name="userID"></param>
  912. /// <returns></returns>
  913. public bool CanCopyUserInventory(UUID itemID, UUID userID)
  914. {
  915. CopyUserInventoryHandler handler = OnCopyUserInventory;
  916. if (handler != null)
  917. {
  918. Delegate[] list = handler.GetInvocationList();
  919. foreach (CopyUserInventoryHandler h in list)
  920. {
  921. if (h(itemID, userID) == false)
  922. return false;
  923. }
  924. }
  925. return true;
  926. }
  927. /// <summary>
  928. /// Check whether the specified user is allowed to edit the given inventory item within their own inventory.
  929. /// </summary>
  930. /// <param name="itemID"></param>
  931. /// <param name="userID"></param>
  932. /// <returns></returns>
  933. public bool CanDeleteUserInventory(UUID itemID, UUID userID)
  934. {
  935. DeleteUserInventoryHandler handler = OnDeleteUserInventory;
  936. if (handler != null)
  937. {
  938. Delegate[] list = handler.GetInvocationList();
  939. foreach (DeleteUserInventoryHandler h in list)
  940. {
  941. if (h(itemID, userID) == false)
  942. return false;
  943. }
  944. }
  945. return true;
  946. }
  947. public bool CanTransferUserInventory(UUID itemID, UUID userID, UUID recipientID)
  948. {
  949. TransferUserInventoryHandler handler = OnTransferUserInventory;
  950. if (handler != null)
  951. {
  952. Delegate[] list = handler.GetInvocationList();
  953. foreach (TransferUserInventoryHandler h in list)
  954. {
  955. if (h(itemID, userID, recipientID) == false)
  956. return false;
  957. }
  958. }
  959. return true;
  960. }
  961. public bool CanTeleport(UUID userID)
  962. {
  963. TeleportHandler handler = OnTeleport;
  964. if (handler != null)
  965. {
  966. Delegate[] list = handler.GetInvocationList();
  967. foreach (TeleportHandler h in list)
  968. {
  969. if (h(userID, m_scene) == false)
  970. return false;
  971. }
  972. }
  973. return true;
  974. }
  975. public bool CanControlPrimMedia(UUID userID, UUID primID, int face)
  976. {
  977. ControlPrimMediaHandler handler = OnControlPrimMedia;
  978. if (handler != null)
  979. {
  980. Delegate[] list = handler.GetInvocationList();
  981. foreach (ControlPrimMediaHandler h in list)
  982. {
  983. if (h(userID, primID, face) == false)
  984. return false;
  985. }
  986. }
  987. return true;
  988. }
  989. public bool CanInteractWithPrimMedia(UUID userID, UUID primID, int face)
  990. {
  991. InteractWithPrimMediaHandler handler = OnInteractWithPrimMedia;
  992. if (handler != null)
  993. {
  994. Delegate[] list = handler.GetInvocationList();
  995. foreach (InteractWithPrimMediaHandler h in list)
  996. {
  997. if (h(userID, primID, face) == false)
  998. return false;
  999. }
  1000. }
  1001. return true;
  1002. }
  1003. }
  1004. }