From bb82076a4d2afd914d325f17443bb409d75bfe0e Mon Sep 17 00:00:00 2001
From: Diva Canto
Date: Thu, 25 Dec 2014 12:17:07 -0800
Subject: Allow for richer semantics of object derez. Specifically, allow the
existence of region modules that do other kinds of garbage collection.
Instead of placing deleted objects in the user's Trash folder, or deleting
them immediately (UseTrashOnDelete = false), a module may decide to take
garbage collection under its control. For example, it may place derezzed
objects in a certain area inworld and delete them later.
---
OpenSim/Region/Framework/Scenes/EventManager.cs | 60 ++++++++++++++++++----
OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 7 ++-
2 files changed, 54 insertions(+), 13 deletions(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Region/Framework/Scenes/EventManager.cs b/OpenSim/Region/Framework/Scenes/EventManager.cs
index ba79964..d325240 100644
--- a/OpenSim/Region/Framework/Scenes/EventManager.cs
+++ b/OpenSim/Region/Framework/Scenes/EventManager.cs
@@ -786,8 +786,30 @@ namespace OpenSim.Region.Framework.Scenes
///
///
public event Action OnObjectAddedToScene;
+
+ ///
+ /// When a client sends a derez request for an object inworld
+ /// but before the object is deleted
+ ///
+ public event DeRezRequested OnDeRezRequested;
+ ///
+ /// Triggered when a client sends a derez request for an object inworld
+ ///
+ /// The client question (it can be null)
+ /// The object in question
+ /// The exact derez action
+ /// Flag indicating whether the object should be deleted from the scene or not
+ public delegate bool DeRezRequested(IClientAPI remoteClient, List objs, DeRezAction action);
///
+ /// Triggered when an object is removed from the scene.
+ ///
+ ///
+ /// Triggered by
+ /// in
+ ///
+ public event ObjectBeingRemovedFromScene OnObjectBeingRemovedFromScene;
+ ///
/// Delegate for
///
/// The object being removed from the scene
@@ -806,15 +828,6 @@ namespace OpenSim.Region.Framework.Scenes
///
public event Action OnObjectRemovedFromPhysicalScene;
- ///
- /// Triggered when an object is removed from the scene.
- ///
- ///
- /// Triggered by
- /// in
- ///
- public event ObjectBeingRemovedFromScene OnObjectBeingRemovedFromScene;
-
public delegate void NoticeNoLandDataFromStorage();
public event NoticeNoLandDataFromStorage OnNoticeNoLandDataFromStorage;
@@ -1521,8 +1534,33 @@ namespace OpenSim.Region.Framework.Scenes
}
}
}
- }
-
+ }
+
+ public bool TriggerDeRezRequested(IClientAPI client, List objs, DeRezAction action)
+ {
+ bool canDeRez = true;
+
+ DeRezRequested handlerDeRezRequested = OnDeRezRequested;
+ if (handlerDeRezRequested != null)
+ {
+ foreach (DeRezRequested d in handlerDeRezRequested.GetInvocationList())
+ {
+ try
+ {
+ canDeRez &= d(client, objs, action);
+ }
+ catch (Exception e)
+ {
+ m_log.ErrorFormat(
+ "[EVENT MANAGER]: Delegate for TriggerDeRezRequested failed - continuing. {0} {1}",
+ e.Message, e.StackTrace);
+ }
+ }
+ }
+
+ return canDeRez;
+ }
+
public void TriggerObjectBeingRemovedFromScene(SceneObjectGroup obj)
{
ObjectBeingRemovedFromScene handlerObjectBeingRemovedFromScene = OnObjectBeingRemovedFromScene;
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
index 5cc5606..b14e2f7 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
@@ -2182,13 +2182,16 @@ namespace OpenSim.Region.Framework.Scenes
}
}
+ // OK, we're done with permissions. Let's check if any part of the code prevents the objects from being deleted
+ bool canDelete = EventManager.TriggerDeRezRequested(remoteClient, deleteGroups, action);
+
if (permissionToTake && (action != DeRezAction.Delete || this.m_useTrashOnDelete))
{
m_asyncSceneObjectDeleter.DeleteToInventory(
action, destinationID, deleteGroups, remoteClient,
- permissionToDelete);
+ permissionToDelete && canDelete);
}
- else if (permissionToDelete)
+ else if (permissionToDelete && canDelete)
{
foreach (SceneObjectGroup g in deleteGroups)
DeleteSceneObject(g, false);
--
cgit v1.1