From 40abeed7d425065e273e3a33264425f8ded35f3e Mon Sep 17 00:00:00 2001
From: Melanie Thielker
Date: Sun, 17 Aug 2008 18:41:13 +0000
Subject: Add the IInventoryModule interface and a sample method call to
Scene.INventory.cs
---
OpenSim/Framework/IInventoryModule.cs | 40 ++++++++++++++++++++++
.../Modules/Avatar/Inventory/InventoryModule.cs | 36 ++++++++++++-------
.../Region/Environment/Scenes/Scene.Inventory.cs | 9 +++++
3 files changed, 72 insertions(+), 13 deletions(-)
create mode 100644 OpenSim/Framework/IInventoryModule.cs
(limited to 'OpenSim')
diff --git a/OpenSim/Framework/IInventoryModule.cs b/OpenSim/Framework/IInventoryModule.cs
new file mode 100644
index 0000000..19171cd
--- /dev/null
+++ b/OpenSim/Framework/IInventoryModule.cs
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) Contributors, http://opensimulator.org/
+ * See CONTRIBUTORS.TXT for a full list of copyright holders.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the OpenSim Project nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+using System.Collections.Generic;
+using libsecondlife;
+
+namespace OpenSim.Framework
+{
+ ///
+ /// An interface for accessing and managing agent inventory
+ ///
+ public interface IInventoryModule
+ {
+// void TestFunction();
+ }
+}
diff --git a/OpenSim/Region/Environment/Modules/Avatar/Inventory/InventoryModule.cs b/OpenSim/Region/Environment/Modules/Avatar/Inventory/InventoryModule.cs
index e1cc688..cc088a0 100644
--- a/OpenSim/Region/Environment/Modules/Avatar/Inventory/InventoryModule.cs
+++ b/OpenSim/Region/Environment/Modules/Avatar/Inventory/InventoryModule.cs
@@ -36,7 +36,7 @@ using OpenSim.Region.Environment.Scenes;
namespace OpenSim.Region.Environment.Modules.Avatar.Inventory
{
- public class InventoryModule : IRegionModule
+ public class InventoryModule : IInventoryModule, IRegionModule
{
private static readonly ILog m_log
= LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
@@ -48,14 +48,20 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Inventory
///
private IDictionary m_pendingOffers = new Dictionary();
- private Scene m_scene;
+ private List m_Scenelist = new List();
#region IRegionModule Members
public void Initialise(Scene scene, IConfigSource config)
{
- m_scene = scene;
- scene.EventManager.OnNewClient += OnNewClient;
+ if(!m_Scenelist.Contains(scene))
+ {
+ m_Scenelist.Add(scene);
+
+ scene.RegisterModuleInterface(this);
+
+ scene.EventManager.OnNewClient += OnNewClient;
+ }
}
public void PostInitialise()
@@ -73,7 +79,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Inventory
public bool IsSharedModule
{
- get { return false; }
+ get { return true; }
}
#endregion
@@ -97,9 +103,9 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Inventory
"[AGENT INVENTORY]: Routing inventory offering message from {0}, {1} to {2}",
client.AgentId, client.Name, toAgentID);
- if (m_scene.Entities.ContainsKey(toAgentID) && m_scene.Entities[toAgentID] is ScenePresence)
+ if (((Scene)(client.Scene)).Entities.ContainsKey(toAgentID) && ((Scene)(client.Scene)).Entities[toAgentID] is ScenePresence)
{
- ScenePresence user = (ScenePresence) m_scene.Entities[toAgentID];
+ ScenePresence user = (ScenePresence) ((Scene)(client.Scene)).Entities[toAgentID];
if (!user.IsChildAgent)
{
@@ -143,9 +149,9 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Inventory
"[AGENT INVENTORY]: Routing inventory accepted message from {0}, {1} to {2}",
client.AgentId, client.Name, toAgentID);
- if (m_scene.Entities.ContainsKey(toAgentID) && m_scene.Entities[toAgentID] is ScenePresence)
+ if (((Scene)(client.Scene)).Entities.ContainsKey(toAgentID) && ((Scene)(client.Scene)).Entities[toAgentID] is ScenePresence)
{
- ScenePresence user = (ScenePresence) m_scene.Entities[toAgentID];
+ ScenePresence user = (ScenePresence) ((Scene)(client.Scene)).Entities[toAgentID];
if (!user.IsChildAgent)
{
@@ -160,7 +166,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Inventory
// Since the message originates from the accepting client, the toAgentID is
// the agent giving the item.
- m_scene.GiveInventoryItem(client, toAgentID, m_pendingOffers[imSessionID]);
+ ((Scene)(client.Scene)).GiveInventoryItem(client, toAgentID, m_pendingOffers[imSessionID]);
m_pendingOffers.Remove(imSessionID);
}
@@ -189,9 +195,9 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Inventory
}
else if (dialog == (byte) InstantMessageDialog.InventoryDeclined)
{
- if (m_scene.Entities.ContainsKey(toAgentID) && m_scene.Entities[toAgentID] is ScenePresence)
+ if (((Scene)(client.Scene)).Entities.ContainsKey(toAgentID) && ((Scene)(client.Scene)).Entities[toAgentID] is ScenePresence)
{
- ScenePresence user = (ScenePresence) m_scene.Entities[toAgentID];
+ ScenePresence user = (ScenePresence) ((Scene)(client.Scene)).Entities[toAgentID];
if (!user.IsChildAgent)
{
@@ -216,5 +222,9 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Inventory
}
}
}
+
+// public void TestFunction()
+// {
+// }
}
-}
\ No newline at end of file
+}
diff --git a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs
index 3f62610..fe66dd5 100644
--- a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs
@@ -2308,5 +2308,14 @@ namespace OpenSim.Region.Environment.Scenes
else
EventManager.TriggerStopScript(part.LocalId, itemID);
}
+
+// public void TestFunction()
+// {
+// IInventoryModule imod = RequestModuleInterface();
+// if (imod == null)
+// return;
+//
+// imod.TestFunction();
+// }
}
}
--
cgit v1.1