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