From 70fa30204272e874b8e3acccdc2e22cd4e42b2b2 Mon Sep 17 00:00:00 2001 From: MW Date: Sun, 22 Jul 2007 11:44:36 +0000 Subject: * Some work in progress code: Inventory cache, start of inventory server/service, userprofile cache, inventory handling. (non of it is enabled yet (or at least it shouldn't be). * Fixed some of the problems with crossing regions when flying: you should no longer sink to ground level when crossing (should keep roughly your right height). Should no longer sometimes get sent back to the centre of the current region when attempting to border cross. But instead sometimes you will find you avatar stop at the edge of region and you will need to start moving again to retry the crossing (which should then work). This code is partly based on Babblefrog's issue #212 patch. [I think I have some ideas of how to solve the stopping at edges problem, just want to get the inventory code done first] * Capabilities code has now been moved to the OpenSim.Framework.Communications project as some of the caps code will be tightly tied to inventory/asset handling and it was causing a two way reference problem when it was in its own project/dll. This is a Big commit as I was going to keep my inventory work local until I had it in a working state, in case it brakes anything, but its getting harder to keep in sync with svn. --- .../Framework/Communications/Capabilities/Caps.cs | 359 +++++++++++ .../Communications/Capabilities/LLSDArray.cs | 42 ++ .../Capabilities/LLSDAssetUploadComplete.cs | 45 ++ .../Capabilities/LLSDAssetUploadRequest.cs | 21 + .../Capabilities/LLSDAssetUploadResponse.cs | 18 + .../Communications/Capabilities/LLSDCapEvent.cs | 41 ++ .../Communications/Capabilities/LLSDCapsDetails.cs | 18 + .../Communications/Capabilities/LLSDEmpty.cs | 38 ++ .../Communications/Capabilities/LLSDHelpers.cs | 164 +++++ .../Communications/Capabilities/LLSDMapLayer.cs | 46 ++ .../Capabilities/LLSDMapLayerResponse.cs | 41 ++ .../Communications/Capabilities/LLSDMapRequest.cs | 13 + .../Communications/Capabilities/LLSDMethod.cs | 8 + .../Capabilities/LLSDStreamHandler.cs | 42 ++ .../Communications/Capabilities/LLSDTest.cs | 41 ++ .../Communications/Capabilities/LLSDType.cs | 59 ++ .../Communications/CommunicationsManager.cs | 5 +- .../Communications/IInterRegionCommunications.cs | 7 +- .../Communications/caches/CachedUserInfo.cs | 77 --- .../Communications/caches/InventoryFolder.cs | 61 -- .../Communications/caches/UserProfileCache.cs | 168 ------ OpenSim/Framework/Data.MySQL/MySQLInventoryData.cs | 34 ++ OpenSim/Framework/Data/InventoryData.cs | 13 +- OpenSim/Framework/General/IRegionCommsListener.cs | 4 +- OpenSim/Framework/General/Interfaces/IClientAPI.cs | 7 +- OpenSim/Framework/General/NullClientAPI.cs | 4 +- OpenSim/Framework/General/RegionCommsListener.cs | 15 +- .../InventoryServiceBase/InventoryServiceBase.cs | 136 +++++ .../Properties/AssemblyInfo.cs | 35 ++ OpenSim/Region/Application/OpenSimMain.cs | 9 +- OpenSim/Region/Caches/AssetCache.cs | 669 --------------------- OpenSim/Region/Caches/Properties/AssemblyInfo.cs | 33 - OpenSim/Region/Capabilities/Caps.cs | 330 ---------- OpenSim/Region/Capabilities/LLSDArray.cs | 42 -- .../Region/Capabilities/LLSDAssetUploadComplete.cs | 44 -- .../Region/Capabilities/LLSDAssetUploadRequest.cs | 21 - .../Region/Capabilities/LLSDAssetUploadResponse.cs | 18 - OpenSim/Region/Capabilities/LLSDCapEvent.cs | 41 -- OpenSim/Region/Capabilities/LLSDCapsDetails.cs | 17 - OpenSim/Region/Capabilities/LLSDEmpty.cs | 38 -- OpenSim/Region/Capabilities/LLSDHelpers.cs | 164 ----- OpenSim/Region/Capabilities/LLSDMapLayer.cs | 46 -- .../Region/Capabilities/LLSDMapLayerResponse.cs | 41 -- OpenSim/Region/Capabilities/LLSDMapRequest.cs | 13 - OpenSim/Region/Capabilities/LLSDMethod.cs | 8 - OpenSim/Region/Capabilities/LLSDStreamHandler.cs | 42 -- OpenSim/Region/Capabilities/LLSDTest.cs | 41 -- OpenSim/Region/Capabilities/LLSDType.cs | 59 -- OpenSim/Region/ClientStack/ClientView.API.cs | 4 +- .../ClientStack/ClientView.AgentAssetUpload.cs | 3 +- .../ClientStack/ClientView.ProcessPackets.cs | 23 +- OpenSim/Region/ClientStack/ClientView.cs | 3 +- OpenSim/Region/ClientStack/PacketServer.cs | 2 +- .../Region/ClientStack/RegionApplicationBase.cs | 2 +- OpenSim/Region/ClientStack/UDPServer.cs | 2 +- .../Communications/Local/CommunicationsLocal.cs | 5 +- .../Communications/Local/LocalBackEndServices.cs | 13 +- .../Communications/OGS1/CommunicationsOGS1.cs | 4 +- .../Region/Communications/OGS1/OGS1GridServices.cs | 19 +- .../Communications/OGS1/OGS1InterSimComms.cs | 10 +- OpenSim/Region/Environment/Scenes/Primitive.cs | 10 + .../Environment/Scenes/Scene.PacketHandlers.cs | 72 ++- OpenSim/Region/Environment/Scenes/Scene.cs | 21 +- OpenSim/Region/Environment/Scenes/SceneBase.cs | 2 +- OpenSim/Region/Environment/Scenes/SceneObject.cs | 5 - OpenSim/Region/Environment/Scenes/ScenePresence.cs | 10 +- .../Region/Examples/SimpleApp/MyNpcCharacter.cs | 4 +- OpenSim/Region/Examples/SimpleApp/MyWorld.cs | 3 +- OpenSim/Region/Examples/SimpleApp/Program.cs | 5 +- 69 files changed, 1417 insertions(+), 2043 deletions(-) create mode 100644 OpenSim/Framework/Communications/Capabilities/Caps.cs create mode 100644 OpenSim/Framework/Communications/Capabilities/LLSDArray.cs create mode 100644 OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadComplete.cs create mode 100644 OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadRequest.cs create mode 100644 OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadResponse.cs create mode 100644 OpenSim/Framework/Communications/Capabilities/LLSDCapEvent.cs create mode 100644 OpenSim/Framework/Communications/Capabilities/LLSDCapsDetails.cs create mode 100644 OpenSim/Framework/Communications/Capabilities/LLSDEmpty.cs create mode 100644 OpenSim/Framework/Communications/Capabilities/LLSDHelpers.cs create mode 100644 OpenSim/Framework/Communications/Capabilities/LLSDMapLayer.cs create mode 100644 OpenSim/Framework/Communications/Capabilities/LLSDMapLayerResponse.cs create mode 100644 OpenSim/Framework/Communications/Capabilities/LLSDMapRequest.cs create mode 100644 OpenSim/Framework/Communications/Capabilities/LLSDMethod.cs create mode 100644 OpenSim/Framework/Communications/Capabilities/LLSDStreamHandler.cs create mode 100644 OpenSim/Framework/Communications/Capabilities/LLSDTest.cs create mode 100644 OpenSim/Framework/Communications/Capabilities/LLSDType.cs delete mode 100644 OpenSim/Framework/Communications/caches/CachedUserInfo.cs delete mode 100644 OpenSim/Framework/Communications/caches/InventoryFolder.cs delete mode 100644 OpenSim/Framework/Communications/caches/UserProfileCache.cs create mode 100644 OpenSim/Framework/InventoryServiceBase/InventoryServiceBase.cs create mode 100644 OpenSim/Framework/InventoryServiceBase/Properties/AssemblyInfo.cs delete mode 100644 OpenSim/Region/Caches/AssetCache.cs delete mode 100644 OpenSim/Region/Caches/Properties/AssemblyInfo.cs delete mode 100644 OpenSim/Region/Capabilities/Caps.cs delete mode 100644 OpenSim/Region/Capabilities/LLSDArray.cs delete mode 100644 OpenSim/Region/Capabilities/LLSDAssetUploadComplete.cs delete mode 100644 OpenSim/Region/Capabilities/LLSDAssetUploadRequest.cs delete mode 100644 OpenSim/Region/Capabilities/LLSDAssetUploadResponse.cs delete mode 100644 OpenSim/Region/Capabilities/LLSDCapEvent.cs delete mode 100644 OpenSim/Region/Capabilities/LLSDCapsDetails.cs delete mode 100644 OpenSim/Region/Capabilities/LLSDEmpty.cs delete mode 100644 OpenSim/Region/Capabilities/LLSDHelpers.cs delete mode 100644 OpenSim/Region/Capabilities/LLSDMapLayer.cs delete mode 100644 OpenSim/Region/Capabilities/LLSDMapLayerResponse.cs delete mode 100644 OpenSim/Region/Capabilities/LLSDMapRequest.cs delete mode 100644 OpenSim/Region/Capabilities/LLSDMethod.cs delete mode 100644 OpenSim/Region/Capabilities/LLSDStreamHandler.cs delete mode 100644 OpenSim/Region/Capabilities/LLSDTest.cs delete mode 100644 OpenSim/Region/Capabilities/LLSDType.cs (limited to 'OpenSim') diff --git a/OpenSim/Framework/Communications/Capabilities/Caps.cs b/OpenSim/Framework/Communications/Capabilities/Caps.cs new file mode 100644 index 0000000..3b1cc6a --- /dev/null +++ b/OpenSim/Framework/Communications/Capabilities/Caps.cs @@ -0,0 +1,359 @@ +/* +* Copyright (c) Contributors, http://www.openmetaverse.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; +using System.Collections; +using System.Collections.Generic; +using System.Text; +using System.IO; +using libsecondlife; +using OpenSim.Framework.Servers; +using OpenSim.Framework.Types; +using OpenSim.Framework.Utilities; +using OpenSim.Framework.Communications.Caches; + +namespace OpenSim.Region.Capabilities +{ + public delegate void UpLoadedTexture(string assetName, LLUUID assetID, LLUUID inventoryItem, byte[] data); + + public class Caps + { + private string m_httpListenerHostName; + private int m_httpListenPort; + private string m_capsObjectPath = "00001-"; + private string m_requestPath = "0000/"; + private string m_mapLayerPath = "0001/"; + private string m_newInventory = "0002/"; + // private string m_requestTexture = "0003/"; + private string m_notecardUpdatePath = "0004/"; + //private string eventQueue = "0100/"; + private BaseHttpServer httpListener; + private LLUUID agentID; + private AssetCache assetCache; + private int eventQueueCount = 1; + private Queue CapsEventQueue = new Queue(); + + public Caps(AssetCache assetCach, BaseHttpServer httpServer, string httpListen, int httpPort, string capsPath, LLUUID agent) + { + assetCache = assetCach; + m_capsObjectPath = capsPath; + httpListener = httpServer; + m_httpListenerHostName = httpListen; + m_httpListenPort = httpPort; + agentID = agent; + } + + /// + /// + /// + public void RegisterHandlers() + { + Console.WriteLine("registering CAPS handlers"); + string capsBase = "/CAPS/" + m_capsObjectPath; + + httpListener.AddStreamHandler(new LLSDStreamhandler("POST", capsBase + m_mapLayerPath, this.GetMapLayer )); + httpListener.AddStreamHandler( new LLSDStreamhandler("POST", capsBase + m_newInventory, this.NewAgentInventoryRequest)); + + AddLegacyCapsHandler(httpListener, m_requestPath, CapsRequest); + AddLegacyCapsHandler(httpListener, m_notecardUpdatePath, NoteCardAgentInventory); + } + + [Obsolete("Use BaseHttpServer.AddStreamHandler(new LLSDStreamHandler( LLSDMethod delegate )) instead.")] + private void AddLegacyCapsHandler(BaseHttpServer httpListener, string path, RestMethod restMethod) + { + string capsBase = "/CAPS/" + m_capsObjectPath; + httpListener.AddStreamHandler(new RestStreamHandler("POST", capsBase + path, restMethod)); + } + + /// + /// + /// + /// + /// + /// + /// + public string CapsRequest(string request, string path, string param) + { + //Console.WriteLine("caps request " + request); + string result = LLSDHelpers.SerialiseLLSDReply(this.GetCapabilities()); + return result; + } + + /// + /// + /// + /// + protected LLSDCapsDetails GetCapabilities() + { + LLSDCapsDetails caps = new LLSDCapsDetails(); + string capsBaseUrl = "http://" + m_httpListenerHostName + ":" + m_httpListenPort.ToString() + "/CAPS/" + m_capsObjectPath; + caps.MapLayer = capsBaseUrl + m_mapLayerPath; + caps.NewFileAgentInventory = capsBaseUrl + m_newInventory; + //caps.RequestTextureDownload = capsBaseUrl + m_requestTexture; + caps.UpdateNotecardAgentInventory = capsBaseUrl + m_notecardUpdatePath; + return caps; + } + + /// + /// + /// + /// + /// + public LLSDMapLayerResponse GetMapLayer(LLSDMapRequest mapReq) + { + LLSDMapLayerResponse mapResponse = new LLSDMapLayerResponse(); + mapResponse.LayerData.Array.Add(this.GetLLSDMapLayerResponse()); + return mapResponse; + } + + /// + /// + /// + /// + protected LLSDMapLayer GetLLSDMapLayerResponse() + { + LLSDMapLayer mapLayer = new LLSDMapLayer(); + mapLayer.Right = 5000; + mapLayer.Top = 5000; + mapLayer.ImageID = new LLUUID("00000000-0000-0000-9999-000000000006"); + return mapLayer; + } + + /// + /// + /// + /// + /// + /// + /// + public string RequestTexture(string request, string path, string param) + { + Console.WriteLine("texture request " + request); + // Needs implementing (added to remove compiler warning) + return ""; + } + + #region EventQueue (Currently not enabled) + /// + /// + /// + /// + /// + /// + /// + public string ProcessEventQueue(string request, string path, string param) + { + string res = ""; + + if (this.CapsEventQueue.Count > 0) + { + lock (this.CapsEventQueue) + { + string item = CapsEventQueue.Dequeue(); + res = item; + } + } + else + { + res = this.CreateEmptyEventResponse(); + } + return res; + } + + /// + /// + /// + /// + /// + /// + public string CreateEstablishAgentComms(string caps, string ipAddressPort) + { + LLSDCapEvent eventItem = new LLSDCapEvent(); + eventItem.id = eventQueueCount; + //should be creating a EstablishAgentComms item, but there isn't a class for it yet + eventItem.events.Array.Add(new LLSDEmpty()); + string res = LLSDHelpers.SerialiseLLSDReply(eventItem); + eventQueueCount++; + + this.CapsEventQueue.Enqueue(res); + return res; + } + + /// + /// + /// + /// + public string CreateEmptyEventResponse() + { + LLSDCapEvent eventItem = new LLSDCapEvent(); + eventItem.id = eventQueueCount; + eventItem.events.Array.Add(new LLSDEmpty()); + string res = LLSDHelpers.SerialiseLLSDReply(eventItem); + eventQueueCount++; + return res; + } + #endregion + + /// + /// + /// + /// + /// + /// + /// + public string NoteCardAgentInventory(string request, string path, string param) + { + Console.WriteLine("notecard update request " + request); + string assetName = "notecardupdate"; + string capsBase = "/CAPS/" + m_capsObjectPath; + LLUUID newAsset = LLUUID.Random(); + LLUUID newInvItem = LLUUID.Random(); + string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString("0000"); + + AssetUploader uploader = new AssetUploader(assetName, newAsset, newInvItem, capsBase + uploaderPath, this.httpListener); + httpListener.AddStreamHandler(new BinaryStreamHandler("POST", capsBase + uploaderPath, uploader.uploaderCaps)); + string uploaderURL = "http://" + m_httpListenerHostName + ":" + m_httpListenPort.ToString() + capsBase + uploaderPath; + + LLSDAssetUploadResponse uploadResponse = new LLSDAssetUploadResponse(); + uploadResponse.uploader = uploaderURL; + uploadResponse.state = "upload"; + // uploader.OnUpLoad += this.UploadCompleteHandler; + return LLSDHelpers.SerialiseLLSDReply(uploadResponse); + } + + /// + /// + /// + /// + /// + public LLSDAssetUploadResponse NewAgentInventoryRequest(LLSDAssetUploadRequest llsdRequest) + { + // Console.WriteLine("asset upload request via CAPS"); + string assetName = llsdRequest.name; + string capsBase = "/CAPS/" + m_capsObjectPath; + LLUUID newAsset = LLUUID.Random(); + LLUUID newInvItem = LLUUID.Random(); + string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString("0000"); + + AssetUploader uploader = new AssetUploader(assetName, newAsset, newInvItem, capsBase + uploaderPath, this.httpListener); + httpListener.AddStreamHandler(new BinaryStreamHandler("POST", capsBase + uploaderPath, uploader.uploaderCaps)); + string uploaderURL = "http://" + m_httpListenerHostName + ":" + m_httpListenPort.ToString() + capsBase + uploaderPath; + + LLSDAssetUploadResponse uploadResponse = new LLSDAssetUploadResponse(); + uploadResponse.uploader = uploaderURL; + uploadResponse.state = "upload"; + uploader.OnUpLoad += this.UploadCompleteHandler; + return uploadResponse; + } + + /// + /// + /// + /// + /// + /// + public void UploadCompleteHandler(string assetName, LLUUID assetID, LLUUID inventoryItem, byte[] data) + { + AssetBase asset; + asset = new AssetBase(); + asset.FullID = assetID; + asset.Type = 0; + asset.InvType = 0; + asset.Name = assetName; + asset.Data = data; + this.assetCache.AddAsset(asset); + } + + public class AssetUploader + { + public event UpLoadedTexture OnUpLoad; + + private string uploaderPath = ""; + private LLUUID newAssetID; + private LLUUID inventoryItemID; + private BaseHttpServer httpListener; + private bool SaveImages = true; + private string m_assetName = ""; + + /// + /// + /// + /// + /// + /// + /// + public AssetUploader(string assetName, LLUUID assetID, LLUUID inventoryItem, string path, BaseHttpServer httpServer) + { + m_assetName = assetName; + newAssetID = assetID; + inventoryItemID = inventoryItem; + uploaderPath = path; + httpListener = httpServer; + } + + /// + /// + /// + /// + /// + /// + /// + public string uploaderCaps(byte[] data, string path, string param) + { + LLUUID inv = this.inventoryItemID; + string res = ""; + LLSDAssetUploadComplete uploadComplete = new LLSDAssetUploadComplete(); + uploadComplete.new_asset = newAssetID.ToStringHyphenated(); + uploadComplete.new_inventory_item = inv; + uploadComplete.state = "complete"; + + res = LLSDHelpers.SerialiseLLSDReply(uploadComplete); + + httpListener.RemoveStreamHandler("POST", uploaderPath); + + if(this.SaveImages) + this.SaveImageToFile(m_assetName + ".jp2", data); + + if (OnUpLoad != null) + { + OnUpLoad(m_assetName, newAssetID, inv, data); + } + + return res; + } + + private void SaveImageToFile(string filename, byte[] data) + { + FileStream fs = File.Create(filename); + BinaryWriter bw = new BinaryWriter(fs); + bw.Write(data); + bw.Close(); + fs.Close(); + } + } + } +} diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDArray.cs b/OpenSim/Framework/Communications/Capabilities/LLSDArray.cs new file mode 100644 index 0000000..e04849f --- /dev/null +++ b/OpenSim/Framework/Communications/Capabilities/LLSDArray.cs @@ -0,0 +1,42 @@ +/* +* Copyright (c) Contributors, http://www.openmetaverse.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; + +namespace OpenSim.Region.Capabilities +{ + [LLSDType("ARRAY")] + public class LLSDArray + { + public ArrayList Array = new ArrayList(); + + public LLSDArray() + { + + } + } +} diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadComplete.cs b/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadComplete.cs new file mode 100644 index 0000000..ce373c0 --- /dev/null +++ b/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadComplete.cs @@ -0,0 +1,45 @@ +/* +* Copyright (c) Contributors, http://www.openmetaverse.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 libsecondlife; + +namespace OpenSim.Region.Capabilities +{ + [LLSDType("MAP")] + public class LLSDAssetUploadComplete + { + public string new_asset = ""; + public LLUUID new_inventory_item = LLUUID.Zero; + public string state = ""; + //public bool success = false; + + public LLSDAssetUploadComplete() + { + + } + } +} diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadRequest.cs b/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadRequest.cs new file mode 100644 index 0000000..7ef77cb --- /dev/null +++ b/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadRequest.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Text; +using libsecondlife; + +namespace OpenSim.Region.Capabilities +{ + [LLSDMap] + public class LLSDAssetUploadRequest + { + public string asset_type = ""; + public string description = ""; + public LLUUID folder_id = LLUUID.Zero; + public string inventory_type = ""; + public string name = ""; + + public LLSDAssetUploadRequest() + { + } + } +} diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadResponse.cs b/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadResponse.cs new file mode 100644 index 0000000..1a620ae --- /dev/null +++ b/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadResponse.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace OpenSim.Region.Capabilities +{ + [LLSDMap] + public class LLSDAssetUploadResponse + { + public string uploader = ""; + public string state = ""; + + public LLSDAssetUploadResponse() + { + + } + } +} diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDCapEvent.cs b/OpenSim/Framework/Communications/Capabilities/LLSDCapEvent.cs new file mode 100644 index 0000000..51b4fe0 --- /dev/null +++ b/OpenSim/Framework/Communications/Capabilities/LLSDCapEvent.cs @@ -0,0 +1,41 @@ +/* +* Copyright (c) Contributors, http://www.openmetaverse.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. +* +*/ +namespace OpenSim.Region.Capabilities +{ + [LLSDType("MAP")] + public class LLSDCapEvent + { + public int id = 0; + public LLSDArray events = new LLSDArray(); + + public LLSDCapEvent() + { + + } + } +} diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDCapsDetails.cs b/OpenSim/Framework/Communications/Capabilities/LLSDCapsDetails.cs new file mode 100644 index 0000000..3b6a629 --- /dev/null +++ b/OpenSim/Framework/Communications/Capabilities/LLSDCapsDetails.cs @@ -0,0 +1,18 @@ +namespace OpenSim.Region.Capabilities +{ + [LLSDType("MAP")] + public class LLSDCapsDetails + { + public string MapLayer = ""; + public string NewFileAgentInventory = ""; + //public string EventQueueGet = ""; + //public string RequestTextureDownload = ""; + //public string ChatSessionRequest = ""; + public string UpdateNotecardAgentInventory = ""; + + public LLSDCapsDetails() + { + + } + } +} diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDEmpty.cs b/OpenSim/Framework/Communications/Capabilities/LLSDEmpty.cs new file mode 100644 index 0000000..d79c09e --- /dev/null +++ b/OpenSim/Framework/Communications/Capabilities/LLSDEmpty.cs @@ -0,0 +1,38 @@ +/* +* Copyright (c) Contributors, http://www.openmetaverse.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. +* +*/ +namespace OpenSim.Region.Capabilities +{ + [LLSDType("MAP")] + public class LLSDEmpty + { + public LLSDEmpty() + { + + } + } +} diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDHelpers.cs b/OpenSim/Framework/Communications/Capabilities/LLSDHelpers.cs new file mode 100644 index 0000000..19ef0c9 --- /dev/null +++ b/OpenSim/Framework/Communications/Capabilities/LLSDHelpers.cs @@ -0,0 +1,164 @@ +/* +* Copyright (c) Contributors, http://www.openmetaverse.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; +using System.Collections; +using System.IO; +using System.Reflection; +using System.Xml; +using libsecondlife; + +namespace OpenSim.Region.Capabilities +{ + public class LLSDHelpers + { + public static string SerialiseLLSDReply(object obj) + { + StringWriter sw = new StringWriter(); + XmlTextWriter writer = new XmlTextWriter(sw); + writer.Formatting = Formatting.None; + writer.WriteStartElement(String.Empty, "llsd", String.Empty); + SerializeLLSDType(writer, obj); + writer.WriteEndElement(); + writer.Close(); + return sw.ToString(); + } + + public static void SerializeLLSDType(XmlTextWriter writer, object obj) + { + Type myType = obj.GetType(); + LLSDType[] llsdattributes = (LLSDType[])myType.GetCustomAttributes(typeof(LLSDType), false); + if (llsdattributes.Length > 0) + { + switch (llsdattributes[0].ObjectType) + { + case "MAP": + writer.WriteStartElement(String.Empty, "map", String.Empty); + FieldInfo[] fields = myType.GetFields(); + for (int i = 0; i < fields.Length; i++) + { + object fieldValue = fields[i].GetValue(obj); + LLSDType[] fieldAttributes = (LLSDType[])fieldValue.GetType().GetCustomAttributes(typeof(LLSDType), false); + if (fieldAttributes.Length > 0) + { + writer.WriteStartElement(String.Empty, "key", String.Empty); + writer.WriteString(fields[i].Name); + writer.WriteEndElement(); + SerializeLLSDType(writer, fieldValue); + } + else + { + writer.WriteStartElement(String.Empty, "key", String.Empty); + writer.WriteString(fields[i].Name); + writer.WriteEndElement(); + LLSD.LLSDWriteOne(writer, fieldValue); + } + } + writer.WriteEndElement(); + break; + case "ARRAY": + // LLSDArray arrayObject = obj as LLSDArray; + // ArrayList a = arrayObject.Array; + ArrayList a = (ArrayList)obj.GetType().GetField("Array").GetValue(obj); + if (a != null) + { + writer.WriteStartElement(String.Empty, "array", String.Empty); + foreach (object item in a) + { + SerializeLLSDType(writer, item); + } + writer.WriteEndElement(); + } + break; + } + } + else + { + LLSD.LLSDWriteOne(writer, obj); + } + } + + public static object DeserialiseLLSDMap(Hashtable llsd, object obj) + { + Type myType = obj.GetType(); + LLSDType[] llsdattributes = (LLSDType[])myType.GetCustomAttributes(typeof(LLSDType), false); + if (llsdattributes.Length > 0) + { + switch (llsdattributes[0].ObjectType) + { + case "MAP": + IDictionaryEnumerator enumerator = llsd.GetEnumerator(); + while (enumerator.MoveNext()) + { + FieldInfo field = myType.GetField((string)enumerator.Key); + if (field != null) + { + if (enumerator.Value is Hashtable) + { + object fieldValue = field.GetValue(obj); + DeserialiseLLSDMap((Hashtable) enumerator.Value, fieldValue); + } + else if (enumerator.Value is ArrayList) + { + object fieldValue = field.GetValue(obj); + fieldValue.GetType().GetField("Array").SetValue(fieldValue, enumerator.Value); + //TODO + // the LLSD map/array types in the array need to be deserialised + // but first we need to know the right class to deserialise them into. + } + else + { + field.SetValue(obj, enumerator.Value); + } + } + } + break; + } + } + return obj; + } + } + + + + + + + + + + + + + + + + + + + +} diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDMapLayer.cs b/OpenSim/Framework/Communications/Capabilities/LLSDMapLayer.cs new file mode 100644 index 0000000..566d0e9 --- /dev/null +++ b/OpenSim/Framework/Communications/Capabilities/LLSDMapLayer.cs @@ -0,0 +1,46 @@ +/* +* Copyright (c) Contributors, http://www.openmetaverse.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 libsecondlife; + +namespace OpenSim.Region.Capabilities +{ + [LLSDType("MAP")] + public class LLSDMapLayer + { + public int Left = 0; + public int Right = 0; + public int Top = 0; + public int Bottom = 0; + public LLUUID ImageID = LLUUID.Zero; + + public LLSDMapLayer() + { + + } + } +} diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDMapLayerResponse.cs b/OpenSim/Framework/Communications/Capabilities/LLSDMapLayerResponse.cs new file mode 100644 index 0000000..ce746ae --- /dev/null +++ b/OpenSim/Framework/Communications/Capabilities/LLSDMapLayerResponse.cs @@ -0,0 +1,41 @@ +/* +* Copyright (c) Contributors, http://www.openmetaverse.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. +* +*/ +namespace OpenSim.Region.Capabilities +{ + [LLSDType("MAP")] + public class LLSDMapLayerResponse + { + public LLSDMapRequest AgentData = new LLSDMapRequest(); + public LLSDArray LayerData = new LLSDArray(); + + public LLSDMapLayerResponse() + { + + } + } +} diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDMapRequest.cs b/OpenSim/Framework/Communications/Capabilities/LLSDMapRequest.cs new file mode 100644 index 0000000..fb739cd --- /dev/null +++ b/OpenSim/Framework/Communications/Capabilities/LLSDMapRequest.cs @@ -0,0 +1,13 @@ +namespace OpenSim.Region.Capabilities +{ + [LLSDType("MAP")] + public class LLSDMapRequest + { + public int Flags = 0; + + public LLSDMapRequest() + { + + } + } +} diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDMethod.cs b/OpenSim/Framework/Communications/Capabilities/LLSDMethod.cs new file mode 100644 index 0000000..5f42f44 --- /dev/null +++ b/OpenSim/Framework/Communications/Capabilities/LLSDMethod.cs @@ -0,0 +1,8 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace OpenSim.Region.Capabilities +{ + public delegate TResponse LLSDMethod(TRequest request); +} diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDStreamHandler.cs b/OpenSim/Framework/Communications/Capabilities/LLSDStreamHandler.cs new file mode 100644 index 0000000..7d99b6e --- /dev/null +++ b/OpenSim/Framework/Communications/Capabilities/LLSDStreamHandler.cs @@ -0,0 +1,42 @@ +using System; +using System.Collections.Generic; +using System.Text; +using OpenSim.Framework.Servers; +using System.IO; +using System.Collections; +using libsecondlife; + +namespace OpenSim.Region.Capabilities +{ + public class LLSDStreamhandler : BaseStreamHandler + where TRequest : new() + { + private LLSDMethod m_method; + + public LLSDStreamhandler(string httpMethod, string path, LLSDMethod method) + : base(httpMethod, path ) + { + m_method = method; + } + + public override byte[] Handle(string path, Stream request) + { + //Encoding encoding = Encoding.UTF8; + //StreamReader streamReader = new StreamReader(request, false); + + //string requestBody = streamReader.ReadToEnd(); + //streamReader.Close(); + + Hashtable hash = (Hashtable)LLSD.LLSDDeserialize( request ); + TRequest llsdRequest = new TRequest(); + LLSDHelpers.DeserialiseLLSDMap(hash, llsdRequest); + + TResponse response = m_method(llsdRequest); + + Encoding encoding = new UTF8Encoding(false); + + return encoding.GetBytes( LLSDHelpers.SerialiseLLSDReply(response) ); + + } + } +} diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDTest.cs b/OpenSim/Framework/Communications/Capabilities/LLSDTest.cs new file mode 100644 index 0000000..f23e327 --- /dev/null +++ b/OpenSim/Framework/Communications/Capabilities/LLSDTest.cs @@ -0,0 +1,41 @@ +/* +* Copyright (c) Contributors, http://www.openmetaverse.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. +* +*/ +namespace OpenSim.Region.Capabilities +{ + [LLSDType("MAP")] + public class LLSDTest + { + public int Test1 = 20; + public int Test2 = 10; + + public LLSDTest() + { + + } + } +} diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDType.cs b/OpenSim/Framework/Communications/Capabilities/LLSDType.cs new file mode 100644 index 0000000..c58a937 --- /dev/null +++ b/OpenSim/Framework/Communications/Capabilities/LLSDType.cs @@ -0,0 +1,59 @@ +/* +* Copyright (c) Contributors, http://www.openmetaverse.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; + +namespace OpenSim.Region.Capabilities +{ + [AttributeUsage(AttributeTargets.Class)] + public class LLSDType : Attribute + { + protected string myType; + + public LLSDType(string type) + { + myType = type; + + } + + public string ObjectType + { + get + { + return myType; + } + } + } + + [AttributeUsage(AttributeTargets.Class)] + public class LLSDMap : LLSDType + { + public LLSDMap() : base( "MAP" ) + { + } + } +} diff --git a/OpenSim/Framework/Communications/CommunicationsManager.cs b/OpenSim/Framework/Communications/CommunicationsManager.cs index db34d1b..e220e17 100644 --- a/OpenSim/Framework/Communications/CommunicationsManager.cs +++ b/OpenSim/Framework/Communications/CommunicationsManager.cs @@ -33,6 +33,7 @@ using OpenSim.Framework.Interfaces; using OpenSim.Framework.Types; using OpenSim.Framework.Servers; using OpenSim.Framework.Communications.Caches; + namespace OpenSim.Framework.Communications { @@ -44,11 +45,13 @@ namespace OpenSim.Framework.Communications public IInventoryServices InventoryServer; public IInterRegionCommunications InterRegion; public UserProfileCache UserProfilesCache; + public AssetCache AssetCache; public NetworkServersInfo ServersInfo; - public CommunicationsManager(NetworkServersInfo serversInfo, BaseHttpServer httpServer) + public CommunicationsManager(NetworkServersInfo serversInfo, BaseHttpServer httpServer, AssetCache assetCache) { ServersInfo = serversInfo; + this.AssetCache = assetCache; UserProfilesCache = new UserProfileCache(this); } diff --git a/OpenSim/Framework/Communications/IInterRegionCommunications.cs b/OpenSim/Framework/Communications/IInterRegionCommunications.cs index 7758f2b..d82fa19 100644 --- a/OpenSim/Framework/Communications/IInterRegionCommunications.cs +++ b/OpenSim/Framework/Communications/IInterRegionCommunications.cs @@ -30,9 +30,10 @@ using OpenSim.Framework.Types; namespace OpenSim.Framework.Communications { - public interface IInterRegionCommunications + public interface IInterRegionCommunications { - bool InformRegionOfChildAgent(ulong regionHandle, AgentCircuitData agentData); - bool ExpectAvatarCrossing(ulong regionHandle, LLUUID agentID, LLVector3 position); + bool InformRegionOfChildAgent(ulong regionHandle, AgentCircuitData agentData); + bool ExpectAvatarCrossing(ulong regionHandle, LLUUID agentID, LLVector3 position, bool isFlying); + bool AcknowledgeAgentCrossed(ulong regionHandle, LLUUID agentID); } } diff --git a/OpenSim/Framework/Communications/caches/CachedUserInfo.cs b/OpenSim/Framework/Communications/caches/CachedUserInfo.cs deleted file mode 100644 index b8d8847..0000000 --- a/OpenSim/Framework/Communications/caches/CachedUserInfo.cs +++ /dev/null @@ -1,77 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using OpenSim.Framework.Data; -using libsecondlife; - -namespace OpenSim.Framework.Communications.Caches -{ - public class CachedUserInfo - { - public UserProfileData UserProfile; - //public Dictionary Folders = new Dictionary(); - public InventoryFolder RootFolder; - - public CachedUserInfo() - { - - } - - /// - /// - /// - /// - /// - public void FolderReceive(LLUUID userID, InventoryFolder folderInfo) - { - if (userID == UserProfile.UUID) - { - if (this.RootFolder == null) - { - if (folderInfo.parentID == LLUUID.Zero) - { - this.RootFolder = folderInfo; - } - } - else - { - if (this.RootFolder.folderID == folderInfo.parentID) - { - this.RootFolder.SubFolders.Add(folderInfo.folderID, folderInfo); - } - else - { - InventoryFolder pFolder = this.RootFolder.HasSubFolder(folderInfo.parentID); - if (pFolder != null) - { - pFolder.SubFolders.Add(folderInfo.folderID, folderInfo); - } - } - } - } - } - - public void ItemReceive(LLUUID userID, InventoryItemBase itemInfo) - { - if (userID == UserProfile.UUID) - { - if (this.RootFolder != null) - { - if (itemInfo.parentFolderID == this.RootFolder.folderID) - { - this.RootFolder.Items.Add(itemInfo.inventoryID, itemInfo); - } - else - { - InventoryFolder pFolder = this.RootFolder.HasSubFolder(itemInfo.parentFolderID); - if (pFolder != null) - { - pFolder.Items.Add(itemInfo.inventoryID, itemInfo); - } - } - } - - } - } - } -} diff --git a/OpenSim/Framework/Communications/caches/InventoryFolder.cs b/OpenSim/Framework/Communications/caches/InventoryFolder.cs deleted file mode 100644 index 8978cee..0000000 --- a/OpenSim/Framework/Communications/caches/InventoryFolder.cs +++ /dev/null @@ -1,61 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using libsecondlife; -using OpenSim.Framework.Data; - -namespace OpenSim.Framework.Communications.Caches -{ - public class InventoryFolder : InventoryFolderBase - { - public Dictionary SubFolders = new Dictionary(); - public Dictionary Items = new Dictionary(); - - public InventoryFolder() - { - } - - public InventoryFolder HasSubFolder(LLUUID folderID) - { - InventoryFolder returnFolder = null; - if (this.SubFolders.ContainsKey(folderID)) - { - returnFolder = this.SubFolders[folderID]; - } - else - { - foreach (InventoryFolder folder in this.SubFolders.Values) - { - returnFolder = folder.HasSubFolder(folderID); - if (returnFolder != null) - { - break; - } - } - } - return returnFolder; - } - - public InventoryFolder CreateNewSubFolder(LLUUID folderID, string folderName, ushort type ) - { - InventoryFolder subFold = new InventoryFolder(); - subFold.name = folderName; - subFold.folderID = folderID; - subFold.type = type; - subFold.parentID = this.folderID; - subFold.agentID = this.agentID; - this.SubFolders.Add(subFold.folderID, subFold); - return subFold; - } - - public List RequestListOfItems() - { - List itemList = new List(); - foreach (InventoryItemBase item in this.Items.Values) - { - itemList.Add(item); - } - return itemList; - } - } -} diff --git a/OpenSim/Framework/Communications/caches/UserProfileCache.cs b/OpenSim/Framework/Communications/caches/UserProfileCache.cs deleted file mode 100644 index bfb6f07..0000000 --- a/OpenSim/Framework/Communications/caches/UserProfileCache.cs +++ /dev/null @@ -1,168 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using libsecondlife; -using OpenSim.Framework.Interfaces; -using OpenSim.Framework.Data; -using OpenSim.Framework.Communications; - -namespace OpenSim.Framework.Communications.Caches -{ - public class UserProfileCache - { - public Dictionary UserProfiles = new Dictionary(); - - private CommunicationsManager m_parent; - - public UserProfileCache(CommunicationsManager parent) - { - m_parent = parent; - } - - /// - /// A new user has moved into a region in this instance - /// so get info from servers - /// - /// - public void AddNewUser(LLUUID userID) - { - if (!this.UserProfiles.ContainsKey(userID)) - { - CachedUserInfo userInfo = new CachedUserInfo(); - userInfo.UserProfile = this.RequestUserProfileForUser(userID); - - if (userInfo.UserProfile != null) - { - this.RequestInventoryForUser(userID, userInfo); - this.UserProfiles.Add(userID, userInfo); - } - else - { - //no profile for this user, what do we do now? - Console.WriteLine("UserProfileCache.cs: user profile for user not found"); - - } - } - else - { - //already have a cached profile for this user - //we should make sure its upto date with the user server version - } - } - - /// - /// A new user has moved into a region in this instance - /// so get info from servers - /// - /// - /// - public void AddNewUser(string firstName, string lastName) - { - - } - - /// - /// A user has left this instance - /// so make sure servers have been updated - /// Then remove cached info - /// - /// - public void UserLogOut(LLUUID userID) - { - - } - - public void HandleCreateInventoryFolder(IClientAPI remoteClient, LLUUID folderID, ushort folderType, string folderName, LLUUID parentID) - { - if (this.UserProfiles.ContainsKey(remoteClient.AgentId)) - { - CachedUserInfo userInfo = this.UserProfiles[remoteClient.AgentId]; - if (userInfo.RootFolder.folderID == parentID) - { - userInfo.RootFolder.CreateNewSubFolder(folderID, folderName, folderType); - } - else - { - InventoryFolder parentFolder = userInfo.RootFolder.HasSubFolder(parentID); - if (parentFolder != null) - { - parentFolder.CreateNewSubFolder(folderID, folderName, folderType); - } - } - } - } - - public void HandleFecthInventoryDescendents(IClientAPI remoteClient, LLUUID folderID, LLUUID ownerID, bool fetchFolders, bool fetchItems, int sortOrder) - { - if (this.UserProfiles.ContainsKey(remoteClient.AgentId)) - { - CachedUserInfo userInfo = this.UserProfiles[remoteClient.AgentId]; - if (userInfo.RootFolder.folderID == folderID) - { - if (fetchItems) - { - remoteClient.SendInventoryFolderDetails(remoteClient.AgentId, folderID, userInfo.RootFolder.RequestListOfItems()); - } - } - else - { - InventoryFolder parentFolder = userInfo.RootFolder.HasSubFolder(folderID); - if(parentFolder != null) - { - if(fetchItems) - { - remoteClient.SendInventoryFolderDetails(remoteClient.AgentId, folderID, parentFolder.RequestListOfItems()); - } - } - } - } - } - - /// - /// Request the user profile from User server - /// - /// - private UserProfileData RequestUserProfileForUser(LLUUID userID) - { - return this.m_parent.UserServer.GetUserProfile(userID); - } - - /// - /// Request Iventory Info from Inventory server - /// - /// - private void RequestInventoryForUser(LLUUID userID, CachedUserInfo userInfo) - { - // this.m_parent.InventoryServer.RequestInventoryForUser(userID, userInfo.FolderReceive, userInfo.ItemReceive); - - //for now we manually create the root folder, - // but should be requesting all inventory from inventory server. - InventoryFolder rootFolder = new InventoryFolder(); - rootFolder.agentID = userID; - rootFolder.folderID = userInfo.UserProfile.rootInventoryFolderID; - rootFolder.name = "My Inventory"; - rootFolder.parentID = LLUUID.Zero; - rootFolder.type = 8; - rootFolder.version = 1; - userInfo.FolderReceive(userID, rootFolder); - } - - /// - /// Make sure UserProfile is updated on user server - /// - /// - private void UpdateUserProfileToServer(LLUUID userID) - { - - } - - /// - /// Update Inventory data to Inventory server - /// - /// - private void UpdateInventoryToServer(LLUUID userID) - { - - } - } -} diff --git a/OpenSim/Framework/Data.MySQL/MySQLInventoryData.cs b/OpenSim/Framework/Data.MySQL/MySQLInventoryData.cs index d32db1b..d8bfc4d 100644 --- a/OpenSim/Framework/Data.MySQL/MySQLInventoryData.cs +++ b/OpenSim/Framework/Data.MySQL/MySQLInventoryData.cs @@ -152,6 +152,40 @@ namespace OpenSim.Framework.Data.MySQL } /// + /// Returns the users inventory root folder. + /// + /// + /// + public InventoryFolderBase getUserRootFolder(LLUUID user) + { + try + { + lock (database) + { + Dictionary param = new Dictionary(); + param["?uuid"] = user.ToStringHyphenated(); + param["?zero"] = LLUUID.Zero.ToStringHyphenated(); + + IDbCommand result = database.Query("SELECT * FROM inventoryfolders WHERE parentFolderID = ?zero AND agentID = ?uuid", param); + IDataReader reader = result.ExecuteReader(); + + List items = database.readInventoryFolders(reader); + InventoryFolderBase rootFolder = items[0]; //should only be one folder with parent set to zero (the root one). + reader.Close(); + result.Dispose(); + + return rootFolder; + } + } + catch (Exception e) + { + database.Reconnect(); + Console.WriteLine(e.ToString()); + return null; + } + } + + /// /// Returns a list of folders in a users inventory contained within the specified folder /// /// The folder to search diff --git a/OpenSim/Framework/Data/InventoryData.cs b/OpenSim/Framework/Data/InventoryData.cs index f6aeb58..87013cf 100644 --- a/OpenSim/Framework/Data/InventoryData.cs +++ b/OpenSim/Framework/Data/InventoryData.cs @@ -143,13 +143,20 @@ namespace OpenSim.Framework.Data List getInventoryInFolder(LLUUID folderID); /// - /// Returns a list of folders in the users inventory root. + /// Returns a list of the root folders within a users inventory /// - /// The UUID of the user who is having inventory being returned - /// A list of folders + /// The user whos inventory is to be searched + /// A list of folder objects List getUserRootFolders(LLUUID user); /// + /// Returns the users inventory root folder. + /// + /// The UUID of the user who is having inventory being returned + /// Root inventory folder + InventoryFolderBase getUserRootFolder(LLUUID user); + + /// /// Returns a list of inventory folders contained in the folder 'parentID' /// /// The folder to get subfolders for diff --git a/OpenSim/Framework/General/IRegionCommsListener.cs b/OpenSim/Framework/General/IRegionCommsListener.cs index 81da5d4..b746671 100644 --- a/OpenSim/Framework/General/IRegionCommsListener.cs +++ b/OpenSim/Framework/General/IRegionCommsListener.cs @@ -34,13 +34,15 @@ namespace OpenSim.Framework { public delegate void ExpectUserDelegate(ulong regionHandle, AgentCircuitData agent); public delegate void UpdateNeighbours(List neighbours); - public delegate void AgentCrossing(ulong regionHandle, LLUUID agentID, LLVector3 position); + public delegate void AgentCrossing(ulong regionHandle, LLUUID agentID, LLVector3 position, bool isFlying); + public delegate void AcknowledgeAgentCross(ulong regionHandle, LLUUID agentID); public interface IRegionCommsListener { event ExpectUserDelegate OnExpectUser; event GenericCall2 OnExpectChildAgent; event AgentCrossing OnAvatarCrossingIntoRegion; + event AcknowledgeAgentCross OnAcknowledgeAgentCrossed; event UpdateNeighbours OnNeighboursUpdate; } } diff --git a/OpenSim/Framework/General/Interfaces/IClientAPI.cs b/OpenSim/Framework/General/Interfaces/IClientAPI.cs index df65027..c2af2f4 100644 --- a/OpenSim/Framework/General/Interfaces/IClientAPI.cs +++ b/OpenSim/Framework/General/Interfaces/IClientAPI.cs @@ -81,8 +81,9 @@ namespace OpenSim.Framework.Interfaces public delegate void AddNewPrim(LLUUID ownerID, LLVector3 pos, PrimitiveBaseShape shape); public delegate void CreateInventoryFolder(IClientAPI remoteClient, LLUUID folderID, ushort folderType, string folderName, LLUUID parentID); + public delegate void CreateNewInventoryItem(IClientAPI remoteClient, LLUUID transActionID, LLUUID folderID, uint callbackID, string description, string name, sbyte invType, sbyte type, byte wearableType, uint nextOwnerMask); public delegate void FetchInventoryDescendents(IClientAPI remoteClient, LLUUID folderID, LLUUID ownerID, bool fetchFolders, bool fetchItems, int sortOrder); - + public delegate void FetchInventory(IClientAPI remoteClient, LLUUID itemID, LLUUID ownerID); public delegate void RequestTaskInventory(IClientAPI remoteClient, uint localID); public interface IClientAPI @@ -128,8 +129,10 @@ namespace OpenSim.Framework.Interfaces event NewAvatar OnNewAvatar; event GenericCall6 OnRemoveAvatar; + event CreateNewInventoryItem OnCreateNewInventoryItem; event CreateInventoryFolder OnCreateNewInventoryFolder; event FetchInventoryDescendents OnFetchInventoryDescendents; + event FetchInventory OnFetchInventory; event RequestTaskInventory OnRequestTaskInventory; event UUIDNameRequest OnNameFromUUIDRequest; @@ -194,7 +197,7 @@ namespace OpenSim.Framework.Interfaces void SendPrimTerseUpdate(ulong regionHandle, ushort timeDilation, uint localID, LLVector3 position, LLQuaternion rotation); void SendInventoryFolderDetails(LLUUID ownerID, LLUUID folderID, List items); - void SendInventoryItemDetails(LLUUID ownerID, LLUUID folderID, InventoryItemBase item); + void SendInventoryItemDetails(LLUUID ownerID, InventoryItemBase item); void SendInventoryItemUpdate(InventoryItemBase Item); void SendTaskInventory(LLUUID taskID, short serial, byte[] fileName); diff --git a/OpenSim/Framework/General/NullClientAPI.cs b/OpenSim/Framework/General/NullClientAPI.cs index 18ac527..1b42064 100644 --- a/OpenSim/Framework/General/NullClientAPI.cs +++ b/OpenSim/Framework/General/NullClientAPI.cs @@ -52,8 +52,10 @@ namespace OpenSim.Framework public event NewAvatar OnNewAvatar; public event GenericCall6 OnRemoveAvatar; + public event CreateNewInventoryItem OnCreateNewInventoryItem; public event CreateInventoryFolder OnCreateNewInventoryFolder; public event FetchInventoryDescendents OnFetchInventoryDescendents; + public event FetchInventory OnFetchInventory; public event RequestTaskInventory OnRequestTaskInventory; public event UUIDNameRequest OnNameFromUUIDRequest; @@ -127,7 +129,7 @@ namespace OpenSim.Framework public virtual void SendPrimTerseUpdate(ulong regionHandle, ushort timeDilation, uint localID, LLVector3 position, LLQuaternion rotation){} public virtual void SendInventoryFolderDetails(LLUUID ownerID, LLUUID folderID, List items){} - public virtual void SendInventoryItemDetails(LLUUID ownerID, LLUUID folderID, InventoryItemBase item){} + public virtual void SendInventoryItemDetails(LLUUID ownerID, InventoryItemBase item){} public virtual void SendInventoryItemUpdate(InventoryItemBase Item) { } public virtual void SendTaskInventory(LLUUID taskID, short serial, byte[] fileName) { } diff --git a/OpenSim/Framework/General/RegionCommsListener.cs b/OpenSim/Framework/General/RegionCommsListener.cs index f5b8272..f7edb7e 100644 --- a/OpenSim/Framework/General/RegionCommsListener.cs +++ b/OpenSim/Framework/General/RegionCommsListener.cs @@ -39,6 +39,7 @@ namespace OpenSim.Framework public event GenericCall2 OnExpectChildAgent; public event AgentCrossing OnAvatarCrossingIntoRegion; public event UpdateNeighbours OnNeighboursUpdate; + public event AcknowledgeAgentCross OnAcknowledgeAgentCrossed; /// /// @@ -57,11 +58,21 @@ namespace OpenSim.Framework return false; } - public virtual bool TriggerExpectAvatarCrossing(ulong regionHandle, LLUUID agentID, LLVector3 position) + public virtual bool TriggerExpectAvatarCrossing(ulong regionHandle, LLUUID agentID, LLVector3 position, bool isFlying) { if (OnAvatarCrossingIntoRegion != null) { - OnAvatarCrossingIntoRegion(regionHandle, agentID, position); + OnAvatarCrossingIntoRegion(regionHandle, agentID, position, isFlying); + return true; + } + return false; + } + + public virtual bool TriggerAcknowledgeAgentCrossed(ulong regionHandle, LLUUID agentID) + { + if (OnAcknowledgeAgentCrossed != null) + { + OnAcknowledgeAgentCrossed(regionHandle, agentID); return true; } return false; diff --git a/OpenSim/Framework/InventoryServiceBase/InventoryServiceBase.cs b/OpenSim/Framework/InventoryServiceBase/InventoryServiceBase.cs new file mode 100644 index 0000000..d407cdb --- /dev/null +++ b/OpenSim/Framework/InventoryServiceBase/InventoryServiceBase.cs @@ -0,0 +1,136 @@ +using System; +using System.Collections.Generic; +using System.Reflection; +using System.Text; +using libsecondlife; +using OpenSim.Framework.Console; +using OpenSim.Framework.Interfaces; +using OpenSim.Framework.Data; + +namespace OpenSim.Framework.InventoryServiceBase +{ + public class InventoryServiceBase + { + protected Dictionary m_plugins = new Dictionary(); + protected IAssetServer m_assetServer; + + public InventoryServiceBase(IAssetServer assetServer) + { + m_assetServer = assetServer; + } + + /// + /// Adds a new user server plugin - plugins will be requested in the order they were loaded. + /// + /// The filename to the user server plugin DLL + public void AddPlugin(string FileName) + { + MainLog.Instance.Verbose("Inventorytorage: Attempting to load " + FileName); + Assembly pluginAssembly = Assembly.LoadFrom(FileName); + + foreach (Type pluginType in pluginAssembly.GetTypes()) + { + if (!pluginType.IsAbstract) + { + Type typeInterface = pluginType.GetInterface("IInventoryData", true); + + if (typeInterface != null) + { + IInventoryData plug = (IInventoryData)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); + plug.Initialise(); + this.m_plugins.Add(plug.getName(), plug); + MainLog.Instance.Verbose("Inventorystorage: Added IInventoryData Interface"); + } + + typeInterface = null; + } + } + + pluginAssembly = null; + } + + /// + /// + /// + /// + /// + public List RequestFirstLevelFolders(LLUUID userID) + { + List inventoryList = new List(); + foreach (KeyValuePair plugin in m_plugins) + { + InventoryFolderBase rootFolder = plugin.Value.getUserRootFolder(userID); + if (rootFolder != null) + { + inventoryList = plugin.Value.getInventoryFolders(rootFolder.folderID); + inventoryList.Insert(0, rootFolder); + return inventoryList; + } + } + return inventoryList; + } + + /// + /// + /// + public InventoryFolderBase RequestUsersRoot(LLUUID userID) + { + foreach (KeyValuePair plugin in m_plugins) + { + return plugin.Value.getUserRootFolder(userID); + } + return null; + } + + /// + /// + /// + /// + /// + public List RequestSubFolders(LLUUID parentFolderID) + { + List inventoryList = new List(); + foreach (KeyValuePair plugin in m_plugins) + { + return plugin.Value.getInventoryFolders(parentFolderID); + } + return inventoryList; + } + + public List RequestFolderItems(LLUUID folderID) + { + List itemsList = new List(); + foreach (KeyValuePair plugin in m_plugins) + { + itemsList = plugin.Value.getInventoryInFolder(folderID); + return itemsList; + } + return itemsList; + } + + /// + /// + /// + /// + public void AddNewInventorySet(UsersInventory inventory) + { + + } + + public class UsersInventory + { + public Dictionary Folders = new Dictionary(); + public Dictionary Items = new Dictionary(); + + public UsersInventory() + { + + } + + protected virtual void CreateNewInventorySet() + { + + } + } + } +} diff --git a/OpenSim/Framework/InventoryServiceBase/Properties/AssemblyInfo.cs b/OpenSim/Framework/InventoryServiceBase/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..35cca07 --- /dev/null +++ b/OpenSim/Framework/InventoryServiceBase/Properties/AssemblyInfo.cs @@ -0,0 +1,35 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("InventoryServiceBase")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("InventoryServiceBase")] +[assembly: AssemblyCopyright("Copyright © 2007")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("7e1fbd0b-4a25-4804-a01f-89b04eb5b349")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Revision and Build Numbers +// by using the '*' as shown below: +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/OpenSim/Region/Application/OpenSimMain.cs b/OpenSim/Region/Application/OpenSimMain.cs index 6b7026c..d961b73 100644 --- a/OpenSim/Region/Application/OpenSimMain.cs +++ b/OpenSim/Region/Application/OpenSimMain.cs @@ -39,14 +39,16 @@ using OpenSim.Framework.Servers; using OpenSim.Framework.Types; using OpenSim.Framework.Configuration; using OpenSim.Physics.Manager; -using OpenSim.Region.Caches; + using OpenSim.Region.ClientStack; using OpenSim.Region.Communications.Local; using OpenSim.Region.Communications.OGS1; +using OpenSim.Framework.Communications.Caches; using OpenSim.Region.Environment.Scenes; using OpenSim.Region.Environment; using System.Text; using System.Collections.Generic; +using OpenSim.Framework.Utilities; namespace OpenSim { @@ -97,11 +99,11 @@ namespace OpenSim if (m_sandbox) { - m_commsManager = new CommunicationsLocal( m_networkServersInfo, m_httpServer); + m_commsManager = new CommunicationsLocal( m_networkServersInfo, m_httpServer, m_assetCache); } else { - m_commsManager = new CommunicationsOGS1( m_networkServersInfo, m_httpServer ); + m_commsManager = new CommunicationsOGS1( m_networkServersInfo, m_httpServer , m_assetCache); } string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Regions"); @@ -137,6 +139,7 @@ namespace OpenSim this.m_udpServers[i].ServerListener(); } + } protected override StorageManager CreateStorageManager(RegionInfo regionInfo) diff --git a/OpenSim/Region/Caches/AssetCache.cs b/OpenSim/Region/Caches/AssetCache.cs deleted file mode 100644 index 8deb0a1..0000000 --- a/OpenSim/Region/Caches/AssetCache.cs +++ /dev/null @@ -1,669 +0,0 @@ -/* -* Copyright (c) Contributors, http://www.openmetaverse.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; -using System.Collections.Generic; -using System.Reflection; -using System.Threading; -using libsecondlife; -using libsecondlife.Packets; -using OpenSim.Framework.Interfaces; -using OpenSim.Framework.Types; - -namespace OpenSim.Region.Caches -{ - public delegate void DownloadComplete(AssetCache.TextureSender sender); - - /// - /// Manages local cache of assets and their sending to viewers. - /// - public class AssetCache : IAssetReceiver - { - public Dictionary Assets; - public Dictionary Textures; - - public List AssetRequests = new List(); //assets ready to be sent to viewers - public List TextureRequests = new List(); //textures ready to be sent - - public Dictionary RequestedAssets = new Dictionary(); //Assets requested from the asset server - public Dictionary RequestedTextures = new Dictionary(); //Textures requested from the asset server - - public Dictionary SendingTextures = new Dictionary(); - private IAssetServer _assetServer; - private Thread _assetCacheThread; - private LLUUID[] textureList = new LLUUID[5]; - - /// - /// - /// - public AssetCache(IAssetServer assetServer) - { - Console.WriteLine("Creating Asset cache"); - _assetServer = assetServer; - _assetServer.SetReceiver(this); - Assets = new Dictionary(); - Textures = new Dictionary(); - this._assetCacheThread = new Thread(new ThreadStart(RunAssetManager)); - this._assetCacheThread.IsBackground = true; - this._assetCacheThread.Start(); - - } - - public AssetCache(string assetServerDLLName, string assetServerURL, string assetServerKey) - { - Console.WriteLine("Creating Asset cache"); - _assetServer = this.LoadAssetDll(assetServerDLLName); - _assetServer.SetServerInfo(assetServerURL, assetServerKey); - _assetServer.SetReceiver(this); - Assets = new Dictionary(); - Textures = new Dictionary(); - this._assetCacheThread = new Thread(new ThreadStart(RunAssetManager)); - this._assetCacheThread.IsBackground = true; - this._assetCacheThread.Start(); - - } - - /// - /// - /// - public void RunAssetManager() - { - while (true) - { - try - { - //Console.WriteLine("Asset cache loop"); - this.ProcessAssetQueue(); - this.ProcessTextureQueue(); - Thread.Sleep(500); - } - catch (Exception e) - { - Console.WriteLine(e.Message); - } - } - } - - public void LoadDefaultTextureSet() - { - //hack: so we can give each user a set of textures - textureList[0] = new LLUUID("00000000-0000-0000-9999-000000000001"); - textureList[1] = new LLUUID("00000000-0000-0000-9999-000000000002"); - textureList[2] = new LLUUID("00000000-0000-0000-9999-000000000003"); - textureList[3] = new LLUUID("00000000-0000-0000-9999-000000000004"); - textureList[4] = new LLUUID("00000000-0000-0000-9999-000000000005"); - - for (int i = 0; i < textureList.Length; i++) - { - this._assetServer.RequestAsset(textureList[i], true); - } - - } - - public AssetBase[] CreateNewInventorySet(LLUUID agentID) - { - AssetBase[] inventorySet = new AssetBase[this.textureList.Length]; - for (int i = 0; i < textureList.Length; i++) - { - if (this.Textures.ContainsKey(textureList[i])) - { - inventorySet[i] = this.CloneImage(agentID, this.Textures[textureList[i]]); - TextureImage image = new TextureImage(inventorySet[i]); - this.Textures.Add(image.FullID, image); - this._assetServer.UploadNewAsset(image); //save the asset to the asset server - } - } - return inventorySet; - } - - public AssetBase GetAsset(LLUUID assetID) - { - AssetBase asset = null; - if (this.Textures.ContainsKey(assetID)) - { - asset = this.Textures[assetID]; - } - else if (this.Assets.ContainsKey(assetID)) - { - asset = this.Assets[assetID]; - } - return asset; - } - - public void AddAsset(AssetBase asset) - { - // Console.WriteLine("adding asset " + asset.FullID.ToStringHyphenated()); - if (asset.Type == 0) - { - //Console.WriteLine("which is a texture"); - if (!this.Textures.ContainsKey(asset.FullID)) - { //texture - TextureImage textur = new TextureImage(asset); - this.Textures.Add(textur.FullID, textur); - this._assetServer.UploadNewAsset(asset); - } - } - else - { - if (!this.Assets.ContainsKey(asset.FullID)) - { - AssetInfo assetInf = new AssetInfo(asset); - this.Assets.Add(assetInf.FullID, assetInf); - this._assetServer.UploadNewAsset(asset); - } - } - } - - /// - /// - /// - private void ProcessTextureQueue() - { - if (this.TextureRequests.Count == 0) - { - //no requests waiting - return; - } - int num; - num = this.TextureRequests.Count; - - AssetRequest req; - for (int i = 0; i < num; i++) - { - req = (AssetRequest)this.TextureRequests[i]; - if (!this.SendingTextures.ContainsKey(req.ImageInfo.FullID)) - { - TextureSender sender = new TextureSender(req); - sender.OnComplete += this.TextureSent; - lock (this.SendingTextures) - { - this.SendingTextures.Add(req.ImageInfo.FullID, sender); - } - } - - } - - this.TextureRequests.Clear(); - } - - /// - /// Event handler, called by a TextureSender object to say that texture has been sent - /// - /// - public void TextureSent(TextureSender sender) - { - if (this.SendingTextures.ContainsKey(sender.request.ImageInfo.FullID)) - { - lock (this.SendingTextures) - { - this.SendingTextures.Remove(sender.request.ImageInfo.FullID); - } - } - } - - public void AssetReceived(AssetBase asset, bool IsTexture) - { - if (asset.FullID != LLUUID.Zero) // if it is set to zero then the asset wasn't found by the server - { - //check if it is a texture or not - //then add to the correct cache list - //then check for waiting requests for this asset/texture (in the Requested lists) - //and move those requests into the Requests list. - if (IsTexture) - { - TextureImage image = new TextureImage(asset); - this.Textures.Add(image.FullID, image); - if (this.RequestedTextures.ContainsKey(image.FullID)) - { - AssetRequest req = this.RequestedTextures[image.FullID]; - req.ImageInfo = image; - if (image.Data.LongLength > 600) - { - //over 600 bytes so split up file - req.NumPackets = 1 + (int)(image.Data.Length - 600 + 999) / 1000; - } - else - { - req.NumPackets = 1; - } - this.RequestedTextures.Remove(image.FullID); - this.TextureRequests.Add(req); - } - } - else - { - AssetInfo assetInf = new AssetInfo(asset); - this.Assets.Add(assetInf.FullID, assetInf); - if (this.RequestedAssets.ContainsKey(assetInf.FullID)) - { - AssetRequest req = this.RequestedAssets[assetInf.FullID]; - req.AssetInf = assetInf; - if (assetInf.Data.LongLength > 600) - { - //over 600 bytes so split up file - req.NumPackets = 1 + (int)(assetInf.Data.Length - 600 + 999) / 1000; - } - else - { - req.NumPackets = 1; - } - this.RequestedAssets.Remove(assetInf.FullID); - this.AssetRequests.Add(req); - } - } - } - } - - public void AssetNotFound(AssetBase asset) - { - //the asset server had no knowledge of requested asset - - } - - #region Assets - /// - /// - /// - /// - /// - public void AddAssetRequest(IClientAPI userInfo, TransferRequestPacket transferRequest) - { - LLUUID requestID = new LLUUID(transferRequest.TransferInfo.Params, 0); - //check to see if asset is in local cache, if not we need to request it from asset server. - - if (!this.Assets.ContainsKey(requestID)) - { - //not found asset - // so request from asset server - if (!this.RequestedAssets.ContainsKey(requestID)) - { - AssetRequest request = new AssetRequest(); - request.RequestUser = userInfo; - request.RequestAssetID = requestID; - request.TransferRequestID = transferRequest.TransferInfo.TransferID; - this.RequestedAssets.Add(requestID, request); - this._assetServer.RequestAsset(requestID, false); - } - return; - } - //it is in our cache - AssetInfo asset = this.Assets[requestID]; - - //work out how many packets it should be sent in - // and add to the AssetRequests list - AssetRequest req = new AssetRequest(); - req.RequestUser = userInfo; - req.RequestAssetID = requestID; - req.TransferRequestID = transferRequest.TransferInfo.TransferID; - req.AssetInf = asset; - - if (asset.Data.LongLength > 600) - { - //over 600 bytes so split up file - req.NumPackets = 1 + (int)(asset.Data.Length - 600 + 999) / 1000; - } - else - { - req.NumPackets = 1; - } - - this.AssetRequests.Add(req); - } - - /// - /// - /// - private void ProcessAssetQueue() - { - if (this.AssetRequests.Count == 0) - { - //no requests waiting - return; - } - int num; - - if (this.AssetRequests.Count < 5) - { - //lower than 5 so do all of them - num = this.AssetRequests.Count; - } - else - { - num = 5; - } - AssetRequest req; - for (int i = 0; i < num; i++) - { - req = (AssetRequest)this.AssetRequests[i]; - - TransferInfoPacket Transfer = new TransferInfoPacket(); - Transfer.TransferInfo.ChannelType = 2; - Transfer.TransferInfo.Status = 0; - Transfer.TransferInfo.TargetType = 0; - Transfer.TransferInfo.Params = req.RequestAssetID.GetBytes(); - Transfer.TransferInfo.Size = (int)req.AssetInf.Data.Length; - Transfer.TransferInfo.TransferID = req.TransferRequestID; - req.RequestUser.OutPacket(Transfer); - - if (req.NumPackets == 1) - { - TransferPacketPacket TransferPacket = new TransferPacketPacket(); - TransferPacket.TransferData.Packet = 0; - TransferPacket.TransferData.ChannelType = 2; - TransferPacket.TransferData.TransferID = req.TransferRequestID; - TransferPacket.TransferData.Data = req.AssetInf.Data; - TransferPacket.TransferData.Status = 1; - req.RequestUser.OutPacket(TransferPacket); - } - else - { - //more than one packet so split file up , for now it can't be bigger than 2000 bytes - TransferPacketPacket TransferPacket = new TransferPacketPacket(); - TransferPacket.TransferData.Packet = 0; - TransferPacket.TransferData.ChannelType = 2; - TransferPacket.TransferData.TransferID = req.TransferRequestID; - byte[] chunk = new byte[1000]; - Array.Copy(req.AssetInf.Data, chunk, 1000); - TransferPacket.TransferData.Data = chunk; - TransferPacket.TransferData.Status = 0; - req.RequestUser.OutPacket(TransferPacket); - - TransferPacket = new TransferPacketPacket(); - TransferPacket.TransferData.Packet = 1; - TransferPacket.TransferData.ChannelType = 2; - TransferPacket.TransferData.TransferID = req.TransferRequestID; - byte[] chunk1 = new byte[(req.AssetInf.Data.Length - 1000)]; - Array.Copy(req.AssetInf.Data, 1000, chunk1, 0, chunk1.Length); - TransferPacket.TransferData.Data = chunk1; - TransferPacket.TransferData.Status = 1; - req.RequestUser.OutPacket(TransferPacket); - } - - } - - //remove requests that have been completed - for (int i = 0; i < num; i++) - { - this.AssetRequests.RemoveAt(0); - } - - } - - public AssetInfo CloneAsset(LLUUID newOwner, AssetInfo sourceAsset) - { - AssetInfo newAsset = new AssetInfo(); - newAsset.Data = new byte[sourceAsset.Data.Length]; - Array.Copy(sourceAsset.Data, newAsset.Data, sourceAsset.Data.Length); - newAsset.FullID = LLUUID.Random(); - newAsset.Type = sourceAsset.Type; - newAsset.InvType = sourceAsset.InvType; - return (newAsset); - } - #endregion - - #region Textures - /// - /// - /// - /// - /// - public void AddTextureRequest(IClientAPI userInfo, LLUUID imageID) - { - //Console.WriteLine("texture request for " + imageID.ToStringHyphenated()); - //check to see if texture is in local cache, if not request from asset server - if (!this.Textures.ContainsKey(imageID)) - { - if (!this.RequestedTextures.ContainsKey(imageID)) - { - //not is cache so request from asset server - AssetRequest request = new AssetRequest(); - request.RequestUser = userInfo; - request.RequestAssetID = imageID; - request.IsTextureRequest = true; - this.RequestedTextures.Add(imageID, request); - this._assetServer.RequestAsset(imageID, true); - } - return; - } - - //Console.WriteLine("texture already in cache"); - TextureImage imag = this.Textures[imageID]; - AssetRequest req = new AssetRequest(); - req.RequestUser = userInfo; - req.RequestAssetID = imageID; - req.IsTextureRequest = true; - req.ImageInfo = imag; - - if (imag.Data.LongLength > 600) - { - //over 600 bytes so split up file - req.NumPackets = 1 + (int)(imag.Data.Length - 600 + 999) / 1000; - } - else - { - req.NumPackets = 1; - } - this.TextureRequests.Add(req); - } - - public TextureImage CloneImage(LLUUID newOwner, TextureImage source) - { - TextureImage newImage = new TextureImage(); - newImage.Data = new byte[source.Data.Length]; - Array.Copy(source.Data, newImage.Data, source.Data.Length); - //newImage.filename = source.filename; - newImage.FullID = LLUUID.Random(); - newImage.Name = source.Name; - return (newImage); - } - #endregion - - private IAssetServer LoadAssetDll(string dllName) - { - Assembly pluginAssembly = Assembly.LoadFrom(dllName); - IAssetServer server = null; - - foreach (Type pluginType in pluginAssembly.GetTypes()) - { - if (pluginType.IsPublic) - { - if (!pluginType.IsAbstract) - { - Type typeInterface = pluginType.GetInterface("IAssetPlugin", true); - - if (typeInterface != null) - { - IAssetPlugin plug = (IAssetPlugin)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); - server = plug.GetAssetServer(); - break; - } - - typeInterface = null; - } - } - } - pluginAssembly = null; - return server; - } - - public class AssetRequest - { - public IClientAPI RequestUser; - public LLUUID RequestAssetID; - public AssetInfo AssetInf; - public TextureImage ImageInfo; - public LLUUID TransferRequestID; - public long DataPointer = 0; - public int NumPackets = 0; - public int PacketCounter = 0; - public bool IsTextureRequest; - //public bool AssetInCache; - //public int TimeRequested; - - public AssetRequest() - { - - } - } - - public class AssetInfo : AssetBase - { - public AssetInfo() - { - - } - - public AssetInfo(AssetBase aBase) - { - Data = aBase.Data; - FullID = aBase.FullID; - Type = aBase.Type; - InvType = aBase.InvType; - Name = aBase.Name; - Description = aBase.Description; - } - } - - public class TextureImage : AssetBase - { - public TextureImage() - { - - } - - public TextureImage(AssetBase aBase) - { - Data = aBase.Data; - FullID = aBase.FullID; - Type = aBase.Type; - InvType = aBase.InvType; - Name = aBase.Name; - Description = aBase.Description; - } - } - - public class TextureSender - { - public AssetRequest request; - public event DownloadComplete OnComplete; - Thread m_thread; - public TextureSender(AssetRequest req) - { - request = req; - //Console.WriteLine("creating worker thread for texture " + req.ImageInfo.FullID.ToStringHyphenated()); - //Console.WriteLine("texture data length is " + req.ImageInfo.Data.Length); - // Console.WriteLine("in " + req.NumPackets + " packets"); - //ThreadPool.QueueUserWorkItem(new WaitCallback(SendTexture), new object()); - - //need some sort of custom threadpool here, as using the .net one, overloads it and stops the handling of incoming packets etc - //but don't really want to create a thread for every texture download - m_thread = new Thread(new ThreadStart(SendTexture)); - m_thread.IsBackground = true; - m_thread.Start(); - } - - public void SendTexture() - { - //Console.WriteLine("starting to send sending texture " + request.ImageInfo.FullID.ToStringHyphenated()); - while (request.PacketCounter != request.NumPackets) - { - SendPacket(); - Thread.Sleep(500); - } - - //Console.WriteLine("finished sending texture " + request.ImageInfo.FullID.ToStringHyphenated()); - if (OnComplete != null) - { - OnComplete(this); - } - } - - public void SendPacket() - { - AssetRequest req = request; - // Console.WriteLine("sending " + req.ImageInfo.FullID); - - // if (req.ImageInfo.FullID == new LLUUID("00000000-0000-0000-5005-000000000005")) - if (req.PacketCounter == 0) - { - //first time for this request so send imagedata packet - if (req.NumPackets == 1) - { - //only one packet so send whole file - ImageDataPacket im = new ImageDataPacket(); - im.ImageID.Packets = 1; - im.ImageID.ID = req.ImageInfo.FullID; - im.ImageID.Size = (uint)req.ImageInfo.Data.Length; - im.ImageData.Data = req.ImageInfo.Data; - im.ImageID.Codec = 2; - req.RequestUser.OutPacket(im); - req.PacketCounter++; - //req.ImageInfo.l= time; - //System.Console.WriteLine("sent texture: " + req.ImageInfo.FullID); - // Console.WriteLine("sending packet 1 for " + req.ImageInfo.FullID.ToStringHyphenated()); - } - else - { - //more than one packet so split file up - ImageDataPacket im = new ImageDataPacket(); - im.ImageID.Packets = (ushort)req.NumPackets; - im.ImageID.ID = req.ImageInfo.FullID; - im.ImageID.Size = (uint)req.ImageInfo.Data.Length; - im.ImageData.Data = new byte[600]; - Array.Copy(req.ImageInfo.Data, 0, im.ImageData.Data, 0, 600); - im.ImageID.Codec = 2; - req.RequestUser.OutPacket(im); - req.PacketCounter++; - //req.ImageInfo.last_used = time; - //System.Console.WriteLine("sent first packet of texture: - // Console.WriteLine("sending packet 1 for " + req.ImageInfo.FullID.ToStringHyphenated()); - } - } - else - { - //Console.WriteLine("sending packet" + req.PacketCounter + "for " + req.ImageInfo.FullID.ToStringHyphenated()); - //send imagepacket - //more than one packet so split file up - ImagePacketPacket im = new ImagePacketPacket(); - im.ImageID.Packet = (ushort)req.PacketCounter; - im.ImageID.ID = req.ImageInfo.FullID; - int size = req.ImageInfo.Data.Length - 600 - 1000 * (req.PacketCounter - 1); - if (size > 1000) size = 1000; - im.ImageData.Data = new byte[size]; - Array.Copy(req.ImageInfo.Data, 600 + 1000 * (req.PacketCounter - 1), im.ImageData.Data, 0, size); - req.RequestUser.OutPacket(im); - req.PacketCounter++; - //req.ImageInfo.last_used = time; - //System.Console.WriteLine("sent a packet of texture: "+req.image_info.FullID); - } - - } - } - } -} - diff --git a/OpenSim/Region/Caches/Properties/AssemblyInfo.cs b/OpenSim/Region/Caches/Properties/AssemblyInfo.cs deleted file mode 100644 index 4ba42b9..0000000 --- a/OpenSim/Region/Caches/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,33 +0,0 @@ -using System.Reflection; -using System.Runtime.InteropServices; -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("OpenSim.Region.Caches")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("OpenSim.Region.Caches")] -[assembly: AssemblyCopyright("Copyright © 2007")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("2b15ddbf-0341-49a6-85c0-cece268a4518")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Revision and Build Numbers -// by using the '*' as shown below: -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/OpenSim/Region/Capabilities/Caps.cs b/OpenSim/Region/Capabilities/Caps.cs deleted file mode 100644 index 06a4bd5..0000000 --- a/OpenSim/Region/Capabilities/Caps.cs +++ /dev/null @@ -1,330 +0,0 @@ -/* -* Copyright (c) Contributors, http://www.openmetaverse.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; -using System.Collections; -using System.Collections.Generic; -using System.Text; -using System.IO; -using libsecondlife; -using OpenSim.Framework.Servers; -using OpenSim.Framework.Types; -using OpenSim.Framework.Utilities; -using OpenSim.Region.Caches; - -namespace OpenSim.Region.Capabilities -{ - public delegate void UpLoadedTexture(string assetName, LLUUID assetID, LLUUID inventoryItem, byte[] data); - - public class Caps - { - private string m_httpListenerHostName; - private int m_httpListenPort; - private string m_capsObjectPath = "00001-"; - private string m_requestPath = "0000/"; - private string m_mapLayerPath = "0001/"; - private string m_newInventory = "0002/"; - // private string m_requestTexture = "0003/"; - //private string eventQueue = "0100/"; - private BaseHttpServer httpListener; - private LLUUID agentID; - private AssetCache assetCache; - private int eventQueueCount = 1; - private Queue CapsEventQueue = new Queue(); - - public Caps(AssetCache assetCach, BaseHttpServer httpServer, string httpListen, int httpPort, string capsPath, LLUUID agent) - { - assetCache = assetCach; - m_capsObjectPath = capsPath; - httpListener = httpServer; - m_httpListenerHostName = httpListen; - m_httpListenPort = httpPort; - agentID = agent; - } - - /// - /// - /// - public void RegisterHandlers() - { - Console.WriteLine("registering CAPS handlers"); - string capsBase = "/CAPS/" + m_capsObjectPath; - - httpListener.AddStreamHandler(new LLSDStreamhandler("POST", capsBase + m_mapLayerPath, this.GetMapLayer )); - httpListener.AddStreamHandler( new LLSDStreamhandler("POST", capsBase + m_newInventory, this.NewAgentInventoryRequest)); - - AddLegacyCapsHandler(httpListener, m_requestPath, CapsRequest); - } - - [Obsolete("Use BaseHttpServer.AddStreamHandler(new LLSDStreamHandler( LLSDMethod delegate )) instead.")] - private void AddLegacyCapsHandler(BaseHttpServer httpListener, string path, RestMethod restMethod) - { - string capsBase = "/CAPS/" + m_capsObjectPath; - httpListener.AddStreamHandler(new RestStreamHandler("POST", capsBase + path, restMethod)); - } - - /// - /// - /// - /// - /// - /// - /// - public string CapsRequest(string request, string path, string param) - { - // Console.WriteLine("caps request " + request); - string result = LLSDHelpers.SerialiseLLSDReply(this.GetCapabilities()); - return result; - } - - /// - /// - /// - /// - protected LLSDCapsDetails GetCapabilities() - { - LLSDCapsDetails caps = new LLSDCapsDetails(); - string capsBaseUrl = "http://" + m_httpListenerHostName + ":" + m_httpListenPort.ToString() + "/CAPS/" + m_capsObjectPath; - caps.MapLayer = capsBaseUrl + m_mapLayerPath; - caps.NewFileAgentInventory = capsBaseUrl + m_newInventory; - //caps.RequestTextureDownload = capsBaseUrl + m_requestTexture; - // caps.ChatSessionRequest = capsBaseUrl + m_requestTexture; - return caps; - } - - /// - /// - /// - /// - /// - public LLSDMapLayerResponse GetMapLayer(LLSDMapRequest mapReq) - { - LLSDMapLayerResponse mapResponse = new LLSDMapLayerResponse(); - mapResponse.LayerData.Array.Add(this.GetLLSDMapLayerResponse()); - return mapResponse; - } - - /// - /// - /// - /// - protected LLSDMapLayer GetLLSDMapLayerResponse() - { - LLSDMapLayer mapLayer = new LLSDMapLayer(); - mapLayer.Right = 5000; - mapLayer.Top = 5000; - mapLayer.ImageID = new LLUUID("00000000-0000-0000-9999-000000000006"); - return mapLayer; - } - - /// - /// - /// - /// - /// - /// - /// - public string RequestTexture(string request, string path, string param) - { - Console.WriteLine("texture request " + request); - // Needs implementing (added to remove compiler warning) - return ""; - } - - #region EventQueue (Currently not enabled) - /// - /// - /// - /// - /// - /// - /// - public string ProcessEventQueue(string request, string path, string param) - { - string res = ""; - - if (this.CapsEventQueue.Count > 0) - { - lock (this.CapsEventQueue) - { - string item = CapsEventQueue.Dequeue(); - res = item; - } - } - else - { - res = this.CreateEmptyEventResponse(); - } - return res; - } - - /// - /// - /// - /// - /// - /// - public string CreateEstablishAgentComms(string caps, string ipAddressPort) - { - LLSDCapEvent eventItem = new LLSDCapEvent(); - eventItem.id = eventQueueCount; - //should be creating a EstablishAgentComms item, but there isn't a class for it yet - eventItem.events.Array.Add(new LLSDEmpty()); - string res = LLSDHelpers.SerialiseLLSDReply(eventItem); - eventQueueCount++; - - this.CapsEventQueue.Enqueue(res); - return res; - } - - /// - /// - /// - /// - public string CreateEmptyEventResponse() - { - LLSDCapEvent eventItem = new LLSDCapEvent(); - eventItem.id = eventQueueCount; - eventItem.events.Array.Add(new LLSDEmpty()); - string res = LLSDHelpers.SerialiseLLSDReply(eventItem); - eventQueueCount++; - return res; - } - #endregion - - /// - /// - /// - /// - /// - public LLSDAssetUploadResponse NewAgentInventoryRequest(LLSDAssetUploadRequest llsdRequest) - { - // Console.WriteLine("asset upload request via CAPS"); - string assetName = llsdRequest.name; - string capsBase = "/CAPS/" + m_capsObjectPath; - LLUUID newAsset = LLUUID.Random(); - LLUUID newInvItem = LLUUID.Random(); - string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString("0000"); - - AssetUploader uploader = new AssetUploader(assetName, newAsset, newInvItem, capsBase + uploaderPath, this.httpListener); - httpListener.AddStreamHandler(new BinaryStreamHandler("POST", capsBase + uploaderPath, uploader.uploaderCaps)); - string uploaderURL = "http://" + m_httpListenerHostName + ":" + m_httpListenPort.ToString() + capsBase + uploaderPath; - - LLSDAssetUploadResponse uploadResponse = new LLSDAssetUploadResponse(); - uploadResponse.uploader = uploaderURL; - uploadResponse.state = "upload"; - uploader.OnUpLoad += this.UploadCompleteHandler; - return uploadResponse; - } - - /// - /// - /// - /// - /// - /// - public void UploadCompleteHandler(string assetName, LLUUID assetID, LLUUID inventoryItem, byte[] data) - { - AssetBase asset; - asset = new AssetBase(); - asset.FullID = assetID; - asset.Type = 0; - asset.InvType = 0; - asset.Name = assetName; - asset.Data = data; - this.assetCache.AddAsset(asset); - } - - public class AssetUploader - { - public event UpLoadedTexture OnUpLoad; - - private string uploaderPath = ""; - private LLUUID newAssetID; - private LLUUID inventoryItemID; - private BaseHttpServer httpListener; - private bool SaveImages = false; - private string m_assetName = ""; - - /// - /// - /// - /// - /// - /// - /// - public AssetUploader(string assetName, LLUUID assetID, LLUUID inventoryItem, string path, BaseHttpServer httpServer) - { - m_assetName = assetName; - newAssetID = assetID; - inventoryItemID = inventoryItem; - uploaderPath = path; - httpListener = httpServer; - } - - /// - /// - /// - /// - /// - /// - /// - public string uploaderCaps(byte[] data, string path, string param) - { - LLUUID inv = this.inventoryItemID; - string res = ""; - LLSDAssetUploadComplete uploadComplete = new LLSDAssetUploadComplete(); - uploadComplete.new_asset = newAssetID.ToStringHyphenated(); - uploadComplete.new_inventory_item = inv; - uploadComplete.state = "complete"; - res = LLSDHelpers.SerialiseLLSDReply(uploadComplete); - - httpListener.RemoveStreamHandler("POST", uploaderPath); - - if(this.SaveImages) - this.SaveImageToFile(m_assetName + ".jp2", data); - - if (OnUpLoad != null) - { - OnUpLoad(m_assetName, newAssetID, inv, data); - } - - return res; - } - - private void SaveImageToFile(string filename, byte[] data) - { - - FileStream fs = File.Create(filename); - BinaryWriter bw = new BinaryWriter(fs); - bw.Write(data); - bw.Close(); - fs.Close(); - } - } - } -} diff --git a/OpenSim/Region/Capabilities/LLSDArray.cs b/OpenSim/Region/Capabilities/LLSDArray.cs deleted file mode 100644 index d3e1979..0000000 --- a/OpenSim/Region/Capabilities/LLSDArray.cs +++ /dev/null @@ -1,42 +0,0 @@ -/* -* Copyright (c) Contributors, http://www.openmetaverse.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; - -namespace OpenSim.Region.Capabilities -{ - [LLSDType("ARRAY")] - public class LLSDArray - { - public ArrayList Array = new ArrayList(); - - public LLSDArray() - { - - } - } -} diff --git a/OpenSim/Region/Capabilities/LLSDAssetUploadComplete.cs b/OpenSim/Region/Capabilities/LLSDAssetUploadComplete.cs deleted file mode 100644 index 5718b8f..0000000 --- a/OpenSim/Region/Capabilities/LLSDAssetUploadComplete.cs +++ /dev/null @@ -1,44 +0,0 @@ -/* -* Copyright (c) Contributors, http://www.openmetaverse.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 libsecondlife; - -namespace OpenSim.Region.Capabilities -{ - [LLSDType("MAP")] - public class LLSDAssetUploadComplete - { - public string new_asset = ""; - public LLUUID new_inventory_item = LLUUID.Zero; - public string state = ""; - - public LLSDAssetUploadComplete() - { - - } - } -} diff --git a/OpenSim/Region/Capabilities/LLSDAssetUploadRequest.cs b/OpenSim/Region/Capabilities/LLSDAssetUploadRequest.cs deleted file mode 100644 index 0096fb1..0000000 --- a/OpenSim/Region/Capabilities/LLSDAssetUploadRequest.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using libsecondlife; - -namespace OpenSim.Region.Capabilities -{ - [LLSDMap] - public class LLSDAssetUploadRequest - { - public string asset_type = ""; - public string description = ""; - public LLUUID folder_id = LLUUID.Zero; - public string inventory_type = ""; - public string name = ""; - - public LLSDAssetUploadRequest() - { - } - } -} diff --git a/OpenSim/Region/Capabilities/LLSDAssetUploadResponse.cs b/OpenSim/Region/Capabilities/LLSDAssetUploadResponse.cs deleted file mode 100644 index 2a2a5d1..0000000 --- a/OpenSim/Region/Capabilities/LLSDAssetUploadResponse.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace OpenSim.Region.Capabilities -{ - [LLSDMap] - public class LLSDAssetUploadResponse - { - public string uploader = ""; - public string state = ""; - - public LLSDAssetUploadResponse() - { - - } - } -} diff --git a/OpenSim/Region/Capabilities/LLSDCapEvent.cs b/OpenSim/Region/Capabilities/LLSDCapEvent.cs deleted file mode 100644 index 2c2689b..0000000 --- a/OpenSim/Region/Capabilities/LLSDCapEvent.cs +++ /dev/null @@ -1,41 +0,0 @@ -/* -* Copyright (c) Contributors, http://www.openmetaverse.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. -* -*/ -namespace OpenSim.Region.Capabilities -{ - [LLSDType("MAP")] - public class LLSDCapEvent - { - public int id = 0; - public LLSDArray events = new LLSDArray(); - - public LLSDCapEvent() - { - - } - } -} diff --git a/OpenSim/Region/Capabilities/LLSDCapsDetails.cs b/OpenSim/Region/Capabilities/LLSDCapsDetails.cs deleted file mode 100644 index 132b8f7..0000000 --- a/OpenSim/Region/Capabilities/LLSDCapsDetails.cs +++ /dev/null @@ -1,17 +0,0 @@ -namespace OpenSim.Region.Capabilities -{ - [LLSDType("MAP")] - public class LLSDCapsDetails - { - public string MapLayer = ""; - public string NewFileAgentInventory = ""; - //public string EventQueueGet = ""; - //public string RequestTextureDownload = ""; - //public string ChatSessionRequest = ""; - - public LLSDCapsDetails() - { - - } - } -} diff --git a/OpenSim/Region/Capabilities/LLSDEmpty.cs b/OpenSim/Region/Capabilities/LLSDEmpty.cs deleted file mode 100644 index ca27c9d..0000000 --- a/OpenSim/Region/Capabilities/LLSDEmpty.cs +++ /dev/null @@ -1,38 +0,0 @@ -/* -* Copyright (c) Contributors, http://www.openmetaverse.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. -* -*/ -namespace OpenSim.Region.Capabilities -{ - [LLSDType("MAP")] - public class LLSDEmpty - { - public LLSDEmpty() - { - - } - } -} diff --git a/OpenSim/Region/Capabilities/LLSDHelpers.cs b/OpenSim/Region/Capabilities/LLSDHelpers.cs deleted file mode 100644 index efeb9b1..0000000 --- a/OpenSim/Region/Capabilities/LLSDHelpers.cs +++ /dev/null @@ -1,164 +0,0 @@ -/* -* Copyright (c) Contributors, http://www.openmetaverse.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; -using System.Collections; -using System.IO; -using System.Reflection; -using System.Xml; -using libsecondlife; - -namespace OpenSim.Region.Capabilities -{ - public class LLSDHelpers - { - public static string SerialiseLLSDReply(object obj) - { - StringWriter sw = new StringWriter(); - XmlTextWriter writer = new XmlTextWriter(sw); - writer.Formatting = Formatting.None; - writer.WriteStartElement(String.Empty, "llsd", String.Empty); - SerializeLLSDType(writer, obj); - writer.WriteEndElement(); - writer.Close(); - return sw.ToString(); - } - - public static void SerializeLLSDType(XmlTextWriter writer, object obj) - { - Type myType = obj.GetType(); - LLSDType[] llsdattributes = (LLSDType[])myType.GetCustomAttributes(typeof(LLSDType), false); - if (llsdattributes.Length > 0) - { - switch (llsdattributes[0].ObjectType) - { - case "MAP": - writer.WriteStartElement(String.Empty, "map", String.Empty); - FieldInfo[] fields = myType.GetFields(); - for (int i = 0; i < fields.Length; i++) - { - object fieldValue = fields[i].GetValue(obj); - LLSDType[] fieldAttributes = (LLSDType[])fieldValue.GetType().GetCustomAttributes(typeof(LLSDType), false); - if (fieldAttributes.Length > 0) - { - writer.WriteStartElement(String.Empty, "key", String.Empty); - writer.WriteString(fields[i].Name); - writer.WriteEndElement(); - SerializeLLSDType(writer, fieldValue); - } - else - { - writer.WriteStartElement(String.Empty, "key", String.Empty); - writer.WriteString(fields[i].Name); - writer.WriteEndElement(); - LLSD.LLSDWriteOne(writer, fieldValue); - } - } - writer.WriteEndElement(); - break; - case "ARRAY": - // LLSDArray arrayObject = obj as LLSDArray; - // ArrayList a = arrayObject.Array; - ArrayList a = (ArrayList)obj.GetType().GetField("Array").GetValue(obj); - if (a != null) - { - writer.WriteStartElement(String.Empty, "array", String.Empty); - foreach (object item in a) - { - SerializeLLSDType(writer, item); - } - writer.WriteEndElement(); - } - break; - } - } - else - { - LLSD.LLSDWriteOne(writer, obj); - } - } - - public static object DeserialiseLLSDMap(Hashtable llsd, object obj) - { - Type myType = obj.GetType(); - LLSDType[] llsdattributes = (LLSDType[])myType.GetCustomAttributes(typeof(LLSDType), false); - if (llsdattributes.Length > 0) - { - switch (llsdattributes[0].ObjectType) - { - case "MAP": - IDictionaryEnumerator enumerator = llsd.GetEnumerator(); - while (enumerator.MoveNext()) - { - FieldInfo field = myType.GetField((string)enumerator.Key); - if (field != null) - { - if (enumerator.Value is Hashtable) - { - object fieldValue = field.GetValue(obj); - DeserialiseLLSDMap((Hashtable) enumerator.Value, fieldValue); - } - else if (enumerator.Value is ArrayList) - { - object fieldValue = field.GetValue(obj); - fieldValue.GetType().GetField("Array").SetValue(fieldValue, enumerator.Value); - //TODO - // the LLSD map/array types in the array need to be deserialised - // but first we need to know the right class to deserialise them into. - } - else - { - field.SetValue(obj, enumerator.Value); - } - } - } - break; - } - } - return obj; - } - } - - - - - - - - - - - - - - - - - - - -} diff --git a/OpenSim/Region/Capabilities/LLSDMapLayer.cs b/OpenSim/Region/Capabilities/LLSDMapLayer.cs deleted file mode 100644 index e0c006c..0000000 --- a/OpenSim/Region/Capabilities/LLSDMapLayer.cs +++ /dev/null @@ -1,46 +0,0 @@ -/* -* Copyright (c) Contributors, http://www.openmetaverse.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 libsecondlife; - -namespace OpenSim.Region.Capabilities -{ - [LLSDType("MAP")] - public class LLSDMapLayer - { - public int Left = 0; - public int Right = 0; - public int Top = 0; - public int Bottom = 0; - public LLUUID ImageID = LLUUID.Zero; - - public LLSDMapLayer() - { - - } - } -} diff --git a/OpenSim/Region/Capabilities/LLSDMapLayerResponse.cs b/OpenSim/Region/Capabilities/LLSDMapLayerResponse.cs deleted file mode 100644 index 8b9837b..0000000 --- a/OpenSim/Region/Capabilities/LLSDMapLayerResponse.cs +++ /dev/null @@ -1,41 +0,0 @@ -/* -* Copyright (c) Contributors, http://www.openmetaverse.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. -* -*/ -namespace OpenSim.Region.Capabilities -{ - [LLSDType("MAP")] - public class LLSDMapLayerResponse - { - public LLSDMapRequest AgentData = new LLSDMapRequest(); - public LLSDArray LayerData = new LLSDArray(); - - public LLSDMapLayerResponse() - { - - } - } -} diff --git a/OpenSim/Region/Capabilities/LLSDMapRequest.cs b/OpenSim/Region/Capabilities/LLSDMapRequest.cs deleted file mode 100644 index 8ac7943..0000000 --- a/OpenSim/Region/Capabilities/LLSDMapRequest.cs +++ /dev/null @@ -1,13 +0,0 @@ -namespace OpenSim.Region.Capabilities -{ - [LLSDType("MAP")] - public class LLSDMapRequest - { - public int Flags = 0; - - public LLSDMapRequest() - { - - } - } -} diff --git a/OpenSim/Region/Capabilities/LLSDMethod.cs b/OpenSim/Region/Capabilities/LLSDMethod.cs deleted file mode 100644 index 068d539..0000000 --- a/OpenSim/Region/Capabilities/LLSDMethod.cs +++ /dev/null @@ -1,8 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace OpenSim.Region.Capabilities -{ - public delegate TResponse LLSDMethod(TRequest request); -} diff --git a/OpenSim/Region/Capabilities/LLSDStreamHandler.cs b/OpenSim/Region/Capabilities/LLSDStreamHandler.cs deleted file mode 100644 index d98e23f..0000000 --- a/OpenSim/Region/Capabilities/LLSDStreamHandler.cs +++ /dev/null @@ -1,42 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using OpenSim.Framework.Servers; -using System.IO; -using System.Collections; -using libsecondlife; - -namespace OpenSim.Region.Capabilities -{ - public class LLSDStreamhandler : BaseStreamHandler - where TRequest : new() - { - private LLSDMethod m_method; - - public LLSDStreamhandler(string httpMethod, string path, LLSDMethod method) - : base(httpMethod, path ) - { - m_method = method; - } - - public override byte[] Handle(string path, Stream request) - { - //Encoding encoding = Encoding.UTF8; - //StreamReader streamReader = new StreamReader(request, false); - - //string requestBody = streamReader.ReadToEnd(); - //streamReader.Close(); - - Hashtable hash = (Hashtable)LLSD.LLSDDeserialize( request ); - TRequest llsdRequest = new TRequest(); - LLSDHelpers.DeserialiseLLSDMap(hash, llsdRequest); - - TResponse response = m_method(llsdRequest); - - Encoding encoding = new UTF8Encoding(false); - - return encoding.GetBytes( LLSDHelpers.SerialiseLLSDReply(response) ); - - } - } -} diff --git a/OpenSim/Region/Capabilities/LLSDTest.cs b/OpenSim/Region/Capabilities/LLSDTest.cs deleted file mode 100644 index 78ccf67..0000000 --- a/OpenSim/Region/Capabilities/LLSDTest.cs +++ /dev/null @@ -1,41 +0,0 @@ -/* -* Copyright (c) Contributors, http://www.openmetaverse.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. -* -*/ -namespace OpenSim.Region.Capabilities -{ - [LLSDType("MAP")] - public class LLSDTest - { - public int Test1 = 20; - public int Test2 = 10; - - public LLSDTest() - { - - } - } -} diff --git a/OpenSim/Region/Capabilities/LLSDType.cs b/OpenSim/Region/Capabilities/LLSDType.cs deleted file mode 100644 index 04f4d9a..0000000 --- a/OpenSim/Region/Capabilities/LLSDType.cs +++ /dev/null @@ -1,59 +0,0 @@ -/* -* Copyright (c) Contributors, http://www.openmetaverse.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; - -namespace OpenSim.Region.Capabilities -{ - [AttributeUsage(AttributeTargets.Class)] - public class LLSDType : Attribute - { - protected string myType; - - public LLSDType(string type) - { - myType = type; - - } - - public string ObjectType - { - get - { - return myType; - } - } - } - - [AttributeUsage(AttributeTargets.Class)] - public class LLSDMap : LLSDType - { - public LLSDMap() : base( "MAP" ) - { - } - } -} diff --git a/OpenSim/Region/ClientStack/ClientView.API.cs b/OpenSim/Region/ClientStack/ClientView.API.cs index c99c365..956f2b4 100644 --- a/OpenSim/Region/ClientStack/ClientView.API.cs +++ b/OpenSim/Region/ClientStack/ClientView.API.cs @@ -81,8 +81,10 @@ namespace OpenSim.Region.ClientStack public event RequestMapBlocks OnRequestMapBlocks; public event TeleportLocationRequest OnTeleportLocationRequest; + public event CreateNewInventoryItem OnCreateNewInventoryItem; public event CreateInventoryFolder OnCreateNewInventoryFolder; public event FetchInventoryDescendents OnFetchInventoryDescendents; + public event FetchInventory OnFetchInventory; public event RequestTaskInventory OnRequestTaskInventory; public event UUIDNameRequest OnNameFromUUIDRequest; @@ -549,7 +551,7 @@ namespace OpenSim.Region.ClientStack } - public void SendInventoryItemDetails(LLUUID ownerID, LLUUID folderID, InventoryItemBase item) + public void SendInventoryItemDetails(LLUUID ownerID, InventoryItemBase item) { Encoding enc = Encoding.ASCII; uint FULL_MASK_PERMISSIONS = 2147483647; diff --git a/OpenSim/Region/ClientStack/ClientView.AgentAssetUpload.cs b/OpenSim/Region/ClientStack/ClientView.AgentAssetUpload.cs index 109f7e6..a785eff 100644 --- a/OpenSim/Region/ClientStack/ClientView.AgentAssetUpload.cs +++ b/OpenSim/Region/ClientStack/ClientView.AgentAssetUpload.cs @@ -33,7 +33,8 @@ using OpenSim.Assets; using OpenSim.Framework.Interfaces; using OpenSim.Framework.Types; using OpenSim.Framework.Utilities; -using OpenSim.Region.Caches; +using OpenSim.Framework.Communications.Caches; + namespace OpenSim.Region.ClientStack { diff --git a/OpenSim/Region/ClientStack/ClientView.ProcessPackets.cs b/OpenSim/Region/ClientStack/ClientView.ProcessPackets.cs index 267e7ee..1613aa1 100644 --- a/OpenSim/Region/ClientStack/ClientView.ProcessPackets.cs +++ b/OpenSim/Region/ClientStack/ClientView.ProcessPackets.cs @@ -387,11 +387,9 @@ namespace OpenSim.Region.ClientStack { CreateInventoryFolderPacket invFolder = (CreateInventoryFolderPacket)Pack; this.OnCreateNewInventoryFolder(this, invFolder.FolderData.FolderID, (ushort)invFolder.FolderData.Type, Util.FieldToString(invFolder.FolderData.Name), invFolder.FolderData.ParentID); - //m_inventoryCache.CreateNewInventoryFolder(this, invFolder.FolderData.FolderID, (ushort)invFolder.FolderData.Type, Util.FieldToString(invFolder.FolderData.Name), invFolder.FolderData.ParentID); } break; case PacketType.CreateInventoryItem: - //Console.WriteLine(Pack.ToString()); CreateInventoryItemPacket createItem = (CreateInventoryItemPacket)Pack; if (createItem.InventoryBlock.TransactionID != LLUUID.Zero) { @@ -399,20 +397,28 @@ namespace OpenSim.Region.ClientStack } else { - // Console.Write(Pack.ToString()); - this.CreateInventoryItem(createItem); + if (this.OnCreateNewInventoryItem != null) + { + this.OnCreateNewInventoryItem(this, createItem.InventoryBlock.TransactionID, createItem.InventoryBlock.FolderID, createItem.InventoryBlock.CallbackID, + Util.FieldToString(createItem.InventoryBlock.Description), Util.FieldToString(createItem.InventoryBlock.Name), createItem.InventoryBlock.InvType, + createItem.InventoryBlock.Type, createItem.InventoryBlock.WearableType, createItem.InventoryBlock.NextOwnerMask); + } } break; case PacketType.FetchInventory: - //Console.WriteLine("fetch item packet"); - FetchInventoryPacket FetchInventory = (FetchInventoryPacket)Pack; - m_inventoryCache.FetchInventory(this, FetchInventory); + if (this.OnFetchInventory != null) + { + FetchInventoryPacket FetchInventory = (FetchInventoryPacket)Pack; + for (int i = 0; i < FetchInventory.InventoryData.Length; i++) + { + this.OnFetchInventory(this, FetchInventory.InventoryData[i].ItemID, FetchInventory.InventoryData[i].OwnerID); + } + } break; case PacketType.FetchInventoryDescendents: if (this.OnFetchInventoryDescendents != null) { FetchInventoryDescendentsPacket Fetch = (FetchInventoryDescendentsPacket)Pack; - // m_inventoryCache.FetchInventoryDescendents(this, Fetch); this.OnFetchInventoryDescendents(this, Fetch.InventoryData.FolderID, Fetch.InventoryData.OwnerID, Fetch.InventoryData.FetchFolders, Fetch.InventoryData.FetchItems, Fetch.InventoryData.SortOrder); } break; @@ -450,7 +456,6 @@ namespace OpenSim.Region.ClientStack } break; case PacketType.RequestTaskInventory: - // Console.WriteLine(Pack.ToString()); RequestTaskInventoryPacket requesttask = (RequestTaskInventoryPacket)Pack; if (this.OnRequestTaskInventory != null) { diff --git a/OpenSim/Region/ClientStack/ClientView.cs b/OpenSim/Region/ClientStack/ClientView.cs index 90ca600..3fd3a46 100644 --- a/OpenSim/Region/ClientStack/ClientView.cs +++ b/OpenSim/Region/ClientStack/ClientView.cs @@ -40,7 +40,8 @@ using OpenSim.Framework.Interfaces; using OpenSim.Framework.Inventory; using OpenSim.Framework.Types; using OpenSim.Framework.Utilities; -using OpenSim.Region.Caches; +using OpenSim.Framework.Communications.Caches; + using Timer=System.Timers.Timer; namespace OpenSim.Region.ClientStack diff --git a/OpenSim/Region/ClientStack/PacketServer.cs b/OpenSim/Region/ClientStack/PacketServer.cs index 7b15ab4..596cdbe 100644 --- a/OpenSim/Region/ClientStack/PacketServer.cs +++ b/OpenSim/Region/ClientStack/PacketServer.cs @@ -33,7 +33,7 @@ using OpenSim.Assets; using OpenSim.Framework; using OpenSim.Framework.Types; using OpenSim.Framework.Interfaces; -using OpenSim.Region.Caches; +using OpenSim.Framework.Communications.Caches; namespace OpenSim.Region.ClientStack { diff --git a/OpenSim/Region/ClientStack/RegionApplicationBase.cs b/OpenSim/Region/ClientStack/RegionApplicationBase.cs index 1651ec2..d91cd95 100644 --- a/OpenSim/Region/ClientStack/RegionApplicationBase.cs +++ b/OpenSim/Region/ClientStack/RegionApplicationBase.cs @@ -36,11 +36,11 @@ using OpenSim.Framework.Interfaces; using OpenSim.Framework.Servers; using OpenSim.Framework.Types; using OpenSim.Physics.Manager; -using OpenSim.Region.Caches; using OpenSim.Region.Environment; using libsecondlife; using OpenSim.Region.Environment.Scenes; using OpenSim.Framework.Communications; +using OpenSim.Framework.Communications.Caches; namespace OpenSim.Region.ClientStack { diff --git a/OpenSim/Region/ClientStack/UDPServer.cs b/OpenSim/Region/ClientStack/UDPServer.cs index 2c10df9..ec64bad 100644 --- a/OpenSim/Region/ClientStack/UDPServer.cs +++ b/OpenSim/Region/ClientStack/UDPServer.cs @@ -35,7 +35,7 @@ using OpenSim.Framework; using OpenSim.Framework.Types; using OpenSim.Framework.Console; using OpenSim.Framework.Interfaces; -using OpenSim.Region.Caches; +using OpenSim.Framework.Communications.Caches; namespace OpenSim.Region.ClientStack { diff --git a/OpenSim/Region/Communications/Local/CommunicationsLocal.cs b/OpenSim/Region/Communications/Local/CommunicationsLocal.cs index 3ce0cc5..0c40453 100644 --- a/OpenSim/Region/Communications/Local/CommunicationsLocal.cs +++ b/OpenSim/Region/Communications/Local/CommunicationsLocal.cs @@ -28,6 +28,7 @@ using OpenSim.Framework.Communications; using OpenSim.Framework.Types; using OpenSim.Framework.Servers; +using OpenSim.Framework.Communications.Caches; namespace OpenSim.Region.Communications.Local { @@ -36,8 +37,8 @@ namespace OpenSim.Region.Communications.Local public LocalBackEndServices SandBoxServices = new LocalBackEndServices(); public LocalUserServices UserServices; - public CommunicationsLocal(NetworkServersInfo serversInfo, BaseHttpServer httpServer ) - : base(serversInfo, httpServer) + public CommunicationsLocal(NetworkServersInfo serversInfo, BaseHttpServer httpServer, AssetCache assetCache ) + : base(serversInfo, httpServer, assetCache) { UserServices = new LocalUserServices(this, serversInfo); UserServices.AddPlugin("OpenSim.Framework.Data.DB4o.dll"); diff --git a/OpenSim/Region/Communications/Local/LocalBackEndServices.cs b/OpenSim/Region/Communications/Local/LocalBackEndServices.cs index 9322f3b..47968fc 100644 --- a/OpenSim/Region/Communications/Local/LocalBackEndServices.cs +++ b/OpenSim/Region/Communications/Local/LocalBackEndServices.cs @@ -161,12 +161,21 @@ namespace OpenSim.Region.Communications.Local /// /// /// - public bool ExpectAvatarCrossing(ulong regionHandle, LLUUID agentID, LLVector3 position) + public bool ExpectAvatarCrossing(ulong regionHandle, LLUUID agentID, LLVector3 position, bool isFlying) { if (this.regionHosts.ContainsKey(regionHandle)) { // Console.WriteLine("CommsManager- Informing a region to expect avatar crossing"); - this.regionHosts[regionHandle].TriggerExpectAvatarCrossing(regionHandle, agentID, position); + this.regionHosts[regionHandle].TriggerExpectAvatarCrossing(regionHandle, agentID, position, isFlying); + return true; + } + return false; + } + + public bool AcknowledgeAgentCrossed(ulong regionHandle, LLUUID agentID) + { + if (this.regionHosts.ContainsKey(regionHandle)) + { return true; } return false; diff --git a/OpenSim/Region/Communications/OGS1/CommunicationsOGS1.cs b/OpenSim/Region/Communications/OGS1/CommunicationsOGS1.cs index 9df0901..47d3148 100644 --- a/OpenSim/Region/Communications/OGS1/CommunicationsOGS1.cs +++ b/OpenSim/Region/Communications/OGS1/CommunicationsOGS1.cs @@ -1,13 +1,15 @@ using OpenSim.Framework.Communications; using OpenSim.Framework.Types; using OpenSim.Framework.Servers; +using OpenSim.Framework.Communications.Caches; + namespace OpenSim.Region.Communications.OGS1 { public class CommunicationsOGS1 : CommunicationsManager { - public CommunicationsOGS1(NetworkServersInfo serversInfo, BaseHttpServer httpServer ) :base(serversInfo, httpServer) + public CommunicationsOGS1(NetworkServersInfo serversInfo, BaseHttpServer httpServer, AssetCache assetCache ) :base(serversInfo, httpServer, assetCache) { OGS1GridServices gridInterComms = new OGS1GridServices(serversInfo, httpServer); GridServer = gridInterComms; diff --git a/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs b/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs index aadf85a..69d0d57 100644 --- a/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs +++ b/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs @@ -382,13 +382,13 @@ namespace OpenSim.Region.Communications.OGS1 /// /// /// - public bool ExpectAvatarCrossing(ulong regionHandle, LLUUID agentID, LLVector3 position) + public bool ExpectAvatarCrossing(ulong regionHandle, LLUUID agentID, LLVector3 position, bool isFlying) { try { if (this.listeners.ContainsKey(regionHandle)) { - this.listeners[regionHandle].TriggerExpectAvatarCrossing(regionHandle, agentID, position); + this.listeners[regionHandle].TriggerExpectAvatarCrossing(regionHandle, agentID, position, isFlying); return true; } RegionInfo regInfo = this.RequestNeighbourInfo(regionHandle); @@ -400,7 +400,7 @@ namespace OpenSim.Region.Communications.OGS1 "tcp://" + regInfo.RemotingAddress + ":" + regInfo.RemotingPort + "/InterRegions"); if (remObject != null) { - retValue = remObject.ExpectAvatarCrossing(regionHandle, agentID, position); + retValue = remObject.ExpectAvatarCrossing(regionHandle, agentID, position, isFlying); } else { @@ -420,6 +420,15 @@ namespace OpenSim.Region.Communications.OGS1 return false; } } + + public bool AcknowledgeAgentCrossed(ulong regionHandle, LLUUID agentID) + { + if (this.listeners.ContainsKey(regionHandle)) + { + return true; + } + return false; + } #endregion #region Methods triggered by calls from external instances @@ -453,13 +462,13 @@ namespace OpenSim.Region.Communications.OGS1 /// /// /// - public bool IncomingArrival(ulong regionHandle, LLUUID agentID, LLVector3 position) + public bool IncomingArrival(ulong regionHandle, LLUUID agentID, LLVector3 position, bool isFlying) { try { if (this.listeners.ContainsKey(regionHandle)) { - this.listeners[regionHandle].TriggerExpectAvatarCrossing(regionHandle, agentID, position); + this.listeners[regionHandle].TriggerExpectAvatarCrossing(regionHandle, agentID, position, isFlying); return true; } } diff --git a/OpenSim/Region/Communications/OGS1/OGS1InterSimComms.cs b/OpenSim/Region/Communications/OGS1/OGS1InterSimComms.cs index 87d62c8..ae08e9c 100644 --- a/OpenSim/Region/Communications/OGS1/OGS1InterSimComms.cs +++ b/OpenSim/Region/Communications/OGS1/OGS1InterSimComms.cs @@ -5,7 +5,7 @@ using OpenSim.Framework.Types; namespace OpenSim.Region.Communications.OGS1 { public delegate bool InformRegionChild(ulong regionHandle, AgentCircuitData agentData); - public delegate bool ExpectArrival(ulong regionHandle, LLUUID agentID, LLVector3 position); + public delegate bool ExpectArrival(ulong regionHandle, LLUUID agentID, LLVector3 position, bool isFlying); public sealed class InterRegionSingleton { @@ -39,11 +39,11 @@ namespace OpenSim.Region.Communications.OGS1 return false; } - public bool ExpectAvatarCrossing(ulong regionHandle, LLUUID agentID, LLVector3 position) + public bool ExpectAvatarCrossing(ulong regionHandle, LLUUID agentID, LLVector3 position, bool isFlying) { if (OnArrival != null) { - return OnArrival(regionHandle, agentID, position); + return OnArrival(regionHandle, agentID, position, isFlying); } return false; } @@ -69,11 +69,11 @@ namespace OpenSim.Region.Communications.OGS1 } } - public bool ExpectAvatarCrossing(ulong regionHandle, LLUUID agentID, LLVector3 position) + public bool ExpectAvatarCrossing(ulong regionHandle, LLUUID agentID, LLVector3 position, bool isFlying) { try { - return InterRegionSingleton.Instance.ExpectAvatarCrossing(regionHandle, agentID, position); + return InterRegionSingleton.Instance.ExpectAvatarCrossing(regionHandle, agentID, position, isFlying); } catch (System.Runtime.Remoting.RemotingException e) { diff --git a/OpenSim/Region/Environment/Scenes/Primitive.cs b/OpenSim/Region/Environment/Scenes/Primitive.cs index f421529..93e4959 100644 --- a/OpenSim/Region/Environment/Scenes/Primitive.cs +++ b/OpenSim/Region/Environment/Scenes/Primitive.cs @@ -587,6 +587,16 @@ namespace OpenSim.Region.Environment.Scenes #endregion + #region Inventory + public void GetInventory(IClientAPI client, uint localID) + { + if (localID == this.m_localId) + { + client.SendTaskInventory(this.m_uuid, 0, new byte[0]); + } + } + #endregion + public void UpdateExtraParam(ushort type, bool inUse, byte[] data) { this.m_Shape.ExtraParams = new byte[data.Length + 7]; diff --git a/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs b/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs index e963737..126b636 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs @@ -26,11 +26,14 @@ * */ using System; +using System.IO; using System.Collections.Generic; using libsecondlife; using libsecondlife.Packets; using OpenSim.Framework.Interfaces; using OpenSim.Framework.Types; +using OpenSim.Framework.Communications.Caches; +using OpenSim.Framework.Data; namespace OpenSim.Region.Environment.Scenes { @@ -139,7 +142,7 @@ namespace OpenSim.Region.Environment.Scenes /// public void SimChat(byte[] message, byte type, LLVector3 fromPos, string fromName, LLUUID fromAgentID) { - ScenePresence avatar = null; + ScenePresence avatar = null; if (this.Avatars.ContainsKey(fromAgentID)) { avatar = this.Avatars[fromAgentID]; @@ -343,6 +346,29 @@ namespace OpenSim.Region.Environment.Scenes } } } + + /// + /// + /// + /// + /// + public void RequestTaskInventory(IClientAPI remoteClient, uint primLocalID) + { + Primitive prim = null; + foreach (EntityBase ent in Entities.Values) + { + if (ent is SceneObject) + { + prim = ((SceneObject)ent).HasChildPrim(primLocalID); + if (prim != null) + { + prim.GetInventory(remoteClient, primLocalID); + break; + } + } + } + } + /// /// /// @@ -623,6 +649,50 @@ namespace OpenSim.Region.Environment.Scenes } /// + /// temporary method to test out creating new inventory items + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public void CreateNewInventoryItem(IClientAPI remoteClient, LLUUID transActionID, LLUUID folderID, uint callbackID, string description, string name, sbyte invType, sbyte type, byte wearableType, uint nextOwnerMask) + { + CachedUserInfo userInfo = commsManager.UserProfilesCache.GetUserDetails(remoteClient.AgentId); + if (userInfo != null) + { + AssetBase asset = new AssetBase(); + asset.Name = name; + asset.Description = description; + asset.InvType = invType; + asset.Type = type; + asset.FullID = LLUUID.Random(); + asset.Data = new byte[0]; + this.assetCache.AddAsset(asset); + + InventoryItemBase item = new InventoryItemBase(); + item.avatarID = remoteClient.AgentId; + item.creatorsID = remoteClient.AgentId; + item.inventoryID = LLUUID.Random(); + item.assetID = asset.FullID; + item.inventoryDescription = description; + item.inventoryName = name; + item.type = invType; + item.parentFolderID = folderID; + item.inventoryCurrentPermissions = 2147483647; + item.inventoryNextPermissions = nextOwnerMask; + + userInfo.ItemReceive(remoteClient.AgentId, item); + remoteClient.SendInventoryItemUpdate(item); + } + } + + /// /// Sends prims to a client /// /// Client to send to diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index 64676f0..518a53f 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs @@ -37,7 +37,7 @@ using OpenSim.Framework.Interfaces; using OpenSim.Framework.Servers; using OpenSim.Framework.Types; using OpenSim.Physics.Manager; -using OpenSim.Region.Caches; +using OpenSim.Framework.Communications.Caches; using OpenSim.Region.Environment.LandManagement; using OpenSim.Region.Scripting; using OpenSim.Region.Terrain; @@ -550,13 +550,14 @@ namespace OpenSim.Region.Environment.Scenes m_estateManager.sendRegionHandshake(client); CreateAndAddScenePresence(client); m_LandManager.sendParcelOverlay(client); - //commsManager.UserProfilesCache.AddNewUser(client.AgentId); + commsManager.UserProfilesCache.AddNewUser(client.AgentId); } protected virtual void SubscribeToClientEvents(IClientAPI client) { client.OnRegionHandShakeReply += SendLayerData; //remoteClient.OnRequestWearables += new GenericCall(this.GetInitialPrims); + client.OnModifyTerrain += ModifyTerrain; client.OnChatFromViewer += SimChat; client.OnInstantMessage += InstantMessage; client.OnRequestWearables += InformClientOfNeighbours; @@ -592,9 +593,11 @@ namespace OpenSim.Region.Environment.Scenes new ParcelObjectOwnerRequest(m_LandManager.handleParcelObjectOwnersRequest); client.OnEstateOwnerMessage += new EstateOwnerMessageRequest(m_estateManager.handleEstateOwnerMessage); - - //client.OnCreateNewInventoryFolder += commsManager.UserProfilesCache.HandleCreateInventoryFolder; + + // client.OnCreateNewInventoryItem += CreateNewInventoryItem; + // client.OnCreateNewInventoryFolder += commsManager.UserProfilesCache.HandleCreateInventoryFolder; // client.OnFetchInventoryDescendents += commsManager.UserProfilesCache.HandleFecthInventoryDescendents; + // client.OnRequestTaskInventory += RequestTaskInventory; } protected ScenePresence CreateAndAddScenePresence(IClientAPI client) @@ -819,13 +822,13 @@ namespace OpenSim.Region.Environment.Scenes } } - public void AgentCrossing(ulong regionHandle, LLUUID agentID, LLVector3 position) + public void AgentCrossing(ulong regionHandle, LLUUID agentID, LLVector3 position, bool isFlying) { if (regionHandle == m_regInfo.RegionHandle) { if (Avatars.ContainsKey(agentID)) { - Avatars[agentID].MakeAvatar(position); + Avatars[agentID].MakeAvatar(position, isFlying); } } } @@ -909,7 +912,7 @@ namespace OpenSim.Region.Environment.Scenes agent.startpos = new LLVector3(128, 128, 70); agent.child = true; commsManager.InterRegion.InformRegionOfChildAgent(regionHandle, agent); - commsManager.InterRegion.ExpectAvatarCrossing(regionHandle, remoteClient.AgentId, position); + commsManager.InterRegion.ExpectAvatarCrossing(regionHandle, remoteClient.AgentId, position, false); remoteClient.SendRegionTeleport(regionHandle, 13, reg.ExternalEndPoint, 4, (1 << 4)); } @@ -922,9 +925,9 @@ namespace OpenSim.Region.Environment.Scenes /// /// /// - public bool InformNeighbourOfCrossing(ulong regionhandle, LLUUID agentID, LLVector3 position) + public bool InformNeighbourOfCrossing(ulong regionhandle, LLUUID agentID, LLVector3 position, bool isFlying) { - return commsManager.InterRegion.ExpectAvatarCrossing(regionhandle, agentID, position); + return commsManager.InterRegion.ExpectAvatarCrossing(regionhandle, agentID, position, isFlying); } public void performParcelPrimCountUpdate() diff --git a/OpenSim/Region/Environment/Scenes/SceneBase.cs b/OpenSim/Region/Environment/Scenes/SceneBase.cs index c91c654..3c2193e 100644 --- a/OpenSim/Region/Environment/Scenes/SceneBase.cs +++ b/OpenSim/Region/Environment/Scenes/SceneBase.cs @@ -32,7 +32,7 @@ using libsecondlife; using OpenSim.Framework.Console; using OpenSim.Framework.Interfaces; using OpenSim.Framework.Types; -using OpenSim.Region.Caches; +using OpenSim.Framework.Communications.Caches; using OpenSim.Region.Terrain; using OpenSim.Framework; diff --git a/OpenSim/Region/Environment/Scenes/SceneObject.cs b/OpenSim/Region/Environment/Scenes/SceneObject.cs index 294087f..d513634 100644 --- a/OpenSim/Region/Environment/Scenes/SceneObject.cs +++ b/OpenSim/Region/Environment/Scenes/SceneObject.cs @@ -40,13 +40,8 @@ namespace OpenSim.Region.Environment.Scenes private Encoding enc = Encoding.ASCII; private Dictionary ChildPrimitives = new Dictionary(); //list of all primitive id's that are part of this group public Primitive rootPrimitive; - private new Scene m_world; protected ulong m_regionHandle; - private bool physicsEnabled = false; // HOUSEKEEPING : Do we really need this? - private PhysicsScene m_PhysScene; // HOUSEKEEPING : Do we really need this? - private PhysicsActor m_PhysActor; // HOUSEKEEPING : Do we really need this? - private EventManager m_eventManager; public bool isSelected = false; diff --git a/OpenSim/Region/Environment/Scenes/ScenePresence.cs b/OpenSim/Region/Environment/Scenes/ScenePresence.cs index 2bb4fb2..e81ac7b 100644 --- a/OpenSim/Region/Environment/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Environment/Scenes/ScenePresence.cs @@ -66,6 +66,7 @@ namespace OpenSim.Region.Environment.Scenes private IScenePresenceBody m_body; // HOUSEKEEPING : Do we really need this? protected RegionInfo m_regionInfo; + protected ulong crossingFromRegion = 0; private Vector3[] Dir_Vectors = new Vector3[6]; private enum Dir_ControlFlags @@ -183,10 +184,11 @@ namespace OpenSim.Region.Environment.Scenes /// /// /// - public void MakeAvatar(LLVector3 pos) + public void MakeAvatar(LLVector3 pos, bool isFlying) { //this.childAvatar = false; this.Pos = pos; + this._physActor.Flying = isFlying; this.newAvatar = true; this.childAgent = false; } @@ -194,8 +196,8 @@ namespace OpenSim.Region.Environment.Scenes protected void MakeChildAgent() { this.Velocity = new LLVector3(0, 0, 0); - this.Pos = new LLVector3(128, 128, 70); this.childAgent = true; + //this.Pos = new LLVector3(128, 128, 70); } /// @@ -551,11 +553,11 @@ namespace OpenSim.Region.Environment.Scenes RegionInfo neighbourRegion = this.m_world.RequestNeighbouringRegionInfo(neighbourHandle); if (neighbourRegion != null) { - bool res = this.m_world.InformNeighbourOfCrossing(neighbourHandle, this.ControllingClient.AgentId, newpos); + bool res = this.m_world.InformNeighbourOfCrossing(neighbourHandle, this.ControllingClient.AgentId, newpos, this._physActor.Flying); if (res) { - this.MakeChildAgent(); this.ControllingClient.CrossRegion(neighbourHandle, newpos, vel, neighbourRegion.ExternalEndPoint); + this.MakeChildAgent(); } } } diff --git a/OpenSim/Region/Examples/SimpleApp/MyNpcCharacter.cs b/OpenSim/Region/Examples/SimpleApp/MyNpcCharacter.cs index e64d9f0..b8e6af5 100644 --- a/OpenSim/Region/Examples/SimpleApp/MyNpcCharacter.cs +++ b/OpenSim/Region/Examples/SimpleApp/MyNpcCharacter.cs @@ -66,8 +66,10 @@ namespace SimpleApp public event NewAvatar OnNewAvatar; public event GenericCall6 OnRemoveAvatar; + public event CreateNewInventoryItem OnCreateNewInventoryItem; public event CreateInventoryFolder OnCreateNewInventoryFolder; public event FetchInventoryDescendents OnFetchInventoryDescendents; + public event FetchInventory OnFetchInventory; public event RequestTaskInventory OnRequestTaskInventory; public event UUIDNameRequest OnNameFromUUIDRequest; @@ -142,7 +144,7 @@ namespace SimpleApp public virtual void SendPrimTerseUpdate(ulong regionHandle, ushort timeDilation, uint localID, LLVector3 position, LLQuaternion rotation) { } public virtual void SendInventoryFolderDetails(LLUUID ownerID, LLUUID folderID, List items) { } - public virtual void SendInventoryItemDetails(LLUUID ownerID, LLUUID folderID, InventoryItemBase item) { } + public virtual void SendInventoryItemDetails(LLUUID ownerID, InventoryItemBase item) { } public virtual void SendInventoryItemUpdate(InventoryItemBase Item) { } public virtual void SendTaskInventory(LLUUID taskID, short serial, byte[] fileName) { } public virtual void SendNameReply(LLUUID profileId, string firstname, string lastname) { } diff --git a/OpenSim/Region/Examples/SimpleApp/MyWorld.cs b/OpenSim/Region/Examples/SimpleApp/MyWorld.cs index 6704a19..1a69e74 100644 --- a/OpenSim/Region/Examples/SimpleApp/MyWorld.cs +++ b/OpenSim/Region/Examples/SimpleApp/MyWorld.cs @@ -5,10 +5,11 @@ using OpenSim.Framework.Communications; using OpenSim.Framework.Interfaces; using OpenSim.Framework.Servers; using OpenSim.Framework.Types; -using OpenSim.Region.Caches; + using OpenSim.Region.Environment.Scenes; using OpenSim.Region.Terrain; using OpenSim.Region.Environment; +using OpenSim.Framework.Communications.Caches; using Avatar=OpenSim.Region.Environment.Scenes.ScenePresence; diff --git a/OpenSim/Region/Examples/SimpleApp/Program.cs b/OpenSim/Region/Examples/SimpleApp/Program.cs index 5c16d6b..a5bc999 100644 --- a/OpenSim/Region/Examples/SimpleApp/Program.cs +++ b/OpenSim/Region/Examples/SimpleApp/Program.cs @@ -8,10 +8,11 @@ using OpenSim.Framework.Interfaces; using OpenSim.Framework.Servers; using OpenSim.Framework.Types; using OpenSim.Physics.Manager; -using OpenSim.Region.Caches; + using OpenSim.Region.Capabilities; using OpenSim.Region.ClientStack; using OpenSim.Region.Communications.Local; +using OpenSim.Framework.Communications.Caches; using OpenSim.Region.GridInterfaces.Local; using System.Timers; using OpenSim.Region.Environment.Scenes; @@ -47,7 +48,7 @@ namespace SimpleApp { base.StartUp(); - m_commsManager = new CommunicationsLocal(m_networkServersInfo, m_httpServer); + m_commsManager = new CommunicationsLocal(m_networkServersInfo, m_httpServer, m_assetCache); m_log.Notice(m_log.LineInfo); -- cgit v1.1