From 3d0860ae616749518a40c6f6088d2644d589daf9 Mon Sep 17 00:00:00 2001 From: dahlia Date: Mon, 12 Apr 2010 17:10:51 -0700 Subject: thanks lkalif for Mantis #4676 - a patch that adds support for inventory links Signed-off-by: dahlia --- CONTRIBUTORS.txt | 1 + OpenSim/Client/MXP/ClientStack/MXPClientView.cs | 1 + .../Sirikata/ClientStack/SirikataClientView.cs | 1 + .../Client/VWoHTTP/ClientStack/VWHClientView.cs | 1 + OpenSim/Framework/IClientAPI.cs | 5 ++++ .../Region/ClientStack/LindenUDP/LLClientView.cs | 34 ++++++++++++++++++++++ .../Region/Examples/SimpleModule/MyNpcCharacter.cs | 1 + OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 31 ++++++++++++++++++++ OpenSim/Region/Framework/Scenes/Scene.cs | 1 + .../Server/IRCClientView.cs | 1 + .../Region/OptionalModules/World/NPC/NPCAvatar.cs | 1 + OpenSim/Tests/Common/Mock/TestClient.cs | 1 + 12 files changed, 79 insertions(+) diff --git a/CONTRIBUTORS.txt b/CONTRIBUTORS.txt index e5c8cb9..9aadd70 100644 --- a/CONTRIBUTORS.txt +++ b/CONTRIBUTORS.txt @@ -88,6 +88,7 @@ what it is today. * Kitto Flora * KittyLiu * Kurt Taylor (IBM) +* lkalif * lulurun * M.Igarashi * maimedleech diff --git a/OpenSim/Client/MXP/ClientStack/MXPClientView.cs b/OpenSim/Client/MXP/ClientStack/MXPClientView.cs index 17bd795..1d6d4c1 100644 --- a/OpenSim/Client/MXP/ClientStack/MXPClientView.cs +++ b/OpenSim/Client/MXP/ClientStack/MXPClientView.cs @@ -642,6 +642,7 @@ namespace OpenSim.Client.MXP.ClientStack public event Action OnRemoveAvatar; public event ObjectPermissions OnObjectPermissions; public event CreateNewInventoryItem OnCreateNewInventoryItem; + public event LinkInventoryItem OnLinkInventoryItem; public event CreateInventoryFolder OnCreateNewInventoryFolder; public event UpdateInventoryFolder OnUpdateInventoryFolder; public event MoveInventoryFolder OnMoveInventoryFolder; diff --git a/OpenSim/Client/Sirikata/ClientStack/SirikataClientView.cs b/OpenSim/Client/Sirikata/ClientStack/SirikataClientView.cs index 4ecbaf9..43c64e9 100644 --- a/OpenSim/Client/Sirikata/ClientStack/SirikataClientView.cs +++ b/OpenSim/Client/Sirikata/ClientStack/SirikataClientView.cs @@ -288,6 +288,7 @@ namespace OpenSim.Client.Sirikata.ClientStack public event Action OnRemoveAvatar; public event ObjectPermissions OnObjectPermissions; public event CreateNewInventoryItem OnCreateNewInventoryItem; + public event LinkInventoryItem OnLinkInventoryItem; public event CreateInventoryFolder OnCreateNewInventoryFolder; public event UpdateInventoryFolder OnUpdateInventoryFolder; public event MoveInventoryFolder OnMoveInventoryFolder; diff --git a/OpenSim/Client/VWoHTTP/ClientStack/VWHClientView.cs b/OpenSim/Client/VWoHTTP/ClientStack/VWHClientView.cs index 1da746a..864b4f1 100644 --- a/OpenSim/Client/VWoHTTP/ClientStack/VWHClientView.cs +++ b/OpenSim/Client/VWoHTTP/ClientStack/VWHClientView.cs @@ -291,6 +291,7 @@ namespace OpenSim.Client.VWoHTTP.ClientStack public event Action OnRemoveAvatar = delegate { }; public event ObjectPermissions OnObjectPermissions = delegate { }; public event CreateNewInventoryItem OnCreateNewInventoryItem = delegate { }; + public event LinkInventoryItem OnLinkInventoryItem = delegate { }; public event CreateInventoryFolder OnCreateNewInventoryFolder = delegate { }; public event UpdateInventoryFolder OnUpdateInventoryFolder = delegate { }; public event MoveInventoryFolder OnMoveInventoryFolder = delegate { }; diff --git a/OpenSim/Framework/IClientAPI.cs b/OpenSim/Framework/IClientAPI.cs index 4577758..af88c4a 100644 --- a/OpenSim/Framework/IClientAPI.cs +++ b/OpenSim/Framework/IClientAPI.cs @@ -236,6 +236,10 @@ namespace OpenSim.Framework IClientAPI remoteClient, UUID transActionID, UUID folderID, uint callbackID, string description, string name, sbyte invType, sbyte type, byte wearableType, uint nextOwnerMask, int creationDate); + public delegate void LinkInventoryItem( + IClientAPI remoteClient, UUID transActionID, UUID folderID, uint callbackID, string description, string name, + sbyte invType, sbyte type, UUID olditemID); + public delegate void FetchInventoryDescendents( IClientAPI remoteClient, UUID folderID, UUID ownerID, bool fetchFolders, bool fetchItems, int sortOrder); @@ -930,6 +934,7 @@ namespace OpenSim.Framework event ObjectPermissions OnObjectPermissions; event CreateNewInventoryItem OnCreateNewInventoryItem; + event LinkInventoryItem OnLinkInventoryItem; event CreateInventoryFolder OnCreateNewInventoryFolder; event UpdateInventoryFolder OnUpdateInventoryFolder; event MoveInventoryFolder OnMoveInventoryFolder; diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index 51ab281..f0f3932 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs @@ -182,6 +182,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP public event TeleportLocationRequest OnSetStartLocationRequest; public event UpdateAvatarProperties OnUpdateAvatarProperties; public event CreateNewInventoryItem OnCreateNewInventoryItem; + public event LinkInventoryItem OnLinkInventoryItem; public event CreateInventoryFolder OnCreateNewInventoryFolder; public event UpdateInventoryFolder OnUpdateInventoryFolder; public event MoveInventoryFolder OnMoveInventoryFolder; @@ -4749,6 +4750,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP AddLocalPacketHandler(PacketType.UpdateInventoryFolder, HandleUpdateInventoryFolder); AddLocalPacketHandler(PacketType.MoveInventoryFolder, HandleMoveInventoryFolder); AddLocalPacketHandler(PacketType.CreateInventoryItem, HandleCreateInventoryItem); + AddLocalPacketHandler(PacketType.LinkInventoryItem, HandleLinkInventoryItem); AddLocalPacketHandler(PacketType.FetchInventory, HandleFetchInventory); AddLocalPacketHandler(PacketType.FetchInventoryDescendents, HandleFetchInventoryDescendents); AddLocalPacketHandler(PacketType.PurgeInventoryDescendents, HandlePurgeInventoryDescendents); @@ -7348,6 +7350,38 @@ namespace OpenSim.Region.ClientStack.LindenUDP return true; } + private bool HandleLinkInventoryItem(IClientAPI sender, Packet Pack) + { + LinkInventoryItemPacket createLink = (LinkInventoryItemPacket)Pack; + + #region Packet Session and User Check + if (m_checkPackets) + { + if (createLink.AgentData.SessionID != SessionId || + createLink.AgentData.AgentID != AgentId) + return true; + } + #endregion + + LinkInventoryItem linkInventoryItem = OnLinkInventoryItem; + + if (linkInventoryItem != null) + { + linkInventoryItem( + this, + createLink.InventoryBlock.TransactionID, + createLink.InventoryBlock.FolderID, + createLink.InventoryBlock.CallbackID, + Util.FieldToString(createLink.InventoryBlock.Description), + Util.FieldToString(createLink.InventoryBlock.Name), + createLink.InventoryBlock.InvType, + createLink.InventoryBlock.Type, + createLink.InventoryBlock.OldItemID); + } + + return true; + } + private bool HandleFetchInventory(IClientAPI sender, Packet Pack) { if (OnFetchInventory != null) diff --git a/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs b/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs index 8d27f9c..09611af 100644 --- a/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs +++ b/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs @@ -129,6 +129,7 @@ namespace OpenSim.Region.Examples.SimpleModule public event Action OnRemoveAvatar; public event CreateNewInventoryItem OnCreateNewInventoryItem; + public event LinkInventoryItem OnLinkInventoryItem; public event CreateInventoryFolder OnCreateNewInventoryFolder; public event UpdateInventoryFolder OnUpdateInventoryFolder; public event MoveInventoryFolder OnMoveInventoryFolder; diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 3b7f38e..7c68ef4 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -722,6 +722,37 @@ namespace OpenSim.Region.Framework.Scenes } } + private void HandleLinkInventoryItem(IClientAPI remoteClient, UUID transActionID, UUID folderID, + uint callbackID, string description, string name, + sbyte invType, sbyte type, UUID olditemID) + { + m_log.DebugFormat("[AGENT INVENTORY]: Received request to create inventory item link {0} in folder {1} pointing to {2}", name, folderID, olditemID); + + if (!Permissions.CanCreateUserInventory(invType, remoteClient.AgentId)) + return; + + ScenePresence presence; + if (TryGetScenePresence(remoteClient.AgentId, out presence)) + { + byte[] data = null; + + AssetBase asset = new AssetBase(); + asset.FullID = olditemID; + asset.Type = type; + asset.Name = name; + asset.Description = description; + + CreateNewInventoryItem(remoteClient, remoteClient.AgentId.ToString(), folderID, name, 0, callbackID, asset, invType, (uint)PermissionMask.All, (uint)PermissionMask.All, (uint)PermissionMask.All, (uint)PermissionMask.All, (uint)PermissionMask.All, Util.UnixTimeSinceEpoch()); + + } + else + { + m_log.ErrorFormat( + "ScenePresence for agent uuid {0} unexpectedly not found in HandleLinkInventoryItem", + remoteClient.AgentId); + } + } + /// /// Remove an inventory item for the client's inventory /// diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index fc915a3..685a678 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -2749,6 +2749,7 @@ namespace OpenSim.Region.Framework.Scenes public virtual void SubscribeToClientInventoryEvents(IClientAPI client) { client.OnCreateNewInventoryItem += CreateNewInventoryItem; + client.OnLinkInventoryItem += HandleLinkInventoryItem; client.OnCreateNewInventoryFolder += HandleCreateInventoryFolder; client.OnUpdateInventoryFolder += HandleUpdateInventoryFolder; client.OnMoveInventoryFolder += HandleMoveInventoryFolder; // 2; //!! diff --git a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs index f5b148f..69e78b3 100644 --- a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs +++ b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs @@ -724,6 +724,7 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server public event Action OnRemoveAvatar; public event ObjectPermissions OnObjectPermissions; public event CreateNewInventoryItem OnCreateNewInventoryItem; + public event LinkInventoryItem OnLinkInventoryItem; public event CreateInventoryFolder OnCreateNewInventoryFolder; public event UpdateInventoryFolder OnUpdateInventoryFolder; public event MoveInventoryFolder OnMoveInventoryFolder; diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs index 338c04b..6360c99 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs @@ -235,6 +235,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC public event Action OnRemoveAvatar; public event CreateNewInventoryItem OnCreateNewInventoryItem; + public event LinkInventoryItem OnLinkInventoryItem; public event CreateInventoryFolder OnCreateNewInventoryFolder; public event UpdateInventoryFolder OnUpdateInventoryFolder; public event MoveInventoryFolder OnMoveInventoryFolder; diff --git a/OpenSim/Tests/Common/Mock/TestClient.cs b/OpenSim/Tests/Common/Mock/TestClient.cs index f015db2..b07a072 100644 --- a/OpenSim/Tests/Common/Mock/TestClient.cs +++ b/OpenSim/Tests/Common/Mock/TestClient.cs @@ -141,6 +141,7 @@ namespace OpenSim.Tests.Common.Mock public event Action OnRemoveAvatar; public event CreateNewInventoryItem OnCreateNewInventoryItem; + public event LinkInventoryItem OnLinkInventoryItem; public event CreateInventoryFolder OnCreateNewInventoryFolder; public event UpdateInventoryFolder OnUpdateInventoryFolder; public event MoveInventoryFolder OnMoveInventoryFolder; -- cgit v1.1