From 71f42f185a48ef96391b39fa0197c1a8b793e969 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Sat, 24 Apr 2010 16:45:25 +0200 Subject: Plumb a data path to initialize an attachment from an alternate source --- .../Avatar/Attachments/AttachmentsModule.cs | 20 ++++++++++++-- .../InventoryAccess/InventoryAccessModule.cs | 1 + .../Framework/Interfaces/IAttachmentsModule.cs | 7 ++++- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 2 +- OpenSim/Services/Interfaces/IAttachmentsService.cs | 31 ++++++++++++++++++++++ 5 files changed, 57 insertions(+), 4 deletions(-) create mode 100644 OpenSim/Services/Interfaces/IAttachmentsService.cs diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs index 8307467..1992bd4 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs @@ -27,6 +27,7 @@ using System.Collections.Generic; using System.Reflection; +using System.Xml; using log4net; using Nini.Config; using OpenMetaverse; @@ -191,8 +192,14 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments public UUID RezSingleAttachmentFromInventory( IClientAPI remoteClient, UUID itemID, uint AttachmentPt, bool updateInventoryStatus) + { + return RezSingleAttachmentFromInventory(remoteClient, itemID, AttachmentPt, true, null); + } + + public UUID RezSingleAttachmentFromInventory( + IClientAPI remoteClient, UUID itemID, uint AttachmentPt, bool updateInventoryStatus, XmlDocument doc) { - SceneObjectGroup att = RezSingleAttachmentFromInventoryInternal(remoteClient, itemID, AttachmentPt); + SceneObjectGroup att = RezSingleAttachmentFromInventoryInternal(remoteClient, itemID, AttachmentPt, doc); if (updateInventoryStatus) { @@ -211,7 +218,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments } protected SceneObjectGroup RezSingleAttachmentFromInventoryInternal( - IClientAPI remoteClient, UUID itemID, uint AttachmentPt) + IClientAPI remoteClient, UUID itemID, uint AttachmentPt, XmlDocument doc) { IInventoryAccessModule invAccess = m_scene.RequestModuleInterface(); if (invAccess != null) @@ -237,6 +244,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments if (tainted) objatt.HasGroupChanged = true; + if (doc != null) + objatt.LoadScriptState(doc); + // Fire after attach, so we don't get messy perms dialogs // 3 == AttachedRez objatt.CreateScriptInstances(0, true, m_scene.DefaultScriptEngine, 3); @@ -318,6 +328,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments { // XXYY!! InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId); + if (item == null) + m_log.Error("[ATTACHMENT]: item == null"); + if (m_scene == null) + m_log.Error("[ATTACHMENT]: m_scene == null"); + if (m_scene.InventoryService == null) + m_log.Error("[ATTACHMENT]: m_scene.InventoryService == null"); item = m_scene.InventoryService.GetItem(item); presence.Appearance.SetAttachment((int)AttachmentPt, itemID, item.AssetID /* att.UUID */); diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs index 2352ced..c50abb8 100644 --- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs +++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs @@ -524,6 +524,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess } else { + throw new Exception("AttachTracer"); group.SetFromItemID(itemID); } diff --git a/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs b/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs index f8af367..958847b 100644 --- a/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs @@ -26,6 +26,7 @@ */ using System; +using System.Xml; using OpenMetaverse; using OpenMetaverse.Packets; using OpenSim.Framework; @@ -82,6 +83,10 @@ namespace OpenSim.Region.Framework.Interfaces UUID RezSingleAttachmentFromInventory( IClientAPI remoteClient, UUID itemID, uint AttachmentPt, bool updateInventoryStatus); + // Same as above, but also load script states from a separate doc + UUID RezSingleAttachmentFromInventory( + IClientAPI remoteClient, UUID itemID, uint AttachmentPt, bool updateInventoryStatus, XmlDocument doc); + /// /// Rez multiple attachments from a user's inventory /// @@ -132,4 +137,4 @@ namespace OpenSim.Region.Framework.Interfaces /// void ShowDetachInUserInventory(UUID itemID, IClientAPI remoteClient); } -} \ No newline at end of file +} diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index c220bf0..a5c0b0d 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -3984,7 +3984,7 @@ Console.WriteLine("Scripted Sit ofset {0}", m_pos); { // Rez from inventory UUID asset - = m_scene.AttachmentsModule.RezSingleAttachmentFromInventory(ControllingClient, itemID, (uint)p); + = m_scene.AttachmentsModule.RezSingleAttachmentFromInventory(ControllingClient, itemID, (uint)p, true, null); m_log.InfoFormat( "[ATTACHMENT]: Rezzed attachment in point {0} from item {1} and asset {2} ({3})", diff --git a/OpenSim/Services/Interfaces/IAttachmentsService.cs b/OpenSim/Services/Interfaces/IAttachmentsService.cs new file mode 100644 index 0000000..3b9f2f2 --- /dev/null +++ b/OpenSim/Services/Interfaces/IAttachmentsService.cs @@ -0,0 +1,31 @@ +//////////////////////////////////////////////////////////////// +// +// (c) 2009, 2010 Careminster Limited and Melanie Thielker +// +// All rights reserved +// +using System; +using System.Diagnostics; +using System.Collections.Generic; +using System.IO; +using System.Text; +using System.Threading; +using System.Reflection; +using OpenSim.Framework; +using OpenSim.Framework.Console; +using OpenSim.Server.Base; +using OpenSim.Services.Base; +using OpenSim.Services.Interfaces; +using Nini.Config; +using log4net; +using Careminster; +using OpenMetaverse; + +namespace Careminster +{ + public interface IAttachmentsService + { + string Get(string id); + void Store(string id, string data); + } +} -- cgit v1.1