Scene.Permissions.cs 50 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334
  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.Collections.Generic;
  29. using System.Text;
  30. using OpenMetaverse;
  31. using OpenSim.Framework;
  32. using OpenSim.Region.Framework.Interfaces;
  33. namespace OpenSim.Region.Framework.Scenes
  34. {
  35. public class ScenePermissions
  36. {
  37. private Scene m_scene;
  38. public ScenePermissions(Scene scene)
  39. {
  40. m_scene = scene;
  41. }
  42. #region Object Permission Checks
  43. public delegate uint GenerateClientFlagsHandler(UUID userID, UUID objectIDID);
  44. private List<GenerateClientFlagsHandler> GenerateClientFlagsCheckFunctions = new List<GenerateClientFlagsHandler>();
  45. public void AddGenerateClientFlagsHandler(GenerateClientFlagsHandler delegateFunc)
  46. {
  47. if (!GenerateClientFlagsCheckFunctions.Contains(delegateFunc))
  48. GenerateClientFlagsCheckFunctions.Add(delegateFunc);
  49. }
  50. public void RemoveGenerateClientFlagsHandler(GenerateClientFlagsHandler delegateFunc)
  51. {
  52. if (GenerateClientFlagsCheckFunctions.Contains(delegateFunc))
  53. GenerateClientFlagsCheckFunctions.Remove(delegateFunc);
  54. }
  55. public uint GenerateClientFlags(UUID userID, UUID objectID)
  56. {
  57. SceneObjectPart part=m_scene.GetSceneObjectPart(objectID);
  58. if (part == null)
  59. return 0;
  60. // libomv will moan about PrimFlags.ObjectYouOfficer being
  61. // obsolete...
  62. #pragma warning disable 0612
  63. uint perms=part.GetEffectiveObjectFlags() |
  64. (uint)PrimFlags.ObjectModify |
  65. (uint)PrimFlags.ObjectCopy |
  66. (uint)PrimFlags.ObjectMove |
  67. (uint)PrimFlags.ObjectTransfer |
  68. (uint)PrimFlags.ObjectYouOwner |
  69. (uint)PrimFlags.ObjectAnyOwner |
  70. (uint)PrimFlags.ObjectOwnerModify |
  71. (uint)PrimFlags.ObjectYouOfficer;
  72. #pragma warning restore 0612
  73. foreach (GenerateClientFlagsHandler check in GenerateClientFlagsCheckFunctions)
  74. {
  75. perms &= check(userID, objectID);
  76. }
  77. return perms;
  78. }
  79. public delegate void SetBypassPermissionsHandler(bool value);
  80. private List<SetBypassPermissionsHandler> SetBypassPermissionsCheckFunctions = new List<SetBypassPermissionsHandler>();
  81. public void AddSetBypassPermissionsHandler(SetBypassPermissionsHandler delegateFunc)
  82. {
  83. if (!SetBypassPermissionsCheckFunctions.Contains(delegateFunc))
  84. SetBypassPermissionsCheckFunctions.Add(delegateFunc);
  85. }
  86. public void RemoveSetBypassPermissionsHandler(SetBypassPermissionsHandler delegateFunc)
  87. {
  88. if (SetBypassPermissionsCheckFunctions.Contains(delegateFunc))
  89. SetBypassPermissionsCheckFunctions.Remove(delegateFunc);
  90. }
  91. public void SetBypassPermissions(bool value)
  92. {
  93. foreach (SetBypassPermissionsHandler check in SetBypassPermissionsCheckFunctions)
  94. {
  95. check(value);
  96. }
  97. }
  98. public delegate bool BypassPermissionsHandler();
  99. private List<BypassPermissionsHandler> BypassPermissionsCheckFunctions = new List<BypassPermissionsHandler>();
  100. public void AddBypassPermissionsHandler(BypassPermissionsHandler delegateFunc)
  101. {
  102. if (!BypassPermissionsCheckFunctions.Contains(delegateFunc))
  103. BypassPermissionsCheckFunctions.Add(delegateFunc);
  104. }
  105. public void RemoveBypassPermissionsHandler(BypassPermissionsHandler delegateFunc)
  106. {
  107. if (BypassPermissionsCheckFunctions.Contains(delegateFunc))
  108. BypassPermissionsCheckFunctions.Remove(delegateFunc);
  109. }
  110. public bool BypassPermissions()
  111. {
  112. foreach (BypassPermissionsHandler check in BypassPermissionsCheckFunctions)
  113. {
  114. if (check() == false)
  115. {
  116. return false;
  117. }
  118. }
  119. return true;
  120. }
  121. public delegate bool PropagatePermissionsHandler();
  122. private List<PropagatePermissionsHandler> PropagatePermissionsCheckFunctions = new List<PropagatePermissionsHandler>();
  123. public void AddPropagatePermissionsHandler(PropagatePermissionsHandler delegateFunc)
  124. {
  125. if (!PropagatePermissionsCheckFunctions.Contains(delegateFunc))
  126. PropagatePermissionsCheckFunctions.Add(delegateFunc);
  127. }
  128. public void RemovePropagatePermissionsHandler(PropagatePermissionsHandler delegateFunc)
  129. {
  130. if (PropagatePermissionsCheckFunctions.Contains(delegateFunc))
  131. PropagatePermissionsCheckFunctions.Remove(delegateFunc);
  132. }
  133. public bool PropagatePermissions()
  134. {
  135. foreach (PropagatePermissionsHandler check in PropagatePermissionsCheckFunctions)
  136. {
  137. if (check() == false)
  138. {
  139. return false;
  140. }
  141. }
  142. return true;
  143. }
  144. #region REZ OBJECT
  145. public delegate bool CanRezObjectHandler(int objectCount, UUID owner, Vector3 objectPosition, Scene scene);
  146. private List<CanRezObjectHandler> CanRezObjectCheckFunctions = new List<CanRezObjectHandler>();
  147. public void AddRezObjectHandler(CanRezObjectHandler delegateFunc)
  148. {
  149. if (!CanRezObjectCheckFunctions.Contains(delegateFunc))
  150. CanRezObjectCheckFunctions.Add(delegateFunc);
  151. }
  152. public void RemoveRezObjectHandler(CanRezObjectHandler delegateFunc)
  153. {
  154. if (CanRezObjectCheckFunctions.Contains(delegateFunc))
  155. CanRezObjectCheckFunctions.Remove(delegateFunc);
  156. }
  157. public bool CanRezObject(int objectCount, UUID owner, Vector3 objectPosition)
  158. {
  159. foreach (CanRezObjectHandler check in CanRezObjectCheckFunctions)
  160. {
  161. if (check(objectCount, owner,objectPosition, m_scene) == false)
  162. {
  163. return false;
  164. }
  165. }
  166. return true;
  167. }
  168. #endregion
  169. #region DELETE OBJECT
  170. public delegate bool CanDeleteObjectHandler(UUID objectID, UUID deleter, Scene scene);
  171. private List<CanDeleteObjectHandler> CanDeleteObjectCheckFunctions = new List<CanDeleteObjectHandler>();
  172. public void AddDeleteObjectHandler(CanDeleteObjectHandler delegateFunc)
  173. {
  174. if (!CanDeleteObjectCheckFunctions.Contains(delegateFunc))
  175. CanDeleteObjectCheckFunctions.Add(delegateFunc);
  176. }
  177. public void RemoveDeleteObjectHandler(CanDeleteObjectHandler delegateFunc)
  178. {
  179. if (CanDeleteObjectCheckFunctions.Contains(delegateFunc))
  180. CanDeleteObjectCheckFunctions.Remove(delegateFunc);
  181. }
  182. public bool CanDeleteObject(UUID objectID, UUID deleter)
  183. {
  184. foreach (CanDeleteObjectHandler check in CanDeleteObjectCheckFunctions)
  185. {
  186. if (check(objectID,deleter,m_scene) == false)
  187. {
  188. return false;
  189. }
  190. }
  191. return true;
  192. }
  193. #endregion
  194. #region TAKE OBJECT
  195. public delegate bool CanTakeObjectHandler(UUID objectID, UUID stealer, Scene scene);
  196. private List<CanTakeObjectHandler> CanTakeObjectCheckFunctions = new List<CanTakeObjectHandler>();
  197. public void AddTakeObjectHandler(CanTakeObjectHandler delegateFunc)
  198. {
  199. if (!CanTakeObjectCheckFunctions.Contains(delegateFunc))
  200. CanTakeObjectCheckFunctions.Add(delegateFunc);
  201. }
  202. public void RemoveTakeObjectHandler(CanTakeObjectHandler delegateFunc)
  203. {
  204. if (CanTakeObjectCheckFunctions.Contains(delegateFunc))
  205. CanTakeObjectCheckFunctions.Remove(delegateFunc);
  206. }
  207. public bool CanTakeObject(UUID objectID, UUID AvatarTakingUUID)
  208. {
  209. foreach (CanTakeObjectHandler check in CanTakeObjectCheckFunctions)
  210. {
  211. if (check(objectID, AvatarTakingUUID, m_scene) == false)
  212. {
  213. return false;
  214. }
  215. }
  216. return true;
  217. }
  218. #endregion
  219. #region TAKE COPY OBJECT
  220. public delegate bool CanTakeCopyObjectHandler(UUID objectID, UUID userID, Scene inScene);
  221. private List<CanTakeCopyObjectHandler> CanTakeCopyObjectCheckFunctions = new List<CanTakeCopyObjectHandler>();
  222. public void AddTakeCopyObjectHandler(CanTakeCopyObjectHandler delegateFunc)
  223. {
  224. if (!CanTakeCopyObjectCheckFunctions.Contains(delegateFunc))
  225. CanTakeCopyObjectCheckFunctions.Add(delegateFunc);
  226. }
  227. public void RemoveTakeCopyObjectHandler(CanTakeCopyObjectHandler delegateFunc)
  228. {
  229. if (CanTakeCopyObjectCheckFunctions.Contains(delegateFunc))
  230. CanTakeCopyObjectCheckFunctions.Remove(delegateFunc);
  231. }
  232. public bool CanTakeCopyObject(UUID objectID, UUID userID)
  233. {
  234. foreach (CanTakeCopyObjectHandler check in CanTakeCopyObjectCheckFunctions)
  235. {
  236. if (check(objectID,userID,m_scene) == false)
  237. {
  238. return false;
  239. }
  240. }
  241. return true;
  242. }
  243. #endregion
  244. #region DUPLICATE OBJECT
  245. public delegate bool CanDuplicateObjectHandler(int objectCount, UUID objectID, UUID owner, Scene scene, Vector3 objectPosition);
  246. private List<CanDuplicateObjectHandler> CanDuplicateObjectCheckFunctions = new List<CanDuplicateObjectHandler>();
  247. public void AddDuplicateObjectHandler(CanDuplicateObjectHandler delegateFunc)
  248. {
  249. if (!CanDuplicateObjectCheckFunctions.Contains(delegateFunc))
  250. CanDuplicateObjectCheckFunctions.Add(delegateFunc);
  251. }
  252. public void RemoveDuplicateObjectHandler(CanDuplicateObjectHandler delegateFunc)
  253. {
  254. if (CanDuplicateObjectCheckFunctions.Contains(delegateFunc))
  255. CanDuplicateObjectCheckFunctions.Remove(delegateFunc);
  256. }
  257. public bool CanDuplicateObject(int objectCount, UUID objectID, UUID owner, Vector3 objectPosition)
  258. {
  259. foreach (CanDuplicateObjectHandler check in CanDuplicateObjectCheckFunctions)
  260. {
  261. if (check(objectCount, objectID, owner, m_scene, objectPosition) == false)
  262. {
  263. return false;
  264. }
  265. }
  266. return true;
  267. }
  268. #endregion
  269. #region EDIT OBJECT
  270. public delegate bool CanEditObjectHandler(UUID objectID, UUID editorID, Scene scene);
  271. private List<CanEditObjectHandler> CanEditObjectCheckFunctions = new List<CanEditObjectHandler>();
  272. public void AddEditObjectHandler(CanEditObjectHandler delegateFunc)
  273. {
  274. if (!CanEditObjectCheckFunctions.Contains(delegateFunc))
  275. CanEditObjectCheckFunctions.Add(delegateFunc);
  276. }
  277. public void RemoveEditObjectHandler(CanEditObjectHandler delegateFunc)
  278. {
  279. if (CanEditObjectCheckFunctions.Contains(delegateFunc))
  280. CanEditObjectCheckFunctions.Remove(delegateFunc);
  281. }
  282. public bool CanEditObject(UUID objectID, UUID editorID)
  283. {
  284. foreach (CanEditObjectHandler check in CanEditObjectCheckFunctions)
  285. {
  286. if (check(objectID, editorID, m_scene) == false)
  287. {
  288. return false;
  289. }
  290. }
  291. return true;
  292. }
  293. public delegate bool CanEditObjectInventoryHandler(UUID objectID, UUID editorID, Scene scene);
  294. private List<CanEditObjectInventoryHandler> CanEditObjectInventoryCheckFunctions = new List<CanEditObjectInventoryHandler>();
  295. public void AddEditObjectInventoryHandler(CanEditObjectInventoryHandler delegateFunc)
  296. {
  297. if (!CanEditObjectInventoryCheckFunctions.Contains(delegateFunc))
  298. CanEditObjectInventoryCheckFunctions.Add(delegateFunc);
  299. }
  300. public void RemoveEditObjectInventoryHandler(CanEditObjectInventoryHandler delegateFunc)
  301. {
  302. if (CanEditObjectInventoryCheckFunctions.Contains(delegateFunc))
  303. CanEditObjectInventoryCheckFunctions.Remove(delegateFunc);
  304. }
  305. public bool CanEditObjectInventory(UUID objectID, UUID editorID)
  306. {
  307. foreach (CanEditObjectInventoryHandler check in CanEditObjectInventoryCheckFunctions)
  308. {
  309. if (check(objectID, editorID, m_scene) == false)
  310. {
  311. return false;
  312. }
  313. }
  314. return true;
  315. }
  316. #endregion
  317. #region MOVE OBJECT
  318. public delegate bool CanMoveObjectHandler(UUID objectID, UUID moverID, Scene scene);
  319. private List<CanMoveObjectHandler> CanMoveObjectCheckFunctions = new List<CanMoveObjectHandler>();
  320. public void AddMoveObjectHandler(CanMoveObjectHandler delegateFunc)
  321. {
  322. if (!CanMoveObjectCheckFunctions.Contains(delegateFunc))
  323. CanMoveObjectCheckFunctions.Add(delegateFunc);
  324. }
  325. public void RemoveMoveObjectHandler(CanMoveObjectHandler delegateFunc)
  326. {
  327. if (CanMoveObjectCheckFunctions.Contains(delegateFunc))
  328. CanMoveObjectCheckFunctions.Remove(delegateFunc);
  329. }
  330. public bool CanMoveObject(UUID objectID, UUID moverID)
  331. {
  332. foreach (CanMoveObjectHandler check in CanMoveObjectCheckFunctions)
  333. {
  334. if (check(objectID,moverID,m_scene) == false)
  335. {
  336. return false;
  337. }
  338. }
  339. return true;
  340. }
  341. #endregion
  342. #region OBJECT ENTRY
  343. public delegate bool CanObjectEntryHandler(UUID objectID, bool enteringRegion, Vector3 newPoint, Scene scene);
  344. private List<CanObjectEntryHandler> CanObjectEntryCheckFunctions = new List<CanObjectEntryHandler>();
  345. public void AddObjectEntryHandler(CanObjectEntryHandler delegateFunc)
  346. {
  347. if (!CanObjectEntryCheckFunctions.Contains(delegateFunc))
  348. CanObjectEntryCheckFunctions.Add(delegateFunc);
  349. }
  350. public void RemoveObjectEntryHandler(CanObjectEntryHandler delegateFunc)
  351. {
  352. if (CanObjectEntryCheckFunctions.Contains(delegateFunc))
  353. CanObjectEntryCheckFunctions.Remove(delegateFunc);
  354. }
  355. public bool CanObjectEntry(UUID objectID, bool enteringRegion, Vector3 newPoint)
  356. {
  357. foreach (CanObjectEntryHandler check in CanObjectEntryCheckFunctions)
  358. {
  359. if (check(objectID, enteringRegion, newPoint, m_scene) == false)
  360. {
  361. return false;
  362. }
  363. }
  364. return true;
  365. }
  366. #endregion
  367. #region RETURN OBJECT
  368. public delegate bool CanReturnObjectHandler(UUID objectID, UUID returnerID, Scene scene);
  369. private List<CanReturnObjectHandler> CanReturnObjectCheckFunctions = new List<CanReturnObjectHandler>();
  370. public void AddReturnObjectHandler(CanReturnObjectHandler delegateFunc)
  371. {
  372. if (!CanReturnObjectCheckFunctions.Contains(delegateFunc))
  373. CanReturnObjectCheckFunctions.Add(delegateFunc);
  374. }
  375. public void RemoveReturnObjectHandler(CanReturnObjectHandler delegateFunc)
  376. {
  377. if (CanReturnObjectCheckFunctions.Contains(delegateFunc))
  378. CanReturnObjectCheckFunctions.Remove(delegateFunc);
  379. }
  380. public bool CanReturnObject(UUID objectID, UUID returnerID)
  381. {
  382. foreach (CanReturnObjectHandler check in CanReturnObjectCheckFunctions)
  383. {
  384. if (check(objectID,returnerID,m_scene) == false)
  385. {
  386. return false;
  387. }
  388. }
  389. return true;
  390. }
  391. #endregion
  392. #region INSTANT MESSAGE
  393. public delegate bool CanInstantMessageHandler(UUID user, UUID target, Scene startScene);
  394. private List<CanInstantMessageHandler> CanInstantMessageCheckFunctions = new List<CanInstantMessageHandler>();
  395. public void AddInstantMessageHandler(CanInstantMessageHandler delegateFunc)
  396. {
  397. if (!CanInstantMessageCheckFunctions.Contains(delegateFunc))
  398. CanInstantMessageCheckFunctions.Add(delegateFunc);
  399. }
  400. public void RemoveInstantMessageHandler(CanInstantMessageHandler delegateFunc)
  401. {
  402. if (CanInstantMessageCheckFunctions.Contains(delegateFunc))
  403. CanInstantMessageCheckFunctions.Remove(delegateFunc);
  404. }
  405. public bool CanInstantMessage(UUID user, UUID target)
  406. {
  407. foreach (CanInstantMessageHandler check in CanInstantMessageCheckFunctions)
  408. {
  409. if (check(user, target, m_scene) == false)
  410. {
  411. return false;
  412. }
  413. }
  414. return true;
  415. }
  416. #endregion
  417. #region INVENTORY TRANSFER
  418. public delegate bool CanInventoryTransferHandler(UUID user, UUID target, Scene startScene);
  419. private List<CanInventoryTransferHandler> CanInventoryTransferCheckFunctions = new List<CanInventoryTransferHandler>();
  420. public void AddInventoryTransferHandler(CanInventoryTransferHandler delegateFunc)
  421. {
  422. if (!CanInventoryTransferCheckFunctions.Contains(delegateFunc))
  423. CanInventoryTransferCheckFunctions.Add(delegateFunc);
  424. }
  425. public void RemoveInventoryTransferHandler(CanInventoryTransferHandler delegateFunc)
  426. {
  427. if (CanInventoryTransferCheckFunctions.Contains(delegateFunc))
  428. CanInventoryTransferCheckFunctions.Remove(delegateFunc);
  429. }
  430. public bool CanInventoryTransfer(UUID user, UUID target)
  431. {
  432. foreach (CanInventoryTransferHandler check in CanInventoryTransferCheckFunctions)
  433. {
  434. if (check(user, target, m_scene) == false)
  435. {
  436. return false;
  437. }
  438. }
  439. return true;
  440. }
  441. #endregion
  442. #region VIEW SCRIPT
  443. public delegate bool CanViewScriptHandler(UUID script, UUID objectID, UUID user, Scene scene);
  444. private List<CanViewScriptHandler> CanViewScriptCheckFunctions = new List<CanViewScriptHandler>();
  445. public void AddViewScriptHandler(CanViewScriptHandler delegateFunc)
  446. {
  447. if (!CanViewScriptCheckFunctions.Contains(delegateFunc))
  448. CanViewScriptCheckFunctions.Add(delegateFunc);
  449. }
  450. public void RemoveViewScriptHandler(CanViewScriptHandler delegateFunc)
  451. {
  452. if (CanViewScriptCheckFunctions.Contains(delegateFunc))
  453. CanViewScriptCheckFunctions.Remove(delegateFunc);
  454. }
  455. public bool CanViewScript(UUID script, UUID objectID, UUID user)
  456. {
  457. foreach (CanViewScriptHandler check in CanViewScriptCheckFunctions)
  458. {
  459. if (check(script, objectID, user, m_scene) == false)
  460. {
  461. return false;
  462. }
  463. }
  464. return true;
  465. }
  466. public delegate bool CanViewNotecardHandler(UUID script, UUID objectID, UUID user, Scene scene);
  467. private List<CanViewNotecardHandler> CanViewNotecardCheckFunctions = new List<CanViewNotecardHandler>();
  468. public void AddViewNotecardHandler(CanViewNotecardHandler delegateFunc)
  469. {
  470. if (!CanViewNotecardCheckFunctions.Contains(delegateFunc))
  471. CanViewNotecardCheckFunctions.Add(delegateFunc);
  472. }
  473. public void RemoveViewNotecardHandler(CanViewNotecardHandler delegateFunc)
  474. {
  475. if (CanViewNotecardCheckFunctions.Contains(delegateFunc))
  476. CanViewNotecardCheckFunctions.Remove(delegateFunc);
  477. }
  478. public bool CanViewNotecard(UUID script, UUID objectID, UUID user)
  479. {
  480. foreach (CanViewNotecardHandler check in CanViewNotecardCheckFunctions)
  481. {
  482. if (check(script, objectID, user, m_scene) == false)
  483. {
  484. return false;
  485. }
  486. }
  487. return true;
  488. }
  489. #endregion
  490. #region EDIT SCRIPT
  491. public delegate bool CanEditScriptHandler(UUID script, UUID objectID, UUID user, Scene scene);
  492. private List<CanEditScriptHandler> CanEditScriptCheckFunctions = new List<CanEditScriptHandler>();
  493. public void AddEditScriptHandler(CanEditScriptHandler delegateFunc)
  494. {
  495. if (!CanEditScriptCheckFunctions.Contains(delegateFunc))
  496. CanEditScriptCheckFunctions.Add(delegateFunc);
  497. }
  498. public void RemoveEditScriptHandler(CanEditScriptHandler delegateFunc)
  499. {
  500. if (CanEditScriptCheckFunctions.Contains(delegateFunc))
  501. CanEditScriptCheckFunctions.Remove(delegateFunc);
  502. }
  503. public bool CanEditScript(UUID script, UUID objectID, UUID user)
  504. {
  505. foreach (CanEditScriptHandler check in CanEditScriptCheckFunctions)
  506. {
  507. if (check(script, objectID, user, m_scene) == false)
  508. {
  509. return false;
  510. }
  511. }
  512. return true;
  513. }
  514. public delegate bool CanEditNotecardHandler(UUID notecard, UUID objectID, UUID user, Scene scene);
  515. private List<CanEditNotecardHandler> CanEditNotecardCheckFunctions = new List<CanEditNotecardHandler>();
  516. public void AddEditNotecardHandler(CanEditNotecardHandler delegateFunc)
  517. {
  518. if (!CanEditNotecardCheckFunctions.Contains(delegateFunc))
  519. CanEditNotecardCheckFunctions.Add(delegateFunc);
  520. }
  521. public void RemoveEditNotecardHandler(CanEditNotecardHandler delegateFunc)
  522. {
  523. if (CanEditNotecardCheckFunctions.Contains(delegateFunc))
  524. CanEditNotecardCheckFunctions.Remove(delegateFunc);
  525. }
  526. public bool CanEditNotecard(UUID script, UUID objectID, UUID user)
  527. {
  528. foreach (CanEditNotecardHandler check in CanEditNotecardCheckFunctions)
  529. {
  530. if (check(script, objectID, user, m_scene) == false)
  531. {
  532. return false;
  533. }
  534. }
  535. return true;
  536. }
  537. #endregion
  538. #region RUN SCRIPT (When Script Placed in Object)
  539. public delegate bool CanRunScriptHandler(UUID script, UUID objectID, UUID user, Scene scene);
  540. private List<CanRunScriptHandler> CanRunScriptCheckFunctions = new List<CanRunScriptHandler>();
  541. public void AddRunScriptHandler(CanRunScriptHandler delegateFunc)
  542. {
  543. if (!CanRunScriptCheckFunctions.Contains(delegateFunc))
  544. CanRunScriptCheckFunctions.Add(delegateFunc);
  545. }
  546. public void RemoveRunScriptHandler(CanRunScriptHandler delegateFunc)
  547. {
  548. if (CanRunScriptCheckFunctions.Contains(delegateFunc))
  549. CanRunScriptCheckFunctions.Remove(delegateFunc);
  550. }
  551. public bool CanRunScript(UUID script, UUID objectID, UUID user)
  552. {
  553. foreach (CanRunScriptHandler check in CanRunScriptCheckFunctions)
  554. {
  555. if (check(script, objectID, user, m_scene) == false)
  556. {
  557. return false;
  558. }
  559. }
  560. return true;
  561. }
  562. #endregion
  563. #region START SCRIPT (When Script run box is Checked after placed in object)
  564. public delegate bool CanStartScriptHandler(UUID script, UUID user, Scene scene);
  565. private List<CanStartScriptHandler> CanStartScriptCheckFunctions = new List<CanStartScriptHandler>();
  566. public void AddStartScriptHandler(CanStartScriptHandler delegateFunc)
  567. {
  568. if (!CanStartScriptCheckFunctions.Contains(delegateFunc))
  569. CanStartScriptCheckFunctions.Add(delegateFunc);
  570. }
  571. public void RemoveStartScriptHandler(CanStartScriptHandler delegateFunc)
  572. {
  573. if (CanStartScriptCheckFunctions.Contains(delegateFunc))
  574. CanStartScriptCheckFunctions.Remove(delegateFunc);
  575. }
  576. public bool CanStartScript(UUID script, UUID user)
  577. {
  578. foreach (CanStartScriptHandler check in CanStartScriptCheckFunctions)
  579. {
  580. if (check(script, user, m_scene) == false)
  581. {
  582. return false;
  583. }
  584. }
  585. return true;
  586. }
  587. #endregion
  588. #region STOP SCRIPT (When Script run box is unchecked after placed in object)
  589. public delegate bool CanStopScriptHandler(UUID script, UUID user, Scene scene);
  590. private List<CanStopScriptHandler> CanStopScriptCheckFunctions = new List<CanStopScriptHandler>();
  591. public void AddStopScriptHandler(CanStopScriptHandler delegateFunc)
  592. {
  593. if (!CanStopScriptCheckFunctions.Contains(delegateFunc))
  594. CanStopScriptCheckFunctions.Add(delegateFunc);
  595. }
  596. public void RemoveStopScriptHandler(CanStopScriptHandler delegateFunc)
  597. {
  598. if (CanStopScriptCheckFunctions.Contains(delegateFunc))
  599. CanStopScriptCheckFunctions.Remove(delegateFunc);
  600. }
  601. public bool CanStopScript(UUID script, UUID user)
  602. {
  603. foreach (CanStopScriptHandler check in CanStopScriptCheckFunctions)
  604. {
  605. if (check(script, user, m_scene) == false)
  606. {
  607. return false;
  608. }
  609. }
  610. return true;
  611. }
  612. #endregion
  613. #region RESET SCRIPT
  614. public delegate bool CanResetScriptHandler(UUID prim, UUID script, UUID user, Scene scene);
  615. private List<CanResetScriptHandler> CanResetScriptCheckFunctions = new List<CanResetScriptHandler>();
  616. public void AddResetScriptHandler(CanResetScriptHandler delegateFunc)
  617. {
  618. if (!CanResetScriptCheckFunctions.Contains(delegateFunc))
  619. CanResetScriptCheckFunctions.Add(delegateFunc);
  620. }
  621. public void RemoveResetScriptHandler(CanResetScriptHandler delegateFunc)
  622. {
  623. if (CanResetScriptCheckFunctions.Contains(delegateFunc))
  624. CanResetScriptCheckFunctions.Remove(delegateFunc);
  625. }
  626. public bool CanResetScript(UUID prim, UUID script, UUID user)
  627. {
  628. foreach (CanResetScriptHandler check in CanResetScriptCheckFunctions)
  629. {
  630. if (check(prim, script, user, m_scene) == false)
  631. {
  632. return false;
  633. }
  634. }
  635. return true;
  636. }
  637. #endregion
  638. #region TERRAFORM LAND
  639. public delegate bool CanTerraformLandHandler(UUID user, Vector3 position, Scene requestFromScene);
  640. private List<CanTerraformLandHandler> CanTerraformLandCheckFunctions = new List<CanTerraformLandHandler>();
  641. public void AddTerraformLandHandler(CanTerraformLandHandler delegateFunc)
  642. {
  643. if (!CanTerraformLandCheckFunctions.Contains(delegateFunc))
  644. CanTerraformLandCheckFunctions.Add(delegateFunc);
  645. }
  646. public void RemoveTerraformLandHandler(CanTerraformLandHandler delegateFunc)
  647. {
  648. if (CanTerraformLandCheckFunctions.Contains(delegateFunc))
  649. CanTerraformLandCheckFunctions.Remove(delegateFunc);
  650. }
  651. public bool CanTerraformLand(UUID user, Vector3 pos)
  652. {
  653. foreach (CanTerraformLandHandler check in CanTerraformLandCheckFunctions)
  654. {
  655. if (check(user, pos, m_scene) == false)
  656. {
  657. return false;
  658. }
  659. }
  660. return true;
  661. }
  662. #endregion
  663. #region RUN CONSOLE COMMAND
  664. public delegate bool CanRunConsoleCommandHandler(UUID user, Scene requestFromScene);
  665. private List<CanRunConsoleCommandHandler> CanRunConsoleCommandCheckFunctions = new List<CanRunConsoleCommandHandler>();
  666. public void AddRunConsoleCommandHandler(CanRunConsoleCommandHandler delegateFunc)
  667. {
  668. if (!CanRunConsoleCommandCheckFunctions.Contains(delegateFunc))
  669. CanRunConsoleCommandCheckFunctions.Add(delegateFunc);
  670. }
  671. public void RemoveRunConsoleCommandHandler(CanRunConsoleCommandHandler delegateFunc)
  672. {
  673. if (CanRunConsoleCommandCheckFunctions.Contains(delegateFunc))
  674. CanRunConsoleCommandCheckFunctions.Remove(delegateFunc);
  675. }
  676. public bool CanRunConsoleCommand(UUID user)
  677. {
  678. foreach (CanRunConsoleCommandHandler check in CanRunConsoleCommandCheckFunctions)
  679. {
  680. if (check(user, m_scene) == false)
  681. {
  682. return false;
  683. }
  684. }
  685. return true;
  686. }
  687. #endregion
  688. #region CAN ISSUE ESTATE COMMAND
  689. public delegate bool CanIssueEstateCommandHandler(UUID user, Scene requestFromScene, bool ownerCommand);
  690. private List<CanIssueEstateCommandHandler> CanIssueEstateCommandCheckFunctions = new List<CanIssueEstateCommandHandler>();
  691. public void AddIssueEstateCommandHandler(CanIssueEstateCommandHandler delegateFunc)
  692. {
  693. if (!CanIssueEstateCommandCheckFunctions.Contains(delegateFunc))
  694. CanIssueEstateCommandCheckFunctions.Add(delegateFunc);
  695. }
  696. public void RemoveIssueEstateCommandHandler(CanIssueEstateCommandHandler delegateFunc)
  697. {
  698. if (CanIssueEstateCommandCheckFunctions.Contains(delegateFunc))
  699. CanIssueEstateCommandCheckFunctions.Remove(delegateFunc);
  700. }
  701. public bool CanIssueEstateCommand(UUID user, bool ownerCommand)
  702. {
  703. foreach (CanIssueEstateCommandHandler check in CanIssueEstateCommandCheckFunctions)
  704. {
  705. if (check(user, m_scene, ownerCommand) == false)
  706. {
  707. return false;
  708. }
  709. }
  710. return true;
  711. }
  712. #endregion
  713. #region CAN BE GODLIKE
  714. public delegate bool IsGodHandler(UUID user, Scene requestFromScene);
  715. private List<IsGodHandler> IsGodCheckFunctions = new List<IsGodHandler>();
  716. public void AddIsGodHandler(IsGodHandler delegateFunc)
  717. {
  718. if (!IsGodCheckFunctions.Contains(delegateFunc))
  719. IsGodCheckFunctions.Add(delegateFunc);
  720. }
  721. public void RemoveIsGodHandler(IsGodHandler delegateFunc)
  722. {
  723. if (IsGodCheckFunctions.Contains(delegateFunc))
  724. IsGodCheckFunctions.Remove(delegateFunc);
  725. }
  726. public bool IsGod(UUID user)
  727. {
  728. foreach (IsGodHandler check in IsGodCheckFunctions)
  729. {
  730. if (check(user, m_scene) == false)
  731. {
  732. return false;
  733. }
  734. }
  735. return true;
  736. }
  737. #endregion
  738. #region EDIT PARCEL
  739. public delegate bool CanEditParcelHandler(UUID user, ILandObject parcel, Scene scene);
  740. private List<CanEditParcelHandler> CanEditParcelCheckFunctions = new List<CanEditParcelHandler>();
  741. public void AddEditParcelHandler(CanEditParcelHandler delegateFunc)
  742. {
  743. if (!CanEditParcelCheckFunctions.Contains(delegateFunc))
  744. CanEditParcelCheckFunctions.Add(delegateFunc);
  745. }
  746. public void RemoveEditParcelHandler(CanEditParcelHandler delegateFunc)
  747. {
  748. if (CanEditParcelCheckFunctions.Contains(delegateFunc))
  749. CanEditParcelCheckFunctions.Remove(delegateFunc);
  750. }
  751. public bool CanEditParcel(UUID user, ILandObject parcel)
  752. {
  753. foreach (CanEditParcelHandler check in CanEditParcelCheckFunctions)
  754. {
  755. if (check(user, parcel, m_scene) == false)
  756. {
  757. return false;
  758. }
  759. }
  760. return true;
  761. }
  762. #endregion
  763. #region SELL PARCEL
  764. public delegate bool CanSellParcelHandler(UUID user, ILandObject parcel, Scene scene);
  765. private List<CanSellParcelHandler> CanSellParcelCheckFunctions = new List<CanSellParcelHandler>();
  766. public void AddSellParcelHandler(CanSellParcelHandler delegateFunc)
  767. {
  768. if (!CanSellParcelCheckFunctions.Contains(delegateFunc))
  769. CanSellParcelCheckFunctions.Add(delegateFunc);
  770. }
  771. public void RemoveSellParcelHandler(CanSellParcelHandler delegateFunc)
  772. {
  773. if (CanSellParcelCheckFunctions.Contains(delegateFunc))
  774. CanSellParcelCheckFunctions.Remove(delegateFunc);
  775. }
  776. public bool CanSellParcel(UUID user, ILandObject parcel)
  777. {
  778. foreach (CanSellParcelHandler check in CanSellParcelCheckFunctions)
  779. {
  780. if (check(user, parcel, m_scene) == false)
  781. {
  782. return false;
  783. }
  784. }
  785. return true;
  786. }
  787. #endregion
  788. #region ABANDON PARCEL
  789. public delegate bool CanAbandonParcelHandler(UUID user, ILandObject parcel, Scene scene);
  790. private List<CanAbandonParcelHandler> CanAbandonParcelCheckFunctions = new List<CanAbandonParcelHandler>();
  791. public void AddAbandonParcelHandler(CanAbandonParcelHandler delegateFunc)
  792. {
  793. if (!CanAbandonParcelCheckFunctions.Contains(delegateFunc))
  794. CanAbandonParcelCheckFunctions.Add(delegateFunc);
  795. }
  796. public void RemoveAbandonParcelHandler(CanAbandonParcelHandler delegateFunc)
  797. {
  798. if (CanAbandonParcelCheckFunctions.Contains(delegateFunc))
  799. CanAbandonParcelCheckFunctions.Remove(delegateFunc);
  800. }
  801. public bool CanAbandonParcel(UUID user, ILandObject parcel)
  802. {
  803. foreach (CanAbandonParcelHandler check in CanAbandonParcelCheckFunctions)
  804. {
  805. if (check(user, parcel, m_scene) == false)
  806. {
  807. return false;
  808. }
  809. }
  810. return true;
  811. }
  812. #endregion
  813. public delegate bool CanReclaimParcelHandler(UUID user, ILandObject parcel, Scene scene);
  814. private List<CanReclaimParcelHandler> CanReclaimParcelCheckFunctions = new List<CanReclaimParcelHandler>();
  815. public void AddReclaimParcelHandler(CanReclaimParcelHandler delegateFunc)
  816. {
  817. if (!CanReclaimParcelCheckFunctions.Contains(delegateFunc))
  818. CanReclaimParcelCheckFunctions.Add(delegateFunc);
  819. }
  820. public void RemoveReclaimParcelHandler(CanReclaimParcelHandler delegateFunc)
  821. {
  822. if (CanReclaimParcelCheckFunctions.Contains(delegateFunc))
  823. CanReclaimParcelCheckFunctions.Remove(delegateFunc);
  824. }
  825. public bool CanReclaimParcel(UUID user, ILandObject parcel)
  826. {
  827. foreach (CanReclaimParcelHandler check in CanReclaimParcelCheckFunctions)
  828. {
  829. if (check(user, parcel, m_scene) == false)
  830. {
  831. return false;
  832. }
  833. }
  834. return true;
  835. }
  836. public delegate bool CanBuyLandHandler(UUID user, ILandObject parcel, Scene scene);
  837. private List<CanBuyLandHandler> CanBuyLandCheckFunctions = new List<CanBuyLandHandler>();
  838. public void AddCanBuyLandHandler(CanBuyLandHandler delegateFunc)
  839. {
  840. if (!CanBuyLandCheckFunctions.Contains(delegateFunc))
  841. CanBuyLandCheckFunctions.Add(delegateFunc);
  842. }
  843. public void RemoveCanBuyLandHandler(CanBuyLandHandler delegateFunc)
  844. {
  845. if (CanBuyLandCheckFunctions.Contains(delegateFunc))
  846. CanBuyLandCheckFunctions.Remove(delegateFunc);
  847. }
  848. public bool CanBuyLand(UUID user, ILandObject parcel)
  849. {
  850. foreach (CanBuyLandHandler check in CanBuyLandCheckFunctions)
  851. {
  852. if (check(user, parcel, m_scene) == false)
  853. {
  854. return false;
  855. }
  856. }
  857. return true;
  858. }
  859. public delegate bool CanLinkObjectHandler(UUID user, UUID objectID);
  860. private List<CanLinkObjectHandler> CanLinkObjectCheckFunctions = new List<CanLinkObjectHandler>();
  861. public void AddCanLinkObjectHandler(CanLinkObjectHandler delegateFunc)
  862. {
  863. if (!CanLinkObjectCheckFunctions.Contains(delegateFunc))
  864. CanLinkObjectCheckFunctions.Add(delegateFunc);
  865. }
  866. public void RemoveCanLinkObjectHandler(CanLinkObjectHandler delegateFunc)
  867. {
  868. if (CanLinkObjectCheckFunctions.Contains(delegateFunc))
  869. CanLinkObjectCheckFunctions.Remove(delegateFunc);
  870. }
  871. public bool CanLinkObject(UUID user, UUID objectID)
  872. {
  873. foreach (CanLinkObjectHandler check in CanLinkObjectCheckFunctions)
  874. {
  875. if (check(user, objectID) == false)
  876. {
  877. return false;
  878. }
  879. }
  880. return true;
  881. }
  882. public delegate bool CanDelinkObjectHandler(UUID user, UUID objectID);
  883. private List<CanDelinkObjectHandler> CanDelinkObjectCheckFunctions = new List<CanDelinkObjectHandler>();
  884. public void AddCanDelinkObjectHandler(CanDelinkObjectHandler delegateFunc)
  885. {
  886. if (!CanDelinkObjectCheckFunctions.Contains(delegateFunc))
  887. CanDelinkObjectCheckFunctions.Add(delegateFunc);
  888. }
  889. public void RemoveCanDelinkObjectHandler(CanDelinkObjectHandler delegateFunc)
  890. {
  891. if (CanDelinkObjectCheckFunctions.Contains(delegateFunc))
  892. CanDelinkObjectCheckFunctions.Remove(delegateFunc);
  893. }
  894. public bool CanDelinkObject(UUID user, UUID objectID)
  895. {
  896. foreach (CanDelinkObjectHandler check in CanDelinkObjectCheckFunctions)
  897. {
  898. if (check(user, objectID) == false)
  899. {
  900. return false;
  901. }
  902. }
  903. return true;
  904. }
  905. #endregion
  906. public delegate bool CanCreateObjectInventoryHandler(int invType, UUID objectID, UUID userID);
  907. private List<CanCreateObjectInventoryHandler> CanCreateObjectInventoryCheckFunctions
  908. = new List<CanCreateObjectInventoryHandler>();
  909. public void AddCanCreateObjectInventoryHandler(CanCreateObjectInventoryHandler delegateFunc)
  910. {
  911. if (!CanCreateObjectInventoryCheckFunctions.Contains(delegateFunc))
  912. CanCreateObjectInventoryCheckFunctions.Add(delegateFunc);
  913. }
  914. public void RemoveCanCreateObjectInventoryHandler(CanCreateObjectInventoryHandler delegateFunc)
  915. {
  916. if (CanCreateObjectInventoryCheckFunctions.Contains(delegateFunc))
  917. CanCreateObjectInventoryCheckFunctions.Remove(delegateFunc);
  918. }
  919. /// <summary>
  920. /// Check whether the specified user is allowed to directly create the given inventory type in a prim's
  921. /// inventory (e.g. the New Script button in the 1.21 Linden Lab client).
  922. /// </summary>
  923. /// <param name="invType"></param>
  924. /// <param name="objectID"></param>
  925. /// <param name="userID"></param>
  926. /// <returns></returns>
  927. public bool CanCreateObjectInventory(int invType, UUID objectID, UUID userID)
  928. {
  929. foreach (CanCreateObjectInventoryHandler check in CanCreateObjectInventoryCheckFunctions)
  930. {
  931. if (check(invType, objectID, userID) == false)
  932. {
  933. return false;
  934. }
  935. }
  936. return true;
  937. }
  938. public delegate bool CanCopyObjectInventoryHandler(UUID itemID, UUID objectID, UUID userID);
  939. private List<CanCopyObjectInventoryHandler> CanCopyObjectInventoryCheckFunctions = new List<CanCopyObjectInventoryHandler>();
  940. public void AddCanCopyObjectInventoryHandler(CanCopyObjectInventoryHandler delegateFunc)
  941. {
  942. if (!CanCopyObjectInventoryCheckFunctions.Contains(delegateFunc))
  943. CanCopyObjectInventoryCheckFunctions.Add(delegateFunc);
  944. }
  945. public void RemoveCanCopyObjectInventoryHandler(CanCopyObjectInventoryHandler delegateFunc)
  946. {
  947. if (CanCopyObjectInventoryCheckFunctions.Contains(delegateFunc))
  948. CanCopyObjectInventoryCheckFunctions.Remove(delegateFunc);
  949. }
  950. public bool CanCopyObjectInventory(UUID itemID, UUID objectID, UUID userID)
  951. {
  952. foreach (CanCopyObjectInventoryHandler check in CanCopyObjectInventoryCheckFunctions)
  953. {
  954. if (check(itemID, objectID, userID) == false)
  955. {
  956. return false;
  957. }
  958. }
  959. return true;
  960. }
  961. public delegate bool CanDeleteObjectInventoryHandler(UUID itemID, UUID objectID, UUID userID);
  962. private List<CanDeleteObjectInventoryHandler> CanDeleteObjectInventoryCheckFunctions
  963. = new List<CanDeleteObjectInventoryHandler>();
  964. public void AddCanDeleteObjectInventoryHandler(CanDeleteObjectInventoryHandler delegateFunc)
  965. {
  966. if (!CanDeleteObjectInventoryCheckFunctions.Contains(delegateFunc))
  967. CanDeleteObjectInventoryCheckFunctions.Add(delegateFunc);
  968. }
  969. public void RemoveCanDeleteObjectInventoryHandler(CanDeleteObjectInventoryHandler delegateFunc)
  970. {
  971. if (CanDeleteObjectInventoryCheckFunctions.Contains(delegateFunc))
  972. CanDeleteObjectInventoryCheckFunctions.Remove(delegateFunc);
  973. }
  974. public bool CanDeleteObjectInventory(UUID itemID, UUID objectID, UUID userID)
  975. {
  976. foreach (CanDeleteObjectInventoryHandler check in CanDeleteObjectInventoryCheckFunctions)
  977. {
  978. if (check(itemID, objectID, userID) == false)
  979. {
  980. return false;
  981. }
  982. }
  983. return true;
  984. }
  985. public delegate bool CanCreateUserInventoryHandler(int invType, UUID userID);
  986. private List<CanCreateUserInventoryHandler> CanCreateUserInventoryCheckFunctions
  987. = new List<CanCreateUserInventoryHandler>();
  988. public void AddCanCreateUserInventoryHandler(CanCreateUserInventoryHandler delegateFunc)
  989. {
  990. if (!CanCreateUserInventoryCheckFunctions.Contains(delegateFunc))
  991. CanCreateUserInventoryCheckFunctions.Add(delegateFunc);
  992. }
  993. public void RemoveCanCreateUserInventoryHandler(CanCreateUserInventoryHandler delegateFunc)
  994. {
  995. if (CanCreateUserInventoryCheckFunctions.Contains(delegateFunc))
  996. CanCreateUserInventoryCheckFunctions.Remove(delegateFunc);
  997. }
  998. /// <summary>
  999. /// Check whether the specified user is allowed to create the given inventory type in their inventory.
  1000. /// </summary>
  1001. /// <param name="invType"></param>
  1002. /// <param name="userID"></param>
  1003. /// <returns></returns>
  1004. public bool CanCreateUserInventory(int invType, UUID userID)
  1005. {
  1006. foreach (CanCreateUserInventoryHandler check in CanCreateUserInventoryCheckFunctions)
  1007. {
  1008. if (check(invType, userID) == false)
  1009. {
  1010. return false;
  1011. }
  1012. }
  1013. return true;
  1014. }
  1015. public delegate bool CanEditUserInventoryHandler(UUID itemID, UUID userID);
  1016. private List<CanEditUserInventoryHandler> CanEditUserInventoryCheckFunctions
  1017. = new List<CanEditUserInventoryHandler>();
  1018. public void AddCanEditUserInventoryHandler(CanEditUserInventoryHandler delegateFunc)
  1019. {
  1020. if (!CanEditUserInventoryCheckFunctions.Contains(delegateFunc))
  1021. CanEditUserInventoryCheckFunctions.Add(delegateFunc);
  1022. }
  1023. public void RemoveCanEditUserInventoryHandler(CanEditUserInventoryHandler delegateFunc)
  1024. {
  1025. if (CanEditUserInventoryCheckFunctions.Contains(delegateFunc))
  1026. CanEditUserInventoryCheckFunctions.Remove(delegateFunc);
  1027. }
  1028. /// <summary>
  1029. /// Check whether the specified user is allowed to edit the given inventory item within their own inventory.
  1030. /// </summary>
  1031. /// <param name="itemID"></param>
  1032. /// <param name="userID"></param>
  1033. /// <returns></returns>
  1034. public bool CanEditUserInventory(UUID itemID, UUID userID)
  1035. {
  1036. foreach (CanEditUserInventoryHandler check in CanEditUserInventoryCheckFunctions)
  1037. {
  1038. if (check(itemID, userID) == false)
  1039. {
  1040. return false;
  1041. }
  1042. }
  1043. return true;
  1044. }
  1045. public delegate bool CanCopyUserInventoryHandler(UUID itemID, UUID userID);
  1046. private List<CanCopyUserInventoryHandler> CanCopyUserInventoryCheckFunctions
  1047. = new List<CanCopyUserInventoryHandler>();
  1048. public void AddCanCopyUserInventoryHandler(CanCopyUserInventoryHandler delegateFunc)
  1049. {
  1050. if (!CanCopyUserInventoryCheckFunctions.Contains(delegateFunc))
  1051. CanCopyUserInventoryCheckFunctions.Add(delegateFunc);
  1052. }
  1053. public void RemoveCanCopyUserInventoryHandler(CanCopyUserInventoryHandler delegateFunc)
  1054. {
  1055. if (CanCopyUserInventoryCheckFunctions.Contains(delegateFunc))
  1056. CanCopyUserInventoryCheckFunctions.Remove(delegateFunc);
  1057. }
  1058. /// <summary>
  1059. /// Check whether the specified user is allowed to copy the given inventory item from their own inventory.
  1060. /// </summary>
  1061. /// <param name="itemID"></param>
  1062. /// <param name="userID"></param>
  1063. /// <returns></returns>
  1064. public bool CanCopyUserInventory(UUID itemID, UUID userID)
  1065. {
  1066. foreach (CanCopyUserInventoryHandler check in CanCopyUserInventoryCheckFunctions)
  1067. {
  1068. if (check(itemID, userID) == false)
  1069. {
  1070. return false;
  1071. }
  1072. }
  1073. return true;
  1074. }
  1075. public delegate bool CanDeleteUserInventoryHandler(UUID itemID, UUID userID);
  1076. private List<CanDeleteUserInventoryHandler> CanDeleteUserInventoryCheckFunctions
  1077. = new List<CanDeleteUserInventoryHandler>();
  1078. public void AddCanDeleteUserInventoryHandler(CanDeleteUserInventoryHandler delegateFunc)
  1079. {
  1080. if (!CanDeleteUserInventoryCheckFunctions.Contains(delegateFunc))
  1081. CanDeleteUserInventoryCheckFunctions.Add(delegateFunc);
  1082. }
  1083. public void RemoveCanDeleteUserInventoryHandler(CanDeleteUserInventoryHandler delegateFunc)
  1084. {
  1085. if (CanDeleteUserInventoryCheckFunctions.Contains(delegateFunc))
  1086. CanDeleteUserInventoryCheckFunctions.Remove(delegateFunc);
  1087. }
  1088. /// <summary>
  1089. /// Check whether the specified user is allowed to edit the given inventory item within their own inventory.
  1090. /// </summary>
  1091. /// <param name="itemID"></param>
  1092. /// <param name="userID"></param>
  1093. /// <returns></returns>
  1094. public bool CanDeleteUserInventory(UUID itemID, UUID userID)
  1095. {
  1096. foreach (CanDeleteUserInventoryHandler check in CanDeleteUserInventoryCheckFunctions)
  1097. {
  1098. if (check(itemID, userID) == false)
  1099. {
  1100. return false;
  1101. }
  1102. }
  1103. return true;
  1104. }
  1105. public delegate bool CanTeleportHandler(UUID userID);
  1106. private List<CanTeleportHandler> CanTeleportCheckFunctions = new List<CanTeleportHandler>();
  1107. public void AddCanTeleportHandler(CanTeleportHandler delegateFunc)
  1108. {
  1109. if (!CanTeleportCheckFunctions.Contains(delegateFunc))
  1110. CanTeleportCheckFunctions.Add(delegateFunc);
  1111. }
  1112. public void RemoveCanTeleportHandler(CanTeleportHandler delegateFunc)
  1113. {
  1114. if (CanTeleportCheckFunctions.Contains(delegateFunc))
  1115. CanTeleportCheckFunctions.Remove(delegateFunc);
  1116. }
  1117. public bool CanTeleport(UUID userID)
  1118. {
  1119. foreach (CanTeleportHandler check in CanTeleportCheckFunctions)
  1120. {
  1121. if (check(userID) == false)
  1122. {
  1123. return false;
  1124. }
  1125. }
  1126. return true;
  1127. }
  1128. }
  1129. }