From 76c60f1f99ca8aa7c1a336918aa0ef5f83b1ae04 Mon Sep 17 00:00:00 2001
From: Diva Canto
Date: Fri, 3 Jun 2011 08:27:01 -0700
Subject: Moved CreateNewInventoryItem to the InventoryAccessModule in
preparation for supporting HG landmarks.
---
.../InventoryAccess/InventoryAccessModule.cs | 79 +++++++++++++++++++++-
OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 74 +-------------------
OpenSim/Region/Framework/Scenes/Scene.cs | 4 +-
3 files changed, 81 insertions(+), 76 deletions(-)
diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
index 1370b1f..641a042 100644
--- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
@@ -30,6 +30,7 @@ using System.Collections.Generic;
using System.Net;
using System.Xml;
using System.Reflection;
+using System.Text;
using System.Threading;
using OpenSim.Framework;
@@ -128,7 +129,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
protected virtual void OnNewClient(IClientAPI client)
{
-
+ client.OnCreateNewInventoryItem += CreateNewInventoryItem;
}
public virtual void Close()
@@ -157,6 +158,82 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
#region Inventory Access
///
+ /// Create a new inventory item. Called when the client creates a new item directly within their
+ /// inventory (e.g. by selecting a context inventory menu option).
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ public void CreateNewInventoryItem(IClientAPI remoteClient, UUID transactionID, UUID folderID,
+ uint callbackID, string description, string name, sbyte invType,
+ sbyte assetType,
+ byte wearableType, uint nextOwnerMask, int creationDate)
+ {
+ m_log.DebugFormat("[AGENT INVENTORY]: Received request to create inventory item {0} in folder {1}", name, folderID);
+
+ if (!m_Scene.Permissions.CanCreateUserInventory(invType, remoteClient.AgentId))
+ return;
+
+ InventoryFolderBase f = new InventoryFolderBase(folderID, remoteClient.AgentId);
+ InventoryFolderBase folder = m_Scene.InventoryService.GetFolder(f);
+
+ if (folder == null || folder.Owner != remoteClient.AgentId)
+ return;
+
+ if (transactionID == UUID.Zero)
+ {
+ ScenePresence presence;
+ if (m_Scene.TryGetScenePresence(remoteClient.AgentId, out presence))
+ {
+ byte[] data = null;
+
+ if (invType == (sbyte)InventoryType.Landmark && presence != null)
+ {
+ string strdata = GenerateLandmark(presence);
+ data = Encoding.ASCII.GetBytes(strdata);
+ }
+
+ AssetBase asset = m_Scene.CreateAsset(name, description, assetType, data, remoteClient.AgentId);
+ m_Scene.AssetService.Store(asset);
+
+ m_Scene.CreateNewInventoryItem(remoteClient, remoteClient.AgentId.ToString(), string.Empty, folderID, asset.Name, 0, callbackID, asset, invType, nextOwnerMask, creationDate);
+ }
+ else
+ {
+ m_log.ErrorFormat(
+ "ScenePresence for agent uuid {0} unexpectedly not found in CreateNewInventoryItem",
+ remoteClient.AgentId);
+ }
+ }
+ else
+ {
+ IAgentAssetTransactions agentTransactions = m_Scene.RequestModuleInterface();
+ if (agentTransactions != null)
+ {
+ agentTransactions.HandleItemCreationFromTransaction(
+ remoteClient, transactionID, folderID, callbackID, description,
+ name, invType, assetType, wearableType, nextOwnerMask);
+ }
+ }
+ }
+
+ protected virtual string GenerateLandmark(ScenePresence presence)
+ {
+ Vector3 pos = presence.AbsolutePosition;
+ return String.Format("Landmark version 2\nregion_id {0}\nlocal_pos {1} {2} {3}\nregion_handle {4}\n",
+ presence.Scene.RegionInfo.RegionID,
+ pos.X, pos.Y, pos.Z,
+ presence.RegionHandle);
+ }
+
+ ///
/// Capability originating call to update the asset of an item in an agent's inventory
///
///
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
index 3c47873..b70e1c3 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
@@ -778,7 +778,7 @@ namespace OpenSim.Region.Framework.Scenes
///
///
///
- private void CreateNewInventoryItem(IClientAPI remoteClient, string creatorID, string creatorData, UUID folderID, string name, uint flags, uint callbackID,
+ public void CreateNewInventoryItem(IClientAPI remoteClient, string creatorID, string creatorData, UUID folderID, string name, uint flags, uint callbackID,
AssetBase asset, sbyte invType, uint nextOwnerMask, int creationDate)
{
CreateNewInventoryItem(
@@ -833,78 +833,6 @@ namespace OpenSim.Region.Framework.Scenes
}
///
- /// Create a new inventory item. Called when the client creates a new item directly within their
- /// inventory (e.g. by selecting a context inventory menu option).
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- public void CreateNewInventoryItem(IClientAPI remoteClient, UUID transactionID, UUID folderID,
- uint callbackID, string description, string name, sbyte invType,
- sbyte assetType,
- byte wearableType, uint nextOwnerMask, int creationDate)
- {
- m_log.DebugFormat("[AGENT INVENTORY]: Received request to create inventory item {0} in folder {1}", name, folderID);
-
- if (!Permissions.CanCreateUserInventory(invType, remoteClient.AgentId))
- return;
-
- InventoryFolderBase f = new InventoryFolderBase(folderID, remoteClient.AgentId);
- InventoryFolderBase folder = InventoryService.GetFolder(f);
-
- if (folder == null || folder.Owner != remoteClient.AgentId)
- return;
-
- if (transactionID == UUID.Zero)
- {
- ScenePresence presence;
- if (TryGetScenePresence(remoteClient.AgentId, out presence))
- {
- byte[] data = null;
-
- if (invType == (sbyte)InventoryType.Landmark && presence != null)
- {
- Vector3 pos = presence.AbsolutePosition;
- string strdata = String.Format(
- "Landmark version 2\nregion_id {0}\nlocal_pos {1} {2} {3}\nregion_handle {4}\n",
- presence.Scene.RegionInfo.RegionID,
- pos.X, pos.Y, pos.Z,
- presence.RegionHandle);
- data = Encoding.ASCII.GetBytes(strdata);
- }
-
- AssetBase asset = CreateAsset(name, description, assetType, data, remoteClient.AgentId);
- AssetService.Store(asset);
-
- CreateNewInventoryItem(remoteClient, remoteClient.AgentId.ToString(), string.Empty, folderID, asset.Name, 0, callbackID, asset, invType, nextOwnerMask, creationDate);
- }
- else
- {
- m_log.ErrorFormat(
- "ScenePresence for agent uuid {0} unexpectedly not found in CreateNewInventoryItem",
- remoteClient.AgentId);
- }
- }
- else
- {
- IAgentAssetTransactions agentTransactions = this.RequestModuleInterface();
- if (agentTransactions != null)
- {
- agentTransactions.HandleItemCreationFromTransaction(
- remoteClient, transactionID, folderID, callbackID, description,
- name, invType, assetType, wearableType, nextOwnerMask);
- }
- }
- }
-
- ///
/// Link an inventory item to an existing item.
///
///
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index 1d562fd..b179683 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -2726,7 +2726,7 @@ namespace OpenSim.Region.Framework.Scenes
public virtual void SubscribeToClientInventoryEvents(IClientAPI client)
{
- client.OnCreateNewInventoryItem += CreateNewInventoryItem;
+
client.OnLinkInventoryItem += HandleLinkInventoryItem;
client.OnCreateNewInventoryFolder += HandleCreateInventoryFolder;
client.OnUpdateInventoryFolder += HandleUpdateInventoryFolder;
@@ -2853,7 +2853,7 @@ namespace OpenSim.Region.Framework.Scenes
public virtual void UnSubscribeToClientInventoryEvents(IClientAPI client)
{
- client.OnCreateNewInventoryItem -= CreateNewInventoryItem;
+
client.OnCreateNewInventoryFolder -= HandleCreateInventoryFolder;
client.OnUpdateInventoryFolder -= HandleUpdateInventoryFolder;
client.OnMoveInventoryFolder -= HandleMoveInventoryFolder; // 2; //!!
--
cgit v1.1